Skip to content

JS Grammar Updates #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 10, 2017
Merged

JS Grammar Updates #8

merged 2 commits into from
Oct 10, 2017

Conversation

amiller-gh
Copy link
Contributor

@amiller-gh amiller-gh commented Oct 9, 2017

  • Fix bug in hex-color that uses invalid token
  • Generate runtime manifest file to avoid dynamic imports
  • Use node path library instead of string concat for path resolution

hex-color.json used a token not present in the lexer, it caused some issues!

It is better convention to use path in node to construct filepaths. Looks cleaner and avoids pesky string concatenation complexities (stray /s, ..s, etc).

The new index.js generated in the generated directory allows us to import JS grammars without constructing the import path dynamically. So:

require(`path/to/grammars/generated/${requestedPackage}.js`);

becomes:

require('path/to/grammars/generated')[requestedPackage];

The presence of this manifest file allows bundlers to package all js grammars into a client side runtime. By referencing the manifest file, all grammars will be bundles. By avoiding dynamic input paths, the runtime is able to be statically analyzed by package bundlers.

 - Fix bug in hex-color that uses invalid token
 - Generate runtime manifest file to avoid dynamic imports
@chriseppstein
Copy link
Collaborator

Looks good. @mahirshah thoughts?

@mahirshah mahirshah merged commit b2d50fc into master Oct 10, 2017
@mahirshah mahirshah deleted the js-gen-updates branch October 13, 2017 19:36
chriseppstein pushed a commit that referenced this pull request Oct 16, 2017
Fix Script to Format Json Grammars into Ohm Grammars
chriseppstein pushed a commit that referenced this pull request Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants