Petit Java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Petit Java

DiegoLont
Hi all,

I try to make sense of Petit Java and the discussions around it, because it makes sense to have a similar architecture for Petit Delphi. The Delphi syntax contains 141 rules, versus 137 rules in java. So we compare pretty closely. But when I try to read the petit java code, I notice some odd things, so maybe someone can tell me why things are as they are.

I thought AST meant we have an Abstract Syntax Tree. A syntax tree, that only contains the information needed. The way we do it on the Delphi side, is that only when we have a purpose for a certain AST Node we create it. On the detail level, we do not have many AST nodes yet, since we only generate FAMIX to the method level. And the number of AST nodes is growing fast. Why does the AST needs to stick to the java grammar as closely as possible?

When I look at the AST Node and at the places where they are created, they more look like grammar nodes than syntax nodes. I have a node called MethodDeclarationNode. But it is created in the rule "methodNotConstructorDeclaration" and when I look at the rule "methodDeclaration" I would expect to have 2 subclasses: a ConstructorDeclarationNode and a MethodNotConstructorDeclarationNode … but instead I have a subclass InterfaceMethodDeclarationNode. I thought FAMIX was meant for this and that is why we convert our AST into FAMIX as well …

In PetitJava there is a visitor for the AST. I do not see how this visitor helps. The AST is changing faster than the implementors of the visitor, not only because we are evolving Petit Java, but also because Java itself also evolves and will make changes to the language in the future. I see only a few possible implementors of this visitor.

And maybe some of the Petit Java developers want to take a look at the Petit Delphi code. Because I am sure we did things good and also some stupid things, so please help us find the stupid things and copy the good things! I know I try to copy the good ideas from petit java.

Regards,
Diego
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Petit Java

Nicolas Anquetil

Hi.

I did not follow either the dicussion very closely, but I would tend to
agree with Yuri that it is better if PetitJava outputs an AST that is
close to the grammar.

reasons are:
- documentation: anybody having the grammar can understand more easily
what each node means

- genericity: fine tunning the AST toward one specific goal (Famix for
Diego, dataflow analysis for Chris) is important, but might impede
somebody else to reuse the parser.
Sticking to the grammar avoids this problem because it is very detailed
so all the information is there.
Then each one can make a visitor that is suited to his need, for example
in verveineJ I made a visitor on the AST that JDT gives me and it worked
like a charm because their AST follows the grammar and I had all I needed.

- conformance: not following the gramar might introduce slight
difference in interpretation that in complex cases will produce a wrong AST

evolution: also not following the gramar might imply entering in a dead
end that will not be able to cope with the next Java version and will
force us to redefine many things.


We are currently working on a Java to FAST exporter that is based on
PetitJava, however, if the AST Petit Java currently outputs is too far
from the grammar, we might end-up having to switch to JDT's AST (like I
do in verveineJ) where everything works and we will "just" have to
create the proper FamixAST nodes ...

nicolas

On 07/02/2013 02:54 PM, Diego Lont wrote:

> Hi all,
>
> I try to make sense of Petit Java and the discussions around it, because it makes sense to have a similar architecture for Petit Delphi. The Delphi syntax contains 141 rules, versus 137 rules in java. So we compare pretty closely. But when I try to read the petit java code, I notice some odd things, so maybe someone can tell me why things are as they are.
>
> I thought AST meant we have an Abstract Syntax Tree. A syntax tree, that only contains the information needed. The way we do it on the Delphi side, is that only when we have a purpose for a certain AST Node we create it. On the detail level, we do not have many AST nodes yet, since we only generate FAMIX to the method level. And the number of AST nodes is growing fast. Why does the AST needs to stick to the java grammar as closely as possible?
>
> When I look at the AST Node and at the places where they are created, they more look like grammar nodes than syntax nodes. I have a node called MethodDeclarationNode. But it is created in the rule "methodNotConstructorDeclaration" and when I look at the rule "methodDeclaration" I would expect to have 2 subclasses: a ConstructorDeclarationNode and a MethodNotConstructorDeclarationNode … but instead I have a subclass InterfaceMethodDeclarationNode. I thought FAMIX was meant for this and that is why we convert our AST into FAMIX as well …
>
> In PetitJava there is a visitor for the AST. I do not see how this visitor helps. The AST is changing faster than the implementors of the visitor, not only because we are evolving Petit Java, but also because Java itself also evolves and will make changes to the language in the future. I see only a few possible implementors of this visitor.
>
> And maybe some of the Petit Java developers want to take a look at the Petit Delphi code. Because I am sure we did things good and also some stupid things, so please help us find the stupid things and copy the good things! I know I try to copy the good ideas from petit java.
>
> Regards,
> Diego
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
Nicolas Anquetil -- RMod research team (Inria)

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev