Skip to content

Commit

Permalink
Merge branch 'master_upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-lischke committed Sep 25, 2016
2 parents ee3e918 + 0b2d530 commit 3b98c11
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 26 deletions.
51 changes: 40 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Maven build folders
target/
# ... but not code generation targets
!tool/src/org/antlr/v4/codegen/target/

# Node.js (npm and typings) cached dependencies
node_modules/
typings/

# Ant build folders
build/
Expand All @@ -8,14 +16,37 @@ user.build.properties
# MacOSX files
.DS_Store

# Python
*.pyc
## Python, selected lines from https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

## CSharp and VisualStudio, selected lines from https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# CSharp
bin/
obj/
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Visual Studio 2015 cache/options directory
.vs/

# NetBeans user configuration files
nbactions*.xml
/nbproject/private/
Expand Down Expand Up @@ -55,13 +86,11 @@ bilder.pyc
bild.log

bild_output.txt
antlr4cpp.suo
antlr4-maven-plugin/target
runtime/Java/target
tool/target
runtime-testsuite/target
tool-testsuite/target
runtime/Cpp/demo/generated
xcuserdata
*.jar
.vscode

# VSCode Java plugin temporary files
javac-services.0.log
javac-services.0.log.lck
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,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

Expand Down
2 changes: 2 additions & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@ YYYY/MM/DD, github id, Full name, email
2016/07/20, kosl90, Li Liqiang, [email protected]
2016/07/27, timoc, Tim O'Callaghan, [email protected]
2016/07/26, nic30, Michal Orsák, [email protected]
2016/08/11, BurtHarris, Ralph "Burt" Harris, [email protected]
2016/08/19, andjo403, Andreas Jonson, [email protected]
18 changes: 17 additions & 1 deletion doc/adding-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -92,6 +107,7 @@ a : ('a'|'b')* 'c' {<InputText():writeln()>} ;
>>
```


### Cross-language actions embedded within grammars

To get:
Expand Down
12 changes: 6 additions & 6 deletions doc/building-antlr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions doc/faq/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ expr : expr '*' expr
;
```

ANTLR 4 automatically constructs parse trees for you and abstract syntax tree (AST) construction is no longer an option. See also What if I need ASTs not parse trees for a compiler, for example?
ANTLR 4 automatically constructs parse trees for you and abstract syntax tree (AST) construction is no longer an option. See also [What if I need ASTs not parse trees for a compiler, for example?](https://github.com/antlr/antlr4/blob/master/doc/faq/parse-trees.md#what-if-i-need-asts-not-parse-trees-for-a-compiler-for-example).

Another big difference is that we discourage the use of actions directly within the grammar because ANTLR 4 automatically generates [listeners and visitors](https://raw.githubusercontent.com/antlr/antlr4/master/doc/listeners.md) for you to use that trigger method calls when some phrases of interest are recognized during a tree walk after parsing. See also [Parse Tree Matching and XPath](https://raw.githubusercontent.com/antlr/antlr4/master/doc/tree-matching.md).
Another big difference is that we discourage the use of actions directly within the grammar because ANTLR 4 automatically generates [listeners and visitors](https://github.com/antlr/antlr4/blob/master/doc/listeners.md) for you to use that trigger method calls when some phrases of interest are recognized during a tree walk after parsing. See also [Parse Tree Matching and XPath](https://github.com/antlr/antlr4/blob/master/doc/tree-matching.md).

Semantic predicates are still allowed in both the parser and lexer rules as our actions. For efficiency sake keep semantic predicates to the right edge of lexical rules.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ public boolean createProject() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,16 @@ private String locateRuntime() {
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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,16 @@ protected String locateRuntime(String targetName) {
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];
Expand Down

0 comments on commit 3b98c11

Please sign in to comment.