Menu

#93 Add a simple visitor to the AST library

V0.8.x
closed
5
2008-07-08
2008-06-06
No

This is a request coming from a discussion between Systerel and the University of Düsseldorf held this afternoon: The idea is to have the AST library providing a simpler visitor design pattern where the accept method does not implement the traversal of the tree internally, but rather delegate it to the visit method. This allows for visitor specific traversals of a tree.

A tentative profile for the visit method is:

<R, P> R visit(Alpha node, P param)

where "node" is the node visited, "Alpha" is its class(a subclass of Formula) and "param" is a client-specific parameter.

Discussion

  • cmetayer

    cmetayer - 2008-06-08

    Logged In: YES
    user_id=1540408
    Originator: NO

    I propose, for the visitor, a generic interface

    For example :

    public interface ISimpleVisitor<R, P> {
    R visitBecomesEqualTo(BecomesEqualTo s, P p);
    ...
    }

    And for the accept method (for the class BecomesSuchThat):

    public <R, P> R accept(ISimpleVisitor<R,P> visitor, P p) {
    return visitor.visitBecomesSuchThat(this, p);
    }

     
  • Nicolas Beauger

    Nicolas Beauger - 2008-07-08
    • status: open --> closed
     
  • Nicolas Beauger

    Nicolas Beauger - 2008-07-08

    Logged In: YES
    user_id=2102738
    Originator: NO

    Implemented. Provided interface ISimpleVisitor.

     

Log in to post a comment.