Skip to content

Commit 44644f2

Browse files
author
whitequark
committedMay 7, 2015
Add a way to run parser from command line: -m pyparser.parser foo.py
1 parent bc28d95 commit 44644f2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎pyparser/parser.py

+10
Original file line numberDiff line numberDiff line change
@@ -1386,3 +1386,13 @@ def yield_expr(self, stmt_loc, exprs):
13861386

13871387
def for_code(code, version=(2,7)):
13881388
return Parser(lexer.Lexer(source.Buffer(code), version))
1389+
1390+
if __name__ == "__main__":
1391+
import sys, time, codecs
1392+
for filename in sys.argv[1:]:
1393+
with codecs.open(filename, encoding='utf-8') as f:
1394+
start = time.time()
1395+
ast = for_code(f.read()).file_input()
1396+
interval = time.time() - start
1397+
print(ast)
1398+
print("elapsed: %.2f" % interval, file=sys.stderr)

0 commit comments

Comments
 (0)
Please sign in to comment.