/// <summary> /// Parses the current file contents to get the AST, tokens, /// and parse errors. /// </summary> private void ParseFileContents() { // ParseError[] parseErrors = null; // First, get the updated file range int lineCount = this.FileLines.Count; if (lineCount > 0) { NoCaseAntlrStringStream input = new NoCaseAntlrStringStream(this.Contents); AdvplLexer lexer = new AdvplLexer(input); CommonTokenStream commonTokenStream = new CommonTokenStream(lexer); AdvplParser advplParser = new AdvplParser(commonTokenStream); advplParser.RemoveErrorListeners(); AdvplErrorListener errorListener = new AdvplErrorListener(); advplParser.AddErrorListener(errorListener); ParserRuleContext tree = advplParser.program(); //Cria a tabela de symbolo SymbolTableDefPhase tableSymbolList = new SymbolTableDefPhase(); ParseTreeWalker walkerGeneral = new ParseTreeWalker(); walkerGeneral.Walk(tableSymbolList, tree); // Translate parse errors into syntax markers this.SyntaxMarkers = errorListener.getErros().Select(ScriptFileMarker.FromAdvplError) .ToArray(); } /* * this.FileRange = * new BufferRange( * new BufferPosition(1, 1), * new BufferPosition( * lineCount + 1, * this.FileLines[lineCount - 1].Length + 1)); * } * else * { * this.FileRange = BufferRange.None; * } * * try * { * this.ScriptAst = * Parser.ParseInput( * this.Contents, * out this.scriptTokens, * out parseErrors); * * } * catch (RuntimeException ex) * { * var parseError = * new ParseError( * null, * ex.ErrorRecord.FullyQualifiedErrorId, * ex.Message); * * parseErrors = new[] { parseError }; * this.scriptTokens = new Token[0]; * this.ScriptAst = null; * } */ /* * //Get all dot sourced referenced files and store them * this.ReferencedFiles = * AstOperations.FindDotSourcedIncludes(this.ScriptAst); * }*/ }