public static List <Tuple <ITree, string, IToken[]> > ParseAsn1InputFiles(IEnumerable <string> inputFiles) { var parsedInputFiles = new List <Tuple <ITree, string, IToken[]> >(); foreach (var inFileName in inputFiles) { ICharStream input = new ANTLRFileStream(inFileName); asn1Lexer lexer = new asn1Lexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); List <IToken> tokenslst = new List <IToken>(); foreach (IToken token in tokens.GetTokens()) { tokenslst.Add(token); } asn1Parser parser = new asn1Parser(tokens); asn1Parser.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); }
public static List<Tuple<ITree, string, IToken[]>> ParseAsn1InputFiles(IEnumerable<string> inputFiles) { var parsedInputFiles = new List<Tuple<ITree, string, IToken[]>>(); foreach (var inFileName in inputFiles) { ICharStream input = new ANTLRFileStream(inFileName); asn1Lexer lexer = new asn1Lexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); List<IToken> tokenslst = new List<IToken>(); foreach (IToken token in tokens.GetTokens()) { tokenslst.Add(token); } asn1Parser parser = new asn1Parser(tokens); asn1Parser.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; }