
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
antlr4js-cli
Advanced tools
Generates javascript code based on specified grammar for lexer, parser, and tokens.
This is a NPM wrapper of a ANTLR 4 code generation tool. So you will need to have a modern version of Java (>= JRE 1.6) to use it.
npm install --save-dev antlr4js-cli
or, installs it as a global package.
npm install -g antlr4js-cli
antlr4 [options] grammerfile
options:
-no-listener don't generate parse tree listener
-visitor generate parse tree visitor
-no-visitor don't generate parse tree visitor (default)
-package ___ specify a package/namespace for the generated code
-depend generate file dependencies
-D<option>=value set/override a grammar-level option
-Werror treat warnings as errors
-XdbgST launch StringTemplate visualizer on generated code
-XdbgSTWait wait for STViz to close before continuing
-Xforce-atn use the ATN simulator for all predictions
-Xlog dump lots of logging info to antlr-timestamp.log
-Xexact-output-dir all output goes into -o dir regardless of paths/package
-o diretory for output files
Let's suppose that your grammar is named "MyGrammar". If your run:
antlr4js -visitor ./MyGrammar.g4 -o out
The tool will have generated the following files in out directory for you:
- MyGrammarLexer.js
- MyGrammarParser.js
- MyGrammarListener.js (if you have not activated the -no-listener option)
- MyGrammarVisitor.js (if you have activated the -visitor option)
Now, you could use the above files, like this:
import antlr4 from 'antlr4';
import MyGrammarLexer from './MyGrammarLexer.js';
import MyGrammarParser from './MyGrammarParser.js';
import MyGrammarListener from './MyGrammarListener.js';
const input = "your text to parse here"
const chars = new antlr4.InputStream(input);
const lexer = new MyGrammarLexer(chars);
const tokens = new antlr4.CommonTokenStream(lexer);
const parser = new MyGrammarParser(tokens);
parser.buildParseTrees = true;
const tree = parser.MyStartRule();
FAQs
ANTLR 4 command line tool for javascript
The npm package antlr4js-cli receives a total of 6 weekly downloads. As such, antlr4js-cli popularity was classified as not popular.
We found that antlr4js-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.