Skip to content

Expand FreeVarVisitor to work with new types of TreeNodes #24

@jmansilla

Description

@jmansilla

So far, the visitor works with AbstractTrees containing 3 types of nodes: Lam, App & Var.

Work needs to be done to expand this logic so it works with all new expression types contained in lamedh/expr/applicative.py

class Error(Expr):
class TypeError(Expr):
class BooleanConstant(Expr):
class NaturalConstant(BooleanConstant):
class UnaryOp(Expr):
class BinaryOp(Expr):
class IfThenElse(Expr):
class Tuple(Expr):
class Indexing(Expr):
class Rec(Expr):
class Pattern:
class LetIn(Expr):
class LetRec(LetIn):

Tasks:

  1. Make sure that free variables of any kind of simple or complex expression creating using this expanded language can be found by the free-var-visitor. All new nodes above except the last 2 (LetIn & LetRec) do not bind variables.

  2. Create new tests-cases contemplating these changes

  3. Simplify what you just did in step (1)

    • Bear in mind that a naive implementation of step (1) you may introduce a zillion new methods "visit_<new_type>" methods.
    • In NodeVisiting Pattern, there's a default method named "generic_visit" that's used every time that a node of class "XYZ" needs to be visited and there's no "visit_xyz" method.
    • Let's try to use that concept to many nodes-type may not need to have special visit-method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    logicWork on logic of expressions manipulation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions