Skip to content

Commit

Permalink
Add a way to run parser from command line: -m pyparser.parser foo.py
Browse files Browse the repository at this point in the history
whitequark committed May 7, 2015
1 parent bc28d95 commit 44644f2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pyparser/parser.py
Original file line number Diff line number Diff line change
@@ -1386,3 +1386,13 @@ def yield_expr(self, stmt_loc, exprs):

def for_code(code, version=(2,7)):
return Parser(lexer.Lexer(source.Buffer(code), version))

if __name__ == "__main__":
import sys, time, codecs
for filename in sys.argv[1:]:
with codecs.open(filename, encoding='utf-8') as f:
start = time.time()
ast = for_code(f.read()).file_input()
interval = time.time() - start
print(ast)
print("elapsed: %.2f" % interval, file=sys.stderr)

0 comments on commit 44644f2

Please sign in to comment.