antlr / antlr4-lab

A client/server for trying out and learning about ANTLR
MIT License
39 stars 11 forks source link

[feature] add link to freeze dry the current configuration of the lab #8

Open parrt opened 2 years ago

parrt commented 2 years ago

Create a link so people can pass around not only grammar but also the state of the parse. Similar to the awesome pythontutor.com

parrt commented 2 years ago

use Cloud Storage?

kaby76 commented 2 years ago

What I would like to see is a way to share a web link to the Lab that contains the grammar x input x start-symbol and automatically runs the program. Yes, you could create the state and add it to a DB on a different server. Or, you could implement this using one long URL, pasting an encoding of the tuple in the link itself. That way when someone wants to share a problem, it's easy to just click on the link to reproduce the issue.

parrt commented 2 years ago

I prefer a stateless approach encoding with URL but that URL size is limited. What if input is 3M? I think it'd be hard to get a lossless compression down to 2k max URL right?

kaby76 commented 2 years ago

I prefer a stateless approach encoding with URL but that URL size is limited. What if input is 3M? I think it'd be hard to get a lossless compression down to 2k max URL right?

I'll see what I can get through compression on all the grammars in grammars-v4. But, yes, 2048 is the limit. Maybe we can have the grammar and input be represented via URL's, e.g., lab.antlr.org/@https://raw.githubusercontent.com/antlr/grammars-v4/master/abnf/Abnf.g4&https://raw.githubusercontent.com/antlr/grammars-v4/master/abnf/examples/iri.abnf&rulelist. That seems possible, right?

parrt commented 2 years ago

Well that works for just those examples on the web and just the grammar and not the input. Input can be unbounded

kaby76 commented 2 years ago

Your right, it seems the state grammar x input x start-symbol will likely need to be stored somewhere.

ericvergnaud commented 2 years ago

Tha limitation only true for get, not for post. One could save state (grammar start rule in put) to a file, which could later be posted

Le 29 oct. 2022 à 22:50, Terence Parr @.***> a écrit :

I prefer a stateless approach encoding with URL but that URL size is limited. What if input is 3M? I think it'd be hard to get a lossless compression down to 2k max URL right?

kaby76 commented 2 years ago

BTW, I did a "gzip -9" of the .g4's in grammars-v4, and some of the SQL grammars after compression are ~30KB. So, I don't see a URL working as a solution for these big grammars. I tried to generate some html files to load up lab.antlr.org and set the form up, but JS doesn't work past a get of lab.antlr.org--security restriction in the browser I guess.