Match one of the characters specified in the character set. Interpret x-y as the set of characters between range x and y, inclusively. The following escaped characters are interpreted as single special characters: \n, \r, \b, \t, \f, \uXXXX, and \u{XXXXXX}. To get ], \, or - you must escape them with \.
+Match one of the characters specified in the character set. Interpret x-y as the set of characters between range x and y, inclusively. The following escaped characters are interpreted as single special characters: \n, \r, \b, \t, \f, \uXXXX, and \u{XXXXXX}. To get ] or \ you must escape them with \. To get - you must escape it with \ too, except for the case when - is the first or last character in the set.
You can also include all characters matching Unicode properties (general category, boolean, or enumerated including scripts and blocks) with \p{PropertyName} or \p{EnumProperty=Value}. (You can invert the test with \P{PropertyName} or \P{EnumProperty=Value}).
@@ -90,6 +90,8 @@ UNICODE_ID : [\p{Alpha}\p{General_Category=Other_Letter}] [\p{Alnum}\p{General_C EMOJI : [\u{1F4A9}\u{1F926}] ; // note Unicode code points > U+FFFF DASHBRACK : [\-\]]+ ; // match - or ] one or more times + +DASH : [---] ; // match a single -, i.e., "any character" between - and - (note first and last - not escaped)END : ('endif'|'end') {System.out.println("found an end");} ; @@ -244,7 +246,8 @@ The mode commands alter the mode stack and hence the mode of the lexer. The 'mor ``` // Default "mode": Everything OUTSIDE of a tag COMMENT : '' ; -CDATA : '' ;OPEN : '<' -> pushMode(INSIDE) ; +CDATA : '' ; +OPEN : '<' -> pushMode(INSIDE) ; ... XMLDeclOpen : ' pushMode(INSIDE) ; SPECIAL_OPEN: '' Name -> more, pushMode(PROC_INSTR) ; diff --git a/doc/lexicon.md b/doc/lexicon.md index 078dc3e7a..92081575a 100644 --- a/doc/lexicon.md +++ b/doc/lexicon.md @@ -26,8 +26,8 @@ The Javadoc comments are hidden from the parser and are ignored at the moment. Token names always start with a capital letter and so do lexer rules as defined by Java’s `Character.isUpperCase` method. Parser rule names always start with a lowercase letter (those that fail `Character.isUpperCase`). The initial character can be followed by uppercase and lowercase letters, digits, and underscores. Here are some sample names: ``` -ID, LPAREN, RIGHT_CURLY // token names/rules -expr, simpleDeclarator, d2, header_file // rule names +ID, LPAREN, RIGHT_CURLY // token names/lexer rules +expr, simpleDeclarator, d2, header_file // parser rule names ``` Like Java, ANTLR accepts Unicode characters in ANTLR names: @@ -96,7 +96,7 @@ The recognizers that ANTLR generates assume a character vocabulary containing al ## Actions -Actions are code blocks written in the target language. You can use actions in a number of places within a grammar, but the syntax is always the same: arbitrary text surrounded by curly braces. You don’t need to escape a closing curly character if it’s in a string or comment: `"}"` or `/*}*/`. If the curlies are balanced, you also don’t need to escape }: `{...}`. Otherwise, escape extra curlies with a backslash: `\{` or `\}`. The action text should conform to the target language as specified with thelanguage option. +Actions are code blocks written in the target language. You can use actions in a number of places within a grammar, but the syntax is always the same: arbitrary text surrounded by curly braces. You don’t need to escape a closing curly character if it’s in a string or comment: `"}"` or `/*}*/`. If the curlies are balanced, you also don’t need to escape }: `{...}`. Otherwise, escape extra curlies with a backslash: `\{` or `\}`. The action text should conform to the target language as specified with the language option. Embedded code can appear in: `@header` and `@members` named actions, parser and lexer rules, exception catching specifications, attribute sections for parser rules (return values, arguments, and locals), and some rule element options (currently predicates). diff --git a/doc/php-target.md b/doc/php-target.md new file mode 100644 index 000000000..d0f010528 --- /dev/null +++ b/doc/php-target.md @@ -0,0 +1,111 @@ +# ANTLR4 Runtime for PHP + +### First steps + +#### 1. Install ANTLR4 + +[The getting started guide](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md) +should get you started. + +#### 2. Install the PHP ANTLR runtime + +Each target language for ANTLR has a runtime package for running parser +generated by ANTLR4. The runtime provides a common set of tools for using your parser. + +Install the runtime with Composer: + +```bash +composer require antlr4-php-runtime +``` + +#### 3. Generate your parser + +You use the ANTLR4 "tool" to generate a parser. These will reference the ANTLR +runtime, installed above. + +Suppose you're using a UNIX system and have set up an alias for the ANTLR4 tool +as described in [the getting started guide](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md). +To generate your PHP parser, run the following command: + +```bash +antlr4 -Dlanguage=PHP MyGrammar.g4 +``` + +For a full list of antlr4 tool options, please visit the +[tool documentation page](https://github.com/antlr/antlr4/blob/master/doc/tool-options.md). + +### Complete example + +Suppose you're using the JSON grammar from https://github.com/antlr/grammars-v4/tree/master/json. + +Then, invoke `antlr4 -Dlanguage=PHP JSON.g4`. The result of this is a +collection of `.php` files in the `parser` directory including: +``` +JsonParser.php +JsonBaseListener.php +JsonLexer.php +JsonListener.php +``` + +Another common option to the ANTLR tool is `-visitor`, which generates a parse +tree visitor, but we won't be doing that here. For a full list of antlr4 tool +options, please visit the [tool documentation page](tool-options.md). + +We'll write a small main func to call the generated parser/lexer +(assuming they are separate). This one writes out the encountered +`ParseTreeContext`'s: + +```php +getText(); + } +} + +$input = InputStream::fromPath($argv[1]); +$lexer = new JSONLexer($input); +$tokens = new CommonTokenStream($lexer); +$parser = new JSONParser($tokens); +$parser->addErrorListener(new DiagnosticErrorListener()); +$parser->setBuildParseTree(true); +$tree = $parser->json(); + +ParseTreeWalker::default()->walk(new TreeShapeListener(), $tree); +``` + +Create a `example.json` file: +```json +{"a":1} +``` + +Parse the input file: + +``` +php json.php example.json +``` + +The expected output is: + +``` +{"a":1} +{"a":1} +"a":1 +1 +``` diff --git a/doc/releasing-antlr.md b/doc/releasing-antlr.md index a44e48e7d..a09fd33eb 100644 --- a/doc/releasing-antlr.md +++ b/doc/releasing-antlr.md @@ -9,17 +9,41 @@ Create a pre-release or full release at github; [Example 4.5-rc-1](https://githu Wack any existing tag as mvn will create one and it fails if already there. ``` -$ git tag -d 4.7 -$ git push origin :refs/tags/4.7 -$ git push upstream :refs/tags/4.7 +$ git tag -d 4.8 +$ git push origin :refs/tags/4.8 +$ git push upstream :refs/tags/4.8 ``` ### Create release candidate tag ```bash -$ git tag -a 4.7-rc1 -m 'heading towards 4.7' -$ git push origin 4.7-rc1 -$ git push upstream 4.7-rc1 +$ git tag -a 4.8-rc1 -m 'heading towards 4.8' +$ git push origin 4.8-rc1 +$ git push upstream 4.8-rc1 +``` + +## Update submodules + +Make sure you tell git to pull in the submodule (for every clone you do of antlr4): + +```bash +git submodule init +``` + +Also bump version to 4.8 in `runtime/PHP/src/RuntimeMetaData.php`. + +Update the runtime submodules by running the following command: + +```bash +git submodule update --recursive +git submodule update --remote --merge # might only need this last one but do both +``` + +Make sure these changes go back to antlr4 repo: + +```bash +git add runtime/PHP +git commit -m "Update PHP Runtime to latest version" ``` ## Bump version @@ -33,7 +57,7 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t * runtime/Python3/src/antlr4/Recognizer.py * runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs * runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj - * runtime/JavaScript/src/antlr4/package.json + * runtime/JavaScript/package.json * runtime/JavaScript/src/antlr4/Recognizer.js * runtime/Cpp/VERSION * runtime/Cpp/runtime/src/RuntimeMetaData.cpp @@ -41,6 +65,8 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t * runtime/Cpp/demo/generate.cmd * runtime/Go/antlr/recognizer.go * runtime/Swift/Antlr4/org/antlr/v4/runtime/RuntimeMetaData.swift + * runtime/Dart/lib/src/runtime_meta_data.dart + * runtime/Dart/pubspec.yaml * tool/src/org/antlr/v4/codegen/target/GoTarget.java * tool/src/org/antlr/v4/codegen/target/CppTarget.java * tool/src/org/antlr/v4/codegen/target/CSharpTarget.java @@ -59,6 +85,10 @@ find tool runtime -type f -exec grep -l '4\.6' {} \; Commit to repository. +## Building + +ugh. apparently you have to `mvn install` and then `mvn compile` or some such or subdir pom.xml's won't see the latest runtime build. + ## Maven Repository Settings First, make sure you have maven set up to communicate with staging servers etc... Create file `~/.m2/settings.xml` with appropriate username/password for staging server and gpg.keyname/passphrase for signing. Make sure it has strict visibility privileges to just you. On unix, it looks like: @@ -106,7 +136,7 @@ Here is the file template ## Maven deploy snapshot -The goal is to get a snapshot, such as `4.7-SNAPSHOT`, to the staging server: [antlr4 tool](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4) and [antlr4 java runtime](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-runtime). +The goal is to get a snapshot, such as `4.8-SNAPSHOT`, to the staging server: [antlr4 tool](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4) and [antlr4 java runtime](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-runtime). Do this: @@ -114,15 +144,15 @@ Do this: $ mvn deploy -DskipTests ... [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ antlr4-tool-testsuite --- -Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.7-SNAPSHOT/maven-metadata.xml -Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.7-SNAPSHOT/antlr4-tool-testsuite-4.7-20161211.173752-1.jar -Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.7-SNAPSHOT/antlr4-tool-testsuite-4.7-20161211.173752-1.jar (3 KB at 3.4 KB/sec) -Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.7-SNAPSHOT/antlr4-tool-testsuite-4.7-20161211.173752-1.pom -Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.7-SNAPSHOT/antlr4-tool-testsuite-4.7-20161211.173752-1.pom (3 KB at 6.5 KB/sec) +Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/maven-metadata.xml +Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/antlr4-tool-testsuite-4.8-20161211.173752-1.jar +Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/antlr4-tool-testsuite-4.8-20161211.173752-1.jar (3 KB at 3.4 KB/sec) +Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/antlr4-tool-testsuite-4.8-20161211.173752-1.pom +Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/antlr4-tool-testsuite-4.8-20161211.173752-1.pom (3 KB at 6.5 KB/sec) Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml Downloaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml (371 B at 1.4 KB/sec) -Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.7-SNAPSHOT/maven-metadata.xml -Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.7-SNAPSHOT/maven-metadata.xml (774 B at 1.8 KB/sec) +Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/maven-metadata.xml +Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/maven-metadata.xml (774 B at 1.8 KB/sec) Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml (388 B at 0.9 KB/sec) [INFO] ------------------------------------------------------------------------ @@ -192,18 +222,18 @@ It will start out by asking you the version number: ``` ... -What is the release version for "ANTLR 4"? (org.antlr:antlr4-master) 4.7: : 4.7 -What is the release version for "ANTLR 4 Runtime"? (org.antlr:antlr4-runtime) 4.7: : -What is the release version for "ANTLR 4 Tool"? (org.antlr:antlr4) 4.7: : -What is the release version for "ANTLR 4 Maven plugin"? (org.antlr:antlr4-maven-plugin) 4.7: : -What is the release version for "ANTLR 4 Runtime Test Generator"? (org.antlr:antlr4-runtime-testsuite) 4.7: : -What is the release version for "ANTLR 4 Tool Tests"? (org.antlr:antlr4-tool-testsuite) 4.7: : -What is SCM release tag or label for "ANTLR 4"? (org.antlr:antlr4-master) antlr4-master-4.7: : 4.7 -What is the new development version for "ANTLR 4"? (org.antlr:antlr4-master) 4.7.1-SNAPSHOT: +What is the release version for "ANTLR 4"? (org.antlr:antlr4-master) 4.8: : 4.8 +What is the release version for "ANTLR 4 Runtime"? (org.antlr:antlr4-runtime) 4.8: : +What is the release version for "ANTLR 4 Tool"? (org.antlr:antlr4) 4.8: : +What is the release version for "ANTLR 4 Maven plugin"? (org.antlr:antlr4-maven-plugin) 4.8: : +What is the release version for "ANTLR 4 Runtime Test Generator"? (org.antlr:antlr4-runtime-testsuite) 4.8: : +What is the release version for "ANTLR 4 Tool Tests"? (org.antlr:antlr4-tool-testsuite) 4.8: : +What is SCM release tag or label for "ANTLR 4"? (org.antlr:antlr4-master) antlr4-master-4.8: : 4.8 +What is the new development version for "ANTLR 4"? (org.antlr:antlr4-master) 4.8.1-SNAPSHOT: ... ``` -Maven will go through your pom.xml files to update versions from 4.7-SNAPSHOT to 4.7 for release and then to 4.7.1-SNAPSHOT after release, which is done with: +Maven will go through your pom.xml files to update versions from 4.8-SNAPSHOT to 4.8 for release and then to 4.8.1-SNAPSHOT after release, which is done with: ```bash mvn release:perform -Darguments="-DskipTests" @@ -217,16 +247,18 @@ Now, go here: and on the left click "Staging Repositories". You click the staging repo and close it, then you refresh, click it and release it. It's done when you see it here: - [http://repo1.maven.org/maven2/org/antlr/antlr4-runtime/](http://repo1.maven.org/maven2/org/antlr/antlr4-runtime/) + [https://oss.sonatype.org/service/local/repositories/releases/content/org/antlr/antlr4-runtime/4.8-1/antlr4-runtime-4.8-1.jar](https://oss.sonatype.org/service/local/repositories/releases/content/org/antlr/antlr4-runtime/4.8-1/antlr4-runtime-4.8-1.jar) + +All releases should be here: https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/ Copy the jars to antlr.org site and update download/index.html ```bash -cp ~/.m2/repository/org/antlr/antlr4-runtime/4.7/antlr4-runtime-4.7.jar ~/antlr/sites/website-antlr4/download/antlr-runtime-4.7.jar -cp ~/.m2/repository/org/antlr/antlr4/4.7/antlr4-4.7-complete.jar ~/antlr/sites/website-antlr4/download/antlr-4.7-complete.jar +cp ~/.m2/repository/org/antlr/antlr4-runtime/4.8/antlr4-runtime-4.8.jar ~/antlr/sites/website-antlr4/download/antlr-runtime-4.8.jar +cp ~/.m2/repository/org/antlr/antlr4/4.8/antlr4-4.8-complete.jar ~/antlr/sites/website-antlr4/download/antlr-4.8-complete.jar cd ~/antlr/sites/website-antlr4/download -git add antlr-4.7-complete.jar -git add antlr-runtime-4.7.jar +git add antlr-4.8-complete.jar +git add antlr-runtime-4.8.jar ``` Update on site: @@ -238,7 +270,7 @@ Update on site: * scripts/topnav.js ``` -git commit -a -m 'add 4.7 jars' +git commit -a -m 'add 4.8 jars' git push origin gh-pages ``` @@ -247,16 +279,14 @@ git push origin gh-pages ### JavaScript ```bash -cd runtime/JavaScript/src -zip -r /tmp/antlr-javascript-runtime-4.7.zip antlr4 -cp /tmp/antlr-javascript-runtime-4.7.zip ~/antlr/sites/website-antlr4/download +cd runtime/JavaScript # git add, commit, push ``` **Push to npm** ```bash -cd runtime/JavaScript/src +cd runtime/JavaScript npm login npm publish antlr4 ``` @@ -264,11 +294,8 @@ npm publish antlr4 Move target to website ```bash -pushd ~/antlr/sites/website-antlr4/download -git add antlr-javascript-runtime-4.7.zip -git commit -a -m 'update JS runtime' -git push origin gh-pages -popd +npm run build +cp /dist/antlr4.js ~/antlr/sites/website-antlr4/download ``` ### CSharp @@ -309,7 +336,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. Restore completed in 427.62 ms for C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\Antlr4.Runtime.dotnet.csproj. Antlr4.Runtime.dotnet -> C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\lib\Release\netstandard1.3\Antlr4.Runtime.Standard.dll Antlr4.Runtime.dotnet -> C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\lib\Release\net35\Antlr4.Runtime.Standard.dll - Successfully created package 'C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\lib\Release\Antlr4.Runtime.Standard.4.7.2.nupkg'. + Successfully created package 'C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\lib\Release\Antlr4.Runtime.Standard.4.8.2.nupkg'. ``` **Publishing to NuGet** @@ -371,7 +398,7 @@ There are links to the artifacts in [download.html](http://www.antlr.org/downloa The C++ target is the most complex one, because it addresses multiple platforms, which require individual handling. We have 4 scenarios to cover: -* **Windows**: static and dynamic libraries for the VC++ runtime 2013 or 2015 (corresponding to Visual Studio 2013 or 2015) + header files. All that in 32 and 64bit, debug + release. +* **Windows**: static and dynamic libraries for the VC++ runtime 2017 or 2019 (corresponding to Visual Studio 2017 or 2019) + header files. All that in 32 and 64bit, debug + release. * **MacOS**: static and dynamic release libraries + header files. * **iOS**: no prebuilt binaries, but just a zip of the source, including the XCode project to build everything from source. * **Linux**: no prebuilt binaries, but just a zip of the source code, including the cmake file to build everything from source there. @@ -385,7 +412,7 @@ On a Mac (with XCode 7+ installed): ```bash cd runtime/Cpp ./deploy-macos.sh -cp antlr4-cpp-runtime-macos.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.7-macos.zip +cp antlr4-cpp-runtime-macos.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.8-macos.zip ``` On any Mac or Linux machine: @@ -393,15 +420,15 @@ On any Mac or Linux machine: ```bash cd runtime/Cpp ./deploy-source.sh -cp antlr4-cpp-runtime-source.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.7-source.zip +cp antlr4-cpp-runtime-source.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.8-source.zip ``` -On a Windows machine the build scripts checks if VS 2013 and/or VS 2015 are installed and builds binaries for each, if found. This script requires 7z to be installed (http://7-zip.org then do `set PATH=%PATH%;C:\Program Files\7-Zip\` from DOS not powershell). +On a Windows machine the build scripts checks if VS 2017 and/or VS 2019 are installed and builds binaries for each, if found. This script requires 7z to be installed (http://7-zip.org then do `set PATH=%PATH%;C:\Program Files\7-Zip\` from DOS not powershell). ```bash cd runtime/Cpp -deploy-windows.cmd -cp runtime\bin\vs-2015\x64\Release DLL\antlr4-cpp-runtime-vs2015.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.7-vs2015.zip +deploy-windows.cmd Community +cp antlr4-cpp-runtime-vs2019.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.8-vs2019.zip ``` Move target to website (**_rename to a specific ANTLR version first if needed_**): @@ -409,14 +436,27 @@ Move target to website (**_rename to a specific ANTLR version first if needed_** ```bash pushd ~/antlr/sites/website-antlr4/download # vi index.html -git add antlr4cpp-runtime-4.7-macos.zip -git add antlr4cpp-runtime-4.7-windows.zip -git add antlr4cpp-runtime-4.7-source.zip +git add antlr4cpp-runtime-4.8-macos.zip +git add antlr4cpp-runtime-4.8-windows.zip +git add antlr4cpp-runtime-4.8-source.zip git commit -a -m 'update C++ runtime' git push origin gh-pages popd ``` +### Dart + +Push to pub.dev + +```bash +cd runtime/Dart +pub publish +``` + +It will warn that no change log found for the new version. +If there are changes relevant to dart in this release, edit [CHANGELOG.md](https://github.com/antlr/antlr4/blob/master/runtime/Dart/CHANGELOG.md) to describe the changes. +Otherwise enter `N` to ignore the warning. + ## Update javadoc for runtime and tool First, gen javadoc: @@ -433,9 +473,9 @@ cd ~/antlr/sites/website-antlr4/api git checkout gh-pages git pull origin gh-pages cd Java -jar xvf ~/.m2/repository/org/antlr/antlr4-runtime/4.7/antlr4-runtime-4.7-javadoc.jar +jar xvf ~/.m2/repository/org/antlr/antlr4-runtime/4.8/antlr4-runtime-4.8-javadoc.jar cd ../JavaTool -jar xvf ~/.m2/repository/org/antlr/antlr4/4.7/antlr4-4.7-javadoc.jar +jar xvf ~/.m2/repository/org/antlr/antlr4/4.8/antlr4-4.8-javadoc.jar git commit -a -m 'freshen api doc' git push origin gh-pages ``` diff --git a/doc/resources/CaseChangingStream.js b/doc/resources/CaseChangingStream.js new file mode 100644 index 000000000..3af1ad612 --- /dev/null +++ b/doc/resources/CaseChangingStream.js @@ -0,0 +1,65 @@ +// +/* Copyright (c) 2012-2017 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. + */ +// + +function CaseChangingStream(stream, upper) { + this._stream = stream; + this._upper = upper; +} + +CaseChangingStream.prototype.LA = function(offset) { + var c = this._stream.LA(offset); + if (c <= 0) { + return c; + } + return String.fromCodePoint(c)[this._upper ? "toUpperCase" : "toLowerCase"]().codePointAt(0); +}; + +CaseChangingStream.prototype.reset = function() { + return this._stream.reset(); +}; + +CaseChangingStream.prototype.consume = function() { + return this._stream.consume(); +}; + +CaseChangingStream.prototype.LT = function(offset) { + return this._stream.LT(offset); +}; + +CaseChangingStream.prototype.mark = function() { + return this._stream.mark(); +}; + +CaseChangingStream.prototype.release = function(marker) { + return this._stream.release(marker); +}; + +CaseChangingStream.prototype.seek = function(_index) { + return this._stream.seek(_index); +}; + +CaseChangingStream.prototype.getText = function(start, stop) { + return this._stream.getText(start, stop); +}; + +CaseChangingStream.prototype.toString = function() { + return this._stream.toString(); +}; + +Object.defineProperty(CaseChangingStream.prototype, "index", { + get: function() { + return this._stream.index; + } +}); + +Object.defineProperty(CaseChangingStream.prototype, "size", { + get: function() { + return this._stream.size; + } +}); + +exports.CaseChangingStream = CaseChangingStream; diff --git a/doc/resources/CaseChangingStream.py b/doc/resources/CaseChangingStream.py new file mode 100644 index 000000000..6d2815de4 --- /dev/null +++ b/doc/resources/CaseChangingStream.py @@ -0,0 +1,13 @@ +class CaseChangingStream(): + def __init__(self, stream, upper): + self._stream = stream + self._upper = upper + + def __getattr__(self, name): + return self._stream.__getattribute__(name) + + def LA(self, offset): + c = self._stream.LA(offset) + if c <= 0: + return c + return ord(chr(c).upper() if self._upper else chr(c).lower()) diff --git a/doc/resources/CaseInsensitiveInputStream.js b/doc/resources/CaseInsensitiveInputStream.js deleted file mode 100644 index 5ec762de9..000000000 --- a/doc/resources/CaseInsensitiveInputStream.js +++ /dev/null @@ -1,54 +0,0 @@ -// -/* Copyright (c) 2012-2017 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. - */ -// - -function CaseInsensitiveInputStream(stream, upper) { - this._stream = stream; - this._case = upper ? String.toUpperCase : String.toLowerCase; - return this; -} - -CaseInsensitiveInputStream.prototype.LA = function (offset) { - c = this._stream.LA(i); - if (c <= 0) { - return c; - } - return this._case.call(String.fromCodePoint(c)) -}; - -CaseInsensitiveInputStream.prototype.reset = function() { - return this._stream.reset(); -}; - -CaseInsensitiveInputStream.prototype.consume = function() { - return this._stream.consume(); -}; - -CaseInsensitiveInputStream.prototype.LT = function(offset) { - return this._stream.LT(offset); -}; - -CaseInsensitiveInputStream.prototype.mark = function() { - return this._stream.mark(); -}; - -CaseInsensitiveInputStream.prototype.release = function(marker) { - return this._stream.release(marker); -}; - -CaseInsensitiveInputStream.prototype.seek = function(_index) { - return this._stream.getText(start, stop); -}; - -CaseInsensitiveInputStream.prototype.getText = function(start, stop) { - return this._stream.getText(start, stop); -}; - -CaseInsensitiveInputStream.prototype.toString = function() { - return this._stream.toString(); -}; - -exports.CaseInsensitiveInputStream = CaseInsensitiveInputStream; diff --git a/doc/resources/case_changing_stream.go b/doc/resources/case_changing_stream.go index 2963acf89..5b510fa32 100644 --- a/doc/resources/case_changing_stream.go +++ b/doc/resources/case_changing_stream.go @@ -1,13 +1,15 @@ -package antlr +package antlr_resource import ( "unicode" + + "github.com/antlr/antlr4/runtime/Go/antlr" ) // CaseChangingStream wraps an existing CharStream, but upper cases, or // lower cases the input before it is tokenized. type CaseChangingStream struct { - CharStream + antlr.CharStream upper bool } @@ -15,10 +17,8 @@ type CaseChangingStream struct { // NewCaseChangingStream returns a new CaseChangingStream that forces // all tokens read from the underlying stream to be either upper case // or lower case based on the upper argument. -func NewCaseChangingStream(in CharStream, upper bool) *CaseChangingStream { - return &CaseChangingStream{ - in, upper, - } +func NewCaseChangingStream(in antlr.CharStream, upper bool) *CaseChangingStream { + return &CaseChangingStream{in, upper} } // LA gets the value of the symbol at offset from the current position diff --git a/doc/targets.md b/doc/targets.md index 418630bb1..ad6e7dba9 100644 --- a/doc/targets.md +++ b/doc/targets.md @@ -9,12 +9,14 @@ This page lists the available and upcoming ANTLR runtimes. Please note that you * [Go](go-target.md) * [C++](cpp-target.md) * [Swift](swift-target.md) +* [PHP](php-target.md) +* [Dart](dart-target.md) ## Target feature parity New features generally appear in the Java target and then migrate to the other targets, but these other targets don't always get updated in the same overall tool release. This section tries to identify features added to Java that have not been added to the other targets. -|Feature|Java|C♯|Python2|Python3|JavaScript|Go|C++|Swift| -|---|---|---|---|---|---|---|---|---| -|Ambiguous tree construction|4.5.1|-|-|-|-|-|-|-| +|Feature|Java|C♯|Python2|Python3|JavaScript|Go|C++|Swift|PHP|Dart +|---|---|---|---|---|---|---|---|---|---|---| +|Ambiguous tree construction|4.5.1|-|-|-|-|-|-|-|-|-| diff --git a/pom.xml b/pom.xml index e636655cf..5c7a93549 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@org.antlr antlr4-master -4.7.3-SNAPSHOT +4.8-2-SNAPSHOT pom ANTLR 4 @@ -151,7 +151,7 @@org.apache.maven.plugins maven-compiler-plugin -3.6.0 +3.8.1 ${maven.compiler.target} diff --git a/runtime-testsuite/annotations/pom.xml b/runtime-testsuite/annotations/pom.xml index 3d39f719f..97bf78649 100644 --- a/runtime-testsuite/annotations/pom.xml +++ b/runtime-testsuite/annotations/pom.xml @@ -9,7 +9,7 @@org.antlr antlr4-master -4.7.3-SNAPSHOT +4.8-2-SNAPSHOT ../../pom.xml antlr4-runtime-test-annotations diff --git a/runtime-testsuite/pom.xml b/runtime-testsuite/pom.xml index ebfdbd723..b6368917d 100644 --- a/runtime-testsuite/pom.xml +++ b/runtime-testsuite/pom.xml @@ -10,7 +10,7 @@org.antlr antlr4-master -4.7.3-SNAPSHOT +4.8-2-SNAPSHOT antlr4-runtime-testsuite ANTLR 4 Runtime Tests (2nd generation) @@ -26,7 +26,7 @@org.antlr ST4 -4.1 +4.3 test @@ -59,19 +59,6 @@ -4.12 test - -org.seleniumhq.selenium -selenium-java -2.46.0 -test -- org.eclipse.jetty -jetty-server - -9.4.19.v20190610 -test -org.glassfish javax.json @@ -109,14 +96,16 @@-Dfile.encoding=UTF-8 - +**/csharp/Test*.java -**/java/Test*.java -**/go/Test*.java -**/javascript/node/Test*.java -**/python2/Test*.java -**/python3/Test*.java -${antlr.tests.swift} -**/csharp/Test*.java +**/java/Test*.java +**/go/Test*.java +**/javascript/Test*.java +**/python2/Test*.java +**/python3/Test*.java +**/php/Test*.java +**/dart/Test*.java +${antlr.tests.swift} +diff --git a/runtime-testsuite/processors/pom.xml b/runtime-testsuite/processors/pom.xml index 24fd9b786..c417c626d 100644 --- a/runtime-testsuite/processors/pom.xml +++ b/runtime-testsuite/processors/pom.xml @@ -9,7 +9,7 @@ org.antlr antlr4-master -4.7.3-SNAPSHOT +4.8-2-SNAPSHOT ../../pom.xml antlr4-runtime-test-annotation-processors diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/CSharp.test.stg b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/CSharp.test.stg index 597248f2b..cd9270286 100644 --- a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/CSharp.test.stg +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/CSharp.test.stg @@ -14,9 +14,9 @@ Cast(t,v) ::= "(() )" Append(a,b) ::= " + " -Concat(a,b) ::= "" +AppendStr(a,b) ::= <% %> -DeclareLocal(s,v) ::= "Object =;" +Concat(a,b) ::= "" AssertIsList(v) ::= "System.Collections.IList __ttt__ = ;" // just use static type system @@ -26,14 +26,18 @@ InitIntMember(n,v) ::= <%int = ;%> InitBooleanMember(n,v) ::= <%bool = ;%> +InitIntVar(n,v) ::= <% %> + +IntArg(n) ::= "int " + +VarRef(n) ::= " " + GetMember(n) ::= <%this. %> SetMember(n,v) ::= <%this. = ;%> AddMember(n,v) ::= <%this. += ;%> -PlusMember(v,n) ::= <% + this. %> - MemberEquals(n,v) ::= <%this. == %> ModMemberEquals(n,m,v) ::= <%this. % == %> @@ -94,6 +98,8 @@ bool Property() { ParserPropertyCall(p, call) ::= " .
" +PositionAdjustingLexerDef() ::= "" + PositionAdjustingLexer() ::= << public override IToken NextToken() { diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Chrome.test.stg b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Chrome.test.stg index e02457a90..7b4729eb5 100644 --- a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Chrome.test.stg +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Chrome.test.stg @@ -14,9 +14,9 @@ Cast(t,v) ::= " " Append(a,b) ::= " + " -Concat(a,b) ::= "" +AppendStr(a,b) ::= <% %> -DeclareLocal(s,v) ::= "var =;" +Concat(a,b) ::= "" AssertIsList(v) ::= < > @@ -26,14 +26,18 @@ InitIntMember(n,v) ::= <%this. = ;%> InitBooleanMember(n,v) ::= <%this. = ;%> +InitIntVar(n,v) ::= <% %> + +IntArg(n) ::= " " + +VarRef(n) ::= " " + GetMember(n) ::= <%this. %> SetMember(n,v) ::= <%this. = ;%> AddMember(n,v) ::= <%this. += ;%> -PlusMember(v,n) ::= <% + this. %> - MemberEquals(n,v) ::= <%this. === %> ModMemberEquals(n,m,v) ::= <%this. % === %> @@ -70,7 +74,7 @@ LANotEquals(i, v) ::= <%this._input.LA()!= %> TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===%> -ImportListener(X) ::= <Listener = require('./ Listener'). Listener;>> +ImportListener(X) ::= "" GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)" @@ -92,6 +96,8 @@ this.Property = function() { } >> +PositionAdjustingLexerDef() ::= "" + PositionAdjustingLexer() ::= << PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) { diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Cpp.test.stg b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Cpp.test.stg index c2b1a7f84..a5dab18bd 100644 --- a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Cpp.test.stg +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Cpp.test.stg @@ -9,19 +9,20 @@ Assert(s) ::= "" Cast(t,v) ::= "dynamic_cast\< *>( )" // Should actually use a more specific name. We may have to use other casts as well. Append(a,b) ::= " + ->toString()" Concat(a,b) ::= "" - -DeclareLocal(s,v) ::= " =" +AppendStr(a,b) ::= " + " AssertIsList(v) ::= "assert( .size() >= 0);" // Use a method that exists only on a list (vector actually). AssignLocal(s,v) ::= " =;" InitIntMember(n,v) ::= "int = ;" InitBooleanMember(n,v) ::= "bool = ;" +InitIntVar(n,v) ::= <% %> +IntArg(n) ::= "int " +VarRef(n) ::= " " GetMember(n) ::= " " SetMember(n,v) ::= " = ;" AddMember(n,v) ::= " += ;" -PlusMember(v,n) ::= " + " MemberEquals(n,v) ::= " == " ModMemberEquals(n,m,v) ::= " % == " ModMemberNotEquals(n,m,v) ::= " % != " @@ -68,6 +69,8 @@ bool Property() { ParserPropertyCall(p, call) ::= " " +PositionAdjustingLexerDef() ::= "" + PositionAdjustingLexer() ::= << protected: class PositionAdjustingLexerATNSimulator : public antlr4::atn::LexerATNSimulator { diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Dart.test.stg b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Dart.test.stg new file mode 100644 index 000000000..9f7d65cb0 --- /dev/null +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Dart.test.stg @@ -0,0 +1,318 @@ +writeln(s) ::= < );>> +write(s) ::= < );>> +writeList(s) ::= < );>> + +False() ::= "false" + +True() ::= "true" + +Not(v) ::= "! " + +Assert(s) ::= < );>> + +Cast(t,v) ::= "( as )" + +Append(a,b) ::= ".toString() + .toString()" + +AppendStr(a,b) ::= <% %> + +Concat(a,b) ::= "" + +AssertIsList(v) ::= "assert ( is List);" // just use static type system + +AssignLocal(s,v) ::= " =;" + +InitIntMember(n,v) ::= <%int = ;%> + +InitBooleanMember(n,v) ::= <%bool = ;%> + +InitIntVar(n,v) ::= <% %> + +IntArg(n) ::= "int " + +VarRef(n) ::= " " + +GetMember(n) ::= <%this. %> + +SetMember(n,v) ::= <%this. = ;%> + +AddMember(n,v) ::= <%this. += ;%> + +MemberEquals(n,v) ::= <%this. == %> + +ModMemberEquals(n,m,v) ::= <%this. % == %> + +ModMemberNotEquals(n,m,v) ::= <%this. % != %> + +DumpDFA() ::= "this.dumpDFA();" + +Pass() ::= "" + +StringList() ::= "List\ " + +BuildParseTrees() ::= "buildParseTree = true;" + +BailErrorStrategy() ::= <%errorHandler = new BailErrorStrategy();%> + +ToStringTree(s) ::= <% .toStringTree(parser: this)%> + +Column() ::= "this.charPositionInLine" + +Text() ::= "this.text" + +ValEquals(a,b) ::= <%==%> + +TextEquals(a) ::= <%this.text == ""%> + +PlusText(a) ::= <%"" + this.text%> + +InputText() ::= "tokenStream.text" + +LTEquals(i, v) ::= <%tokenStream.LT().text ==%> + +LANotEquals(i, v) ::= <%tokenStream.LA()!= %> + +TokenStartColumnEquals(i) ::= <%this.tokenStartCharPositionInLine==%> + +ImportListener(X) ::= "" + +GetExpectedTokenNames() ::= "this.expectedTokens.toString(vocabulary: this.vocabulary)" + +RuleInvocationStack() ::= "ruleInvocationStack" + +LL_EXACT_AMBIG_DETECTION() ::= < > + +ParserToken(parser, token) ::= <% .TOKEN_ %> + +Production(p) ::= <% %> + +Result(r) ::= <%
%> + +ParserPropertyMember() ::= << +@members { +bool Property() { + return true; +} +} +>> + +ParserPropertyCall(p, call) ::= " .
" + +PositionAdjustingLexerDef() ::= << +class PositionAdjustingLexerATNSimulator extends LexerATNSimulator { + PositionAdjustingLexerATNSimulator(Lexer recog, ATN atn, + List\ decisionToDFA, PredictionContextCache sharedContextCache) + : super(atn, decisionToDFA, sharedContextCache, recog: recog); + + void resetAcceptPosition(CharStream input, int index, int line, + int charPositionInLine) { + input.seek(index); + this.line = line; + this.charPositionInLine = charPositionInLine; + consume(input); + } +} +>> + +PositionAdjustingLexer() ::= << +@override +Token nextToken() { + if (!(super.interpreter is PositionAdjustingLexerATNSimulator)) { + interpreter = new PositionAdjustingLexerATNSimulator( + this, _ATN, _decisionToDFA, _sharedContextCache); + } + + return super.nextToken(); +} + +@override +Token emit() { + switch (type) { + case TOKEN_TOKENS: + handleAcceptPositionForKeyword("tokens"); + break; + + case TOKEN_LABEL: + handleAcceptPositionForIdentifier(); + break; + + default: + break; + } + + return super.emit(); +} + +bool handleAcceptPositionForIdentifier() { + String tokenText = text; + int identifierLength = 0; + while (identifierLength \< tokenText.length && + isIdentifierChar(tokenText[identifierLength])) { + identifierLength++; + } + + if (inputStream.index > tokenStartCharIndex + identifierLength) { + int offset = identifierLength - 1; + interpreter.resetAcceptPosition(inputStream, tokenStartCharIndex + offset, + tokenStartLine, tokenStartCharPositionInLine + offset); + return true; + } + + return false; +} + +bool handleAcceptPositionForKeyword(String keyword) { + if (inputStream.index > tokenStartCharIndex + keyword.length) { + int offset = keyword.length - 1; + interpreter.resetAcceptPosition(inputStream, tokenStartCharIndex + offset, + tokenStartLine, tokenStartCharPositionInLine + offset); + return true; + } + + return false; +} + +@override +PositionAdjustingLexerATNSimulator get interpreter { + return super.interpreter as PositionAdjustingLexerATNSimulator; +} + +static bool isIdentifierChar(String c) { + return isLetterOrDigit(c) || c == '_'; +} + +static const ZERO = 48; +static const LOWER_A = 97; +static const LOWER_Z = 122; +static const UPPER_A = 65; +static const UPPER_Z = 90; + +static bool isLetterOrDigit(String char) => isLetter(char) || isDigit(char); + +// Note: this is intentially ASCII only +static bool isLetter(String char) { + if (char == null) return false; + var cc = char.codeUnitAt(0); + return cc >= LOWER_A && cc \<= LOWER_Z || cc >= UPPER_A && cc \<= UPPER_Z; +} + +static bool isDigit(String char) { + if (char == null) return false; + var cc = char.codeUnitAt(0); + return cc >= ZERO && cc \< ZERO + 10; +} +>> + +BasicListener(X) ::= << +@parser::definitions { +class LeafListener extends TBaseListener { + void visitTerminal(TerminalNode node) { + print(node.symbol.text); + } +} +} +>> + +WalkListener(s) ::= << +ParseTreeWalker walker = new ParseTreeWalker(); +walker.walk(new LeafListener(), ); +>> + +TreeNodeWithAltNumField(X) ::= << +@parser::definitions { +class MyRuleNode extends ParserRuleContext { + int altNum; + + MyRuleNode(ParserRuleContext parent, int invokingStateNumber) + : super(parent, invokingStateNumber); + + @override int get altNumber { + return altNum; + } + + @override void set altNumber(int altNum) { + this.altNum = altNum; + } +} +} +>> + +TokenGetterListener(X) ::= << +@parser::definitions { +class LeafListener extends TBaseListener { + void exitA(AContext ctx) { + if (ctx.childCount==2) + stdout.write("${ctx.INT(0).symbol.text} ${ctx.INT(1).symbol.text} ${ctx.INTs()}"); + else + print(ctx.ID().symbol); + } +} +} +>> + +RuleGetterListener(X) ::= << +@parser::definitions { +class LeafListener extends TBaseListener { + void exitA(AContext ctx) { + if (ctx.childCount==2) { + stdout.write("${ctx.b(0).start.text} ${ctx.b(1).start.text} ${ctx.bs()[0].start.text}"); + } else + print(ctx.b(0).start.text); + } +} +} +>> + + +LRListener(X) ::= << +@parser::definitions { +class LeafListener extends TBaseListener { + void exitE(EContext ctx) { + if (ctx.childCount==3) { + stdout.write("${ctx.e(0).start.text} ${ctx.e(1).start.text} ${ctx.es()[0].start.text}\n"); + } else + print(ctx.INT().symbol.text); + } +} +} +>> + +LRWithLabelsListener(X) ::= << +@parser::definitions { +class LeafListener extends TBaseListener { + void exitCall(CallContext ctx) { + stdout.write("${ctx.e().start.text} ${ctx.eList()}"); + } + void exitInt(IntContext ctx) { + print(ctx.INT().symbol.text); + } +} +} +>> + +DeclareContextListGettersFunction() ::= << +void foo() { + SContext s = null; + List\a = s.as(); + List\ b = s.bs(); +} +>> + +Declare_foo() ::= << + void foo() {print("foo");} +>> + +Invoke_foo() ::= "foo();" + +Declare_pred() ::= < > + +Invoke_pred(v) ::= < )>> + +ParserTokenType(t) ::= "Parser. " +ContextRuleFunction(ctx, rule) ::= " . " +StringType() ::= "String" +ContextMember(ctx, subctx, member) ::= " . . " diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Explorer.test.stg b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Explorer.test.stg index 6cfe9ba27..cf2802edc 100644 --- a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Explorer.test.stg +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Explorer.test.stg @@ -14,9 +14,9 @@ Cast(t,v) ::= " " Append(a,b) ::= " + " -Concat(a,b) ::= "" +AppendStr(a,b) ::= <% %> -DeclareLocal(s,v) ::= "var =;" +Concat(a,b) ::= "" AssertIsList(v) ::= < > @@ -26,14 +26,18 @@ InitIntMember(n,v) ::= <%this. = ;%> InitBooleanMember(n,v) ::= <%this. = ;%> +InitIntVar(n,v) ::= <% %> + +IntArg(n) ::= " " + +VarRef(n) ::= " " + GetMember(n) ::= <%this. %> SetMember(n,v) ::= <%this. = ;%> AddMember(n,v) ::= <%this. += ;%> -PlusMember(v,n) ::= <% + this. %> - MemberEquals(n,v) ::= <%this. === %> ModMemberEquals(n,m,v) ::= <%this. % === %> @@ -98,6 +102,8 @@ this.Property = function() { ParserPropertyCall(p, call) ::= " .
" +PositionAdjustingLexerDef() ::= "" + PositionAdjustingLexer() ::= << PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) { diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Firefox.test.stg b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Firefox.test.stg index c94be90e8..3882eb059 100644 --- a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Firefox.test.stg +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Firefox.test.stg @@ -14,9 +14,9 @@ Cast(t,v) ::= " " Append(a,b) ::= " + " -Concat(a,b) ::= "" +AppendStr(a,b) ::= <% %> -DeclareLocal(s,v) ::= "var =;" +Concat(a,b) ::= "" AssertIsList(v) ::= < > @@ -26,14 +26,18 @@ InitIntMember(n,v) ::= <%this. = ;%> InitBooleanMember(n,v) ::= <%this. = ;%> +InitIntVar(n,v) ::= <% %> + +IntArg(n) ::= " " + +VarRef(n) ::= " " + GetMember(n) ::= <%this. %> SetMember(n,v) ::= <%this. = ;%> AddMember(n,v) ::= <%this. += ;%> -PlusMember(v,n) ::= <% + this. %> - MemberEquals(n,v) ::= <%this. === %> ModMemberEquals(n,m,v) ::= <%this. % === %> @@ -72,11 +76,7 @@ LANotEquals(i, v) ::= <%this._input.LA()!= %> TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===%> -ImportListener(X) ::= << -@parser::header { -var Listener = require('./ Listener'). Listener; -} ->> +ImportListener(X) ::= "" GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)" @@ -100,6 +100,8 @@ this.Property = function() { ParserPropertyCall(p, call) ::= " .
" +PositionAdjustingLexerDef() ::= "" + PositionAdjustingLexer() ::= << PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) { diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Go.test.stg b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Go.test.stg index 37fe63441..eb8def195 100644 --- a/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Go.test.stg +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Go.test.stg @@ -14,9 +14,9 @@ Cast(t,v) ::= "( )" Append(a,b) ::= " + fmt.Sprint()" -Concat(a,b) ::= "" +AppendStr(a,b) ::= " + " -DeclareLocal(s, v) ::= "var