Set a variable in the environment.
(string)
The name of the variable.
(any)
The value of the variable.
(VariableTracker)
The tracker for variable changes.
(Object)
The location information for error reporting.
Class representing an environment for variable storage and lookup.
((Environment | null)
= null)
The parent environment.
Set a variable in the environment.
(string)
The name of the variable.
(any)
The value of the variable.
(VariableTracker)
The tracker for variable changes.
(Object)
The location information for error reporting.
InterpreterVisitor class is responsible for interpreting and executing code. It manages the environment, variable tracking, and console output.
Extends BaseVisitor
The environment in which the code is executed. Initialized as a new Environment instance with the name 'Global'.
Type: Environment
Tracks variables and their metadata during execution.
Type: VariableTracker
Keeps track of the state related to 'continue' statements.
Type: (Expression | null)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
Registers native functions (e.g., parseInt, toString) in the environment.
Type: void
Type: Object
(Object)
(BaseVisitor)
The value of the literal.
Type: any
The type of the literal.
Type: string
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.exp Expression
|
The expression inside the group. |
The expression inside the group.
Type: Expression
(BaseVisitor)
The name of the variable.
Type: string
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.op string
|
The operator of the unary expression. |
options.exp Expression
|
The right expression of the unary expression. |
The operator of the unary expression.
Type: string
The right expression of the unary expression.
Type: Expression
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.op string
|
The operator of the arithmetic expression. |
options.left Expression
|
The left expression of the arithmetic expression. |
options.right Expression
|
The right expression of the arithmetic expression. |
The operator of the arithmetic expression.
Type: string
The left expression of the arithmetic expression.
Type: Expression
The right expression of the arithmetic expression.
Type: Expression
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.op string
|
The operator of the relational expression. |
options.left Expression
|
The left expression of the relational expression. |
options.right Expression
|
The right expression of the relational expression. |
The operator of the relational expression.
Type: string
The left expression of the relational expression.
Type: Expression
The right expression of the relational expression.
Type: Expression
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.op string
|
The operator of the logical expression. |
options.left Expression
|
The left expression of the logical expression. |
options.right Expression
|
The right expression of the logical expression. |
The operator of the logical expression.
Type: string
The left expression of the logical expression.
Type: Expression
The right expression of the logical expression.
Type: Expression
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.cond Expression
|
The condition of the ternary expression. |
options.trueExp Expression
|
The true expression of the ternary expression. |
options.falseExp Expression
|
The false expression of the ternary expression. |
The condition of the ternary expression.
Type: Expression
The true expression of the ternary expression.
Type: Expression
The false expression of the ternary expression.
Type: Expression
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.id string
|
The name of the variable. |
options.sig string
|
The assignation of the variable. |
options.assign Expression
|
The expression to assign to the variable. |
The name of the variable.
Type: string
The assignation of the variable.
Type: string
The expression to assign to the variable.
Type: Expression
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.exp (Expression | undefined)
|
The expression to return. |
The expression to return.
Type: (Expression | undefined)
(BaseVisitor)
(Object)
(BaseVisitor)
(Object)
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.cond Expression
|
The expression of the case. |
options.stmt Array<Expression>
|
The instructions of the case. |
The expression of the case.
Type: Expression
The instructions of the case.
Type: Array<Expression>
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.cond Expression
|
The expression of the switch. |
options.cases Array<Case>
|
The cases of the switch. |
options.def Case
|
The default case of the switch. |
The expression of the switch.
Type: Expression
The cases of the switch.
Type: Array<Case>
The default case of the switch.
Type: Case
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.init Expression
|
The initialization of the for loop. |
options.cond Expression
|
The condition of the for loop. |
options.update Expression
|
The increment of the for loop. |
options.stmt Block
|
The instructions of the for loop. |
The initialization of the for loop.
Type: Expression
The condition of the for loop.
Type: Expression
The increment of the for loop.
Type: Expression
The instructions of the for loop.
Type: Block
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.vd Expression
|
The name of the variable. |
options.array Expression
|
The expression to iterate. |
options.stmt Block
|
The instructions of the for each loop. |
The name of the variable.
Type: Expression
The expression to iterate.
Type: Expression
The instructions of the for each loop.
Type: Block
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.cond Expression
|
The condition of the while loop. |
options.stmt Block
|
The instructions of the while loop. |
The condition of the while loop.
Type: Expression
The instructions of the while loop.
Type: Block
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.cond Expression
|
The condition of the if. |
options.stmtThen Expression
|
The instructions of the if. |
options.stmtElse Expression
|
The else of the if. |
The condition of the if.
Type: Expression
The instructions of the if.
Type: Expression
The else of the if.
Type: Expression
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.stmt Array<Expression>
|
The instructions of the block. |
The instructions of the block.
Type: Array<Expression>
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.exp Array<Expression>
|
The expression to print. |
The expression to print.
Type: Array<Expression>
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.exp Expression
|
The expression of the statement. |
The expression of the statement.
Type: Expression
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.type string
|
The type of the variable. |
options.id string
|
The name of the variable. |
options.value (Expression | null)
|
The expression of the variable. |
The type of the variable.
Type: string
The name of the variable.
Type: string
The expression of the variable.
Type: (Expression | null)
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.callee Expression
|
The name of the callee. |
options.args Array<Expression>
|
The arguments of the callee. |
The name of the callee.
Type: Expression
The arguments of the callee.
Type: Array<Expression>
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.type string
|
The type of the function. |
options.id string
|
The name of the function. |
options.params Array<Expression>
|
The parameters of the function. |
options.block Block
|
The body of the function. |
The type of the function.
Type: string
The name of the function.
Type: string
The parameters of the function.
Type: Array<Expression>
The body of the function.
Type: Block
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.id string
|
The name of the struct. |
options.fields Array<Expression>
|
The fields of the struct. |
The name of the struct.
Type: string
The fields of the struct.
Type: Array<Expression>
(BaseVisitor)
Represents an instance of a class or data structure with associated properties.
(Object)
| Name | Description |
|---|---|
options.id string
|
The class instance. |
options.args Array<Expression>
|
The arguments of the class instance. |
The arguments of the class instance.
Type: Array<Expression>
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.object Expression
|
The object to get the property. |
options.property string
|
The property to get. |
The object to get the property.
Type: Expression
The property to get.
Type: string
(BaseVisitor)
(Object)
| Name | Description |
|---|---|
options.object Expression
|
The object to set the property. |
options.property string
|
The property to set. |
options.value Expression
|
The value to set. |
options.sig string
|
The assignation of the property. |
The object to set the property.
Type: Expression
The property to set.
Type: string
The value to set.
Type: Expression
The assignation of the property.
Type: string
(BaseVisitor)
The name of the array instance.
Type: Array<Expression>
The type of the array instance.
Type: string
The dimension of the array instance.
(BaseVisitor)
(Expression)
any:
(Literal)
any:
(Group)
any:
(VarValue)
any:
(Unary)
any:
(Arithmetic)
any:
(Relational)
any:
(Logical)
any:
(Ternary)
any:
(VarAssign)
any:
(Return)
any:
(Continue)
any:
(Break)
any:
(Case)
any:
(Switch)
any:
(For)
any:
(ForEach)
any:
(While)
any:
(If)
any:
(Block)
any:
(ExpressionStatement)
any:
(VarDeclaration)
any:
(Callee)
any:
(FuncDeclaration)
any:
(StructDeclaration)
any:
(Get)
any:
(ArrayInstance)
any:
Base visitor class.
(Expression)
any:
(Literal)
any:
(Group)
any:
(VarValue)
any:
(Unary)
any:
(Arithmetic)
any:
(Relational)
any:
(Logical)
any:
(Ternary)
any:
(VarAssign)
any:
(Return)
any:
(Continue)
any:
(Break)
any:
(Case)
any:
(Switch)
any:
(For)
any:
(ForEach)
any:
(While)
any:
(If)
any:
(Block)
any:
(ExpressionStatement)
any:
(VarDeclaration)
any:
(Callee)
any:
(FuncDeclaration)
any:
(StructDeclaration)
any:
(Get)
any:
(ArrayInstance)
any:
Performs an arithmetic operation between two literals.
(string)
The arithmetic operator ('+', '-', '*', '/', '%').
(Literal)
The left operand of the operation.
(Literal)
The right operand of the operation.
(Object)
The location information for error reporting.
Literal:
The result of the arithmetic operation as a new Literal object.
Creates common rules for arithmetic operations between types.
Array<Array<string>>:
A list of rules for type compatibility in arithmetic operations.
Creates common rules for relational operations between types.
Array<Array<string>>:
A list of rules for type compatibility in relational operations.
A map defining the operation rules for each arithmetic operator.
A map defining the operation rules for each relational operator.
Represents an invocable entity, which can be invoked with arguments. This is a base class intended to be extended by specific invocable types.
Invokes this entity with the given arguments.
(InterpreterVisitor)
The interpreter instance managing the execution context.
(Array<any>)
The arguments to pass to the invocable entity.
any:
The result of the invocation.
Performs a logical operation between two literals of type 'bool'.
(string)
The logical operator ('&&' for logical AND, '||' for logical OR).
(Literal)
The left operand of the logical operation, which must be of type 'bool'.
(Literal)
The right operand of the logical operation, which must be of type 'bool'.
(Object)
The location information for error reporting.
Literal:
The result of the logical operation as a new Literal object of type 'bool'.
Performs a relational operation between two literals.
(string)
The relational operator ('<', '>', '<=', '>=', '==', '!=').
(Literal)
The left operand of the relational operation.
(Literal)
The right operand of the relational operation.
(Object)
The location information for error reporting.
Literal:
The result of the relational operation as a new Literal object of type 'bool'.
Performs a unary operation on a single literal.
(string)
The unary operator ('-' for negation, '!' for logical NOT).
(Literal)
The literal operand on which the unary operation is performed.
(Object)
The location information for error reporting.
Literal:
The result of the unary operation as a new Literal object.
Type: any
Represents an abstract instance that cannot be instantiated directly.
This class serves as a base for concrete instances like Struct and ArrayList.
((Environment | Literal))
The properties associated with this instance.
Creates a deep copy of the instance. This method must be implemented by subclasses.
AbstractInstance:
A new instance that is a deep copy of the current instance.
Represents an ArrayList, which is an invocable entity capable of creating and managing arrays.
Extends Invocable
(ArrayListInstance)
The ArrayListInstance associated with this ArrayList.
(Array<any>)
The arguments provided to this ArrayList.
Type: ArrayListInstance
Invokes this ArrayList with the given arguments. Creates a new instance of ArrayList or retrieves an array based on the node configuration.
(InterpreterVisitor)
The interpreter instance managing the execution context.
(Array<any>)
The arguments to pass to the ArrayList.
ArrayListInstance:
A new instance of ArrayList or an array.
Creates a default array with the specified type and dimensions.
ArrayListInstance:
A new ArrayListInstance with default values.
Retrieves an array based on the node arguments and updates the node type.
(InterpreterVisitor)
The interpreter instance managing the execution context.
ArrayListInstance:
A new ArrayListInstance with evaluated values.
Clones a Literal object, including its value and type.
(Literal)
The Literal object to clone.
Literal:
A new Literal object with the cloned value and type.
Clones a value, handling instances of Literal, ArrayListInstance, and other types.
(any)
The value to clone.
any:
The cloned value.
Clones an ArrayListInstance object, including its class instance and properties.
(ArrayListInstance)
The ArrayListInstance object to clone.
ArrayListInstance:
A new ArrayListInstance object with cloned properties.
Represents a native function that can be invoked with a specific arity.
Extends Invocable
A collection of native functions available in the environment.
Type: Object<string, NativeFunction>
Parses a string argument into an integer.
Type: NativeFunction
Parses a string argument into a float.
Type: NativeFunction
Converts a value to its string representation.
Type: NativeFunction
Converts a string to lowercase.
Type: NativeFunction
Converts a string to uppercase.
Type: NativeFunction
Returns the type of the argument as a string.
Type: NativeFunction
Prints the arguments to the console.
Type: NativeFunction
Finds the index of a value in an ArrayList.
Type: NativeFunction
Joins the elements of an ArrayList into a string.
Type: NativeFunction
Returns the keys of a Struct as a string array.
Type: NativeFunction
Represents a function defined outside the current scope, with its own environment.
Extends Invocable
(FuncDeclaration)
The function declaration node.
(Environment)
The environment in which the function was declared.
Type: FuncDeclaration
Type: Environment
Invokes the function with the provided arguments.
(Interpreter)
The interpreter instance.
(Array<Literal>)
The arguments to pass to the function.
(Literal | null):
The result of the function invocation.
Represents a structure (or class) in the system, allowing for the creation of structured instances.
Extends Invocable
(StructDeclaration)
The structure declaration node.
(Environment)
The environment in which the structure was declared.
Type: StructDeclaration
Type: Environment
Creates an instance of the structure with the provided arguments.
(Interpreter)
The interpreter instance.
(Array<Literal>)
The arguments to initialize the structure instance.
StructInstance:
The newly created structure instance.
Represents an instance of a structure, holding its properties and allowing access to them.
Extends AbstractInstance
(Struct)
The structure class this instance belongs to.
(Environment)
The environment holding the instance properties.
Creates a deep copy of the StructInstance.
StructInstance:
A new instance that is a deep copy of the current one.
Represents an instance of an ArrayList, holding its elements and allowing access to them.
Extends AbstractInstance
(ArrayList)
The ArrayList class this instance belongs to.
(Literal)
The list of literals representing the array elements.
Sets a value at a specific index in the ArrayList instance.
(Literal)
The index of the element to set.
(any)
The value to assign.
(Object)
The location where the assignment is performed.
Gets a value at a specific index in the ArrayList instance or its length.
(Literal)
The index of the element to get or a special key ("length").
(Object)
The location from which the value is accessed.
any:
The value at the specified index or the length of the ArrayList.
Creates a deep copy of the ArrayListInstance.
ArrayListInstance:
A new instance that is a deep copy of the current one.
Exception used to signal a break in loop control.
Extends Error
Exception used to signal a continue in loop control.
Extends Error
Exception used to signal a return from a function.
Extends Error
(Literal)
The value to be returned from the function.
Creates a Literal based on the variable declaration type and value.
(string)
The type of the variable.
(string)
The name of the variable.
((Literal | null))
The initial value of the variable.
(Location)
The location in the source code where the variable is declared.
Literal:
The resulting
Literal
based on the type and value.
(object | null):
boolean:
string: