示例#1
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);
            }
        }
示例#2
0
 public SpringLexer(IBuffer buffer)
 {
     Buffer             = buffer;
     _currentPosition   = 0;
     _toyLangAntlrLexer = new ToylangLexer(new AntlrInputStream(buffer.GetText()));
 }