-
Notifications
You must be signed in to change notification settings - Fork 63
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
Return an expression or decide how to continue #387
Comments
If I correctly understand your needs, you have a two ways to do that:
|
Good idea, thanks. integer = [0-9]+ // static rule
word = [a-z]i+ // static rule
entry = tag `${some generated rule that makes the grammar}` // dynamic rule generated through javascript code I understand it is a bit fuzzy but I am new to parser generators. Thanks for the help and patience. |
You cannot have {{
// For example, you does not use top-level initializer and
// you decide to write some code inside it for your plugin
}}
integer = [0-9]+ // static rule
word = [a-z]i+ // static rule
// dynamic rules will be injected to the AST by plugin,
// plugin take their input from `ast.topLevelInitializer` |
I'm going to close this. Please reopen if there is a concrete feature to request. |
Hello, I am rewriting a grammar from Parsimmon to Peggy and I would like to encode some behavior I have in my previous grammar.
Is there any way to decide how to continue parsing using the value of some label? In Parsimmon this is the chain function but I was wondering whether this is possible in peggy.
For example let's say I have object with type information (and this is specified somewhere else). In my parsed test I do get a name and then some type following that name.
Now, I know I can create a grammar for a limited amount of those labels but let's say the labels are many (many) and the resulting types are complex and they are specified somewhere else, outside the grammar. How do I generate dynamic grammar from the value I get, decide how to continue parsing?
The following is not valid, just a concept
if decide is integer then it expects to parse integer, if it is word then it expects to parse a word and so on.
The text was updated successfully, but these errors were encountered: