private void NextToken() { _currentToken = ReadToken(); if (_currentToken == null) _currentToken = TokenAst.Create(LRParser.Eof, _context, new SourceLocation(0, _currentLine - 1, 0), string.Empty); }
public ScriptForEachStatement(AstNodeArgs args) : base(args) { _name = (TokenAst)ChildNodes[1]; _expr = (ScriptExpr)ChildNodes[3]; _statement = (ScriptStatement)ChildNodes[4]; }
public void Prepare(CompilerContext context, ISourceStream source) { _context = context; _source = source; _currentToken = null; _bufferedTokens.Clear(); ResetSource(); }
public IEnumerable<TokenAst> BeginScan() { while (true) { _currentToken = ReadToken(); yield return _currentToken; if (_currentToken.Terminal == LRParser.Eof) yield break; } }
public ScriptConstExpr(AstNodeArgs args) : base(args) { TokenAst constant = (TokenAst)ChildNodes[0]; Value = constant.Value; if (constant.IsKeyword) { if (Value.Equals("true")) { Value = true; } else if (Value.Equals("false")) { Value = false; } else if (Value.Equals("null")) { Value = null; } } }
private ParserActionType GetActionTypeForOperation(TokenAst current) { ITerminal thisTerm = current.Terminal; for (int i = _stack.Count - 2; i >= 0; i--) { if (_stack[i].Node == null) continue; IGrammarTerm term = _stack[i].Node.Term; if (!term.IsSet(TermOptions.IsOperator)) continue; ITerminal prevTerm = term as ITerminal; if (prevTerm.Precedence == thisTerm.Precedence) return thisTerm.Associativity == Associativity.Left ? ParserActionType.Reduce : ParserActionType.Shift; ParserActionType result = prevTerm.Precedence > thisTerm.Precedence ? ParserActionType.Reduce : ParserActionType.Shift; return result; } return ParserActionType.Shift; }