public IListSource<LNode> Parse(IListSource<Token> input, ISourceFile file, IMessageSink msgs, Symbol inputType = null) { // For efficiency we'd prefer to re-use our _parser object, but // when parsing lazily, we can't re-use it because another parsing // operation could start before this one is finished. To force // greedy parsing, we can call ParseStmtsGreedy(), but the caller may // prefer lazy parsing, especially if the input is large. As a // compromise I'll check if the source file is larger than a // certain arbitrary size. Also, ParseExprs() is always greedy // so we can always re-use _parser in that case. bool exprMode = inputType == ParsingService.Exprs; char _ = '\0'; if (inputType == ParsingService.Exprs || file.Text.TryGet(255, ref _)) { LesParser parser = _parser; if (parser == null) _parser = parser = new LesParser(input, file, msgs); else { parser.ErrorSink = msgs; parser.Reset(input.AsList(), file); } if (inputType == ParsingService.Exprs) return parser.ExprList(); else return parser.Start(new Holder<TokenType>(TokenType.Semicolon)).Buffered(); } else { var parser = new LesParser(input, file, msgs); return parser.Start(new Holder<TokenType>(TokenType.Semicolon)).Buffered(); } }
public IListSource <LNode> Parse(IListSource <Token> input, ISourceFile file, IMessageSink msgs, ParsingMode inputType = null) { // For efficiency we'd prefer to re-use our _parser object, but // when parsing lazily, we can't re-use it because another parsing // operation could start before this one is finished. To force // greedy parsing, we can call ParseStmtsGreedy(), but the caller may // prefer lazy parsing, especially if the input is large. As a // compromise I'll check if the source file is larger than a // certain arbitrary size. Also, ParseExprs() is always greedy // so we can always re-use _parser in that case. bool exprMode = inputType == ParsingMode.Expressions; char _ = '\0'; if (inputType == ParsingMode.Expressions || file.Text.TryGet(255, ref _)) { Les3Parser parser = _parser; if (parser == null) { _parser = parser = new Les3Parser(input.AsList(), file, msgs); } else { parser.ErrorSink = msgs; parser.Reset(input.AsList(), file); } if (inputType == ParsingMode.Expressions) { return(parser.Start(new Holder <TokenType>(default(TokenType))).Buffered()); } else { return(parser.Start(new Holder <TokenType>(TokenType.Semicolon)).Buffered()); } } else { var parser = new Les3Parser(input.AsList(), file, msgs); return(parser.Start(new Holder <TokenType>(TokenType.Semicolon)).Buffered()); } }
public Les2Parser(IListSource <Token> tokens, ISourceFile file, IMessageSink messageSink) : this(tokens.AsList(), file, messageSink) { }