Closed bson closed 6 years ago
Hi Jan,
You’re new to PEGs, right? I had the same problem when I started...
The issue is that you need a production that specifies the delimiters between identifiers, so you need something like this:
doc <- * identifier +
identifier <- ...
__ <- [\ \t]
You don’t want to put this sort of thing in your identifier definitions. You want to do that in the container (production).
There are other ways than the above (and I’m no expert), but this is the general idea. Check out the samples for more ways to do it with different grammars.
Does that help?
Cheers,
ast
On May 15, 2018, at 7:28 AM, Jan Brittenson notifications@github.com wrote:
I have a PEG grammar with a rule:
identifier <- "" [a-zA-Z][a-zA-Z0-9.]* ""
Basically, an identifier can't start with a digit or period. But when I try to compile it I get:
Line 4: expected "?", "", "+", [\s], "#", [a-zA-Z] identifier <- "" [a-zA-Z][a-zA-Z0-9_.] ""
Now, I can insert a space to make it a sequence, but I don't want whitespace in my identifiers: identifier <- "" [a-zA-Z] [a-zA-Z0-9.]* ""
Same with the backticks, actually. I wish I could simply specify a regex without having to make it a sequence at all. It's a lexographic element...
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jcoglan/canopy/issues/31, or mute the thread https://github.com/notifications/unsubscribe-auth/AAK9nvzrs-JA3ALWSb4j3OvsnSJtbYKpks5tymdhgaJpZM4T-6Mx.
-- Andrew S. Townley ast@atownley.org http://atownley.org
Yeah, sorry, I just discovered I misinterpreted how an example mentioned "whitespace". I forget where, but clearly I have to explicitly use a whitespace rule and nothing is separated by whitespace by default. So, doh. It actually works fine. facepalm
I totally misunderstood! Apologies.
I have a PEG grammar with a rule:
Basically, an identifier can't start with a digit or period. But when I try to compile it I get:
Now, I can insert a space to make it a sequence, but I don't want whitespace in my identifiers:
Same with the backticks, actually. I wish I could simply specify a regex without having to make it a sequence at all. It's a lexographic element...