Mercurial > pub > ImplabNet
diff Implab/Parsing/Grammar.cs @ 158:130781364799 v2
refactoring, code cleanup
author | cin |
---|---|
date | Thu, 18 Feb 2016 14:34:02 +0300 |
parents | c0bf853aa04f |
children |
line wrap: on
line diff
--- a/Implab/Parsing/Grammar.cs Thu Feb 18 11:03:47 2016 +0300 +++ b/Implab/Parsing/Grammar.cs Thu Feb 18 14:34:02 2016 +0300 @@ -11,7 +11,6 @@ /// </summary> /// <typeparam name="TGrammar"></typeparam> public abstract class Grammar<TGrammar> where TGrammar: Grammar<TGrammar>, new() { - Alphabet m_alphabet = new Alphabet(); static TGrammar _instance; public static TGrammar Instance{ @@ -22,8 +21,14 @@ } } + readonly CharAlphabet m_alphabet = new CharAlphabet(); + + public CharAlphabet Alphabet { + get { return m_alphabet; } + } + public SymbolToken UnclassifiedToken() { - return new SymbolToken(Alphabet.UNCLASSIFIED); + return new SymbolToken(CharAlphabet.UNCLASSIFIED); } public void DefineAlphabet(IEnumerable<char> alphabet) { @@ -52,7 +57,7 @@ int TranslateOrAdd(char ch) { var t = m_alphabet.Translate(ch); - if (t == Alphabet.UNCLASSIFIED) + if (t == CharAlphabet.UNCLASSIFIED) t = m_alphabet.DefineSymbol(ch); return t; } @@ -63,7 +68,7 @@ int TranslateOrDie(char ch) { var t = m_alphabet.Translate(ch); - if (t == Alphabet.UNCLASSIFIED) + if (t == CharAlphabet.UNCLASSIFIED) throw new ApplicationException(String.Format("Symbol '{0}' is UNCLASSIFIED", ch)); return t; }