@@ -64,7 +64,7 @@ def render_statement(ostream, match: rd.Match, statement: rd.Statement, indent=0
6464 ostream .write (" = %s" % statement .description )
6565 ostream .writeln ("" )
6666
67- elif isinstance (statement , (rd .AndStatement , rd . OrStatement , rd . OptionalStatement , rd . NotStatement )):
67+ elif isinstance (statement , (rd .CompoundStatement )):
6868 # emit `and:` `or:` `optional:` `not:`
6969 ostream .write (statement .type )
7070
@@ -87,7 +87,7 @@ def render_statement(ostream, match: rd.Match, statement: rd.Statement, indent=0
8787 # so, we have to inline some of the feature rendering here.
8888
8989 child = statement .child
90- value = getattr ( child , child .type )
90+ value = child . dict ( by_alias = True ). get ( child .type )
9191
9292 if value :
9393 if isinstance (child , frzf .StringFeature ):
@@ -211,12 +211,12 @@ def render_match(ostream, match: rd.Match, indent=0, mode=MODE_SUCCESS):
211211 return
212212
213213 # 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 :
215215 if not any (map (lambda m : m .success , match .children )):
216216 return
217217
218218 # 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 :
220220 child_mode = MODE_FAILURE
221221
222222 elif mode == MODE_FAILURE :
@@ -225,12 +225,12 @@ def render_match(ostream, match: rd.Match, indent=0, mode=MODE_SUCCESS):
225225 return
226226
227227 # 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 :
229229 if any (map (lambda m : m .success , match .children )):
230230 return
231231
232232 # 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 :
234234 child_mode = MODE_SUCCESS
235235 else :
236236 raise RuntimeError ("unexpected mode: " + mode )
0 commit comments