Visualizer: Shareable grammars as URL
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.
+1
Done. Give it a try and let me know what you think!
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.
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/
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.
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.
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.