MCPcopy
hub / github.com/antlr/antlr4 / parse

Method parse

tool/src/org/antlr/v4/Tool.java:648–673  ·  view source on GitHub ↗
(String fileName, CharStream in)

Source from the content-addressed store, hash-verified

646 }
647
648 public GrammarRootAST parse(String fileName, CharStream in) {
649 try {
650 GrammarASTAdaptor adaptor = new GrammarASTAdaptor(in);
651 ToolANTLRLexer lexer = new ToolANTLRLexer(in, this);
652 CommonTokenStream tokens = new CommonTokenStream(lexer);
653 lexer.tokens = tokens;
654 ToolANTLRParser p = new ToolANTLRParser(tokens, this);
655 p.setTreeAdaptor(adaptor);
656 ParserRuleReturnScope r = p.grammarSpec();
657 GrammarAST root = (GrammarAST) r.getTree();
658 if (root instanceof GrammarRootAST) {
659 ((GrammarRootAST) root).hasErrors = lexer.getNumberOfSyntaxErrors() > 0 || p.getNumberOfSyntaxErrors() > 0;
660 assert ((GrammarRootAST) root).tokenStream == tokens;
661 if (grammarOptions != null) {
662 ((GrammarRootAST) root).cmdLineOptions = grammarOptions;
663 }
664 return ((GrammarRootAST) root);
665 }
666 return null;
667 }
668 catch (RecognitionException re) {
669 // TODO: do we gen errors now?
670 ErrorManager.internalError("can't generate this message at moment; antlr recovers");
671 }
672 return null;
673 }
674
675 public void generateATNs(Grammar g) {
676 DOTGenerator dotGenerator = new DOTGenerator(g);

Callers 8

parseGrammarMethod · 0.95
loadImportedGrammarMethod · 0.95
binaryGrammarMethod · 0.45
testLookaheadTreesMethod · 0.45
testAmbiguousTreesMethod · 0.45
testInterpMethod · 0.45

Calls 3

internalErrorMethod · 0.95
getTreeMethod · 0.45

Tested by 5

binaryGrammarMethod · 0.36
testLookaheadTreesMethod · 0.36
testAmbiguousTreesMethod · 0.36
testInterpMethod · 0.36