コード例 #1
0
ファイル: Program.cs プロジェクト: whitten/asn1scc
        public static List <Tuple <ITree, string, IToken[]> > ParseAcnInputFiles(IEnumerable <string> inputFiles)
        {
            var parsedInputFiles = new List <Tuple <ITree, string, IToken[]> >();

            foreach (var inFileName in inputFiles)
            {
                ICharStream       input  = new ANTLRFileStream(inFileName);
                acnLexer          lexer  = new acnLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lexer);

                List <IToken> tokenslst = new List <IToken>();
                foreach (IToken token in tokens.GetTokens())
                {
                    tokenslst.Add(token);
                }

                acnParser parser = new acnParser(tokens);
                acnParser.moduleDefinitions_return result = parser.moduleDefinitions();

                ITree tree = (CommonTree)result.Tree;
                CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
                nodes.TokenStream = tokens;
                parsedInputFiles.Add(Tuple.Create(tree, inFileName, tokenslst.ToArray()));
            }

            return(parsedInputFiles);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: realpsyence/asn1scc
        public static List<Tuple<ITree, string, IToken[]>> ParseAcnInputFiles(IEnumerable<string> inputFiles)
        {
            var parsedInputFiles = new List<Tuple<ITree, string, IToken[]>>();

            foreach (var inFileName in inputFiles)
            {
                ICharStream input = new ANTLRFileStream(inFileName);
                acnLexer lexer = new acnLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lexer);

                List<IToken> tokenslst = new List<IToken>();
                foreach (IToken token in tokens.GetTokens())
                {
                    tokenslst.Add(token);
                }

                acnParser parser = new acnParser(tokens);
                acnParser.moduleDefinitions_return result = parser.moduleDefinitions();

                ITree tree = (CommonTree)result.Tree;
                CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
                nodes.TokenStream = tokens;
                parsedInputFiles.Add(Tuple.Create(tree, inFileName, tokenslst.ToArray()));
            }

            return parsedInputFiles;
        }