no-context / moo

Optimised tokenizer/lexer generator! 🐄 Uses /y for performance. Moo.
BSD 3-Clause "New" or "Revised" License
817 stars 65 forks source link

adjustments to moo for import/export compatibility #113

Closed lisp closed 5 years ago

lisp commented 5 years ago

what approach is intended to use moo in a browser via export/import i found this note in the nearley playground, but it remains unresolved:

https://github.com/bijection/nearley-playground/issues/16

i have read also the nearley note about "compiling in browsers"

https://nearley.js.org/docs/using-in-frontend

but that does not indicate how to adjust the process to use moo as a lexer and also does not mention how to handle export/import.

tjvr commented 5 years ago

I'm not sure we have enough information to answer your question.

There are lots of tools to get JavaScript into a browser, even if the JS uses imports: for example rollup, webpack, or browserify. Moo doesn't mind what you use.

Maybe this is a question about compiling Nearley grammars?

The Nearley Playground is a special case, since it lets you write grammars containing JavaScript in the browser.

I'm afraid I don't have the time to provide advice on JavaScript bundling 🙂

Sent with GitHawk

lisp commented 5 years ago

i suppose, what i am hoping to do is not to have to bundle it, but instead to generate a lexer which works with export/import.

tjvr commented 5 years ago

You should be able to include the moo JS file in your page, and then use var moo = window.moo in your Nearley grammar instead of require().

Sent with GitHawk