-
Notifications
You must be signed in to change notification settings - Fork 60
Generate mozcpp grammar automatically #470
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script updates the mozcpp grammar automatically. | ||
| # | ||
| # Usage: ./generate-moz-grammars/generate-mozcpp.sh | ||
|
|
||
| # FIXME we need to remove this line once we are going to use | ||
| # the tree-sitter-cpp bindings | ||
| # Get the tree-sitter-cpp submodule version | ||
| TS_CPP_VERSION=`git submodule status tree-sitter-cpp | awk '{ print $1 }'` | ||
|
|
||
| # Enter the mozcpp directory | ||
| pushd tree-sitter-mozcpp | ||
|
|
||
| # Create tree-sitter-cpp directory | ||
| mkdir -p tree-sitter-cpp | ||
|
|
||
| # Enter tree-sitter-cpp directory | ||
| pushd tree-sitter-cpp | ||
|
|
||
| # Shallow clone tree-sitter-cpp to a specific revision | ||
| git init | ||
| git remote add origin https://github.com/tree-sitter/tree-sitter-cpp.git | ||
| git fetch --depth 1 origin $TS_CPP_VERSION | ||
| git checkout FETCH_HEAD | ||
|
|
||
| # Install tree-sitter-cpp dependencies | ||
| npm install -y | ||
|
|
||
| # Exit tree-sitter-cpp directory | ||
| popd | ||
|
|
||
| # Init npm | ||
| npm init -y | ||
|
|
||
| # Install a small module that lets the parser be used from Node | ||
| npm install --save nan | ||
|
|
||
| # Install the Tree-sitter CLI | ||
| npm install --save-dev tree-sitter-cli | ||
|
|
||
| # Generate moz-cpp grammar | ||
| ./node_modules/.bin/tree-sitter generate | ||
|
|
||
| # Delete node_modules | ||
| rm -rf node_modules | ||
|
|
||
| # Delete package files | ||
| rm -rf package-lock.json package.json | ||
|
|
||
| # Delete tree-sitter-cpp directory | ||
| rm -rf tree-sitter-cpp | ||
|
|
||
| # Exit tree-sitter-mozcpp directory | ||
| popd | ||
|
|
||
| # Enter enums directory | ||
| pushd enums | ||
|
|
||
| # Recreate the grammar for rust-code-analysis | ||
| cargo clean && cargo run -- -lrust -o ../src/languages | ||
|
|
||
| # Exit enums directory | ||
| popd | ||
|
|
||
| # Format the produced grammars | ||
| cargo fmt | ||
|
|
||
| # Run rust code-analysis to verify if everything works correctly and to | ||
| # update the Cargo.lock | ||
| cargo test --workspace | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.