MCPcopy Create free account
hub / github.com/antlr/codebuff / main

Function main

python/src/dump_java_features.py:30–45  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

28
29
30def main(argv):
31 if len(argv)>1:
32 input = FileStream(argv[1])
33 else:
34 input = InputStream(sample)
35 lexer = JavaLexer(input)
36 stream = CommonTokenStream(lexer)
37 parser = JavaParser(stream)
38 tree = parser.compilationUnit()
39 # print(Trees.toStringTree(tree, None, parser))
40 print "Grammar %s has %d rules, %d tokens" % (parser.grammarFileName, len(parser.ruleNames), len(lexer.ruleNames))
41 print ', '.join(CollectTokenFeatures.feature_names)
42 token_features = CollectTokenFeatures(stream)
43 walker = ParseTreeWalker()
44 walker.walk(token_features, tree)
45 print token_features.feature_names
46
47if __name__ == '__main__':
48 main(sys.argv)

Callers 1

Calls 3

joinMethod · 0.45
walkMethod · 0.45

Tested by

no test coverage detected