/// <summary> /// /// </summary> /// <param name="grammar">Content of grammar-file</param> /// <param name="lexer"></param> /// <param name="TerminalNames">Names of terminals</param> /// <param name="assemblies">Array of assemblies where framewrok will search for types and methods used in "grammar"</param> /// <exception cref="LeftRecursionGrammarException"></exception> public LL1GrammarParser(string grammar, ILexer <UToken> lexer, IDictionary <string, UToken> TerminalNames, System.Reflection.Assembly[] assemblies) { // grammar parsing using GrammarDefinitionParser Initialization.Lexer grammar_lexer = new Lexer(); IList <AbstractToken> tokens = grammar_lexer.Tokenize(grammar); GrammarCreator creator = new GrammarCreator(new REEvaluator(), new AssembliesAccessWrapper(assemblies)); foreach (var name_term in TerminalNames) { creator.RegisterTerminal(name_term.Key, name_term.Value); } GrammarDefinitionParser.ParseGrammarBase(tokens, ref creator); Parser = new RecursiveDescentParser <UToken>(creator.Create()); Lexer = lexer ?? throw new ArgumentNullException("Lexer is null"); }
internal AbstractParser(GrammarCreator gc) { Grammar = gc.Create(); }