}//ParseAll method public ParseTree ScanOnly(string sourceText, string fileName) { Context.CurrentParseTree = new ParseTree(sourceText, fileName); Context.Source = new SourceStream(sourceText, Language.Grammar.CaseSensitive, Context.TabWidth); while (true) { var token = Scanner.GetToken(); if (token == null || token.Terminal == Language.Grammar.Eof) { break; } } return(Context.CurrentParseTree); }
public void ReadInput() { Token token; Terminal term; //Get token from scanner while skipping all comment tokens (but accumulating them in comment block) do { token = Scanner.GetToken(); term = token.Terminal; if (term.Category == TokenCategory.Comment) { Context.CurrentCommentTokens.Add(token); } } while (term.Flags.IsSet(TermFlags.IsNonGrammar) && term != _grammar.Eof); //Check brace token if (term.Flags.IsSet(TermFlags.IsBrace) && !CheckBraceToken(token)) { token = new Token(_grammar.SyntaxError, token.Location, token.Text, string.Format(Resources.ErrUnmatchedCloseBrace, token.Text)); } //Create parser input node Context.CurrentParserInput = new ParseTreeNode(token); //attach comments if any accumulated to content token if (token.Terminal.Category == TokenCategory.Content) { Context.CurrentParserInput.Comments = Context.CurrentCommentTokens; Context.CurrentCommentTokens = new TokenList(); } //Fire event on Terminal token.Terminal.OnParserInputPreview(Context); }
public ParseTree ScanOnly(string sourceText, string fileName) { Context.CurrentParseTree = new ParseTree(sourceText, fileName); Context.SourceStream.SetText(sourceText, 0, false); while (true) { var token = Scanner.GetToken(); if (token == null || token.Terminal == Language.Grammar.Eof) { break; } } return(Context.CurrentParseTree); }