npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

antlr4ng-cli

v2.0.0

Published

ANTLR4 NG command line tool for TypeScript

Downloads

109,707

Readme

Weekly Downloads npm version

Part of the Next Generation ANTLR Project

Custom ANTLR4 Code Generator

This package contains a custom code generator for ANTLR4 grammars. It is based on the official ANTLR4 code generator, but includes support for the antlr4ng runtime, so the TypeScript output is different. Other than that it is a drop-in replacement for the official generator and can also be used with the official runtimes (C++, Java, etc.).

Installation

To install the package, run the following command:

npm install antlr4ng-cli

Usage

The package needs Java installed on your system, To generate your parser, run the following command:

antlr4ng <options> <grammar-file>

in the root of your project, where you installed the package.

Note: in contrast to antlr4ts you have to specify the target language explicitly, just as if you use the generator jar file directly. A typical case would be:

antlr4ng -Dlanguage=TypeScript -o generated/ -visitor -listener -Xexact-output-dir path/to/YourLexer.g4 path/to/YourParser.g4

Release Notes

2.0.0

This is the next major release of the code generator, after an overhaul of the antlr4ng runtime. It introduces a number of API changes, but no changes to the original working mechanism. The other targets (C++, Java, etc.) are not affected by this release. All changes in this release are to support the new antlr4ng major release 3.0.0:

  • Renamed class members (_type -> type, _channel -> channel, _mode -> mode, _parseListeners -> parseListeners).
  • Specialized getText methods for the token stream, to avoid frequent parameter checking in method overloading.
  • Merged the class RuleContext into ParserRuleContext. It's not used anywhere else, so why keeping it around?
  • ParserRuleContext.exception has been removed and it is no longer set in generated code (only relevant for error conditions, where a proper exception is passed to error listeners.
  • More non-null assertions and null-safety checks have been added (mostly relevant for local rule variables and return values).

1.0.7

Code generation improvements, especially for local rule attributes. Attributes in a rule (which are implemented as local variables in the generated code) can be unassigned and need extra null-safety checks (the ? operator) or non-null assertions. The code generator now adds these checks automatically.

1.0.5 - 1.0.6

Code generation changes:

  • Local attributes in rule contexts are now made optional, to account for the fact that they are not always set.

1.0.4

Compatible with antlr4ng 2.0.0

Code generation changes:

  • More locations where the override keyword is needed in generated classes.
  • ParserRuleContext._ctx was renamed to ParserRuleContext.context in the runtime.
  • Optional null result for listener/walker methods.
  • TokenStream.getText no longer needs a temporary interval as parameter, but can directly work with start and stop values.

1.0.3

  • Non-optional token members of a rule context no longer return null, which makes explicit non-null assertions in user code unnecessary.
  • Added override keyword for generated copyFrom methods.

1.0.2

Updated the ANTLR4 jar.

1.0.1

  • Some changes for renamed class members in the runtime (e.g. _interp -> interpreter).

1.0.0

  • Initial release.