1- # Copyright (c) 2015-2019, 2021-2022 by Rocky Bernstein
1+ # Copyright (c) 2015-2019, 2021-2023 by Rocky Bernstein
22#
33# This program is free software: you can redistribute it and/or modify
44# it under the terms of the GNU General Public License as published by
@@ -1169,11 +1169,14 @@ def build_ast(
11691169 self .p .insts = self .scanner .insts
11701170 self .p .offset2inst_index = self .scanner .offset2inst_index
11711171 ast = python_parser .parse (self .p , tokens , customize , code )
1172+ self .customize (customize )
11721173 self .p .insts = p_insts
1174+
11731175 except (python_parser .ParserError , AssertionError ) as e :
11741176 raise ParserError (e , tokens )
1177+ transform_tree = self .treeTransform .transform (ast , code )
11751178 maybe_show_tree (self , ast )
1176- return ast
1179+ return transform_tree
11771180
11781181 # The bytecode for the end of the main routine has a
11791182 # "return None". However you can't issue a "return" statement in
@@ -1199,23 +1202,28 @@ def build_ast(
11991202 if len (tokens ) == 0 :
12001203 return PASS
12011204
1202- # Build parse tree from tokenized and massaged disassembly.
1205+ # Build a parse tree from tokenized and massaged disassembly.
12031206 try :
12041207 # FIXME: have p.insts update in a better way
12051208 # modularity is broken here
12061209 p_insts = self .p .insts
12071210 self .p .insts = self .scanner .insts
12081211 self .p .offset2inst_index = self .scanner .offset2inst_index
1212+ self .p .opc = self .scanner .opc
12091213 ast = parser .parse (self .p , tokens , customize , code )
12101214 self .p .insts = p_insts
1211- except (parser .ParserError , AssertionError ) as e :
1215+ except (python_parser .ParserError , AssertionError ) as e :
12121216 raise ParserError (e , tokens , {})
12131217
1214- maybe_show_tree (self , ast )
1215-
12161218 checker (ast , False , self .ast_errors )
12171219
1218- return ast
1220+ self .customize (customize )
1221+ transform_tree = self .treeTransform .transform (ast , code )
1222+
1223+ maybe_show_tree (self , ast )
1224+
1225+ del ast # Save memory
1226+ return transform_tree
12191227
12201228 # FIXME: we could provide another customized routine
12211229 # that fixes up parents along a particular path to a node that
0 commit comments