yhirose / cpp-peglib

A single file C++ header-only PEG (Parsing Expression Grammars) library
MIT License
916 stars 113 forks source link

Add options for disable autorefresh, profile and packrat to the playground #207

Closed mingodad closed 2 years ago

yhirose commented 2 years ago

@mingodad thank you for the pull request. I have implemented the same thing in a different way. Please let me know if my implementation has something missing.

mingodad commented 2 years ago

I know that layout design is not easy but look at how the old and the new layout appear when I resize the browser (or a user with different screen size, maybe phone/tablet). peglib-playground-new peglib-playground-old

mingodad commented 2 years ago

Also on my pull request I've moved the last two lines of the profile to the top because when I'm tuning a grammar those two lines are key to evaluate if the change was worth without need to scroll.

mingodad commented 2 years ago

You are already using jquery maybe this would give some idea to a different layout http://layout.jquery-dev.com/demos.cfm

mingodad commented 2 years ago

Also several ot the ones here https://ourcodeworld.com/articles/read/663/top-5-best-draggable-droppable-and-resizable-grid-layout-designer-jquery-and-javascript-plugins are outdated but can serve as inspiration.

mingodad commented 2 years ago

Nice work on the layout of the new playground !

mingodad commented 2 years ago

We'll need a magic parameter to tell the playground to not read the stored grammar/input or start with Auto refresh off because when editing a literal in a grammar and making it temporarily empty peglib enters an infinite loop or something like that.

For example I was editing this grammar:

start <- _ STRING_LONG* !.
_ <- [ \t\n\r]
STRING_LONG <- '[' '='* '['  ( ! (']' '='* ']') . )* ']' '='* ']'

And then deleted the = inside the middle '='* and then now I have the browser blocked and no way to recover (even from the devtools).

Something like https://yhirose.github.io/cpp-peglib/?autorefresh=off to reload but do not try to parse straight way.

yhirose commented 2 years ago

If the playground doesn't detect such an infinite loop and freeze the browser, it's a bug. Anyway, I tried to reproduce it on my browser with the above grammar, but I can't reproduce it it, and the cursor is keep blinking without stuck.

image

By the way, the easiest way to recover from the freeze is to open the top page of https://yhirose.github.io/index.html, and clear the current local storage values for the playground in the Developer Tools window.

mingodad commented 2 years ago

Thank you ! Opening the https://yhirose.github.io/index.html allowed me to fix the issue. The grammar was not exactly that one because I recover from the screen retyping it and omitted some elements, can you try with the one shown bellow and delete the = inside the second '='* (not the first one as shown by your screenshoot) with the Auto refresh checkbox checked (tested on Firefox too and it get frozen and asking to kill the page):

start <- _ STRING_LONG* !.
_ <- [ \t\n\r]*
STRING_LONG <-
     '[' '='* '[' ( ! (']' '='* ']') . )* ']' '='* ']' _

Input:

[==[]=]==]