Skip to content
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

testing/debugging grammar interactively ? #149

Open
asmodehn opened this issue May 22, 2018 · 12 comments
Open

testing/debugging grammar interactively ? #149

asmodehn opened this issue May 22, 2018 · 12 comments
Labels
discussion Discuss new features or other changes good first issue help wanted

Comments

@asmodehn
Copy link
Contributor

I am thinking something along the lines of https://omrelli.ug/nearley-playground/
that provides an interactive feedback to the user creating a grammar, via examples or other way.
The nicest tool I know is about regular expressions only : https://regex101.com/

Is there something like that for parser grammars ? where we could just add lark syntax?

I am not used to write parser grammars, and I am currently doing this in a python interpreter. The raw python error messages can be quite cryptic for a newcomer.
Any idea ? Am I missing an obvious tool here ?

@erezsh
Copy link
Member

erezsh commented May 22, 2018

Sorry, there isn't an interactive tool for Lark.

Lark does have syntax highlighting for sublime-text, so you could use it to edit the grammar file and load it from the interpreter (it would probably be more convenient than writing the grammar in the interpreter).

@erezsh
Copy link
Member

erezsh commented May 22, 2018

It should probably be pretty simple to fork nearley-playground and change the syntax to Lark's. It could be a nice addition to the lark toolbox.

@asmodehn
Copy link
Contributor Author

asmodehn commented May 22, 2018

I am already using sublime for syntax highlighting. Syntax is usually correct, but I guess I'm getting trapped into all the non obvious cases (using this parser fails, but why ?).

Related "feature request" issue is at lark-parser/lark_syntax#2

We probably would want to run Lark (python code) in the browser, somehow... Just to make sure we are actually testing lark while using it, and providing a strong guarantee for the grammar one would copy/paste between web page and lark file...

Let me know if you have any preference for a Browser Python implementation ( brython, skulpt, etc.) I might give it a try sometime...

@asmodehn
Copy link
Contributor Author

Just for the record, and maybe inspiration, the two best tools I could find around the net :

@erezsh
Copy link
Member

erezsh commented May 23, 2018

The first one seems nice, but a little primitive. Ideally, you'd have syntax highlighting, proper error handling, and a display of the resulting tree (when given an input).

I don't have experience with brython or skulpt, or alternatives, so I'll leave it to whoever chooses to implement it. I can say that from a cursory glance, brython seems like the best choice.

@erezsh erezsh added the discussion Discuss new features or other changes label May 23, 2018
@erezsh
Copy link
Member

erezsh commented Aug 6, 2020

Now that Lark has an online IDE, this should be easier to implement: https://lark-parser.github.io/lark/ide/app.html new link: https://www.lark-parser.org/ide/

@asmodehn
Copy link
Contributor Author

asmodehn commented Aug 7, 2020

Oh the online IDE is very nice indeed ! Sadly, I probably won't have time to come back to this in the near future though, but I ll give it a spin whenever I can.

@enjoysmath
Copy link

Now that Lark has an online IDE, this should be easier to implement: https://lark-parser.github.io/lark/ide/app.html

Never loads, mon! :>

@erezsh
Copy link
Member

erezsh commented May 17, 2023

Sorry, that's an old link! New link is https://www.lark-parser.org/ide/

@erezsh
Copy link
Member

erezsh commented May 17, 2023

P.S. @enjoysmath You should be able to share the same Lark instance with as many modules that you want. As long as you use the documented API, it should work fine.

@enjoysmath
Copy link

enjoysmath commented May 17, 2023 via email

@erezsh
Copy link
Member

erezsh commented May 17, 2023

@enjoysmath I don't remember Django well enough, but if it's technically possible to share the same Lark instance, I don't see a reason not to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss new features or other changes good first issue help wanted
Projects
None yet
Development

No branches or pull requests

3 participants