From f73ae702f27aa99400f3e74f52082c560666e63a Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Tue, 1 Jan 2019 14:13:17 +0300 Subject: [PATCH 01/36] LexerATNSimulator: avoid repeatable import of Lexer Importing module is quite expensive operation for using it in a lexer during normal operations. The patch avoids it by caching the required properties in LexerATNSimulator object. Signed-off-by: Alexey Khoroshilov --- contributors.txt | 3 ++- runtime/Python3/src/antlr4/atn/LexerATNSimulator.py | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/contributors.txt b/contributors.txt index f48052823..9f1b83f81 100644 --- a/contributors.txt +++ b/contributors.txt @@ -210,4 +210,5 @@ YYYY/MM/DD, github id, Full name, email 2018/11/14, nxtstep, Adriaan (Arjan) Duz, codewithadriaan[et]gmail[dot]com 2018/11/15, amykyta3, Alex Mykyta, amykyta3@users.noreply.github.com 2018/11/29, hannemann-tamas, Ralf Hannemann-Tamas, ralf.ht@gmail.com -2018/12/20, WalterCouto, Walter Couto, WalterCouto@users.noreply.github.com \ No newline at end of file +2018/12/20, WalterCouto, Walter Couto, WalterCouto@users.noreply.github.com +2019/01/01, khoroshilov, Alexey Khoroshilov, khoroshilov@ispras.ru diff --git a/runtime/Python3/src/antlr4/atn/LexerATNSimulator.py b/runtime/Python3/src/antlr4/atn/LexerATNSimulator.py index cc638c820..4c4468bb6 100644 --- a/runtime/Python3/src/antlr4/atn/LexerATNSimulator.py +++ b/runtime/Python3/src/antlr4/atn/LexerATNSimulator.py @@ -75,6 +75,9 @@ class LexerATNSimulator(ATNSimulator): self.column = 0 from antlr4.Lexer import Lexer self.mode = Lexer.DEFAULT_MODE + # Cache Lexer properties to avoid further imports + self.DEFAULT_MODE = Lexer.DEFAULT_MODE + self.MAX_CHAR_VALUE = Lexer.MAX_CHAR_VALUE # Used during DFA/ATN exec to record the most recent accept configuration info self.prevAccept = SimState() @@ -105,8 +108,7 @@ class LexerATNSimulator(ATNSimulator): self.startIndex = -1 self.line = 1 self.column = 0 - from antlr4.Lexer import Lexer - self.mode = Lexer.DEFAULT_MODE + self.mode = self.DEFAULT_MODE def matchATN(self, input:InputStream): startState = self.atn.modeToStartState[self.mode] @@ -291,8 +293,7 @@ class LexerATNSimulator(ATNSimulator): lexerActionExecutor.execute(self.recog, input, startIndex) def getReachableTarget(self, trans:Transition, t:int): - from antlr4.Lexer import Lexer - if trans.matches(t, 0, Lexer.MAX_CHAR_VALUE): + if trans.matches(t, 0, self.MAX_CHAR_VALUE): return trans.target else: return None @@ -420,8 +421,7 @@ class LexerATNSimulator(ATNSimulator): elif t.serializationType in [ Transition.ATOM, Transition.RANGE, Transition.SET ]: if treatEofAsEpsilon: - from antlr4.Lexer import Lexer - if t.matches(Token.EOF, 0, Lexer.MAX_CHAR_VALUE): + if t.matches(Token.EOF, 0, self.MAX_CHAR_VALUE): c = LexerATNConfig(state=t.target, config=config) return c From 44e5a2c8ea53579724eb760200e2ae215907d2de Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Fri, 27 Nov 2020 13:08:19 +0800 Subject: [PATCH 02/36] Fix invalid import --- .../test/org/antlr/v4/test/runtime/python/BasePythonTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/python/BasePythonTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/python/BasePythonTest.java index 65545ed26..c7c39857e 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/python/BasePythonTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/python/BasePythonTest.java @@ -5,7 +5,6 @@ */ package org.antlr.v4.test.runtime.python; -import com.sun.codemodel.internal.JForEach; import org.antlr.v4.Tool; import org.antlr.v4.automata.ATNFactory; import org.antlr.v4.automata.ATNPrinter; From 82c8824147165e0e6d38672d15a7e40d0ca3419b Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sat, 28 Nov 2020 22:42:43 +0800 Subject: [PATCH 03/36] Upgrade JUnit to address dependabot security alert --- antlr4-maven-plugin/pom.xml | 2 +- .../src/test/projects/dependencyRemoved/pom.xml | 2 +- antlr4-maven-plugin/src/test/projects/importTokens/pom.xml | 2 +- antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml | 2 +- antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml | 2 +- doc/java-target.md | 2 +- runtime-testsuite/pom.xml | 2 +- tool-testsuite/pom.xml | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/antlr4-maven-plugin/pom.xml b/antlr4-maven-plugin/pom.xml index 544d5f433..86d8507d8 100644 --- a/antlr4-maven-plugin/pom.xml +++ b/antlr4-maven-plugin/pom.xml @@ -64,7 +64,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml index 35be7219b..e778e9206 100644 --- a/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml +++ b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.11 + 4.13.1 test diff --git a/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml b/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml index 7f8c6570d..99c88cb09 100644 --- a/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml +++ b/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.11 + 4.13.1 test diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml b/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml index 4ab0de8f2..bd2a6d26a 100644 --- a/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml +++ b/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.11 + 4.13.1 test diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml b/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml index 77dcf0038..2a6efd252 100644 --- a/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml +++ b/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.11 + 4.13.1 test diff --git a/doc/java-target.md b/doc/java-target.md index 60612a9fd..eb73a3d6f 100644 --- a/doc/java-target.md +++ b/doc/java-target.md @@ -139,7 +139,7 @@ Edit the pom.xml file. Now we need to extensively modify the pom.xml file. The f junit junit - 3.8.1 + 4.13.1 diff --git a/runtime-testsuite/pom.xml b/runtime-testsuite/pom.xml index 337ae5b08..311e10c36 100644 --- a/runtime-testsuite/pom.xml +++ b/runtime-testsuite/pom.xml @@ -56,7 +56,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/tool-testsuite/pom.xml b/tool-testsuite/pom.xml index 6d5fc6fcf..6f1c40b6d 100644 --- a/tool-testsuite/pom.xml +++ b/tool-testsuite/pom.xml @@ -45,8 +45,8 @@ junit junit - 4.12 - test + 4.13.1 + test From 36f1d07ca0062fa21baff2abdfb60a70299aa00e Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 29 Nov 2020 09:59:55 +0800 Subject: [PATCH 04/36] Fix #2976 --- doc/getting-started.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/getting-started.md b/doc/getting-started.md index 2bc998e64..1cbd2e9bc 100644 --- a/doc/getting-started.md +++ b/doc/getting-started.md @@ -24,14 +24,14 @@ and put it somewhere rational like `/usr/local/lib`. 2. Add `antlr-4.9-complete.jar` to your `CLASSPATH`: ``` -$ export CLASSPATH=".:/usr/local/lib/antlr-4.9-complete.jar.jar:$CLASSPATH" +$ export CLASSPATH=".:/usr/local/lib/antlr-4.9-complete.jar:$CLASSPATH" ``` It's also a good idea to put this in your `.bash_profile` or whatever your startup script is. 3. Create aliases for the ANTLR Tool, and `TestRig`. ``` -$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar.jar:$CLASSPATH" org.antlr.v4.Tool' -$ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar.jar:$CLASSPATH" org.antlr.v4.gui.TestRig' +$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar:$CLASSPATH" org.antlr.v4.Tool' +$ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig' ``` ### WINDOWS @@ -41,7 +41,7 @@ $ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar.jar:$CLAS 0. Install Java (version 1.7 or higher) 1. Download antlr-4.9-complete.jar (or whatever version) from [https://www.antlr.org/download/](https://www.antlr.org/download/) Save to your directory for 3rd party Java libraries, say `C:\Javalib` -2. Add `antlr-4.9-complete.jar.jar` to CLASSPATH, either: +2. Add `antlr-4.9-complete.jar` to CLASSPATH, either: * Permanently: Using System Properties dialog > Environment variables > Create or append to `CLASSPATH` variable * Temporarily, at command line: ``` From 7d8b6dfae3557af8a7c275f72992bc88114dde3d Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 29 Nov 2020 10:27:22 +0800 Subject: [PATCH 05/36] Fix incorrect token string templates --- .../org/antlr/v4/tool/templates/codegen/Python2/Python2.stg | 4 ++-- .../org/antlr/v4/tool/templates/codegen/Python3/Python3.stg | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Python2/Python2.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Python2/Python2.stg index e1bcc2a35..b4b518d0d 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Python2/Python2.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Python2/Python2.stg @@ -551,10 +551,10 @@ TokenLabelType() ::= "" InputSymbolType() ::= "" TokenPropertyRef_text(t) ::= "(None if . is None else ..text)" -TokenPropertyRef_type(t) ::= "(0 if . is None else ..type()" +TokenPropertyRef_type(t) ::= "(0 if . is None else ..type)" TokenPropertyRef_line(t) ::= "(0 if . is None else ..line)" TokenPropertyRef_pos(t) ::= "(0 if . is None else ..column)" -TokenPropertyRef_channel(t) ::= "(0 if (. is None else ..channel)" +TokenPropertyRef_channel(t) ::= "(0 if . is None else ..channel)" TokenPropertyRef_index(t) ::= "(0 if . is None else ..tokenIndex)" TokenPropertyRef_int(t) ::= "(0 if . is None else int(..text))" diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg index ca602a8e5..1fdceee02 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg @@ -564,10 +564,10 @@ TokenLabelType() ::= "" InputSymbolType() ::= "" TokenPropertyRef_text(t) ::= "(None if . is None else ..text)" -TokenPropertyRef_type(t) ::= "(0 if . is None else ..type()" +TokenPropertyRef_type(t) ::= "(0 if . is None else ..type)" TokenPropertyRef_line(t) ::= "(0 if . is None else ..line)" TokenPropertyRef_pos(t) ::= "(0 if . is None else ..column)" -TokenPropertyRef_channel(t) ::= "(0 if (. is None else ..channel)" +TokenPropertyRef_channel(t) ::= "(0 if . is None else ..channel)" TokenPropertyRef_index(t) ::= "(0 if . is None else ..tokenIndex)" TokenPropertyRef_int(t) ::= "(0 if . is None else int(..text))" From 517f8ab90d3f66c6cad3b29989d9c514dce69895 Mon Sep 17 00:00:00 2001 From: Felix Nieuwenhuizen Date: Mon, 30 Nov 2020 20:33:56 +0100 Subject: [PATCH 06/36] travis: upgrade c++ build to focal & llvm 10 --- .travis.yml | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 58d4ccb4b..91c15b32f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,59 +19,56 @@ stages: matrix: include: - os: linux - dist: trusty + dist: focal compiler: clang jdk: openjdk8 env: - TARGET=cpp - - CXX=g++-5 + - CXX=g++-10 - GROUP=LEXER stage: main-test addons: apt: sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.7 + - sourceline: 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main' packages: - - g++-5 + - g++-10 - uuid-dev - - clang-3.7 + - clang-10 - os: linux - dist: trusty + dist: focal compiler: clang jdk: openjdk8 env: - TARGET=cpp - - CXX=g++-5 + - CXX=g++-10 - GROUP=PARSER stage: main-test addons: apt: sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.7 + - sourceline: 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main' packages: - - g++-5 + - g++-10 - uuid-dev - - clang-3.7 + - clang-10 - os: linux - dist: trusty + dist: focal compiler: clang jdk: openjdk8 env: - TARGET=cpp - - CXX=g++-5 + - CXX=g++-10 - GROUP=RECURSION stage: main-test addons: apt: sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.7 + - sourceline: 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main' packages: - - g++-5 + - g++-10 - uuid-dev - - clang-3.7 + - clang-10 - os: osx compiler: clang osx_image: xcode10.2 From 99c3589742ef8017332a4dd192bda977701a49c2 Mon Sep 17 00:00:00 2001 From: Felix Nieuwenhuizen Date: Tue, 1 Dec 2020 06:41:08 +0100 Subject: [PATCH 07/36] upgrade to java 11 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91c15b32f..b2acb6982 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ matrix: - os: linux dist: focal compiler: clang - jdk: openjdk8 + jdk: openjdk11 env: - TARGET=cpp - CXX=g++-10 @@ -38,7 +38,7 @@ matrix: - os: linux dist: focal compiler: clang - jdk: openjdk8 + jdk: openjdk11 env: - TARGET=cpp - CXX=g++-10 @@ -55,7 +55,7 @@ matrix: - os: linux dist: focal compiler: clang - jdk: openjdk8 + jdk: openjdk11 env: - TARGET=cpp - CXX=g++-10 From 8f7faab0eeeae2037060e59e4e24d4aecd90d2c4 Mon Sep 17 00:00:00 2001 From: Felix Nieuwenhuizen Date: Sun, 4 Oct 2020 15:09:41 +0200 Subject: [PATCH 08/36] revert change of Vocabulary constructor from PR #2839 to fix build error in Cpp runtime test --- runtime/Cpp/runtime/src/Vocabulary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Cpp/runtime/src/Vocabulary.h b/runtime/Cpp/runtime/src/Vocabulary.h index f06ce6978..e8924bf17 100755 --- a/runtime/Cpp/runtime/src/Vocabulary.h +++ b/runtime/Cpp/runtime/src/Vocabulary.h @@ -22,7 +22,7 @@ namespace dfa { /// except . static const Vocabulary EMPTY_VOCABULARY; - Vocabulary() = default; + Vocabulary() {} Vocabulary(Vocabulary const&) = default; virtual ~Vocabulary(); From 4fcec7348db8b3edacf5988af71996cdb6dde3b5 Mon Sep 17 00:00:00 2001 From: maxence-lefebvre Date: Tue, 1 Dec 2020 17:56:44 +0100 Subject: [PATCH 09/36] :ambulance: fix bad import --- runtime/JavaScript/src/antlr4/CharStreams.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/JavaScript/src/antlr4/CharStreams.js b/runtime/JavaScript/src/antlr4/CharStreams.js index 7c6e275ef..045f93df5 100644 --- a/runtime/JavaScript/src/antlr4/CharStreams.js +++ b/runtime/JavaScript/src/antlr4/CharStreams.js @@ -3,7 +3,7 @@ * can be found in the LICENSE.txt file in the project root. */ -const {InputStream} = require('./InputStream'); +const InputStream = require('./InputStream'); const fs = require("fs"); /** From ec755822b09c5813f8dc70c9a6f6e1cb998c304e Mon Sep 17 00:00:00 2001 From: maxence-lefebvre Date: Tue, 1 Dec 2020 17:58:16 +0100 Subject: [PATCH 10/36] Update contributors.txt --- contributors.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contributors.txt b/contributors.txt index a11dc27f2..96f40f1b9 100644 --- a/contributors.txt +++ b/contributors.txt @@ -279,4 +279,5 @@ YYYY/MM/DD, github id, Full name, email 2020/10/16, adarshbhat, Adarsh Bhat, adarshbhat@users.noreply.github.com 2020/10/20, adamwojs, Adam Wójs, adam[at]wojs.pl 2020/10/24, cliid, Jiwu Jang, jiwujang@naver.com -2020/11/05, MichelHartmann, Michel Hartmann, MichelHartmann@users.noreply.github.com \ No newline at end of file +2020/11/05, MichelHartmann, Michel Hartmann, MichelHartmann@users.noreply.github.com +2020/12/01, maxence-lefebvre, Maxence Lefebvre, maxence-lefebvre@users.noreply.github.com From b87ef1d743aa8c900a77928a6ea50eda3c6a869f Mon Sep 17 00:00:00 2001 From: David Phillips Date: Thu, 3 Dec 2020 15:04:06 -0800 Subject: [PATCH 11/36] Add trailing newline to contributors.txt --- contributors.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributors.txt b/contributors.txt index a11dc27f2..06d0b1f80 100644 --- a/contributors.txt +++ b/contributors.txt @@ -279,4 +279,4 @@ YYYY/MM/DD, github id, Full name, email 2020/10/16, adarshbhat, Adarsh Bhat, adarshbhat@users.noreply.github.com 2020/10/20, adamwojs, Adam Wójs, adam[at]wojs.pl 2020/10/24, cliid, Jiwu Jang, jiwujang@naver.com -2020/11/05, MichelHartmann, Michel Hartmann, MichelHartmann@users.noreply.github.com \ No newline at end of file +2020/11/05, MichelHartmann, Michel Hartmann, MichelHartmann@users.noreply.github.com From 88a9e963e8aa46e48d156a574d617626c9c4bf9d Mon Sep 17 00:00:00 2001 From: David Phillips Date: Thu, 3 Dec 2020 15:03:43 -0800 Subject: [PATCH 12/36] Sign contributors.txt --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index 06d0b1f80..aa297cd54 100644 --- a/contributors.txt +++ b/contributors.txt @@ -280,3 +280,4 @@ YYYY/MM/DD, github id, Full name, email 2020/10/20, adamwojs, Adam Wójs, adam[at]wojs.pl 2020/10/24, cliid, Jiwu Jang, jiwujang@naver.com 2020/11/05, MichelHartmann, Michel Hartmann, MichelHartmann@users.noreply.github.com +2020/12/03, electrum, David Phillips, david@acz.org From 5eedc1e65a2967891921eec2310cdb64490fe7f2 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Thu, 3 Dec 2020 15:00:29 -0800 Subject: [PATCH 13/36] Java: add newline to version mismatch messages --- runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java b/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java index e486a68b1..6729c9961 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java +++ b/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java @@ -157,11 +157,11 @@ public class RuntimeMetaData { !getMajorMinorVersion(runtimeVersion).equals(getMajorMinorVersion(compileTimeVersion)); if ( runtimeConflictsWithGeneratingTool ) { - System.err.printf("ANTLR Tool version %s used for code generation does not match the current runtime version %s", + System.err.printf("ANTLR Tool version %s used for code generation does not match the current runtime version %s%n", generatingToolVersion, runtimeVersion); } if ( runtimeConflictsWithCompileTimeTool ) { - System.err.printf("ANTLR Runtime version %s used for parser compilation does not match the current runtime version %s", + System.err.printf("ANTLR Runtime version %s used for parser compilation does not match the current runtime version %s%n", compileTimeVersion, runtimeVersion); } } From 3bf3867054c6feee0dacc02ced134498c97686f7 Mon Sep 17 00:00:00 2001 From: Tabari Alexander Date: Sat, 5 Dec 2020 20:20:01 -0500 Subject: [PATCH 14/36] Fixed exception clauses in JS template. The generated exception clause block was missing a leading '}' to terminate the try block. --- .../v4/tool/templates/codegen/JavaScript/JavaScript.stg | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg index 2b310fb70..5eacbed4f 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg @@ -266,10 +266,9 @@ RuleFunction(currentRule,args,code,locals,ruleCtx,altLabelCtxs,namedActions,fina - + } - - } catch (re) { + catch (re) { if(re instanceof antlr4.error.RecognitionException) { localctx.exception = re; this._errHandler.reportError(this, re); From 74b8bb780d258a5b68e81ece0834ee53d74381e4 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 6 Dec 2020 15:49:29 +0800 Subject: [PATCH 15/36] rollback partially incorrect fix for #2902 --- runtime/JavaScript/src/antlr4/PredictionContext.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/JavaScript/src/antlr4/PredictionContext.js b/runtime/JavaScript/src/antlr4/PredictionContext.js index b40cc79ed..ed95600a2 100644 --- a/runtime/JavaScript/src/antlr4/PredictionContext.js +++ b/runtime/JavaScript/src/antlr4/PredictionContext.js @@ -562,7 +562,7 @@ function mergeArrays(a, b, rootIsWildcard, mergeCache) { while (i < a.returnStates.length && j < b.returnStates.length) { const a_parent = a.parents[i]; const b_parent = b.parents[j]; - if (equalArrays(a.returnStates[i], b.returnStates[j])) { + if (a.returnStates[i] === b.returnStates[j]) { // same payload (stack tops are equal), must yield merged singleton const payload = a.returnStates[i]; // $+$ = $ From 3ea6506bd447b63a49a7d946bfe2d96915349505 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 6 Dec 2020 22:36:45 +0800 Subject: [PATCH 16/36] Potential fix to #2980 --- .../antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg index dc022c254..632fda1d2 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg @@ -410,7 +410,7 @@ if(la_===+1) { StarBlock(choice, alts, sync, iteration) ::= << this.state = ; this._errHandler.sync(this); -let _alt = this._interp.adaptivePredict(this._input,,this._ctx) +var _alt = this._interp.adaptivePredict(this._input,,this._ctx) while(_alt!= && _alt!=antlr4.atn.ATN.INVALID_ALT_NUMBER) { if(_alt===1+1) { @@ -426,7 +426,7 @@ while(_alt!= && _alt!=antlr4.atn.ATN.INVALID_ALT_NUMBER) { PlusBlock(choice, alts, error) ::= << this.state = ; this._errHandler.sync(this); -let _alt = 1+1; +var _alt = 1+1; do { switch (_alt) { Date: Sat, 12 Dec 2020 20:44:21 +0800 Subject: [PATCH 17/36] ensure 1 statement per line to help debug --- .../org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg index 13d497dcb..4188ad412 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg @@ -706,11 +706,13 @@ cases(ttypes) ::= << >> InvokeRule(r, argExprsChunks) ::= << -State = ; = }>(,); +State = ; + = }>(,); >> MatchToken(m) ::= << -State = ; = }>Match(); +State = ; + = }>Match(); >> MatchSet(m, expr, capture) ::= "" From c4d0ace5f3bb8c1887dd186709a828c10a7fbd3c Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 13 Dec 2020 09:56:29 +0800 Subject: [PATCH 18/36] upgrade ini --- runtime/JavaScript/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/JavaScript/package.json b/runtime/JavaScript/package.json index 6c96379fe..5d8cd2c55 100644 --- a/runtime/JavaScript/package.json +++ b/runtime/JavaScript/package.json @@ -21,7 +21,8 @@ "@babel/preset-env": "^7.12.7", "babel-loader": "^8.2.1", "webpack": "^4.44.2", - "webpack-cli": "^3.3.12" + "webpack-cli": "^3.3.12", + "ini": "1.3.6" }, "scripts": { "build": "webpack" From 441b0d60e71603b168f271358a942255d41b484f Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sun, 13 Dec 2020 10:13:34 +0800 Subject: [PATCH 19/36] Fix typo --- runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CharStreams.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CharStreams.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CharStreams.cs index c5e20b153..4106f3162 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CharStreams.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CharStreams.cs @@ -85,7 +85,7 @@ namespace Antlr4.Runtime /// Creates an given a . /// - public static ICharStream fromstring(string s) + public static ICharStream fromString(string s) { return new CodePointCharStream(s); } From 4884a0fecb19687b8d073bbb3ca7e4757079c4b4 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 2 Dec 2020 17:51:54 +0300 Subject: [PATCH 20/36] Drop support of outdated net35, remove mono and vs2013 .csproj and .sln files --- appveyor.yml | 1 - .../Antlr4.Runtime.dotnet.csproj | 15 +- .../Antlr4.Runtime/Antlr4.Runtime.mono.csproj | 241 ------------------ .../Antlr4.Runtime.vs2013.csproj | 239 ----------------- .../Antlr4.Runtime/Sharpen/Compat/Funcs.cs | 14 +- runtime/CSharp/runtime/CSharp/Antlr4.mono.sln | 43 ---- .../CSharp/runtime/CSharp/Antlr4.vs2013.sln | 23 -- 7 files changed, 10 insertions(+), 566 deletions(-) delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.mono.csproj delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.vs2013.csproj delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.mono.sln delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.vs2013.sln diff --git a/appveyor.yml b/appveyor.yml index 113c03558..0b74b024f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,6 @@ install: build_script: - mvn -DskipTests install --batch-mode - msbuild /target:restore /target:rebuild /property:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln - - msbuild ./runtime-testsuite/target/classes/CSharp/runtime/CSharp/Antlr4.vs2013.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:detailed after_build: - msbuild /target:pack /property:Configuration=Release /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln test_script: diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj index a1e095d64..31cf38798 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj @@ -2,8 +2,8 @@ The ANTLR Organization 4.9 - en-US - netstandard1.3;net35 + en-US + netstandard1.3; $(NoWarn);CS1591;CS1574;CS1580 true Antlr4.Runtime.Standard @@ -14,7 +14,7 @@ ANTLR 4 .NET Standard Runtime Eric Vergnaud, Terence Parr, Sam Harwell The .NET Core C# ANTLR 4 runtime from the ANTLR Organization - The runtime library for parsers generated by the C# target of the standard ANTLR 4 tool. + The runtime library for parsers generated by the C# target of the standard ANTLR 4 tool. Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. true https://github.com/antlr/antlr4/blob/master/LICENSE.txt @@ -44,10 +44,7 @@ true lib\Release - - DOTNETCORE;NET35PLUS;NET40PLUS;NET45PLUS - - - NET35PLUS - + + DOTNETCORE;NET40PLUS;NET45PLUS + diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.mono.csproj b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.mono.csproj deleted file mode 100644 index fc42da254..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.mono.csproj +++ /dev/null @@ -1,241 +0,0 @@ - - - - - Debug - AnyCPU - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF} - Library - Properties - Antlr4.Runtime - Antlr4.Runtime.Standard - v3.5 - 512 - obj\net20\ - ..\ - true - true - ..\..\Antlr4.snk - - - true - full - false - lib\Debug - DEBUG;TRACE;NET35PLUS - prompt - 4 - 1591 0659 - - - true - lib\Release - TRACE;NET35PLUS - prompt - 4 - 1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MSBuild:Compile - Antlr4.Runtime.Tree.Xpath - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.vs2013.csproj b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.vs2013.csproj deleted file mode 100644 index b9117f367..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.vs2013.csproj +++ /dev/null @@ -1,239 +0,0 @@ - - - - - Debug - AnyCPU - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF} - Library - Properties - Antlr4.Runtime - Antlr4.Runtime.Standard - v3.5 - 512 - obj\net35\ - ..\ - true - - - - true - full - false - bin\net35\Debug\ - $(OutputPath)$(AssemblyName).xml - DEBUG;TRACE;NET35PLUS - prompt - 4 - 1591 - - - pdbonly - true - bin\net35\Release\ - $(OutputPath)$(AssemblyName).xml - TRACE;NET35PLUS - prompt - 4 - 1591 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Funcs.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Funcs.cs index 9b1c974b6..0be99b9f9 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Funcs.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Funcs.cs @@ -13,10 +13,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR TArg PARTICULAR PURPOSE AND @@ -25,17 +25,11 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // -#if !NET35PLUS - -using System.Runtime.CompilerServices; - namespace Antlr4.Runtime.Sharpen { public delegate TResult Func (); - + public delegate TResult Func (T arg); - + public delegate TResult Func (T1 arg1, T2 arg2); } - -#endif diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.mono.sln b/runtime/CSharp/runtime/CSharp/Antlr4.mono.sln deleted file mode 100644 index b5b7bc455..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.mono.sln +++ /dev/null @@ -1,43 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -VisualStudioVersion = 12.0.30110.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{47C0086D-577C-43DA-ADC7-544F27656E45}" - ProjectSection(SolutionItems) = preProject - ..\..\Readme.md = ..\..\Readme.md - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{4CE79A54-058D-4940-875E-7F6AA9922A7D}" - ProjectSection(SolutionItems) = preProject - ..\..\build\Antlr4.nuspec = ..\..\build\Antlr4.nuspec - ..\..\build\Antlr4.Runtime.nuspec = ..\..\build\Antlr4.Runtime.nuspec - ..\..\build\Antlr4.VS2008.nuspec = ..\..\build\Antlr4.VS2008.nuspec - ..\..\build\build.ps1 = ..\..\build\build.ps1 - ..\..\build\check-key.ps1 = ..\..\build\check-key.ps1 - build\KeyReporting.targets = build\KeyReporting.targets - ..\..\build\keys.ps1 = ..\..\build\keys.ps1 - ..\..\build\push.ps1 = ..\..\build\push.ps1 - ..\..\build\version.ps1 = ..\..\build\version.ps1 - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.mono", "Antlr4.Runtime\Antlr4.Runtime.mono.csproj", "{E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {4CE79A54-058D-4940-875E-7F6AA9922A7D} = {47C0086D-577C-43DA-ADC7-544F27656E45} - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.vs2013.sln b/runtime/CSharp/runtime/CSharp/Antlr4.vs2013.sln deleted file mode 100644 index 2bf8cd6b9..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.vs2013.sln +++ /dev/null @@ -1,23 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{47C0086D-577C-43DA-ADC7-544F27656E45}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.vs2013", "Antlr4.Runtime\Antlr4.Runtime.vs2013.csproj", "{E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal \ No newline at end of file From 11077ac15cfbbe80c93584a968fea63c3e6eebfb Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 2 Dec 2020 20:54:59 +0300 Subject: [PATCH 21/36] Replace netstandard1.3 target with netstandard2.0;netstandard2.1; remove DOTNETCORE;NET40PLUS;NET45PLUS defined constants, add NETSTANDARD20 --- .../CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj index 31cf38798..b3c9c73fe 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj @@ -3,7 +3,7 @@ The ANTLR Organization 4.9 en-US - netstandard1.3; + netstandard2.0;netstandard2.1 $(NoWarn);CS1591;CS1574;CS1580 true Antlr4.Runtime.Standard @@ -44,7 +44,7 @@ true lib\Release - - DOTNETCORE;NET40PLUS;NET45PLUS + + NETSTANDARD20 From 573f71bf7d9397a39b954c7ef05889f935eded35 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 2 Dec 2020 20:58:18 +0300 Subject: [PATCH 22/36] Remove preprocessor directives that check COMPACT, PORTABLE, NET40PLUS, NET45PLUS from code --- .../CSharp/Antlr4.Runtime/AntlrFileStream.cs | 34 - .../Antlr4.Runtime/Atn/ATNDeserializer.cs | 2 +- .../CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs | 2 - .../CSharp/Antlr4.Runtime/Atn/ATNState.cs | 2 - .../Antlr4.Runtime/Atn/ParserATNSimulator.cs | 5 +- .../Antlr4.Runtime/Atn/SemanticContext.cs | 4 - .../Antlr4.Runtime/ConsoleErrorListener.cs | 8 +- .../Antlr4.Runtime/DefaultErrorStrategy.cs | 2 - .../Antlr4.Runtime/Dfa/AbstractEdgeMap.cs | 6 - .../CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap.cs | 32 +- .../CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap.cs | 15 +- .../CSharp/Antlr4.Runtime/Dfa/IEdgeMap.cs | 5 - .../Antlr4.Runtime/Dfa/SingletonEdgeMap.cs | 7 +- .../Antlr4.Runtime/Dfa/SparseEdgeMap.cs | 16 +- .../Antlr4.Runtime/IAntlrErrorListener.cs | 7 +- .../Misc/ParseCanceledException.cs | 6 +- .../Misc/RuleDependencyChecker.cs | 626 +----------------- .../CSharp/Antlr4.Runtime/Misc/Utils.cs | 14 - .../runtime/CSharp/Antlr4.Runtime/Parser.cs | 10 - .../Antlr4.Runtime/ParserRuleContext.cs | 19 +- .../Antlr4.Runtime/Properties/AssemblyInfo.cs | 8 +- .../CSharp/Antlr4.Runtime/Recognizer.cs | 18 +- .../Antlr4.Runtime/Sharpen/Collections.cs | 23 - .../Sharpen/Compat/SerializableAttribute.cs | 5 +- .../Antlr4.Runtime/Sharpen/ListExtensions.cs | 6 +- .../Antlr4.Runtime/TokenStreamRewriter.cs | 2 - .../Antlr4.Runtime/Tree/IParseTreeVisitor.cs | 4 - .../Antlr4.Runtime/Tree/ParseTreeProperty.cs | 4 - 28 files changed, 21 insertions(+), 871 deletions(-) diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs index ec59b87e6..e74df8c83 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs @@ -3,18 +3,11 @@ * can be found in the LICENSE.txt file in the project root. */ -#if !PORTABLE - -using Antlr4.Runtime.Sharpen; using Encoding = System.Text.Encoding; using File = System.IO.File; namespace Antlr4.Runtime { -#if COMPACT - using StreamReader = System.IO.StreamReader; -#endif - /// /// This is an /// @@ -47,17 +40,10 @@ namespace Antlr4.Runtime } string text; -#if !COMPACT if (encoding != null) text = File.ReadAllText(fileName, encoding); else text = File.ReadAllText(fileName); -#else - if (encoding != null) - text = ReadAllText(fileName, encoding); - else - text = ReadAllText(fileName); -#endif data = text.ToCharArray(); n = data.Length; @@ -70,25 +56,5 @@ namespace Antlr4.Runtime return fileName; } } - -#if COMPACT - private static string ReadAllText(string path) - { - using (var reader = new StreamReader(path)) - { - return reader.ReadToEnd(); - } - } - - private static string ReadAllText(string path, Encoding encoding) - { - using (var reader = new StreamReader(path, encoding ?? Encoding.Default)) - { - return reader.ReadToEnd(); - } - } -#endif } } - -#endif diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs index 3ce2e87d2..d38c01464 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs @@ -398,7 +398,7 @@ namespace Antlr4.Runtime.Atn } } - protected internal virtual void ReadSets(ATN atn, IList sets, Func readUnicode) + protected internal virtual void ReadSets(ATN atn, IList sets, System.Func readUnicode) { // // SETS diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs index 53eb97e51..60e5b1931 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs @@ -77,9 +77,7 @@ namespace Antlr4.Runtime.Atn protected void ConsoleWriteLine(string format, params object[] arg) { -#if !PORTABLE System.Console.WriteLine(format, arg); -#endif } public PredictionContextCache getSharedContextCache() diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs index 3f5c61a47..52541d52b 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs @@ -95,9 +95,7 @@ namespace Antlr4.Runtime.Atn { if (epsilonOnlyTransitions != e.IsEpsilon) { -#if !PORTABLE System.Console.Error.WriteLine("ATN state {0} has both epsilon and non-epsilon transitions.", stateNumber); -#endif epsilonOnlyTransitions = false; } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs index a7d914a71..6ea9489b4 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs @@ -2112,9 +2112,7 @@ namespace Antlr4.Runtime.Atn */ public void DumpDeadEndConfigs(NoViableAltException nvae) { -#if !PORTABLE System.Console.Error.WriteLine("dead end configs: "); -#endif foreach (ATNConfig c in nvae.DeadEndConfigs.configs) { String trans = "no edges"; @@ -2133,9 +2131,8 @@ namespace Antlr4.Runtime.Atn trans = (not ? "~" : "") + "Set " + st.set.ToString(); } } -#if !PORTABLE + System.Console.Error.WriteLine(c.ToString(parser, true) + ":" + trans); -#endif } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs index c6cf0cda6..4d8f357b0 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs @@ -437,11 +437,7 @@ namespace Antlr4.Runtime.Atn Collections.EmptyList(); List result = collection.OfType().ToList(); -#if NET40PLUS collection.ExceptWith(result); -#else - collection.ExceptWith(result.Cast()); -#endif return result; } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs index 84bbeea4a..4849fe80c 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs @@ -3,10 +3,6 @@ * can be found in the LICENSE.txt file in the project root. */ -#if !PORTABLE - -using Antlr4.Runtime; -using Antlr4.Runtime.Sharpen; using System.IO; namespace Antlr4.Runtime @@ -44,6 +40,4 @@ namespace Antlr4.Runtime output.WriteLine("line " + line + ":" + charPositionInLine + " " + msg); } } -} - -#endif +} \ No newline at end of file diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs index 019055e25..5dee39cdd 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs @@ -160,9 +160,7 @@ namespace Antlr4.Runtime } else { -#if !PORTABLE System.Console.Error.WriteLine("unknown recognition error type: " + e.GetType().FullName); -#endif NotifyErrorListeners(recognizer, e.Message, e); } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap.cs index b9c55f472..e298c3c5e 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap.cs @@ -4,8 +4,6 @@ */ using System.Collections; using System.Collections.Generic; -using Antlr4.Runtime.Dfa; -using Antlr4.Runtime.Sharpen; namespace Antlr4.Runtime.Dfa { @@ -78,11 +76,7 @@ namespace Antlr4.Runtime.Dfa get; } -#if NET45PLUS public abstract IReadOnlyDictionary ToMap(); -#else - public abstract IDictionary ToMap(); -#endif public virtual IEnumerator> GetEnumerator() { diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap.cs index b59120bbf..81617c5f4 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap.cs @@ -5,15 +5,9 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using Antlr4.Runtime.Dfa; -using Antlr4.Runtime.Sharpen; using Interlocked = System.Threading.Interlocked; -#if NET45PLUS using Volatile = System.Threading.Volatile; -#elif !PORTABLE && !COMPACT -using Thread = System.Threading.Thread; -#endif namespace Antlr4.Runtime.Dfa { @@ -35,13 +29,7 @@ namespace Antlr4.Runtime.Dfa { get { -#if NET45PLUS return Volatile.Read(ref size); -#elif !PORTABLE && !COMPACT - return Thread.VolatileRead(ref size); -#else - return Interlocked.CompareExchange(ref size, 0, 0); -#endif } } @@ -67,11 +55,7 @@ namespace Antlr4.Runtime.Dfa return null; } -#if NET45PLUS return Volatile.Read(ref arrayData[key - minIndex]); -#else - return Interlocked.CompareExchange(ref arrayData[key - minIndex], null, null); -#endif } } @@ -156,24 +140,15 @@ namespace Antlr4.Runtime.Dfa return new EmptyEdgeMap(minIndex, maxIndex); } -#if NET45PLUS public override IReadOnlyDictionary ToMap() -#else - public override IDictionary ToMap() -#endif { if (IsEmpty) { return Sharpen.Collections.EmptyMap(); } -#if COMPACT - IDictionary result = new SortedList(); -#elif PORTABLE && !NET45PLUS - IDictionary result = new Dictionary(); -#else IDictionary result = new SortedDictionary(); -#endif + for (int i = 0; i < arrayData.Length; i++) { T element = arrayData[i]; @@ -183,11 +158,8 @@ namespace Antlr4.Runtime.Dfa } result[i + minIndex] = element; } -#if NET45PLUS + return new ReadOnlyDictionary(result); -#else - return result; -#endif } } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap.cs index 9098de65c..76dcbd073 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap.cs @@ -3,11 +3,7 @@ * can be found in the LICENSE.txt file in the project root. */ using System.Collections.Generic; -using Antlr4.Runtime.Sharpen; - -#if NET45PLUS using System.Collections.ObjectModel; -#endif namespace Antlr4.Runtime.Dfa { @@ -74,18 +70,9 @@ namespace Antlr4.Runtime.Dfa } } -#if NET45PLUS public override IReadOnlyDictionary ToMap() -#else - public override IDictionary ToMap() -#endif { - Dictionary result = new Dictionary(); -#if NET45PLUS - return new ReadOnlyDictionary(result); -#else - return result; -#endif + return new ReadOnlyDictionary(new Dictionary()); } } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap.cs index f8cd641af..fc76a3063 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap.cs @@ -39,12 +39,7 @@ namespace Antlr4.Runtime.Dfa [return: NotNull] IEdgeMap Clear(); -#if NET45PLUS [return: NotNull] IReadOnlyDictionary ToMap(); -#else - [return: NotNull] - IDictionary ToMap(); -#endif } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap.cs index 5757684cf..fbc6c2c0d 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap.cs @@ -3,7 +3,6 @@ * can be found in the LICENSE.txt file in the project root. */ using System.Collections.Generic; -using Antlr4.Runtime.Sharpen; namespace Antlr4.Runtime.Dfa { @@ -123,17 +122,13 @@ namespace Antlr4.Runtime.Dfa return this; } -#if NET45PLUS public override IReadOnlyDictionary ToMap() -#else - public override IDictionary ToMap() -#endif { if (IsEmpty) { return Sharpen.Collections.EmptyMap(); } - return Antlr4.Runtime.Sharpen.Collections.SingletonMap(key, value); + return Sharpen.Collections.SingletonMap(key, value); } } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap.cs index 05a0ac84f..2f1eb7425 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap.cs @@ -181,11 +181,7 @@ namespace Antlr4.Runtime.Dfa return new EmptyEdgeMap(minIndex, maxIndex); } -#if NET45PLUS public override IReadOnlyDictionary ToMap() -#else - public override IDictionary ToMap() -#endif { if (IsEmpty) { @@ -193,22 +189,14 @@ namespace Antlr4.Runtime.Dfa } lock (this) { -#if COMPACT - IDictionary result = new SortedList(); -#elif PORTABLE && !NET45PLUS - IDictionary result = new Dictionary(); -#else IDictionary result = new SortedDictionary(); -#endif + for (int i = 0; i < Count; i++) { result[keys[i]] = values[i]; } -#if NET45PLUS + return new ReadOnlyDictionary(result); -#else - return result; -#endif } } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener.cs index fe8b0150e..01e76e617 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener.cs @@ -2,19 +2,14 @@ * 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. */ -using Antlr4.Runtime; -using Antlr4.Runtime.Sharpen; + using System.IO; namespace Antlr4.Runtime { /// How to emit recognition errors. /// How to emit recognition errors. -#if COMPACT - public interface IAntlrErrorListener -#else public interface IAntlrErrorListener -#endif { /// Upon syntax error, notify any interested parties. /// diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs index e0e5ee39b..6dc7200e6 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs @@ -4,10 +4,6 @@ */ using System; -#if COMPACT -using OperationCanceledException = System.Exception; -#endif - namespace Antlr4.Runtime.Misc { /// This exception is thrown to cancel a parsing operation. @@ -22,7 +18,7 @@ namespace Antlr4.Runtime.Misc /// response to a parse error. /// /// Sam Harwell - [System.Serializable] + [Serializable] public class ParseCanceledException : OperationCanceledException { public ParseCanceledException() diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs index 0d77cbb4f..ab98df309 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs @@ -3,17 +3,12 @@ * can be found in the LICENSE.txt file in the project root. */ -#if NET45PLUS - using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Security; using System.Text; -using Antlr4.Runtime; using Antlr4.Runtime.Atn; -using Antlr4.Runtime.Misc; using Antlr4.Runtime.Sharpen; namespace Antlr4.Runtime.Misc @@ -87,7 +82,7 @@ namespace Antlr4.Runtime.Misc { string[] ruleNames = GetRuleNames(recognizerType); int[] ruleVersions = GetRuleVersions(recognizerType, ruleNames); - RuleDependencyChecker.RuleRelations relations = ExtractRuleRelations(recognizerType); + RuleRelations relations = ExtractRuleRelations(recognizerType); StringBuilder errors = new StringBuilder(); foreach (Tuple dependency in dependencies) { @@ -314,13 +309,9 @@ namespace Antlr4.Runtime.Misc foreach (MethodInfo method in clazz.DeclaredMethods) { GetElementDependencies(AsCustomAttributeProvider(method), result); -#if COMPACT - if (method.ReturnTypeCustomAttributes != null) - GetElementDependencies(AsCustomAttributeProvider(method.ReturnTypeCustomAttributes), result); -#else + if (method.ReturnParameter != null) GetElementDependencies(AsCustomAttributeProvider(method.ReturnParameter), result); -#endif foreach (ParameterInfo parameter in method.GetParameters()) GetElementDependencies(AsCustomAttributeProvider(parameter), result); @@ -459,7 +450,6 @@ namespace Antlr4.Runtime.Misc { } -#if PORTABLE || DOTNETCORE public interface ICustomAttributeProvider { object[] GetCustomAttributes(Type attributeType, bool inherit); @@ -544,617 +534,5 @@ namespace Antlr4.Runtime.Misc return _provider.GetCustomAttributes(attributeType, inherit).ToArray(); } } -#else - protected static ICustomAttributeProvider AsCustomAttributeProvider(ICustomAttributeProvider obj) - { - return obj; - } -#endif } } - -#else - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Security; -using System.Text; -using Antlr4.Runtime; -using Antlr4.Runtime.Atn; -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Sharpen; - -namespace Antlr4.Runtime.Misc -{ - /// Sam Harwell - public class RuleDependencyChecker - { -#if false - private static readonly Logger Logger = Logger.GetLogger(typeof(Antlr4.Runtime.Misc.RuleDependencyChecker).FullName); -#endif - - private const BindingFlags AllDeclaredStaticMembers = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static; - private const BindingFlags AllDeclaredMembers = AllDeclaredStaticMembers | BindingFlags.Instance; - private static readonly HashSet checkedAssemblies = new HashSet(); - - public static void CheckDependencies(Assembly assembly) - { - if (IsChecked(assembly)) - { - return; - } - - IList typesToCheck = GetTypesToCheck(assembly); - ArrayList> dependencies = new ArrayList>(); - foreach (Type clazz in typesToCheck) - { - dependencies.AddRange(GetDependencies(clazz)); - } - - if (dependencies.Count > 0) - { - IDictionary>> recognizerDependencies = new Dictionary>>(); - foreach (Tuple dependency in dependencies) - { - Type recognizerType = dependency.Item1.Recognizer; - IList> list; - if (!recognizerDependencies.TryGetValue(recognizerType, out list)) - { - list = new ArrayList>(); - recognizerDependencies[recognizerType] = list; - } - list.Add(dependency); - } - - foreach (KeyValuePair>> entry in recognizerDependencies) - { - //processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, String.format("ANTLR 4: Validating {0} dependencies on rules in {1}.", entry.getValue().size(), entry.getKey().toString())); - CheckDependencies(entry.Value, entry.Key); - } - } - - MarkChecked(assembly); - } - - private static IList GetTypesToCheck(Assembly assembly) - { - return assembly.GetTypes(); - } - - private static bool IsChecked(Assembly assembly) - { - lock (checkedAssemblies) - { - return checkedAssemblies.Contains(assembly.FullName); - } - } - - private static void MarkChecked(Assembly assembly) - { - lock (checkedAssemblies) - { - checkedAssemblies.Add(assembly.FullName); - } - } - - private static void CheckDependencies(IList> dependencies, Type recognizerType) - { - string[] ruleNames = GetRuleNames(recognizerType); - int[] ruleVersions = GetRuleVersions(recognizerType, ruleNames); - RuleDependencyChecker.RuleRelations relations = ExtractRuleRelations(recognizerType); - StringBuilder errors = new StringBuilder(); - foreach (Tuple dependency in dependencies) - { -#if DOTNETCORE - if (!dependency.Item1.Recognizer.GetTypeInfo().IsAssignableFrom(recognizerType)) -#else - if (!dependency.Item1.Recognizer.IsAssignableFrom(recognizerType)) -#endif - { - continue; - } - // this is the rule in the dependency set with the highest version number - int effectiveRule = dependency.Item1.Rule; - if (effectiveRule < 0 || effectiveRule >= ruleVersions.Length) - { - string message = string.Format("Rule dependency on unknown rule {0}@{1} in {2}", dependency.Item1.Rule, dependency.Item1.Version, dependency.Item1.Recognizer.ToString()); - errors.AppendLine(dependency.Item2.ToString()); - errors.AppendLine(message); - continue; - } - Dependents dependents = Dependents.Self | dependency.Item1.Dependents; - ReportUnimplementedDependents(errors, dependency, dependents); - BitSet @checked = new BitSet(); - int highestRequiredDependency = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, effectiveRule, null); - if ((dependents & Dependents.Parents) != 0) - { - BitSet parents = relations.parents[dependency.Item1.Rule]; - for (int parent = parents.NextSetBit(0); parent >= 0; parent = parents.NextSetBit(parent + 1)) - { - if (parent < 0 || parent >= ruleVersions.Length || @checked.Get(parent)) - { - continue; - } - @checked.Set(parent); - int required = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, parent, "parent"); - highestRequiredDependency = Math.Max(highestRequiredDependency, required); - } - } - if ((dependents & Dependents.Children) != 0) - { - BitSet children = relations.children[dependency.Item1.Rule]; - for (int child = children.NextSetBit(0); child >= 0; child = children.NextSetBit(child + 1)) - { - if (child < 0 || child >= ruleVersions.Length || @checked.Get(child)) - { - continue; - } - @checked.Set(child); - int required = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, child, "child"); - highestRequiredDependency = Math.Max(highestRequiredDependency, required); - } - } - if ((dependents & Dependents.Ancestors) != 0) - { - BitSet ancestors = relations.GetAncestors(dependency.Item1.Rule); - for (int ancestor = ancestors.NextSetBit(0); ancestor >= 0; ancestor = ancestors.NextSetBit(ancestor + 1)) - { - if (ancestor < 0 || ancestor >= ruleVersions.Length || @checked.Get(ancestor)) - { - continue; - } - @checked.Set(ancestor); - int required = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, ancestor, "ancestor"); - highestRequiredDependency = Math.Max(highestRequiredDependency, required); - } - } - if ((dependents & Dependents.Descendants) != 0) - { - BitSet descendants = relations.GetDescendants(dependency.Item1.Rule); - for (int descendant = descendants.NextSetBit(0); descendant >= 0; descendant = descendants.NextSetBit(descendant + 1)) - { - if (descendant < 0 || descendant >= ruleVersions.Length || @checked.Get(descendant)) - { - continue; - } - @checked.Set(descendant); - int required = CheckDependencyVersion(errors, dependency, ruleNames, ruleVersions, descendant, "descendant"); - highestRequiredDependency = Math.Max(highestRequiredDependency, required); - } - } - int declaredVersion = dependency.Item1.Version; - if (declaredVersion > highestRequiredDependency) - { - string message = string.Format("Rule dependency version mismatch: {0} has maximum dependency version {1} (expected {2}) in {3}", ruleNames[dependency.Item1.Rule], highestRequiredDependency, declaredVersion, dependency.Item1.Recognizer.ToString()); - errors.AppendLine(dependency.Item2.ToString()); - errors.AppendLine(message); - } - } - if (errors.Length > 0) - { - throw new InvalidOperationException(errors.ToString()); - } - } - - private static readonly Dependents ImplementedDependents = Dependents.Self | Dependents.Parents | Dependents.Children | Dependents.Ancestors | Dependents.Descendants; - - private static void ReportUnimplementedDependents(StringBuilder errors, Tuple dependency, Dependents dependents) - { - Dependents unimplemented = dependents; - unimplemented &= ~ImplementedDependents; - if (unimplemented != Dependents.None) - { - string message = string.Format("Cannot validate the following dependents of rule {0}: {1}", dependency.Item1.Rule, unimplemented); - errors.AppendLine(message); - } - } - - private static int CheckDependencyVersion(StringBuilder errors, Tuple dependency, string[] ruleNames, int[] ruleVersions, int relatedRule, string relation) - { - string ruleName = ruleNames[dependency.Item1.Rule]; - string path; - if (relation == null) - { - path = ruleName; - } - else - { - string mismatchedRuleName = ruleNames[relatedRule]; - path = string.Format("rule {0} ({1} of {2})", mismatchedRuleName, relation, ruleName); - } - int declaredVersion = dependency.Item1.Version; - int actualVersion = ruleVersions[relatedRule]; - if (actualVersion > declaredVersion) - { - string message = string.Format("Rule dependency version mismatch: {0} has version {1} (expected <= {2}) in {3}", path, actualVersion, declaredVersion, dependency.Item1.Recognizer.ToString()); - errors.AppendLine(dependency.Item2.ToString()); - errors.AppendLine(message); - } - return actualVersion; - } - - private static int[] GetRuleVersions(Type recognizerClass, string[] ruleNames) - { - int[] versions = new int[ruleNames.Length]; -#if DOTNETCORE - FieldInfo[] fields = recognizerClass.GetTypeInfo().GetFields(); -#else - FieldInfo[] fields = recognizerClass.GetFields(); -#endif - foreach (FieldInfo field in fields) - { - bool isStatic = field.IsStatic; - bool isInteger = field.FieldType == typeof(int); - if (isStatic && isInteger && field.Name.StartsWith("RULE_")) - { - try - { - string name = field.Name.Substring("RULE_".Length); - if (name.Length == 0 || !System.Char.IsLower(name[0])) - { - continue; - } - int index = (int)field.GetValue(null); - if (index < 0 || index >= versions.Length) - { -#if false - object[] @params = new object[] { index, field.Name, recognizerClass.Name }; - Logger.Log(Level.Warning, "Rule index {0} for rule ''{1}'' out of bounds for recognizer {2}.", @params); -#endif - continue; - } - MethodInfo ruleMethod = GetRuleMethod(recognizerClass, name); - if (ruleMethod == null) - { -#if false - object[] @params = new object[] { name, recognizerClass.Name }; - Logger.Log(Level.Warning, "Could not find rule method for rule ''{0}'' in recognizer {1}.", @params); -#endif - continue; - } -#if DOTNETCORE - RuleVersionAttribute ruleVersion = ruleMethod.GetCustomAttribute(); -#else - RuleVersionAttribute ruleVersion = (RuleVersionAttribute)Attribute.GetCustomAttribute(ruleMethod, typeof(RuleVersionAttribute)); -#endif - int version = ruleVersion != null ? ruleVersion.Version : 0; - versions[index] = version; - } - catch (ArgumentException) - { -#if false - Logger.Log(Level.Warning, null, ex); -#else - throw; -#endif - } - catch (MemberAccessException) - { -#if false - Logger.Log(Level.Warning, null, ex); -#else - throw; -#endif - } - } - } - return versions; - } - - private static MethodInfo GetRuleMethod(Type recognizerClass, string name) - { -#if DOTNETCORE - MethodInfo[] declaredMethods = recognizerClass.GetTypeInfo().GetMethods(); -#else - MethodInfo[] declaredMethods = recognizerClass.GetMethods(); -#endif - foreach (MethodInfo method in declaredMethods) - { -#if DOTNETCORE - if (method.Name.Equals(name) && method.IsDefined(typeof(RuleVersionAttribute))) -#else - if (method.Name.Equals(name) && Attribute.IsDefined(method, typeof(RuleVersionAttribute))) -#endif - { - return method; - } - } - return null; - } - - private static string[] GetRuleNames(Type recognizerClass) - { -#if DOTNETCORE - FieldInfo ruleNames = recognizerClass.GetTypeInfo().GetField("ruleNames"); -#else - FieldInfo ruleNames = recognizerClass.GetField("ruleNames"); -#endif - return (string[])ruleNames.GetValue(null); - } - - public static IList> GetDependencies(Type clazz) - { - IList> result = new ArrayList>(); - -#if DOTNETCORE - GetElementDependencies(AsCustomAttributeProvider(clazz.GetTypeInfo()), result); -#else - GetElementDependencies(AsCustomAttributeProvider(clazz), result); -#endif -#if DOTNETCORE - foreach (ConstructorInfo ctor in clazz.GetTypeInfo().GetConstructors(AllDeclaredMembers)) -#else - foreach (ConstructorInfo ctor in clazz.GetConstructors(AllDeclaredMembers)) -#endif - { - GetElementDependencies(AsCustomAttributeProvider(ctor), result); - foreach (ParameterInfo parameter in ctor.GetParameters()) - GetElementDependencies(AsCustomAttributeProvider(parameter), result); - } - -#if DOTNETCORE - foreach (FieldInfo field in clazz.GetTypeInfo().GetFields(AllDeclaredMembers)) -#else - foreach (FieldInfo field in clazz.GetFields(AllDeclaredMembers)) -#endif - { - GetElementDependencies(AsCustomAttributeProvider(field), result); - } - -#if DOTNETCORE - foreach (MethodInfo method in clazz.GetTypeInfo().GetMethods(AllDeclaredMembers)) -#else - foreach (MethodInfo method in clazz.GetMethods(AllDeclaredMembers)) -#endif - { - GetElementDependencies(AsCustomAttributeProvider(method), result); -#if COMPACT - if (method.ReturnTypeCustomAttributes != null) - GetElementDependencies(AsCustomAttributeProvider(method.ReturnTypeCustomAttributes), result); -#else - if (method.ReturnParameter != null) - GetElementDependencies(AsCustomAttributeProvider(method.ReturnParameter), result); -#endif - - foreach (ParameterInfo parameter in method.GetParameters()) - GetElementDependencies(AsCustomAttributeProvider(parameter), result); - } - - return result; - } - - private static void GetElementDependencies(ICustomAttributeProvider annotatedElement, IList> result) - { - foreach (RuleDependencyAttribute dependency in annotatedElement.GetCustomAttributes(typeof(RuleDependencyAttribute), true)) - { - result.Add(Tuple.Create(dependency, annotatedElement)); - } - } - - private static RuleDependencyChecker.RuleRelations ExtractRuleRelations(Type recognizer) - { - string serializedATN = GetSerializedATN(recognizer); - if (serializedATN == null) - { - return null; - } - ATN atn = new ATNDeserializer().Deserialize(serializedATN.ToCharArray()); - RuleDependencyChecker.RuleRelations relations = new RuleDependencyChecker.RuleRelations(atn.ruleToStartState.Length); - foreach (ATNState state in atn.states) - { - if (!state.epsilonOnlyTransitions) - { - continue; - } - foreach (Transition transition in state.transitions) - { - if (transition.TransitionType != TransitionType.RULE) - { - continue; - } - RuleTransition ruleTransition = (RuleTransition)transition; - relations.AddRuleInvocation(state.ruleIndex, ruleTransition.target.ruleIndex); - } - } - return relations; - } - - private static string GetSerializedATN(Type recognizerClass) - { -#if DOTNETCORE - FieldInfo serializedAtnField = recognizerClass.GetTypeInfo().GetField("_serializedATN", AllDeclaredStaticMembers); -#else - FieldInfo serializedAtnField = recognizerClass.GetField("_serializedATN", AllDeclaredStaticMembers); -#endif - if (serializedAtnField != null) - return (string)serializedAtnField.GetValue(null); - -#if DOTNETCORE - if (recognizerClass.GetTypeInfo().BaseType != null) - return GetSerializedATN(recognizerClass.GetTypeInfo().BaseType); -#else - if (recognizerClass.BaseType != null) - return GetSerializedATN(recognizerClass.BaseType); -#endif - - return null; - } - - private sealed class RuleRelations - { - public readonly BitSet[] parents; - - public readonly BitSet[] children; - - public RuleRelations(int ruleCount) - { - parents = new BitSet[ruleCount]; - for (int i = 0; i < ruleCount; i++) - { - parents[i] = new BitSet(); - } - children = new BitSet[ruleCount]; - for (int i_1 = 0; i_1 < ruleCount; i_1++) - { - children[i_1] = new BitSet(); - } - } - - public bool AddRuleInvocation(int caller, int callee) - { - if (caller < 0) - { - // tokens rule - return false; - } - if (children[caller].Get(callee)) - { - // already added - return false; - } - children[caller].Set(callee); - parents[callee].Set(caller); - return true; - } - - public BitSet GetAncestors(int rule) - { - BitSet ancestors = new BitSet(); - ancestors.Or(parents[rule]); - while (true) - { - int cardinality = ancestors.Cardinality(); - for (int i = ancestors.NextSetBit(0); i >= 0; i = ancestors.NextSetBit(i + 1)) - { - ancestors.Or(parents[i]); - } - if (ancestors.Cardinality() == cardinality) - { - // nothing changed - break; - } - } - return ancestors; - } - - public BitSet GetDescendants(int rule) - { - BitSet descendants = new BitSet(); - descendants.Or(children[rule]); - while (true) - { - int cardinality = descendants.Cardinality(); - for (int i = descendants.NextSetBit(0); i >= 0; i = descendants.NextSetBit(i + 1)) - { - descendants.Or(children[i]); - } - if (descendants.Cardinality() == cardinality) - { - // nothing changed - break; - } - } - return descendants; - } - } - - private RuleDependencyChecker() - { - } - -#if PORTABLE - public interface ICustomAttributeProvider - { - object[] GetCustomAttributes(Type attributeType, bool inherit); - } - - protected static ICustomAttributeProvider AsCustomAttributeProvider(Type type) - { - return new TypeCustomAttributeProvider(type); - } - - protected static ICustomAttributeProvider AsCustomAttributeProvider(MethodBase method) - { - return new MethodBaseCustomAttributeProvider(method); - } - - protected static ICustomAttributeProvider AsCustomAttributeProvider(ParameterInfo parameter) - { - return new ParameterInfoCustomAttributeProvider(parameter); - } - - protected static ICustomAttributeProvider AsCustomAttributeProvider(FieldInfo field) - { - return new FieldInfoCustomAttributeProvider(field); - } - - protected sealed class TypeCustomAttributeProvider : ICustomAttributeProvider - { - private readonly Type _provider; - - public TypeCustomAttributeProvider(Type provider) - { - _provider = provider; - } - - public object[] GetCustomAttributes(Type attributeType, bool inherit) - { - return Attribute.GetCustomAttributes(_provider, attributeType, inherit); - } - } - - protected sealed class MethodBaseCustomAttributeProvider : ICustomAttributeProvider - { - private readonly MethodBase _provider; - - public MethodBaseCustomAttributeProvider(MethodBase provider) - { - _provider = provider; - } - - public object[] GetCustomAttributes(Type attributeType, bool inherit) - { - return Attribute.GetCustomAttributes(_provider, attributeType, inherit); - } - } - - protected sealed class ParameterInfoCustomAttributeProvider : ICustomAttributeProvider - { - private readonly ParameterInfo _provider; - - public ParameterInfoCustomAttributeProvider(ParameterInfo provider) - { - _provider = provider; - } - - public object[] GetCustomAttributes(Type attributeType, bool inherit) - { - return Attribute.GetCustomAttributes(_provider, attributeType, inherit); - } - } - - protected sealed class FieldInfoCustomAttributeProvider : ICustomAttributeProvider - { - private readonly FieldInfo _provider; - - public FieldInfoCustomAttributeProvider(FieldInfo provider) - { - _provider = provider; - } - - public object[] GetCustomAttributes(Type attributeType, bool inherit) - { - return Attribute.GetCustomAttributes(_provider, attributeType, inherit); - } - } -#else - protected static ICustomAttributeProvider AsCustomAttributeProvider(ICustomAttributeProvider obj) - { - return obj; - } -#endif - } -} - -#endif diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs index 9f7000bcc..414db8bae 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Text; -using Antlr4.Runtime.Sharpen; namespace Antlr4.Runtime.Misc { @@ -13,20 +12,7 @@ namespace Antlr4.Runtime.Misc { public static string Join(string separator, IEnumerable items) { -#if NET40PLUS return string.Join(separator, items); -#else - ArrayList elements = new ArrayList(); - foreach (T item in items) - { - if (item == null) - elements.Add(""); - else - elements.Add(item.ToString()); - } - - return string.Join(separator, elements.ToArray()); -#endif } public static int NumNonnull(object[] data) diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs index 130e00418..2382d4506 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs @@ -19,7 +19,6 @@ namespace Antlr4.Runtime /// This is all the parsing support code essentially; most of it is error recovery stuff. public abstract class Parser : Recognizer { -#if !PORTABLE public class TraceListener : IParseTreeListener { @@ -58,7 +57,6 @@ namespace Antlr4.Runtime private readonly Parser _enclosing; private readonly TextWriter _output; } -#endif public class TrimToSizeListener : IParseTreeListener { @@ -133,7 +131,6 @@ namespace Antlr4.Runtime /// private bool _buildParseTrees = true; -#if !PORTABLE /// /// When /// @@ -149,7 +146,6 @@ namespace Antlr4.Runtime /// other parser methods. /// private Parser.TraceListener _tracer; -#endif /// /// The list of @@ -192,9 +188,7 @@ namespace Antlr4.Runtime _errHandler.Reset(this); _ctx = null; _syntaxErrors = 0; -#if !PORTABLE Trace = false; -#endif _precedenceStack.Clear(); _precedenceStack.Add(0); ATNSimulator interpreter = Interpreter; @@ -1146,7 +1140,6 @@ namespace Antlr4.Runtime return s; } -#if !PORTABLE /// For debugging and other purposes. /// For debugging and other purposes. public virtual void DumpDFA() @@ -1167,7 +1160,6 @@ namespace Antlr4.Runtime } } } -#endif public virtual string SourceName { @@ -1214,7 +1206,6 @@ namespace Antlr4.Runtime } } -#if !PORTABLE /// /// During a parse is sometimes useful to listen in on the rule entry and exit /// events as well as token matches. @@ -1258,6 +1249,5 @@ namespace Antlr4.Runtime } } } -#endif } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs index 00b73ffc6..4503db1dc 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs @@ -279,11 +279,7 @@ namespace Antlr4.Runtime return null; } -#if (NET45PLUS && !DOTNETCORE) public virtual IReadOnlyList GetTokens(int ttype) -#else - public virtual ITerminalNode[] GetTokens(int ttype) -#endif { if (children == null) { @@ -310,11 +306,8 @@ namespace Antlr4.Runtime { return Collections.EmptyList(); } -#if (NET45PLUS && !DOTNETCORE) + return tokens; -#else - return tokens.ToArray(); -#endif } public virtual T GetRuleContext(int i) @@ -323,13 +316,8 @@ namespace Antlr4.Runtime return GetChild(i); } -#if (NET45PLUS && !DOTNETCORE) public virtual IReadOnlyList GetRuleContexts() where T : Antlr4.Runtime.ParserRuleContext -#else - public virtual T[] GetRuleContexts() - where T : Antlr4.Runtime.ParserRuleContext -#endif { if (children == null) { @@ -351,11 +339,8 @@ namespace Antlr4.Runtime { return Collections.EmptyList(); } -#if (NET45PLUS && !DOTNETCORE) + return contexts; -#else - return contexts.ToArray(); -#endif } public override int ChildCount diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs index b4798599e..b11606203 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs @@ -4,7 +4,6 @@ */ using System; using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -20,17 +19,13 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: CLSCompliant(true)] -#if !PORTABLE || NET45PLUS // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -#if !PORTABLE // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("bc228eb9-e79c-4e5a-a1b9-0434ea566bab")] -#endif -#endif // Version information for an assembly consists of the following four values: // @@ -43,7 +38,6 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("4.9")] -#if !COMPACT [assembly: AssemblyFileVersion("4.9")] [assembly: AssemblyInformationalVersion("4.9")] -#endif + diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Recognizer.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Recognizer.cs index 150ead5a6..5f24bb00e 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Recognizer.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Recognizer.cs @@ -4,13 +4,10 @@ */ using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; using Antlr4.Runtime.Atn; using Antlr4.Runtime.Misc; -#if NET40PLUS -using System.Runtime.CompilerServices; -#endif - namespace Antlr4.Runtime { public abstract class Recognizer : IRecognizer @@ -18,17 +15,13 @@ namespace Antlr4.Runtime { public const int Eof = -1; -#if NET40PLUS private static readonly ConditionalWeakTable> tokenTypeMapCache = new ConditionalWeakTable>(); private static readonly ConditionalWeakTable> ruleIndexMapCache = new ConditionalWeakTable>(); -#endif [NotNull] private IAntlrErrorListener[] _listeners = { -#if !PORTABLE ConsoleErrorListener.Instance -#endif }; private ATNInterpreter _interp; @@ -74,11 +67,7 @@ namespace Antlr4.Runtime { get { -#if NET40PLUS return tokenTypeMapCache.GetValue(Vocabulary, CreateTokenTypeMap); -#else - return CreateTokenTypeMap(Vocabulary); -#endif } } @@ -117,11 +106,8 @@ namespace Antlr4.Runtime { throw new NotSupportedException("The current recognizer does not provide a list of rule names."); } -#if NET40PLUS + return ruleIndexMapCache.GetValue(ruleNames, Utils.ToMap); -#else - return Utils.ToMap(ruleNames); -#endif } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs index d39298f15..786240722 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs @@ -4,7 +4,6 @@ */ namespace Antlr4.Runtime.Sharpen { - using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -15,11 +14,7 @@ namespace Antlr4.Runtime.Sharpen return EmptyListImpl.Instance; } -#if NET45PLUS public static ReadOnlyDictionary EmptyMap() -#else - public static IDictionary EmptyMap() -#endif { return EmptyMapImpl.Instance; } @@ -29,17 +24,9 @@ namespace Antlr4.Runtime.Sharpen return new ReadOnlyCollection(new T[] { item }); } -#if NET45PLUS public static ReadOnlyDictionary SingletonMap(TKey key, TValue value) -#else - public static IDictionary SingletonMap(TKey key, TValue value) -#endif { -#if NET45PLUS return new ReadOnlyDictionary(new Dictionary { { key, value } }); -#else - return new Dictionary { { key, value } }; -#endif } private static class EmptyListImpl @@ -49,18 +36,8 @@ namespace Antlr4.Runtime.Sharpen private static class EmptyMapImpl { -#if NET45PLUS public static readonly ReadOnlyDictionary Instance = new ReadOnlyDictionary(new Dictionary()); -#else - public static IDictionary Instance - { - get - { - return new Dictionary(); - } - } -#endif } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs index 72b66c7fb..ff18f30b9 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs @@ -3,7 +3,7 @@ * can be found in the LICENSE.txt file in the project root. */ -#if PORTABLE || DOTNETCORE +#if NETSTANDARD20 namespace System { @@ -13,5 +13,4 @@ namespace System } } -#endif - +#endif \ No newline at end of file diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/ListExtensions.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/ListExtensions.cs index 999a97f71..e57af31df 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/ListExtensions.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/ListExtensions.cs @@ -5,7 +5,6 @@ namespace Antlr4.Runtime.Sharpen { using System.Collections.Generic; - using Antlr4.Runtime.Misc; internal static class ListExtensions { @@ -16,8 +15,5 @@ namespace Antlr4.Runtime.Sharpen list[index] = value; return previous; } - - - - } + } } diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs index 8ba429c60..62b22ba36 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs @@ -621,9 +621,7 @@ namespace Antlr4.Runtime // kill first delete rop.index = Math.Min(prevRop.index, rop.index); rop.lastIndex = Math.Max(prevRop.lastIndex, rop.lastIndex); -#if !PORTABLE System.Console.Out.WriteLine("new rop " + rop); -#endif } else { diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor.cs index 3b3188183..4ad93c6da 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor.cs @@ -16,11 +16,7 @@ namespace Antlr4.Runtime.Tree /// . /// /// Sam Harwell -#if COMPACT - public interface IParseTreeVisitor -#else public interface IParseTreeVisitor -#endif { /// Visit a parse tree, and return a user-defined result of the operation. /// Visit a parse tree, and return a user-defined result of the operation. diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty.cs index 40b2e421a..3b12cb99e 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty.cs @@ -2,11 +2,7 @@ * 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. */ -#if NET40PLUS using System.Collections.Concurrent; -#else -using Antlr4.Runtime.Sharpen; -#endif namespace Antlr4.Runtime.Tree { From 047005044dc45e69c6625c8b7682112d7c32cb71 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 2 Dec 2020 20:59:58 +0300 Subject: [PATCH 23/36] Remove Compact folder because it's not actual --- .../Sharpen/Compat/CollectionDebuggerView.cs | 83 -- .../Sharpen/Compat/ConcurrentDictionary.cs | 468 -------- .../Antlr4.Runtime/Sharpen/Compat/Funcs.cs | 35 - .../Sharpen/Compat/IStructuralComparable.cs | 41 - .../Sharpen/Compat/IStructuralEquatable.cs | 43 - .../Sharpen/Compat/SplitOrderedList.cs | 551 ---------- .../Antlr4.Runtime/Sharpen/Compat/Tuple.cs | 115 -- .../Antlr4.Runtime/Sharpen/Compat/Tuples.cs | 995 ------------------ 8 files changed, 2331 deletions(-) delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/CollectionDebuggerView.cs delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/ConcurrentDictionary.cs delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Funcs.cs delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/IStructuralComparable.cs delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/IStructuralEquatable.cs delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SplitOrderedList.cs delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Tuple.cs delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Tuples.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/CollectionDebuggerView.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/CollectionDebuggerView.cs deleted file mode 100644 index b1c0c8664..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/CollectionDebuggerView.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -// CollectionDebuggerView.cs -// -// Authors: -// Marek Safar -// -// Copyright (C) 2009 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#if !NET40PLUS || (PORTABLE && !WINRT) - -using System; -using System.Collections.Generic; -using System.Diagnostics; - -namespace Antlr4.Runtime.Sharpen -{ - // - // Custom debugger type proxy to display collections as arrays - // - internal sealed class CollectionDebuggerView - { - readonly ICollection c; - - public CollectionDebuggerView (ICollection col) - { - this.c = col; - } - -#if !COMPACT - [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] -#endif - public T[] Items { - get { - var o = new T [c.Count]; - c.CopyTo (o, 0); - return o; - } - } - } - - internal sealed class CollectionDebuggerView - { - readonly ICollection> c; - - public CollectionDebuggerView (ICollection> col) - { - this.c = col; - } - -#if !COMPACT - [DebuggerBrowsable (DebuggerBrowsableState.RootHidden)] -#endif - public KeyValuePair[] Items { - get { - var o = new KeyValuePair [c.Count]; - c.CopyTo (o, 0); - return o; - } - } - } -} - -#endif diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/ConcurrentDictionary.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/ConcurrentDictionary.cs deleted file mode 100644 index a79467d86..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/ConcurrentDictionary.cs +++ /dev/null @@ -1,468 +0,0 @@ -// ConcurrentDictionary.cs -// -// Copyright (c) 2009 Jérémie "Garuma" Laval -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -// - -#if !NET40PLUS || (PORTABLE && !WINRT) - -using System; -using System.Threading; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Runtime.Serialization; -using System.Diagnostics; - -// declare the namespace so Sharpen-generated using declarations will not produce errors -namespace System.Collections.Concurrent -{ -} - -namespace Antlr4.Runtime.Sharpen -{ -#if !COMPACT - [DebuggerDisplay ("Count={Count}")] - [DebuggerTypeProxy (typeof (CollectionDebuggerView<,>))] -#endif - public class ConcurrentDictionary : IDictionary, - ICollection>, IEnumerable>, - IDictionary, ICollection, IEnumerable - { - IEqualityComparer comparer; - - SplitOrderedList> internalDictionary; - - public ConcurrentDictionary () : this (EqualityComparer.Default) - { - } - - public ConcurrentDictionary (IEnumerable> collection) - : this (collection, EqualityComparer.Default) - { - } - - public ConcurrentDictionary (IEqualityComparer comparer) - { - this.comparer = comparer; - this.internalDictionary = new SplitOrderedList> (comparer); - } - - public ConcurrentDictionary (IEnumerable> collection, IEqualityComparer comparer) - : this (comparer) - { - foreach (KeyValuePair pair in collection) - Add (pair.Key, pair.Value); - } - - // Parameters unused - public ConcurrentDictionary (int concurrencyLevel, int capacity) - : this (EqualityComparer.Default) - { - - } - - public ConcurrentDictionary (int concurrencyLevel, - IEnumerable> collection, - IEqualityComparer comparer) - : this (collection, comparer) - { - - } - - // Parameters unused - public ConcurrentDictionary (int concurrencyLevel, int capacity, IEqualityComparer comparer) - : this (comparer) - { - - } - - void CheckKey (TKey key) - { - if (key == null) - throw new ArgumentNullException ("key"); - } - - void Add (TKey key, TValue value) - { - while (!TryAdd (key, value)); - } - - void IDictionary.Add (TKey key, TValue value) - { - Add (key, value); - } - - public bool TryAdd (TKey key, TValue value) - { - CheckKey (key); - return internalDictionary.Insert (Hash (key), key, Make (key, value)); - } - - void ICollection>.Add (KeyValuePair pair) - { - Add (pair.Key, pair.Value); - } - - public TValue AddOrUpdate (TKey key, Func addValueFactory, Func updateValueFactory) - { - CheckKey (key); - if (addValueFactory == null) - throw new ArgumentNullException ("addValueFactory"); - if (updateValueFactory == null) - throw new ArgumentNullException ("updateValueFactory"); - return internalDictionary.InsertOrUpdate (Hash (key), - key, - () => Make (key, addValueFactory (key)), - (e) => Make (key, updateValueFactory (key, e.Value))).Value; - } - - public TValue AddOrUpdate (TKey key, TValue addValue, Func updateValueFactory) - { - return AddOrUpdate (key, (_) => addValue, updateValueFactory); - } - - TValue AddOrUpdate (TKey key, TValue addValue, TValue updateValue) - { - CheckKey (key); - return internalDictionary.InsertOrUpdate (Hash (key), - key, - Make (key, addValue), - Make (key, updateValue)).Value; - } - - TValue GetValue (TKey key) - { - TValue temp; - if (!TryGetValue (key, out temp)) - throw new KeyNotFoundException (key.ToString ()); - return temp; - } - - public bool TryGetValue (TKey key, out TValue value) - { - CheckKey (key); - KeyValuePair pair; - bool result = internalDictionary.Find (Hash (key), key, out pair); - value = pair.Value; - - return result; - } - - public bool TryUpdate (TKey key, TValue newValue, TValue comparisonValue) - { - CheckKey (key); - return internalDictionary.CompareExchange (Hash (key), key, Make (key, newValue), (e) => e.Value.Equals (comparisonValue)); - } - - public TValue this[TKey key] { - get { - return GetValue (key); - } - set { - AddOrUpdate (key, value, value); - } - } - - public TValue GetOrAdd (TKey key, Func valueFactory) - { - CheckKey (key); - return internalDictionary.InsertOrGet (Hash (key), key, Make (key, default(TValue)), () => Make (key, valueFactory (key))).Value; - } - - public TValue GetOrAdd (TKey key, TValue value) - { - CheckKey (key); - return internalDictionary.InsertOrGet (Hash (key), key, Make (key, value), null).Value; - } - - public bool TryRemove (TKey key, out TValue value) - { - CheckKey (key); - KeyValuePair data; - bool result = internalDictionary.Delete (Hash (key), key, out data); - value = data.Value; - return result; - } - - bool Remove (TKey key) - { - TValue dummy; - - return TryRemove (key, out dummy); - } - - bool IDictionary.Remove (TKey key) - { - return Remove (key); - } - - bool ICollection>.Remove (KeyValuePair pair) - { - return Remove (pair.Key); - } - - public bool ContainsKey (TKey key) - { - CheckKey (key); - KeyValuePair dummy; - return internalDictionary.Find (Hash (key), key, out dummy); - } - - bool IDictionary.Contains (object key) - { - if (!(key is TKey)) - return false; - - return ContainsKey ((TKey)key); - } - - void IDictionary.Remove (object key) - { - if (!(key is TKey)) - return; - - Remove ((TKey)key); - } - - object IDictionary.this [object key] - { - get { - if (!(key is TKey)) - throw new ArgumentException ("key isn't of correct type", "key"); - - return this[(TKey)key]; - } - set { - if (!(key is TKey) || !(value is TValue)) - throw new ArgumentException ("key or value aren't of correct type"); - - this[(TKey)key] = (TValue)value; - } - } - - void IDictionary.Add (object key, object value) - { - if (!(key is TKey) || !(value is TValue)) - throw new ArgumentException ("key or value aren't of correct type"); - - Add ((TKey)key, (TValue)value); - } - - bool ICollection>.Contains (KeyValuePair pair) - { - return ContainsKey (pair.Key); - } - - public KeyValuePair[] ToArray () - { - // This is most certainly not optimum but there is - // not a lot of possibilities - - return new List> (this).ToArray (); - } - - public void Clear() - { - // Pronk - internalDictionary = new SplitOrderedList> (comparer); - } - - public int Count { - get { - return internalDictionary.Count; - } - } - - public bool IsEmpty { - get { - return Count == 0; - } - } - - bool ICollection>.IsReadOnly { - get { - return false; - } - } - - bool IDictionary.IsReadOnly { - get { - return false; - } - } - - public ICollection Keys { - get { - return GetPart ((kvp) => kvp.Key); - } - } - - public ICollection Values { - get { - return GetPart ((kvp) => kvp.Value); - } - } - - ICollection IDictionary.Keys { - get { - return (ICollection)Keys; - } - } - - ICollection IDictionary.Values { - get { - return (ICollection)Values; - } - } - - ICollection GetPart (Func, T> extractor) - { - List temp = new List (); - - foreach (KeyValuePair kvp in this) - temp.Add (extractor (kvp)); - - return new ReadOnlyCollection(temp); - } - - void ICollection.CopyTo (Array array, int startIndex) - { - KeyValuePair[] arr = array as KeyValuePair[]; - if (arr == null) - return; - - CopyTo (arr, startIndex, Count); - } - - void CopyTo (KeyValuePair[] array, int startIndex) - { - CopyTo (array, startIndex, Count); - } - - void ICollection>.CopyTo (KeyValuePair[] array, int startIndex) - { - CopyTo (array, startIndex); - } - - void CopyTo (KeyValuePair[] array, int startIndex, int num) - { - foreach (var kvp in this) { - array [startIndex++] = kvp; - - if (--num <= 0) - return; - } - } - - public IEnumerator> GetEnumerator () - { - return GetEnumeratorInternal (); - } - - IEnumerator IEnumerable.GetEnumerator () - { - return (IEnumerator)GetEnumeratorInternal (); - } - - IEnumerator> GetEnumeratorInternal () - { - return internalDictionary.GetEnumerator (); - } - - IDictionaryEnumerator IDictionary.GetEnumerator () - { - return new ConcurrentDictionaryEnumerator (GetEnumeratorInternal ()); - } - - class ConcurrentDictionaryEnumerator : IDictionaryEnumerator - { - IEnumerator> internalEnum; - - public ConcurrentDictionaryEnumerator (IEnumerator> internalEnum) - { - this.internalEnum = internalEnum; - } - - public bool MoveNext () - { - return internalEnum.MoveNext (); - } - - public void Reset () - { - internalEnum.Reset (); - } - - public object Current { - get { - return Entry; - } - } - - public DictionaryEntry Entry { - get { - KeyValuePair current = internalEnum.Current; - return new DictionaryEntry (current.Key, current.Value); - } - } - - public object Key { - get { - return internalEnum.Current.Key; - } - } - - public object Value { - get { - return internalEnum.Current.Value; - } - } - } - - object ICollection.SyncRoot { - get { - return this; - } - } - - bool IDictionary.IsFixedSize { - get { - return false; - } - } - - bool ICollection.IsSynchronized { - get { return true; } - } - - static KeyValuePair Make (U key, V value) - { - return new KeyValuePair (key, value); - } - - uint Hash (TKey key) - { - return (uint)comparer.GetHashCode (key); - } - } -} -#endif diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Funcs.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Funcs.cs deleted file mode 100644 index 0be99b9f9..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Funcs.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -// System.Func.cs -// -// Authors: -// Alejandro Serrano "Serras" (trupill@yahoo.es) -// Marek Safar (marek.safar@gmail.com) -// - -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR TArg PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// - -namespace Antlr4.Runtime.Sharpen { - - public delegate TResult Func (); - - public delegate TResult Func (T arg); - - public delegate TResult Func (T1 arg1, T2 arg2); -} diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/IStructuralComparable.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/IStructuralComparable.cs deleted file mode 100644 index 0f6b37205..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/IStructuralComparable.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// IStructuralComparable.cs -// -// Authors: -// Zoltan Varga (vargaz@gmail.com) -// -// Copyright (C) 2009 Novell -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#if !NET40PLUS - -using System; -using System.Collections; - -namespace Antlr4.Runtime.Sharpen -{ - internal interface IStructuralComparable { - int CompareTo (object other, IComparer comparer); - } -} - -#endif diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/IStructuralEquatable.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/IStructuralEquatable.cs deleted file mode 100644 index 7e8cb1605..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/IStructuralEquatable.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// IStructuralEquatable.cs -// -// Authors: -// Zoltan Varga (vargaz@gmail.com) -// -// Copyright (C) 2009 Novell -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#if !NET40PLUS - -using System; -using System.Collections; - -namespace Antlr4.Runtime.Sharpen -{ - internal interface IStructuralEquatable { - bool Equals (object other, IEqualityComparer comparer); - - int GetHashCode (IEqualityComparer comparer); - } -} - -#endif diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SplitOrderedList.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SplitOrderedList.cs deleted file mode 100644 index 4f9874b05..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SplitOrderedList.cs +++ /dev/null @@ -1,551 +0,0 @@ -// SplitOrderedList.cs -// -// Copyright (c) 2010 Jérémie "Garuma" Laval -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -// - -#if !NET40PLUS || (PORTABLE && !WINRT) - -using System; -using System.Threading; -using System.Collections; -using System.Collections.Generic; - -namespace Antlr4.Runtime.Sharpen -{ - internal class SplitOrderedList - { - class Node - { - public bool Marked; - public ulong Key; - public TKey SubKey; - public T Data; - public Node Next; - - public Node Init (ulong key, TKey subKey, T data) - { - this.Key = key; - this.SubKey = subKey; - this.Data = data; - - this.Marked = false; - this.Next = null; - - return this; - } - - // Used to create dummy node - public Node Init (ulong key) - { - this.Key = key; - this.Data = default (T); - - this.Next = null; - this.Marked = false; - this.SubKey = default (TKey); - - return this; - } - - // Used to create marked node - public Node Init (Node wrapped) - { - this.Marked = true; - this.Next = wrapped; - - this.Key = 0; - this.Data = default (T); - this.SubKey = default (TKey); - - return this; - } - } - - const int MaxLoad = 5; - const uint BucketSize = 512; - - Node head; - Node tail; - - Node[] buckets = new Node [BucketSize]; - int count; - int size = 2; - - SimpleRwLock slim = new SimpleRwLock (); - - readonly IEqualityComparer comparer; - - public SplitOrderedList (IEqualityComparer comparer) - { - this.comparer = comparer; - head = new Node ().Init (0); - tail = new Node ().Init (ulong.MaxValue); - head.Next = tail; - SetBucket (0, head); - } - - public int Count { - get { - return count; - } - } - - public T InsertOrUpdate (uint key, TKey subKey, Func addGetter, Func updateGetter) - { - Node current; - bool result = InsertInternal (key, subKey, default (T), addGetter, out current); - - if (result) - return current.Data; - - // FIXME: this should have a CAS-like behavior - return current.Data = updateGetter (current.Data); - } - - public T InsertOrUpdate (uint key, TKey subKey, T addValue, T updateValue) - { - Node current; - if (InsertInternal (key, subKey, addValue, null, out current)) - return current.Data; - - // FIXME: this should have a CAS-like behavior - return current.Data = updateValue; - } - - public bool Insert (uint key, TKey subKey, T data) - { - Node current; - return InsertInternal (key, subKey, data, null, out current); - } - - public T InsertOrGet (uint key, TKey subKey, T data, Func dataCreator) - { - Node current; - InsertInternal (key, subKey, data, dataCreator, out current); - return current.Data; - } - - bool InsertInternal (uint key, TKey subKey, T data, Func dataCreator, out Node current) - { - Node node = new Node ().Init (ComputeRegularKey (key), subKey, data); - - uint b = key % (uint)size; - Node bucket; - - if ((bucket = GetBucket (b)) == null) - bucket = InitializeBucket (b); - - if (!ListInsert (node, bucket, out current, dataCreator)) - return false; - - int csize = size; - if (Interlocked.Increment (ref count) / csize > MaxLoad && (csize & 0x40000000) == 0) - Interlocked.CompareExchange (ref size, 2 * csize, csize); - - current = node; - - return true; - } - - public bool Find (uint key, TKey subKey, out T data) - { - Node node; - uint b = key % (uint)size; - data = default (T); - Node bucket; - - if ((bucket = GetBucket (b)) == null) - bucket = InitializeBucket (b); - - if (!ListFind (ComputeRegularKey (key), subKey, bucket, out node)) - return false; - - data = node.Data; - - return !node.Marked; - } - - public bool CompareExchange (uint key, TKey subKey, T data, Func check) - { - Node node; - uint b = key % (uint)size; - Node bucket; - - if ((bucket = GetBucket (b)) == null) - bucket = InitializeBucket (b); - - if (!ListFind (ComputeRegularKey (key), subKey, bucket, out node)) - return false; - - if (!check (node.Data)) - return false; - - node.Data = data; - - return true; - } - - public bool Delete (uint key, TKey subKey, out T data) - { - uint b = key % (uint)size; - Node bucket; - - if ((bucket = GetBucket (b)) == null) - bucket = InitializeBucket (b); - - if (!ListDelete (bucket, ComputeRegularKey (key), subKey, out data)) - return false; - - Interlocked.Decrement (ref count); - return true; - } - - public IEnumerator GetEnumerator () - { - Node node = head.Next; - - while (node != tail) { - while (node.Marked || (node.Key & 1) == 0) { - node = node.Next; - if (node == tail) - yield break; - } - yield return node.Data; - node = node.Next; - } - } - - Node InitializeBucket (uint b) - { - Node current; - uint parent = GetParent (b); - Node bucket; - - if ((bucket = GetBucket (parent)) == null) - bucket = InitializeBucket (parent); - - Node dummy = new Node ().Init (ComputeDummyKey (b)); - if (!ListInsert (dummy, bucket, out current, null)) - return current; - - return SetBucket (b, dummy); - } - - // Turn v's MSB off - static uint GetParent (uint v) - { - uint t, tt; - - // Find MSB position in v - var pos = (tt = v >> 16) > 0 ? - (t = tt >> 8) > 0 ? 24 + logTable[t] : 16 + logTable[tt] : - (t = v >> 8) > 0 ? 8 + logTable[t] : logTable[v]; - - return (uint)(v & ~(1 << pos)); - } - - // Reverse integer bits and make sure LSB is set - static ulong ComputeRegularKey (uint key) - { - return ComputeDummyKey (key) | 1; - } - - // Reverse integer bits - static ulong ComputeDummyKey (uint key) - { - return ((ulong)(((uint)reverseTable[key & 0xff] << 24) | - ((uint)reverseTable[(key >> 8) & 0xff] << 16) | - ((uint)reverseTable[(key >> 16) & 0xff] << 8) | - ((uint)reverseTable[(key >> 24) & 0xff]))) << 1; - } - - // Bucket storage is abstracted in a simple two-layer tree to avoid too much memory resize - Node GetBucket (uint index) - { - if (index >= buckets.Length) - return null; - return buckets[index]; - } - - Node SetBucket (uint index, Node node) - { - try { - slim.EnterReadLock (); - CheckSegment (index, true); - - Interlocked.CompareExchange (ref buckets[index], node, null); - return buckets[index]; - } finally { - slim.ExitReadLock (); - } - } - - // When we run out of space for bucket storage, we use a lock-based array resize - void CheckSegment (uint segment, bool readLockTaken) - { - if (segment < buckets.Length) - return; - - if (readLockTaken) - slim.ExitReadLock (); - try { - slim.EnterWriteLock (); - while (segment >= buckets.Length) - Array.Resize (ref buckets, buckets.Length * 2); - } finally { - slim.ExitWriteLock (); - } - if (readLockTaken) - slim.EnterReadLock (); - } - - Node ListSearch (ulong key, TKey subKey, ref Node left, Node h) - { - Node leftNodeNext = null, rightNode = null; - - do { - Node t = h; - Node tNext = t.Next; - do { - if (!tNext.Marked) { - left = t; - leftNodeNext = tNext; - } - t = tNext.Marked ? tNext.Next : tNext; - if (t == tail) - break; - - tNext = t.Next; - } while (tNext.Marked || t.Key < key || (tNext.Key == key && !comparer.Equals (subKey, t.SubKey))); - - rightNode = t; - - if (leftNodeNext == rightNode) { - if (rightNode != tail && rightNode.Next.Marked) - continue; - else - return rightNode; - } - - if (Interlocked.CompareExchange (ref left.Next, rightNode, leftNodeNext) == leftNodeNext) { - if (rightNode != tail && rightNode.Next.Marked) - continue; - else - return rightNode; - } - } while (true); - } - - bool ListDelete (Node startPoint, ulong key, TKey subKey, out T data) - { - Node rightNode = null, rightNodeNext = null, leftNode = null; - data = default (T); - Node markedNode = null; - - do { - rightNode = ListSearch (key, subKey, ref leftNode, startPoint); - if (rightNode == tail || rightNode.Key != key || !comparer.Equals (subKey, rightNode.SubKey)) - return false; - - data = rightNode.Data; - rightNodeNext = rightNode.Next; - - if (!rightNodeNext.Marked) { - if (markedNode == null) - markedNode = new Node (); - markedNode.Init (rightNodeNext); - - if (Interlocked.CompareExchange (ref rightNode.Next, markedNode, rightNodeNext) == rightNodeNext) - break; - } - } while (true); - - if (Interlocked.CompareExchange (ref leftNode.Next, rightNodeNext, rightNode) != rightNode) - ListSearch (rightNode.Key, subKey, ref leftNode, startPoint); - - return true; - } - - bool ListInsert (Node newNode, Node startPoint, out Node current, Func dataCreator) - { - ulong key = newNode.Key; - Node rightNode = null, leftNode = null; - - do { - rightNode = current = ListSearch (key, newNode.SubKey, ref leftNode, startPoint); - if (rightNode != tail && rightNode.Key == key && comparer.Equals (newNode.SubKey, rightNode.SubKey)) - return false; - - newNode.Next = rightNode; - if (dataCreator != null) - newNode.Data = dataCreator (); - if (Interlocked.CompareExchange (ref leftNode.Next, newNode, rightNode) == rightNode) - return true; - } while (true); - } - - bool ListFind (ulong key, TKey subKey, Node startPoint, out Node data) - { - Node rightNode = null, leftNode = null; - data = null; - - rightNode = ListSearch (key, subKey, ref leftNode, startPoint); - data = rightNode; - - return rightNode != tail && rightNode.Key == key && comparer.Equals (subKey, rightNode.SubKey); - } - - static readonly byte[] reverseTable = { - 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 - }; - - static readonly byte[] logTable = { - 0xFF, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 - }; - - struct SimpleRwLock - { - const int RwWait = 1; - const int RwWrite = 2; - const int RwRead = 4; - - int rwlock; - - public void EnterReadLock () - { - SpinWait sw = new SpinWait (); - do { - while ((rwlock & (RwWrite | RwWait)) > 0) - sw.SpinOnce (); - -#if COMPACT - if ((InterlockedAdd (ref rwlock, RwRead) & (RwWait | RwWait)) == 0) - return; - - InterlockedAdd (ref rwlock, -RwRead); -#else - if ((Interlocked.Add (ref rwlock, RwRead) & (RwWait | RwWait)) == 0) - return; - - Interlocked.Add (ref rwlock, -RwRead); -#endif - } while (true); - } - - public void ExitReadLock () - { -#if COMPACT - InterlockedAdd (ref rwlock, -RwRead); -#else - Interlocked.Add (ref rwlock, -RwRead); -#endif - } - - public void EnterWriteLock () - { - SpinWait sw = new SpinWait (); - do { - int state = rwlock; - if (state < RwWrite) { - if (Interlocked.CompareExchange (ref rwlock, RwWrite, state) == state) - return; - state = rwlock; - } - // We register our interest in taking the Write lock (if upgradeable it's already done) - while ((state & RwWait) == 0 && Interlocked.CompareExchange (ref rwlock, state | RwWait, state) != state) - state = rwlock; - // Before falling to sleep - while (rwlock > RwWait) - sw.SpinOnce (); - } while (true); - } - - public void ExitWriteLock () - { -#if COMPACT - InterlockedAdd (ref rwlock, -RwWrite); -#else - Interlocked.Add (ref rwlock, -RwWrite); -#endif - } - -#if COMPACT - /// - /// Adds two 32-bit integers and replaces the first integer with the sum, as an atomic operation. - /// - /// A variable containing the first value to be added. The sum of the two values is stored in . - /// The value to be added to the integer at . - /// The new value stored at . - private static int InterlockedAdd(ref int location1, int value) - { -#if false // the code calling this private method will never make use of this optimization - if (value == 1) - return Interlocked.Increment(ref location1); - else if (value == -1) - return Interlocked.Decrement(ref location1); -#endif - - while (true) - { - int previous = location1; - if (Interlocked.CompareExchange(ref location1, previous + value, previous) == previous) - return previous + value; - } - } -#endif - } - } - - internal struct SpinWait - { - // The number of step until SpinOnce yield on multicore machine - const int step = 10; - const int maxTime = 200; -#if !COMPACT - static readonly bool isSingleCpu = (Environment.ProcessorCount == 1); -#endif - - int ntime; - - public void SpinOnce () - { - ntime += 1; -#if COMPACT - Thread.Sleep(0); -#else - ManualResetEvent mre = new ManualResetEvent (false); - if (isSingleCpu) { - // On a single-CPU system, spinning does no good - mre.WaitOne (0); - } else { - if (ntime % step == 0) - mre.WaitOne (0); - else - // Multi-CPU system might be hyper-threaded, let other thread run - mre.WaitOne (Math.Min (ntime, maxTime) << 1); - } -#endif - } - } -} - -#endif diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Tuple.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Tuple.cs deleted file mode 100644 index ae7979d40..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Tuple.cs +++ /dev/null @@ -1,115 +0,0 @@ -// -// Tuple.cs -// -// Authors: -// Zoltan Varga (vargaz@gmail.com) -// -// Copyright (C) 2009 Novell -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#if !NET40PLUS - -using System; - -namespace Antlr4.Runtime.Sharpen -{ - internal static class Tuple - { - public static Tuple> Create - ( - T1 item1, - T2 item2, - T3 item3, - T4 item4, - T5 item5, - T6 item6, - T7 item7, - T8 item8) { - return new Tuple> (item1, item2, item3, item4, item5, item6, item7, new Tuple (item8)); - } - - public static Tuple Create - ( - T1 item1, - T2 item2, - T3 item3, - T4 item4, - T5 item5, - T6 item6, - T7 item7) { - return new Tuple (item1, item2, item3, item4, item5, item6, item7); - } - - public static Tuple Create - ( - T1 item1, - T2 item2, - T3 item3, - T4 item4, - T5 item5, - T6 item6) { - return new Tuple (item1, item2, item3, item4, item5, item6); - } - - public static Tuple Create - ( - T1 item1, - T2 item2, - T3 item3, - T4 item4, - T5 item5) { - return new Tuple (item1, item2, item3, item4, item5); - } - - public static Tuple Create - ( - T1 item1, - T2 item2, - T3 item3, - T4 item4) { - return new Tuple (item1, item2, item3, item4); - } - - public static Tuple Create - ( - T1 item1, - T2 item2, - T3 item3) { - return new Tuple (item1, item2, item3); - } - - public static Tuple Create - ( - T1 item1, - T2 item2) { - return new Tuple (item1, item2); - } - - public static Tuple Create - ( - T1 item1) { - return new Tuple (item1); - } - } -} - -#endif diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Tuples.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Tuples.cs deleted file mode 100644 index dda3a9cce..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/Tuples.cs +++ /dev/null @@ -1,995 +0,0 @@ -// -// Tuples.cs -// -// Authors: -// Zoltan Varga (vargaz@gmail.com) -// Marek Safar (marek.safar@gmail.com) -// -// Copyright (C) 2009 Novell -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#if !NET40PLUS - -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Antlr4.Runtime.Sharpen -{ - internal partial class Tuple - { - public Tuple (T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest) - { - this.item1 = item1; - this.item2 = item2; - this.item3 = item3; - this.item4 = item4; - this.item5 = item5; - this.item6 = item6; - this.item7 = item7; - this.rest = rest; - - bool ok = true; - if (!typeof (TRest).IsGenericType) - ok = false; - if (ok) { - Type t = typeof (TRest).GetGenericTypeDefinition (); - if (!(t == typeof (Tuple<>) || t == typeof (Tuple<,>) || t == typeof (Tuple<,,>) || t == typeof (Tuple<,,,>) || t == typeof (Tuple<,,,,>) || t == typeof (Tuple <,,,,,>) || t == typeof (Tuple<,,,,,,>) || t == typeof (Tuple<,,,,,,,>))) - ok = false; - } - if (!ok) - throw new ArgumentException ("rest", "The last element of an eight element tuple must be a Tuple."); - } - } - - /* The rest is generated by the script at the bottom */ - - [Serializable] - internal class Tuple : IStructuralEquatable, IStructuralComparable, IComparable - { - T1 item1; - - public Tuple (T1 item1) - { - this.item1 = item1; - } - - public T1 Item1 { - get { return item1; } - } - - int IComparable.CompareTo (object obj) - { - return ((IStructuralComparable) this).CompareTo (obj, Comparer.Default); - } - - int IStructuralComparable.CompareTo (object other, IComparer comparer) - { - var t = other as Tuple; - if (t == null) { - if (other == null) return 1; - throw new ArgumentException ("other"); - } - - return comparer.Compare (item1, t.item1); - } - - public override bool Equals (object obj) - { - return ((IStructuralEquatable) this).Equals (obj, EqualityComparer.Default); - } - - bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer) - { - var t = other as Tuple; - if (t == null) - return false; - - return comparer.Equals (item1, t.item1); - } - - public override int GetHashCode () - { - return ((IStructuralEquatable) this).GetHashCode (EqualityComparer.Default); - } - - int IStructuralEquatable.GetHashCode (IEqualityComparer comparer) - { - return comparer.GetHashCode (item1); - } - - public override string ToString () - { - return String.Format ("({0})", item1); - } - } - - [Serializable] - public class Tuple : IStructuralEquatable, IStructuralComparable, IComparable - { - T1 item1; - T2 item2; - - public Tuple (T1 item1, T2 item2) - { - this.item1 = item1; - this.item2 = item2; - } - - public T1 Item1 { - get { return item1; } - } - - public T2 Item2 { - get { return item2; } - } - - int IComparable.CompareTo (object obj) - { - return ((IStructuralComparable) this).CompareTo (obj, Comparer.Default); - } - - int IStructuralComparable.CompareTo (object other, IComparer comparer) - { - var t = other as Tuple; - if (t == null) { - if (other == null) return 1; - throw new ArgumentException ("other"); - } - - int res = comparer.Compare (item1, t.item1); - if (res != 0) return res; - return comparer.Compare (item2, t.item2); - } - - public override bool Equals (object obj) - { - return ((IStructuralEquatable) this).Equals (obj, EqualityComparer.Default); - } - - bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer) - { - var t = other as Tuple; - if (t == null) - return false; - - return comparer.Equals (item1, t.item1) && - comparer.Equals (item2, t.item2); - } - - public override int GetHashCode () - { - return ((IStructuralEquatable) this).GetHashCode (EqualityComparer.Default); - } - - int IStructuralEquatable.GetHashCode (IEqualityComparer comparer) - { - int h = comparer.GetHashCode (item1); - h = (h << 5) - h + comparer.GetHashCode (item2); - return h; - } - - public override string ToString () - { - return String.Format ("({0}, {1})", item1, item2); - } - } - - [Serializable] - internal class Tuple : IStructuralEquatable, IStructuralComparable, IComparable - { - T1 item1; - T2 item2; - T3 item3; - - public Tuple (T1 item1, T2 item2, T3 item3) - { - this.item1 = item1; - this.item2 = item2; - this.item3 = item3; - } - - public T1 Item1 { - get { return item1; } - } - - public T2 Item2 { - get { return item2; } - } - - public T3 Item3 { - get { return item3; } - } - - int IComparable.CompareTo (object obj) - { - return ((IStructuralComparable) this).CompareTo (obj, Comparer.Default); - } - - int IStructuralComparable.CompareTo (object other, IComparer comparer) - { - var t = other as Tuple; - if (t == null) { - if (other == null) return 1; - throw new ArgumentException ("other"); - } - - int res = comparer.Compare (item1, t.item1); - if (res != 0) return res; - res = comparer.Compare (item2, t.item2); - if (res != 0) return res; - return comparer.Compare (item3, t.item3); - } - - public override bool Equals (object obj) - { - return ((IStructuralEquatable) this).Equals (obj, EqualityComparer.Default); - } - - bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer) - { - var t = other as Tuple; - if (t == null) - return false; - - return comparer.Equals (item1, t.item1) && - comparer.Equals (item2, t.item2) && - comparer.Equals (item3, t.item3); - } - - public override int GetHashCode () - { - return ((IStructuralEquatable) this).GetHashCode (EqualityComparer.Default); - } - - int IStructuralEquatable.GetHashCode (IEqualityComparer comparer) - { - int h = comparer.GetHashCode (item1); - h = (h << 5) - h + comparer.GetHashCode (item2); - h = (h << 5) - h + comparer.GetHashCode (item3); - return h; - } - - public override string ToString () - { - return String.Format ("({0}, {1}, {2})", item1, item2, item3); - } - } - - [Serializable] - internal class Tuple : IStructuralEquatable, IStructuralComparable, IComparable - { - T1 item1; - T2 item2; - T3 item3; - T4 item4; - - public Tuple (T1 item1, T2 item2, T3 item3, T4 item4) - { - this.item1 = item1; - this.item2 = item2; - this.item3 = item3; - this.item4 = item4; - } - - public T1 Item1 { - get { return item1; } - } - - public T2 Item2 { - get { return item2; } - } - - public T3 Item3 { - get { return item3; } - } - - public T4 Item4 { - get { return item4; } - } - - int IComparable.CompareTo (object obj) - { - return ((IStructuralComparable) this).CompareTo (obj, Comparer.Default); - } - - int IStructuralComparable.CompareTo (object other, IComparer comparer) - { - var t = other as Tuple; - if (t == null) { - if (other == null) return 1; - throw new ArgumentException ("other"); - } - - int res = comparer.Compare (item1, t.item1); - if (res != 0) return res; - res = comparer.Compare (item2, t.item2); - if (res != 0) return res; - res = comparer.Compare (item3, t.item3); - if (res != 0) return res; - return comparer.Compare (item4, t.item4); - } - - public override bool Equals (object obj) - { - return ((IStructuralEquatable) this).Equals (obj, EqualityComparer.Default); - } - - bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer) - { - var t = other as Tuple; - if (t == null) - return false; - - return comparer.Equals (item1, t.item1) && - comparer.Equals (item2, t.item2) && - comparer.Equals (item3, t.item3) && - comparer.Equals (item4, t.item4); - } - - public override int GetHashCode () - { - return ((IStructuralEquatable) this).GetHashCode (EqualityComparer.Default); - } - - int IStructuralEquatable.GetHashCode (IEqualityComparer comparer) - { - int h = comparer.GetHashCode (item1); - h = (h << 5) - h + comparer.GetHashCode (item2); - h = (h << 5) - h + comparer.GetHashCode (item3); - h = (h << 5) - h + comparer.GetHashCode (item4); - return h; - } - - public override string ToString () - { - return String.Format ("({0}, {1}, {2}, {3})", item1, item2, item3, item4); - } - } - - [Serializable] - internal class Tuple : IStructuralEquatable, IStructuralComparable, IComparable - { - T1 item1; - T2 item2; - T3 item3; - T4 item4; - T5 item5; - - public Tuple (T1 item1, T2 item2, T3 item3, T4 item4, T5 item5) - { - this.item1 = item1; - this.item2 = item2; - this.item3 = item3; - this.item4 = item4; - this.item5 = item5; - } - - public T1 Item1 { - get { return item1; } - } - - public T2 Item2 { - get { return item2; } - } - - public T3 Item3 { - get { return item3; } - } - - public T4 Item4 { - get { return item4; } - } - - public T5 Item5 { - get { return item5; } - } - - int IComparable.CompareTo (object obj) - { - return ((IStructuralComparable) this).CompareTo (obj, Comparer.Default); - } - - int IStructuralComparable.CompareTo (object other, IComparer comparer) - { - var t = other as Tuple; - if (t == null) { - if (other == null) return 1; - throw new ArgumentException ("other"); - } - - int res = comparer.Compare (item1, t.item1); - if (res != 0) return res; - res = comparer.Compare (item2, t.item2); - if (res != 0) return res; - res = comparer.Compare (item3, t.item3); - if (res != 0) return res; - res = comparer.Compare (item4, t.item4); - if (res != 0) return res; - return comparer.Compare (item5, t.item5); - } - - public override bool Equals (object obj) - { - return ((IStructuralEquatable) this).Equals (obj, EqualityComparer.Default); - } - - bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer) - { - var t = other as Tuple; - if (t == null) - return false; - - return comparer.Equals (item1, t.item1) && - comparer.Equals (item2, t.item2) && - comparer.Equals (item3, t.item3) && - comparer.Equals (item4, t.item4) && - comparer.Equals (item5, t.item5); - } - - public override int GetHashCode () - { - return ((IStructuralEquatable) this).GetHashCode (EqualityComparer.Default); - } - - int IStructuralEquatable.GetHashCode (IEqualityComparer comparer) - { - int h = comparer.GetHashCode (item1); - h = (h << 5) - h + comparer.GetHashCode (item2); - h = (h << 5) - h + comparer.GetHashCode (item3); - h = (h << 5) - h + comparer.GetHashCode (item4); - h = (h << 5) - h + comparer.GetHashCode (item5); - return h; - } - - public override string ToString () - { - return String.Format ("({0}, {1}, {2}, {3}, {4})", item1, item2, item3, item4, item5); - } - } - - [Serializable] - internal class Tuple : IStructuralEquatable, IStructuralComparable, IComparable - { - T1 item1; - T2 item2; - T3 item3; - T4 item4; - T5 item5; - T6 item6; - - public Tuple (T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6) - { - this.item1 = item1; - this.item2 = item2; - this.item3 = item3; - this.item4 = item4; - this.item5 = item5; - this.item6 = item6; - } - - public T1 Item1 { - get { return item1; } - } - - public T2 Item2 { - get { return item2; } - } - - public T3 Item3 { - get { return item3; } - } - - public T4 Item4 { - get { return item4; } - } - - public T5 Item5 { - get { return item5; } - } - - public T6 Item6 { - get { return item6; } - } - - int IComparable.CompareTo (object obj) - { - return ((IStructuralComparable) this).CompareTo (obj, Comparer.Default); - } - - int IStructuralComparable.CompareTo (object other, IComparer comparer) - { - var t = other as Tuple; - if (t == null) { - if (other == null) return 1; - throw new ArgumentException ("other"); - } - - int res = comparer.Compare (item1, t.item1); - if (res != 0) return res; - res = comparer.Compare (item2, t.item2); - if (res != 0) return res; - res = comparer.Compare (item3, t.item3); - if (res != 0) return res; - res = comparer.Compare (item4, t.item4); - if (res != 0) return res; - res = comparer.Compare (item5, t.item5); - if (res != 0) return res; - return comparer.Compare (item6, t.item6); - } - - public override bool Equals (object obj) - { - return ((IStructuralEquatable) this).Equals (obj, EqualityComparer.Default); - } - - bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer) - { - var t = other as Tuple; - if (t == null) - return false; - - return comparer.Equals (item1, t.item1) && - comparer.Equals (item2, t.item2) && - comparer.Equals (item3, t.item3) && - comparer.Equals (item4, t.item4) && - comparer.Equals (item5, t.item5) && - comparer.Equals (item6, t.item6); - } - - public override int GetHashCode () - { - return ((IStructuralEquatable) this).GetHashCode (EqualityComparer.Default); - } - - int IStructuralEquatable.GetHashCode (IEqualityComparer comparer) - { - int h = comparer.GetHashCode (item1); - h = (h << 5) - h + comparer.GetHashCode (item2); - h = (h << 5) - h + comparer.GetHashCode (item3); - h = (h << 5) - h + comparer.GetHashCode (item4); - h = (h << 5) - h + comparer.GetHashCode (item5); - h = (h << 5) - h + comparer.GetHashCode (item6); - return h; - } - - public override string ToString () - { - return String.Format ("({0}, {1}, {2}, {3}, {4}, {5})", item1, item2, item3, item4, item5, item6); - } - } - - [Serializable] - internal class Tuple : IStructuralEquatable, IStructuralComparable, IComparable - { - T1 item1; - T2 item2; - T3 item3; - T4 item4; - T5 item5; - T6 item6; - T7 item7; - - public Tuple (T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7) - { - this.item1 = item1; - this.item2 = item2; - this.item3 = item3; - this.item4 = item4; - this.item5 = item5; - this.item6 = item6; - this.item7 = item7; - } - - public T1 Item1 { - get { return item1; } - } - - public T2 Item2 { - get { return item2; } - } - - public T3 Item3 { - get { return item3; } - } - - public T4 Item4 { - get { return item4; } - } - - public T5 Item5 { - get { return item5; } - } - - public T6 Item6 { - get { return item6; } - } - - public T7 Item7 { - get { return item7; } - } - - int IComparable.CompareTo (object obj) - { - return ((IStructuralComparable) this).CompareTo (obj, Comparer.Default); - } - - int IStructuralComparable.CompareTo (object other, IComparer comparer) - { - var t = other as Tuple; - if (t == null) { - if (other == null) return 1; - throw new ArgumentException ("other"); - } - - int res = comparer.Compare (item1, t.item1); - if (res != 0) return res; - res = comparer.Compare (item2, t.item2); - if (res != 0) return res; - res = comparer.Compare (item3, t.item3); - if (res != 0) return res; - res = comparer.Compare (item4, t.item4); - if (res != 0) return res; - res = comparer.Compare (item5, t.item5); - if (res != 0) return res; - res = comparer.Compare (item6, t.item6); - if (res != 0) return res; - return comparer.Compare (item7, t.item7); - } - - public override bool Equals (object obj) - { - return ((IStructuralEquatable) this).Equals (obj, EqualityComparer.Default); - } - - bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer) - { - var t = other as Tuple; - if (t == null) - return false; - - return comparer.Equals (item1, t.item1) && - comparer.Equals (item2, t.item2) && - comparer.Equals (item3, t.item3) && - comparer.Equals (item4, t.item4) && - comparer.Equals (item5, t.item5) && - comparer.Equals (item6, t.item6) && - comparer.Equals (item7, t.item7); - } - - public override int GetHashCode () - { - return ((IStructuralEquatable) this).GetHashCode (EqualityComparer.Default); - } - - int IStructuralEquatable.GetHashCode (IEqualityComparer comparer) - { - int h = comparer.GetHashCode (item1); - h = (h << 5) - h + comparer.GetHashCode (item2); - h = (h << 5) - h + comparer.GetHashCode (item3); - h = (h << 5) - h + comparer.GetHashCode (item4); - h = (h << 5) - h + comparer.GetHashCode (item5); - h = (h << 5) - h + comparer.GetHashCode (item6); - h = (h << 5) - h + comparer.GetHashCode (item7); - return h; - } - - public override string ToString () - { - return String.Format ("({0}, {1}, {2}, {3}, {4}, {5}, {6})", item1, item2, item3, item4, item5, item6, item7); - } - } - - [Serializable] - internal partial class Tuple : IStructuralEquatable, IStructuralComparable, IComparable - { - T1 item1; - T2 item2; - T3 item3; - T4 item4; - T5 item5; - T6 item6; - T7 item7; - TRest rest; - - public T1 Item1 { - get { return item1; } - } - - public T2 Item2 { - get { return item2; } - } - - public T3 Item3 { - get { return item3; } - } - - public T4 Item4 { - get { return item4; } - } - - public T5 Item5 { - get { return item5; } - } - - public T6 Item6 { - get { return item6; } - } - - public T7 Item7 { - get { return item7; } - } - - public TRest Rest { - get { return rest; } - } - - int IComparable.CompareTo (object obj) - { - return ((IStructuralComparable) this).CompareTo (obj, Comparer.Default); - } - - int IStructuralComparable.CompareTo (object other, IComparer comparer) - { - var t = other as Tuple; - if (t == null) { - if (other == null) return 1; - throw new ArgumentException ("other"); - } - - int res = comparer.Compare (item1, t.item1); - if (res != 0) return res; - res = comparer.Compare (item2, t.item2); - if (res != 0) return res; - res = comparer.Compare (item3, t.item3); - if (res != 0) return res; - res = comparer.Compare (item4, t.item4); - if (res != 0) return res; - res = comparer.Compare (item5, t.item5); - if (res != 0) return res; - res = comparer.Compare (item6, t.item6); - if (res != 0) return res; - res = comparer.Compare (item7, t.item7); - if (res != 0) return res; - return comparer.Compare (rest, t.rest); - } - - public override bool Equals (object obj) - { - return ((IStructuralEquatable) this).Equals (obj, EqualityComparer.Default); - } - - bool IStructuralEquatable.Equals (object other, IEqualityComparer comparer) - { - var t = other as Tuple; - if (t == null) - return false; - - return comparer.Equals (item1, t.item1) && - comparer.Equals (item2, t.item2) && - comparer.Equals (item3, t.item3) && - comparer.Equals (item4, t.item4) && - comparer.Equals (item5, t.item5) && - comparer.Equals (item6, t.item6) && - comparer.Equals (item7, t.item7) && - comparer.Equals (rest, t.rest); - } - - public override int GetHashCode () - { - return ((IStructuralEquatable) this).GetHashCode (EqualityComparer.Default); - } - - int IStructuralEquatable.GetHashCode (IEqualityComparer comparer) - { - int h = comparer.GetHashCode (item1); - h = (h << 5) - h + comparer.GetHashCode (item2); - h = (h << 5) - h + comparer.GetHashCode (item3); - h = (h << 5) - h + comparer.GetHashCode (item4); - h = (h << 5) - h + comparer.GetHashCode (item5); - h = (h << 5) - h + comparer.GetHashCode (item6); - h = (h << 5) - h + comparer.GetHashCode (item7); - h = (h << 5) - h + comparer.GetHashCode (rest); - return h; - } - - public override string ToString () - { - return String.Format ("({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7})", item1, item2, item3, item4, item5, item6, item7, rest); - } - } - -} - -#endif - -#if FALSE - -// -// generator script -// - -using System; -using System.Text; - -public class TupleGen -{ - public static void Main () { - for (int arity = 1; arity < 9; ++arity) { - string type_name = GetTypeName (arity); - - Console.WriteLine ("\t[Serializable]"); - Console.Write ("\tpublic {0}class ", arity < 8 ? null : "partial "); - Console.Write (type_name); - Console.WriteLine (" : IStructuralEquatable, IStructuralComparable, IComparable"); - Console.WriteLine ("\t{"); - for (int i = 1; i <= arity; ++i) - Console.WriteLine ("\t\t{0} {1};", GetItemTypeName (i), GetItemName (i)); - - if (arity < 8) { - Console.WriteLine (); - Console.Write ("\t\tpublic Tuple ("); - for (int i = 1; i <= arity; ++i) { - Console.Write ("{0} {1}", GetItemTypeName (i), GetItemName (i)); - if (i < arity) - Console.Write (", "); - } - Console.WriteLine (")"); - Console.WriteLine ("\t\t{"); - for (int i = 1; i <= arity; ++i) - Console.WriteLine ("\t\t\t this.{0} = {0};", GetItemName (i)); - Console.WriteLine ("\t\t}"); - } - - for (int i = 1; i <= arity; ++i) { - Console.WriteLine (); - Console.WriteLine ("\t\tpublic {0} {1} {{", GetItemTypeName (i), - System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase (GetItemName (i))); - Console.Write ("\t\t\tget { "); - Console.WriteLine ("return {0}; }}", GetItemName (i)); - Console.WriteLine ("\t\t}"); - } - - Console.WriteLine (); - Console.WriteLine ("\t\tint IComparable.CompareTo (object obj)"); - Console.WriteLine ("\t\t{"); - Console.WriteLine ("\t\t\treturn ((IStructuralComparable) this).CompareTo (obj, Comparer.Default);"); - Console.WriteLine ("\t\t}"); - - Console.WriteLine (); - Console.WriteLine ("\t\tint IStructuralComparable.CompareTo (object other, IComparer comparer)"); - Console.WriteLine ("\t\t{"); - Console.WriteLine ("\t\t\tvar t = other as {0};", type_name); - Console.WriteLine ("\t\t\tif (t == null) {"); - Console.WriteLine ("\t\t\t\tif (other == null) return 1;"); - Console.WriteLine ("\t\t\t\tthrow new ArgumentException ("other");"); - Console.WriteLine ("\t\t\t}"); - Console.WriteLine (); - - for (int i = 1; i < arity; ++i) { - Console.Write ("\t\t\t"); - if (i == 1) - Console.Write ("int "); - - Console.WriteLine ("res = comparer.Compare ({0}, t.{0});", GetItemName (i)); - Console.WriteLine ("\t\t\tif (res != 0) return res;"); - } - Console.WriteLine ("\t\t\treturn comparer.Compare ({0}, t.{0});", GetItemName (arity)); - Console.WriteLine ("\t\t}"); - - Console.WriteLine (); - Console.WriteLine ("\t\tpublic override bool Equals (object obj)"); - Console.WriteLine ("\t\t{"); - Console.WriteLine ("\t\t\treturn ((IStructuralEquatable) this).Equals (obj, EqualityComparer.Default);"); - Console.WriteLine ("\t\t}"); - - Console.WriteLine (); - Console.WriteLine ("\t\tbool IStructuralEquatable.Equals (object other, IEqualityComparer comparer)"); - Console.WriteLine ("\t\t{"); - Console.WriteLine ("\t\t\tvar t = other as {0};", type_name); - Console.WriteLine ("\t\t\tif (t == null)"); - Console.WriteLine ("\t\t\t\treturn false;"); - Console.WriteLine (); - Console.Write ("\t\t\treturn"); - - for (int i = 1; i <= arity; ++i) { - if (i == 1) - Console.Write (" "); - else - Console.Write ("\t\t\t\t"); - - Console.Write ("comparer.Equals ({0}, t.{0})", GetItemName (i)); - if (i != arity) - Console.WriteLine (" &&"); - else - Console.WriteLine (";"); - } - Console.WriteLine ("\t\t}"); - - Console.WriteLine (); - Console.WriteLine ("\t\tpublic override int GetHashCode ()"); - Console.WriteLine ("\t\t{"); - Console.WriteLine ("\t\t\treturn ((IStructuralEquatable) this).GetHashCode (EqualityComparer.Default);"); - Console.WriteLine ("\t\t}"); - - Console.WriteLine (); - Console.WriteLine ("\t\tint IStructuralEquatable.GetHashCode (IEqualityComparer comparer)"); - Console.WriteLine ("\t\t{"); - if (arity == 1) { - Console.WriteLine ("\t\t\treturn comparer.GetHashCode ({0});", GetItemName (arity)); - } else { - Console.WriteLine ("\t\t\tint h = comparer.GetHashCode ({0});", GetItemName (1)); - for (int i = 2; i <= arity; ++i) - Console.WriteLine ("\t\t\th = (h << 5) - h + comparer.GetHashCode ({0});", GetItemName (i)); - Console.WriteLine ("\t\t\treturn h;"); - } - - Console.WriteLine ("\t\t}"); - - Console.WriteLine (); - Console.WriteLine ("\t\tpublic override string ToString ()"); - Console.WriteLine ("\t\t{"); - Console.Write ("\t\t\treturn String.Format (\"("); - for (int i = 1; i <= arity; ++i) { - Console.Write ("{" + (i - 1) + "}"); - if (i < arity) - Console.Write (", "); - } - Console.Write (")\", "); - for (int i = 1; i <= arity; ++i) { - Console.Write (GetItemName (i)); - if (i < arity) - Console.Write (", "); - } - Console.WriteLine (");"); - Console.WriteLine ("\t\t}"); - - Console.WriteLine ("\t}\n"); - } - } - - static string GetTypeName (int arity) - { - StringBuilder sb = new StringBuilder (); - sb.Append ("Tuple<"); - for (int i = 1; i <= arity; ++i) { - sb.Append (GetItemTypeName (i)); - if (i < arity) - sb.Append (", "); - } - sb.Append (">"); - - return sb.ToString (); - } - - static string GetItemName (int arity) - { - return arity < 8 ? "item" + arity.ToString () : "rest"; - } - - static string GetItemTypeName (int arity) - { - return arity < 8 ? "T" + arity.ToString () : "TRest"; - } -} - -#endif From 30d2b87f6371a0aa978ce6a721b549927f821b10 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 2 Dec 2020 21:00:32 +0300 Subject: [PATCH 24/36] Move SerializableAttribute from Compact to Sharpen folder --- .../Antlr4.Runtime/Sharpen/{Compat => }/SerializableAttribute.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/{Compat => }/SerializableAttribute.cs (100%) diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/SerializableAttribute.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Compat/SerializableAttribute.cs rename to runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/SerializableAttribute.cs From ab7265958b9e9a055d6995edfde3ae129dff7ef8 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 2 Dec 2020 21:11:15 +0300 Subject: [PATCH 25/36] Rename Antlr4.dotnet.sln ->Antlr4.sln, Antlr4.Runtime.dotnet.csproj -> Antlr4.Runtime.csproj --- appveyor.yml | 4 +-- ...me.dotnet.csproj => Antlr4.Runtime.csproj} | 0 .../CSharp/runtime/CSharp/Antlr4.dotnet.sln | 34 ------------------- runtime/CSharp/runtime/CSharp/Antlr4.sln | 34 +++++++++++++++++++ 4 files changed, 36 insertions(+), 36 deletions(-) rename runtime/CSharp/runtime/CSharp/Antlr4.Runtime/{Antlr4.Runtime.dotnet.csproj => Antlr4.Runtime.csproj} (100%) delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln create mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.sln diff --git a/appveyor.yml b/appveyor.yml index 0b74b024f..d457fc757 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,9 +11,9 @@ install: - cinst -y dart-sdk --version=2.8.4 build_script: - mvn -DskipTests install --batch-mode - - msbuild /target:restore /target:rebuild /property:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln + - msbuild /target:restore /target:rebuild /property:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.sln after_build: - - msbuild /target:pack /property:Configuration=Release /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln + - msbuild /target:pack /property:Configuration=Release /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.sln test_script: - mvn install -Dantlr-php-php="C:\tools\php\php.exe" -Dantlr-dart-dart="C:\tools\dart-sdk\bin\dart.exe" -Dantlr-dart-pub="C:\tools\dart-sdk\bin\pub.bat" -Dantlr-dart-dart2native="C:\tools\dart-sdk\bin\dart2native.bat" -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" --batch-mode artifacts: diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj rename to runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln b/runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln deleted file mode 100644 index 27dc0c4a8..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln +++ /dev/null @@ -1,34 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26114.2 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime.dotnet", "Antlr4.Runtime\Antlr4.Runtime.dotnet.csproj", "{0F9F8436-A767-4407-8E81-F9C6270E2B5A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Debug|x64.ActiveCfg = Debug|x64 - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Debug|x64.Build.0 = Debug|x64 - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Debug|x86.ActiveCfg = Debug|x86 - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Debug|x86.Build.0 = Debug|x86 - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Release|Any CPU.Build.0 = Release|Any CPU - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Release|x64.ActiveCfg = Release|x64 - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Release|x64.Build.0 = Release|x64 - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Release|x86.ActiveCfg = Release|x86 - {0F9F8436-A767-4407-8E81-F9C6270E2B5A}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.sln b/runtime/CSharp/runtime/CSharp/Antlr4.sln new file mode 100644 index 000000000..1f63a3fa4 --- /dev/null +++ b/runtime/CSharp/runtime/CSharp/Antlr4.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26114.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime", "Antlr4.Runtime\Antlr4.Runtime.csproj", "{A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|Any CPU.Build.0 = Release|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|x64.ActiveCfg = Debug|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|x64.Build.0 = Debug|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|x86.ActiveCfg = Debug|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|x86.Build.0 = Debug|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|x64.ActiveCfg = Release|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|x64.Build.0 = Release|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|x86.ActiveCfg = Release|Any CPU + {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From b09a185890fd859216ffd7686afb99a644933baf Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 2 Dec 2020 21:11:56 +0300 Subject: [PATCH 26/36] Update README.md --- runtime/CSharp/README.md | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/runtime/CSharp/README.md b/runtime/CSharp/README.md index 5667a2709..c0eaf7a8c 100644 --- a/runtime/CSharp/README.md +++ b/runtime/CSharp/README.md @@ -2,15 +2,13 @@ ### Note to historical users -Versions of ANTLR 4.4.x and before managed the C# -target as part of a [separate tool provided by Sam Harwell](https://github.com/tunnelvisionlabs/antlr4cs/releases/tag/v4.3.0). +Versions of ANTLR 4.4.x and before managed the C# +target as part of a [separate tool provided by Sam Harwell](https://github.com/tunnelvisionlabs/antlr4cs/releases/tag/v4.6.6). As of 4.5, we our releasing a (mono-compatible) C# target together with the main tool. -Mono compatibility makes it possible to use ANTLR 4 in any C# development -environment, including of course Microsoft Visual Studio, but also Xamarin Studio, which runs on MacOS X. -Given Microsoft's recent commitment to *cross-platform developer experiences*, -we believe this is a great opportunity for C# developers. +The current version is written using netstandard2.0 and netstandard2.1, it's possible +to use it on different platforms (Windows, MacOS X, Linux, and other). Releasing the runtime with the tool ensures that you can get the exact same behavior across many languages: Java, C#, Python, JavaScript, Go, Swift and C++. @@ -59,22 +57,21 @@ Use the GUI or the following command in the Package Manager Console: Install-Package Antlr4.Runtime.Standard ``` - ### Step 6: You're done! Of course, the generated code is not going to meet your requirement by magic. There are 3 ways to use the generated code: - by generating a parse tree, and traversing it using a listener. This is the most common method. - - by generating a parse tree, and traversing it using a visitor. This requires the -visitor option, and is a bit more work. - - by providing code within your grammar, which gets executed when your input files are parsed. + - by generating a parse tree, and traversing it using a visitor. This requires the `-visitor` option, and is a bit more work. + - by providing code within your grammar, which gets executed when your input files are parsed. While the latter works, it is no longer the recommended approach, because it is not portable, and harder to maintain. More importantly, it breaks the parsing when your code breaks. See the web site for examples of using the generated code. - + To learn more about ANTLR 4, read [the book](http://a.co/2n4rJlb). - + ### Visual Studio integration -If you require tighter Visual Studio integration, you can use the tools from [Tunnel Vision Labs](http://tunnelvisionlabs.com/). +If you require tighter Visual Studio integration, you can use the tools from [Tunnel Vision Labs](http://tunnelvisionlabs.com/). (please note however that they use a different tool and runtime) From d3026a2e43f7a7594c787945779c2e918930704a Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 2 Dec 2020 21:27:17 +0300 Subject: [PATCH 27/36] Update Visual Studio 2017 -> 2019 in appveyor.yml to support building under netstandard2.1 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d457fc757..cb134c487 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ version: '4.9.1-SNAPSHOT+AppVeyor.{build}' cache: - '%USERPROFILE%\.m2' - '%USERPROFILE%\.nuget\packages -> **\project.json' -image: Visual Studio 2017 +image: Visual Studio 2019 build: off install: - git submodule update --init --recursive From cc58bce43cf4f519b62296a3e8f00e05b10e879e Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sat, 26 Dec 2020 21:32:30 +0300 Subject: [PATCH 28/36] Remove not used .ps1 files from build directory --- build/Antlr4.Runtime.nuspec | 64 ----------------- build/Antlr4.VS2008.nuspec | 35 --------- build/Antlr4.nuspec | 35 --------- build/build.ps1 | 139 ------------------------------------ build/check-key.ps1 | 31 -------- build/keys.ps1 | 17 ----- build/push.ps1 | 29 -------- build/version.ps1 | 1 - 8 files changed, 351 deletions(-) delete mode 100644 build/Antlr4.Runtime.nuspec delete mode 100644 build/Antlr4.VS2008.nuspec delete mode 100644 build/Antlr4.nuspec delete mode 100644 build/build.ps1 delete mode 100644 build/check-key.ps1 delete mode 100644 build/keys.ps1 delete mode 100644 build/push.ps1 delete mode 100644 build/version.ps1 diff --git a/build/Antlr4.Runtime.nuspec b/build/Antlr4.Runtime.nuspec deleted file mode 100644 index f629ba1fe..000000000 --- a/build/Antlr4.Runtime.nuspec +++ /dev/null @@ -1,64 +0,0 @@ - - - - Antlr4.Runtime - 0.0.0 - Sam Harwell, Terence Parr - Sam Harwell - The runtime library for parsers generated by the C# target of ANTLR 4. This package supports projects targeting .NET 2.0 or newer, and built using Visual Studio 2008 or newer. - en-us - https://github.com/sharwell/antlr4cs - https://raw.github.com/sharwell/antlr4cs/master/LICENSE.txt - https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png - Copyright © Sam Harwell 2014 - https://github.com/sharwell/antlr4cs/releases/v$version$ - true - antlr antlr4 parsing - ANTLR 4 Runtime - The runtime library for parsers generated by the C# target of ANTLR 4. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/Antlr4.VS2008.nuspec b/build/Antlr4.VS2008.nuspec deleted file mode 100644 index 36ffe7ec9..000000000 --- a/build/Antlr4.VS2008.nuspec +++ /dev/null @@ -1,35 +0,0 @@ - - - - Antlr4.VS2008 - 0.0.0 - Sam Harwell, Terence Parr - Sam Harwell - The C# target of the ANTLR 4 parser generator for Visual Studio 2008 projects. This package supports projects targeting .NET 2.0 or newer, and built using Visual Studio 2008. - en-us - https://github.com/sharwell/antlr4cs - https://raw.github.com/sharwell/antlr4cs/master/LICENSE.txt - https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png - Copyright © Sam Harwell 2014 - https://github.com/sharwell/antlr4cs/releases/v$version$ - true - true - antlr antlr4 parsing - ANTLR 4 (Visual Studio 2008) - The C# target of the ANTLR 4 parser generator for Visual Studio 2008 projects. - - - - - - - - - - - - - - - - diff --git a/build/Antlr4.nuspec b/build/Antlr4.nuspec deleted file mode 100644 index 9dc4e4754..000000000 --- a/build/Antlr4.nuspec +++ /dev/null @@ -1,35 +0,0 @@ - - - - Antlr4 - 0.0.0 - Sam Harwell, Terence Parr - Sam Harwell - The C# target of the ANTLR 4 parser generator for Visual Studio 2010+ projects. This package supports projects targeting .NET 2.0 or newer, and built using Visual Studio 2010 or newer. - en-us - https://github.com/sharwell/antlr4cs - https://raw.github.com/sharwell/antlr4cs/master/LICENSE.txt - https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png - Copyright © Sam Harwell 2014 - https://github.com/sharwell/antlr4cs/releases/v$version$ - true - true - antlr antlr4 parsing - ANTLR 4 - The C# target of the ANTLR 4 parser generator for Visual Studio 2010+ projects. - - - - - - - - - - - - - - - - diff --git a/build/build.ps1 b/build/build.ps1 deleted file mode 100644 index 5dcc5e607..000000000 --- a/build/build.ps1 +++ /dev/null @@ -1,139 +0,0 @@ -param ( - [switch]$Debug, - [string]$VisualStudioVersion = "12.0", - [switch]$NoClean, - [string]$Java6Home, - [string]$MavenHome, - [string]$MavenRepo = "$($env:USERPROFILE)\.m2", - [switch]$SkipMaven, - [switch]$SkipKeyCheck -) - -# build the solutions -$SolutionPath = "..\Runtime\CSharp\Antlr4.sln" -$CF35SolutionPath = "..\Runtime\CSharp\Antlr4.VS2008.sln" - -# make sure the script was run from the expected path -if (!(Test-Path $SolutionPath)) { - echo "The script was run from an invalid working directory." - exit 1 -} - -. .\version.ps1 - -If ($Debug) { - $BuildConfig = 'Debug' -} Else { - $BuildConfig = 'Release' -} - -If ($NoClean) { - $Target = 'build' -} Else { - $Target = 'rebuild' -} - -If (-not $MavenHome) { - $MavenHome = $env:M2_HOME -} - -$Java6RegKey = 'HKLM:\SOFTWARE\JavaSoft\Java Runtime Environment\1.6' -$Java6RegValue = 'JavaHome' -If (-not $Java6Home -and (Test-Path $Java6RegKey)) { - $JavaHomeKey = Get-Item -LiteralPath $Java6RegKey - If ($JavaHomeKey.GetValue($Java6RegValue, $null) -ne $null) { - $JavaHomeProperty = Get-ItemProperty $Java6RegKey $Java6RegValue - $Java6Home = $JavaHomeProperty.$Java6RegValue - } -} - -# this is configured here for path checking, but also in the .props and .targets files -[xml]$pom = Get-Content "..\tool\pom.xml" -$CSharpToolVersionNodeInfo = Select-Xml "/mvn:project/mvn:version" -Namespace @{mvn='http://maven.apache.org/POM/4.0.0'} $pom -$CSharpToolVersion = $CSharpToolVersionNodeInfo.Node.InnerText.trim() - -# build the main project -$msbuild = "$env:windir\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe" - -&$msbuild '/nologo' '/m' '/nr:false' "/t:$Target" "/p:Configuration=$BuildConfig" "/p:VisualStudioVersion=$VisualStudioVersion" $SolutionPath -if ($LASTEXITCODE -ne 0) { - $host.ui.WriteErrorLine('Build failed, aborting!') - exit $p.ExitCode -} - -# build the compact framework project -$msbuild = "$env:windir\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" - -&$msbuild '/nologo' '/m' '/nr:false' '/t:rebuild' "/p:Configuration=$BuildConfig" $CF35SolutionPath -if ($LASTEXITCODE -ne 0) { - $host.ui.WriteErrorLine('.NET 3.5 Compact Framework Build failed, aborting!') - exit $p.ExitCode -} - -if (-not (Test-Path 'nuget')) { - mkdir "nuget" -} - -# Build the Java library using Maven -If (-not $SkipMaven) { - $OriginalPath = $PWD - - cd '..\tool' - $MavenPath = "$MavenHome\bin\mvn.bat" - If (-not (Test-Path $MavenPath)) { - $host.ui.WriteErrorLine("Couldn't locate Maven binary: $MavenPath") - cd $OriginalPath - exit 1 - } - - If (-not (Test-Path $Java6Home)) { - $host.ui.WriteErrorLine("Couldn't locate Java 6 installation: $Java6Home") - cd $OriginalPath - exit 1 - } - - $MavenGoal = 'package' - &$MavenPath '-DskipTests=true' '--errors' '-e' '-Dgpg.useagent=true' "-Djava6.home=$Java6Home" '-Psonatype-oss-release' $MavenGoal - if ($LASTEXITCODE -ne 0) { - $host.ui.WriteErrorLine('Maven build of the C# Target custom Tool failed, aborting!') - cd $OriginalPath - exit $p.ExitCode - } - - cd $OriginalPath -} - -$JarPath = "..\tool\target\antlr4-csharp-$CSharpToolVersion-complete.jar" -if (!(Test-Path $JarPath)) { - $host.ui.WriteErrorLine("Couldn't locate the complete jar used for building C# parsers: $JarPath") - exit 1 -} - -# By default, do not create a NuGet package unless the expected strong name key files were used -if (-not $SkipKeyCheck) { - . .\keys.ps1 - - foreach ($pair in $Keys.GetEnumerator()) { - $assembly = Resolve-FullPath -Path "..\runtime\CSharp\Antlr4.Runtime\bin\$($pair.Key)\$BuildConfig\Antlr4.Runtime.dll" - # Run the actual check in a separate process or the current process will keep the assembly file locked - powershell -Command ".\check-key.ps1 -Assembly '$assembly' -ExpectedKey '$($pair.Value)' -Build '$($pair.Key)'" - if ($LASTEXITCODE -ne 0) { - Exit $p.ExitCode - } - } -} - -$packages = @( - 'Antlr4.Runtime' - 'Antlr4' - 'Antlr4.VS2008') - -$nuget = '..\runtime\CSharp\.nuget\NuGet.exe' -ForEach ($package in $packages) { - If (-not (Test-Path ".\$package.nuspec")) { - $host.ui.WriteErrorLine("Couldn't locate NuGet package specification: $package") - exit 1 - } - - &$nuget 'pack' ".\$package.nuspec" '-OutputDirectory' 'nuget' '-Prop' "Configuration=$BuildConfig" '-Version' "$AntlrVersion" '-Prop' "M2_REPO=$M2_REPO" '-Prop' "CSharpToolVersion=$CSharpToolVersion" '-Symbols' -} diff --git a/build/check-key.ps1 b/build/check-key.ps1 deleted file mode 100644 index b92a9cdcc..000000000 --- a/build/check-key.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -param( - [string]$Assembly, - [string]$ExpectedKey, - [string]$Build = $null -) - -function Get-PublicKeyToken() { - param([string]$assembly = $null) - if ($assembly) { - $bytes = $null - $bytes = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom($assembly).GetName().GetPublicKeyToken() - if ($bytes) { - $key = "" - for ($i=0; $i -lt $bytes.Length; $i++) { - $key += "{0:x2}" -f $bytes[$i] - } - - $key - } - } -} - -if (-not $Build) { - $Build = $Assembly -} - -$actual = Get-PublicKeyToken -assembly $Assembly -if ($actual -ne $ExpectedKey) { - $host.ui.WriteErrorLine("Invalid publicKeyToken for '$Build'; expected '$ExpectedKey' but found '$actual'") - exit 1 -} diff --git a/build/keys.ps1 b/build/keys.ps1 deleted file mode 100644 index 4e2f34250..000000000 --- a/build/keys.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -# Note: these values may only change during minor release -$Keys = @{ - 'net20' = '7983ae52036899ac' - 'net30' = '7671200403f6656a' - 'net35-cf' = '770a97458f51159e' - 'net35-client' = '4307381ae04f9aa7' - 'net40-client' = 'bb1075973a9370c4' - 'net45' = 'edc21c04cf562012' - 'netcore45' = 'e4e9019902d0b6e2' - 'portable-net40' = '90bf14da8e1462b4' - 'portable-net45' = '3d23c8e77559f391' -} - -function Resolve-FullPath() { - param([string]$Path) - [System.IO.Path]::GetFullPath((Join-Path (pwd) $Path)) -} diff --git a/build/push.ps1 b/build/push.ps1 deleted file mode 100644 index 17791c1cd..000000000 --- a/build/push.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -. .\version.ps1 - -If ($AntlrVersion.EndsWith('-dev')) { - $host.ui.WriteErrorLine("Cannot push development version '$AntlrVersion' to NuGet.") - Exit 1 -} - -$packages = @( - 'Antlr4.Runtime' - 'Antlr4' - 'Antlr4.VS2008') - -# Make sure all packages exist before pushing any packages -ForEach ($package in $packages) { - If (-not (Test-Path ".\nuget\$package.$AntlrVersion.nupkg")) { - $host.ui.WriteErrorLine("Couldn't locate NuGet package: $JarPath") - exit 1 - } - - If (-not (Test-Path ".\nuget\$package.$AntlrVersion.symbols.nupkg")) { - $host.ui.WriteErrorLine("Couldn't locate NuGet symbols package: $JarPath") - exit 1 - } -} - -$nuget = '..\runtime\CSharp\.nuget\NuGet.exe' -ForEach ($package in $packages) { - &$nuget 'push' ".\nuget\$package.$AntlrVersion.nupkg" -} diff --git a/build/version.ps1 b/build/version.ps1 deleted file mode 100644 index 457481bd8..000000000 --- a/build/version.ps1 +++ /dev/null @@ -1 +0,0 @@ -$AntlrVersion = "4.5.1" From 626192dd9b2bfb9a2c883c6ce47c935071e903e6 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sat, 26 Dec 2020 21:37:39 +0300 Subject: [PATCH 29/36] Fix dotnet tests: use dotnet on all platforms, remove useless files --- .../v4/test/runtime/BaseRuntimeTest.java | 4 +- ....Test.dotnet.csproj => Antlr4.Test.csproj} | 6 +- .../runtime/csharp/Antlr4.Test.mono.csproj | 51 -- .../runtime/csharp/Antlr4.Test.vs2013.csproj | 44 - .../antlr/v4/test/runtime/csharp/App.config | 7 - .../v4/test/runtime/csharp/AssemblyInfo.cs | 28 - .../test/runtime/csharp/BaseCSharpTest.java | 778 ++++++------------ 7 files changed, 254 insertions(+), 664 deletions(-) rename runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/{Antlr4.Test.dotnet.csproj => Antlr4.Test.csproj} (75%) delete mode 100644 runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.mono.csproj delete mode 100644 runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.vs2013.csproj delete mode 100644 runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/App.config delete mode 100644 runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/AssemblyInfo.cs diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTest.java index 501688388..ebed54349 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseRuntimeTest.java @@ -119,12 +119,12 @@ public abstract class BaseRuntimeTest { @Test public void testOne() throws Exception { // System.out.println(delegate.getTmpDir()); - if ( descriptor.ignore(descriptor.getTarget()) ) { + if (descriptor.ignore(descriptor.getTarget()) ) { System.out.println("Ignore " + descriptor); return; } - if ( descriptor.getTestType().contains("Parser") ) { + if (descriptor.getTestType().contains("Parser") ) { testParser(descriptor); } else { diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.dotnet.csproj b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.csproj similarity index 75% rename from runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.dotnet.csproj rename to runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.csproj index 42a540de5..3611a9857 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.dotnet.csproj +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.csproj @@ -1,13 +1,11 @@  - netcoreapp1.0 + netcoreapp2.0 $(NoWarn);CS3021 Test Exe - Antlr4.Test.dotnet - 1.1.1 - $(PackageTargetFallback);dnxcore50 + Antlr4.Test false false false diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.mono.csproj b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.mono.csproj deleted file mode 100644 index eb4870943..000000000 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.mono.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - - Debug - AnyCPU - {EDC70A11-C4C1-4209-93A6-CCE2B19E8E95} - Exe - Antlr4.Test.mono - Test - Test - v3.5 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - true - - - true - bin\Release - prompt - 4 - true - - - - - - - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF} - Antlr4.Runtime.mono - - - - - - - - - - - Test.exe.config - Always - - - diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.vs2013.csproj b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.vs2013.csproj deleted file mode 100644 index bab5315d5..000000000 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.vs2013.csproj +++ /dev/null @@ -1,44 +0,0 @@ - - - Debug - AnyCPU - {EDC70A11-C4C1-4209-93A6-CCE2B19E8E95} - Exe - Antlr4.Test.mono - Test - Test - v3.5 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - true - - - true - bin\Release - prompt - 4 - true - - - - - - - - - - - - - {E1A46D9D-66CB-46E8-93B0-7FC87299ABEF} - Antlr4.Runtime.vs2013 - - - diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/App.config b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/App.config deleted file mode 100644 index 43157903b..000000000 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/App.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/AssemblyInfo.cs b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/AssemblyInfo.cs deleted file mode 100644 index f67408625..000000000 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/AssemblyInfo.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle ("Antlr4.Test.mono")] -[assembly: AssemblyDescription ("")] -[assembly: AssemblyConfiguration ("")] -[assembly: AssemblyCompany ("")] -[assembly: AssemblyProduct ("")] -[assembly: AssemblyCopyright ("ericvergnaud")] -[assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("")] -[assembly: CLSCompliant (true)] -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion ("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java index 9ad30452b..68f779291 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java @@ -58,13 +58,6 @@ import static org.junit.Assert.assertTrue; public class BaseCSharpTest implements RuntimeTestSupport { public static final String newline = System.getProperty("line.separator"); - public static final String pathSep = System.getProperty("path.separator"); - - /** - * When {@code true}, on Linux will call dotnet cli toolchain, otherwise - * will continue to use mono - */ - public static final boolean NETSTANDARD = Boolean.parseBoolean(System.getProperty("antlr-csharp-netstandard")); /** * When the {@code antlr.preserve-test-dir} runtime property is set to @@ -120,22 +113,24 @@ public class BaseCSharpTest implements RuntimeTestSupport { public String tmpdir = null; - /** If error during parser execution, store stderr here; can't return - * stdout and stderr. This doesn't trap errors from running antlr. + /** + * If error during parser execution, store stderr here; can't return + * stdout and stderr. This doesn't trap errors from running antlr. */ protected String stderrDuringParse; - /** Errors found while running antlr */ + /** + * Errors found while running antlr + */ protected StringBuilder antlrToolErrors; @Override public void testSetUp() throws Exception { if (CREATE_PER_TEST_DIRECTORIES) { // new output dir for each test - String testDirectory = getClass().getSimpleName() + "-"+Thread.currentThread().getName()+ "-" + System.currentTimeMillis(); + String testDirectory = getClass().getSimpleName() + "-" + Thread.currentThread().getName() + "-" + System.currentTimeMillis(); tmpdir = new File(BASE_TEST_DIR, testDirectory).getAbsolutePath(); - } - else { + } else { tmpdir = new File(BASE_TEST_DIR).getAbsolutePath(); if (!PRESERVE_TEST_DIR && new File(tmpdir).exists()) { eraseDirectory(new File(tmpdir)); @@ -165,7 +160,7 @@ public class BaseCSharpTest implements RuntimeTestSupport { @Override public String getANTLRToolErrors() { - if ( antlrToolErrors.length()==0 ) { + if (antlrToolErrors.length() == 0) { return null; } return antlrToolErrors.toString(); @@ -177,14 +172,13 @@ public class BaseCSharpTest implements RuntimeTestSupport { } protected Tool newTool() { - org.antlr.v4.Tool tool = new Tool(new String[] {"-o", tmpdir}); + org.antlr.v4.Tool tool = new Tool(new String[]{"-o", tmpdir}); return tool; } protected String load(String fileName, String encoding) - throws IOException - { - if ( fileName==null ) { + throws IOException { + if (fileName == null) { return null; } @@ -192,51 +186,47 @@ public class BaseCSharpTest implements RuntimeTestSupport { int size = 65000; InputStreamReader isr; InputStream fis = getClass().getClassLoader().getResourceAsStream(fullFileName); - if ( encoding!=null ) { + if (encoding != null) { isr = new InputStreamReader(fis, encoding); - } - else { + } else { isr = new InputStreamReader(fis); } try { char[] data = new char[size]; int n = isr.read(data); return new String(data, 0, n); - } - finally { + } finally { isr.close(); } } protected String execLexer(String grammarFileName, - String grammarStr, - String lexerName, - String input) - { + String grammarStr, + String lexerName, + String input) { return execLexer(grammarFileName, grammarStr, lexerName, input, false); } @Override public String execLexer(String grammarFileName, - String grammarStr, - String lexerName, - String input, - boolean showDFA) - { + String grammarStr, + String lexerName, + String input, + boolean showDFA) { boolean success = rawGenerateRecognizer(grammarFileName, - grammarStr, - null, - lexerName); + grammarStr, + null, + lexerName); assertTrue(success); writeFile(tmpdir, "input", input); writeLexerTestFile(lexerName, showDFA); addSourceFiles("Test.cs"); - if(!compile()) { + if (!compile()) { System.err.println("Failed to compile!"); return stderrDuringParse; } String output = execTest(); - if ( output!=null && output.length()==0 ) { + if (output != null && output.length() == 0) { output = null; } return output; @@ -244,73 +234,74 @@ public class BaseCSharpTest implements RuntimeTestSupport { Set sourceFiles = new HashSet(); - private void addSourceFiles(String ... files) { - for(String file : files) + private void addSourceFiles(String... files) { + for (String file : files) this.sourceFiles.add(file); } @Override - public String execParser(String grammarFileName, - String grammarStr, - String parserName, - String lexerName, - String listenerName, - String visitorName, - String startRuleName, - String input, - boolean showDiagnosticErrors) - { + public String execParser(String grammarFileName, + String grammarStr, + String parserName, + String lexerName, + String listenerName, + String visitorName, + String startRuleName, + String input, + boolean showDiagnosticErrors) { boolean success = rawGenerateRecognizer(grammarFileName, - grammarStr, - parserName, - lexerName, - "-visitor"); + grammarStr, + parserName, + lexerName, + "-visitor"); assertTrue(success); writeFile(tmpdir, "input", input); return rawExecRecognizer(parserName, - lexerName, - startRuleName, - showDiagnosticErrors); + lexerName, + startRuleName, + showDiagnosticErrors); } - /** Return true if all is well */ + /** + * Return true if all is well + */ protected boolean rawGenerateRecognizer(String grammarFileName, - String grammarStr, - String parserName, - String lexerName, - String... extraOptions) - { + String grammarStr, + String parserName, + String lexerName, + String... extraOptions) { return rawGenerateRecognizer(grammarFileName, grammarStr, parserName, lexerName, false, extraOptions); } - /** Return true if all is well */ + /** + * Return true if all is well + */ protected boolean rawGenerateRecognizer(String grammarFileName, - String grammarStr, - String parserName, - String lexerName, - boolean defaultListener, - String... extraOptions) - { + String grammarStr, + String parserName, + String lexerName, + boolean defaultListener, + String... extraOptions) { ErrorQueue equeue = antlrOnString(getTmpDir(), "CSharp", grammarFileName, grammarStr, defaultListener, extraOptions); if (!equeue.errors.isEmpty()) { return false; } List files = new ArrayList(); - if ( lexerName!=null ) { - files.add(lexerName+".cs"); + if (lexerName != null) { + files.add(lexerName + ".cs"); } - if ( parserName!=null ) { - files.add(parserName+".cs"); + if (parserName != null) { + files.add(parserName + ".cs"); Set optionsSet = new HashSet(Arrays.asList(extraOptions)); String grammarName = grammarFileName.substring(0, grammarFileName.lastIndexOf('.')); if (!optionsSet.contains("-no-listener")) { - files.add(grammarName+"Listener.cs"); - files.add(grammarName+"BaseListener.cs"); + files.add(grammarName + "Listener.cs"); + files.add(grammarName + "BaseListener.cs"); } if (optionsSet.contains("-visitor")) { - files.add(grammarName+"Visitor.cs"); - files.add(grammarName+"BaseVisitor.cs"); + files.add(grammarName + "Visitor.cs"); + files.add(grammarName + "BaseVisitor.cs"); } } addSourceFiles(files.toArray(new String[files.size()])); @@ -318,19 +309,17 @@ public class BaseCSharpTest implements RuntimeTestSupport { } protected String rawExecRecognizer(String parserName, - String lexerName, - String parserStartRuleName, - boolean debug) - { + String lexerName, + String parserStartRuleName, + boolean debug) { this.stderrDuringParse = null; - if ( parserName==null ) { + if (parserName == null) { writeLexerTestFile(lexerName, false); - } - else { + } else { writeParserTestFile(parserName, - lexerName, - parserStartRuleName, - debug); + lexerName, + parserStartRuleName, + debug); } addSourceFiles("Test.cs"); @@ -342,50 +331,80 @@ public class BaseCSharpTest implements RuntimeTestSupport { assertTrue(success); String output = execTest(); - if ( output!=null && output.length()==0 ) { + if (output != null && output.length() == 0) { output = null; } return output; } public boolean compile() { - if(!NETSTANDARD) { - try { - if(!createProject()) - return false; - if(!buildProject()) - return false; - return true; - } catch(Exception e) { - e.printStackTrace(System.err); - return false; - } - } - else - { - try { - return buildDotnetProject(); - } catch(Exception e) { - e.printStackTrace(System.err); - return false; - } - } + try { + return buildProject(); + } catch (Exception e) { + e.printStackTrace(System.err); + return false; + } } - private File getTestProjectFile() { - return new File(tmpdir, "Antlr4.Test.mono.csproj"); + private boolean isWindows() { + return System.getProperty("os.name").toLowerCase().contains("windows"); } - private boolean buildProject() throws Exception { - String msbuild = locateMSBuild(); - String[] args = { - msbuild, - "/p:Configuration=Release", - getTestProjectFile().getAbsolutePath() - }; -// System.err.println("Starting build "+ Utils.join(args, " ")); + private String locateExec() { + return new File(tmpdir, "bin/Release/netcoreapp2.0/Test.dll").getAbsolutePath(); + } + + public boolean buildProject() { + try { + // save auxiliary files + String pack = BaseCSharpTest.class.getPackage().getName().replace(".", "/") + "/"; + saveResourceAsFile(pack + "Antlr4.Test.csproj", new File(tmpdir, "Antlr4.Test.csproj")); + + // find runtime package + final ClassLoader loader = Thread.currentThread().getContextClassLoader(); + final URL runtimeProj = loader.getResource("CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj"); + if (runtimeProj == null) { + throw new RuntimeException("C# runtime project file not found!"); + } + File runtimeProjFile = new File(runtimeProj.getFile()); + String runtimeProjPath = runtimeProjFile.getPath(); + + // add Runtime project reference + String[] args = new String[]{ + "dotnet", + "add", + "Antlr4.Test.csproj", + "reference", + runtimeProjPath + }; + boolean success = runProcess(args, tmpdir); + assertTrue(success); + + // build test + args = new String[]{ + "dotnet", + "build", + "Antlr4.Test.csproj", + "-c", + "Release" + }; + success = runProcess(args, tmpdir); + assertTrue(success); + } catch (Exception e) { + e.printStackTrace(System.err); + return false; + } + + return true; + } + + private boolean runProcess(String[] args, String path) throws Exception { + return runProcess(args, path, 0); + } + + private boolean runProcess(String[] args, String path, int retries) throws Exception { ProcessBuilder pb = new ProcessBuilder(args); - pb.directory(new File(tmpdir)); + pb.directory(new File(path)); Process process = pb.start(); StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream()); StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream()); @@ -394,208 +413,39 @@ public class BaseCSharpTest implements RuntimeTestSupport { process.waitFor(); stdoutVacuum.join(); stderrVacuum.join(); - // xbuild sends errors to output, so check exit code int exitValue = process.exitValue(); boolean success = (exitValue == 0); - if ( !success ) { - this.stderrDuringParse = stdoutVacuum.toString(); - String stderrString = stderrVacuum.toString(); - System.err.println("buildProject command: " + Utils.join(args, " ")); - System.err.println("buildProject exitValue: " + exitValue); - System.err.println("buildProject stdout: " + stderrDuringParse); - System.err.println("buildProject stderr: " + stderrString); + if (!success) { + this.stderrDuringParse = stderrVacuum.toString(); + System.err.println("runProcess command: " + Utils.join(args, " ")); + System.err.println("runProcess exitValue: " + exitValue); + System.err.println("runProcess stdoutVacuum: " + stdoutVacuum.toString()); + System.err.println("runProcess stderrVacuum: " + stderrDuringParse); + } + if (exitValue == 132) { + // Retry after SIGILL. We are seeing this intermittently on + // macOS (issue #2078). + if (retries < 3) { + System.err.println("runProcess retrying; " + retries + + " retries so far"); + return runProcess(args, path, retries + 1); + } else { + System.err.println("runProcess giving up after " + retries + + " retries"); + return false; + } } return success; } - private String locateMSBuild() { - if(isWindows()) - return "\"C:\\Program Files (x86)\\MSBuild\\12.0\\Bin\\MSBuild.exe\""; - else - return locateTool("xbuild"); - } - - private boolean isWindows() { - return System.getProperty("os.name").toLowerCase().contains("windows"); - } - - private String locateExec() { - if (!NETSTANDARD) - return new File(tmpdir, "bin/Release/Test.exe").getAbsolutePath(); - - return new File(tmpdir, "bin/Release/netcoreapp1.0/Test.dll").getAbsolutePath(); - } - - private String locateTool(String tool) { - String[] roots = { "/opt/local/bin/", "/usr/local/bin/", "/usr/bin/" }; - for(String root : roots) { - if(new File(root + tool).exists()) - return root + tool; - } - throw new RuntimeException("Could not locate " + tool); - } - - public boolean createProject() { - try { - String pack = BaseCSharpTest.class.getPackage().getName().replace(".", "/") + "/"; - // save auxiliary files - saveResourceAsFile(pack + "AssemblyInfo.cs", new File(tmpdir, "AssemblyInfo.cs")); - saveResourceAsFile(pack + "App.config", new File(tmpdir, "App.config")); - // update project - String projectName = isWindows() ? "Antlr4.Test.vs2013.csproj" : "Antlr4.Test.mono.csproj"; - final ClassLoader loader = Thread.currentThread().getContextClassLoader(); - InputStream input = loader.getResourceAsStream(pack + projectName); - Document prjXml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input); - // update runtime project reference - // find project file as a resource not relative pathname (now that we've merged repos) - String runtimeName = isWindows() ? "Antlr4.Runtime.vs2013.csproj" : "Antlr4.Runtime.mono.csproj"; - final URL runtimeProj = loader.getResource("CSharp/runtime/CSharp/Antlr4.Runtime/"+runtimeName); - if ( runtimeProj==null ) { - throw new RuntimeException("C# runtime project file not found!"); - } - String runtimeProjPath = runtimeProj.getPath(); - if(isWindows()){ - runtimeProjPath = runtimeProjPath.replaceFirst("/", ""); - } - XPathExpression exp = XPathFactory.newInstance().newXPath() - .compile("/Project/ItemGroup/ProjectReference[@Include='" + runtimeName + "']"); - Element node = (Element)exp.evaluate(prjXml, XPathConstants.NODE); - node.setAttribute("Include", runtimeProjPath.replace("/", "\\")); - // update project file list - exp = XPathFactory.newInstance().newXPath().compile("/Project/ItemGroup[Compile/@Include='AssemblyInfo.cs']"); - Element group = (Element)exp.evaluate(prjXml, XPathConstants.NODE); - if(group==null) - return false; - // remove existing children - while(group.hasChildNodes()) - group.removeChild(group.getFirstChild()); - // add AssemblyInfo.cs, not a generated source - sourceFiles.add("AssemblyInfo.cs"); - // add files to compile - for(String file : sourceFiles) { - Element elem = group.getOwnerDocument().createElement("Compile"); - elem.setAttribute("Include", file); - group.appendChild(elem); - } - // save project - File prjFile = getTestProjectFile(); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.transform(new DOMSource(prjXml), new StreamResult(prjFile)); - return true; - } - catch(Exception e) { - e.printStackTrace(System.err); - return false; - } - } - - public boolean buildDotnetProject() { - try { - // save auxiliary files - String pack = BaseCSharpTest.class.getPackage().getName().replace(".", "/") + "/"; - saveResourceAsFile(pack + "Antlr4.Test.dotnet.csproj", new File(tmpdir, "Antlr4.Test.dotnet.csproj")); - - // find runtime package - final ClassLoader loader = Thread.currentThread().getContextClassLoader(); - final URL runtimeProj = loader.getResource("CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj"); - if ( runtimeProj==null ) { - throw new RuntimeException("C# runtime project file not found!"); - } - File runtimeProjFile = new File(runtimeProj.getFile()); - String runtimeProjPath = runtimeProjFile.getPath(); - - // add Runtime project reference - String dotnetcli = locateTool("dotnet"); - String[] args = new String[] { - dotnetcli, - "add", - "Antlr4.Test.dotnet.csproj", - "reference", - runtimeProjPath - }; - boolean success = runProcess(args, tmpdir); - assertTrue(success); - - // restore project - args = new String[] { - dotnetcli, - "restore", - "Antlr4.Test.dotnet.csproj", - "--no-dependencies" - }; - success = runProcess(args, tmpdir); - assertTrue(success); - - // build test - args = new String[] { - dotnetcli, - "build", - "Antlr4.Test.dotnet.csproj", - "-c", - "Release", - "--no-dependencies" - }; - success = runProcess(args, tmpdir); - assertTrue(success); - } - catch(Exception e) { - e.printStackTrace(System.err); - return false; - } - - return true; - } - - private boolean runProcess(String[] args, String path) throws Exception { - return runProcess(args, path, 0); - } - - private boolean runProcess(String[] args, String path, int retries) throws Exception { - ProcessBuilder pb = new ProcessBuilder(args); - pb.directory(new File(path)); - Process process = pb.start(); - StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream()); - StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream()); - stdoutVacuum.start(); - stderrVacuum.start(); - process.waitFor(); - stdoutVacuum.join(); - stderrVacuum.join(); - int exitValue = process.exitValue(); - boolean success = (exitValue == 0); - if ( !success ) { - this.stderrDuringParse = stderrVacuum.toString(); - System.err.println("runProcess command: " + Utils.join(args, " ")); - System.err.println("runProcess exitValue: " + exitValue); - System.err.println("runProcess stdoutVacuum: " + stdoutVacuum.toString()); - System.err.println("runProcess stderrVacuum: " + stderrDuringParse); - } - if (exitValue == 132) { - // Retry after SIGILL. We are seeing this intermittently on - // macOS (issue #2078). - if (retries < 3) { - System.err.println("runProcess retrying; " + retries + - " retries so far"); - return runProcess(args, path, retries + 1); - } - else { - System.err.println("runProcess giving up after " + retries + - " retries"); - return false; - } - } - return success; - } - private void saveResourceAsFile(String resourceName, File file) throws IOException { InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName); - if ( input==null ) { + if (input == null) { System.err.println("Can't find " + resourceName + " as resource"); throw new IOException("Missing resource:" + resourceName); } OutputStream output = new FileOutputStream(file.getAbsolutePath()); - while(input.available()>0) { + while (input.available() > 0) { output.write(input.read()); } output.close(); @@ -635,8 +485,7 @@ public class BaseCSharpTest implements RuntimeTestSupport { System.err.println("execTest stderrVacuum: " + stderrString); } return writtenOutput; - } - catch (Exception e) { + } catch (Exception e) { System.err.println("can't exec recognizer"); e.printStackTrace(System.err); } @@ -644,138 +493,62 @@ public class BaseCSharpTest implements RuntimeTestSupport { } private String[] getExecTestArgs(String exec, Path output, Path errorOutput) { - if ( isWindows() ) { - return new String[]{ - exec, new File(tmpdir, "input").getAbsolutePath(), + return new String[]{ + "dotnet", exec, new File(tmpdir, "input").getAbsolutePath(), output.toAbsolutePath().toString(), errorOutput.toAbsolutePath().toString() - }; - } - else { - if (!NETSTANDARD) { - String mono = locateTool("mono"); - return new String[] { - mono, exec, new File(tmpdir, "input").getAbsolutePath(), - output.toAbsolutePath().toString(), - errorOutput.toAbsolutePath().toString() - }; - } - - String dotnet = locateTool("dotnet"); - return new String[] { - dotnet, exec, new File(tmpdir, "input").getAbsolutePath(), - output.toAbsolutePath().toString(), - errorOutput.toAbsolutePath().toString() - }; - } - } - - List getMessagesOfType(List msgs, Class c) { - List filtered = new ArrayList(); - for (ANTLRMessage m : msgs) { - if ( m.getClass() == c ) filtered.add(m); - } - return filtered; - } - - - protected void checkGrammarSemanticsError(ErrorQueue equeue, - GrammarSemanticsMessage expectedMessage) - throws Exception - { - ANTLRMessage foundMsg = null; - for (int i = 0; i < equeue.errors.size(); i++) { - ANTLRMessage m = equeue.errors.get(i); - if (m.getErrorType()==expectedMessage.getErrorType() ) { - foundMsg = m; - } - } - assertNotNull("no error; "+expectedMessage.getErrorType()+" expected", foundMsg); - assertTrue("error is not a GrammarSemanticsMessage", - foundMsg instanceof GrammarSemanticsMessage); - assertEquals(Arrays.toString(expectedMessage.getArgs()), Arrays.toString(foundMsg.getArgs())); - if ( equeue.size()!=1 ) { - System.err.println(equeue); - } - } - - - public static class FilteringTokenStream extends CommonTokenStream { - public FilteringTokenStream(TokenSource src) { super(src); } - Set hide = new HashSet(); - @Override - protected boolean sync(int i) { - if (!super.sync(i)) { - return false; - } - - Token t = get(i); - if ( hide.contains(t.getType()) ) { - ((WritableToken)t).setChannel(Token.HIDDEN_CHANNEL); - } - - return true; - } - public void setTokenTypeChannel(int ttype, int channel) { - hide.add(ttype); - } - } - - protected void mkdir(String dir) { - File f = new File(dir); - f.mkdirs(); + }; } protected void writeParserTestFile(String parserName, - String lexerName, - String parserStartRuleName, - boolean debug) - { + String lexerName, + String parserStartRuleName, + boolean debug) { ST outputFileST = new ST( - "using System;\n" + - "using Antlr4.Runtime;\n" + - "using Antlr4.Runtime.Tree;\n" + - "using System.IO;\n" + - "using System.Text;\n" + - "\n" + - "public class Test {\n" + - " public static void Main(string[] args) {\n" + - " var input = CharStreams.fromPath(args[0]);\n" + - " using (FileStream fsOut = new FileStream(args[1], FileMode.Create, FileAccess.Write))\n" + - " using (FileStream fsErr = new FileStream(args[2], FileMode.Create, FileAccess.Write))\n" + - " using (TextWriter output = new StreamWriter(fsOut),\n" + - " errorOutput = new StreamWriter(fsErr)) {\n" + - " lex = new (input, output, errorOutput);\n" + - " CommonTokenStream tokens = new CommonTokenStream(lex);\n" + - " \n"+ - " parser.BuildParseTree = true;\n" + - " ParserRuleContext tree = parser.();\n" + - " ParseTreeWalker.Default.Walk(new TreeShapeListener(), tree);\n" + - " }\n" + - " }\n" + - "}\n" + - "\n" + - "class TreeShapeListener : IParseTreeListener {\n" + - " public void VisitTerminal(ITerminalNode node) { }\n" + - " public void VisitErrorNode(IErrorNode node) { }\n" + - " public void ExitEveryRule(ParserRuleContext ctx) { }\n" + - "\n" + - " public void EnterEveryRule(ParserRuleContext ctx) {\n" + - " for (int i = 0; i \\< ctx.ChildCount; i++) {\n" + - " IParseTree parent = ctx.GetChild(i).Parent;\n" + - " if (!(parent is IRuleNode) || ((IRuleNode)parent).RuleContext != ctx) {\n" + - " throw new Exception(\"Invalid parse tree shape detected.\");\n" + - " }\n" + - " }\n" + - " }\n" + - "}" + "using System;\n" + + "using Antlr4.Runtime;\n" + + "using Antlr4.Runtime.Tree;\n" + + "using System.IO;\n" + + "using System.Text;\n" + + "\n" + + "public class Test {\n" + + " public static void Main(string[] args) {\n" + + " var input = CharStreams.fromPath(args[0]);\n" + + " using (FileStream fsOut = new FileStream(args[1], FileMode.Create, FileAccess.Write))\n" + + " using (FileStream fsErr = new FileStream(args[2], FileMode.Create, FileAccess.Write))\n" + + " using (TextWriter output = new StreamWriter(fsOut),\n" + + " errorOutput = new StreamWriter(fsErr)) {\n" + + " lex = new (input, output, errorOutput);\n" + + " CommonTokenStream tokens = new CommonTokenStream(lex);\n" + + " \n" + + " parser.BuildParseTree = true;\n" + + " ParserRuleContext tree = parser.();\n" + + " ParseTreeWalker.Default.Walk(new TreeShapeListener(), tree);\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class TreeShapeListener : IParseTreeListener {\n" + + " public void VisitTerminal(ITerminalNode node) { }\n" + + " public void VisitErrorNode(IErrorNode node) { }\n" + + " public void ExitEveryRule(ParserRuleContext ctx) { }\n" + + "\n" + + " public void EnterEveryRule(ParserRuleContext ctx) {\n" + + " for (int i = 0; i \\< ctx.ChildCount; i++) {\n" + + " IParseTree parent = ctx.GetChild(i).Parent;\n" + + " if (!(parent is IRuleNode) || ((IRuleNode)parent).RuleContext != ctx) {\n" + + " throw new Exception(\"Invalid parse tree shape detected.\");\n" + + " }\n" + + " }\n" + + " }\n" + + "}" ); ST createParserST = new ST(" parser = new (tokens, output, errorOutput);\n"); - if ( debug ) { + if (debug) { createParserST = - new ST( - " parser = new (tokens, output, errorOutput);\n" + - " parser.AddErrorListener(new DiagnosticErrorListener());\n"); + new ST( + " parser = new (tokens, output, errorOutput);\n" + + " parser.AddErrorListener(new DiagnosticErrorListener());\n"); } outputFileST.add("createParser", createParserST); outputFileST.add("parserName", parserName); @@ -786,113 +559,63 @@ public class BaseCSharpTest implements RuntimeTestSupport { protected void writeLexerTestFile(String lexerName, boolean showDFA) { ST outputFileST = new ST( - "using System;\n" + - "using Antlr4.Runtime;\n" + - "using System.IO;\n" + - "using System.Text;\n" + - "\n" + - "public class Test {\n" + - " public static void Main(string[] args) {\n" + - " var input = CharStreams.fromPath(args[0]);\n" + - " using (FileStream fsOut = new FileStream(args[1], FileMode.Create, FileAccess.Write))\n" + - " using (FileStream fsErr = new FileStream(args[2], FileMode.Create, FileAccess.Write))\n" + - " using (TextWriter output = new StreamWriter(fsOut),\n" + - " errorOutput = new StreamWriter(fsErr)) {\n" + - " lex = new (input, output, errorOutput);\n" + - " CommonTokenStream tokens = new CommonTokenStream(lex);\n" + - " tokens.Fill();\n" + - " foreach (object t in tokens.GetTokens())\n" + - " output.WriteLine(t);\n" + - (showDFA?" output.Write(lex.Interpreter.GetDFA(Lexer.DEFAULT_MODE).ToLexerString());\n":"")+ - " }\n" + - "}\n" + - "}" + "using System;\n" + + "using Antlr4.Runtime;\n" + + "using System.IO;\n" + + "using System.Text;\n" + + "\n" + + "public class Test {\n" + + " public static void Main(string[] args) {\n" + + " var input = CharStreams.fromPath(args[0]);\n" + + " using (FileStream fsOut = new FileStream(args[1], FileMode.Create, FileAccess.Write))\n" + + " using (FileStream fsErr = new FileStream(args[2], FileMode.Create, FileAccess.Write))\n" + + " using (TextWriter output = new StreamWriter(fsOut),\n" + + " errorOutput = new StreamWriter(fsErr)) {\n" + + " lex = new (input, output, errorOutput);\n" + + " CommonTokenStream tokens = new CommonTokenStream(lex);\n" + + " tokens.Fill();\n" + + " foreach (object t in tokens.GetTokens())\n" + + " output.WriteLine(t);\n" + + (showDFA ? " output.Write(lex.Interpreter.GetDFA(Lexer.DEFAULT_MODE).ToLexerString());\n" : "") + + " }\n" + + "}\n" + + "}" ); outputFileST.add("lexerName", lexerName); writeFile(tmpdir, "Test.cs", outputFileST.render()); } - public void writeRecognizerAndCompile(String parserName, String lexerName, - String parserStartRuleName, - boolean debug) { - if ( parserName==null ) { - writeLexerTestFile(lexerName, debug); - } - else { - writeParserTestFile(parserName, - lexerName, - parserStartRuleName, - debug); - } - - addSourceFiles("Test.cs"); - } - - - protected void eraseFiles(final String filesEndingWith) { - File tmpdirF = new File(tmpdir); - String[] files = tmpdirF.list(); - for(int i = 0; files!=null && i < files.length; i++) { - if ( files[i].endsWith(filesEndingWith) ) { - new File(tmpdir+"/"+files[i]).delete(); - } - } - } - protected void eraseDirectory(File dir) { File[] files = dir.listFiles(); - if (files != null) { - for (File file : files) { - if (file.isDirectory()) { - eraseDirectory(file); - } - else { - file.delete(); - } - } - } - dir.delete(); + if (files != null) { + for (File file : files) { + if (file.isDirectory()) { + eraseDirectory(file); + } else { + file.delete(); + } + } + } + dir.delete(); } @Override public void eraseTempDir() { - if (!PRESERVE_TEST_DIR) { - File tmpdirF = new File(tmpdir); - if ( tmpdirF.exists() ) { - eraseDirectory(tmpdirF); - tmpdirF.delete(); - } - } - } - - public String getFirstLineOfException() { - if ( this.stderrDuringParse ==null ) { - return null; + if (!PRESERVE_TEST_DIR) { + File tmpdirF = new File(tmpdir); + if (tmpdirF.exists()) { + eraseDirectory(tmpdirF); + tmpdirF.delete(); + } } - String[] lines = this.stderrDuringParse.split("\n"); - String prefix="Exception in thread \"main\" "; - return lines[0].substring(prefix.length(),lines[0].length()); } - public List realElements(List elements) { - return elements.subList(Token.MIN_USER_TOKEN_TYPE, elements.size()); - } - - public void assertNotNullOrEmpty(String message, String text) { - assertNotNull(message, text); - assertFalse(message, text.isEmpty()); - } - - public void assertNotNullOrEmpty(String text) { - assertNotNull(text); - assertFalse(text.isEmpty()); - } - - - /** Return map sorted by key */ - public ,V> LinkedHashMap sort(Map data) { - LinkedHashMap dup = new LinkedHashMap(); + /** + * Return map sorted by key + */ + public , V> LinkedHashMap sort(Map data) { + LinkedHashMap dup = new LinkedHashMap(); List keys = new ArrayList(); keys.addAll(data.keySet()); Collections.sort(keys); @@ -909,5 +632,4 @@ public class BaseCSharpTest implements RuntimeTestSupport { protected static void assertEquals(String a, String b) { org.junit.Assert.assertEquals(a, b); } - } From 22967d3ccd78e17f7dd4b6375a3070cce7af9e12 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sat, 26 Dec 2020 21:38:57 +0300 Subject: [PATCH 30/36] Remove tests/ dir from .gitignore (it skips files from runtime tests directory) --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9c2088800..81e058979 100644 --- a/.gitignore +++ b/.gitignore @@ -97,7 +97,6 @@ xcuserdata # VSCode Java plugin temporary files javac-services.0.log javac-services.0.log.lck -test/ # Don't ignore python tests !runtime/Python3/test/ From dc8fc4f94f8482be2e7a08d4f7bb82f2d70c48cd Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Mon, 28 Dec 2020 13:51:17 +0300 Subject: [PATCH 31/36] Fix dotnet build, remove not used code --- .../v4/test/runtime/csharp/Antlr4.Test.csproj | 2 +- .../test/runtime/csharp/BaseCSharpTest.java | 42 +------------- .../Antlr4.Runtime/Antlr4.Runtime.csproj | 9 +-- .../Antlr4.Runtime/ParserRuleContext.cs | 56 +++++++++---------- .../Sharpen/SerializableAttribute.cs | 16 ------ 5 files changed, 33 insertions(+), 92 deletions(-) delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/SerializableAttribute.cs diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.csproj b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.csproj index 3611a9857..b6436700f 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.csproj +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/Antlr4.Test.csproj @@ -1,7 +1,7 @@  - netcoreapp2.0 + netcoreapp3.1 $(NoWarn);CS3021 Test Exe diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java index 68f779291..bc356fd8f 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java @@ -166,40 +166,6 @@ public class BaseCSharpTest implements RuntimeTestSupport { return antlrToolErrors.toString(); } - protected org.antlr.v4.Tool newTool(String[] args) { - Tool tool = new Tool(args); - return tool; - } - - protected Tool newTool() { - org.antlr.v4.Tool tool = new Tool(new String[]{"-o", tmpdir}); - return tool; - } - - protected String load(String fileName, String encoding) - throws IOException { - if (fileName == null) { - return null; - } - - String fullFileName = getClass().getPackage().getName().replace('.', '/') + '/' + fileName; - int size = 65000; - InputStreamReader isr; - InputStream fis = getClass().getClassLoader().getResourceAsStream(fullFileName); - if (encoding != null) { - isr = new InputStreamReader(fis, encoding); - } else { - isr = new InputStreamReader(fis); - } - try { - char[] data = new char[size]; - int n = isr.read(data); - return new String(data, 0, n); - } finally { - isr.close(); - } - } - protected String execLexer(String grammarFileName, String grammarStr, String lexerName, @@ -232,7 +198,7 @@ public class BaseCSharpTest implements RuntimeTestSupport { return output; } - Set sourceFiles = new HashSet(); + Set sourceFiles = new HashSet<>(); private void addSourceFiles(String... files) { for (String file : files) @@ -346,12 +312,8 @@ public class BaseCSharpTest implements RuntimeTestSupport { } } - private boolean isWindows() { - return System.getProperty("os.name").toLowerCase().contains("windows"); - } - private String locateExec() { - return new File(tmpdir, "bin/Release/netcoreapp2.0/Test.dll").getAbsolutePath(); + return new File(tmpdir, "bin/Release/netcoreapp3.1/Test.dll").getAbsolutePath(); } public boolean buildProject() { diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj index b3c9c73fe..0da3e7abe 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj @@ -15,14 +15,14 @@ Eric Vergnaud, Terence Parr, Sam Harwell The .NET Core C# ANTLR 4 runtime from the ANTLR Organization The runtime library for parsers generated by the C# target of the standard ANTLR 4 tool. - Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. + Copyright (c) 2012-2020 The ANTLR Project. All rights reserved. true - https://github.com/antlr/antlr4/blob/master/LICENSE.txt + BSD-3-Clause https://github.com/antlr/antlr4 + https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png https://github.com/antlr/antlr4/releases antlr parsing grammar - 1.6.1 false false false @@ -44,7 +44,4 @@ true lib\Release - - NETSTANDARD20 - diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs index 4503db1dc..79c22daa5 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs @@ -34,7 +34,7 @@ namespace Antlr4.Runtime /// public class ParserRuleContext : RuleContext { - public static readonly Antlr4.Runtime.ParserRuleContext EMPTY = new Antlr4.Runtime.ParserRuleContext(); + public static readonly Antlr4.Runtime.ParserRuleContext EMPTY = new Antlr4.Runtime.ParserRuleContext(); /// /// If we are debugging or building a parse tree for a visitor, @@ -174,6 +174,7 @@ namespace Antlr4.Runtime { children = new List(); } + children.Add(t); } @@ -183,6 +184,7 @@ namespace Antlr4.Runtime { children = new List(); } + children.Add(ruleInvocation); } @@ -236,6 +238,7 @@ namespace Antlr4.Runtime { return default(T); } + int j = -1; // what element have we found with ctxType? foreach (IParseTree o in children) @@ -245,10 +248,11 @@ namespace Antlr4.Runtime j++; if (j == i) { - return (T)o; + return (T) o; } } } + return default(T); } @@ -258,13 +262,14 @@ namespace Antlr4.Runtime { return null; } + int j = -1; // what token with ttype have we found? foreach (IParseTree o in children) { if (o is ITerminalNode) { - ITerminalNode tnode = (ITerminalNode)o; + ITerminalNode tnode = (ITerminalNode) o; IToken symbol = tnode.Symbol; if (symbol.Type == ttype) { @@ -276,21 +281,23 @@ namespace Antlr4.Runtime } } } + return null; } - public virtual IReadOnlyList GetTokens(int ttype) + public virtual ITerminalNode[] GetTokens(int ttype) { if (children == null) { return Collections.EmptyList(); } + List tokens = null; foreach (IParseTree o in children) { if (o is ITerminalNode) { - ITerminalNode tnode = (ITerminalNode)o; + ITerminalNode tnode = (ITerminalNode) o; IToken symbol = tnode.Symbol; if (symbol.Type == ttype) { @@ -298,16 +305,18 @@ namespace Antlr4.Runtime { tokens = new List(); } + tokens.Add(tnode); } } } + if (tokens == null) { return Collections.EmptyList(); } - return tokens; + return tokens.ToArray(); } public virtual T GetRuleContext(int i) @@ -316,13 +325,14 @@ namespace Antlr4.Runtime return GetChild(i); } - public virtual IReadOnlyList GetRuleContexts() + public virtual T[] GetRuleContexts() where T : Antlr4.Runtime.ParserRuleContext { if (children == null) { return Collections.EmptyList(); } + List contexts = null; foreach (IParseTree o in children) { @@ -332,23 +342,22 @@ namespace Antlr4.Runtime { contexts = new List(); } - contexts.Add((T)o); + + contexts.Add((T) o); } } + if (contexts == null) { return Collections.EmptyList(); } - return contexts; + return contexts.ToArray(); } public override int ChildCount { - get - { - return children != null ? children.Count : 0; - } + get { return children != null ? children.Count : 0; } } public override Interval SourceInterval @@ -359,32 +368,21 @@ namespace Antlr4.Runtime { return Interval.Invalid; } + return Interval.Of(_start.TokenIndex, _stop.TokenIndex); } } public virtual IToken Start { - get - { - return _start; - } - set - { - _start = value; - } + get { return _start; } + set { _start = value; } } public virtual IToken Stop { - get - { - return _stop; - } - set - { - _stop = value; - } + get { return _stop; } + set { _stop = value; } } /// Used for rule context info debugging during parse-time, not so much for ATN debugging diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/SerializableAttribute.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/SerializableAttribute.cs deleted file mode 100644 index ff18f30b9..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/SerializableAttribute.cs +++ /dev/null @@ -1,16 +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. - */ - -#if NETSTANDARD20 - -namespace System -{ - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate, Inherited = false)] - internal sealed class SerializableAttribute : Attribute - { - } -} - -#endif \ No newline at end of file From b4ceb2022a1484af13df30604de342772a4d935a Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Mon, 28 Dec 2020 16:01:38 +0300 Subject: [PATCH 32/36] Simplify structure of csharp runtime files, remove not used .sln file, use PackageIcon property instead of outdated PackageIcon in Antlr4.csproj --- .../test/runtime/csharp/BaseCSharpTest.java | 2 +- runtime/CSharp/Antlr.png | Bin 0 -> 1603 bytes .../Antlr4.Runtime.csproj => Antlr4.csproj} | 10 ++++-- runtime/CSharp/{runtime => }/Antlr4.snk | Bin .../Antlr4.Runtime => }/AntlrFileStream.cs | 0 .../Antlr4.Runtime => }/AntlrInputStream.cs | 0 .../CSharp/Antlr4.Runtime => }/Atn/ATN.cs | 0 .../Antlr4.Runtime => }/Atn/ATNConfig.cs | 0 .../Antlr4.Runtime => }/Atn/ATNConfigSet.cs | 0 .../Atn/ATNDeserializationOptions.cs | 0 .../Atn/ATNDeserializer.cs | 0 .../Antlr4.Runtime => }/Atn/ATNSimulator.cs | 0 .../Antlr4.Runtime => }/Atn/ATNState.cs | 0 .../CSharp/Antlr4.Runtime => }/Atn/ATNType.cs | 0 .../Atn/AbstractPredicateTransition.cs | 0 .../Atn/ActionTransition.cs | 0 .../Antlr4.Runtime => }/Atn/AmbiguityInfo.cs | 0 .../Atn/ArrayPredictionContext.cs | 0 .../Antlr4.Runtime => }/Atn/AtomTransition.cs | 0 .../Atn/BasicBlockStartState.cs | 0 .../Antlr4.Runtime => }/Atn/BasicState.cs | 0 .../Antlr4.Runtime => }/Atn/BlockEndState.cs | 0 .../Atn/BlockStartState.cs | 0 .../Antlr4.Runtime => }/Atn/ConflictInfo.cs | 0 .../Atn/ContextSensitivityInfo.cs | 0 .../Atn/DecisionEventInfo.cs | 0 .../Antlr4.Runtime => }/Atn/DecisionInfo.cs | 0 .../Antlr4.Runtime => }/Atn/DecisionState.cs | 0 .../Atn/EmptyPredictionContext.cs | 0 .../Atn/EpsilonTransition.cs | 0 .../Antlr4.Runtime => }/Atn/ErrorInfo.cs | 0 .../Antlr4.Runtime => }/Atn/ILexerAction.cs | 0 .../Antlr4.Runtime => }/Atn/LL1Analyzer.cs | 0 .../Antlr4.Runtime => }/Atn/LexerATNConfig.cs | 0 .../Atn/LexerATNSimulator.cs | 0 .../Atn/LexerActionExecutor.cs | 0 .../Atn/LexerActionType.cs | 0 .../Atn/LexerChannelAction.cs | 0 .../Atn/LexerCustomAction.cs | 0 .../Atn/LexerIndexedCustomAction.cs | 0 .../Atn/LexerModeAction.cs | 0 .../Atn/LexerMoreAction.cs | 0 .../Atn/LexerPopModeAction.cs | 0 .../Atn/LexerPushModeAction.cs | 0 .../Atn/LexerSkipAction.cs | 0 .../Atn/LexerTypeAction.cs | 0 .../Atn/LookaheadEventInfo.cs | 0 .../Antlr4.Runtime => }/Atn/LoopEndState.cs | 0 .../Antlr4.Runtime => }/Atn/MergeCache.cs | 0 .../Atn/NotSetTransition.cs | 0 .../Antlr4.Runtime => }/Atn/ParseInfo.cs | 0 .../Atn/ParserATNSimulator.cs | 0 .../Atn/PlusBlockStartState.cs | 0 .../Atn/PlusLoopbackState.cs | 0 .../Atn/PrecedencePredicateTransition.cs | 0 .../Atn/PredicateEvalInfo.cs | 0 .../Atn/PredicateTransition.cs | 0 .../Atn/PredictionContext.cs | 0 .../Atn/PredictionContextCache.cs | 0 .../Antlr4.Runtime => }/Atn/PredictionMode.cs | 0 .../Atn/ProfilingATNSimulator.cs | 0 .../Atn/RangeTransition.cs | 0 .../Antlr4.Runtime => }/Atn/RuleStartState.cs | 0 .../Antlr4.Runtime => }/Atn/RuleStopState.cs | 0 .../Antlr4.Runtime => }/Atn/RuleTransition.cs | 0 .../Atn/SemanticContext.cs | 0 .../Antlr4.Runtime => }/Atn/SetTransition.cs | 0 .../Antlr4.Runtime => }/Atn/SimulatorState.cs | 0 .../Atn/SingletonPredictionContext.cs | 0 .../Atn/StarBlockStartState.cs | 0 .../Atn/StarLoopEntryState.cs | 0 .../Atn/StarLoopbackState.cs | 0 .../Antlr4.Runtime => }/Atn/StateType.cs | 0 .../Atn/TokensStartState.cs | 0 .../Antlr4.Runtime => }/Atn/Transition.cs | 0 .../Antlr4.Runtime => }/Atn/TransitionType.cs | 0 .../Atn/WildcardTransition.cs | 0 .../Antlr4.Runtime => }/BailErrorStrategy.cs | 0 .../Antlr4.Runtime => }/BaseErrorListener.cs | 0 .../BufferedTokenStream.cs | 0 .../CSharp/Antlr4.Runtime => }/CharStreams.cs | 0 .../CSharp/Antlr4.Runtime => }/CommonToken.cs | 0 .../Antlr4.Runtime => }/CommonTokenFactory.cs | 0 .../Antlr4.Runtime => }/CommonTokenStream.cs | 0 .../ConsoleErrorListener.cs | 0 .../DefaultErrorStrategy.cs | 0 .../CSharp/Antlr4.Runtime => }/Dependents.cs | 0 .../Dfa/AbstractEdgeMap.cs | 0 .../Dfa/AcceptStateInfo.cs | 0 .../Antlr4.Runtime => }/Dfa/ArrayEdgeMap.cs | 0 .../CSharp/Antlr4.Runtime => }/Dfa/DFA.cs | 0 .../Antlr4.Runtime => }/Dfa/DFASerializer.cs | 0 .../Antlr4.Runtime => }/Dfa/DFAState.cs | 0 .../Antlr4.Runtime => }/Dfa/EmptyEdgeMap.cs | 0 .../Antlr4.Runtime => }/Dfa/IEdgeMap.cs | 0 .../Dfa/LexerDFASerializer.cs | 0 .../Dfa/SingletonEdgeMap.cs | 0 .../Antlr4.Runtime => }/Dfa/SparseEdgeMap.cs | 0 .../DiagnosticErrorListener.cs | 0 .../FailedPredicateException.cs | 0 .../IAntlrErrorListener.cs | 0 .../IAntlrErrorStrategy.cs | 0 .../CSharp/Antlr4.Runtime => }/ICharStream.cs | 0 .../CSharp/Antlr4.Runtime => }/IIntStream.cs | 0 .../IParserErrorListener.cs | 0 .../CSharp/Antlr4.Runtime => }/IRecognizer.cs | 0 .../CSharp/Antlr4.Runtime => }/IToken.cs | 0 .../Antlr4.Runtime => }/ITokenFactory.cs | 0 .../Antlr4.Runtime => }/ITokenSource.cs | 0 .../Antlr4.Runtime => }/ITokenStream.cs | 0 .../CSharp/Antlr4.Runtime => }/IVocabulary.cs | 0 .../Antlr4.Runtime => }/IWritableToken.cs | 0 .../InputMismatchException.cs | 0 .../InterpreterRuleContext.cs | 0 .../CSharp/Antlr4.Runtime => }/Lexer.cs | 0 .../Antlr4.Runtime => }/LexerInterpreter.cs | 0 .../LexerNoViableAltException.cs | 0 .../Antlr4.Runtime => }/ListTokenSource.cs | 0 .../CSharp/Antlr4.Runtime => }/Misc/Args.cs | 0 .../Antlr4.Runtime => }/Misc/ArrayList.cs | 0 .../Antlr4.Runtime => }/Misc/IIntSet.cs | 0 .../Antlr4.Runtime => }/Misc/Interval.cs | 0 .../Antlr4.Runtime => }/Misc/IntervalSet.cs | 0 .../Antlr4.Runtime => }/Misc/MultiMap.cs | 0 .../Antlr4.Runtime => }/Misc/MurmurHash.cs | 0 .../Misc/NotNullAttribute.cs | 0 .../Misc/NullableAttribute.cs | 0 .../CSharp/Antlr4.Runtime => }/Misc/Pair.cs | 0 .../Misc/ParseCanceledException.cs | 0 .../Misc/RuleDependencyChecker.cs | 0 .../CSharp/Antlr4.Runtime => }/Misc/Utils.cs | 0 .../NoViableAltException.cs | 0 .../CSharp/Antlr4.Runtime => }/Parser.cs | 0 .../Antlr4.Runtime => }/ParserInterpreter.cs | 0 .../Antlr4.Runtime => }/ParserRuleContext.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Antlr4.Runtime => }/ProxyErrorListener.cs | 0 .../ProxyParserErrorListener.cs | 0 .../RecognitionException.cs | 0 .../CSharp/Antlr4.Runtime => }/Recognizer.cs | 0 .../CSharp/Antlr4.Runtime => }/RuleContext.cs | 0 .../RuleDependencyAttribute.cs | 0 .../RuleVersionAttribute.cs | 0 .../Antlr4.Runtime => }/Sharpen/Arrays.cs | 0 .../Sharpen/AtomicReference.cs | 0 .../Antlr4.Runtime => }/Sharpen/BitSet.cs | 0 .../Sharpen/Collections.cs | 0 .../Sharpen/DictionaryExtensions.cs | 0 .../Sharpen/ListExtensions.cs | 0 .../Antlr4.Runtime => }/Sharpen/Runtime.cs | 0 .../Sharpen/SequenceEqualityComparer.cs | 0 .../TokenStreamRewriter.cs | 0 .../CSharp/Antlr4.Runtime => }/TokenTypes.cs | 0 .../Tree/AbstractParseTreeVisitor.cs | 0 .../Antlr4.Runtime => }/Tree/ErrorNodeImpl.cs | 0 .../Antlr4.Runtime => }/Tree/IErrorNode.cs | 0 .../Antlr4.Runtime => }/Tree/IParseTree.cs | 0 .../Tree/IParseTreeListener.cs | 0 .../Tree/IParseTreeVisitor.cs | 0 .../Antlr4.Runtime => }/Tree/IRuleNode.cs | 0 .../Antlr4.Runtime => }/Tree/ISyntaxTree.cs | 0 .../Antlr4.Runtime => }/Tree/ITerminalNode.cs | 0 .../CSharp/Antlr4.Runtime => }/Tree/ITree.cs | 0 .../Tree/ParseTreeProperty.cs | 0 .../Tree/ParseTreeWalker.cs | 0 .../Antlr4.Runtime => }/Tree/Pattern/Chunk.cs | 0 .../Tree/Pattern/ParseTreeMatch.cs | 0 .../Tree/Pattern/ParseTreePattern.cs | 0 .../Tree/Pattern/ParseTreePatternMatcher.cs | 0 .../Tree/Pattern/RuleTagToken.cs | 0 .../Tree/Pattern/TagChunk.cs | 0 .../Tree/Pattern/TextChunk.cs | 0 .../Tree/Pattern/TokenTagToken.cs | 0 .../Tree/TerminalNodeImpl.cs | 0 .../CSharp/Antlr4.Runtime => }/Tree/Trees.cs | 0 .../Antlr4.Runtime => }/Tree/Xpath/XPath.cs | 0 .../Tree/Xpath/XPathElement.cs | 0 .../Tree/Xpath/XPathLexer.cs | 0 .../Tree/Xpath/XPathLexer.g4 | 0 .../Tree/Xpath/XPathLexer.tokens | 0 .../Tree/Xpath/XPathLexerErrorListener.cs | 0 .../Tree/Xpath/XPathRuleAnywhereElement.cs | 0 .../Tree/Xpath/XPathRuleElement.cs | 0 .../Tree/Xpath/XPathTokenAnywhereElement.cs | 0 .../Tree/Xpath/XPathTokenElement.cs | 0 .../Xpath/XPathWildcardAnywhereElement.cs | 0 .../Tree/Xpath/XPathWildcardElement.cs | 0 .../UnbufferedCharStream.cs | 0 .../UnbufferedTokenStream.cs | 0 .../CSharp/Antlr4.Runtime => }/Vocabulary.cs | 0 runtime/CSharp/runtime/CSharp/Antlr4.sln | 34 ------------------ tool-testsuite/pom.xml | 1 - 192 files changed, 8 insertions(+), 39 deletions(-) create mode 100644 runtime/CSharp/Antlr.png rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj => Antlr4.csproj} (91%) rename runtime/CSharp/{runtime => }/Antlr4.snk (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/AntlrFileStream.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/AntlrInputStream.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ATN.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ATNConfig.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ATNConfigSet.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ATNDeserializationOptions.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ATNDeserializer.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ATNSimulator.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ATNState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ATNType.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/AbstractPredicateTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ActionTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/AmbiguityInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ArrayPredictionContext.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/AtomTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/BasicBlockStartState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/BasicState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/BlockEndState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/BlockStartState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ConflictInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ContextSensitivityInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/DecisionEventInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/DecisionInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/DecisionState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/EmptyPredictionContext.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/EpsilonTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ErrorInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ILexerAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LL1Analyzer.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerATNConfig.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerATNSimulator.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerActionExecutor.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerActionType.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerChannelAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerCustomAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerIndexedCustomAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerModeAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerMoreAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerPopModeAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerPushModeAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerSkipAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LexerTypeAction.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LookaheadEventInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/LoopEndState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/MergeCache.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/NotSetTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ParseInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ParserATNSimulator.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/PlusBlockStartState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/PlusLoopbackState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/PrecedencePredicateTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/PredicateEvalInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/PredicateTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/PredictionContext.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/PredictionContextCache.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/PredictionMode.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/ProfilingATNSimulator.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/RangeTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/RuleStartState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/RuleStopState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/RuleTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/SemanticContext.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/SetTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/SimulatorState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/SingletonPredictionContext.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/StarBlockStartState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/StarLoopEntryState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/StarLoopbackState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/StateType.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/TokensStartState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/Transition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/TransitionType.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Atn/WildcardTransition.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/BailErrorStrategy.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/BaseErrorListener.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/BufferedTokenStream.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/CharStreams.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/CommonToken.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/CommonTokenFactory.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/CommonTokenStream.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ConsoleErrorListener.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/DefaultErrorStrategy.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dependents.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/AbstractEdgeMap.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/AcceptStateInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/ArrayEdgeMap.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/DFA.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/DFASerializer.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/DFAState.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/EmptyEdgeMap.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/IEdgeMap.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/LexerDFASerializer.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/SingletonEdgeMap.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Dfa/SparseEdgeMap.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/DiagnosticErrorListener.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/FailedPredicateException.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/IAntlrErrorListener.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/IAntlrErrorStrategy.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ICharStream.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/IIntStream.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/IParserErrorListener.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/IRecognizer.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/IToken.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ITokenFactory.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ITokenSource.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ITokenStream.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/IVocabulary.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/IWritableToken.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/InputMismatchException.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/InterpreterRuleContext.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Lexer.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/LexerInterpreter.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/LexerNoViableAltException.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ListTokenSource.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/Args.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/ArrayList.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/IIntSet.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/Interval.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/IntervalSet.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/MultiMap.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/MurmurHash.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/NotNullAttribute.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/NullableAttribute.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/Pair.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/ParseCanceledException.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/RuleDependencyChecker.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Misc/Utils.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/NoViableAltException.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Parser.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ParserInterpreter.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ParserRuleContext.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Properties/AssemblyInfo.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ProxyErrorListener.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/ProxyParserErrorListener.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/RecognitionException.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Recognizer.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/RuleContext.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/RuleDependencyAttribute.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/RuleVersionAttribute.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Sharpen/Arrays.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Sharpen/AtomicReference.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Sharpen/BitSet.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Sharpen/Collections.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Sharpen/DictionaryExtensions.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Sharpen/ListExtensions.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Sharpen/Runtime.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Sharpen/SequenceEqualityComparer.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/TokenStreamRewriter.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/TokenTypes.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/AbstractParseTreeVisitor.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/ErrorNodeImpl.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/IErrorNode.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/IParseTree.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/IParseTreeListener.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/IParseTreeVisitor.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/IRuleNode.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/ISyntaxTree.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/ITerminalNode.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/ITree.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/ParseTreeProperty.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/ParseTreeWalker.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Pattern/Chunk.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Pattern/ParseTreeMatch.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Pattern/ParseTreePattern.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Pattern/ParseTreePatternMatcher.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Pattern/RuleTagToken.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Pattern/TagChunk.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Pattern/TextChunk.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Pattern/TokenTagToken.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/TerminalNodeImpl.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Trees.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPath.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathElement.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathLexer.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathLexer.g4 (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathLexer.tokens (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathLexerErrorListener.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathRuleAnywhereElement.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathRuleElement.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathTokenAnywhereElement.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathTokenElement.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathWildcardAnywhereElement.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Tree/Xpath/XPathWildcardElement.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/UnbufferedCharStream.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/UnbufferedTokenStream.cs (100%) rename runtime/CSharp/{runtime/CSharp/Antlr4.Runtime => }/Vocabulary.cs (100%) delete mode 100644 runtime/CSharp/runtime/CSharp/Antlr4.sln diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java index bc356fd8f..79b87f4d0 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseCSharpTest.java @@ -324,7 +324,7 @@ public class BaseCSharpTest implements RuntimeTestSupport { // find runtime package final ClassLoader loader = Thread.currentThread().getContextClassLoader(); - final URL runtimeProj = loader.getResource("CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj"); + final URL runtimeProj = loader.getResource("CSharp/Antlr4.csproj"); if (runtimeProj == null) { throw new RuntimeException("C# runtime project file not found!"); } diff --git a/runtime/CSharp/Antlr.png b/runtime/CSharp/Antlr.png new file mode 100644 index 0000000000000000000000000000000000000000..01f16f6a7f977e3c3637d22fa8ede242d6a4f5a1 GIT binary patch literal 1603 zcmaJ>X;2eq7*2`xLKG2Nh=}U~(oP|}8wi+%fC)(?E%69w;sq?pLLwv^cNemNwKeIC zIFdm}Y>POh6_r{X(JI=J2vkAF;(-S`R<7}=t+qftDhg;f2-qLRo!R}q_nqf?-g9=# z(#4BBrt+q8I2;dUf=tbxbJ;gw@&jLE{XIh>d{#)9dxa2iO*GmU03*jrl<0!F{+ATSJ} zv&7)*q_nD~Ks-U>fRGP|>EK8Nh>YMP5wIvi6bcAn1cnd+1V@D-Fe;2fVFVa?KsFkw z&p_2O#YimH5`zYswxAGXwOaYsa6Un1LWoEtf?xq85QMRaFe=YXV@#Nt3LI6C;gpUv zT4*C-23(3*I*~(*K{nIZC73K@vSwDy;2D3m2A9j^A3RJ1y4mFv^&=jr4-{kwh z!c=me1&7o)MdXk=c5oSiu22>4V5<8ocgV6w20WjJZf#q|o3Fag6wqsH-b2_IK)gsUGvmxyt>5St9-8ts2Z zJ?dij$8{ZBT-F#{eca6MJIOBgj^N6x9FAL!QYJ}eem$sJuiv@M`_(_EGK-M(#zMxg zqC~9-Z3+B%OCeLD{zU-pDSXo9TYT)ZUAKphmKbEbn=RhRKJTl64&Rx@&3BL&b2dg* z-g?$iu%fs5QXSEC>RCJ0BdRY*Su)h7PH&vdc>8m$cKd_X?rSDK?Ed7XV^4FMb6N_w zc~*3%-P&-o_1lO(RZJN-HM{k2S_m^^gU58@T7PaImk~UVE3)-6Yv$h(U^CnOS26)k z&WgZ0FB(F+KYSH`xnQnaxvdOz=YQVp{Gv9%HxWORML_vd#hTC{HQW zpAfy@Q9kJzZ(994;jZo??2!LGQx}sOlwJ4L^v&0fmRvuH)h$?gWzbT)A}flzZ?WpO&XZOt|#*Y@|f(^P^{gE$cz<<6@(G z#dbI(G&61+uSJJ;*PQWr8q?yhOh2(IyOm1W-m|}@stD=KupO7syX0q{CyO_EO7g2B z_a0e3luF)R2b5|W`=_3|bTTpaDy2!8wc$O#mkEwn-yH4dQNfV9rRV&^iPcM(8-K3s zbFVqswe2HbYLl_jQsckufZXds$CR#ytv|HW(L38J+m1Oeh7Z1MJiZQAaP#IZ%6)&Z zvEX)bU&eyvZD)g@L^&k`d1rBc_RnyEO}}CEXU(5#KaewK;l6 zlC+~?Mqgq0Zrpj{9S485`N;j%j+|=siGhRl=rm9JB*Cic_PVuRw*mRyr^SjJ2mY=V z2x4DsmCx^TJF%>?Oi?lCcv5r&^<8a+L7S+5F)|K+bvP04|+rRP5Z!7=+ literal 0 HcmV?d00001 diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj b/runtime/CSharp/Antlr4.csproj similarity index 91% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj rename to runtime/CSharp/Antlr4.csproj index 0da3e7abe..97e9dcef5 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.csproj +++ b/runtime/CSharp/Antlr4.csproj @@ -7,7 +7,7 @@ $(NoWarn);CS1591;CS1574;CS1580 true Antlr4.Runtime.Standard - ../../Antlr4.snk + Antlr4.snk true true Antlr4.Runtime.Standard @@ -19,8 +19,7 @@ true BSD-3-Clause https://github.com/antlr/antlr4 - - https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png + Antlr.png https://github.com/antlr/antlr4/releases antlr parsing grammar false @@ -44,4 +43,9 @@ true lib\Release + + + PreserveNewest + + diff --git a/runtime/CSharp/runtime/Antlr4.snk b/runtime/CSharp/Antlr4.snk similarity index 100% rename from runtime/CSharp/runtime/Antlr4.snk rename to runtime/CSharp/Antlr4.snk diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs b/runtime/CSharp/AntlrFileStream.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrFileStream.cs rename to runtime/CSharp/AntlrFileStream.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrInputStream.cs b/runtime/CSharp/AntlrInputStream.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/AntlrInputStream.cs rename to runtime/CSharp/AntlrInputStream.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs b/runtime/CSharp/Atn/ATN.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATN.cs rename to runtime/CSharp/Atn/ATN.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfig.cs b/runtime/CSharp/Atn/ATNConfig.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfig.cs rename to runtime/CSharp/Atn/ATNConfig.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfigSet.cs b/runtime/CSharp/Atn/ATNConfigSet.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNConfigSet.cs rename to runtime/CSharp/Atn/ATNConfigSet.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializationOptions.cs b/runtime/CSharp/Atn/ATNDeserializationOptions.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializationOptions.cs rename to runtime/CSharp/Atn/ATNDeserializationOptions.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs b/runtime/CSharp/Atn/ATNDeserializer.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNDeserializer.cs rename to runtime/CSharp/Atn/ATNDeserializer.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs b/runtime/CSharp/Atn/ATNSimulator.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNSimulator.cs rename to runtime/CSharp/Atn/ATNSimulator.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs b/runtime/CSharp/Atn/ATNState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNState.cs rename to runtime/CSharp/Atn/ATNState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNType.cs b/runtime/CSharp/Atn/ATNType.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ATNType.cs rename to runtime/CSharp/Atn/ATNType.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AbstractPredicateTransition.cs b/runtime/CSharp/Atn/AbstractPredicateTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AbstractPredicateTransition.cs rename to runtime/CSharp/Atn/AbstractPredicateTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ActionTransition.cs b/runtime/CSharp/Atn/ActionTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ActionTransition.cs rename to runtime/CSharp/Atn/ActionTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs b/runtime/CSharp/Atn/AmbiguityInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AmbiguityInfo.cs rename to runtime/CSharp/Atn/AmbiguityInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ArrayPredictionContext.cs b/runtime/CSharp/Atn/ArrayPredictionContext.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ArrayPredictionContext.cs rename to runtime/CSharp/Atn/ArrayPredictionContext.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AtomTransition.cs b/runtime/CSharp/Atn/AtomTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/AtomTransition.cs rename to runtime/CSharp/Atn/AtomTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/BasicBlockStartState.cs b/runtime/CSharp/Atn/BasicBlockStartState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/BasicBlockStartState.cs rename to runtime/CSharp/Atn/BasicBlockStartState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/BasicState.cs b/runtime/CSharp/Atn/BasicState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/BasicState.cs rename to runtime/CSharp/Atn/BasicState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/BlockEndState.cs b/runtime/CSharp/Atn/BlockEndState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/BlockEndState.cs rename to runtime/CSharp/Atn/BlockEndState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/BlockStartState.cs b/runtime/CSharp/Atn/BlockStartState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/BlockStartState.cs rename to runtime/CSharp/Atn/BlockStartState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ConflictInfo.cs b/runtime/CSharp/Atn/ConflictInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ConflictInfo.cs rename to runtime/CSharp/Atn/ConflictInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs b/runtime/CSharp/Atn/ContextSensitivityInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ContextSensitivityInfo.cs rename to runtime/CSharp/Atn/ContextSensitivityInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/DecisionEventInfo.cs b/runtime/CSharp/Atn/DecisionEventInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/DecisionEventInfo.cs rename to runtime/CSharp/Atn/DecisionEventInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/DecisionInfo.cs b/runtime/CSharp/Atn/DecisionInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/DecisionInfo.cs rename to runtime/CSharp/Atn/DecisionInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/DecisionState.cs b/runtime/CSharp/Atn/DecisionState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/DecisionState.cs rename to runtime/CSharp/Atn/DecisionState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/EmptyPredictionContext.cs b/runtime/CSharp/Atn/EmptyPredictionContext.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/EmptyPredictionContext.cs rename to runtime/CSharp/Atn/EmptyPredictionContext.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs b/runtime/CSharp/Atn/EpsilonTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/EpsilonTransition.cs rename to runtime/CSharp/Atn/EpsilonTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs b/runtime/CSharp/Atn/ErrorInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ErrorInfo.cs rename to runtime/CSharp/Atn/ErrorInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs b/runtime/CSharp/Atn/ILexerAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ILexerAction.cs rename to runtime/CSharp/Atn/ILexerAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs b/runtime/CSharp/Atn/LL1Analyzer.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LL1Analyzer.cs rename to runtime/CSharp/Atn/LL1Analyzer.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNConfig.cs b/runtime/CSharp/Atn/LexerATNConfig.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNConfig.cs rename to runtime/CSharp/Atn/LexerATNConfig.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs b/runtime/CSharp/Atn/LexerATNSimulator.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerATNSimulator.cs rename to runtime/CSharp/Atn/LexerATNSimulator.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionExecutor.cs b/runtime/CSharp/Atn/LexerActionExecutor.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionExecutor.cs rename to runtime/CSharp/Atn/LexerActionExecutor.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionType.cs b/runtime/CSharp/Atn/LexerActionType.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerActionType.cs rename to runtime/CSharp/Atn/LexerActionType.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerChannelAction.cs b/runtime/CSharp/Atn/LexerChannelAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerChannelAction.cs rename to runtime/CSharp/Atn/LexerChannelAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerCustomAction.cs b/runtime/CSharp/Atn/LexerCustomAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerCustomAction.cs rename to runtime/CSharp/Atn/LexerCustomAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerIndexedCustomAction.cs b/runtime/CSharp/Atn/LexerIndexedCustomAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerIndexedCustomAction.cs rename to runtime/CSharp/Atn/LexerIndexedCustomAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerModeAction.cs b/runtime/CSharp/Atn/LexerModeAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerModeAction.cs rename to runtime/CSharp/Atn/LexerModeAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerMoreAction.cs b/runtime/CSharp/Atn/LexerMoreAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerMoreAction.cs rename to runtime/CSharp/Atn/LexerMoreAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerPopModeAction.cs b/runtime/CSharp/Atn/LexerPopModeAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerPopModeAction.cs rename to runtime/CSharp/Atn/LexerPopModeAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerPushModeAction.cs b/runtime/CSharp/Atn/LexerPushModeAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerPushModeAction.cs rename to runtime/CSharp/Atn/LexerPushModeAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerSkipAction.cs b/runtime/CSharp/Atn/LexerSkipAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerSkipAction.cs rename to runtime/CSharp/Atn/LexerSkipAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerTypeAction.cs b/runtime/CSharp/Atn/LexerTypeAction.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LexerTypeAction.cs rename to runtime/CSharp/Atn/LexerTypeAction.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LookaheadEventInfo.cs b/runtime/CSharp/Atn/LookaheadEventInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LookaheadEventInfo.cs rename to runtime/CSharp/Atn/LookaheadEventInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LoopEndState.cs b/runtime/CSharp/Atn/LoopEndState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/LoopEndState.cs rename to runtime/CSharp/Atn/LoopEndState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/MergeCache.cs b/runtime/CSharp/Atn/MergeCache.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/MergeCache.cs rename to runtime/CSharp/Atn/MergeCache.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/NotSetTransition.cs b/runtime/CSharp/Atn/NotSetTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/NotSetTransition.cs rename to runtime/CSharp/Atn/NotSetTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParseInfo.cs b/runtime/CSharp/Atn/ParseInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParseInfo.cs rename to runtime/CSharp/Atn/ParseInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs b/runtime/CSharp/Atn/ParserATNSimulator.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ParserATNSimulator.cs rename to runtime/CSharp/Atn/ParserATNSimulator.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PlusBlockStartState.cs b/runtime/CSharp/Atn/PlusBlockStartState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PlusBlockStartState.cs rename to runtime/CSharp/Atn/PlusBlockStartState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PlusLoopbackState.cs b/runtime/CSharp/Atn/PlusLoopbackState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PlusLoopbackState.cs rename to runtime/CSharp/Atn/PlusLoopbackState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PrecedencePredicateTransition.cs b/runtime/CSharp/Atn/PrecedencePredicateTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PrecedencePredicateTransition.cs rename to runtime/CSharp/Atn/PrecedencePredicateTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs b/runtime/CSharp/Atn/PredicateEvalInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredicateEvalInfo.cs rename to runtime/CSharp/Atn/PredicateEvalInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredicateTransition.cs b/runtime/CSharp/Atn/PredicateTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredicateTransition.cs rename to runtime/CSharp/Atn/PredicateTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContext.cs b/runtime/CSharp/Atn/PredictionContext.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContext.cs rename to runtime/CSharp/Atn/PredictionContext.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContextCache.cs b/runtime/CSharp/Atn/PredictionContextCache.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionContextCache.cs rename to runtime/CSharp/Atn/PredictionContextCache.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs b/runtime/CSharp/Atn/PredictionMode.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/PredictionMode.cs rename to runtime/CSharp/Atn/PredictionMode.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ProfilingATNSimulator.cs b/runtime/CSharp/Atn/ProfilingATNSimulator.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/ProfilingATNSimulator.cs rename to runtime/CSharp/Atn/ProfilingATNSimulator.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/RangeTransition.cs b/runtime/CSharp/Atn/RangeTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/RangeTransition.cs rename to runtime/CSharp/Atn/RangeTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/RuleStartState.cs b/runtime/CSharp/Atn/RuleStartState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/RuleStartState.cs rename to runtime/CSharp/Atn/RuleStartState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/RuleStopState.cs b/runtime/CSharp/Atn/RuleStopState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/RuleStopState.cs rename to runtime/CSharp/Atn/RuleStopState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/RuleTransition.cs b/runtime/CSharp/Atn/RuleTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/RuleTransition.cs rename to runtime/CSharp/Atn/RuleTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs b/runtime/CSharp/Atn/SemanticContext.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SemanticContext.cs rename to runtime/CSharp/Atn/SemanticContext.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SetTransition.cs b/runtime/CSharp/Atn/SetTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SetTransition.cs rename to runtime/CSharp/Atn/SetTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SimulatorState.cs b/runtime/CSharp/Atn/SimulatorState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SimulatorState.cs rename to runtime/CSharp/Atn/SimulatorState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs b/runtime/CSharp/Atn/SingletonPredictionContext.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/SingletonPredictionContext.cs rename to runtime/CSharp/Atn/SingletonPredictionContext.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/StarBlockStartState.cs b/runtime/CSharp/Atn/StarBlockStartState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/StarBlockStartState.cs rename to runtime/CSharp/Atn/StarBlockStartState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopEntryState.cs b/runtime/CSharp/Atn/StarLoopEntryState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopEntryState.cs rename to runtime/CSharp/Atn/StarLoopEntryState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopbackState.cs b/runtime/CSharp/Atn/StarLoopbackState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/StarLoopbackState.cs rename to runtime/CSharp/Atn/StarLoopbackState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/StateType.cs b/runtime/CSharp/Atn/StateType.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/StateType.cs rename to runtime/CSharp/Atn/StateType.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/TokensStartState.cs b/runtime/CSharp/Atn/TokensStartState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/TokensStartState.cs rename to runtime/CSharp/Atn/TokensStartState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/Transition.cs b/runtime/CSharp/Atn/Transition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/Transition.cs rename to runtime/CSharp/Atn/Transition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/TransitionType.cs b/runtime/CSharp/Atn/TransitionType.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/TransitionType.cs rename to runtime/CSharp/Atn/TransitionType.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/WildcardTransition.cs b/runtime/CSharp/Atn/WildcardTransition.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Atn/WildcardTransition.cs rename to runtime/CSharp/Atn/WildcardTransition.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BailErrorStrategy.cs b/runtime/CSharp/BailErrorStrategy.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BailErrorStrategy.cs rename to runtime/CSharp/BailErrorStrategy.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BaseErrorListener.cs b/runtime/CSharp/BaseErrorListener.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BaseErrorListener.cs rename to runtime/CSharp/BaseErrorListener.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs b/runtime/CSharp/BufferedTokenStream.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs rename to runtime/CSharp/BufferedTokenStream.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CharStreams.cs b/runtime/CSharp/CharStreams.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CharStreams.cs rename to runtime/CSharp/CharStreams.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CommonToken.cs b/runtime/CSharp/CommonToken.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CommonToken.cs rename to runtime/CSharp/CommonToken.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CommonTokenFactory.cs b/runtime/CSharp/CommonTokenFactory.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CommonTokenFactory.cs rename to runtime/CSharp/CommonTokenFactory.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CommonTokenStream.cs b/runtime/CSharp/CommonTokenStream.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/CommonTokenStream.cs rename to runtime/CSharp/CommonTokenStream.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs b/runtime/CSharp/ConsoleErrorListener.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ConsoleErrorListener.cs rename to runtime/CSharp/ConsoleErrorListener.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs b/runtime/CSharp/DefaultErrorStrategy.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/DefaultErrorStrategy.cs rename to runtime/CSharp/DefaultErrorStrategy.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dependents.cs b/runtime/CSharp/Dependents.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dependents.cs rename to runtime/CSharp/Dependents.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap.cs b/runtime/CSharp/Dfa/AbstractEdgeMap.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/AbstractEdgeMap.cs rename to runtime/CSharp/Dfa/AbstractEdgeMap.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/AcceptStateInfo.cs b/runtime/CSharp/Dfa/AcceptStateInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/AcceptStateInfo.cs rename to runtime/CSharp/Dfa/AcceptStateInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap.cs b/runtime/CSharp/Dfa/ArrayEdgeMap.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/ArrayEdgeMap.cs rename to runtime/CSharp/Dfa/ArrayEdgeMap.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/DFA.cs b/runtime/CSharp/Dfa/DFA.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/DFA.cs rename to runtime/CSharp/Dfa/DFA.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/DFASerializer.cs b/runtime/CSharp/Dfa/DFASerializer.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/DFASerializer.cs rename to runtime/CSharp/Dfa/DFASerializer.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs b/runtime/CSharp/Dfa/DFAState.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs rename to runtime/CSharp/Dfa/DFAState.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap.cs b/runtime/CSharp/Dfa/EmptyEdgeMap.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/EmptyEdgeMap.cs rename to runtime/CSharp/Dfa/EmptyEdgeMap.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap.cs b/runtime/CSharp/Dfa/IEdgeMap.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/IEdgeMap.cs rename to runtime/CSharp/Dfa/IEdgeMap.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/LexerDFASerializer.cs b/runtime/CSharp/Dfa/LexerDFASerializer.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/LexerDFASerializer.cs rename to runtime/CSharp/Dfa/LexerDFASerializer.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap.cs b/runtime/CSharp/Dfa/SingletonEdgeMap.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SingletonEdgeMap.cs rename to runtime/CSharp/Dfa/SingletonEdgeMap.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap.cs b/runtime/CSharp/Dfa/SparseEdgeMap.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Dfa/SparseEdgeMap.cs rename to runtime/CSharp/Dfa/SparseEdgeMap.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/DiagnosticErrorListener.cs b/runtime/CSharp/DiagnosticErrorListener.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/DiagnosticErrorListener.cs rename to runtime/CSharp/DiagnosticErrorListener.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/FailedPredicateException.cs b/runtime/CSharp/FailedPredicateException.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/FailedPredicateException.cs rename to runtime/CSharp/FailedPredicateException.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener.cs b/runtime/CSharp/IAntlrErrorListener.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IAntlrErrorListener.cs rename to runtime/CSharp/IAntlrErrorListener.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IAntlrErrorStrategy.cs b/runtime/CSharp/IAntlrErrorStrategy.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IAntlrErrorStrategy.cs rename to runtime/CSharp/IAntlrErrorStrategy.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ICharStream.cs b/runtime/CSharp/ICharStream.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ICharStream.cs rename to runtime/CSharp/ICharStream.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IIntStream.cs b/runtime/CSharp/IIntStream.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IIntStream.cs rename to runtime/CSharp/IIntStream.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs b/runtime/CSharp/IParserErrorListener.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IParserErrorListener.cs rename to runtime/CSharp/IParserErrorListener.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IRecognizer.cs b/runtime/CSharp/IRecognizer.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IRecognizer.cs rename to runtime/CSharp/IRecognizer.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IToken.cs b/runtime/CSharp/IToken.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IToken.cs rename to runtime/CSharp/IToken.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ITokenFactory.cs b/runtime/CSharp/ITokenFactory.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ITokenFactory.cs rename to runtime/CSharp/ITokenFactory.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ITokenSource.cs b/runtime/CSharp/ITokenSource.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ITokenSource.cs rename to runtime/CSharp/ITokenSource.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ITokenStream.cs b/runtime/CSharp/ITokenStream.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ITokenStream.cs rename to runtime/CSharp/ITokenStream.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IVocabulary.cs b/runtime/CSharp/IVocabulary.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IVocabulary.cs rename to runtime/CSharp/IVocabulary.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IWritableToken.cs b/runtime/CSharp/IWritableToken.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/IWritableToken.cs rename to runtime/CSharp/IWritableToken.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/InputMismatchException.cs b/runtime/CSharp/InputMismatchException.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/InputMismatchException.cs rename to runtime/CSharp/InputMismatchException.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/InterpreterRuleContext.cs b/runtime/CSharp/InterpreterRuleContext.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/InterpreterRuleContext.cs rename to runtime/CSharp/InterpreterRuleContext.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Lexer.cs b/runtime/CSharp/Lexer.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Lexer.cs rename to runtime/CSharp/Lexer.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/LexerInterpreter.cs b/runtime/CSharp/LexerInterpreter.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/LexerInterpreter.cs rename to runtime/CSharp/LexerInterpreter.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/LexerNoViableAltException.cs b/runtime/CSharp/LexerNoViableAltException.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/LexerNoViableAltException.cs rename to runtime/CSharp/LexerNoViableAltException.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ListTokenSource.cs b/runtime/CSharp/ListTokenSource.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ListTokenSource.cs rename to runtime/CSharp/ListTokenSource.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Args.cs b/runtime/CSharp/Misc/Args.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Args.cs rename to runtime/CSharp/Misc/Args.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/ArrayList.cs b/runtime/CSharp/Misc/ArrayList.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/ArrayList.cs rename to runtime/CSharp/Misc/ArrayList.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/IIntSet.cs b/runtime/CSharp/Misc/IIntSet.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/IIntSet.cs rename to runtime/CSharp/Misc/IIntSet.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Interval.cs b/runtime/CSharp/Misc/Interval.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Interval.cs rename to runtime/CSharp/Misc/Interval.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/IntervalSet.cs b/runtime/CSharp/Misc/IntervalSet.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/IntervalSet.cs rename to runtime/CSharp/Misc/IntervalSet.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/MultiMap.cs b/runtime/CSharp/Misc/MultiMap.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/MultiMap.cs rename to runtime/CSharp/Misc/MultiMap.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/MurmurHash.cs b/runtime/CSharp/Misc/MurmurHash.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/MurmurHash.cs rename to runtime/CSharp/Misc/MurmurHash.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/NotNullAttribute.cs b/runtime/CSharp/Misc/NotNullAttribute.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/NotNullAttribute.cs rename to runtime/CSharp/Misc/NotNullAttribute.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/NullableAttribute.cs b/runtime/CSharp/Misc/NullableAttribute.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/NullableAttribute.cs rename to runtime/CSharp/Misc/NullableAttribute.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Pair.cs b/runtime/CSharp/Misc/Pair.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Pair.cs rename to runtime/CSharp/Misc/Pair.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs b/runtime/CSharp/Misc/ParseCanceledException.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/ParseCanceledException.cs rename to runtime/CSharp/Misc/ParseCanceledException.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs b/runtime/CSharp/Misc/RuleDependencyChecker.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/RuleDependencyChecker.cs rename to runtime/CSharp/Misc/RuleDependencyChecker.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs b/runtime/CSharp/Misc/Utils.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Misc/Utils.cs rename to runtime/CSharp/Misc/Utils.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/NoViableAltException.cs b/runtime/CSharp/NoViableAltException.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/NoViableAltException.cs rename to runtime/CSharp/NoViableAltException.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs b/runtime/CSharp/Parser.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Parser.cs rename to runtime/CSharp/Parser.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs b/runtime/CSharp/ParserInterpreter.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserInterpreter.cs rename to runtime/CSharp/ParserInterpreter.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs b/runtime/CSharp/ParserRuleContext.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ParserRuleContext.cs rename to runtime/CSharp/ParserRuleContext.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs b/runtime/CSharp/Properties/AssemblyInfo.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs rename to runtime/CSharp/Properties/AssemblyInfo.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener.cs b/runtime/CSharp/ProxyErrorListener.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ProxyErrorListener.cs rename to runtime/CSharp/ProxyErrorListener.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ProxyParserErrorListener.cs b/runtime/CSharp/ProxyParserErrorListener.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/ProxyParserErrorListener.cs rename to runtime/CSharp/ProxyParserErrorListener.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/RecognitionException.cs b/runtime/CSharp/RecognitionException.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/RecognitionException.cs rename to runtime/CSharp/RecognitionException.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Recognizer.cs b/runtime/CSharp/Recognizer.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Recognizer.cs rename to runtime/CSharp/Recognizer.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/RuleContext.cs b/runtime/CSharp/RuleContext.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/RuleContext.cs rename to runtime/CSharp/RuleContext.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/RuleDependencyAttribute.cs b/runtime/CSharp/RuleDependencyAttribute.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/RuleDependencyAttribute.cs rename to runtime/CSharp/RuleDependencyAttribute.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/RuleVersionAttribute.cs b/runtime/CSharp/RuleVersionAttribute.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/RuleVersionAttribute.cs rename to runtime/CSharp/RuleVersionAttribute.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Arrays.cs b/runtime/CSharp/Sharpen/Arrays.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Arrays.cs rename to runtime/CSharp/Sharpen/Arrays.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/AtomicReference.cs b/runtime/CSharp/Sharpen/AtomicReference.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/AtomicReference.cs rename to runtime/CSharp/Sharpen/AtomicReference.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/BitSet.cs b/runtime/CSharp/Sharpen/BitSet.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/BitSet.cs rename to runtime/CSharp/Sharpen/BitSet.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs b/runtime/CSharp/Sharpen/Collections.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs rename to runtime/CSharp/Sharpen/Collections.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/DictionaryExtensions.cs b/runtime/CSharp/Sharpen/DictionaryExtensions.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/DictionaryExtensions.cs rename to runtime/CSharp/Sharpen/DictionaryExtensions.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/ListExtensions.cs b/runtime/CSharp/Sharpen/ListExtensions.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/ListExtensions.cs rename to runtime/CSharp/Sharpen/ListExtensions.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Runtime.cs b/runtime/CSharp/Sharpen/Runtime.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/Runtime.cs rename to runtime/CSharp/Sharpen/Runtime.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/SequenceEqualityComparer.cs b/runtime/CSharp/Sharpen/SequenceEqualityComparer.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Sharpen/SequenceEqualityComparer.cs rename to runtime/CSharp/Sharpen/SequenceEqualityComparer.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs b/runtime/CSharp/TokenStreamRewriter.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/TokenStreamRewriter.cs rename to runtime/CSharp/TokenStreamRewriter.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/TokenTypes.cs b/runtime/CSharp/TokenTypes.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/TokenTypes.cs rename to runtime/CSharp/TokenTypes.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/AbstractParseTreeVisitor.cs b/runtime/CSharp/Tree/AbstractParseTreeVisitor.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/AbstractParseTreeVisitor.cs rename to runtime/CSharp/Tree/AbstractParseTreeVisitor.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ErrorNodeImpl.cs b/runtime/CSharp/Tree/ErrorNodeImpl.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ErrorNodeImpl.cs rename to runtime/CSharp/Tree/ErrorNodeImpl.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IErrorNode.cs b/runtime/CSharp/Tree/IErrorNode.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IErrorNode.cs rename to runtime/CSharp/Tree/IErrorNode.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTree.cs b/runtime/CSharp/Tree/IParseTree.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTree.cs rename to runtime/CSharp/Tree/IParseTree.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeListener.cs b/runtime/CSharp/Tree/IParseTreeListener.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeListener.cs rename to runtime/CSharp/Tree/IParseTreeListener.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor.cs b/runtime/CSharp/Tree/IParseTreeVisitor.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IParseTreeVisitor.cs rename to runtime/CSharp/Tree/IParseTreeVisitor.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IRuleNode.cs b/runtime/CSharp/Tree/IRuleNode.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/IRuleNode.cs rename to runtime/CSharp/Tree/IRuleNode.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ISyntaxTree.cs b/runtime/CSharp/Tree/ISyntaxTree.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ISyntaxTree.cs rename to runtime/CSharp/Tree/ISyntaxTree.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ITerminalNode.cs b/runtime/CSharp/Tree/ITerminalNode.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ITerminalNode.cs rename to runtime/CSharp/Tree/ITerminalNode.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ITree.cs b/runtime/CSharp/Tree/ITree.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ITree.cs rename to runtime/CSharp/Tree/ITree.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty.cs b/runtime/CSharp/Tree/ParseTreeProperty.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeProperty.cs rename to runtime/CSharp/Tree/ParseTreeProperty.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeWalker.cs b/runtime/CSharp/Tree/ParseTreeWalker.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/ParseTreeWalker.cs rename to runtime/CSharp/Tree/ParseTreeWalker.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/Chunk.cs b/runtime/CSharp/Tree/Pattern/Chunk.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/Chunk.cs rename to runtime/CSharp/Tree/Pattern/Chunk.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreeMatch.cs b/runtime/CSharp/Tree/Pattern/ParseTreeMatch.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreeMatch.cs rename to runtime/CSharp/Tree/Pattern/ParseTreeMatch.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePattern.cs b/runtime/CSharp/Tree/Pattern/ParseTreePattern.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePattern.cs rename to runtime/CSharp/Tree/Pattern/ParseTreePattern.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePatternMatcher.cs b/runtime/CSharp/Tree/Pattern/ParseTreePatternMatcher.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/ParseTreePatternMatcher.cs rename to runtime/CSharp/Tree/Pattern/ParseTreePatternMatcher.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/RuleTagToken.cs b/runtime/CSharp/Tree/Pattern/RuleTagToken.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/RuleTagToken.cs rename to runtime/CSharp/Tree/Pattern/RuleTagToken.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TagChunk.cs b/runtime/CSharp/Tree/Pattern/TagChunk.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TagChunk.cs rename to runtime/CSharp/Tree/Pattern/TagChunk.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TextChunk.cs b/runtime/CSharp/Tree/Pattern/TextChunk.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TextChunk.cs rename to runtime/CSharp/Tree/Pattern/TextChunk.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TokenTagToken.cs b/runtime/CSharp/Tree/Pattern/TokenTagToken.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Pattern/TokenTagToken.cs rename to runtime/CSharp/Tree/Pattern/TokenTagToken.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/TerminalNodeImpl.cs b/runtime/CSharp/Tree/TerminalNodeImpl.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/TerminalNodeImpl.cs rename to runtime/CSharp/Tree/TerminalNodeImpl.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Trees.cs b/runtime/CSharp/Tree/Trees.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Trees.cs rename to runtime/CSharp/Tree/Trees.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPath.cs b/runtime/CSharp/Tree/Xpath/XPath.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPath.cs rename to runtime/CSharp/Tree/Xpath/XPath.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathElement.cs b/runtime/CSharp/Tree/Xpath/XPathElement.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathElement.cs rename to runtime/CSharp/Tree/Xpath/XPathElement.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexer.cs b/runtime/CSharp/Tree/Xpath/XPathLexer.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexer.cs rename to runtime/CSharp/Tree/Xpath/XPathLexer.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexer.g4 b/runtime/CSharp/Tree/Xpath/XPathLexer.g4 similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexer.g4 rename to runtime/CSharp/Tree/Xpath/XPathLexer.g4 diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexer.tokens b/runtime/CSharp/Tree/Xpath/XPathLexer.tokens similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexer.tokens rename to runtime/CSharp/Tree/Xpath/XPathLexer.tokens diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexerErrorListener.cs b/runtime/CSharp/Tree/Xpath/XPathLexerErrorListener.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathLexerErrorListener.cs rename to runtime/CSharp/Tree/Xpath/XPathLexerErrorListener.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleAnywhereElement.cs b/runtime/CSharp/Tree/Xpath/XPathRuleAnywhereElement.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleAnywhereElement.cs rename to runtime/CSharp/Tree/Xpath/XPathRuleAnywhereElement.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleElement.cs b/runtime/CSharp/Tree/Xpath/XPathRuleElement.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathRuleElement.cs rename to runtime/CSharp/Tree/Xpath/XPathRuleElement.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenAnywhereElement.cs b/runtime/CSharp/Tree/Xpath/XPathTokenAnywhereElement.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenAnywhereElement.cs rename to runtime/CSharp/Tree/Xpath/XPathTokenAnywhereElement.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenElement.cs b/runtime/CSharp/Tree/Xpath/XPathTokenElement.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathTokenElement.cs rename to runtime/CSharp/Tree/Xpath/XPathTokenElement.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardAnywhereElement.cs b/runtime/CSharp/Tree/Xpath/XPathWildcardAnywhereElement.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardAnywhereElement.cs rename to runtime/CSharp/Tree/Xpath/XPathWildcardAnywhereElement.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardElement.cs b/runtime/CSharp/Tree/Xpath/XPathWildcardElement.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Tree/Xpath/XPathWildcardElement.cs rename to runtime/CSharp/Tree/Xpath/XPathWildcardElement.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs b/runtime/CSharp/UnbufferedCharStream.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/UnbufferedCharStream.cs rename to runtime/CSharp/UnbufferedCharStream.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/UnbufferedTokenStream.cs b/runtime/CSharp/UnbufferedTokenStream.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/UnbufferedTokenStream.cs rename to runtime/CSharp/UnbufferedTokenStream.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Vocabulary.cs b/runtime/CSharp/Vocabulary.cs similarity index 100% rename from runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Vocabulary.cs rename to runtime/CSharp/Vocabulary.cs diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.sln b/runtime/CSharp/runtime/CSharp/Antlr4.sln deleted file mode 100644 index 1f63a3fa4..000000000 --- a/runtime/CSharp/runtime/CSharp/Antlr4.sln +++ /dev/null @@ -1,34 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26114.2 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr4.Runtime", "Antlr4.Runtime\Antlr4.Runtime.csproj", "{A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|Any CPU.Build.0 = Release|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|x64.ActiveCfg = Debug|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|x64.Build.0 = Debug|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|x86.ActiveCfg = Debug|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Debug|x86.Build.0 = Debug|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|x64.ActiveCfg = Release|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|x64.Build.0 = Release|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|x86.ActiveCfg = Release|Any CPU - {A90A2A23-E922-407F-BDB8-C88E6CA1AE4F}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/tool-testsuite/pom.xml b/tool-testsuite/pom.xml index 6f1c40b6d..06e149fb6 100644 --- a/tool-testsuite/pom.xml +++ b/tool-testsuite/pom.xml @@ -67,7 +67,6 @@ ../../antlr4-python2/src ../../antlr4-python3/src - ../../antlr4-csharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.mono.csproj ../../antlr4-cpp/src ../../antlr4-javascript/src From 925c0a6b8baf38d5419f07a974a9f73dfc292753 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Mon, 28 Dec 2020 16:06:19 +0300 Subject: [PATCH 33/36] Fix CI scripts; use dotnet everywhere for testing; remove before-install-linux-csharp.sh, run-tests-csharp.sh --- .travis.yml | 7 +- .travis/before-install-linux-csharp.sh | 8 - .travis/before-install-linux-dotnet.sh | 12 +- .travis/before-install-osx-dotnet.sh | 1134 +++++++++++++++++++++++- .travis/run-tests-csharp.sh | 5 - .travis/run-tests-dotnet.sh | 13 +- appveyor.yml | 4 +- 7 files changed, 1122 insertions(+), 61 deletions(-) delete mode 100755 .travis/before-install-linux-csharp.sh delete mode 100755 .travis/run-tests-csharp.sh diff --git a/.travis.yml b/.travis.yml index b2acb6982..ca525bd4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -147,7 +147,9 @@ matrix: stage: smoke-test - os: linux jdk: openjdk8 - env: TARGET=csharp + env: + - TARGET=dotnet + - GROUP=MAIN stage: main-test - os: linux jdk: openjdk8 @@ -162,21 +164,18 @@ matrix: stage: main-test - os: linux jdk: openjdk8 - dist: trusty env: - TARGET=dotnet - GROUP=LEXER stage: extended-test - os: linux jdk: openjdk8 - dist: trusty env: - TARGET=dotnet - GROUP=PARSER stage: extended-test - os: linux jdk: openjdk8 - dist: trusty env: - TARGET=dotnet - GROUP=RECURSION diff --git a/.travis/before-install-linux-csharp.sh b/.travis/before-install-linux-csharp.sh deleted file mode 100755 index 0872a4635..000000000 --- a/.travis/before-install-linux-csharp.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF -echo "deb http://download.mono-project.com/repo/debian xenial main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list -sudo apt-get update -qq -sudo apt-get install -qq mono-complete diff --git a/.travis/before-install-linux-dotnet.sh b/.travis/before-install-linux-dotnet.sh index 816044f40..57ff8ed04 100755 --- a/.travis/before-install-linux-dotnet.sh +++ b/.travis/before-install-linux-dotnet.sh @@ -2,9 +2,9 @@ set -euo pipefail -# install dotnet -sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' -sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893 -sudo apt-get update -sudo apt-get --allow-unauthenticated install dotnet-dev-1.0.4 - +wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb +sudo dpkg -i packages-microsoft-prod.deb +sudo apt-get update; \ + sudo apt-get install -y apt-transport-https && \ + sudo apt-get update && \ + sudo apt-get install -y dotnet-sdk-3.1 \ No newline at end of file diff --git a/.travis/before-install-osx-dotnet.sh b/.travis/before-install-osx-dotnet.sh index a4b187709..147f974de 100755 --- a/.travis/before-install-osx-dotnet.sh +++ b/.travis/before-install-osx-dotnet.sh @@ -1,37 +1,1111 @@ -#!/bin/bash +#!/usr/bin/env bash -set -euo pipefail +# Copied from https://dot.net/v1/dotnet-install.sh (see also https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#recommended-version) -cache_dir="$HOME/Library/Caches/Antlr4" -dotnet_url='https://download.microsoft.com/download/F/4/F/F4FCB6EC-5F05-4DF8-822C-FF013DF1B17F/dotnet-dev-osx-x64.1.1.4.pkg' -dotnet_file=$(basename "$dotnet_url") -dotnet_shasum='dc46d93716db8bea8cc3c668088cc9e39384b5a4' +# Copyright (c) .NET Foundation and contributors. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. -thisdir=$(dirname "$0") +# Stop script on NZEC +set -e +# Stop script if unbound variable found (use ${var:-} if intentional) +set -u +# By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success +# This is causing it to fail +set -o pipefail -# OpenSSL setup for dotnet core -mkdir -p /usr/local/lib -ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/ -ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/ +# Use in the the functions: eval $invocation +invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"' -# download dotnet core -mkdir -p "$cache_dir" -(cd "$cache_dir" - if [ -f "$dotnet_file" ] - then - if ! shasum -s -c <<<"$dotnet_shasum $dotnet_file" - then - rm -f "$dotnet_file" - fi - fi - if ! [ -f "$dotnet_file" ] - then - curl "$dotnet_url" -o "$dotnet_file" - fi -) +# standard output may be used as a return value in the functions +# we need a way to write text on the screen in the functions so that +# it won't interfere with the return value. +# Exposing stream 3 as a pipe to standard output of the script itself +exec 3>&1 -# install dotnet core -sudo installer -pkg "$cache_dir/$dotnet_file" -target / +# Setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors. +# See if stdout is a terminal +if [ -t 1 ] && command -v tput > /dev/null; then + # see if it supports colors + ncolors=$(tput colors) + if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then + bold="$(tput bold || echo)" + normal="$(tput sgr0 || echo)" + black="$(tput setaf 0 || echo)" + red="$(tput setaf 1 || echo)" + green="$(tput setaf 2 || echo)" + yellow="$(tput setaf 3 || echo)" + blue="$(tput setaf 4 || echo)" + magenta="$(tput setaf 5 || echo)" + cyan="$(tput setaf 6 || echo)" + white="$(tput setaf 7 || echo)" + fi +fi + +say_warning() { + printf "%b\n" "${yellow:-}dotnet_install: Warning: $1${normal:-}" +} + +say_err() { + printf "%b\n" "${red:-}dotnet_install: Error: $1${normal:-}" >&2 +} + +say() { + # using stream 3 (defined in the beginning) to not interfere with stdout of functions + # which may be used as return value + printf "%b\n" "${cyan:-}dotnet-install:${normal:-} $1" >&3 +} + +say_verbose() { + if [ "$verbose" = true ]; then + say "$1" + fi +} + +# This platform list is finite - if the SDK/Runtime has supported Linux distribution-specific assets, +# then and only then should the Linux distribution appear in this list. +# Adding a Linux distribution to this list does not imply distribution-specific support. +get_legacy_os_name_from_platform() { + eval $invocation + + platform="$1" + case "$platform" in + "centos.7") + echo "centos" + return 0 + ;; + "debian.8") + echo "debian" + return 0 + ;; + "debian.9") + echo "debian.9" + return 0 + ;; + "fedora.23") + echo "fedora.23" + return 0 + ;; + "fedora.24") + echo "fedora.24" + return 0 + ;; + "fedora.27") + echo "fedora.27" + return 0 + ;; + "fedora.28") + echo "fedora.28" + return 0 + ;; + "opensuse.13.2") + echo "opensuse.13.2" + return 0 + ;; + "opensuse.42.1") + echo "opensuse.42.1" + return 0 + ;; + "opensuse.42.3") + echo "opensuse.42.3" + return 0 + ;; + "rhel.7"*) + echo "rhel" + return 0 + ;; + "ubuntu.14.04") + echo "ubuntu" + return 0 + ;; + "ubuntu.16.04") + echo "ubuntu.16.04" + return 0 + ;; + "ubuntu.16.10") + echo "ubuntu.16.10" + return 0 + ;; + "ubuntu.18.04") + echo "ubuntu.18.04" + return 0 + ;; + "alpine.3.4.3") + echo "alpine" + return 0 + ;; + esac + return 1 +} + +get_linux_platform_name() { + eval $invocation + + if [ -n "$runtime_id" ]; then + echo "${runtime_id%-*}" + return 0 + else + if [ -e /etc/os-release ]; then + . /etc/os-release + echo "$ID${VERSION_ID:+.${VERSION_ID}}" + return 0 + elif [ -e /etc/redhat-release ]; then + local redhatRelease=$(&1 || true) | grep -q musl +} + +get_current_os_name() { + eval $invocation + + local uname=$(uname) + if [ "$uname" = "Darwin" ]; then + echo "osx" + return 0 + elif [ "$uname" = "FreeBSD" ]; then + echo "freebsd" + return 0 + elif [ "$uname" = "Linux" ]; then + local linux_platform_name + linux_platform_name="$(get_linux_platform_name)" || { echo "linux" && return 0 ; } + + if [ "$linux_platform_name" = "rhel.6" ]; then + echo $linux_platform_name + return 0 + elif is_musl_based_distro; then + echo "linux-musl" + return 0 + else + echo "linux" + return 0 + fi + fi + + say_err "OS name could not be detected: UName = $uname" + return 1 +} + +get_legacy_os_name() { + eval $invocation + + local uname=$(uname) + if [ "$uname" = "Darwin" ]; then + echo "osx" + return 0 + elif [ -n "$runtime_id" ]; then + echo $(get_legacy_os_name_from_platform "${runtime_id%-*}" || echo "${runtime_id%-*}") + return 0 + else + if [ -e /etc/os-release ]; then + . /etc/os-release + os=$(get_legacy_os_name_from_platform "$ID${VERSION_ID:+.${VERSION_ID}}" || echo "") + if [ -n "$os" ]; then + echo "$os" + return 0 + fi + fi + fi + + say_verbose "Distribution specific OS name and version could not be detected: UName = $uname" + return 1 +} + +machine_has() { + eval $invocation + + hash "$1" > /dev/null 2>&1 + return $? +} + + +check_min_reqs() { + local hasMinimum=false + if machine_has "curl"; then + hasMinimum=true + elif machine_has "wget"; then + hasMinimum=true + fi + + if [ "$hasMinimum" = "false" ]; then + say_err "curl (recommended) or wget are required to download dotnet. Install missing prerequisite to proceed." + return 1 + fi + return 0 +} + +# args: +# input - $1 +to_lowercase() { + #eval $invocation + + echo "$1" | tr '[:upper:]' '[:lower:]' + return 0 +} + +# args: +# input - $1 +remove_trailing_slash() { + #eval $invocation + + local input="${1:-}" + echo "${input%/}" + return 0 +} + +# args: +# input - $1 +remove_beginning_slash() { + #eval $invocation + + local input="${1:-}" + echo "${input#/}" + return 0 +} + +# args: +# root_path - $1 +# child_path - $2 - this parameter can be empty +combine_paths() { + eval $invocation + + # TODO: Consider making it work with any number of paths. For now: + if [ ! -z "${3:-}" ]; then + say_err "combine_paths: Function takes two parameters." + return 1 + fi + + local root_path="$(remove_trailing_slash "$1")" + local child_path="$(remove_beginning_slash "${2:-}")" + say_verbose "combine_paths: root_path=$root_path" + say_verbose "combine_paths: child_path=$child_path" + echo "$root_path/$child_path" + return 0 +} + +get_machine_architecture() { + eval $invocation + + if command -v uname > /dev/null; then + CPUName=$(uname -m) + case $CPUName in + armv7l) + echo "arm" + return 0 + ;; + aarch64) + echo "arm64" + return 0 + ;; + esac + fi + + # Always default to 'x64' + echo "x64" + return 0 +} + +# args: +# architecture - $1 +get_normalized_architecture_from_architecture() { + eval $invocation + + local architecture="$(to_lowercase "$1")" + case "$architecture" in + \) + echo "$(get_normalized_architecture_from_architecture "$(get_machine_architecture)")" + return 0 + ;; + amd64|x64) + echo "x64" + return 0 + ;; + arm) + echo "arm" + return 0 + ;; + arm64) + echo "arm64" + return 0 + ;; + esac + + say_err "Architecture \`$architecture\` not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues" + return 1 +} + +# The version text returned from the feeds is a 1-line or 2-line string: +# For the SDK and the dotnet runtime (2 lines): +# Line 1: # commit_hash +# Line 2: # 4-part version +# For the aspnetcore runtime (1 line): +# Line 1: # 4-part version + +# args: +# version_text - stdin +get_version_from_version_info() { + eval $invocation + + cat | tail -n 1 | sed 's/\r$//' + return 0 +} + +# args: +# install_root - $1 +# relative_path_to_package - $2 +# specific_version - $3 +is_dotnet_package_installed() { + eval $invocation + + local install_root="$1" + local relative_path_to_package="$2" + local specific_version="${3//[$'\t\r\n']}" + + local dotnet_package_path="$(combine_paths "$(combine_paths "$install_root" "$relative_path_to_package")" "$specific_version")" + say_verbose "is_dotnet_package_installed: dotnet_package_path=$dotnet_package_path" + + if [ -d "$dotnet_package_path" ]; then + return 0 + else + return 1 + fi +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# coherent - $4 +get_latest_version_info() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local coherent="$4" + + local version_file_url=null + if [[ "$runtime" == "dotnet" ]]; then + version_file_url="$uncached_feed/Runtime/$channel/latest.version" + elif [[ "$runtime" == "aspnetcore" ]]; then + version_file_url="$uncached_feed/aspnetcore/Runtime/$channel/latest.version" + elif [ -z "$runtime" ]; then + if [ "$coherent" = true ]; then + version_file_url="$uncached_feed/Sdk/$channel/latest.coherent.version" + else + version_file_url="$uncached_feed/Sdk/$channel/latest.version" + fi + else + say_err "Invalid value for \$runtime" + return 1 + fi + say_verbose "get_latest_version_info: latest url: $version_file_url" + + download "$version_file_url" + return $? +} + +# args: +# json_file - $1 +parse_jsonfile_for_version() { + eval $invocation + + local json_file="$1" + if [ ! -f "$json_file" ]; then + say_err "Unable to find \`$json_file\`" + return 1 + fi + + sdk_section=$(cat $json_file | awk '/"sdk"/,/}/') + if [ -z "$sdk_section" ]; then + say_err "Unable to parse the SDK node in \`$json_file\`" + return 1 + fi + + sdk_list=$(echo $sdk_section | awk -F"[{}]" '{print $2}') + sdk_list=${sdk_list//[\" ]/} + sdk_list=${sdk_list//,/$'\n'} + + local version_info="" + while read -r line; do + IFS=: + while read -r key value; do + if [[ "$key" == "version" ]]; then + version_info=$value + fi + done <<< "$line" + done <<< "$sdk_list" + if [ -z "$version_info" ]; then + say_err "Unable to find the SDK:version node in \`$json_file\`" + return 1 + fi + + unset IFS; + echo "$version_info" + return 0 +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# version - $4 +# json_file - $5 +get_specific_version_from_version() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local version="$(to_lowercase "$4")" + local json_file="$5" + + if [ -z "$json_file" ]; then + case "$version" in + latest) + local version_info + version_info="$(get_latest_version_info "$azure_feed" "$channel" "$normalized_architecture" false)" || return 1 + say_verbose "get_specific_version_from_version: version_info=$version_info" + echo "$version_info" | get_version_from_version_info + return 0 + ;; + coherent) + local version_info + version_info="$(get_latest_version_info "$azure_feed" "$channel" "$normalized_architecture" true)" || return 1 + say_verbose "get_specific_version_from_version: version_info=$version_info" + echo "$version_info" | get_version_from_version_info + return 0 + ;; + *) + echo "$version" + return 0 + ;; + esac + else + local version_info + version_info="$(parse_jsonfile_for_version "$json_file")" || return 1 + echo "$version_info" + return 0 + fi +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# specific_version - $4 +construct_download_link() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local specific_version="${4//[$'\t\r\n']}" + local specific_product_version="$(get_specific_product_version "$1" "$4")" + + local osname + osname="$(get_current_os_name)" || return 1 + + local download_link=null + if [[ "$runtime" == "dotnet" ]]; then + download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz" + elif [[ "$runtime" == "aspnetcore" ]]; then + download_link="$azure_feed/aspnetcore/Runtime/$specific_version/aspnetcore-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz" + elif [ -z "$runtime" ]; then + download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_product_version-$osname-$normalized_architecture.tar.gz" + else + return 1 + fi + + echo "$download_link" + return 0 +} + +# args: +# azure_feed - $1 +# specific_version - $2 +get_specific_product_version() { + # If we find a 'productVersion.txt' at the root of any folder, we'll use its contents + # to resolve the version of what's in the folder, superseding the specified version. + eval $invocation + + local azure_feed="$1" + local specific_version="${2//[$'\t\r\n']}" + local specific_product_version=$specific_version + + local download_link=null + if [[ "$runtime" == "dotnet" ]]; then + download_link="$azure_feed/Runtime/$specific_version/productVersion.txt${feed_credential}" + elif [[ "$runtime" == "aspnetcore" ]]; then + download_link="$azure_feed/aspnetcore/Runtime/$specific_version/productVersion.txt${feed_credential}" + elif [ -z "$runtime" ]; then + download_link="$azure_feed/Sdk/$specific_version/productVersion.txt${feed_credential}" + else + return 1 + fi + + if machine_has "curl" + then + specific_product_version=$(curl -s --fail "$download_link") + if [ $? -ne 0 ] + then + specific_product_version=$specific_version + fi + elif machine_has "wget" + then + specific_product_version=$(wget -qO- "$download_link") + if [ $? -ne 0 ] + then + specific_product_version=$specific_version + fi + fi + specific_product_version="${specific_product_version//[$'\t\r\n']}" + + echo "$specific_product_version" + return 0 +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# specific_version - $4 +construct_legacy_download_link() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local specific_version="${4//[$'\t\r\n']}" + + local distro_specific_osname + distro_specific_osname="$(get_legacy_os_name)" || return 1 + + local legacy_download_link=null + if [[ "$runtime" == "dotnet" ]]; then + legacy_download_link="$azure_feed/Runtime/$specific_version/dotnet-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" + elif [ -z "$runtime" ]; then + legacy_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" + else + return 1 + fi + + echo "$legacy_download_link" + return 0 +} + +get_user_install_path() { + eval $invocation + + if [ ! -z "${DOTNET_INSTALL_DIR:-}" ]; then + echo "$DOTNET_INSTALL_DIR" + else + echo "$HOME/.dotnet" + fi + return 0 +} + +# args: +# install_dir - $1 +resolve_installation_path() { + eval $invocation + + local install_dir=$1 + if [ "$install_dir" = "" ]; then + local user_install_path="$(get_user_install_path)" + say_verbose "resolve_installation_path: user_install_path=$user_install_path" + echo "$user_install_path" + return 0 + fi + + echo "$install_dir" + return 0 +} + +# args: +# relative_or_absolute_path - $1 +get_absolute_path() { + eval $invocation + + local relative_or_absolute_path=$1 + echo "$(cd "$(dirname "$1")" && pwd -P)/$(basename "$1")" + return 0 +} + +# args: +# input_files - stdin +# root_path - $1 +# out_path - $2 +# override - $3 +copy_files_or_dirs_from_list() { + eval $invocation + + local root_path="$(remove_trailing_slash "$1")" + local out_path="$(remove_trailing_slash "$2")" + local override="$3" + local osname="$(get_current_os_name)" + local override_switch=$( + if [ "$override" = false ]; then + if [ "$osname" = "linux-musl" ]; then + printf -- "-u"; + else + printf -- "-n"; + fi + fi) + + cat | uniq | while read -r file_path; do + local path="$(remove_beginning_slash "${file_path#$root_path}")" + local target="$out_path/$path" + if [ "$override" = true ] || (! ([ -d "$target" ] || [ -e "$target" ])); then + mkdir -p "$out_path/$(dirname "$path")" + if [ -d "$target" ]; then + rm -rf "$target" + fi + cp -R $override_switch "$root_path/$path" "$target" + fi + done +} + +# args: +# zip_path - $1 +# out_path - $2 +extract_dotnet_package() { + eval $invocation + + local zip_path="$1" + local out_path="$2" + + local temp_out_path="$(mktemp -d "$temporary_file_template")" + + local failed=false + tar -xzf "$zip_path" -C "$temp_out_path" > /dev/null || failed=true + + local folders_with_version_regex='^.*/[0-9]+\.[0-9]+[^/]+/' + find "$temp_out_path" -type f | grep -Eo "$folders_with_version_regex" | sort | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" false + find "$temp_out_path" -type f | grep -Ev "$folders_with_version_regex" | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" "$override_non_versioned_files" + + rm -rf "$temp_out_path" + + if [ "$failed" = true ]; then + say_err "Extraction failed" + return 1 + fi +} + +# args: +# remote_path - $1 +# [out_path] - $2 - stdout if not provided +download() { + eval $invocation + + local remote_path="$1" + local out_path="${2:-}" + + if [[ "$remote_path" != "http"* ]]; then + cp "$remote_path" "$out_path" + return $? + fi + + local failed=false + if machine_has "curl"; then + downloadcurl "$remote_path" "$out_path" || failed=true + elif machine_has "wget"; then + downloadwget "$remote_path" "$out_path" || failed=true + else + failed=true + fi + if [ "$failed" = true ]; then + say_verbose "Download failed: $remote_path" + return 1 + fi + return 0 +} + +downloadcurl() { + eval $invocation + local remote_path="$1" + local out_path="${2:-}" + + # Append feed_credential as late as possible before calling curl to avoid logging feed_credential + remote_path="${remote_path}${feed_credential}" + + local curl_options="--retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs " + local failed=false + if [ -z "$out_path" ]; then + curl $curl_options "$remote_path" || failed=true + else + curl $curl_options -o "$out_path" "$remote_path" || failed=true + fi + if [ "$failed" = true ]; then + say_verbose "Curl download failed" + return 1 + fi + return 0 +} + +downloadwget() { + eval $invocation + local remote_path="$1" + local out_path="${2:-}" + + # Append feed_credential as late as possible before calling wget to avoid logging feed_credential + remote_path="${remote_path}${feed_credential}" + local wget_options="--tries 20 --waitretry 2 --connect-timeout 15 " + local failed=false + if [ -z "$out_path" ]; then + wget -q $wget_options -O - "$remote_path" || failed=true + else + wget $wget_options -O "$out_path" "$remote_path" || failed=true + fi + if [ "$failed" = true ]; then + say_verbose "Wget download failed" + return 1 + fi + return 0 +} + +calculate_vars() { + eval $invocation + valid_legacy_download_link=true + + normalized_architecture="$(get_normalized_architecture_from_architecture "$architecture")" + say_verbose "normalized_architecture=$normalized_architecture" + + specific_version="$(get_specific_version_from_version "$azure_feed" "$channel" "$normalized_architecture" "$version" "$json_file")" + specific_product_version="$(get_specific_product_version "$azure_feed" "$specific_version")" + say_verbose "specific_version=$specific_version" + if [ -z "$specific_version" ]; then + say_err "Could not resolve version information." + return 1 + fi + + download_link="$(construct_download_link "$azure_feed" "$channel" "$normalized_architecture" "$specific_version")" + say_verbose "Constructed primary named payload URL: $download_link" + + legacy_download_link="$(construct_legacy_download_link "$azure_feed" "$channel" "$normalized_architecture" "$specific_version")" || valid_legacy_download_link=false + + if [ "$valid_legacy_download_link" = true ]; then + say_verbose "Constructed legacy named payload URL: $legacy_download_link" + else + say_verbose "Cound not construct a legacy_download_link; omitting..." + fi + + install_root="$(resolve_installation_path "$install_dir")" + say_verbose "InstallRoot: $install_root" +} + +install_dotnet() { + eval $invocation + local download_failed=false + local asset_name='' + local asset_relative_path='' + + if [[ "$runtime" == "dotnet" ]]; then + asset_relative_path="shared/Microsoft.NETCore.App" + asset_name=".NET Core Runtime" + elif [[ "$runtime" == "aspnetcore" ]]; then + asset_relative_path="shared/Microsoft.AspNetCore.App" + asset_name="ASP.NET Core Runtime" + elif [ -z "$runtime" ]; then + asset_relative_path="sdk" + asset_name=".NET Core SDK" + else + say_err "Invalid value for \$runtime" + return 1 + fi + + # Check if the SDK version is already installed. + if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$specific_version"; then + say "$asset_name version $specific_version is already installed." + return 0 + fi + + mkdir -p "$install_root" + zip_path="$(mktemp "$temporary_file_template")" + say_verbose "Zip path: $zip_path" + + say "Downloading link: $download_link" + + # Failures are normal in the non-legacy case for ultimately legacy downloads. + # Do not output to stderr, since output to stderr is considered an error. + download "$download_link" "$zip_path" 2>&1 || download_failed=true + + # if the download fails, download the legacy_download_link + if [ "$download_failed" = true ]; then + say "Cannot download: $download_link" + + if [ "$valid_legacy_download_link" = true ]; then + download_failed=false + download_link="$legacy_download_link" + zip_path="$(mktemp "$temporary_file_template")" + say_verbose "Legacy zip path: $zip_path" + say "Downloading legacy link: $download_link" + download "$download_link" "$zip_path" 2>&1 || download_failed=true + + if [ "$download_failed" = true ]; then + say "Cannot download: $download_link" + fi + fi + fi + + if [ "$download_failed" = true ]; then + say_err "Could not find/download: \`$asset_name\` with version = $specific_version" + say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support" + return 1 + fi + + say "Extracting zip from $download_link" + extract_dotnet_package "$zip_path" "$install_root" + + # Check if the SDK version is installed; if not, fail the installation. + # if the version contains "RTM" or "servicing"; check if a 'release-type' SDK version is installed. + if [[ $specific_version == *"rtm"* || $specific_version == *"servicing"* ]]; then + IFS='-' + read -ra verArr <<< "$specific_version" + release_version="${verArr[0]}" + unset IFS; + say_verbose "Checking installation: version = $release_version" + if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$release_version"; then + return 0 + fi + fi + + # Check if the standard SDK version is installed. + say_verbose "Checking installation: version = $specific_product_version" + if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$specific_product_version"; then + return 0 + fi + + say_err "\`$asset_name\` with version = $specific_product_version failed to install with an unknown error." + return 1 +} + +args=("$@") + +local_version_file_relative_path="/.version" +bin_folder_relative_path="" +temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX" + +channel="LTS" +version="Latest" +json_file="" +install_dir="" +architecture="" +dry_run=false +no_path=false +no_cdn=false +azure_feed="https://dotnetcli.azureedge.net/dotnet" +uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet" +feed_credential="" +verbose=false +runtime="" +runtime_id="" +override_non_versioned_files=true +non_dynamic_parameters="" + +while [ $# -ne 0 ] +do + name="$1" + case "$name" in + -c|--channel|-[Cc]hannel) + shift + channel="$1" + ;; + -v|--version|-[Vv]ersion) + shift + version="$1" + ;; + -i|--install-dir|-[Ii]nstall[Dd]ir) + shift + install_dir="$1" + ;; + --arch|--architecture|-[Aa]rch|-[Aa]rchitecture) + shift + architecture="$1" + ;; + --shared-runtime|-[Ss]hared[Rr]untime) + say_warning "The --shared-runtime flag is obsolete and may be removed in a future version of this script. The recommended usage is to specify '--runtime dotnet'." + if [ -z "$runtime" ]; then + runtime="dotnet" + fi + ;; + --runtime|-[Rr]untime) + shift + runtime="$1" + if [[ "$runtime" != "dotnet" ]] && [[ "$runtime" != "aspnetcore" ]]; then + say_err "Unsupported value for --runtime: '$1'. Valid values are 'dotnet' and 'aspnetcore'." + if [[ "$runtime" == "windowsdesktop" ]]; then + say_err "WindowsDesktop archives are manufactured for Windows platforms only." + fi + exit 1 + fi + ;; + --dry-run|-[Dd]ry[Rr]un) + dry_run=true + ;; + --no-path|-[Nn]o[Pp]ath) + no_path=true + non_dynamic_parameters+=" $name" + ;; + --verbose|-[Vv]erbose) + verbose=true + non_dynamic_parameters+=" $name" + ;; + --no-cdn|-[Nn]o[Cc]dn) + no_cdn=true + non_dynamic_parameters+=" $name" + ;; + --azure-feed|-[Aa]zure[Ff]eed) + shift + azure_feed="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + ;; + --uncached-feed|-[Uu]ncached[Ff]eed) + shift + uncached_feed="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + ;; + --feed-credential|-[Ff]eed[Cc]redential) + shift + feed_credential="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + ;; + --runtime-id|-[Rr]untime[Ii]d) + shift + runtime_id="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + ;; + --jsonfile|-[Jj][Ss]on[Ff]ile) + shift + json_file="$1" + ;; + --skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles) + override_non_versioned_files=false + non_dynamic_parameters+=" $name" + ;; + -?|--?|-h|--help|-[Hh]elp) + script_name="$(basename "$0")" + echo ".NET Tools Installer" + echo "Usage: $script_name [-c|--channel ] [-v|--version ] [-p|--prefix ]" + echo " $script_name -h|-?|--help" + echo "" + echo "$script_name is a simple command line interface for obtaining dotnet cli." + echo "" + echo "Options:" + echo " -c,--channel Download from the channel specified, Defaults to \`$channel\`." + echo " -Channel" + echo " Possible values:" + echo " - Current - most current release" + echo " - LTS - most current supported release" + echo " - 2-part version in a format A.B - represents a specific release" + echo " examples: 2.0; 1.0" + echo " - Branch name" + echo " examples: release/2.0.0; Master" + echo " Note: The version parameter overrides the channel parameter." + echo " -v,--version Use specific VERSION, Defaults to \`$version\`." + echo " -Version" + echo " Possible values:" + echo " - latest - most latest build on specific channel" + echo " - coherent - most latest coherent build on specific channel" + echo " coherent applies only to SDK downloads" + echo " - 3-part version in a format A.B.C - represents specific version of build" + echo " examples: 2.0.0-preview2-006120; 1.1.0" + echo " -i,--install-dir Install under specified location (see Install Location below)" + echo " -InstallDir" + echo " --architecture Architecture of dotnet binaries to be installed, Defaults to \`$architecture\`." + echo " --arch,-Architecture,-Arch" + echo " Possible values: x64, arm, and arm64" + echo " --runtime Installs a shared runtime only, without the SDK." + echo " -Runtime" + echo " Possible values:" + echo " - dotnet - the Microsoft.NETCore.App shared runtime" + echo " - aspnetcore - the Microsoft.AspNetCore.App shared runtime" + echo " --dry-run,-DryRun Do not perform installation. Display download link." + echo " --no-path, -NoPath Do not set PATH for the current process." + echo " --verbose,-Verbose Display diagnostics information." + echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user." + echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user." + echo " --feed-credential,-FeedCredential Azure feed shared access token. This parameter typically is not specified." + echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable." + echo " -SkipNonVersionedFiles" + echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly." + echo " --jsonfile Determines the SDK version from a user specified global.json file." + echo " Note: global.json must have a value for 'SDK:Version'" + echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)." + echo " -RuntimeId" + echo " -?,--?,-h,--help,-Help Shows this help message" + echo "" + echo "Obsolete parameters:" + echo " --shared-runtime The recommended alternative is '--runtime dotnet'." + echo " This parameter is obsolete and may be removed in a future version of this script." + echo " Installs just the shared runtime bits, not the entire SDK." + echo "" + echo "Install Location:" + echo " Location is chosen in following order:" + echo " - --install-dir option" + echo " - Environmental variable DOTNET_INSTALL_DIR" + echo " - $HOME/.dotnet" + exit 0 + ;; + *) + say_err "Unknown argument \`$name\`" + exit 1 + ;; + esac + + shift +done + +if [ "$no_cdn" = true ]; then + azure_feed="$uncached_feed" +fi + +say "Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:" +say "- The SDK needs to be installed without user interaction and without admin rights." +say "- The SDK installation doesn't need to persist across multiple CI runs." +say "To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.\n" + +check_min_reqs +calculate_vars +script_name=$(basename "$0") + +if [ "$dry_run" = true ]; then + say "Payload URLs:" + say "Primary named payload URL: $download_link" + if [ "$valid_legacy_download_link" = true ]; then + say "Legacy named payload URL: $legacy_download_link" + fi + repeatable_command="./$script_name --version "\""$specific_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\""" + if [[ "$runtime" == "dotnet" ]]; then + repeatable_command+=" --runtime "\""dotnet"\""" + elif [[ "$runtime" == "aspnetcore" ]]; then + repeatable_command+=" --runtime "\""aspnetcore"\""" + fi + repeatable_command+="$non_dynamic_parameters" + say "Repeatable invocation: $repeatable_command" + exit 0 +fi + +install_dotnet + +bin_path="$(get_absolute_path "$(combine_paths "$install_root" "$bin_folder_relative_path")")" +if [ "$no_path" = false ]; then + say "Adding to current process PATH: \`$bin_path\`. Note: This change will be visible only when sourcing script." + export PATH="$bin_path":"$PATH" +else + say "Binaries of dotnet can be found in $bin_path" +fi + +say "Note that the script does not resolve dependencies during installation." +say "To check the list of dependencies, go to https://docs.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section." +say "Installation finished successfully." -# make the link -ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/ diff --git a/.travis/run-tests-csharp.sh b/.travis/run-tests-csharp.sh deleted file mode 100755 index 7f2c27524..000000000 --- a/.travis/run-tests-csharp.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=csharp.* test diff --git a/.travis/run-tests-dotnet.sh b/.travis/run-tests-dotnet.sh index 448805664..a7780c49a 100755 --- a/.travis/run-tests-dotnet.sh +++ b/.travis/run-tests-dotnet.sh @@ -2,20 +2,21 @@ set -euo pipefail +export PATH=$PATH:/Users/travis/.dotnet + # we need to build the runtime before test run, since we used "--no-dependencies" # when we call dotnet cli for restore and build, in order to speed up -dotnet restore ../runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj -dotnet build -c Release -f netstandard1.3 ../runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj +dotnet build -c Release -f netstandard2.0 ../runtime/CSharp/Antlr4.csproj # call test if [ $GROUP == "LEXER" ]; then - mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* -Dantlr-csharp-netstandard=true test + mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* test elif [ $GROUP == "PARSER" ]; then - mvn -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* -Dantlr-csharp-netstandard=true test + mvn -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* test elif [ $GROUP == "RECURSION" ]; then - mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* -Dantlr-csharp-netstandard=true test + mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* test else - mvn -q -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* -Dantlr-csharp-netstandard=true test + mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=csharp.* test fi diff --git a/appveyor.yml b/appveyor.yml index cb134c487..d0fb7da9a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,9 +11,9 @@ install: - cinst -y dart-sdk --version=2.8.4 build_script: - mvn -DskipTests install --batch-mode - - msbuild /target:restore /target:rebuild /property:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.sln + - dotnet build runtime/CSharp/Antlr4.csproj -c Release after_build: - - msbuild /target:pack /property:Configuration=Release /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.sln + - dotnet pack runtime/CSharp/Antlr4.csproj -c Release test_script: - mvn install -Dantlr-php-php="C:\tools\php\php.exe" -Dantlr-dart-dart="C:\tools\dart-sdk\bin\dart.exe" -Dantlr-dart-pub="C:\tools\dart-sdk\bin\pub.bat" -Dantlr-dart-dart2native="C:\tools\dart-sdk\bin\dart2native.bat" -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" --batch-mode artifacts: From e4b3ae9be2870f5434a7c3055c99498d9bec555f Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Mon, 28 Dec 2020 16:16:22 +0300 Subject: [PATCH 34/36] Remove not used AssebmblyInfo.cs --- doc/releasing-antlr.md | 3 +- runtime/CSharp/Properties/AssemblyInfo.cs | 36 ----------------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/doc/releasing-antlr.md b/doc/releasing-antlr.md index 53db4cdc3..c8fd719a2 100644 --- a/doc/releasing-antlr.md +++ b/doc/releasing-antlr.md @@ -55,8 +55,7 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t * runtime/Python2/src/antlr4/Recognizer.py * runtime/Python3/setup.py * 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/CSharp/Antlr4.csproj * runtime/PHP/src/RuntimeMetaData.php * runtime/JavaScript/package.json * runtime/JavaScript/src/antlr4/Recognizer.js diff --git a/runtime/CSharp/Properties/AssemblyInfo.cs b/runtime/CSharp/Properties/AssemblyInfo.cs index b11606203..d846533bb 100644 --- a/runtime/CSharp/Properties/AssemblyInfo.cs +++ b/runtime/CSharp/Properties/AssemblyInfo.cs @@ -3,41 +3,5 @@ * can be found in the LICENSE.txt file in the project root. */ using System; -using System.Reflection; -using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Antlr4.Runtime")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Antlr organization")] -[assembly: AssemblyProduct("Antlr4.Runtime")] -[assembly: AssemblyCopyright("Antlr organization")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] [assembly: CLSCompliant(true)] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("bc228eb9-e79c-4e5a-a1b9-0434ea566bab")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.9")] -[assembly: AssemblyFileVersion("4.9")] -[assembly: AssemblyInformationalVersion("4.9")] - From a001c2f67bb506130af370e5cb37eac9076a0847 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Mon, 28 Dec 2020 16:36:27 +0300 Subject: [PATCH 35/36] Replace PackageIcon with PackageIconUrl because it does not work fine, remove Antlr.png --- runtime/CSharp/Antlr.png | Bin 1603 -> 0 bytes runtime/CSharp/Antlr4.csproj | 9 +-------- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 runtime/CSharp/Antlr.png diff --git a/runtime/CSharp/Antlr.png b/runtime/CSharp/Antlr.png deleted file mode 100644 index 01f16f6a7f977e3c3637d22fa8ede242d6a4f5a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1603 zcmaJ>X;2eq7*2`xLKG2Nh=}U~(oP|}8wi+%fC)(?E%69w;sq?pLLwv^cNemNwKeIC zIFdm}Y>POh6_r{X(JI=J2vkAF;(-S`R<7}=t+qftDhg;f2-qLRo!R}q_nqf?-g9=# z(#4BBrt+q8I2;dUf=tbxbJ;gw@&jLE{XIh>d{#)9dxa2iO*GmU03*jrl<0!F{+ATSJ} zv&7)*q_nD~Ks-U>fRGP|>EK8Nh>YMP5wIvi6bcAn1cnd+1V@D-Fe;2fVFVa?KsFkw z&p_2O#YimH5`zYswxAGXwOaYsa6Un1LWoEtf?xq85QMRaFe=YXV@#Nt3LI6C;gpUv zT4*C-23(3*I*~(*K{nIZC73K@vSwDy;2D3m2A9j^A3RJ1y4mFv^&=jr4-{kwh z!c=me1&7o)MdXk=c5oSiu22>4V5<8ocgV6w20WjJZf#q|o3Fag6wqsH-b2_IK)gsUGvmxyt>5St9-8ts2Z zJ?dij$8{ZBT-F#{eca6MJIOBgj^N6x9FAL!QYJ}eem$sJuiv@M`_(_EGK-M(#zMxg zqC~9-Z3+B%OCeLD{zU-pDSXo9TYT)ZUAKphmKbEbn=RhRKJTl64&Rx@&3BL&b2dg* z-g?$iu%fs5QXSEC>RCJ0BdRY*Su)h7PH&vdc>8m$cKd_X?rSDK?Ed7XV^4FMb6N_w zc~*3%-P&-o_1lO(RZJN-HM{k2S_m^^gU58@T7PaImk~UVE3)-6Yv$h(U^CnOS26)k z&WgZ0FB(F+KYSH`xnQnaxvdOz=YQVp{Gv9%HxWORML_vd#hTC{HQW zpAfy@Q9kJzZ(994;jZo??2!LGQx}sOlwJ4L^v&0fmRvuH)h$?gWzbT)A}flzZ?WpO&XZOt|#*Y@|f(^P^{gE$cz<<6@(G z#dbI(G&61+uSJJ;*PQWr8q?yhOh2(IyOm1W-m|}@stD=KupO7syX0q{CyO_EO7g2B z_a0e3luF)R2b5|W`=_3|bTTpaDy2!8wc$O#mkEwn-yH4dQNfV9rRV&^iPcM(8-K3s zbFVqswe2HbYLl_jQsckufZXds$CR#ytv|HW(L38J+m1Oeh7Z1MJiZQAaP#IZ%6)&Z zvEX)bU&eyvZD)g@L^&k`d1rBc_RnyEO}}CEXU(5#KaewK;l6 zlC+~?Mqgq0Zrpj{9S485`N;j%j+|=siGhRl=rm9JB*Cic_PVuRw*mRyr^SjJ2mY=V z2x4DsmCx^TJF%>?Oi?lCcv5r&^<8a+L7S+5F)|K+bvP04|+rRP5Z!7=+ diff --git a/runtime/CSharp/Antlr4.csproj b/runtime/CSharp/Antlr4.csproj index 97e9dcef5..d9d59e578 100644 --- a/runtime/CSharp/Antlr4.csproj +++ b/runtime/CSharp/Antlr4.csproj @@ -19,7 +19,7 @@ true BSD-3-Clause https://github.com/antlr/antlr4 - Antlr.png + https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png https://github.com/antlr/antlr4/releases antlr parsing grammar false @@ -37,15 +37,8 @@ true full false - lib\Debug true - lib\Release - - - PreserveNewest - - From 6990edd4d418b60c36af7fba07a5a43883ece2ee Mon Sep 17 00:00:00 2001 From: Alex Mykyta Date: Mon, 28 Dec 2020 20:56:20 -0800 Subject: [PATCH 36/36] Improve python3 performance via addition of __slots__ --- runtime/Python3/src/antlr4/BufferedTokenStream.py | 1 + runtime/Python3/src/antlr4/CommonTokenFactory.py | 4 +++- runtime/Python3/src/antlr4/CommonTokenStream.py | 1 + runtime/Python3/src/antlr4/FileStream.py | 1 + runtime/Python3/src/antlr4/InputStream.py | 1 + runtime/Python3/src/antlr4/IntervalSet.py | 1 + runtime/Python3/src/antlr4/LL1Analyzer.py | 1 + runtime/Python3/src/antlr4/Lexer.py | 6 +++++- runtime/Python3/src/antlr4/ListTokenSource.py | 3 ++- runtime/Python3/src/antlr4/Parser.py | 5 +++++ runtime/Python3/src/antlr4/ParserInterpreter.py | 5 +++++ runtime/Python3/src/antlr4/ParserRuleContext.py | 2 +- runtime/Python3/src/antlr4/Recognizer.py | 1 + runtime/Python3/src/antlr4/RuleContext.py | 3 +-- runtime/Python3/src/antlr4/Token.py | 2 +- runtime/Python3/src/antlr4/TokenStreamRewriter.py | 10 +++++++--- runtime/Python3/src/antlr4/atn/ATN.py | 9 +++++++-- runtime/Python3/src/antlr4/atn/ATNConfig.py | 5 +++++ runtime/Python3/src/antlr4/atn/ATNConfigSet.py | 9 ++++++--- .../src/antlr4/atn/ATNDeserializationOptions.py | 2 +- runtime/Python3/src/antlr4/atn/ATNDeserializer.py | 1 + runtime/Python3/src/antlr4/atn/ATNSimulator.py | 2 +- runtime/Python3/src/antlr4/atn/ATNState.py | 12 +++++++++++- runtime/Python3/src/antlr4/atn/LexerATNSimulator.py | 10 ++++++---- runtime/Python3/src/antlr4/atn/LexerAction.py | 9 ++++++++- .../Python3/src/antlr4/atn/LexerActionExecutor.py | 3 ++- .../Python3/src/antlr4/atn/ParserATNSimulator.py | 5 ++++- runtime/Python3/src/antlr4/atn/SemanticContext.py | 5 ++++- runtime/Python3/src/antlr4/atn/Transition.py | 13 ++++++++++++- runtime/Python3/src/antlr4/dfa/DFA.py | 2 +- runtime/Python3/src/antlr4/dfa/DFASerializer.py | 1 + runtime/Python3/src/antlr4/dfa/DFAState.py | 6 ++++++ runtime/Python3/src/antlr4/tree/Chunk.py | 3 ++- runtime/Python3/src/antlr4/tree/ParseTreeMatch.py | 2 +- runtime/Python3/src/antlr4/tree/ParseTreePattern.py | 1 + .../src/antlr4/tree/ParseTreePatternMatcher.py | 1 + runtime/Python3/src/antlr4/tree/RuleTagToken.py | 3 ++- runtime/Python3/src/antlr4/tree/TokenTagToken.py | 2 +- runtime/Python3/src/antlr4/tree/Tree.py | 3 ++- .../v4/tool/templates/codegen/Python3/Python3.stg | 1 + 40 files changed, 124 insertions(+), 33 deletions(-) diff --git a/runtime/Python3/src/antlr4/BufferedTokenStream.py b/runtime/Python3/src/antlr4/BufferedTokenStream.py index 341800abc..2c49de233 100644 --- a/runtime/Python3/src/antlr4/BufferedTokenStream.py +++ b/runtime/Python3/src/antlr4/BufferedTokenStream.py @@ -27,6 +27,7 @@ class TokenStream(object): class BufferedTokenStream(TokenStream): + __slots__ = ('tokenSource', 'tokens', 'index', 'fetchedEOF') def __init__(self, tokenSource:Lexer): # The {@link TokenSource} from which tokens for this stream are fetched. diff --git a/runtime/Python3/src/antlr4/CommonTokenFactory.py b/runtime/Python3/src/antlr4/CommonTokenFactory.py index 17296fab1..0d09ad785 100644 --- a/runtime/Python3/src/antlr4/CommonTokenFactory.py +++ b/runtime/Python3/src/antlr4/CommonTokenFactory.py @@ -15,6 +15,8 @@ class TokenFactory(object): pass class CommonTokenFactory(TokenFactory): + __slots__ = 'copyText' + # # The default {@link CommonTokenFactory} instance. # @@ -56,4 +58,4 @@ class CommonTokenFactory(TokenFactory): t.text = text return t -CommonTokenFactory.DEFAULT = CommonTokenFactory() \ No newline at end of file +CommonTokenFactory.DEFAULT = CommonTokenFactory() diff --git a/runtime/Python3/src/antlr4/CommonTokenStream.py b/runtime/Python3/src/antlr4/CommonTokenStream.py index f08374422..dd0a984e3 100644 --- a/runtime/Python3/src/antlr4/CommonTokenStream.py +++ b/runtime/Python3/src/antlr4/CommonTokenStream.py @@ -35,6 +35,7 @@ from antlr4.Token import Token class CommonTokenStream(BufferedTokenStream): + __slots__ = 'channel' def __init__(self, lexer:Lexer, channel:int=Token.DEFAULT_CHANNEL): super().__init__(lexer) diff --git a/runtime/Python3/src/antlr4/FileStream.py b/runtime/Python3/src/antlr4/FileStream.py index b89238907..1c6ce9fbc 100644 --- a/runtime/Python3/src/antlr4/FileStream.py +++ b/runtime/Python3/src/antlr4/FileStream.py @@ -14,6 +14,7 @@ from antlr4.InputStream import InputStream class FileStream(InputStream): + __slots__ = 'fileName' def __init__(self, fileName:str, encoding:str='ascii', errors:str='strict'): super().__init__(self.readDataFrom(fileName, encoding, errors)) diff --git a/runtime/Python3/src/antlr4/InputStream.py b/runtime/Python3/src/antlr4/InputStream.py index ca63d083a..5d077d135 100644 --- a/runtime/Python3/src/antlr4/InputStream.py +++ b/runtime/Python3/src/antlr4/InputStream.py @@ -12,6 +12,7 @@ from antlr4.Token import Token class InputStream (object): + __slots__ = ('name', 'strdata', '_index', 'data', '_size') def __init__(self, data: str): self.name = "" diff --git a/runtime/Python3/src/antlr4/IntervalSet.py b/runtime/Python3/src/antlr4/IntervalSet.py index 9742426c9..5c1a68725 100644 --- a/runtime/Python3/src/antlr4/IntervalSet.py +++ b/runtime/Python3/src/antlr4/IntervalSet.py @@ -11,6 +11,7 @@ from antlr4.Token import Token IntervalSet = None class IntervalSet(object): + __slots__ = ('intervals', 'readOnly') def __init__(self): self.intervals = None diff --git a/runtime/Python3/src/antlr4/LL1Analyzer.py b/runtime/Python3/src/antlr4/LL1Analyzer.py index 6b398fcd9..a200a5d0e 100644 --- a/runtime/Python3/src/antlr4/LL1Analyzer.py +++ b/runtime/Python3/src/antlr4/LL1Analyzer.py @@ -14,6 +14,7 @@ from antlr4.atn.Transition import WildcardTransition, NotSetTransition, Abstract class LL1Analyzer (object): + __slots__ = 'atn' #* Special value added to the lookahead sets to indicate that we hit # a predicate during analysis if {@code seeThruPreds==false}. diff --git a/runtime/Python3/src/antlr4/Lexer.py b/runtime/Python3/src/antlr4/Lexer.py index 0a96b70af..82accadcb 100644 --- a/runtime/Python3/src/antlr4/Lexer.py +++ b/runtime/Python3/src/antlr4/Lexer.py @@ -28,6 +28,11 @@ class TokenSource(object): class Lexer(Recognizer, TokenSource): + __slots__ = ( + '_input', '_output', '_factory', '_tokenFactorySourcePair', '_token', + '_tokenStartCharIndex', '_tokenStartLine', '_tokenStartColumn', + '_hitEOF', '_channel', '_type', '_modeStack', '_mode', '_text' + ) DEFAULT_MODE = 0 MORE = -2 @@ -322,4 +327,3 @@ class Lexer(Recognizer, TokenSource): else: # TODO: Do we lose character or line position information? self._input.consume() - diff --git a/runtime/Python3/src/antlr4/ListTokenSource.py b/runtime/Python3/src/antlr4/ListTokenSource.py index eebc75641..40bcaf94a 100644 --- a/runtime/Python3/src/antlr4/ListTokenSource.py +++ b/runtime/Python3/src/antlr4/ListTokenSource.py @@ -18,6 +18,7 @@ from antlr4.Token import Token class ListTokenSource(TokenSource): + __slots__ = ('tokens', 'sourceName', 'pos', 'eofToken', '_factory') # Constructs a new {@link ListTokenSource} instance from the specified # collection of {@link Token} objects and source name. @@ -140,4 +141,4 @@ class ListTokenSource(TokenSource): if inputStream is not None: return inputStream.getSourceName() else: - return "List" \ No newline at end of file + return "List" diff --git a/runtime/Python3/src/antlr4/Parser.py b/runtime/Python3/src/antlr4/Parser.py index 11bf41796..081af14ea 100644 --- a/runtime/Python3/src/antlr4/Parser.py +++ b/runtime/Python3/src/antlr4/Parser.py @@ -23,6 +23,7 @@ from antlr4.tree.ParseTreePatternMatcher import ParseTreePatternMatcher from antlr4.tree.Tree import ParseTreeListener, TerminalNode, ErrorNode class TraceListener(ParseTreeListener): + __slots__ = '_parser' def __init__(self, parser): self._parser = parser @@ -44,7 +45,11 @@ class TraceListener(ParseTreeListener): # self is all the parsing support code essentially; most of it is error recovery stuff.# class Parser (Recognizer): + __slots__ = ( + '_input', '_output', '_errHandler', '_precedenceStack', '_ctx', + 'buildParseTrees', '_tracer', '_parseListeners', '_syntaxErrors' + ) # self field maps from the serialized ATN string to the deserialized {@link ATN} with # bypass alternatives. # diff --git a/runtime/Python3/src/antlr4/ParserInterpreter.py b/runtime/Python3/src/antlr4/ParserInterpreter.py index 117f67bab..4de43623c 100644 --- a/runtime/Python3/src/antlr4/ParserInterpreter.py +++ b/runtime/Python3/src/antlr4/ParserInterpreter.py @@ -32,6 +32,11 @@ from antlr4.error.Errors import RecognitionException, UnsupportedOperationExcept class ParserInterpreter(Parser): + __slots__ = ( + 'grammarFileName', 'atn', 'tokenNames', 'ruleNames', 'decisionToDFA', + 'sharedContextCache', '_parentContextStack', + 'pushRecursionContextStates' + ) def __init__(self, grammarFileName:str, tokenNames:list, ruleNames:list, atn:ATN, input:TokenStream): super().__init__(input) diff --git a/runtime/Python3/src/antlr4/ParserRuleContext.py b/runtime/Python3/src/antlr4/ParserRuleContext.py index e4ec5983a..f945c5ba9 100644 --- a/runtime/Python3/src/antlr4/ParserRuleContext.py +++ b/runtime/Python3/src/antlr4/ParserRuleContext.py @@ -34,7 +34,7 @@ from antlr4.tree.Tree import ParseTreeListener, ParseTree, TerminalNodeImpl, Err ParserRuleContext = None class ParserRuleContext(RuleContext): - + __slots__ = ('children', 'start', 'stop', 'exception') def __init__(self, parent:ParserRuleContext = None, invokingStateNumber:int = None ): super().__init__(parent, invokingStateNumber) #* If we are debugging or building a parse tree for a visitor, diff --git a/runtime/Python3/src/antlr4/Recognizer.py b/runtime/Python3/src/antlr4/Recognizer.py index c98228847..28e84f199 100644 --- a/runtime/Python3/src/antlr4/Recognizer.py +++ b/runtime/Python3/src/antlr4/Recognizer.py @@ -11,6 +11,7 @@ from antlr4.error.ErrorListener import ProxyErrorListener, ConsoleErrorListener RecognitionException = None class Recognizer(object): + __slots__ = ('_listeners', '_interp', '_stateNumber') tokenTypeMapCache = dict() ruleIndexMapCache = dict() diff --git a/runtime/Python3/src/antlr4/RuleContext.py b/runtime/Python3/src/antlr4/RuleContext.py index 7f6dd9143..7812ba3b1 100644 --- a/runtime/Python3/src/antlr4/RuleContext.py +++ b/runtime/Python3/src/antlr4/RuleContext.py @@ -33,7 +33,7 @@ RuleContext = None Parser = None class RuleContext(RuleNode): - + __slots__ = ('parentCtx', 'invokingState') EMPTY = None def __init__(self, parent:RuleContext=None, invokingState:int=-1): @@ -225,4 +225,3 @@ class RuleContext(RuleNode): buf.write("]") return buf.getvalue() - diff --git a/runtime/Python3/src/antlr4/Token.py b/runtime/Python3/src/antlr4/Token.py index 6f4d5e262..10a68a8c2 100644 --- a/runtime/Python3/src/antlr4/Token.py +++ b/runtime/Python3/src/antlr4/Token.py @@ -10,6 +10,7 @@ from io import StringIO class Token (object): + __slots__ = ('source', 'type', 'channel', 'start', 'stop', 'tokenIndex', 'line', 'column', '_text') INVALID_TYPE = 0 @@ -68,7 +69,6 @@ class Token (object): class CommonToken(Token): - # An empty {@link Pair} which is used as the default value of # {@link #source} for tokens that do not have a source. EMPTY_SOURCE = (None, None) diff --git a/runtime/Python3/src/antlr4/TokenStreamRewriter.py b/runtime/Python3/src/antlr4/TokenStreamRewriter.py index 04a3af657..59baf8f47 100644 --- a/runtime/Python3/src/antlr4/TokenStreamRewriter.py +++ b/runtime/Python3/src/antlr4/TokenStreamRewriter.py @@ -11,6 +11,8 @@ from antlr4.CommonTokenStream import CommonTokenStream class TokenStreamRewriter(object): + __slots__ = ('tokens', 'programs', 'lastRewriteTokenIndexes') + DEFAULT_PROGRAM_NAME = "default" PROGRAM_INIT_SIZE = 100 MIN_TOKEN_INDEX = 0 @@ -99,7 +101,7 @@ class TokenStreamRewriter(object): def getProgram(self, program_name): return self.programs.setdefault(program_name, []) - + def getDefaultText(self): return self.getText(self.DEFAULT_PROGRAM_NAME, 0, len(self.tokens.tokens) - 1) @@ -195,6 +197,7 @@ class TokenStreamRewriter(object): return reduced class RewriteOperation(object): + __slots__ = ('tokens', 'index', 'text', 'instructionIndex') def __init__(self, tokens, index, text=""): """ @@ -233,8 +236,9 @@ class TokenStreamRewriter(object): class InsertAfterOp(InsertBeforeOp): pass - + class ReplaceOp(RewriteOperation): + __slots__ = 'last_index' def __init__(self, from_idx, to_idx, tokens, text): super(TokenStreamRewriter.ReplaceOp, self).__init__(tokens, from_idx, text) @@ -244,7 +248,7 @@ class TokenStreamRewriter(object): if self.text: buf.write(self.text) return self.last_index + 1 - + def __str__(self): if self.text: return ''.format(self.tokens.get(self.index), self.tokens.get(self.last_index), diff --git a/runtime/Python3/src/antlr4/atn/ATN.py b/runtime/Python3/src/antlr4/atn/ATN.py index 4ef5640b1..2639e3c1e 100644 --- a/runtime/Python3/src/antlr4/atn/ATN.py +++ b/runtime/Python3/src/antlr4/atn/ATN.py @@ -12,6 +12,11 @@ from antlr4.atn.ATNState import ATNState, DecisionState class ATN(object): + __slots__ = ( + 'grammarType', 'maxTokenType', 'states', 'decisionToState', + 'ruleToStartState', 'ruleToStopState', 'modeNameToStartState', + 'ruleToTokenType', 'lexerActions', 'modeToStartState' + ) INVALID_ALT_NUMBER = 0 @@ -58,7 +63,7 @@ class ATN(object): if s.nextTokenWithinRule is not None: return s.nextTokenWithinRule s.nextTokenWithinRule = self.nextTokensInContext(s, None) - s.nextTokenWithinRule.readonly = True + s.nextTokenWithinRule.readOnly = True return s.nextTokenWithinRule def nextTokens(self, s:ATNState, ctx:RuleContext = None): @@ -124,4 +129,4 @@ class ATN(object): ctx = ctx.parentCtx if Token.EPSILON in following: expected.addOne(Token.EOF) - return expected \ No newline at end of file + return expected diff --git a/runtime/Python3/src/antlr4/atn/ATNConfig.py b/runtime/Python3/src/antlr4/atn/ATNConfig.py index e2d8b99cc..e008fb2ef 100644 --- a/runtime/Python3/src/antlr4/atn/ATNConfig.py +++ b/runtime/Python3/src/antlr4/atn/ATNConfig.py @@ -21,6 +21,10 @@ from antlr4.atn.SemanticContext import SemanticContext ATNConfig = None class ATNConfig(object): + __slots__ = ( + 'state', 'alt', 'context', 'semanticContext', 'reachesIntoOuterContext', + 'precedenceFilterSuppressed' + ) def __init__(self, state:ATNState=None, alt:int=None, context:PredictionContext=None, semantic:SemanticContext=None, config:ATNConfig=None): if config is not None: @@ -110,6 +114,7 @@ class ATNConfig(object): LexerATNConfig = None class LexerATNConfig(ATNConfig): + __slots__ = ('lexerActionExecutor', 'passedThroughNonGreedyDecision') def __init__(self, state:ATNState, alt:int=None, context:PredictionContext=None, semantic:SemanticContext=SemanticContext.NONE, lexerActionExecutor:LexerActionExecutor=None, config:LexerATNConfig=None): diff --git a/runtime/Python3/src/antlr4/atn/ATNConfigSet.py b/runtime/Python3/src/antlr4/atn/ATNConfigSet.py index b240c25dc..9e9a512a6 100644 --- a/runtime/Python3/src/antlr4/atn/ATNConfigSet.py +++ b/runtime/Python3/src/antlr4/atn/ATNConfigSet.py @@ -20,6 +20,12 @@ from antlr4.error.Errors import UnsupportedOperationException, IllegalStateExcep ATNSimulator = None class ATNConfigSet(object): + __slots__ = ( + 'configLookup', 'fullCtx', 'readonly', 'configs', 'uniqueAlt', + 'conflictingAlts', 'hasSemanticContext', 'dipsIntoOuterContext', + 'cachedHashCode' + ) + # # The reason that we need this is because we don't want the hash map to use # the standard hash code and equals. We need all configurations with the same @@ -204,6 +210,3 @@ class OrderedATNConfigSet(ATNConfigSet): def __init__(self): super().__init__() - - - diff --git a/runtime/Python3/src/antlr4/atn/ATNDeserializationOptions.py b/runtime/Python3/src/antlr4/atn/ATNDeserializationOptions.py index 9c4e23dec..a2af6b4d0 100644 --- a/runtime/Python3/src/antlr4/atn/ATNDeserializationOptions.py +++ b/runtime/Python3/src/antlr4/atn/ATNDeserializationOptions.py @@ -6,6 +6,7 @@ ATNDeserializationOptions = None class ATNDeserializationOptions(object): + __slots__ = ('readOnly', 'verifyATN', 'generateRuleBypassTransitions') defaultOptions = None @@ -21,4 +22,3 @@ class ATNDeserializationOptions(object): ATNDeserializationOptions.defaultOptions = ATNDeserializationOptions() ATNDeserializationOptions.defaultOptions.readOnly = True - diff --git a/runtime/Python3/src/antlr4/atn/ATNDeserializer.py b/runtime/Python3/src/antlr4/atn/ATNDeserializer.py index cd0bb661a..cc100d05a 100644 --- a/runtime/Python3/src/antlr4/atn/ATNDeserializer.py +++ b/runtime/Python3/src/antlr4/atn/ATNDeserializer.py @@ -31,6 +31,7 @@ SERIALIZED_VERSION = 3 SERIALIZED_UUID = ADDED_UNICODE_SMP class ATNDeserializer (object): + __slots__ = ('deserializationOptions', 'data', 'pos', 'uuid') def __init__(self, options : ATNDeserializationOptions = None): if options is None: diff --git a/runtime/Python3/src/antlr4/atn/ATNSimulator.py b/runtime/Python3/src/antlr4/atn/ATNSimulator.py index 26c0b94af..4f6f53f48 100644 --- a/runtime/Python3/src/antlr4/atn/ATNSimulator.py +++ b/runtime/Python3/src/antlr4/atn/ATNSimulator.py @@ -10,6 +10,7 @@ from antlr4.dfa.DFAState import DFAState class ATNSimulator(object): + __slots__ = ('atn', 'sharedContextCache', '__dict__') # Must distinguish between missing edge and edge we know leads nowhere#/ ERROR = DFAState(configs=ATNConfigSet()) @@ -44,4 +45,3 @@ class ATNSimulator(object): return context visited = dict() return getCachedPredictionContext(context, self.sharedContextCache, visited) - diff --git a/runtime/Python3/src/antlr4/atn/ATNState.py b/runtime/Python3/src/antlr4/atn/ATNState.py index 97ade9559..fbf6a7b94 100644 --- a/runtime/Python3/src/antlr4/atn/ATNState.py +++ b/runtime/Python3/src/antlr4/atn/ATNState.py @@ -69,6 +69,10 @@ from antlr4.atn.Transition import Transition INITIAL_NUM_TRANSITIONS = 4 class ATNState(object): + __slots__ = ( + 'atn', 'stateNumber', 'stateType', 'ruleIndex', 'epsilonOnlyTransitions', + 'transitions', 'nextTokenWithinRule', + ) # constants for serialization INVALID_TYPE = 0 @@ -148,7 +152,7 @@ class BasicState(ATNState): class DecisionState(ATNState): - + __slots__ = ('decision', 'nonGreedy') def __init__(self): super().__init__() self.decision = -1 @@ -156,6 +160,7 @@ class DecisionState(ATNState): # The start of a regular {@code (...)} block. class BlockStartState(DecisionState): + __slots__ = 'endState' def __init__(self): super().__init__() @@ -169,6 +174,7 @@ class BasicBlockStartState(BlockStartState): # Terminal node of a simple {@code (a|b|c)} block. class BlockEndState(ATNState): + __slots__ = 'startState' def __init__(self): super().__init__() @@ -187,6 +193,7 @@ class RuleStopState(ATNState): self.stateType = self.RULE_STOP class RuleStartState(ATNState): + __slots__ = ('stopState', 'isPrecedenceRule') def __init__(self): super().__init__() @@ -209,6 +216,7 @@ class PlusLoopbackState(DecisionState): # real decision-making note for {@code A+}. # class PlusBlockStartState(BlockStartState): + __slots__ = 'loopBackState' def __init__(self): super().__init__() @@ -230,6 +238,7 @@ class StarLoopbackState(ATNState): class StarLoopEntryState(DecisionState): + __slots__ = ('loopBackState', 'isPrecedenceDecision') def __init__(self): super().__init__() @@ -240,6 +249,7 @@ class StarLoopEntryState(DecisionState): # Mark the end of a * or + loop. class LoopEndState(ATNState): + __slots__ = 'loopBackState' def __init__(self): super().__init__() diff --git a/runtime/Python3/src/antlr4/atn/LexerATNSimulator.py b/runtime/Python3/src/antlr4/atn/LexerATNSimulator.py index 4c4468bb6..71201ff5f 100644 --- a/runtime/Python3/src/antlr4/atn/LexerATNSimulator.py +++ b/runtime/Python3/src/antlr4/atn/LexerATNSimulator.py @@ -34,6 +34,7 @@ from antlr4.dfa.DFAState import DFAState from antlr4.error.Errors import LexerNoViableAltException, UnsupportedOperationException class SimState(object): + __slots__ = ('index', 'line', 'column', 'dfaState') def __init__(self): self.reset() @@ -49,6 +50,10 @@ Lexer = None LexerATNSimulator = None class LexerATNSimulator(ATNSimulator): + __slots__ = ( + 'decisionToDFA', 'recog', 'startIndex', 'line', 'column', 'mode', + 'DEFAULT_MODE', 'MAX_CHAR_VALUE', 'prevAccept' + ) debug = False dfa_debug = False @@ -58,8 +63,6 @@ class LexerATNSimulator(ATNSimulator): ERROR = None - match_calls = 0 - def __init__(self, recog:Lexer, atn:ATN, decisionToDFA:list, sharedContextCache:PredictionContextCache): super().__init__(atn, sharedContextCache) self.decisionToDFA = decisionToDFA @@ -89,7 +92,6 @@ class LexerATNSimulator(ATNSimulator): self.startIndex = simulator.startIndex def match(self, input:InputStream , mode:int): - self.match_calls += 1 self.mode = mode mark = input.mark() try: @@ -565,4 +567,4 @@ class LexerATNSimulator(ATNSimulator): LexerATNSimulator.ERROR = DFAState(0x7FFFFFFF, ATNConfigSet()) -del Lexer \ No newline at end of file +del Lexer diff --git a/runtime/Python3/src/antlr4/atn/LexerAction.py b/runtime/Python3/src/antlr4/atn/LexerAction.py index 5d11f21ae..0fa7a895f 100644 --- a/runtime/Python3/src/antlr4/atn/LexerAction.py +++ b/runtime/Python3/src/antlr4/atn/LexerAction.py @@ -22,6 +22,7 @@ class LexerActionType(IntEnum): TYPE = 7 #The type of a {@link LexerTypeAction} action. class LexerAction(object): + __slots__ = ('actionType', 'isPositionDependent') def __init__(self, action:LexerActionType): self.actionType = action @@ -39,7 +40,7 @@ class LexerAction(object): # #

The {@code skip} command does not have any parameters, so this action is # implemented as a singleton instance exposed by {@link #INSTANCE}.

-class LexerSkipAction(LexerAction ): +class LexerSkipAction(LexerAction): # Provides a singleton instance of this parameterless lexer action. INSTANCE = None @@ -58,6 +59,7 @@ LexerSkipAction.INSTANCE = LexerSkipAction() # Implements the {@code type} lexer action by calling {@link Lexer#setType} # with the assigned type. class LexerTypeAction(LexerAction): + __slots__ = 'type' def __init__(self, type:int): super().__init__(LexerActionType.TYPE) @@ -84,6 +86,7 @@ class LexerTypeAction(LexerAction): # Implements the {@code pushMode} lexer action by calling # {@link Lexer#pushMode} with the assigned mode. class LexerPushModeAction(LexerAction): + __slots__ = 'mode' def __init__(self, mode:int): super().__init__(LexerActionType.PUSH_MODE) @@ -152,6 +155,7 @@ LexerMoreAction.INSTANCE = LexerMoreAction() # Implements the {@code mode} lexer action by calling {@link Lexer#mode} with # the assigned mode. class LexerModeAction(LexerAction): + __slots__ = 'mode' def __init__(self, mode:int): super().__init__(LexerActionType.MODE) @@ -186,6 +190,7 @@ class LexerModeAction(LexerAction): # command argument could not be evaluated when the grammar was compiled.

class LexerCustomAction(LexerAction): + __slots__ = ('ruleIndex', 'actionIndex') # Constructs a custom lexer action with the specified rule and action # indexes. @@ -220,6 +225,7 @@ class LexerCustomAction(LexerAction): # Implements the {@code channel} lexer action by calling # {@link Lexer#setChannel} with the assigned channel. class LexerChannelAction(LexerAction): + __slots__ = 'channel' # Constructs a new {@code channel} action with the specified channel value. # @param channel The channel value to pass to {@link Lexer#setChannel}. @@ -255,6 +261,7 @@ class LexerChannelAction(LexerAction): # lexer actions, see {@link LexerActionExecutor#append} and # {@link LexerActionExecutor#fixOffsetBeforeMatch}.

class LexerIndexedCustomAction(LexerAction): + __slots__ = ('offset', 'action') # Constructs a new indexed custom action by associating a character offset # with a {@link LexerAction}. diff --git a/runtime/Python3/src/antlr4/atn/LexerActionExecutor.py b/runtime/Python3/src/antlr4/atn/LexerActionExecutor.py index df125169f..5c6462c3a 100644 --- a/runtime/Python3/src/antlr4/atn/LexerActionExecutor.py +++ b/runtime/Python3/src/antlr4/atn/LexerActionExecutor.py @@ -20,6 +20,7 @@ Lexer = None LexerActionExecutor = None class LexerActionExecutor(object): + __slots__ = ('lexerActions', 'hashCode') def __init__(self, lexerActions:list=list()): self.lexerActions = lexerActions @@ -139,4 +140,4 @@ class LexerActionExecutor(object): return self.hashCode == other.hashCode \ and self.lexerActions == other.lexerActions -del Lexer \ No newline at end of file +del Lexer diff --git a/runtime/Python3/src/antlr4/atn/ParserATNSimulator.py b/runtime/Python3/src/antlr4/atn/ParserATNSimulator.py index 9948f4be3..d1fb3d7ed 100644 --- a/runtime/Python3/src/antlr4/atn/ParserATNSimulator.py +++ b/runtime/Python3/src/antlr4/atn/ParserATNSimulator.py @@ -255,6 +255,10 @@ from antlr4.error.Errors import NoViableAltException class ParserATNSimulator(ATNSimulator): + __slots__ = ( + 'parser', 'decisionToDFA', 'predictionMode', '_input', '_startIndex', + '_outerContext', '_dfa', 'mergeCache' + ) debug = False debug_list_atn_decisions = False @@ -1643,4 +1647,3 @@ class ParserATNSimulator(ATNSimulator): ", input=" + self.parser.getTokenStream().getText(startIndex, stopIndex)) if self.parser is not None: self.parser.getErrorListenerDispatch().reportAmbiguity(self.parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs) - diff --git a/runtime/Python3/src/antlr4/atn/SemanticContext.py b/runtime/Python3/src/antlr4/atn/SemanticContext.py index d4593195e..8f4dc3108 100644 --- a/runtime/Python3/src/antlr4/atn/SemanticContext.py +++ b/runtime/Python3/src/antlr4/atn/SemanticContext.py @@ -95,6 +95,7 @@ def filterPrecedencePredicates(collection:set): class Predicate(SemanticContext): + __slots__ = ('ruleIndex', 'predIndex', 'isCtxDependent') def __init__(self, ruleIndex:int=-1, predIndex:int=-1, isCtxDependent:bool=False): self.ruleIndex = ruleIndex @@ -153,6 +154,7 @@ class PrecedencePredicate(SemanticContext): # is false. del AND class AND(SemanticContext): + __slots__ = 'opnds' def __init__(self, a:SemanticContext, b:SemanticContext): operands = set() @@ -238,6 +240,7 @@ class AND(SemanticContext): # contexts is true. del OR class OR (SemanticContext): + __slots__ = 'opnds' def __init__(self, a:SemanticContext, b:SemanticContext): operands = set() @@ -317,4 +320,4 @@ class OR (SemanticContext): return buf.getvalue() -SemanticContext.NONE = Predicate() \ No newline at end of file +SemanticContext.NONE = Predicate() diff --git a/runtime/Python3/src/antlr4/atn/Transition.py b/runtime/Python3/src/antlr4/atn/Transition.py index 0ed042cda..2e4c99717 100644 --- a/runtime/Python3/src/antlr4/atn/Transition.py +++ b/runtime/Python3/src/antlr4/atn/Transition.py @@ -26,6 +26,8 @@ ATNState = None RuleStartState = None class Transition (object): + __slots__ = ('target','isEpsilon','label') + # constants for serialization EPSILON = 1 RANGE = 2 @@ -66,6 +68,7 @@ class Transition (object): # TODO: make all transitions sets? no, should remove set edges class AtomTransition(Transition): + __slots__ = ('label_', 'serializationType') def __init__(self, target:ATNState, label:int): super().__init__(target) @@ -85,6 +88,7 @@ class AtomTransition(Transition): return str(self.label_) class RuleTransition(Transition): + __slots__ = ('ruleIndex', 'precedence', 'followState', 'serializationType') def __init__(self, ruleStart:RuleStartState, ruleIndex:int, precedence:int, followState:ATNState): super().__init__(ruleStart) @@ -99,6 +103,7 @@ class RuleTransition(Transition): class EpsilonTransition(Transition): + __slots__ = ('serializationType', 'outermostPrecedenceReturn') def __init__(self, target, outermostPrecedenceReturn=-1): super(EpsilonTransition, self).__init__(target) @@ -113,6 +118,7 @@ class EpsilonTransition(Transition): return "epsilon" class RangeTransition(Transition): + __slots__ = ('serializationType', 'start', 'stop') def __init__(self, target:ATNState, start:int, stop:int): super().__init__(target) @@ -139,6 +145,7 @@ class AbstractPredicateTransition(Transition): class PredicateTransition(AbstractPredicateTransition): + __slots__ = ('serializationType', 'ruleIndex', 'predIndex', 'isCtxDependent') def __init__(self, target:ATNState, ruleIndex:int, predIndex:int, isCtxDependent:bool): super().__init__(target) @@ -158,6 +165,7 @@ class PredicateTransition(AbstractPredicateTransition): return "pred_" + str(self.ruleIndex) + ":" + str(self.predIndex) class ActionTransition(Transition): + __slots__ = ('serializationType', 'ruleIndex', 'actionIndex', 'isCtxDependent') def __init__(self, target:ATNState, ruleIndex:int, actionIndex:int=-1, isCtxDependent:bool=False): super().__init__(target) @@ -175,6 +183,7 @@ class ActionTransition(Transition): # A transition containing a set of values. class SetTransition(Transition): + __slots__ = 'serializationType' def __init__(self, target:ATNState, set:IntervalSet): super().__init__(target) @@ -207,6 +216,7 @@ class NotSetTransition(SetTransition): class WildcardTransition(Transition): + __slots__ = 'serializationType' def __init__(self, target:ATNState): super().__init__(target) @@ -220,6 +230,7 @@ class WildcardTransition(Transition): class PrecedencePredicateTransition(AbstractPredicateTransition): + __slots__ = ('serializationType', 'precedence') def __init__(self, target:ATNState, precedence:int): super().__init__(target) @@ -254,4 +265,4 @@ Transition.serializationTypes = { del ATNState del RuleStartState -from antlr4.atn.ATNState import * \ No newline at end of file +from antlr4.atn.ATNState import * diff --git a/runtime/Python3/src/antlr4/dfa/DFA.py b/runtime/Python3/src/antlr4/dfa/DFA.py index af6839ca0..d80589a68 100644 --- a/runtime/Python3/src/antlr4/dfa/DFA.py +++ b/runtime/Python3/src/antlr4/dfa/DFA.py @@ -11,6 +11,7 @@ from antlr4.error.Errors import IllegalStateException class DFA(object): + __slots__ = ('atnStartState', 'decision', '_states', 's0', 'precedenceDfa') def __init__(self, atnStartState:DecisionState, decision:int=0): # From which ATN state did we create this DFA? @@ -130,4 +131,3 @@ class DFA(object): from antlr4.dfa.DFASerializer import LexerDFASerializer serializer = LexerDFASerializer(self) return str(serializer) - diff --git a/runtime/Python3/src/antlr4/dfa/DFASerializer.py b/runtime/Python3/src/antlr4/dfa/DFASerializer.py index eeb6e366c..bca0727b7 100644 --- a/runtime/Python3/src/antlr4/dfa/DFASerializer.py +++ b/runtime/Python3/src/antlr4/dfa/DFASerializer.py @@ -12,6 +12,7 @@ from antlr4.dfa.DFAState import DFAState class DFASerializer(object): + __slots__ = ('dfa', 'literalNames', 'symbolicNames') def __init__(self, dfa:DFA, literalNames:list=None, symbolicNames:list=None): self.dfa = dfa diff --git a/runtime/Python3/src/antlr4/dfa/DFAState.py b/runtime/Python3/src/antlr4/dfa/DFAState.py index d7af5a172..51955a448 100644 --- a/runtime/Python3/src/antlr4/dfa/DFAState.py +++ b/runtime/Python3/src/antlr4/dfa/DFAState.py @@ -11,6 +11,8 @@ from antlr4.atn.SemanticContext import SemanticContext class PredPrediction(object): + __slots__ = ('alt', 'pred') + def __init__(self, pred:SemanticContext, alt:int): self.alt = alt self.pred = pred @@ -43,6 +45,10 @@ class PredPrediction(object): # meaning that state was reached via a different set of rule invocations.

#/ class DFAState(object): + __slots__ = ( + 'stateNumber', 'configs', 'edges', 'isAcceptState', 'prediction', + 'lexerActionExecutor', 'requiresFullContext', 'predicates' + ) def __init__(self, stateNumber:int=-1, configs:ATNConfigSet=ATNConfigSet()): self.stateNumber = stateNumber diff --git a/runtime/Python3/src/antlr4/tree/Chunk.py b/runtime/Python3/src/antlr4/tree/Chunk.py index a2fd16c97..081419a34 100644 --- a/runtime/Python3/src/antlr4/tree/Chunk.py +++ b/runtime/Python3/src/antlr4/tree/Chunk.py @@ -8,6 +8,7 @@ class Chunk(object): pass class TagChunk(Chunk): + __slots__ = ('tag', 'label') def __init__(self, tag:str, label:str=None): self.tag = tag @@ -20,10 +21,10 @@ class TagChunk(Chunk): return self.label + ":" + self.tag class TextChunk(Chunk): + __slots__ = 'text' def __init__(self, text:str): self.text = text def __str__(self): return "'" + self.text + "'" - diff --git a/runtime/Python3/src/antlr4/tree/ParseTreeMatch.py b/runtime/Python3/src/antlr4/tree/ParseTreeMatch.py index bbda73e8f..c02bc0357 100644 --- a/runtime/Python3/src/antlr4/tree/ParseTreeMatch.py +++ b/runtime/Python3/src/antlr4/tree/ParseTreeMatch.py @@ -14,7 +14,7 @@ from antlr4.tree.Tree import ParseTree class ParseTreeMatch(object): - + __slots__ = ('tree', 'pattern', 'labels', 'mismatchedNode') # # Constructs a new instance of {@link ParseTreeMatch} from the specified # parse tree and pattern. diff --git a/runtime/Python3/src/antlr4/tree/ParseTreePattern.py b/runtime/Python3/src/antlr4/tree/ParseTreePattern.py index 1abb880d3..37fd0bf09 100644 --- a/runtime/Python3/src/antlr4/tree/ParseTreePattern.py +++ b/runtime/Python3/src/antlr4/tree/ParseTreePattern.py @@ -14,6 +14,7 @@ from antlr4.xpath.XPath import XPath class ParseTreePattern(object): + __slots__ = ('matcher', 'patternRuleIndex', 'pattern', 'patternTree') # Construct a new instance of the {@link ParseTreePattern} class. # diff --git a/runtime/Python3/src/antlr4/tree/ParseTreePatternMatcher.py b/runtime/Python3/src/antlr4/tree/ParseTreePatternMatcher.py index 07b96408c..62fd197b0 100644 --- a/runtime/Python3/src/antlr4/tree/ParseTreePatternMatcher.py +++ b/runtime/Python3/src/antlr4/tree/ParseTreePatternMatcher.py @@ -89,6 +89,7 @@ class StartRuleDoesNotConsumeFullPattern(Exception): class ParseTreePatternMatcher(object): + __slots__ = ('lexer', 'parser', 'start', 'stop', 'escape') # Constructs a {@link ParseTreePatternMatcher} or from a {@link Lexer} and # {@link Parser} object. The lexer input stream is altered for tokenizing diff --git a/runtime/Python3/src/antlr4/tree/RuleTagToken.py b/runtime/Python3/src/antlr4/tree/RuleTagToken.py index 7b2018fe7..a198f7da1 100644 --- a/runtime/Python3/src/antlr4/tree/RuleTagToken.py +++ b/runtime/Python3/src/antlr4/tree/RuleTagToken.py @@ -13,7 +13,8 @@ from antlr4.Token import Token class RuleTagToken(Token): - # + __slots__ = ('label', 'ruleName') + # # Constructs a new instance of {@link RuleTagToken} with the specified rule # name, bypass token type, and label. # diff --git a/runtime/Python3/src/antlr4/tree/TokenTagToken.py b/runtime/Python3/src/antlr4/tree/TokenTagToken.py index d00327ae9..b7beeb876 100644 --- a/runtime/Python3/src/antlr4/tree/TokenTagToken.py +++ b/runtime/Python3/src/antlr4/tree/TokenTagToken.py @@ -13,7 +13,7 @@ from antlr4.Token import CommonToken class TokenTagToken(CommonToken): - + __slots__ = ('tokenName', 'label') # Constructs a new instance of {@link TokenTagToken} with the specified # token name, type, and label. # diff --git a/runtime/Python3/src/antlr4/tree/Tree.py b/runtime/Python3/src/antlr4/tree/Tree.py index 68660b48b..812acc96b 100644 --- a/runtime/Python3/src/antlr4/tree/Tree.py +++ b/runtime/Python3/src/antlr4/tree/Tree.py @@ -80,6 +80,7 @@ class ParseTreeListener(object): del ParserRuleContext class TerminalNodeImpl(TerminalNode): + __slots__ = ('parentCtx', 'symbol') def __init__(self, symbol:Token): self.parentCtx = None @@ -187,4 +188,4 @@ class ParseTreeWalker(object): ctx.exitRule(listener) listener.exitEveryRule(ctx) -ParseTreeWalker.DEFAULT = ParseTreeWalker() \ No newline at end of file +ParseTreeWalker.DEFAULT = ParseTreeWalker() diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg index 1fdceee02..d140615cf 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Python3/Python3.stg @@ -652,6 +652,7 @@ CaptureNextTokenType(d) ::= " = self._input.LA(1)" StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMembers) ::= << class (ParserRuleContext): + __slots__ = 'parser' def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1:=None}>): super().__init__(parent, invokingState)