Interface Expression.Visitor<T>
- Type Parameters:
T- the return type of the visit operations
- All Known Implementing Classes:
Interpreter
- Enclosing interface:
Expression
Defines methods for visiting each type of expression node in the Abstract Syntax Tree, enabling implementation of operations such as evaluation, type checking, or code generation through the Visitor pattern.
-
Method Summary
Modifier and TypeMethodDescriptionvisitBinary(Binary expr) Visits a binary expression node in the AST.Visits a function call or method invocation expression node.Visits a comprehension expression node in the AST.visitConditional(Conditional expr) Visits a conditional expression node in the AST.visitIdentifier(Identifier expr) Visits an identifier expression node in the AST.visitIndex(Index expr) Visits an index expression node in the AST.visitList(ListExpression expr) Visits a list expression node in the AST.visitLiteral(Literal expr) Visits a literal expression node in the AST.visitMap(MapExpression expr) Visits a map expression node in the AST.visitSelect(Select expr) Visits a select expression node in the AST.visitStruct(Struct expr) Visits a struct expression node in the AST.visitUnary(Unary expr) Visits a unary expression node in the AST.
-
Method Details
-
visitLiteral
Visits a literal expression node in the AST.This method is called by the accept method of a Literal expression to dispatch the visit operation to the appropriate visitor implementation.
- Parameters:
expr- the literal expression node to visit- Returns:
- the result of the visit operation, type T
-
visitIdentifier
Visits an identifier expression node in the AST.This method is called by the accept method of an Identifier expression node to dispatch the visit to the appropriate visitor implementation.
- Parameters:
expr- the identifier expression node to visit- Returns:
- the result of the visit operation, type T
-
visitSelect
Visits a select expression node in the AST.Processes a field selection operation, which can represent either a value fetch (operand.field) or a presence test (has(operand.field)) depending on the isTest flag.
- Parameters:
expr- the select expression node to visit- Returns:
- the result of processing the select expression
-
visitCall
Visits a function call or method invocation expression node.This method is called by the visitor pattern implementation when processing a Call expression node in the abstract syntax tree. It allows for custom handling of function calls and method invocations during traversal of the expression tree.
- Parameters:
expr- the call expression node to visit, containing the target expression, function name, arguments, and macro flag- Returns:
- the result of processing the call expression, type depends on the specific visitor implementation
-
visitList
Visits a list expression node in the AST.This method is called by the accept method of ListExpression to dispatch the visit operation to the appropriate visitor implementation.
- Parameters:
expr- the list expression node to visit- Returns:
- the result of the visit operation, type T
-
visitMap
Visits a map expression node in the AST.Invoked by the accept method of a MapExpression to dispatch the visit to the appropriate visitor implementation.
- Parameters:
expr- the map expression node to visit- Returns:
- the result of the visit operation as defined by the visitor implementation
-
visitStruct
Visits a struct expression node in the AST.This method is called by the accept method of a Struct expression node to dispatch the visit operation to the appropriate visitor implementation.
- Parameters:
expr- the struct expression node to visit- Returns:
- the result of the visit operation, type T
-
visitComprehension
Visits a comprehension expression node in the AST.Processes a comprehension expression which represents operations that generate lists or maps through iteration and accumulation. The comprehension includes an iteration variable and range, an accumulator variable with its initialization, a loop condition and step expression, and a final result expression.
- Parameters:
expr- the comprehension expression node to visit- Returns:
- the result of processing the comprehension expression
-
visitUnary
Visits a unary expression node in the AST.Processes a unary operation such as logical NOT (!) or numeric negation (-) by delegating to the appropriate visitor method.
- Parameters:
expr- the unary expression node to visit- Returns:
- the result of the visit operation, type T
-
visitBinary
Visits a binary expression node in the AST.Processes a binary operation by delegating to the appropriate visitor method based on the operator and operands.
- Parameters:
expr- the binary expression node to visit- Returns:
- the result of the visit operation, type T
-
visitConditional
Visits a conditional expression node in the AST.Processes a conditional expression that evaluates a condition and returns one of two possible values based on the result. The conditional expression follows the form "condition ? then : otherwise".
- Parameters:
expr- the conditional expression to visit- Returns:
- the result of the visit operation
-
visitIndex
Visits an index expression node in the AST.Processes an index operation that accesses elements from collections such as lists, maps, or strings using the specified operand and index expressions.
- Parameters:
expr- the index expression to visit, containing an operand and an index- Returns:
- the result of processing the index expression, type determined by the visitor implementation
-