Mercurial > pub > ImplabNet
diff Implab/Formats/JSON/JSONGrammar.cs @ 172:92d5278d1b10 ref20160224
Working on text scanner
author | cin |
---|---|
date | Mon, 14 Mar 2016 01:19:38 +0300 |
parents | e227e78d72e4 |
children | 0c3c69fe225b |
line wrap: on
line diff
--- a/Implab/Formats/JSON/JSONGrammar.cs Thu Mar 10 01:19:33 2016 +0300 +++ b/Implab/Formats/JSON/JSONGrammar.cs Mon Mar 14 01:19:38 2016 +0300 @@ -1,6 +1,7 @@ using System.Linq; using Implab.Automaton.RegularExpressions; using System; +using Implab.Automaton; namespace Implab.Formats.JSON { class JSONGrammar : Grammar<char,JSONGrammar.TokenType> { @@ -35,8 +36,8 @@ get { return _instance.Value; } } - readonly RegularCharDFADefinition<TokenType> m_jsonDFA; - readonly RegularCharDFADefinition<TokenType> m_stringDFA; + readonly RegularDFA<char, TokenType> m_jsonDFA; + readonly RegularDFA<char, TokenType> m_stringDFA; public JSONGrammar() { DefineAlphabet(Enumerable.Range(0, 0x20).Select(x => (char)x)); @@ -87,21 +88,17 @@ .Or(unescaped.Closure().Tag(TokenType.UnescapedChar)); - m_jsonDFA = new RegularCharDFADefinition<TokenType>(new CharAlphabet()); - BuildDFA(jsonExpression, m_jsonDFA, m_jsonDFA.InputAlphabet); - - - m_stringDFA = new RegularCharDFADefinition<TokenType>(new CharAlphabet()); - BuildDFA(jsonStringExpression, m_jsonDFA, m_jsonDFA.InputAlphabet); + m_jsonDFA = BuildDFA(jsonExpression); + m_stringDFA = BuildDFA(jsonStringExpression); } - public RegularCharDFADefinition<TokenType> JsonDFA { + public RegularDFA<char, TokenType> JsonDFA { get { return m_jsonDFA; } } - public RegularDFADefinition<char,TokenType> JsonStringDFA { + public RegularDFA<char,TokenType> JsonStringDFA { get { return m_stringDFA; } @@ -110,6 +107,10 @@ Token<TokenType> SymbolRangeToken(char start, char stop) { return SymbolToken(Enumerable.Range(start,stop - start).Cast<char>()); } + + protected override IAlphabetBuilder<char> CreateAlphabet() { + return new CharAlphabet(); + } } }