Esempio n. 1
0
 /// <summary>
 /// Initializes the specified grammar.
 /// </summary>
 /// <param name="grammar">The grammar.</param>
 public LanguageData(Grammar grammar)
 {
     Grammar     = grammar;
     GrammarData = new GrammarData(this);
     ParserData  = new ParserData(this);
     ConstructAll();
 }
Esempio n. 2
0
 public LanguageData(Grammar grammar, bool construct = true)
 {
     Grammar     = grammar;
     GrammarData = new GrammarData(this);
     ParserData  = new ParserData(this);
     ScannerData = new ScannerData(this);
     if (construct)
     {
         ConstructAll();
     }
 }
Esempio n. 3
0
 public Parser(LanguageData language, NonTerminal root)
 {
     Language = language;
     Data     = Language.ParserData;
     _grammar = Language.Grammar;
     Context  = new ParsingContext(this);
     Scanner  = new Scanner(this);
     Root     = root;
     if (Root == null)
     {
         Root         = Language.Grammar.Root;
         InitialState = Language.ParserData.InitialState;
     }
     else
     {
         if (Root != Language.Grammar.Root && !Language.Grammar.SnippetRoots.Contains(Root))
         {
             throw new Exception(string.Format(Resources.ErrRootNotRegistered, root.Name));
         }
         InitialState = Language.ParserData.InitialStates[Root];
     }
 }