Skip to content

Commit

Permalink
Typescript target (#4027)
Browse files Browse the repository at this point in the history
* Fix CMake syntax for variable expansion

When using variables to compare (like in if clause) the variable
shouldn't be quoted. More details can be found at the link below:

https://cmake.org/cmake/help/latest/command/if.html#variable-expansion

Signed-off-by: HS <hs@apotell.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* initial commit

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* renamed for clarity

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* renamed for clarity

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* able to locate antlr4 runtime using ts-node, missing types

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* progressing

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* able to 'run' a test. It fails but it compiles and resolves!

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* reflect refactored runtime

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* able to run RecursiveLexerRuleRefWithWildcardPlus_1 test locally

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* passes LexerExec tests in IntelliJ

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* make ATN private

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* ignore same tests as JavaScript

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* compiles Parser and Lexer bu local run fails

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* ParserExec.TokenOffset test successful in IntelliJ !

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Progressing, passing 131 of 348 tests

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* pass 327 tests out of 348

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* more successful tests

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* 333 successful tests out of 348

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* all tests pass except 7 caused by #3868

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* update getting-started doc

Signed-off-by: nicksxs <nicksxs@hotmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* add blank github action file for hosted CI

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* update getting started document to say java 11

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Revert "update getting started document to say java 11"

This reverts commit 1df58f77820b5feb747d34cc6aff26276db8b6dd.

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* add C# book code links

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Add Jim/Ken to readme

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Update Swift Package to support static library

Add static library distribution in SPM

Signed-off-by: Hell_Ghost <dev.hellghost@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Update Package.swift

Signed-off-by: Hell_Ghost dev.hellghost@gmail.com
Signed-off-by: Hell_Ghost <dev.hellghost@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Add caching support for maven & dependencies. Also, include caching for
cpp builds using actions/ccache.

Builds are more reliable (avoids the archive.apache server which
intermittently reports timeouts) and also significantly improves the
overall builds times (down from 46 mins to 28 mins).

The slowest part of the build now is the Windows+cpp builds because
there is no reliable cache implementation yet. MacOS+cpp (65% cache hit) is
also relatively slow compared to Ubuntu+cpp (99% cache hit).

Signed-off-by: HS <hs@apotell.com>
Signed-off-by: Terence Parr <parrt@antlr.org>

# Conflicts:
#	.github/workflows/hosted.yml
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* use snap to install go 1.19

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* grr...install snap

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* ugh. start snap

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* ugh. start snap

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* ugh. cant get snap to install go

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* try downloading golang with curl

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Issue #3823: Temporarily disable a few tests on CI

The tests are currently failing. The underlying issues have been fixed
on dev and so the builds will be turned back with the next release.

Signed-off-by: HS <hs@apotell.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* update actions status badge

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* update getting started document to say java 11

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Revert "update getting started document to say java 11"

This reverts commit 3591ee0b51c6bb914f7ef0749182306fefe9cc18.

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* update getting-started doc

Signed-off-by: nicksxs <nicksxs@hotmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* make getValue visible to external profiler tools.

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Fix #3508: Document the $parser attribute and its use in target-agnostic grammars.

Signed-off-by: Ross Patterson <ross.patterson@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Add accessor to IntervalSet for intervals

Signed-off-by: James Taylor <jamestaylor@apache.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Remove libuuid dependency from C++ runtime

libuuid and its headers are not referenced anywhere, so remove it.

Signed-off-by: Bryan Tan <bryantan@technius.net>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Add `@SuppressWarnings("CheckReturnValue")` to prevent error_prone lib errors.

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: Fixes for antlr/antlr4#3718

  o Implement collections with generics to solve hash collisions
  o Fix type casting in LL start parser simulation optimization
  o General minor tidy ups

Acknowledgements to @kaby76 for help with tracing errors

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #3718 Revert accidental keyboard error in Java target

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #3718 Correct DFAState index in Lexer ATN Simulator

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #3718 Fix go runtime test runners

With older versions of go, there was no good way to tell the compiler to use your local
development copy of a particular package instead of the one installed in GOPATH/src/...

However, we are now using modules, which allows us to tell the compiler that instead of
a module downloaded to GOPATH/pkg, to use a local copy on disk.

Hence this change removes the need to copy the whole of the go installation to a
tempoorary location, then put the antlr go runtime in to the go installation as if it was
part of the compiler. Hence the execution time for the go tests is now faster than before.

This works because when the generated code is placed in the temporary location, we create
a go.mod file for it, tell the module to replace the online module for the go runtime with
the local copy on disk, then ro a go mod tidy to add the dependencies from the code (which
avoids network access, so it is instant), which adds the ANTLR dependency itself (which is
then replaced at compile time).

All go runtime tests now pass.

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Rm remote github actions; hosted seems to work

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* install golang with curl; go was missing from dev

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: Rework of all Hash() and Equals() methods - implement generic collections

 - Implement new collections using generics that implement the functionality
   required by the Java runtime in a more idiomatic Go way.
 - Fix Hash() and Equals() for all objects in the runtime
 - Fix getConflictingAlts so that it behaves the same way as Java, using a
   new generic collection
 - Replaces the use of the array2DHashSet, which was causing unneeded memory
   allocations. Replaced with generic collection that allocates minimally
   (though, I think I can improve on that with a little analysis).

Jim Idle - jimi@idle.ws

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #3718 Correct DFAState index in Lexer ATN Simulator

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* feat: Reduce initial memory allocations for collections

  - Many small collections are created at runtime, the default allocation for
    maps, even though small, still requires memory. Specifying a very small
    initial allocation prevents unnecesary allocations and has no measurable
    effect on performance. A small incremental change.

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #3758 Allow for string being a keyword and fix go template to use escapedName

  - The go template was ignoring the use of escapedName in many places and was
    not consistenet with the Java version.
  - Added 'string' to the list of reserved words for the Go target

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #3758 Add go.sum to the repo

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #3758 Ensure that standard runtime extensions are included in go.mod

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #2826  Go template is incorrect for dynamic scopes

closes #2826
obviates PR #3101

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #2016 - Generate correct iGo code for lists in a grammar, such as `label+=arg+`

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* feat: Bump poms to use 4.11 Snapshot

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* turn off Golang test at circleci for now

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Replace smart-quote with single-quote in code examples

Signed-off-by: Tim McCormack <cortex@brainonfire.net>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Augment error message during testing to include full cause of problem.

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Augment error message during testing to include full cause of problem. (round 2 to avoid null ptr)

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Cpp: Link to threads library

As detailed in #3708, it is necessary to link against the (p)threads
library in order to be able to use std::call_once without producing
linker errors.

Since this function is frequently used in ANTLR's cpp version, this
commit ensures that the respective library is always linked against in
order to avoid this error, even if downstream users are not explicitly
linking against an appropriate threads library.

Fixes #3708

Signed-off-by: Robert Adam <dev@robert-adam.de>

Co-authored-by: Bryan Tan <Technius@users.noreply.github.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* add test for #2016 and fix java.

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* ensure all targets have the appropriate argument list for the template causing the problem.

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Fix other targets

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix format

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* add check that $args is a list

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* change made by @lingyv-li to fix bug in DART exposed by this test.

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix AssertIsList in multiple targets. Go doesn't pass test and has no AssertIsList so I'm dropping that test from the Go test suite.

How did a comment to the C++ runnerFor my future reference as to how to build things from the command line.

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* C++ gets an exception with this test so I'm turning it off. See antlr/antlr4#3845

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* feat: #3840 Move Go to version v4.11.0

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* feat: #3840 Create the v4 version of the Go runtime

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* feat: Create the v4 runtime layout for the Go runtime, ready for release tagging

Note that the vast majority of the changes here are just copying the runtime file in to
the /v4 subdirectory so that we can support legacy projects that use GOPATH only, as well
as users that can use go modules. At a later release, we will delete the default path, and move
the v4 subdirectory back to the top level. But, we cannot do that on this release.

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Reenable go tests on CircleCI

Signed-off-by: Ivan Kochurkin <kvanttt@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Fold constants in generated code for all runtimes

Go: getInlineTestSetWordSize 32 -> 64
Dart: get rid of BigInt
Swift: optimize TestSetInline
Python: fixes #3698
JavaScript: fixes #3699

Signed-off-by: Ivan Kochurkin <kvanttt@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Use int literals instead of refs for Python and JavaScript

Update getMultiTokenAlternativeDescriptor test

fixes #3703

Signed-off-by: Ivan Kochurkin <kvanttt@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* update release doc for Go version numbers

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix: #2016 Fix Go template list reference, go runtime and got test template for list labels

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* feat: Add a deprecation message to the existing v1 module

Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Split tool and runtime tests for GitHub workflow

Build only necessary modules for tests

Signed-off-by: Ivan Kochurkin <kvanttt@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Remove not used methods from FileUtils (runtime tests)

Signed-off-by: Ivan Kochurkin <kvanttt@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Update dependencies of antlr4-maven-plugin

Signed-off-by: Ivan Kochurkin <kvanttt@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Update jUnit: 5.8.2 -> 5.9.0

Signed-off-by: Ivan Kochurkin <kvanttt@gmail.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Fixes #3733; update ST4 so it uses proper ANTLR 3

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* tweak doc

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Set to 4.11.0 not 4.11 in poms

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* [maven-release-plugin] prepare release 4.11.0

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* [maven-release-plugin] prepare for next development iteration

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Damn. java target said 4.10.2 not 4.11.0

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* roll back to 4.11.0; made mistake

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* roll back to 4.11.0; made mistake

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* [maven-release-plugin] prepare release antlr4-master-4.11.0

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* [maven-release-plugin] prepare for next development iteration

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* use build and twine to publish source and wheel

Signed-off-by: Qijia Liu <liumeo@pku.edu.cn>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* tweak doc

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* tweak c++ build script to make Mac binaries with cmake/make

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* tweak release doc

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* tweak code / doc related to bad previous release

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* [maven-release-plugin] prepare release 4.11.1

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* [maven-release-plugin] prepare for next development iteration

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* clean up deploy c++ source script

Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* cleanup code generation

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* don't initialize default param values twice

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* add missing field

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* update codegen template for 4.11.1

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* support new param: Parser

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix template for 4.11

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* default export Listener and Visitor

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* also default export parser and lexer

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* all tests pass except 7 caused by #3868

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix issues

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* make it easy to break

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix #3868

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* ALL TESTS PASS!!!!

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* cross fingers with CI

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* try fixing broken go tests

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Try fix typescript CI

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* disable cpp for now

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix broken config

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* try fix macos gh build

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* improve speed by caching node_modules

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* no longer using ts-node

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix all tsc warnings

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* try fix MacOS CI

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* CI errors seem random, reactivate ubuntu

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Disable node_modules caching, which seems to randomly fail in CI

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* don't delete symlink contents on windows (java bug with is SymbolicLink ?)

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* fix broken windows CI

Signed-off-by: ERIC-WINDOWS\ericv <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* verify windows ci

Signed-off-by: ERIC-WINDOWS\ericv <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* Revert "verify windows ci"

This reverts commit 770d8218ecbc1a94d60854d5b00cc3c761c3469c.

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* reinstate full CI

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* manually merged

* manually merge

* fix merge

* fix broken template

* add template for invoking context list

* fix typo

* fix test templates

* Add code of conduct but with a different name since I do not like that name

Signed-off-by: Terence Parr <parrt@antlr.org>

* Update C# release instructions

* Tweak code of conduct

Signed-off-by: Terence Parr <parrt@antlr.org>

* Bring back the Package.swift in the project's root

Signed-off-by: Nikolay Edigaryev <edigaryev@gmail.com>

* swift-target.md: fix SPM installation instructions

Signed-off-by: Nikolay Edigaryev <edigaryev@gmail.com>

* the scope (parser or lexer) in @parser::header was dropped, so keep track of it and only include @Header in Listener and Visitor code

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>

* drop workaround in favor of #3878

* drop cache usage since it fails in CI

* #3878 was missing some scenarios

* fix issue when deleting test folder

* fix warnings

* drop duplicate behavior

* drop alien 'abstractRecognizer' property

* drop alien property 'channels'

* fix various codegen issues

* change import

* restore js extensions, see microsoft/TypeScript#50501

* use consistent inheritance

* more API

* more API stuff

* fix typo

* fix typescript exports

* use ts-node to run typescript tests

* webpack runtime before linking

* fix exec paths on windows

Signed-off-by: ERIC-WINDOWS\ericv <eric.vergnaud@wanadoo.fr>

* fix failing tests

* fix a few import issues

* merge typescript-target with latest dev

* runs Java and JavaScript tests after merging typescript-target

* merge test template

* skip unsupported test

* fix template prototype

* fix missing merge

* bump typescript beta version after rebase

* update docs

* rollback unwanted changes

Signed-off-by: HS <hs@apotell.com>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: nicksxs <nicksxs@hotmail.com>
Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Hell_Ghost <dev.hellghost@gmail.com>
Signed-off-by: Hell_Ghost dev.hellghost@gmail.com
Signed-off-by: Ross Patterson <ross.patterson@gmail.com>
Signed-off-by: James Taylor <jamestaylor@apache.org>
Signed-off-by: Bryan Tan <bryantan@technius.net>
Signed-off-by: Jim.Idle <jimi@gatherstars.com>
Signed-off-by: Tim McCormack <cortex@brainonfire.net>
Signed-off-by: Ivan Kochurkin <kvanttt@gmail.com>
Signed-off-by: Qijia Liu <liumeo@pku.edu.cn>
Signed-off-by: ERIC-WINDOWS\ericv <eric.vergnaud@wanadoo.fr>
Signed-off-by: Nikolay Edigaryev <edigaryev@gmail.com>
Co-authored-by: HS <hs@apotell.com>
Co-authored-by: nicksxs <nicksxs@hotmail.com>
Co-authored-by: Terence Parr <parrt@antlr.org>
Co-authored-by: Hell_Ghost <dev.hellghost@gmail.com>
Co-authored-by: Ross Patterson <ross.patterson@gmail.com>
Co-authored-by: James Taylor <jamestaylor@apache.org>
Co-authored-by: Bryan Tan <bryantan@technius.net>
Co-authored-by: Jim.Idle <jimi@gatherstars.com>
Co-authored-by: Tim McCormack <cortex@brainonfire.net>
Co-authored-by: Robert Adam <dev@robert-adam.de>
Co-authored-by: Bryan Tan <Technius@users.noreply.github.com>
Co-authored-by: Ivan Kochurkin <kvanttt@gmail.com>
Co-authored-by: Qijia Liu <liumeo@pku.edu.cn>
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
  • Loading branch information
15 people committed Dec 21, 2022
1 parent 1ce192d commit 692c4f2
Show file tree
Hide file tree
Showing 86 changed files with 1,968 additions and 1,577 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ env:
es2016: true
amd: true
jasmine: true
extends: 'eslint:recommended'
extends:
- eslint:recommended
globals:
Atomics: readonly
SharedArrayBuffer: readonly
Set: readonly
# parser: babel-eslint
parser: "@babel/eslint-parser"
parserOptions:
sourceType: module
project: ['./tsconfig.json']
rules:
no-unused-vars: ["error", {vars: "all", args: "none"}]
no-prototype-builtins: [ "off" ]
Expand Down
2,524 changes: 1,122 additions & 1,402 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "antlr4",
"version": "4.11.1",
"version": "4.12.0-beta.1",
"type": "module",
"description": "JavaScript runtime for ANTLR4",
"main": "src/antlr4/index.js",
"main": "dist/antlr4.js",
"types": "src/antlr4/index.d.ts",
"repository": "antlr/antlr4.git",
"keywords": [
"lexer",
Expand All @@ -18,23 +19,30 @@
},
"homepage": "https://github.com/antlr/antlr4",
"devDependencies": {
"@babel/preset-env": "^7.16.11",
"babel-loader": "^8.2.4",
"eslint-plugin-es5": "^1.5.0",
"eslint-webpack-plugin": "^3.1.1",
"@babel/core": "^7.19.1",
"@babel/preset-env": "^7.19.4",
"@types/node": "^18.7.23",
"@babel/eslint-parser": "^7.19.1",
"babel-loader": "^8.2.5",
"compression-webpack-plugin": "^10.0.0",
"eslint": "^8.23.1",
"eslint-webpack-plugin": "^3.2.0",
"glob-parent": "^6.0.2",
"jasmine": "^4.0.2",
"jasmine-spec-reporter": "^7.0.0",
"minimist": "^1.2.6",
"source-map-support": "^0.5.21",
"terser-webpack-plugin": "^5.3.6",
"typescript": "^4.8.3",
"webpack": "^5.66.0",
"webpack-cli": "^4.9.1"
"webpack-cli": "^4.10.0"
},
"scripts": {
"build": "webpack",
"test": "jasmine"
},
"engines": {
"node": ">=14"
"node": ">=16"
},
"browser": {
"fs": false,
Expand Down
8 changes: 8 additions & 0 deletions src/antlr4/BufferedTokenStream.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { TokenStream } from './TokenStream';
import { Lexer } from "./Lexer";

export declare class BufferedTokenStream extends TokenStream {

tokenSource: Lexer;

}
17 changes: 11 additions & 6 deletions src/antlr4/BufferedTokenStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ export default class BufferedTokenStream extends TokenStream {
return this.tokenSource.getSourceName();
}

// Get the text of all tokens in this buffer.///
// Get the text of all tokens in this buffer.///
getText(interval) {
this.lazyInit();
this.fill();
if (interval === undefined || interval === null) {
if (!interval) {
interval = new Interval(0, this.tokens.length - 1);
}
let start = interval.start;
Expand Down Expand Up @@ -371,11 +371,16 @@ export default class BufferedTokenStream extends TokenStream {
return s;
}

// Get all tokens from lexer until EOF///
// Get all tokens from lexer until EOF///
fill() {
this.lazyInit();
while (this.fetch(1000) === 1000) {
continue;
}
// noinspection StatementWithEmptyBodyJS
while (this.fetch(1000) === 1000);
}
}

Object.defineProperty(BufferedTokenStream, "size", {
get: function() {
return this.tokens.length;
}
})
11 changes: 11 additions & 0 deletions src/antlr4/CharStream.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export declare class CharStream {

index: number; // defined as property

constructor(data: string);
constructor(data: string, decodeToUnicodeCodePoints: boolean);
seek(index: number): void;
consume(): void;
getText(start: number, stop: number): string;
LA(offset: number): number;
}
127 changes: 127 additions & 0 deletions src/antlr4/CharStream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/

import Token from './Token.js';
import './polyfills/codepointat.js';
import './polyfills/fromcodepoint.js';

/**
* If decodeToUnicodeCodePoints is true, the input is treated
* as a series of Unicode code points.
*
* Otherwise, the input is treated as a series of 16-bit UTF-16 code
* units.
*/
export default class CharStream {
constructor(data, decodeToUnicodeCodePoints) {
this.name = "<empty>";
this.strdata = data;
this.decodeToUnicodeCodePoints = decodeToUnicodeCodePoints || false;
// _loadString - Vacuum all input from a string and then treat it like a buffer.
this._index = 0;
this.data = [];
if (this.decodeToUnicodeCodePoints) {
for (let i = 0; i < this.strdata.length; ) {
const codePoint = this.strdata.codePointAt(i);
this.data.push(codePoint);
i += codePoint <= 0xFFFF ? 1 : 2;
}
} else {
this.data = new Array(this.strdata.length);
for (let i = 0; i < this.strdata.length; i++) {
this.data[i] = this.strdata.charCodeAt(i);
}
}
this._size = this.data.length;
}

/**
* Reset the stream so that it's in the same state it was
* when the object was created *except* the data array is not
* touched.
*/
reset() {
this._index = 0;
}

consume() {
if (this._index >= this._size) {
// assert this.LA(1) == Token.EOF
throw ("cannot consume EOF");
}
this._index += 1;
}

LA(offset) {
if (offset === 0) {
return 0; // undefined
}
if (offset < 0) {
offset += 1; // e.g., translate LA(-1) to use offset=0
}
const pos = this._index + offset - 1;
if (pos < 0 || pos >= this._size) { // invalid
return Token.EOF;
}
return this.data[pos];
}

LT(offset) {
return this.LA(offset);
}

// mark/release do nothing; we have entire buffer
mark() {
return -1;
}

release(marker) {
}

/**
* consume() ahead until p==_index; can't just set p=_index as we must
* update line and column. If we seek backwards, just set p
*/
seek(_index) {
if (_index <= this._index) {
this._index = _index; // just jump; don't update stream state (line,
// ...)
return;
}
// seek forward
this._index = Math.min(_index, this._size);
}

getText(start, stop) {
if (stop >= this._size) {
stop = this._size - 1;
}
if (start >= this._size) {
return "";
} else {
if (this.decodeToUnicodeCodePoints) {
let result = "";
for (let i = start; i <= stop; i++) {
result += String.fromCodePoint(this.data[i]);
}
return result;
} else {
return this.strdata.slice(start, stop + 1);
}
}
}

toString() {
return this.strdata;
}

get index(){
return this._index;
}

get size(){
return this._size;
}
}
10 changes: 10 additions & 0 deletions src/antlr4/CommonToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ export default class CommonToken extends Token {
return t;
}

cloneWithType(type) {
const t = new CommonToken(this.source, type, this.channel, this.start, this.stop);
t.tokenIndex = this.tokenIndex;
t.line = this.line;
t.column = this.column;
if (type === Token.EOF)
t.text = "";
return t;
}

toString() {
let txt = this.text;
if (txt !== null) {
Expand Down
11 changes: 11 additions & 0 deletions src/antlr4/CommonTokenStream.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {Lexer} from "./Lexer";
import {BufferedTokenStream} from "./BufferedTokenStream";

export declare class CommonTokenStream extends BufferedTokenStream {
// properties
tokens: string[];
// methods
constructor(lexer: Lexer);
constructor(lexer: Lexer, channel: number);
fill(): void;
}
10 changes: 10 additions & 0 deletions src/antlr4/FileStream.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {CharStream} from "./CharStream";

export declare class FileStream extends CharStream {

index: number; // defined as property

constructor(fileName: string);
constructor(fileName: string, decodeToUnicodeCodePoints: boolean);

}
4 changes: 4 additions & 0 deletions src/antlr4/InputStream.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare class InputStream {
constructor(data: string);
constructor(data: string, decodeToUnicodeCodePoints: boolean);
}
Loading

0 comments on commit 692c4f2

Please sign in to comment.