예제 #1
0
        public void SyntaxError(TextWriter textWriter, IRecognizer recogniser, IToken token, int i1, int i2,
                                string msg, RecognitionException recognitionException)
        {
            var lexeme           = Builder.GetCurrentLexeme();
            var nonCommentLexeme = Builder.GetCurrentNonCommentLexeme();

            Builder.ResetCurrentLexeme(token.TokenIndex, token.TokenIndex);
            var mark = Builder.Mark();

            Builder.Done(mark, SpringNodeType.Error, new ErrorMessage(msg, token.StopIndex - token.StartIndex + 1));
            Builder.ResetCurrentLexeme(lexeme, nonCommentLexeme);
        }
예제 #2
0
            public override Unit VisitPrimaryExpression(CParser.PrimaryExpressionContext context)
            {
                if (context.Identifier() != null)
                {
                    _builder.ResetCurrentLexeme(context.SourceInterval.a, context.SourceInterval.a);
                    var mark = _builder.Mark();
                    base.VisitChildren(context);
                    _builder.Done(mark, SpringReferenceNodeElement.NODE_TYPE, context);
                }
                else
                {
                    VisitChildren(context);
                }

                return(Unit.Instance);
            }
예제 #3
0
        public IFile ParseFile()
        {
            using (var def = Lifetime.Define())
            {
                var builder = new PsiBuilder(_lexer, SpringFileNodeType.Instance, new TokenFactory(), def.Lifetime);
                var lexer   = new ToylangLexer(new AntlrInputStream(_lexer.Buffer.GetText()));
                var parser  = new ToylangParser(new CommonTokenStream(lexer));
                parser.AddErrorListener(new SpringErrorListener(builder));
                var visitor = new NodeVisitor(builder);

                // Begin Top level File
                var fileBeginMark = builder.Mark();

                // Inner structure
                visitor.Visit(parser.file());

                // End Top level File
                builder.ResetCurrentLexeme(visitor.MaxTokenIndexConsumed, visitor.MaxTokenIndexConsumed);
                builder.Done(fileBeginMark, SpringFileNodeType.Instance, null);

                var compositeElement = builder.BuildTree();
                var file             = (IFile)compositeElement;
                return(file);
            }
        }
예제 #4
0
            public override void SyntaxError(
                TextWriter output, IRecognizer recognizer, IToken offendingSymbol,
                int line, int charPositionInLine, string msg, RecognitionException e
                )
            {
                var curLexeme           = _builder.GetCurrentLexeme();
                var curNonCommentLexeme = _builder.GetCurrentNonCommentLexeme();

                _builder.ResetCurrentLexeme(offendingSymbol.TokenIndex, offendingSymbol.TokenIndex);

                var mark   = _builder.Mark();
                var length = offendingSymbol.StopIndex - offendingSymbol.StartIndex + 1;

                _builder.Done(mark, PascalNodeTypes.Error, new PascalErrorNodeType.Message(msg, length));

                _builder.ResetCurrentLexeme(curLexeme, curNonCommentLexeme);
            }
예제 #5
0
        public override void SyntaxError(
            TextWriter output, IRecognizer recognizer, IToken offendingSymbol,
            int line, int charPositionInLine, string msg, RecognitionException e
            )
        {
            _builder.ResetCurrentLexeme(offendingSymbol.TokenIndex, offendingSymbol.TokenIndex);
            var mark   = _builder.Mark();
            var length = offendingSymbol.StopIndex - offendingSymbol.StartIndex + 1;

            _builder.Done(mark, SpringErrorNodeType.Instance, new SpringErrorNodeType.Message(msg, length));
        }
예제 #6
0
 private int _enter(int lexeme)
 {
     _psiBuilder.ResetCurrentLexeme(lexeme, lexeme);
     return(_psiBuilder.Mark());
 }
예제 #7
0
 public override void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol,
                                  int line, int charPositionInLine, string msg, RecognitionException e)
 {
     _builder.ResetCurrentLexeme(offendingSymbol.TokenIndex, offendingSymbol.TokenIndex);
     _builder.DoneBeforeWhitespaces(_builder.Mark(), SpringPsiBuilderErrorElement.NODE_TYPE, new ErrorMsgWithLengthAndType(msg, offendingSymbol.Text.Length));
 }
예제 #8
0
 private int BeginCreatingNode(int begin)
 {
     _psiBuilder.ResetCurrentLexeme(begin, begin);
     return(_psiBuilder.Mark());
 }