示例#1
0
 /// <summary>
 /// Initializes a new instance of the LRkParser class with the given lexer
 /// </summary>
 /// <param name="variables">The parser's variables</param>
 /// <param name="virtuals">The parser's virtuals</param>
 /// <param name="actions">The parser's actions</param>
 /// <param name="lexer">The input lexer</param>
 protected BaseLRParser(Symbol[] variables, Symbol[] virtuals, SemanticAction[] actions, Lexer.BaseLexer lexer)
 {
     ModeRecoverErrors   = DEFAULT_MODE_RECOVER;
     ModeDebug           = DEFAULT_MODE_DEBUG;
     symVariables        = new ROList <Symbol>(new List <Symbol>(variables));
     symVirtuals         = new ROList <Symbol>(new List <Symbol>(virtuals));
     symActions          = new ROList <SemanticAction>(actions != null ? new List <SemanticAction>(actions) : new List <SemanticAction>());
     ModeRecoverErrors   = true;
     allErrors           = new List <ParseError>();
     this.lexer          = lexer;
     this.lexer.OnError += OnLexicalError;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the parser
 /// </summary>
 /// <param name="automaton">The parser's automaton</param>
 /// <param name="variables">The parser's variables</param>
 /// <param name="virtuals">The parser's virtuals</param>
 /// <param name="actions">The parser's actions</param>
 /// <param name="lexer">The input lexer</param>
 protected LRkParser(LRkAutomaton automaton, Symbol[] variables, Symbol[] virtuals, SemanticAction[] actions, Lexer.BaseLexer lexer)
     : base(variables, virtuals, actions, lexer)
 {
     this.automaton = automaton;
     stack          = new int[INIT_STACK_SIZE];
     stackIDs       = new int[INIT_STACK_SIZE];
     head           = 0;
     builder        = new LRkASTBuilder(lexer.tokens, symVariables, symVirtuals);
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the LRkParser class with the given lexer
 /// </summary>
 /// <param name="automaton">The parser's automaton</param>
 /// <param name="variables">The parser's variables</param>
 /// <param name="virtuals">The parser's virtuals</param>
 /// <param name="actions">The parser's actions</param>
 /// <param name="lexer">The input lexer</param>
 public RNGLRParser(RNGLRAutomaton automaton, Symbol[] variables, Symbol[] virtuals, SemanticAction[] actions, Lexer.BaseLexer lexer)
     : base(variables, virtuals, actions, lexer)
 {
     parserAutomaton = automaton;
     gss             = new GSS();
     sppf            = new SPPFBuilder(lexer.tokens, symVariables, symVirtuals);
     nullables       = new int[variables.Length];
     BuildNullables(variables.Length);
     sppf.ClearHistory();
 }