示例#1
0
        public VbaParseResult CompileSource(TextReader source, Func <VbaParser, ParserRuleContext> rule)
        {
            var headerReader = new ModuleHeaderTextReader(source);
            var preprocessor = new SourceTextReader(headerReader);
            var input        = new AntlrInputStream(preprocessor);
            var lexer        = new VbaLexer(input);
            var proxy        = new LineAdjustProxy(lexer, () => headerReader.Line);
            var tokens       = new CommonTokenStream(proxy);
            var parser       = new VbaParser(tokens);

            return(new VbaParseResult(rule(parser), parser));
        }
示例#2
0
        internal static VbaParser BuildVbaParser(string source)
        {
            var errorHandler = new TestErrorListener();

            var input = new AntlrInputStream(source);

            var lexer = new VbaLexer(input);

            lexer.AddErrorListener(errorHandler);

            var tokens = new CommonTokenStream(lexer);

            var parser = new VbaParser(tokens);

            parser.AddErrorListener(errorHandler);
            parser.AddErrorListener(new DiagnosticErrorListener());
            parser.ErrorHandler = new BailErrorStrategy();
            return(parser);
        }
示例#3
0
 internal VbaParseResult(ParserRuleContext result, VbaParser parser)
 {
     _result = result;
     _parser = parser;
 }