@@ -64,7 +64,7 @@ def render_statement(ostream, match: rd.Match, statement: rd.Statement, indent=0
64
64
ostream .write (" = %s" % statement .description )
65
65
ostream .writeln ("" )
66
66
67
- elif isinstance (statement , (rd .AndStatement , rd . OrStatement , rd . OptionalStatement , rd . NotStatement )):
67
+ elif isinstance (statement , (rd .CompoundStatement )):
68
68
# emit `and:` `or:` `optional:` `not:`
69
69
ostream .write (statement .type )
70
70
@@ -87,7 +87,7 @@ def render_statement(ostream, match: rd.Match, statement: rd.Statement, indent=0
87
87
# so, we have to inline some of the feature rendering here.
88
88
89
89
child = statement .child
90
- value = getattr ( child , child .type )
90
+ value = child . dict ( by_alias = True ). get ( child .type )
91
91
92
92
if value :
93
93
if isinstance (child , frzf .StringFeature ):
@@ -211,12 +211,12 @@ def render_match(ostream, match: rd.Match, indent=0, mode=MODE_SUCCESS):
211
211
return
212
212
213
213
# optional statement with no successful children is empty
214
- if isinstance (match .node , rd .StatementNode ) and isinstance ( match .node .statement , rd .OptionalStatement ) :
214
+ if isinstance (match .node , rd .StatementNode ) and match .node .statement . type == rd .CompoundStatementType . OPTIONAL :
215
215
if not any (map (lambda m : m .success , match .children )):
216
216
return
217
217
218
218
# not statement, so invert the child mode to show failed evaluations
219
- if isinstance (match .node , rd .StatementNode ) and isinstance ( match .node .statement , rd .NotStatement ) :
219
+ if isinstance (match .node , rd .StatementNode ) and match .node .statement . type == rd .CompoundStatementType . NOT :
220
220
child_mode = MODE_FAILURE
221
221
222
222
elif mode == MODE_FAILURE :
@@ -225,12 +225,12 @@ def render_match(ostream, match: rd.Match, indent=0, mode=MODE_SUCCESS):
225
225
return
226
226
227
227
# optional statement with successful children is not relevant
228
- if isinstance (match .node , rd .StatementNode ) and isinstance ( match .node .statement , rd .OptionalStatement ) :
228
+ if isinstance (match .node , rd .StatementNode ) and match .node .statement . type == rd .CompoundStatementType . OPTIONAL :
229
229
if any (map (lambda m : m .success , match .children )):
230
230
return
231
231
232
232
# not statement, so invert the child mode to show successful evaluations
233
- if isinstance (match .node , rd .StatementNode ) and isinstance ( match .node .statement , rd .NotStatement ) :
233
+ if isinstance (match .node , rd .StatementNode ) and match .node .statement . type == rd .CompoundStatementType . NOT :
234
234
child_mode = MODE_SUCCESS
235
235
else :
236
236
raise RuntimeError ("unexpected mode: " + mode )
0 commit comments