Lyuben Atanasov created GROOVY-10069:
----------------------------------------
Summary: Java ParserPlugin implementation
Key: GROOVY-10069
URL: https://issues.apache.org/jira/browse/GROOVY-10069
Project: Groovy
Issue Type: Wish
Reporter: Lyuben Atanasov
Since the existence of the {{ParserPlugin}} and {{ParserPluginFactory}}
interfaces, it seems possible to create a parser for different programming
languages, and to create a specific plugin implementation to adapt the parse
tree to a Groovy AST.
Even though Groovy is highly compatible with Java source code, there are some
subtle differences like the meaning of a semicolon, strings, and annotations
that contain an array value, to name a few. Groovy's AST transformations are an
excellent tool, and it would be nice if we could use them on parsed Java source
code as well, without worrying about parsing errors. Therefore, I'd like to see
an optional ParserPlugin implementation that strictly parses Java source. It
would convert the parse tree to an AST, just like the existing Groovy parsers,
and the compilation process would not be altered in any other way.
What I propose is not compilation of Java code, which is already supported. It
is more of a transparent translation from Java to Groovy. The expected output
would be 100% Groovy.
The reason for this wish is to be able to support existing or legacy code
already written in Java, without the need to go through the entire code base,
while still keeping the ability to perform AST transformations. It would also
probably enable running plain Java code as a script.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)