Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-dev] Ascending tree traversal with parameters and multiple rules

Hello Johannes,

I am not sure I completly understand your example.
For your TransformationUnit processing program statements you have the
following workflow:
1. use "statement" of getContainer to initialize "contained" of a random
subunit
2. if subunit was applied, write value of "container" of subunit to
"statement" of getContainer

However I don't understand your intention in the last paragraph:
Do you want:
a) match the "container" parameter of every rule to "statement" (I think
you meant "statement" because the surrounding unit doesn't have a
"container" parameter)
-> this is possible, just provide a parametermapping for every single
"container" to "statement" in getContainer
b) only want to match specific "container" parameters to "statement"
-> In this case I would assume that your problem are those rules that do
not move "statement" up in the container hierarchy. However this would
only result in infinte sequences if a situation occurs where the
"special cases" rules are applicable and the "advancing" rule which
moves statement is not applicable for example your rules have reached
the class method but a "special cases" rule is still applicable and get
checked again and again. My problem with b) is, that the "special cases"
rules are potentially NOT checked the way they are modelled because the
independent unit might try them or not. If there is any relation between
the "special cases" rules and the "advancing" rule for example "only use
advance rule if all special rules are applicable" it is better to use a
sequential unit or conditional unit to group rules accordingly.

If I have misunderstood your problem please explain it in more detail.

Regards,
Enrico

On 07.04.2011 14:48, Johannes Tietje wrote:
> Hello,
>
> I recently worked on a set of Henshin rules (packaged as a
> transformation unit) which should traverse a number of objects
> structured as a tree (more specifically, an abstract syntax tree (AST)
> of a Java program) and the questions arises, whether there is any
> possibility to let Henshin obtain one transformation unit "output"
> parameter from a set of containing rules equally?
>
> More specifically, I came along this problem:
>
> My input value is a node of the AST and the goal of the transformation
> unit is, that I receive a specific parent node through a parameter,
> after no rule could be applied any more. I already have a transformation
> unit doing this, working on classes and their respective parents, which
> ascends the class inheritance tree step by step---starting with a given
> class X' and returning her parent-class X. The rules are structures as
> follows:
>
> searchBaseClass (counted unit, count = -1):
>   getExtendedClass (rule):
>     class (parameter)
>     extendedClass (parameter)
>   
>   class (parameter)
>
> The unit parameter "class" is set by the surrounding transformation
> unit, sets the rule parameter "class" to its own value and will be
> re-set according to the rule parameter "extendedClass" after every
> successful application of the rule so that the "class" parameter of the
> unit eventually contains the uppermost class of the inheritance tree.
>
> Now, I wanted to model a similar action, but instead of working on
> classes, the rules have to work on program statements
> (System.out.println("Hello, World")) and their containers
> (If-Conditions, Switch-Case, Loops) eventually resulting in receiving
> the class method the statement is contained in. The structure so far is:
>
> searchContainingClassMethod (counted unit, count = -1):
>   getContainer (independent unit):
>     getContainerStatementInStatementContainer (rule):
>       contained (parameter)
>       container (parameter)
>
>     getContainerStatementInCondition (rule):
>       contained (parameter)
>       container (parameter)
>     ...
>
>     contained (parameter)
>     container (parameter)
>
>   statement (parameter)
>
> The unit parameter "statement" is set by the surrounding transformation
> unit, sets the inner unit parameter "contained" to its own value and
> will be re-set according to the inner unit parameter "container" after
> every successful application of the inner transformation unit so that
> "statement" eventually contains the class method containing the initial
> method call.
>
> The problem I experienced was, that because I have multiple rules (as
> the structure of the AST contains a lot of "special cases" for certain
> syntactical features) working on the "container" and "contained"
> parameters, I can't map every "container" output parameter of every rule
> to the "container" parameter of the surrounding transformation unit but
> only one---resulting in an infinite application of one rule (because the
> previous container will only be re-set by one single rule).
>
> Greets,
> Johannes
>
> _______________________________________________
> henshin-dev mailing list
> henshin-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/henshin-dev


Back to the top