Class Interpreter
Provides core evaluation logic for the SILQ interpreter, including arithmetic operations, type checking, and expression evaluation.
public class Interpreter : IVisitor<object>, IVisitor
- Inheritance
-
Interpreter
- Implements
- Inherited Members
Constructors
Interpreter(object)
Initializes a new instance of the Interpreter class with the specified context.
public Interpreter(object context)
Parameters
contextobjectThe context in which the interpreter operates.
Methods
Interpret(List<Statement>)
Interprets a list of statements by executing each statement in order. Throws a RuntimeError if an error occurs during execution.
public void Interpret(List<Statement> statements)
Parameters
Interpret(Expression)
Interprets the given expression by evaluating it and converting the result to a string.
public string Interpret(Expression expression)
Parameters
expressionExpressionThe expression to interpret.
Returns
- string
The string representation of the evaluated expression.
Visit(Binary)
Visits a Binary expression and evaluates it according to its operator and operands.
public object Visit(Binary binary)
Parameters
binaryBinaryThe binary expression to evaluate.
Returns
- object
The result of the binary operation.
Visit(Function)
Visits a Function expression and processes its behavior.
public object Visit(Function function)
Parameters
functionFunctionThe function expression to evaluate.
Returns
- object
The result of the function evaluation.
Visit(Grouping)
Visits a Grouping expression and evaluates its contained expression.
public object Visit(Grouping grouping)
Parameters
groupingGroupingThe grouping expression to evaluate.
Returns
- object
The result of the evaluated grouping expression.
Visit(Literal)
Visits a Literal expression and returns its value, converting to double if possible.
public object Visit(Literal literal)
Parameters
literalLiteralThe literal expression to evaluate.
Returns
- object
The value of the literal, possibly as a double.
Visit(Unary)
Visits a Unary expression and evaluates it according to its operator.
public object Visit(Unary unary)
Parameters
unaryUnaryThe unary expression to evaluate.
Returns
- object
The result of the unary operation.
Visit(Variable)
Visits a Variable expression and retrieves its value from the environment.
public object Visit(Variable variable)
Parameters
variableVariableThe variable expression to evaluate.
Returns
- object
The value of the variable from the environment.
Visit(As)
Implements the visitor method for the As statement.
public void Visit(As statement)
Parameters
statementAsThe "As" statement to process.
Visit(From)
Implements the visitor method for the From statement.
public object Visit(From from)
Parameters
fromFromThe "From" statement to process.
Returns
Visit(Function)
Implements the visitor method for the Function statement.
public void Visit(Function statement)
Parameters
statementFunctionThe "Function" statement to process.
Visit(Print)
Implements the visitor method for the Print statement. Evaluates the expression and writes its string representation to the console.
public void Visit(Print print)
Parameters
printPrintThe print statement to execute.
Visit(Select)
Implements the visitor method for the Select statement.
public void Visit(Select select)
Parameters
selectSelectThe "Select" statement to process.
Visit(Where)
Implements the visitor method for the Where statement.
public void Visit(Where where)
Parameters
whereWhereThe "Where" statement to process.