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.

Crash (unknown symbol type) when custom token matcher expected

See original GitHub issue

I’m running into an issue when using a custom token matcher. If there is a syntax error in the input, where nearley sees some token but is expecting a custom token matcher instead, it crashes instead of producing an error message.

This can be seen by passing the input ["print", "blah", 12, ";", ";"] to the example grammar from the documentation. This results in the following error:

/home/willem/Git/nearley-test/node_modules/nearley/lib/nearley.js:402
            throw new Error('Unknown symbol type: ' + symbol);
            ^

Error: Unknown symbol type: [object Object]
    at Parser.getSymbolDisplay (/home/willem/Git/nearley-test/node_modules/nearley/lib/nearley.js:402:19)
    at Parser.<anonymous> (/home/willem/Git/nearley-test/node_modules/nearley/lib/nearley.js:363:38)
    at Array.forEach (<anonymous>)
    at Parser.reportError (/home/willem/Git/nearley-test/node_modules/nearley/lib/nearley.js:360:21)
    at Parser.feed (/home/willem/Git/nearley-test/node_modules/nearley/lib/nearley.js:314:42)
    at Object.<anonymous> (/home/willem/Git/nearley-test/test-parser.js:6:8)
    at Module._compile (internal/modules/cjs/loader.js:1121:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
    at Module.load (internal/modules/cjs/loader.js:976:32)
    at Function.Module._load (internal/modules/cjs/loader.js:884:14)

This seemingly comes from the procedure that is constructing the error output (maybe related to #479?). I tried modifying nearley.js to print symbol, but that is just an empty object {}. Returning an empty string instead of throwing an error fixes the crash, but this results in the token name displayed as empty in the error output (not really helpful…)

(node -v: v13.3.0, npm -v: 6.13.1, nearleyc -v: 2.19.0)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kachcommented, Jun 16, 2020

This should be fixed! Thank you @airportyh

0reactions
airportyhcommented, Jun 16, 2020

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

laravel - Visual Studio Code PHP Intelephense Keep Showing ...
After the latest update of PHP Intelephense that I get today, the intelephense keep showing an error for an undefined symbol ...
Read more >
ChangeLog - crash
This helps detecting various memory errors on the crash's custom memory ... gcc generates the message "warning: format '%ld' expects argument of type...
Read more >
Bug listing with status RESOLVED with resolution FIXED as at ...
Invalid token (not "=")" status:RESOLVED resolution:FIXED severity:major ... Bug:5265 - "automount doesn't work with NIS/YP maps: undefined symbol: ...
Read more >
Common issues and resolutions for Power Apps
The gallery will then show data as expected. Custom connectors and Microsoft Dataverse. If an app created using Power Apps build 2.0.540 or ......
Read more >
Xcode 13 Release Notes | Apple Developer Documentation
Keyboard shortcuts in Xcode now work as expected when the documentation window has ... Use hierarchical mode to customize the symbol's primary layer...
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