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.

json.ne example throwing errors - Issue with moo?

See original GitHub issue

I’m trying to run the example json.ne grammar on the following input:

["hello”]

And getting the following error:

Error: invalid syntax at line 1 col 2:

  ["hello"]
   ^
Unexpected "\”"

Am I missing something?

Just for context I’ve written a couple of simple grammars before without using moo or a custom lexer without any trouble. It seems from the nearley docs that there’s been a lot of change with the lexer implementation recently, so I’m thinking I may have missed something…

I’m running nearley 2.10.2 and moo 0.4.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
deltaideacommented, Aug 4, 2017

Duplicate of #247. Solution:

  var grammar = require('./json.js')
- var p = new nearley.Parser(grammar.ParserRules, grammar.ParserStart);
+ var p = new nearley.Parser(nearley.Grammar.fromCompiled(grammar));

  console.log(grammar.Lexer.has('number'))

Docs currently don’t mention fromCompiled() properly. We’re working on that. Check out this preview of updated docs.

Thank you for the repro code! You’re awesome.

0reactions
tjvrcommented, Aug 4, 2017

Glad we solved it 😃

Want to help review @deltaidea’s docs PR? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proper way to rethrow a JsonConverter exception
Based on the Newtonsoft example here. I've ended up doing the following: List<MyParseException> errors = new List<MyParseException>(); ...
Read more >
Serialization Error Handling - Json.NET
The Error event is an event handler found on JsonSerializer. The error event is raised whenever an exception is thrown while serializing or...
Read more >
Struggling to deserialize JSON with escaped double quotes
I'll try to illustrate this. This is valid JSON. { "errors": [ { "params": { "password": "size must be between 4 and 30",...
Read more >
What Is JSON and How to Handle an “Unexpected Token” Error
The first thing to do in this situation is to confirm where the error is happening exactly. To ensure the error happens on...
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
This string has to be valid JSON and will throw this error if incorrect syntax was encountered. Examples. JSON.parse() does not allow trailing...
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