public ExceptionLexer(ICharStream input, IOutputStream outputStream, IErrorShow errorShow) : base(input) { IAntlrErrorListener <int> errorListener = new CMMErrorListener(outputStream, errorShow); this.RemoveErrorListeners(); this.AddErrorListener(errorListener); }
public void StaticError(String input) { try { ICharStream stream = CharStreams.fromstring(input); ITokenSource lexer = new ExceptionLexer(stream, outputStream, error); ITokenStream tokens = new CommonTokenStream(lexer); CMMParser parser = new CMMParser(tokens); parser.BuildParseTree = true; parser.RemoveErrorListeners(); CMMErrorListener errorListener = new CMMErrorListener(); errorListener.outputStream = outputStream; errorListener.errorShow = error; parser.AddErrorListener(errorListener); CMMErrorStrategy errorStrategy = new CMMErrorStrategy(); parser.ErrorHandler = errorStrategy; parser.statements(); } catch (Exception e1) { outputStream?.Print(e1.Message); } }