update version number and tweak doc

This commit is contained in:
parrt 2017-12-08 12:47:11 -08:00
parent f113891e06
commit 763a1242b7
29 changed files with 215 additions and 42 deletions

View File

@ -6,7 +6,7 @@ Hi and welcome to the version 4 release of ANTLR! It's named after the fearless
ANTLR is really two things: a tool that translates your grammar to a parser/lexer in Java (or other target language) and the runtime needed by the generated parsers/lexers. Even if you are using the ANTLR Intellij plug-in or ANTLRWorks to run the ANTLR tool, the generated code will still need the runtime library.
The first thing you should do is probably download and install a development tool plug-in. Even if you only use such tools for editing, they are great. Then, follow the instructions below to get the runtime environment available to your system to run generated parsers/lexers. In what follows, I talk about antlr-4.7-complete.jar, which has the tool and the runtime and any other support libraries (e.g., ANTLR v4 is written in v3).
The first thing you should do is probably download and install a development tool plug-in. Even if you only use such tools for editing, they are great. Then, follow the instructions below to get the runtime environment available to your system to run generated parsers/lexers. In what follows, I talk about antlr-4.7.1-complete.jar, which has the tool and the runtime and any other support libraries (e.g., ANTLR v4 is written in v3).
If you are going to integrate ANTLR into your existing build system using mvn, ant, or want to get ANTLR into your IDE such as eclipse or intellij, see Integrating ANTLR into Development Systems.
@ -16,21 +16,21 @@ If you are going to integrate ANTLR into your existing build system using mvn, a
1. Download
```
$ cd /usr/local/lib
$ curl -O http://www.antlr.org/download/antlr-4.7-complete.jar
$ curl -O http://www.antlr.org/download/antlr-4.7.1-complete.jar
```
Or just download in browser from website:
[http://www.antlr.org/download.html](http://www.antlr.org/download.html)
and put it somewhere rational like `/usr/local/lib`.
2. Add `antlr-4.7-complete.jar` to your `CLASSPATH`:
2. Add `antlr-4.7.1-complete.jar` to your `CLASSPATH`:
```
$ export CLASSPATH=".:/usr/local/lib/antlr-4.7-complete.jar:$CLASSPATH"
$ export CLASSPATH=".:/usr/local/lib/antlr-4.7.1-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.7-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.7.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
$ alias grun='java org.antlr.v4.gui.TestRig'
```
@ -45,7 +45,7 @@ Save to your directory for 3rd party Java libraries, say `C:\Javalib`
* Permanently: Using System Properties dialog > Environment variables > Create or append to `CLASSPATH` variable
* Temporarily, at command line:
```
SET CLASSPATH=.;C:\Javalib\antlr-4.7-complete.jar;%CLASSPATH%
SET CLASSPATH=.;C:\Javalib\antlr-4.7.1-complete.jar;%CLASSPATH%
```
3. Create short convenient commands for the ANTLR Tool, and TestRig, using batch files or doskey commands:
* Batch files (in directory in system PATH) antlr4.bat and grun.bat
@ -67,7 +67,7 @@ Either launch org.antlr.v4.Tool directly:
```
$ java org.antlr.v4.Tool
ANTLR Parser Generator Version 4.7
ANTLR Parser Generator Version 4.7.1
-o ___ specify output directory where all output is generated
-lib ___ specify location of .tokens files
...
@ -76,8 +76,8 @@ ANTLR Parser Generator Version 4.7
or use -jar option on java:
```
$ java -jar /usr/local/lib/antlr-4.7-complete.jar
ANTLR Parser Generator Version 4.7
$ java -jar /usr/local/lib/antlr-4.7.1-complete.jar
ANTLR Parser Generator Version 4.7.1
-o ___ specify output directory where all output is generated
-lib ___ specify location of .tokens files
...

View File

@ -4,7 +4,7 @@ If you invoke the ANTLR tool without command line arguments, youll get a help
```bash
$ antlr4
ANTLR Parser Generator Version 4.5
ANTLR Parser Generator Version 4.7.1
-o ___ specify output directory where all output is generated
-lib ___ specify location of grammars, tokens files
-atn generate rule augmented transition network diagrams
@ -23,6 +23,7 @@ ANTLR Parser Generator Version 4.5
-XdbgSTWait wait for STViz to close before continuing
-Xforce-atn use the ATN simulator for all predictions
-Xlog dump lots of logging info to antlr-timestamp.log
-Xexact-output-dir all output goes into -o dir regardless of paths/package
```
Here are more details on the options:
@ -159,3 +160,175 @@ This option creates a log file containing lots of information messages from ANTL
$ antlr4 -Xlog T.g4
wrote ./antlr-2012-09-06-17.56.19.log
```
## `-Xexact-output-dir`
(*See the [discussion](https://github.com/antlr/antlr4/pull/2065)*).
All output goes into `-o` dir regardless of paths/package.
* Output `-o` directory specifier is the exact directory containing the output. Previously it would include the relative path specified on the grammar itself for the purposes of packages.
**new**: `-o /tmp subdir/T.g4` => `/tmp/subdir/T.java`
**old**: `-o /tmp subdir/T.g4` => `/tmp/T.java`
* Previously we looked for the tokens vocab file in the `-lib` dir or in the output dir. **New**: also look in the directory containing the grammar, particularly if it it is specified with a path.
### Example for the output directory (4.7)
Here is the existing 4.7 functionality.
(For these examples, assume a4.7 and a4.7.1 are aliases to the right version of ANTLR's `org.antlr.v4.Tool`.)
```bash
$ cd /tmp/parrt
$ tree
.
├── B.g4
└── src
└── pkg
└── A.g4
$ a4.7 -o /tmp/build src/pkg/A.g4
$ tree /tmp/build
/tmp/build/
└── src
└── pkg
├── A.tokens
├── ABaseListener.java
├── ALexer.java
├── ALexer.tokens
├── AListener.java
└── AParser.java
```
Now, let's build a grammar that sits in the current directory:
```bash
$ a4.7 -o /tmp/build B.g4
$ tree /tmp/build
/tmp/build
├── B.tokens
├── BBaseListener.java
├── BLexer.java
├── BLexer.tokens
├── BListener.java
├── BParser.java
└── src
└── pkg
├── A.tokens
├── ABaseListener.java
├── ALexer.java
├── ALexer.tokens
├── AListener.java
└── AParser.java
```
Finally, if we don't specify the output directory, it paid attention to the relative path specified on the input grammar:
```bash
$ a4.7 src/pkg/A.g4
$ tree
.
├── B.g4
└── src
└── pkg
├── A.g4
├── A.tokens
├── ABaseListener.java
├── ALexer.java
├── ALexer.tokens
├── AListener.java
└── AParser.java
```
### Example for the output directory (4.7.1 with -Xexact-output-dir)
Now, the output directory is the exact directory where output is generated regardless of relative paths on the grammar
```bash
$ cd /tmp/parrt
$ a4.7.1 -Xexact-output-dir -o /tmp/build src/pkg/A.g4
$ tree /tmp/build
/tmp/build
├── A.tokens
├── ABaseListener.java
├── ALexer.java
├── ALexer.tokens
├── AListener.java
└── AParser.java
```
If you use the package option, it still does not change where the output is generated if you use `-o`
```bash
$ a4.7.1 -Xexact-output-dir -package pkg -o /tmp/build src/pkg/A.g4
$ tree /tmp/build
/tmp/build
├── A.tokens
├── ABaseListener.java
├── ALexer.java
├── ALexer.tokens
├── AListener.java
└── AParser.java
```
4.7.1 does however add the package specification into the generated files:
```bash
$ grep package /tmp/build/A*.java
/tmp/build/ABaseListener.java:package pkg;
/tmp/build/ALexer.java:package pkg;
/tmp/build/AListener.java:package pkg;
/tmp/build/AParser.java:package pkg;
```
Compare this to 4.7:
```bash
$ a4.7 -package pkg -o /tmp/build src/pkg/A.g4
beast:/tmp/parrt $ tree /tmp/build
/tmp/build
└── src
└── pkg
├── A.tokens
├── ABaseListener.java
├── ALexer.java
├── ALexer.tokens
├── AListener.java
└── AParser.java
```
### Example of where it looks for tokens vocab
In 4.7, we got an error for an obvious case that should work:
```bash
$ cd /tmp/parrt
$ tree
.
└── src
└── pkg
├── L.g4
└── P.g4
$ a4.7 -o /tmp/build src/pkg/*.g4
error(160): P.g4:2:21: cannot find tokens file /tmp/build/L.tokens
warning(125): P.g4:3:4: implicit definition of token A in parser
```
In 4.7.1 it looks in the directory containing the grammars as well:
```bash
$ a4.7.1 -o /tmp/build src/pkg/*.g4
$ tree /tmp/build
/tmp/build
├── L.java
├── L.tokens
├── P.java
├── P.tokens
├── PBaseListener.java
├── PListener.java
└── src
└── pkg
├── L.java
└── L.tokens
```

View File

@ -43,7 +43,7 @@ See the docs and the book to learn about writing lexer and parser grammars.
### Step 4: Generate the C# code
This can be done either from the cmd line, or by adding a custom pre-build command in your project.
At minimal, the cmd line should look as follows: ``java -jar antlr4-4.7.jar -Dlanguage=CSharp grammar.g4``
At minimal, the cmd line should look as follows: ``java -jar antlr4-4.7.1.jar -Dlanguage=CSharp grammar.g4``
This will generate the files, which you can then integrate in your project.
This is just a quick start. The tool has many useful options to control generation, please refer to its documentation.

View File

@ -42,8 +42,8 @@ using System.Runtime.InteropServices;
// 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.7")]
[assembly: AssemblyVersion("4.7.1")]
#if !COMPACT
[assembly: AssemblyFileVersion("4.7")]
[assembly: AssemblyInformationalVersion("4.7")]
[assembly: AssemblyFileVersion("4.7.1")]
[assembly: AssemblyInformationalVersion("4.7.1")]
#endif

View File

@ -1 +1 @@
4.7
4.7.1

View File

@ -66,7 +66,7 @@ set(ANTLR4CPP_EXTERNAL_ROOT ${CMAKE_BINARY_DIR}/externals/antlr4cpp)
# external repository
# GIT_REPOSITORY https://github.com/antlr/antlr4.git
set(ANTLR4CPP_EXTERNAL_REPO "https://github.com/antlr/antlr4.git")
set(ANTLR4CPP_EXTERNAL_TAG "4.7")
set(ANTLR4CPP_EXTERNAL_TAG "4.7.1")
if(NOT EXISTS "${ANTLR4CPP_JAR_LOCATION}")
message(FATAL_ERROR "Unable to find antlr tool. ANTLR4CPP_JAR_LOCATION:${ANTLR4CPP_JAR_LOCATION}")

View File

@ -6,7 +6,7 @@
:: Download the ANLTR jar and place it in the same folder as this script (or adjust the LOCATION var accordingly).
set LOCATION=antlr-4.7-complete.jar
set LOCATION=antlr-4.7.1-complete.jar
java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
::java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
::java -jar %LOCATION% -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4

View File

@ -7,7 +7,7 @@
using namespace antlr4;
const std::string RuntimeMetaData::VERSION = "4.7";
const std::string RuntimeMetaData::VERSION = "4.7.1";
std::string RuntimeMetaData::getRuntimeVersion() {
return VERSION;

View File

@ -49,7 +49,7 @@ var tokenTypeMapCache = make(map[string]int)
var ruleIndexMapCache = make(map[string]int)
func (b *BaseRecognizer) checkVersion(toolVersion string) {
runtimeVersion := "4.7"
runtimeVersion := "4.7.1"
if runtimeVersion != toolVersion {
fmt.Println("ANTLR runtime and generated code versions disagree: " + runtimeVersion + "!=" + toolVersion)
}

View File

@ -67,7 +67,7 @@ public class RuntimeMetaData {
* omitted.</li>
* </ul>
*/
public static final String VERSION = "4.7";
public static final String VERSION = "4.7.1";
/**
* Gets the currently executing version of the ANTLR 4 runtime library.

View File

@ -21,7 +21,7 @@ Recognizer.ruleIndexMapCache = {};
Recognizer.prototype.checkVersion = function(toolVersion) {
var runtimeVersion = "4.7";
var runtimeVersion = "4.7.1";
if (runtimeVersion!==toolVersion) {
console.log("ANTLR runtime and generated code versions disagree: "+runtimeVersion+"!="+toolVersion);
}

View File

@ -1,6 +1,6 @@
{
"name": "antlr4",
"version": "4.7.0",
"version": "4.7.1",
"description": "JavaScript runtime for ANTLR4",
"main": "src/antlr4/index.js",
"repository": "antlr/antlr4.git",

View File

@ -2,12 +2,12 @@ from distutils.core import setup
setup(
name='antlr4-python2-runtime',
version='4.7',
version='4.7.1',
packages=['antlr4', 'antlr4.atn', 'antlr4.dfa', 'antlr4.tree', 'antlr4.error', 'antlr4.xpath'],
package_dir={'': 'src'},
url='http://www.antlr.org',
license='BSD',
author='Eric Vergnaud, Terence Parr, Sam Harwell',
author_email='eric.vergnaud@wanadoo.fr',
description='ANTLR 4.7 runtime for Python 2.7.6'
description='ANTLR 4.7.1 runtime for Python 2.7.6'
)

View File

@ -30,7 +30,7 @@ class Recognizer(object):
return major, minor
def checkVersion(self, toolVersion):
runtimeVersion = "4.7"
runtimeVersion = "4.7.1"
rvmajor, rvminor = self.extractVersion(runtimeVersion)
tvmajor, tvminor = self.extractVersion(toolVersion)
if rvmajor!=tvmajor or rvminor!=tvminor:

View File

@ -39,7 +39,7 @@ class TestLexer(Lexer):
def __init__(self, input=None):
super(TestLexer, self).__init__(input)
self.checkVersion("4.7")
self.checkVersion("4.7.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None
@ -95,7 +95,7 @@ class TestLexer2(Lexer):
def __init__(self, input=None):
super(TestLexer2, self).__init__(input)
self.checkVersion("4.7")
self.checkVersion("4.7.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None

View File

@ -2,12 +2,12 @@ from distutils.core import setup
setup(
name='antlr4-python3-runtime',
version='4.7',
version='4.7.1',
packages=['antlr4', 'antlr4.atn', 'antlr4.dfa', 'antlr4.tree', 'antlr4.error', 'antlr4.xpath'],
package_dir={'': 'src'},
url='http://www.antlr.org',
license='BSD',
author='Eric Vergnaud, Terence Parr, Sam Harwell',
author_email='eric.vergnaud@wanadoo.fr',
description='ANTLR 4.7 runtime for Python 3.4.0'
description='ANTLR 4.7.1 runtime for Python 3.4.0'
)

View File

@ -33,7 +33,7 @@ class Recognizer(object):
return major, minor
def checkVersion(self, toolVersion):
runtimeVersion = "4.7"
runtimeVersion = "4.7.1"
rvmajor, rvminor = self.extractVersion(runtimeVersion)
tvmajor, tvminor = self.extractVersion(toolVersion)
if rvmajor!=tvmajor or rvminor!=tvminor:

View File

@ -119,7 +119,7 @@ class XPathLexer(Lexer):
def __init__(self, input=None):
super().__init__(input)
self.checkVersion("4.7")
self.checkVersion("4.7.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None

View File

@ -792,7 +792,7 @@ class CLexer(Lexer):
def __init__(self, input=None):
super().__init__(input)
self.checkVersion("4.7")
self.checkVersion("4.7.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None

View File

@ -915,7 +915,7 @@ class CParser ( Parser ):
def __init__(self, input:TokenStream):
super().__init__(input)
self.checkVersion("4.7")
self.checkVersion("4.7.1")
self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
self._predicates = None

View File

@ -63,7 +63,7 @@ public class RuntimeMetaData {
/// omitted, the `-` (hyphen-minus) appearing before it is also
/// omitted.
///
public static let VERSION: String = "4.7"
public static let VERSION: String = "4.7.1"
///
/// Gets the currently executing version of the ANTLR 4 runtime library.

View File

@ -354,7 +354,7 @@ func getVocabulary() -> Vocabulary {
override <accessLevelNotOpen(parser)>
init(_ input:TokenStream) throws {
RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION)
RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION)
try super.init(input)
_interp = ParserATNSimulator(self,<p.name>._ATN,<p.name>._decisionToDFA, <parser.name>._sharedContextCache)
}

View File

@ -28,7 +28,7 @@ public class CSharpTarget extends Target {
@Override
public String getVersion() {
return "4.7";
return "4.7.1";
}
@Override

View File

@ -50,7 +50,7 @@ public class CppTarget extends Target {
}
public String getVersion() {
return "4.7";
return "4.7.1";
}
public boolean needsHeader() { return true; }

View File

@ -71,7 +71,7 @@ public class GoTarget extends Target {
@Override
public String getVersion() {
return "4.7";
return "4.7.1";
}
public Set<String> getBadWords() {

View File

@ -51,7 +51,7 @@ public class JavaScriptTarget extends Target {
@Override
public String getVersion() {
return "4.7";
return "4.7.1";
}
public Set<String> getBadWords() {

View File

@ -94,7 +94,7 @@ public class Python2Target extends Target {
@Override
public String getVersion() {
return "4.7";
return "4.7.1";
}
public Set<String> getBadWords() {

View File

@ -96,7 +96,7 @@ public class Python3Target extends Target {
@Override
public String getVersion() {
return "4.7";
return "4.7.1";
}
/** Avoid grammar symbols in this set to prevent conflicts in gen'd code. */

View File

@ -87,7 +87,7 @@ public class SwiftTarget extends Target {
@Override
public String getVersion() {
return "4.7"; // Java and tool versions move in lock step
return "4.7.1"; // Java and tool versions move in lock step
}
public Set<String> getBadWords() {