File tree Expand file tree Collapse file tree 4 files changed +222
-106
lines changed
Expand file tree Collapse file tree 4 files changed +222
-106
lines changed Original file line number Diff line number Diff line change 1+
2+ import ast
3+ import sys
4+
5+ filename = sys .argv [1 ]
6+ print ('Crawling file:' , filename )
7+
8+
9+ with open (filename , 'r' ) as f :
10+ source = f .read ()
11+
12+ t = ast .parse (source )
13+ print (t )
14+
15+ shift = 3
16+ def print_node (node , indent = 0 ):
17+ if isinstance (node , ast .AST ):
18+ print (' ' * indent , "NODE" , node .__class__ .__name__ )
19+ for field in node ._fields :
20+ print (' ' * indent ,'-' , field )
21+ f = getattr (node , field )
22+ if isinstance (f , list ):
23+ for f2 in f :
24+ print_node (f2 , indent = indent + shift )
25+ else :
26+ print_node (f , indent = indent + shift )
27+ else :
28+ print (' ' * indent , 'OBJ' , node )
29+
30+ print_node (t )
31+
32+ # print(ast.dump(t))
33+
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ pub enum Statement {
5555 Break ,
5656 Continue ,
5757 Return {
58- value : Option < Box < Expression > > ,
58+ value : Option < Expression > ,
5959 } ,
6060 Import {
6161 import_parts : Vec < SingleImport > ,
Original file line number Diff line number Diff line change @@ -168,10 +168,10 @@ FlowStatement: ast::LocatedStatement = {
168168 node: ast::Statement::Continue,
169169 }
170170 },
171- <loc:@L> "return" <t :TestList?> => {
171+ <loc:@L> "return" <value :TestList?> => {
172172 ast::LocatedStatement {
173173 location: loc,
174- node: ast::Statement::Return { value: t.map(Box::new) },
174+ node: ast::Statement::Return { value },
175175 }
176176 },
177177 <loc:@L> <y:YieldExpr> => {
You can’t perform that action at this time.
0 commit comments