Hi again Groovy-Dev

Here’s another update on the progress on the Antlr4 parser. I’m still exploring 
the limitations of the parser, partly by inspection and comparison with the 
Groovy documentation, and partly by experimentation (letting it loose on all 
the *.groovy files in the repository)

Since last update, I’ve fixed a number of issues:
assert statement (with either colon or comma as separator)
Added cast operator
super() or this()-call in constructors
Support identifiers as property names and map literal entry names
Incorporated Pavel’s ASTBuilder as Java. And un-machinetranslated in where I 
could, so it’s more idiomatic Java-ish.
Multiple declarations are now handled in locals and fields/properties.
Trailing commas are OK in lists and maps
Scripts may contain methods now
Updated Antlr4 version and made it configurable with the others in main 
build.gradle
Fixed the classname-detection login (Now I will never, ever forget 
binarySearch’s return value!
Allow F and D as suffix to integer literals
Allow static import and imports with aliases
Still outstanding:
Full Unicode letter support  for identifiers
Proper unescaping of string literals
The grammar is too limited around call expressions trailing a non-path 
expression
Some combinations of parameterless calls and closure-only calls don’t work yet
Error messages look a lot different from the old parser - may need some qork
Haven’t looked at error recovery -(single token correction built into Antlr4 
does some of the work)
Some newline handling around various operators need attention
So you can help me with a couple of answers:
Is it a goal to close the gap to Java’s more trickier syntax, such as 
placement-new and placement constructor calls? From what I can tell, we’d have 
to extend the AST too to support that. Has anyone ever used that except in 
compiler test cases?
./benchmark/bench/heapsort.groovy uses access modfiers on the script’s local 
variables — that’s not really allowed, is it? How should that work? It can’t 
get it to work in Groovy 2.4.x

As before, to play with it, try:

$ git clone -b antlr4 https://github.com/jespersm/groovy.git 
<https://github.com/jespersm/groovy.git>
$ cd groovy
$ gradle -PuseAntlr4=true console

Have fun.

-Jesper

Reply via email to