public IFile ParseFile()
        {
            using (var lifetimeDefinition = Lifetime.Define())
            {
                var builder    = new PsiBuilder(_lexer, GherkinNodeTypes.FILE, null, lifetimeDefinition.Lifetime);
                var fileMarker = builder.Mark();

                while (!builder.Eof())
                {
                    var tokenType = builder.GetTokenType();

                    if (tokenType == GherkinTokenTypes.FEATURE_KEYWORD)
                    {
                        ParseFeature(builder);
                    }
                    else if (tokenType == GherkinTokenTypes.TAG)
                    {
                        ParseTags(builder);
                    }
                    else if (tokenType == GherkinTokenTypes.COMMENT)
                    {
                        ParseComments(builder);
                    }
                    else
                    {
                        builder.AdvanceLexer();
                    }
                }

                builder.Done(fileMarker, GherkinNodeTypes.FILE, new GherkinFile.FileMetadata(_sourceFile?.Name, _lang));
                var resultTree = (GherkinFile)builder.BuildTree();

                return(resultTree);
            }
        }
Example #2
0
        public IFile ParseFile()
        {
            using (var def = Lifetime.Define())
            {
                var builder  = new PsiBuilder(myLexer, SpringFileNodeType.Instance, new TokenFactory(), def.Lifetime);
                var fileMark = builder.Mark();

                StringBuilder b = new StringBuilder();
                foreach (var tok in myLexer.Tokens())
                {
                    b.Append(tok + " ");
                }

                b.ToString();

                ParseDefines(builder);

                builder.Done(fileMark, SpringFileNodeType.Instance, null);
                var file = (IFile)builder.BuildTree();

                SprintTreeScopeUtl.InitScopes(file);

                var sb = new StringBuilder();
                DebugUtil.DumpPsi(new StringWriter(sb), file);
                sb.ToString();

                return(file);
            }
        }
Example #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);
            }
        }
Example #4
0
        public IFile ParseFile()
        {
            using (var def = Lifetime.Define())
            {
                var builder  = new PsiBuilder(myLexer, SpringFileNodeType.Instance, new TokenFactory(), def.Lifetime);
                var fileMark = builder.Mark();

                ParseBlock(builder);

                builder.Done(fileMark, SpringFileNodeType.Instance, null);
                var file = (IFile)builder.BuildTree();
                return(file);
            }
        }
Example #5
0
 public IFile ParseFile()
 {
     using (var def = Lifetime.Define())
     {
         var builder  = new PsiBuilder(myLexer, SpringFileNodeType.Instance, new TokenFactory(), def.Lifetime);
         var fileMark = builder.Mark();
         ParseSeq(builder);
         builder.Done(fileMark, SpringFileNodeType.Instance, null);
         var file          = (IFile)builder.BuildTree();
         var stringBuilder = new StringBuilder();
         DebugUtil.DumpPsi(new StringWriter(stringBuilder), file);
         stringBuilder.ToString();
         return(file);
     }
 }
Example #6
0
        public IFile ParseFile()
        {
            using (var def = Lifetime.Define())
            {
                var builder  = new PsiBuilder(myLexer, SpringFileNodeType.Instance, new TokenFactory(), def.Lifetime);
                var fileMark = builder.Mark();

                var parser = new CParser(new CommonTokenStream(new CLexer(new AntlrInputStream(myLexer.Buffer.GetText()))));
                parser.AddErrorListener(new ErrorListener(builder));
                new Visitor(builder).Visit(parser.compilationUnit());

                builder.Done(fileMark, SpringFileNodeType.Instance, null);
                var file = (IFile)builder.BuildTree();
                return(file);
            }
        }
Example #7
0
        public IFile ParseFile()
        {
            using (var def = Lifetime.Define())
            {
                var builder = new PsiBuilder(new PascalLexer(_lexer.Buffer), PascalNodeTypes.File, new TokenFactory(), def.Lifetime);

                var parser = new GPascalParser(new CommonTokenStream(new GPascalLexer(new AntlrInputStream(new BufferTextReader(_lexer.Buffer)))));
                parser.AddErrorListener(new PascalErrorListener(builder));

                var fileMark = builder.Mark();
                new PascalParserVisitor(builder).Visit(parser.program());
                builder.Done(fileMark, PascalNodeTypes.File, null);

                var file = (IFile)builder.BuildTree();
                return(file);
            }
        }
Example #8
0
        public IFile ParseFile()
        {
            using (var def = Lifetime.Define())
            {
                var builder = new PsiBuilder(new HaskellLexer(_lexer.Buffer), HaskellCompositeNodeType.FILE,
                                             new TokenFactory(), def.Lifetime);

                var parser =
                    new GHaskellParser(
                        new CommonTokenStream(
                            new GHaskellLexer(new AntlrInputStream(new BufferTextReader(_lexer.Buffer)))));
                parser.AddErrorListener(new HaskellErrorListener(builder));

                var fileMark = builder.Mark();
                new HaskellParserVisitor(builder).Visit(parser.module());
                builder.Done(fileMark, HaskellCompositeNodeType.FILE, null);

                var file = (IFile)builder.BuildTree();
                return(file);
            }
        }
Example #9
0
        public IFile ParseFile()
        {
            using (var def = Lifetime.Define())
            {
                var builder = new PsiBuilder(new CILexer(myLexer.Buffer), SpringFileNodeType.Instance, new TokenFactory(), def.Lifetime);

                string  inputText   = myLexer.Buffer.GetText();
                var     tokenStream = new CommonTokenStream(new CLexer(new AntlrInputStream(inputText)));
                CParser cParser     = new CParser(tokenStream);
                cParser.AddErrorListener(new ParserErrorListener(builder));
                var visitor = new BuilderVisitor(builder);

                var fileMark = builder.Mark();

                CParser.CompilationUnitContext fileContext = cParser.compilationUnit();
                visitor.Visit(fileContext);

                builder.Done(fileMark, SpringFileNodeType.Instance, null);
                var file = (IFile)builder.BuildTree();
                return(file);
            }
        }
Example #10
0
        public IFile ParseFile()
        {
            using (var def = Lifetime.Define())
            {
                var builder  = new PsiBuilder(myLexer, SpringFileNodeType.Instance, new TokenFactory(), def.Lifetime);
                var fileMark = builder.Mark();

                // ParseBlock(builder);
                // ParseExpression(builder);
                ParseCompoundStmt(builder);

                builder.Done(fileMark, SpringFileNodeType.Instance, null);

                if (!builder.Eof())
                {
                    builder.Error("Unexpected token");
                }

                var file = (IFile)builder.BuildTree();
                return(file);
            }
        }
Example #11
0
        public IFile ParseFile()
        {
            using (var def = Lifetime.Define())
            {
                var builder = new PsiBuilder(myLexer, SpringFileNodeType.Instance, new TokenFactory(), def.Lifetime);

                SpringLangLexer  antlrLexer  = new SpringLangLexer(new AntlrInputStream(myLexer.Buffer.GetText()));
                SpringLangParser antlrParser = new SpringLangParser(new CommonTokenStream(antlrLexer));

                BuilderVisitor visitor = new BuilderVisitor(builder);

                visitor.Visit(antlrParser.program());

                // ParseBlock(builder);

                var file = (IFile)builder.BuildTree();

                var stringBuilder = new StringBuilder();
                DebugUtil.DumpPsi(new StringWriter(stringBuilder), file);
                stringBuilder.ToString();

                return(file);
            }
        }