Groovy Custom Language API

Hi Maxim,

I'm currently about to develop Groovy Support for Idea.
The plugin is called Groovyj.

Groovy: https://groovy.codehaus.org
Groovyj: https://svn.canoo.com/trunk/groovyj/
the root contains a readme.txt that is useful.

I have it as far as that the Lexer works for the currently supported cases (some issues with \t and excessive newlines but I know how to solve that).
The problem is with the Parser. I don't want to re-implement the parser logic that is already available for Groovy (generated from an antlr grammar).
But the current API seems to force me into that since the
Idea Parser Interface and especially the PsiBuilder are bound to the Strategy that e.g. the JS Parser uses.

I would rather like to create the PSI from the AST that Groovy already gives me. (this is different from the AST implementation inside Idea).

My current spike of wiring in the parser can be found at
https://svn.canoo.com/trunk/groovyj/src/java/groovy/idesupport/idea/parsing/GroovyParser.java

Any help is much appreciated
Mittie

9 comments
Comment actions Permalink

Dierk,

I've just tried to implement ANTLR -> PsiBuilder adapter myself but miserably
failed for quite funny reason. First of all I need text to be parsed to pass
to ANTLR parser and there's nowhere to take it from except iterating embedded
lexer via PsiBuilder passed. So far so good but then I need to iterate over
ANTLR AST build synchronously calling mark()/marker.done() from PsiBuilder
but there's no place to take new copy from...

Well, we'll pass original text (in form of java.lang.CharSequence most probably)
so that'll fix the problem. This will break existing (if any) language plugins
unfortunately though.

-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"

Hi Maxim,

I'm currently about to develop Groovy Support for Idea. The plugin is
called Groovyj.

Groovy: https://groovy.codehaus.org
Groovyj: https://svn.canoo.com/trunk/groovyj/
the root contains a readme.txt that is useful.
I have it as far as that the Lexer works for the currently supported
cases (some issues with \t and excessive newlines but I know how to
solve that).

The problem is with the Parser. I don't want to re-implement the
parser logic that is already available for Groovy (generated from an
antlr grammar).

But the current API seems to force me into that since the

Idea Parser Interface and especially the PsiBuilder are bound to the
Strategy that e.g. the JS Parser uses.

I would rather like to create the PSI from the AST that Groovy already
gives me. (this is different from the AST implementation inside Idea).

My current spike of wiring in the parser can be found at
https://svn.canoo.com/trunk/groovyj/src/java/groovy/idesupport/idea/pa
rsing/GroovyParser.java

Any help is much appreciated
Mittie




0
Comment actions Permalink

Maxim,

Will this adapter be part of the OpenAPI or JavaScript plugin?

Maas

0
Comment actions Permalink

To make it part of the OpenAPI thus part of the IDEA distribution we need
to depend on antlr.jar and distribute that as well. I will check out the
license and other details that may arise.

-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"

Maxim,

Will this adapter be part of the OpenAPI or JavaScript plugin?

Maas




0
Comment actions Permalink

An example on the wiki would be sufficient. But I dont think there will be any license problems :

http://www.antlr.org/license.html

+We reserve no legal rights to the ANTLR--it is fully in the public domain. An individual or company may do whatever they wish with source code distributed with ANTLR or the code generated by ANTLR, including the incorporation of ANTLR, or its output, into commerical software.

We encourage users to develop software with ANTLR. However, we do ask that credit is given to us for developing ANTLR. By "credit", we mean that if you use ANTLR or incorporate any source code into one of your programs (commercial product, research project, or otherwise) that you acknowledge this fact somewhere in the documentation, research report, etc... If you like ANTLR and have developed a nice tool with the output, please mention that you developed it using ANTLR. In addition, we ask that the headers remain intact in our source code. As long as these guidelines are kept, we expect to continue enhancing this system and expect to make other tools available as they are completed.+

0
Comment actions Permalink

Hi Maxim,

thanx a lot for your timely answer.
I experienced the very same failed attempts. Good to know I didn't miss anything obvious.

Passing the string_to_parse would definitely do the trick.

Thanx a lot for your effort.
I hardly cannot wait any longer to see the grooviest programming language in the coolest IDE on this planet!

cheers
Dierk

0
Comment actions Permalink

Hi Maxim,
there may be a way to resolve our issue that is backward compatible with the old one:
allow Parsers to use their own PsiBuilder.

To that end, the PsiBuilder class should be available as source code and be non-final. (such a cool implementation of the Builder Pattern deserves to be open anyway)
We could then subclass or re-implement it as needed and pass it to the ctor of our parser. The Parser can then use it in its parse(...) method, ignoring the PsiBuilder parameter.

I cannot look into the framework. There may be reasons that disallow the above solution like when every call the the parse(...) methods is done with a newly created PsiBuilder or so.

just a thought
Mittie

0
Comment actions Permalink

Maas van den Berg wrote:

An example on the wiki would be sufficient. But I dont think there will be any license problems :

http://www.antlr.org/license.html

+We reserve no legal rights to the ANTLR--it is fully in the public domain. An individual or company may do whatever they wish with source code distributed with ANTLR or the code generated by ANTLR, including the incorporation of ANTLR, or its output, into commerical software.

We encourage users to develop software with ANTLR. However, we do ask that credit is given to us for developing ANTLR. By "credit", we mean that if you use ANTLR or incorporate any source code into one of your programs (commercial product, research project, or otherwise) that you acknowledge this fact somewhere in the documentation, research report, etc... If you like ANTLR and have developed a nice tool with the output, please mention that you developed it using ANTLR. In addition, we ask that the headers remain intact in our source code. As long as these guidelines are kept, we expect to continue enhancing this system and expect to make other tools available as they are completed.+


Oh, how i hate it when developers show their copyright-related cluelessness in their ambiguous licenses. First they say "it is fully in the public domain". Then they say "However, we do ask that credit is given to us for developing ANTLR", and "In addition, we ask that the headers remain intact in our source code". Which is it? Is it in the public domain or not? ]]>

Sorry. Had to get that off my chest.

/Kreiger



Attachment(s):
signature.asc
0
Comment actions Permalink

Maxim Shafirov wrote:

I've just tried to implement ANTLR -> PsiBuilder adapter myself but


I would be very interested in ANTLR grammar file support for IDEA. Will
you be publishing a plugin?

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://www.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

0
Comment actions Permalink

Hi Maxim,

What's the update regarding your ANTLR -> PsiBuilder adapter? It doesn't seem to have made into Irida build #3281 this time. Is that because of licensing issues?

Thanks,
Franck

0

Please sign in to leave a comment.