-
Notifications
You must be signed in to change notification settings - Fork 66
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
ReferenceError: head is not defined #275
Comments
I grabbed the grammar, ran it through peggy's CLI with the default options, then called $(PEGJS) $(GRAMMAR) -o $@ (add I agree that the line you've highlighted looks wrong. Here's what I get: var peg$f0 = function(head, tail) { tail.unshift(head); return tail; }; |
Hi @hildjj, Thanks for the quick response. I also noticed that the Makefile is out of date. I've generated the parser by hand as follows
|
Example input, please? And can you check that you're using Peggy 2.0.1, which was just released yesterday? |
Peggy Version
Input Grammar
|
OK, it has nothing to do with the build process. Remove the parens on line 43: identifier
= head:[_a-zA-Z] tail:[_a-zA-Z0-9]* { return head + tail.join(''); } which ends up being identifier
= [_a-zA-Z] [_a-zA-Z0-9]* { return text(); } Some old version of peg.js must have changed how parens are handled. In today's world, they hide labels from the containing rule. Once I got that working, there are a bunch of other test errors, but that's a separate issue. |
Thanks @hildjj. I'll close this, and try to work out why the tests are failing. |
Let us know if you'd like more help with the grammar. Happy to pitch in as needed. |
Actually, your original grammar worked because of a bug, fixed in [email protected]:
Also, you could simplify your grammar much more using a new segmentTail
= ws ',' ws @segment and using a identifier
= $([_a-zA-Z] [_a-zA-Z0-9]*) |
Hello & thank you for your work on peggy and for picking up where pegjs left off.
I'm one of the maintainers of amqplib and investigating amqp-node/amqplib#453. amqplib uses pegjs via bitsyntax to generate a parser from the grammar specified here.
bitsyntax's last working parser was generated using [email protected] and upgrading to [email protected], peggy@^1.0.0 or peggy@latest results in a broken parser.
I'm completely new to pegjs/peggy and was hoping it's an easy fix. Can you give me any pointers please?
Thanks
The text was updated successfully, but these errors were encountered: