-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite parser generator #84
base: main
Are you sure you want to change the base?
Rewrite parser generator #84
Conversation
220a632
to
5471713
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good attempt
Also, if you are using someone else's ideas or code it's nice to mention them
@final | ||
class NotParsedMarker(Enum): | ||
marker = 0 | ||
|
||
|
||
not_parsed = NotParsedMarker.marker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use object()
and it'll give the same effect
Also @final
doesn't do a lot, It's better to just use Literal[not_parsed]
for annotations
| ENDMARKER { None } | ||
| ENDMARKER { [] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change was made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None is now a valid result but we expect a list to be returned there.
return not ok | ||
return not_parsed if ok is not not_parsed else True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool check is more than enough here and in positive_lookahead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, False
now a correct parsing result. For mark incorrect parsing result we always should use not_parsed
.
I don't use any another idea. I just improved my last attempt. Now |
@MatthieuDartiailh, please look at pull request. |
48d9637
to
5471713
Compare
5aae014
to
3cefc85
Compare
What does this pull request do?
This pull request changes what we consider successful parsing. Now we have the
not_parsed
marker (the name can be changed) which mark that rule can't parse input. This solves the problem with empty collections being interpreted as parsing failure and also allows you to drag None up. Unfortunately this is a very big change. Parsers generated by the previous version will not work. However, this solves all problems.