Merge branch 'master' into fixGitignore

These are changes from the upstream master.
This commit is contained in:
Burt Harris 2016-09-23 14:47:33 -07:00
commit 9a7e0b5e4e
7 changed files with 47 additions and 13 deletions

View File

@ -15,18 +15,18 @@ ANTLR project lead and supreme dictator for life
## Useful information ## Useful information
* [Release notes](https://github.com/antlr/antlr4/releases) * [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/) * [Official site](http://www.antlr.org/)
* [Documentation](https://raw.githubusercontent.com/antlr/antlr4/master/doc/index.md) * [Documentation](https://github.com/antlr/antlr4/blob/master/doc/index.md)
* [FAQ](https://raw.githubusercontent.com/antlr/antlr4/master/doc/faq/index.md) * [FAQ](https://github.com/antlr/antlr4/blob/master/doc/faq/index.md)
* [API](http://www.antlr.org/api/Java/index.html) * [API](http://www.antlr.org/api/Java/index.html)
* [ANTLR v3](http://www.antlr3.org/) * [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. 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 to build ANTLR itself](https://github.com/antlr/antlr4/blob/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 we create and deploy an ANTLR release](https://github.com/antlr/antlr4/blob/master/doc/releasing-antlr.md)
## The Definitive ANTLR 4 Reference ## The Definitive ANTLR 4 Reference

View File

@ -93,3 +93,4 @@ YYYY/MM/DD, github id, Full name, email
2016/03/29, msteiger, Martin Steiger, antlr@martin-steiger.de 2016/03/29, msteiger, Martin Steiger, antlr@martin-steiger.de
2016/03/28, gagern, Martin von Gagern, gagern@ma.tum.de 2016/03/28, gagern, Martin von Gagern, gagern@ma.tum.de
2016/08/11, BurtHarris, Ralph "Burt" Harris, Burt_Harris_antlr4@azxs.33mail.com 2016/08/11, BurtHarris, Ralph "Burt" Harris, Burt_Harris_antlr4@azxs.33mail.com
2016/08/19, andjo403, Andreas Jonson, andjo403@hotmail.com

View File

@ -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 <something>.
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" TestType() ::= "Parser"
@ -92,6 +107,7 @@ a : ('a'|'b')* 'c' {<InputText():writeln()>} ;
>> >>
``` ```
### Cross-language actions embedded within grammars ### Cross-language actions embedded within grammars
To get: To get:

View File

@ -13,14 +13,14 @@ The first step is to get the Java source code from the ANTLR 4 repository at git
```bash ```bash
$ cd /tmp $ cd /tmp
/tmp $ git clone git@github.com:antlr/antlr4.git /tmp $ git clone https://github.com/antlr/antlr4.git
Cloning into 'antlr4'... Cloning into 'antlr4'...
remote: Counting objects: 43273, done. remote: Counting objects: 61480, done.
remote: Compressing objects: 100% (57/57), done. remote: Total 61480 (delta 0), reused 0 (delta 0), pack-reused 61480
remote: Total 43273 (delta 26), reused 0 (delta 0) Receiving objects: 100% (61480/61480), 31.24 MiB | 7.18 MiB/s, done.
Receiving objects: 100% (43273/43273), 18.76 MiB | 1.60 MiB/s, done. Resolving deltas: 100% (32970/32970), done.
Resolving deltas: 100% (22419/22419), done.
Checking connectivity... done. Checking connectivity... done.
Checking out files: 100% (1427/1427), done.
``` ```
# Compile # Compile

View File

@ -482,6 +482,9 @@ public abstract class BaseTest {
throw new RuntimeException("C# runtime project file not found!"); throw new RuntimeException("C# runtime project file not found!");
} }
String runtimeProjPath = runtimeProj.getPath(); String runtimeProjPath = runtimeProj.getPath();
if(isWindows()){
runtimeProjPath = runtimeProjPath.replaceFirst("/", "");
}
XPathExpression exp = XPathFactory.newInstance().newXPath() XPathExpression exp = XPathFactory.newInstance().newXPath()
.compile("/Project/ItemGroup/ProjectReference[@Include='" + runtimeName + "']"); .compile("/Project/ItemGroup/ProjectReference[@Include='" + runtimeName + "']");
Element node = (Element)exp.evaluate(prjXml, XPathConstants.NODE); Element node = (Element)exp.evaluate(prjXml, XPathConstants.NODE);

View File

@ -445,9 +445,16 @@ public abstract class BaseTest {
if ( runtimeSrc==null ) { if ( runtimeSrc==null ) {
throw new RuntimeException("Cannot find JavaScript runtime"); throw new RuntimeException("Cannot find JavaScript runtime");
} }
if(isWindows()){
return runtimeSrc.getPath().replaceFirst("/", "");
}
return runtimeSrc.getPath(); return runtimeSrc.getPath();
} }
private boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows");
}
public void testErrors(String[] pairs, boolean printTree) { public void testErrors(String[] pairs, boolean printTree) {
for (int i = 0; i < pairs.length; i += 2) { for (int i = 0; i < pairs.length; i += 2) {
String input = pairs[i]; String input = pairs[i];

View File

@ -583,9 +583,16 @@ public abstract class BasePythonTest {
if ( runtimeSrc==null ) { if ( runtimeSrc==null ) {
throw new RuntimeException("Cannot find "+targetName+" runtime"); throw new RuntimeException("Cannot find "+targetName+" runtime");
} }
if(isWindows()){
return runtimeSrc.getPath().replaceFirst("/", "");
}
return runtimeSrc.getPath(); return runtimeSrc.getPath();
} }
private boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows");
}
public void testErrors(String[] pairs, boolean printTree) { public void testErrors(String[] pairs, boolean printTree) {
for (int i = 0; i < pairs.length; i+=2) { for (int i = 0; i < pairs.length; i+=2) {
String input = pairs[i]; String input = pairs[i];