From 6e780c90bb7d453d76b87bb5ab1540d4cb4e4718 Mon Sep 17 00:00:00 2001 From: Andreas Jonson Date: Fri, 19 Aug 2016 22:22:05 +0200 Subject: [PATCH 1/3] update the runtime paths to work in windows the old paths contained a / at the beginning of the path e.g. "/C:/" but the expected path is "C:/" and due to this all test for the targets javascript, python and c# failed on windows. --- contributors.txt | 1 + .../test/org/antlr/v4/test/runtime/csharp/BaseTest.java | 3 +++ .../antlr/v4/test/runtime/javascript/node/BaseTest.java | 7 +++++++ .../org/antlr/v4/test/runtime/python/BasePythonTest.java | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/contributors.txt b/contributors.txt index 687eeaf20..7d7311c82 100644 --- a/contributors.txt +++ b/contributors.txt @@ -92,3 +92,4 @@ YYYY/MM/DD, github id, Full name, email 2016/03/27, beardlybread, Bradley Steinbacher, bradley.j.steinbacher@gmail.com 2016/03/29, msteiger, Martin Steiger, antlr@martin-steiger.de 2016/03/28, gagern, Martin von Gagern, gagern@ma.tum.de +2016/08/19, andjo403, Andreas Jonson, andjo403@hotmail.com diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseTest.java index 23eb6eca4..14848a7aa 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/csharp/BaseTest.java @@ -482,6 +482,9 @@ public abstract class BaseTest { 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); diff --git a/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/node/BaseTest.java b/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/node/BaseTest.java index 59b68d14c..8db0f0716 100644 --- a/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/node/BaseTest.java +++ b/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/node/BaseTest.java @@ -445,9 +445,16 @@ public abstract class BaseTest { if ( runtimeSrc==null ) { throw new RuntimeException("Cannot find JavaScript runtime"); } + if(isWindows()){ + return runtimeSrc.getPath().replaceFirst("/", ""); + } return runtimeSrc.getPath(); } + private boolean isWindows() { + return System.getProperty("os.name").toLowerCase().contains("windows"); + } + public void testErrors(String[] pairs, boolean printTree) { for (int i = 0; i < pairs.length; i += 2) { String input = pairs[i]; 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 ab91d9b02..f221f3008 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 @@ -583,9 +583,16 @@ public abstract class BasePythonTest { if ( runtimeSrc==null ) { throw new RuntimeException("Cannot find "+targetName+" runtime"); } + if(isWindows()){ + return runtimeSrc.getPath().replaceFirst("/", ""); + } return runtimeSrc.getPath(); } + private boolean isWindows() { + return System.getProperty("os.name").toLowerCase().contains("windows"); + } + public void testErrors(String[] pairs, boolean printTree) { for (int i = 0; i < pairs.length; i+=2) { String input = pairs[i]; From d3ceee50430f77e2c3672f2ae925e29b28400186 Mon Sep 17 00:00:00 2001 From: Eric Vergnaud Date: Sat, 24 Sep 2016 00:02:18 +0800 Subject: [PATCH 2/3] Enhancing the doc --- doc/adding-tests.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/adding-tests.md b/doc/adding-tests.md index 769383d31..4da6d4093 100644 --- a/doc/adding-tests.md +++ b/doc/adding-tests.md @@ -63,7 +63,22 @@ TestTemplates ::= [ ... ``` -For every name mentioned, you will find a `.stg` file with the actual test. E.g., `Sets/StarSet.stg`: +For every name mentioned, you will find a `.stg` file with the actual test template. E.g., `Sets/StarSet.stg`. + +Each `.stg` file descripes the following mandatory elements for the test: + - the test type: "Parser" or "Lexer" + - some ANTLR options, such as "Debug" + - the grammar + - the start rule + - the input i.e. the text to parse + - the expected output + - the expected errors + +The grammar can itself contain template expressions such as . +The test generator replaces these with the corresponding values from the target language template (see below). +It then generates a unit test in which the grammar, the input and the expected output and errors are inlined. + +Here is an example test template: ``` TestType() ::= "Parser" @@ -92,6 +107,7 @@ a : ('a'|'b')* 'c' {} ; >> ``` + ### Cross-language actions embedded within grammars To get: From 2f92b475003e1dd4254a519a88bf10c3667de1c6 Mon Sep 17 00:00:00 2001 From: parrt Date: Fri, 23 Sep 2016 13:19:44 -0700 Subject: [PATCH 3/3] tweak links in doc --- README.md | 12 ++++++------ doc/building-antlr.md | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c1d6902de..e743269a7 100644 --- a/README.md +++ b/README.md @@ -15,18 +15,18 @@ ANTLR project lead and supreme dictator for life ## Useful information * [Release notes](https://github.com/antlr/antlr4/releases) -* [Getting started with v4](https://raw.githubusercontent.com/antlr/antlr4/master/doc/getting-started.md) +* [Getting started with v4](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md) * [Official site](http://www.antlr.org/) -* [Documentation](https://raw.githubusercontent.com/antlr/antlr4/master/doc/index.md) -* [FAQ](https://raw.githubusercontent.com/antlr/antlr4/master/doc/faq/index.md) +* [Documentation](https://github.com/antlr/antlr4/blob/master/doc/index.md) +* [FAQ](https://github.com/antlr/antlr4/blob/master/doc/faq/index.md) * [API](http://www.antlr.org/api/Java/index.html) * [ANTLR v3](http://www.antlr3.org/) -* [v3 to v4 Migration, differences](https://raw.githubusercontent.com/antlr/antlr4/master/doc/faq/general.md) +* [v3 to v4 Migration, differences](https://github.com/antlr/antlr4/blob/master/doc/faq/general.md) You might also find the following pages useful, particularly if you want to mess around with the various target languages. -* [How to build ANTLR itself](https://raw.githubusercontent.com/antlr/antlr4/master/doc/building-antlr.md) -* [How we create and deploy an ANTLR release](https://raw.githubusercontent.com/antlr/antlr4/master/doc/releasing-antlr.md) +* [How to build ANTLR itself](https://github.com/antlr/antlr4/blob/master/doc/building-antlr.md) +* [How we create and deploy an ANTLR release](https://github.com/antlr/antlr4/blob/master/doc/releasing-antlr.md) ## The Definitive ANTLR 4 Reference diff --git a/doc/building-antlr.md b/doc/building-antlr.md index f6780d970..b054438d1 100644 --- a/doc/building-antlr.md +++ b/doc/building-antlr.md @@ -13,14 +13,14 @@ The first step is to get the Java source code from the ANTLR 4 repository at git ```bash $ cd /tmp -/tmp $ git clone git@github.com:antlr/antlr4.git +/tmp $ git clone https://github.com/antlr/antlr4.git Cloning into 'antlr4'... -remote: Counting objects: 43273, done. -remote: Compressing objects: 100% (57/57), done. -remote: Total 43273 (delta 26), reused 0 (delta 0) -Receiving objects: 100% (43273/43273), 18.76 MiB | 1.60 MiB/s, done. -Resolving deltas: 100% (22419/22419), done. +remote: Counting objects: 61480, done. +remote: Total 61480 (delta 0), reused 0 (delta 0), pack-reused 61480 +Receiving objects: 100% (61480/61480), 31.24 MiB | 7.18 MiB/s, done. +Resolving deltas: 100% (32970/32970), done. Checking connectivity... done. +Checking out files: 100% (1427/1427), done. ``` # Compile