ohm-editor icon indicating copy to clipboard operation
ohm-editor copied to clipboard

Visualizer: Shareable grammars as URL

Open mroeder opened this issue 9 years ago • 7 comments

It's nice that the visualizer currently remembers the lasted grammar I worked on and the example I used with it (in local storage). I would love to see a generated URL in the style of:

http://esprima.org/demo/parse.html?code=var%20my%20%3D%20Grammar%3B (I would rather like to see # instead of ? but that's the general idea)

to share my grammar (and examples) with others and remember multiple grammars in my bookmarks. It's also a neat thing when reporting bugs for Ohm.

mroeder avatar Feb 05 '16 19:02 mroeder

+1

alexwarth avatar Feb 06 '16 01:02 alexwarth

Done. Give it a try and let me know what you think!

pdubroy avatar Feb 11 '16 14:02 pdubroy

Wow! First report: It completely crashed my (Chrome) browser! All the windows, all tabs (100+). :-/ I guess it doesn’t like grammars that are still in LocalStorage? ... But it didn't happen the second time I tried. Still, my grammar is in the LocalStorage but nowhere to be seen.

mroeder avatar Feb 11 '16 19:02 mroeder

Oh, btw. I always like a "default grammar" when you came to the visualizer instead of an empty canvas. Would be nice to get some example when I go straight to: http://cdglabs.org/ohm/visualizer/

mroeder avatar Feb 11 '16 19:02 mroeder

Well, and the encoding for the URL is somewhat verbose. One character - in example or grammar - results in ~4 characters in the URL. Not that pleasant for (real) grammars like ES5, etc. Maybe that is what crashed my browser: I had a long grammar (SL) in LocalStorage.

mroeder avatar Feb 11 '16 20:02 mroeder

Uh...very weird. I did test with the ES5 grammar and a very large input string, no problems.

And it should be totally ignoring your grammar in localStorage...I decided not to try to load them, because it would just be some code that would be temporary that we'd want to delete later...and I figured it wasn't worth it.

pdubroy avatar Feb 11 '16 20:02 pdubroy

Re-opening as the previous fix didn't work properly in Firefox and Safari.

Given the length of some "real" grammars (e.g., the ES6 grammar is >23k chars), we will probably need to implement this with a real backend.

pdubroy avatar Feb 15 '16 14:02 pdubroy