waxeye-org / waxeye

Waxeye is a parser generator based on parsing expression grammars (PEGs). It supports C, Java, JavaScript, Python, Racket, and Ruby.
https://waxeye-org.github.io/waxeye/index.html
Other
235 stars 38 forks source link

New homepage and a web demo (via RacketScript) #65

Closed glebm closed 7 years ago

glebm commented 7 years ago
  1. Adds a new homepage. It can be built and pushed to GitHub pages by running:

    build/push-gh-pages

    Demo: https://glebm.github.io/waxeye/index.html

  2. Adds a web demo! It runs directly in the browser. The waxeye compiler is compiled using RacketScript.

    Demo: https://glebm.github.io/waxeye/demo.html

Minimal changes were necessary on the waxeye side to make it work with RacketScript. Incidentally, these changes also reduced the size of the final executable by ~50%.

On the RacketScript side, had to fix a few bugs in RacketScript: https://github.com/vishesh/racketscript/pull/73

This PR can be merged only once the RacketScript PR is merged and a new version of RacketScript has been released. For now, I just want your feedback.

/cc @jishi9 @ddrone

orlandohill commented 7 years ago

Looks great!

My guess is, not using srfi/1 is what reduced the executable size.

I'll give more detailed feedback later.

glebm commented 7 years ago

By the way, here is the background for the changes made to waxeye to compile with RacketScript: https://github.com/vishesh/racketscript/issues/68#issuecomment-324873679

orlandohill commented 7 years ago

Having a web-based demo is a really nice idea. It's something I've wanted since the beginning, and using a Racket-to-JS compiler is the approach I was last considering.

There's probably a lot of potential for a browser-based grammar IDE, but I'm sure what you've already done would help people get a better sense of the project.

Perhaps the layout of DrRacket and PEG.js' demo (https://pegjs.org/online) could be useful design references. Editable grammar in one pane, editable input string and output AST in another.

orlandohill commented 7 years ago

The ability to see/copy-to-clipboard the generated files is nice. Perhaps there could be a button to view or copy each file, and eventually for each language.

The AST that results from parsing the user's example input could be more readable. #68 will help with that.

I'm not sure about Parser AST modes. Is there a particular problem you have in mind?

orlandohill commented 7 years ago

I'd prefer not to say that Waxeye is based on packrat parsing. Packrat parsing is something very specific. The current version of Waxeye uses memoization, but it does so using a hash table, only for the result of non-terminals, and doesn't provide linear run-time guarantees.

Using the term 'language-agnostic' instead of 'language independent' is an improvement. I like the slogan "Write once, parse anywhere" :)

glebm commented 7 years ago

A new version of RacketScript has been released, so this can now be merged!

I've made some changes to the PR to address the comments. See the links in the original posts for the updated copy and UI.

The changes are in a separate commit to make reviewing easier, they can be squashed when merging (GitHub now has an option to do that in the UI).

I'm not sure about Parser AST modes. Is there a particular problem you have in mind?

This is only useful when debugging Waxeye itself, and for now I've hidden this option in a <details> tag.

The ability to see/copy-to-clipboard the generated files is nice. Perhaps there could be a button to view or copy each file, and eventually for each language.

This is now hidden by default. While nice, the generated parser does not include the runtime, and there are no instructions on this yet. We can add it in the future.

I'd prefer not to say that Waxeye is based on packrat parsing. Packrat parsing is something very specific. The current version of Waxeye uses memoization, but it does so using a hash table, only for the result of non-terminals, and doesn't provide linear run-time guarantees.

Thanks for the explanation! Fixed the copy.

orlandohill commented 7 years ago

The new demo looks great! Thanks for updating the homepage text too.

Is it possible to write a RacketScript-compatible version of ind in code.rkt that keeps the original behavior? Maybe the code generation can be improved later.

Is the following compatible?

(apply string-append (make-list indent-level (make-string indent-unit #\space)))
glebm commented 7 years ago

That should be compatible, I'll give it a try.

glebm commented 7 years ago

Done!

orlandohill commented 7 years ago

Great, thanks!

glebm commented 7 years ago

Great! After you run:

build/site && build/push-gh-pages

The site will be available here once you enable GitHub pages in the repository settings (set the gh-pages branch as "Source"): https://orlandohill.github.io/waxeye

Here are the instruction on making waxeye.org point to it: https://help.github.com/articles/quick-start-setting-up-a-custom-domain/

orlandohill commented 7 years ago

Ok, I'll set that up when I get the time. Hopefully by the end of the week.