Skip to content

Commit

Permalink
New point releases
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-lischke committed Sep 19, 2023
1 parent aa79ca7 commit acb8ecf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 55 deletions.
12 changes: 12 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ The benchmarks consist of a set of query files, which are parsed by a MySQL pars

## Release Notes

### 1.1.0

This release includes a lot of cleanup.

- Generated parser rules that can appear as either returning a single parse context or a list of that no longer use the `__list()` appendix in their name. Instead method overloading is used now to distinguish between the two cases.
- The members `getTypedRuleContext` and `getTypedRuleContexts` have been renamed to `getRuleContext` and `getRuleContexts` respectively, just as in the Java runtime.
- There are more renames (`_errHandler` -> 'errorHandler`, `_input` -> `inputStream` and more).
- The package has been stripped down to just a single bundle file. This is an ESM module now, so it can be used in both, node and browser environments. No differentiation is made anymore between the two.
- The internal folder structure has been changed to match the Java runtime.
- Extended some classes, added new type definitions and exported some more classes.
- Improved `BitSet` to use less memory.

### 1.0.6 - 1.0.7

- Fixed recognizer token type and rule index maps.
Expand Down
69 changes: 16 additions & 53 deletions cli/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,39 @@
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/mike-lischke/antlr4ng/nodejs.yml?style=for-the-badge&color=green&logo=github)](https://github.com/mike-lischke/antlr4ng/actions/workflows/nodejs.yml)
![Weekly Downloads](https://img.shields.io/npm/dw/antlr4ng?style=for-the-badge&color=blue)
[![npm version](https://img.shields.io/npm/v/antlr4ng?style=for-the-badge&color=yellow)](https://www.npmjs.com/package/antlr4ng)
[![Weekly Downloads](https://img.shields.io/npm/dw/antlr4ng-cli?style=for-the-badge&color=blue)](https://www.npmjs.com/package/antlr4ng-cli)
[![npm version](https://img.shields.io/npm/v/antlr4ng-cli?style=for-the-badge&color=yellow)](https://www.npmjs.com/package/antlr4ng-cli)

# TypeScript Target Runtime for ANTLR 4
# Custom ANTLR4 Code Generator

This package is a fork of the official ANTLR4 JavaScript runtime (with its TypeScript additions), with the following changes:

- Much improved TypeScript type definitions.
- XPath implementation.
- Vocabulary implementation.
- Complete Interval implementation.
- Consistent formatting (indentation, semicolons, spaces, etc.).
- Numerous smaller fixes (`null` instead of `undefined` and others).
- Smaller node package (no test specs or other unnecessary files).
- Bug fixes.

It is (mostly) a drop-in replacement of the `antlr4` package, and can be used as such. For more information about ANTLR see www.antlr.org. Read more details about the [JavaScript](https://github.com/antlr/antlr4/blob/master/doc/javascript-target.md) and [TypeScript](https://github.com/antlr/antlr4/blob/master/doc/typescript-target.md) targets at the provided links, but keep in mind that this documentation applies to the original JS/TS target.
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`](https://github.com/mike-lischke/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:

```bash
npm install antlr4ng
npm install antlr4ng-cli
```

This package has a peer dependency to `antlr4ng-cli`, which is the tool to generate parser files compatible with this runtime, so it is strongly recommended to install this one too:
## Usage

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

```bash
npm install --save-dev antlr4ng-cli
antlr4ng <options> <grammar-file>
```
See [its readme](./cli/ReadMe.md) for more information.

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

This runtime is constantly monitored for performance regressions. The following table shows the results of the benchmarks run on last release:

| Test | Cold Run | Warm Run|
| ---- | -------- | ------- |
| Query Collection| 8658 ms | 236 ms |
| Example File | 1024 ms | 117 ms |
| Large Inserts | 10612 ms | 10631 ms |
| Total | 20354 ms | 11005 ms |

The benchmarks consist of a set of query files, which are parsed by a MySQL parser.
> 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:
>
> ```bash
> antlr4ng -Dlanguage=TypeScript -o generated/ -visitor -listener -Xexact-output-dir path/to/YourLexer.g4 path/to/YourParser.g4
> ```
## Release Notes
### 1.0.6 - 1.0.7

- Fixed recognizer token type and rule index maps.
- Fixed `getTokens()` in `BufferedTokenStream`.
- Added new peer dependency `antlr4ng-cli`, which is the tool to generate parser files compatible with this runtime.

### 1.0.5

- Added benchmarks.
- Introduced the `IntStream` interface as the base for `CharStream` and `TokenStream`. This avoids duplicate code in the stream type definitions.
- Removed `FileStream` as a preparation to get rid of the separate package files for node and browser. If something needs to be loaded from a file, the particular environment should provide the code for that.

### 1.0.2 - 1.0.4

- Github build action
- Updated package.json
- Exported `ErrorNode`, `InputMismatchException`
- Some smaller fixes

### 1.0.1
- Added and/or replaced all copyrights to a common ANTLR version.
- Removed all individual default exports. Only the final lib exports contain both, default and non-default exports. This avoids namespace access like `antlr4.atn`. Everything is available under a top level import.
- Renamed ErrorListener to BaseErrorListener, as that is what it is actually when comparing it to the Java runtime.
- Some changes for renamed class members in the runtime (e.g. `_interp` -> `interpreter`).
### 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "antlr4ng-cli",
"version": "1.0.0",
"version": "1.0.1",
"preferGlobal": true,
"description": "ANTLR 4 NG command line tool for TypeScript",
"author": "Mike Lischke",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "antlr4ng",
"version": "1.0.7",
"version": "1.1.0",
"type": "module",
"description": "Alternative JavaScript/TypeScript runtime for ANTLR4",
"main": "dist/antlr4.mjs",
Expand Down

0 comments on commit acb8ecf

Please sign in to comment.