Open heckad opened 1 year ago
stmt*
have a value of None
if no stmt
was found.
I haven't checked i, but it think that stmts
returns None
and block
doesn't handle it
An easy, but possible problematic way to solve this is recursively checking expressions until we find single Repeat
A possibly more compilated way to solve this is to properly handle this is stmts
I will look into that
Unfortunately here we need a more general indicator of a failure
The problem with using None
is that if user wants to return it:
start: stmts
stmts: r=stmt* { None if not r else r }
stmt: block
block: "{" stmts "}"
I haven't checked i, but it think that stmts returns None and block doesn't handle it
stmts returns an empty array not None. And that is interpreted as False. None is a good marker.
stmts returns an empty array not None
Yes, initially i was wrong about it
Gram file
Input
Result
The problem in the generated parse rule for the
block
stmt Code(stmts := self.stmts())
shoud be(stmts := self.stmts()) is not None
because an empty array is interpreted as false.