You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/04/11 01:38:10 UTC

[34/50] groovy git commit: Refine the README of sub-project groovy-parser-antlr4

Refine the README of sub-project groovy-parser-antlr4


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c0791d9f
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c0791d9f
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c0791d9f

Branch: refs/heads/master
Commit: c0791d9f4d2d298ec1786994359af295d9a7b0c7
Parents: d21ddc7
Author: sunlan <su...@apache.org>
Authored: Wed Feb 8 13:41:35 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Wed Feb 8 13:41:35 2017 +0800

----------------------------------------------------------------------
 subprojects/groovy-parser-antlr4/README.md | 35 ++++++++++++++++++-------
 1 file changed, 26 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/c0791d9f/subprojects/groovy-parser-antlr4/README.md
----------------------------------------------------------------------
diff --git a/subprojects/groovy-parser-antlr4/README.md b/subprojects/groovy-parser-antlr4/README.md
index f209c08..7192087 100644
--- a/subprojects/groovy-parser-antlr4/README.md
+++ b/subprojects/groovy-parser-antlr4/README.md
@@ -1,18 +1,35 @@
-This is the home of the Parrot parser, which is based on antlr4.
+## This is the home of the new parser Parrot, which is based on antlr4.
 
-In the gradle build the property useAntlr4 has to be set to enable the build of the parser and the execution of all tests with it.
+The new parser(Parrot) can parse Groovy source code and construct the related AST, which is almost identical to the one generated by the old parser(except the corrected node position, e.g. line, column of node). Currently all features of Groovy are available. In addition, **the following new features have been added:**
 
-Command line example:
-`./gradlew -PuseAntlr4=true bootstrapJar`
+* do-while loop, standard loop(e.g. `for(int i = 0, j = 10; i < j; i++, j--) {..}`)
+* lambda expression
+* method reference and constructor reference
+* try-with-resources(i.e. ARM)
+* code block(i.e. `{..}`)
+* array initializer of Java style(e.g. `new int[] {1, 2, 3}`)
+* default method of interface
+* new operators: identity operators(`===`, `!==`), elvis assignment(`?=`), `!in`, `!instanceof`
+* safe index(e.g. `nullableVar?[1, 2]`)
+* groovydoc attached to AST node as metadata
 
-To enable the new parser automatically at runtime the system property groovy.antlr4 has to be set.
-
-Command line example:
+**How to enable the new parser**
+* In the gradle build the property useAntlr4 has to be set to enable the build of the parser and the execution of all tests with it. Command line example:
+```
+./gradlew -PuseAntlr4=true bootstrapJar
+```
+* To enable the new parser automatically at runtime the system property groovy.antlr4 has to be set. Command line example:
 ```
 export JAVA_OPTS="-Dgroovy.antlr4=true"
 groovy foo.groovy
 ```
+* This system property also controls groovyc and has to be used in case it is used outside of this build, for example with:
+```
+groovyOptions.forkOptions.jvmArgs += ["-Dgroovy.antlr4=true"]
+```
 
-This system property also controls groovyc and has to be used in case it is used outside of this build, for example with:
+**JVM options to control parsing:**
+* `groovy.antlr4.cache.threshold`: how frequently to clear DFA cache(default: 50). **Notice:** The more frequently the DFA cache is cleared, the poorer parsing performance will be(you can not set the value that is less than the default value). But the DFA cache has to be cleared to avoid OutOfMemoryError's occurring. 
+* `groovy.extract.doc.comment`: whether to collect groovydoc while parsing groovy source code(default: false)
 
-`groovyOptions.forkOptions.jvmArgs += ["-Dgroovy.antlr4=true"]`
+*P.S. Parrot is based on the highly optimized version of antlr4(com.tunnelvisionlabs:antlr4), which is licensed under BSD. *