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.

Is it possible to use nearley-unparse with Moo?

See original GitHub issue

I’ve been trying to use Nearley to parse a list of problems but I’m having trouble getting nearley-unparse to correctly generate text matching Moo tokens. I posted a StackOverflow question to no avail so I thought it might be better suited for here. I’m using Nearley v2.11.0, Node v7.9.0 and NPM v4.2.0.

Everything is in the same Gist, but my grammar looks like this and the problems I’m trying to parse look like this.

After compiling the grammar however and using nearley-unparse however, I just end up with text that looks like this, with the Moo tokens missing.

Section  (Due )- #*, , 
Section  (Due )- #, *, 
Section  (Due )- #*, , , *, 
Section  (Due )- #*, *
Section (Due )- #*, *, *, *

Is this a limitation of Nearley or Moo? Or am I doing something wrong with my grammar?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
bumbaazcommented, Jan 5, 2019

Hi, i just want to point out that it may be the case that nearley-unparse may not work even when the rules defined in moo do not involve regexes.

The following grammar, when compiled, only returns empty strings when unparsed

    @{%
        const moo = require('moo')
        let lexer = moo.compile({
    	word: ["hellothere"]
        });
    %}
    @lexer lexer
    result -> %word

While this works:

    result -> "hellothere"
0reactions
tjvrcommented, Jan 5, 2019

I haven’t tested the unparser with Moo myself. I suppose it’s plausible that it needs to be updated!

Sent with GitHawk

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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