tools to print AST

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

tools to print AST

Hamlet D'Arcy

Does the spock source contain any tools to print AST in text format?


--
Hamlet D'Arcy
[hidden email]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tools to print AST

Peter Niederwieser
Administrator

Hi Hamlet,

On Oct 25, 5:09 pm, "Hamlet D'Arcy" <[hidden email]> wrote:
> Does the spock source contain any tools to print AST in text format?

No. For a while I used the (old) Eclipse plugin's AST view for
inspecting the AST, and now I use GroovyConsole's AST browser.
However, Spock contains some other AST-related stuff that might be
interesting to the outside world:
1. Visitors that make it easy to replace nodes while walking the AST
(StatementReplacingVisitorSupport, ExpressionReplacingVisitorSupport)
2. A helper class for inspecting the AST (AstInspector)
3. An embedded specification runner that makes it trivial to debug
Spock's transforms (this one is obviously more specific to Spock than
the other two)

Cheers,
Peter

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tools to print AST

Hamlet D'Arcy

> No. For a while I used the (old) Eclipse plugin's AST view for
> inspecting the AST, and now I use GroovyConsole's AST browser.

Be sure to get the newest AST Viewer (as in the code from yesterday).
The tree nodes are becoming much more informative.
If you're using the AST browser and you find yourself looking in the
grid pane for data, then we should move that data to the node
descriptor. For instance, instead of showing "ClassNode" we should
show "ClassNode - String"... I've updated many of the nodes to be more
descriptive, but there are many left to do.


> 1. Visitors that make it easy to replace nodes while walking the AST
> (StatementReplacingVisitorSupport, ExpressionReplacingVisitorSupport)

I still think a _functional_ (as in FP) visitor is the proper
solution. Visitors should return ASTNode not void, and then
replacements are simple for all types. I will continue to look at
this.

> 2. A helper class for inspecting the AST (AstInspector)

Cool, I will look at the unit test and usage later.

> 3. An embedded specification runner that makes it trivial to debug
> Spock's transforms (this one is obviously more specific to Spock than
> the other two)

What is the name of that? Have you seen the Groovy
TransformTestHelper? It is meant to let you step thru any Transform in
a debugger, whether it is local or global.

Does Spock have IntelliJ IDEA files? I don't see them checked in. It
would help to have the .ipr and .iml (but not the .iws of course).

--
Hamlet D'Arcy
[hidden email]



On Sun, Oct 25, 2009 at 11:50 AM, Peter Niederwieser <[hidden email]> wrote:

>
> Hi Hamlet,
>
> On Oct 25, 5:09 pm, "Hamlet D'Arcy" <[hidden email]> wrote:
>> Does the spock source contain any tools to print AST in text format?
>
> No. For a while I used the (old) Eclipse plugin's AST view for
> inspecting the AST, and now I use GroovyConsole's AST browser.
> However, Spock contains some other AST-related stuff that might be
> interesting to the outside world:
> 1. Visitors that make it easy to replace nodes while walking the AST
> (StatementReplacingVisitorSupport, ExpressionReplacingVisitorSupport)
> 2. A helper class for inspecting the AST (AstInspector)
> 3. An embedded specification runner that makes it trivial to debug
> Spock's transforms (this one is obviously more specific to Spock than
> the other two)
>
> Cheers,
> Peter
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tools to print AST

Peter Niederwieser
Administrator

Hamlet,

On 25.10.2009, at 18:11, Hamlet D'Arcy wrote:

>> 1. Visitors that make it easy to replace nodes while walking the AST
>> (StatementReplacingVisitorSupport, ExpressionReplacingVisitorSupport)
>
> I still think a _functional_ (as in FP) visitor is the proper
> solution. Visitors should return ASTNode not void, and then
> replacements are simple for all types. I will continue to look at
> this.

It's certainly worthwhile to investigate this. One the other hand,  
many visitors
don't need to return anything from visit methods, and in those cases  
neither
the method implementation nor its caller should have to deal with  
return values.
And two different visitor interfaces don't sound too compelling  
either. Have
you seen functional visitors used in other (OO) compiler  
implementations?

>> 3. An embedded specification runner that makes it trivial to debug
>> Spock's transforms (this one is obviously more specific to Spock than
>> the other two)
>
> What is the name of that? Have you seen the Groovy
> TransformTestHelper? It is meant to let you step thru any Transform in
> a debugger, whether it is local or global.

Actually there are two classes: EmbeddedSpeckCompiler and  
EmbeddedSpeckRunner.
They are used extensively throughout Spock's test suite. I have read  
about TransformTestHelper,
but have yet to take a closer look at it.


> Does Spock have IntelliJ IDEA files? I don't see them checked in. It
> would help to have the .ipr and .iml (but not the .iws of course).

Does sharing the .ipr and .iml provide anything over opening the  
project from its POM?
For example, will it make Spock's code style and inspection settings  
available to others?

Cheers,
Peter

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tools to print AST

Hamlet D'Arcy

> Does sharing the .ipr and .iml provide anything over opening the
> project from its POM?
> For example, will it make Spock's code style and inspection settings
> available to others?

I suppose it could make the style available, but probably not worth the effort.

If opening from the POM works then I'll do that. Hopefully it works.
It so rarely works correctly for me that I forget about that option.

--
Hamlet D'Arcy
[hidden email]




On Sun, Oct 25, 2009 at 12:38 PM, Peter Niederwieser <[hidden email]> wrote:

>
> Hamlet,
>
> On 25.10.2009, at 18:11, Hamlet D'Arcy wrote:
>
>>> 1. Visitors that make it easy to replace nodes while walking the AST
>>> (StatementReplacingVisitorSupport, ExpressionReplacingVisitorSupport)
>>
>> I still think a _functional_ (as in FP) visitor is the proper
>> solution. Visitors should return ASTNode not void, and then
>> replacements are simple for all types. I will continue to look at
>> this.
>
> It's certainly worthwhile to investigate this. One the other hand,
> many visitors
> don't need to return anything from visit methods, and in those cases
> neither
> the method implementation nor its caller should have to deal with
> return values.
> And two different visitor interfaces don't sound too compelling
> either. Have
> you seen functional visitors used in other (OO) compiler
> implementations?
>
>>> 3. An embedded specification runner that makes it trivial to debug
>>> Spock's transforms (this one is obviously more specific to Spock than
>>> the other two)
>>
>> What is the name of that? Have you seen the Groovy
>> TransformTestHelper? It is meant to let you step thru any Transform in
>> a debugger, whether it is local or global.
>
> Actually there are two classes: EmbeddedSpeckCompiler and
> EmbeddedSpeckRunner.
> They are used extensively throughout Spock's test suite. I have read
> about TransformTestHelper,
> but have yet to take a closer look at it.
>
>
>> Does Spock have IntelliJ IDEA files? I don't see them checked in. It
>> would help to have the .ipr and .iml (but not the .iws of course).
>
> Does sharing the .ipr and .iml provide anything over opening the
> project from its POM?
> For example, will it make Spock's code style and inspection settings
> available to others?
>
> Cheers,
> Peter
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tools to print AST

Peter Niederwieser
Administrator
On 25.10.2009, at 18:54, Hamlet D'Arcy wrote:


Does sharing the .ipr and .iml provide anything over opening the
project from its POM?
For example, will it make Spock's code style and inspection settings
available to others?

I suppose it could make the style available, but probably not worth the effort.

If opening from the POM works then I'll do that. Hopefully it works.
It so rarely works correctly for me that I forget about that option.

I've had many problems with IDEA's Maven integration on bigger projects in the past, but for Spock is has always worked just fine. Let me know in case you run into problems. If you want to compile/run some code, I suggest to disable stub generation for all files, as it is not needed.

Cheers,
Peter


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...