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
Non-greedy operators for * , + , and ? #57
Comments
Update: This could be satisfied by a repetition count (which is a generalization of my initial thought) as suggested in Google Groups at: http://groups.google.com/group/pegjs/browse_thread/thread/2bea15581be45187 |
In PEG formalism, you can easily match until a terminator by using a predicate together with the
Is that sufficient for you? |
Yes, that works perfectly. Thanks! |
@dmajda What's the recommended practice for stripping out the empty char returned by the For example:
I was able to achieve this by breaking |
#66 will fix this. I think in the mean while you can use:
|
@islandr Please don't use issues as a place to ask questions about PEG.js usage. Especially when they are closed and especially when you are asking something that other people beside me can help you with. The proper channel is the Google Group. |
Sorry David. Thought this would have been a good place since it was On Wed, Jan 9, 2013 at 9:51 PM, David Majda notifications@github.comwrote:
|
I have a language where there are repeated instances of the same pattern where I only care about the first symbol. For example:
This simple example could be matched by this pattern (where _ is whitespace):
identifier _ "OBJECT IDENTIFIER" _ "::=" _ "{" _ identifier _ number _ "}"
This isn't such a big deal in this case (I already typed the pattern :-) But the language has a set of other big hairy constructs that don't warrant the full parsing (I only want the initial identifier on each line to do the job I have in mind).
I would like to type something like this pattern:
identifier _ "OBJECT IDENTIFIER" .*? "}"
where the ".*?" is non-greedy - it only consumes to the first occurrence of the terminal. Could this be on the list for PEG.js? Many thanks.
The text was updated successfully, but these errors were encountered: