_ast = y_tab.yyparse(t_def.AST)
#element.serialize(_ast, 'a.xml', 'utf-8')
#_ast = element.deserialize('a.xml', t_def.factory, 'utf-8')
- _ast.post_process()
+ _ast.post_process(python)
#element.serialize(_ast, 'b.xml', 'utf-8')
#_ast = element.deserialize('b.xml', t_def.factory, 'utf-8')
(generate_py if python else generate_flex)(
self.children[2] # action
)
@method(AST)
-def post_process(self):
+def post_process(self, python):
# variables that will be serialized
self.start_conditions = [
AST.StartCondition(
]
self.actions_text = []
self.eof_actions_text = [
- AST.Text(text = ['\t\t\t\tyyterminate();\n'])
+ AST.Text(
+ text = [
+ '\t\t\t\tyyterminate()\n'
+ if python else
+ '\t\t\t\tyyterminate();\n'
+ ]
+ )
]
self.flex_rules = []
self.n_groups = 0
self.actions_text.append(
AST.Text(
text = [
- 'ECHO;\n'
+ (
+ 'ECHO()\n'
+ if python else
+ 'ECHO;\n'
+ )
if self.children[0].default else
- 'YY_FATAL_ERROR( "flex scanner jammed" );\n'
+ (
+ 'YY_FATAL_ERROR( "flex scanner jammed" )\n'
+ if python else
+ 'YY_FATAL_ERROR( "flex scanner jammed" );\n'
+ )
]
)
)