-
Notifications
You must be signed in to change notification settings - Fork 65
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
Implementation of the ranges (with delimiters) #291
Conversation
What if there was a way to define parser-functions, and it would be just I think by creating a new syntax for every feature it will resemble Perl and its regular expressions quite soon (arguably, it already resembles it way too much). The thing not mentioned in PR description, but probably the most awaited by me, is delimited repetition (
|
|
I think we will soon need to determine what our long-term syntax extensibility approach is, before we run out of adequate syntax to act as the extensibility point. I don't think |
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.
I'm sorry this took so long to get to.
The only substantive thing here is to figure out what happens with names being passed to nested repeats.
Once we get that nailed, and get this rebased, I'm ready to land it and start working toward a release.
@Mingun do you have time to work on this? If not, I'll try to rebase it at least. |
I'll look at weekend |
``` expression| exact | expression| .. | expression|min.. | expression| ..max| expression|min..max| ``` Introduce two new opcodes: * IF_LT <min>, <then part length>, <else part length> * IF_GE <max>, <then part length>, <else part length> Introduce a new AST node -- `repeated`, that contains expression and the minimum and maximum number of it repetition. If `node.min.value` is `null` or isn't positive -- check of the minimum length isn't made. If `node.max.value` is `null`, check of the maximum length isn't made. If `node.min` is `null` then it is equals to the `node.max` (exact repetitions case)
Added two new opcodes: - IF_LT_DYNAMIC: same as IF_LT, but the argument is a reference to the stack variable instead of constant - IF_GE_DYNAMIC: same as IF_GE, but the argument is a reference to the stack variable instead of constant
…ries and regenerate parser
Ok, the bug seems to be fixed, I'll check it once again on this week and add a changelog entry for plugins' authors. |
The diff between the 7-month old version and the current:
All done, ready for merge. |
This is fantastic work. Thank you very much. I'm going to merge as-is, then when I do a full review of the documentation page, there may be a few nits I clean up while fixing other things. |
Reincarnation of the pegjs/pegjs#209.
Previous attempt, closed by technical reasons: #208
This is an implementation of the ranges proposal with batteries, i.e.:
The syntax chosen saves the
<
and>
characters for the template definitions where their are more natural.[
and]
already used for character class definitions and(
and)
already used for grouping.