From 8217e543eb4b119512b6842d83a05b6f8f3c7748 Mon Sep 17 00:00:00 2001 From: t-gergely Date: Fri, 26 Apr 2019 11:55:43 +0200 Subject: [PATCH 01/20] Update tree-matching.md Deleted redundant and misplaced sample code. --- doc/tree-matching.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/doc/tree-matching.md b/doc/tree-matching.md index f4c6d278c..b0ec83bb5 100644 --- a/doc/tree-matching.md +++ b/doc/tree-matching.md @@ -52,15 +52,6 @@ m.setDelimiters("<<", ">>", "$"); // $ is the escape character This would allow pattern `<> = <> ;$<< ick $>>` to be interpreted as elements: `ID`, ` = `, `expr`, and ` ;<< ick >>`. -```java -String xpath = "//blockStatement/*"; -String treePattern = "int = ;"; -ParseTreePattern p = -parser.compileParseTreePattern(treePattern, -JavaParser.RULE_localVariableDeclarationStatement); -List matches = p.findAll(tree, xpath); -``` - ### Pattern labels The tree pattern matcher tracks the nodes in the tree at matches against the tags in a tree pattern. That way we can use the `get()` and `getAll()` methods to retrieve components of the matched subtree. For example, for pattern ``, `get("ID")` returns the node matched for that `ID`. If more than one node matched the specified token or rule tag, only the first match is returned. If there is no node associated with the label, this returns null. From 3740b2899529da7fc25ef81c919e4d6ee6a71726 Mon Sep 17 00:00:00 2001 From: Massimo Santini Date: Mon, 13 May 2019 16:21:41 +0200 Subject: [PATCH 02/20] Added a missing quote. Added a closing quote. --- doc/actions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/actions.md b/doc/actions.md index ef51c8f4c..9eb61eb52 100644 --- a/doc/actions.md +++ b/doc/actions.md @@ -84,7 +84,7 @@ Using a rule label looks like this: returnStat : 'return' e=expr {System.out.println("matched "+e.text);} ; ``` -You can also use `$ followed by the name of the attribute to access the value associated with the currently executing rule. For example, `$start` is the starting token of the current rule. +You can also use `$` followed by the name of the attribute to access the value associated with the currently executing rule. For example, `$start` is the starting token of the current rule. ``` returnStat : 'return' expr {System.out.println("first token "+$start.getText());} ; From f6f265408ae69d8b482750cd382a968dd9d75243 Mon Sep 17 00:00:00 2001 From: Massimo Santini Date: Mon, 13 May 2019 16:24:40 +0200 Subject: [PATCH 03/20] Adding myself Added my info as per pull request #2552 (I did just because it was requested, feel free to remove my info if you think is more appropriate due to the minimal patch I'm submitting). --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index d081c5482..23048b17a 100644 --- a/contributors.txt +++ b/contributors.txt @@ -216,3 +216,4 @@ YYYY/MM/DD, github id, Full name, email 2019/03/13, base698, Justin Thomas, justin.thomas1@gmail.com 2019/03/18, carlodri, Carlo Dri, carlo.dri@gmail.com 2019/05/02, askingalot, Andy Collins, askingalot@gmail.com +2019/05/13, mapio, Massimo Santini, massimo.santini@gmail.com From d47538d0383ad9968e21059e0afcdad50751dad0 Mon Sep 17 00:00:00 2001 From: Abhijith Neil Abraham Date: Mon, 8 Jul 2019 11:58:25 +0530 Subject: [PATCH 04/20] Update contributors.txt --- contributors.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contributors.txt b/contributors.txt index f4f4010c0..6da2cc4b8 100644 --- a/contributors.txt +++ b/contributors.txt @@ -217,4 +217,5 @@ YYYY/MM/DD, github id, Full name, email 2019/02/06, ralucado, Cristina Raluca Vijulie, ralucris.v[at]gmail[dot]com 2019/03/13, base698, Justin Thomas, justin.thomas1@gmail.com 2019/03/18, carlodri, Carlo Dri, carlo.dri@gmail.com -2019/05/02, askingalot, Andy Collins, askingalot@gmail.com \ No newline at end of file +2019/05/02, askingalot, Andy Collins, askingalot@gmail.com +2019/07/08, abhijithneilabraham,Abhijith Neil Abraham, abhijithneilabrahampk@gmail.com From 925408d08b928071b1fec133e3dce026cd9bbf14 Mon Sep 17 00:00:00 2001 From: thron7 Date: Fri, 2 Aug 2019 11:46:19 +0200 Subject: [PATCH 05/20] (minor) word slip --- doc/lexer-rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lexer-rules.md b/doc/lexer-rules.md index 5070f4790..382fe4cb9 100644 --- a/doc/lexer-rules.md +++ b/doc/lexer-rules.md @@ -25,7 +25,7 @@ fragment DIGIT : [0-9] ; // not a token by itself ## Lexical Modes -Modes allow you to group lexical rules by context, such as inside and outside of XML tags. It’s like having multiple sublexers, one for context. The lexer can only return tokens matched by entering a rule in the current mode. Lexers start out in the so-called default mode. All rules are considered to be within the default mode unless you specify a mode command. Modes are not allowed within combined grammars, just lexer grammars. (See grammar `XMLLexer` from [Tokenizing XML](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference).) +Modes allow you to group lexical rules by context, such as inside and outside of XML tags. It’s like having multiple sublexers, one for each context. The lexer can only return tokens matched by entering a rule in the current mode. Lexers start out in the so-called default mode. All rules are considered to be within the default mode unless you specify a mode command. Modes are not allowed within combined grammars, just lexer grammars. (See grammar `XMLLexer` from [Tokenizing XML](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference).) ``` rules in default mode From ca5b581c1f218ce3dbd63041734b59be0c4c22de Mon Sep 17 00:00:00 2001 From: thron7 Date: Fri, 2 Aug 2019 11:57:49 +0200 Subject: [PATCH 06/20] Update contributors.txt --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index d40bacd5f..08ce09b49 100644 --- a/contributors.txt +++ b/contributors.txt @@ -221,3 +221,4 @@ YYYY/MM/DD, github id, Full name, email 2019/07/11, olowo726, Olof Wolgast, olof@baah.se 2019/07/16, abhijithneilabraham, Abhijith Neil Abraham, abhijithneilabrahampk@gmail.com 2019/07/26, Braavos96, Eric Hettiaratchi, erichettiaratchi@gmail.com +2019/08/02, thron7, Thomas Herchenroeder, thron7[at]users[dot]sourceforge[dot]net From e2ee6e86dfc385247b6efcaaff87dc6e8485af98 Mon Sep 17 00:00:00 2001 From: Eason Lin Date: Mon, 12 Aug 2019 18:01:09 +0800 Subject: [PATCH 07/20] [Golang] enable syntax highlighting --- doc/go-target.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/go-target.md b/doc/go-target.md index 4f7e64e05..695f1564f 100644 --- a/doc/go-target.md +++ b/doc/go-target.md @@ -65,7 +65,7 @@ Another common option to the ANTLR tool is `-visitor`, which generates a parse t We'll write a small main func to call the generated parser/lexer (assuming they are separate). This one writes out the encountered `ParseTreeContext`'s. Suppose the gen'ed parser code is in the `parser` directory relative to this code: -``` +```golang package main import ( From 0fa34a9621989985ef1002468f15843e75f60e1f Mon Sep 17 00:00:00 2001 From: Eason Lin Date: Mon, 12 Aug 2019 18:06:56 +0800 Subject: [PATCH 08/20] sign contributors.txt --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index d40bacd5f..b917153d6 100644 --- a/contributors.txt +++ b/contributors.txt @@ -221,3 +221,4 @@ YYYY/MM/DD, github id, Full name, email 2019/07/11, olowo726, Olof Wolgast, olof@baah.se 2019/07/16, abhijithneilabraham, Abhijith Neil Abraham, abhijithneilabrahampk@gmail.com 2019/07/26, Braavos96, Eric Hettiaratchi, erichettiaratchi@gmail.com +2019/08/12, easonlin404, Eason Lin, easonlin404@gmail.com From 5a711ac79ce635b890cec3bb557166ec157ad7d3 Mon Sep 17 00:00:00 2001 From: Markus Franke Date: Tue, 27 Aug 2019 13:26:04 +0200 Subject: [PATCH 09/20] Fix escaping of angle brackets --- runtime/Cpp/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Cpp/README.md b/runtime/Cpp/README.md index 73fab634f..79bd27884 100644 --- a/runtime/Cpp/README.md +++ b/runtime/Cpp/README.md @@ -55,11 +55,11 @@ Either open the included XCode project and build that or use the cmake compilati Try run cmake -DCMAKE_ANDROID_NDK=/folder/of/android_ndkr17_and_above -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=14 -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_BUILD_TYPE=Release /folder/antlr4_src_dir -G Ninja. #### Compiling on Linux -- cd /runtime/Cpp (this is where this readme is located) +- cd \/runtime/Cpp (this is where this readme is located) - mkdir build && mkdir run && cd build - cmake .. -DANTLR_JAR_LOCATION=full/path/to/antlr4-4.5.4-SNAPSHOT.jar -DWITH_DEMO=True - make -- DESTDIR=/runtime/Cpp/run make install +- DESTDIR=\/runtime/Cpp/run make install If you don't want to build the demo then simply run cmake without parameters. There is another cmake script available in the subfolder cmake/ for those who prefer the superbuild cmake pattern. From 97e61c07cad52efff8feecc74e2fb2f5733f633a Mon Sep 17 00:00:00 2001 From: Markus Franke Date: Tue, 27 Aug 2019 13:36:07 +0200 Subject: [PATCH 10/20] Update contributors file --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index d40bacd5f..a6abdb2f1 100644 --- a/contributors.txt +++ b/contributors.txt @@ -221,3 +221,4 @@ YYYY/MM/DD, github id, Full name, email 2019/07/11, olowo726, Olof Wolgast, olof@baah.se 2019/07/16, abhijithneilabraham, Abhijith Neil Abraham, abhijithneilabrahampk@gmail.com 2019/07/26, Braavos96, Eric Hettiaratchi, erichettiaratchi@gmail.com +2019/08/27, wurzelpeter, Markus Franke, markus[hyphen]franke[at]web[dot]de From e8d7e0943dfd424c118fb0dd1ea6de972f7a850e Mon Sep 17 00:00:00 2001 From: "Sean C. Sullivan" Date: Sun, 15 Sep 2019 14:20:11 -0700 Subject: [PATCH 11/20] maven-compiler-plugin 3.8.1 (latest version) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e636655cf..6cd7fe26e 100644 --- a/pom.xml +++ b/pom.xml @@ -151,7 +151,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.6.0 + 3.8.1 ${maven.compiler.source} ${maven.compiler.target} From 144f9eaff88cf1a04c4c152460c5649cfd1a48ad Mon Sep 17 00:00:00 2001 From: "Sean C. Sullivan" Date: Sun, 15 Sep 2019 14:21:36 -0700 Subject: [PATCH 12/20] maven-plugin-plugin 3.6.0 (latest version) --- antlr4-maven-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/antlr4-maven-plugin/pom.xml b/antlr4-maven-plugin/pom.xml index 6e57f5e79..7d2608f3e 100644 --- a/antlr4-maven-plugin/pom.xml +++ b/antlr4-maven-plugin/pom.xml @@ -120,7 +120,7 @@ org.apache.maven.plugins maven-plugin-plugin - 3.3 + 3.6.0 true From bc7690f4497dcc0818d924672ba0959f0aee83e3 Mon Sep 17 00:00:00 2001 From: "Sean C. Sullivan" Date: Sun, 15 Sep 2019 14:23:12 -0700 Subject: [PATCH 13/20] add [sullis] to contributors.txt --- contributors.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contributors.txt b/contributors.txt index 6ff7f398d..1cc89fcc2 100644 --- a/contributors.txt +++ b/contributors.txt @@ -225,4 +225,5 @@ YYYY/MM/DD, github id, Full name, email 2019/09/03, João Henrique, johnnyonflame@hotmail.com 2019/09/10, yar3333, Yaroslav Sivakov, yar3333@gmail.com 2019/09/10, marcospassos, Marcos Passos, marcospassos.com@gmail.com -2019/09/10, amorimjuliana, Juliana Amorim, juu.amorim@gmail.com \ No newline at end of file +2019/09/10, amorimjuliana, Juliana Amorim, juu.amorim@gmail.com +2019/09/15, sullis, Sean Sullivan, github@seansullivan.com From 2758f0ba020e9b88c1ccf599e52c955fec51bc22 Mon Sep 17 00:00:00 2001 From: Ben List Date: Wed, 6 Nov 2019 09:00:01 -0500 Subject: [PATCH 14/20] Missing lexer/parermodifier clarification in example --- doc/lexicon.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lexicon.md b/doc/lexicon.md index 078dc3e7a..5ae203515 100644 --- a/doc/lexicon.md +++ b/doc/lexicon.md @@ -26,8 +26,8 @@ The Javadoc comments are hidden from the parser and are ignored at the moment. Token names always start with a capital letter and so do lexer rules as defined by Java’s `Character.isUpperCase` method. Parser rule names always start with a lowercase letter (those that fail `Character.isUpperCase`). The initial character can be followed by uppercase and lowercase letters, digits, and underscores. Here are some sample names: ``` -ID, LPAREN, RIGHT_CURLY // token names/rules -expr, simpleDeclarator, d2, header_file // rule names +ID, LPAREN, RIGHT_CURLY // token names/lexer rules +expr, simpleDeclarator, d2, header_file // parser rule names ``` Like Java, ANTLR accepts Unicode characters in ANTLR names: From 9d29a1aa1e42d36b1b4747c49da2793624c2ff7a Mon Sep 17 00:00:00 2001 From: Ben List Date: Wed, 6 Nov 2019 09:02:51 -0500 Subject: [PATCH 15/20] Signed contributors.txt --- contributors.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contributors.txt b/contributors.txt index 9751a6e90..e0d902148 100644 --- a/contributors.txt +++ b/contributors.txt @@ -230,4 +230,5 @@ YYYY/MM/DD, github id, Full name, email 2019/09/10, amorimjuliana, Juliana Amorim, juu.amorim@gmail.com 2019/09/17, kaz, Kazuki Sawada, kazuki@6715.jp 2019/09/28, lmy269, Mingyang Liu, lmy040758@gmail.com -2019/10/31, a-square, Alexei Averchenko, lex.aver@gmail.com \ No newline at end of file +2019/10/31, a-square, Alexei Averchenko, lex.aver@gmail.com +2019/11/05, listba, Ben List, ben.list89@gmail.com From 5b785e8c997e161edff47d8d56e6805818556b7c Mon Sep 17 00:00:00 2001 From: praveen4463 Date: Tue, 21 Jan 2020 19:54:55 +0530 Subject: [PATCH 16/20] fixing a typo, was role instead of rule fixing a typo, was role instead of rule --- doc/lexer-rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lexer-rules.md b/doc/lexer-rules.md index 5070f4790..c74bb3fff 100644 --- a/doc/lexer-rules.md +++ b/doc/lexer-rules.md @@ -123,7 +123,7 @@ ESC : '\\' . ; // match any escaped \x character {«action»} -Lexer actions can appear anywhere as of 4.2, not just at the end of the outermost alternative. The lexer executes the actions at the appropriate input position, according to the placement of the action within the rule. To execute a single action for a role that has multiple alternatives, you can enclose the alts in parentheses and put the action afterwards: +Lexer actions can appear anywhere as of 4.2, not just at the end of the outermost alternative. The lexer executes the actions at the appropriate input position, according to the placement of the action within the rule. To execute a single action for a rule that has multiple alternatives, you can enclose the alts in parentheses and put the action afterwards:
 END : ('endif'|'end') {System.out.println("found an end");} ;

From 3b76f1d61f1299a493c80acf9c85e11ca9a5972c Mon Sep 17 00:00:00 2001
From: Nathanael Demacon 
Date: Mon, 17 Feb 2020 11:11:28 +0100
Subject: [PATCH 17/20] Update cpp-target.md code

---
 doc/cpp-target.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/cpp-target.md b/doc/cpp-target.md
index eec7cf88b..1fc8e8684 100644
--- a/doc/cpp-target.md
+++ b/doc/cpp-target.md
@@ -65,7 +65,7 @@ int main(int argc, const char* argv[]) {
 
   tree::ParseTree *tree = parser.key();
   TreeShapeListener listener;
-  tree::ParseTreeWalker::DEFAULT->walk(&listener, tree);
+  tree::ParseTreeWalker::DEFAULT.walk(&listener, tree);
 
   return 0;
 }

From f2830be501b5ff7872316aff0652e108a07fdb08 Mon Sep 17 00:00:00 2001
From: Nathanael Demacon 
Date: Mon, 17 Feb 2020 11:13:22 +0100
Subject: [PATCH 18/20] Update contributors.txt

---
 contributors.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contributors.txt b/contributors.txt
index bea8d1123..9ab0f33bc 100644
--- a/contributors.txt
+++ b/contributors.txt
@@ -239,3 +239,4 @@ YYYY/MM/DD, github id, Full name, email
 2019/11/18, mlilback, Mark Lilback, mark@lilback.com
 2020/02/02, carocad, Camilo Roca, carocad@unal.edu.co
 2020/02/10, julibert, Julián Bermúdez Ortega, julibert.dev@gmail.com
+2020/02/17, quantumsheep, Nathanael Demacon, nathanael.dmc@outlook.fr

From db4e0252de65c821603908a822112a12ffe9e868 Mon Sep 17 00:00:00 2001
From: Leon Wehmeier 
Date: Wed, 8 Apr 2020 16:53:54 +0200
Subject: [PATCH 19/20] Signed contributors.md

---
 contributors.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contributors.txt b/contributors.txt
index ee58ff694..7659415fe 100644
--- a/contributors.txt
+++ b/contributors.txt
@@ -240,4 +240,5 @@ YYYY/MM/DD, github id, Full name, email
 2020/02/02, carocad, Camilo Roca, carocad@unal.edu.co
 2020/02/10, julibert, Julián Bermúdez Ortega, julibert.dev@gmail.com
 2020/02/21, StochasticTinkr, Daniel Pitts, github@coloraura.com
-2020/03/17, XsongyangX, Song Yang, songyang1218@gmail.com
\ No newline at end of file
+2020/03/17, XsongyangX, Song Yang, songyang1218@gmail.com
+2020/04/08, lwehmeier, Leon Wehmeier, wehmeier@st.ovgu.de

From 83dcc58ae6584a2ddf414f0ef256d68d433d7f12 Mon Sep 17 00:00:00 2001
From: Leon Wehmeier 
Date: Wed, 8 Apr 2020 16:55:38 +0200
Subject: [PATCH 20/20] cpp-target.md: fixed link to "Antlr4 for C++ with
 CMake: A practical example" blog post

---
 doc/cpp-target.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/cpp-target.md b/doc/cpp-target.md
index eec7cf88b..6104ac1d9 100644
--- a/doc/cpp-target.md
+++ b/doc/cpp-target.md
@@ -1,6 +1,6 @@
 # C++
 
-The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library. Also see [Antlr4 for C++ with CMake: A practical example](http://blorente.me//Antlr-,-C++-and-CMake-Wait-what.html).
+The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library. Also see [Antlr4 for C++ with CMake: A practical example](http://blorente.me/beyond-the-loop/Antlr-cpp-cmake/).
 
 ## How to create a C++ lexer or parser?
 This is pretty much the same as creating a Java lexer or parser, except you need to specify the language target, for example: