question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: head is not defined

See original GitHub issue

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 https://github.com/amqp-node/amqplib/issues/453. amqplib uses pegjs via bitsyntax to generate a parser from the grammar specified here.

bitsyntax’s last working parser was generated using pegjs@0.7.0 and upgrading to pegjs@0.1.0, peggy@^1.0.0 or peggy@latest results in a broken parser.

/Users/steve/Development/squaremo/bitsyntax-js/lib/parser.js:256
  var peg$f17 = function() { return head + tail.join(''); };
                             ^

ReferenceError: head is not defined

I’m completely new to pegjs/peggy and was hoping it’s an easy fix. Can you give me any pointers please?

Thanks

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Minguncommented, Jun 3, 2022

Actually, your original grammar worked because of a bug, fixed in pegjs@0.10.0:

Fixed label scoping so that labels in expressions like (a:"a") or (a:"a" b:"b" c:"c") aren’t visible from the outside.

Also, you could simplify your grammar much more using a new @ operator, for example, here:

segmentTail
    = ws ',' ws @segment

and using a $ operator instead of return text():

identifier
    = $([_a-zA-Z] [_a-zA-Z0-9]*)
1reaction
hildjjcommented, Jun 2, 2022

Let us know if you’d like more help with the grammar. Happy to pitch in as needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: head is not defined #6 - GitHub
Hi! running the plugin with the current version of reveal.js (3.8) causes a Reference Error: toolbar.js:41 Uncaught ReferenceError: head is ...
Read more >
javascript - Next.js - Head element doesn't work - Stack Overflow
1 Answer 1 · I haven't written the Head component by myself. It goes from Next.js. – user3309314 · @user3309314 Look again at...
Read more >
ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
The JavaScript exception "variable is not defined" occurs when there is a non-existent variable referenced somewhere.
Read more >
How to Fix Uncaught ReferenceError: $ is not defined in jQuery
The most common reason behind the error "Uncaught ReferenceError: $ is not defined" is executing the jQuery code before the jQuery library file...
Read more >
How to fix ReferenceError: Document is not defined ... - Sabe.io
The best way to resolve this is to just move your code to the bottom of the page so that the document will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found