class Kaze::Interpreter
- Kaze::Interpreter
 - Reference
 - Object
 
Overview
Interpreter to compute expressions and statements.
Included Modules
Defined in:
interpreter.crConstructors
- 
        .new
        
          
Constructor function for the interpreter.
 
Instance Method Summary
- 
        #execute_block(statements : Array(Stmt), environment : Environment)
        
          
Creates a new environment for a block, and executes the block's statement array.
 - 
        #globals : Kaze::Environment
        
          
The global environment.
 - 
        #globals=(globals : Kaze::Environment)
        
          
The global environment.
 - 
        #interpret(statements : Array(Stmt))
        
          
Interprets a source file.
 - 
        #interpret(statement : Stmt | Expr | Nil)
        
          
Interprets a line in the REPL.
 - 
        #resolve(expr : Expr, depth : Int32)
        
          
Resloves an expression.
 - 
        #visit_assign_expr(expr : Expr::Assign) : VG
        
          
Evaluates an assignment expression.
 - 
        #visit_binary_expr(expr : Expr::Binary) : VG
        
          
Evaluates a binary expression.
 - 
        #visit_block_stmt(stmt : Stmt::Block) : Nil
        
          
Executes a statement block.
 - #visit_break_stmt(stmt : Stmt::Break) : Nil
 - 
        #visit_call_expr(expr : Expr::Call) : VG
        
          
Evaluates a function call.
 - 
        #visit_class_stmt(stmt : Stmt::Class) : Nil
        
          
Interprets a class.
 - 
        #visit_expression_stmt(stmt : Stmt::Expression) : Nil
        
          
Executes an expression statement.
 - 
        #visit_function_stmt(stmt : Stmt::Function) : Nil
        
          
Executes a function statement i.e.
 - 
        #visit_get_expr(expr : Expr::Get) : VG
        
          
Evaluates a get expression.
 - 
        #visit_grouping_expr(expr : Expr::Grouping) : VG
        
          
Evaluates a grouping (parenthesized) expression.
 - 
        #visit_if_stmt(stmt : Stmt::If) : Nil
        
          
Executes an if statement.
 - 
        #visit_lambda_expr(expr : Expr::Lambda) : VG
        
          
Evaluates a anonymous lambda function.
 - 
        #visit_literal_expr(expr : Expr::Literal) : VG
        
          
Evaluates a literal expression.
 - 
        #visit_logical_expr(expr : Expr::Logical) : VG
        
          
Evaluates a logical AND or OR expression.
 - 
        #visit_return_stmt(stmt : Stmt::Return) : Nil
        
          
Executes a return statement.
 - 
        #visit_self_expr(expr : Expr::Self) : VG
        
          
Evaluates
self. - 
        #visit_set_expr(expr : Expr::Set) : VG
        
          
Evaluates a set expression.
 - 
        #visit_super_expr(expr : Expr::Super) : VG
        
          
Evaluates a
superexpression. - 
        #visit_ternary_expr(expr : Expr::Ternary) : VG
        
          
Evaluates a ternary i.e.
 - 
        #visit_unary_expr(expr : Expr::Unary) : VG
        
          
Evaluates a unary expression.
 - 
        #visit_var_stmt(stmt : Stmt::Var) : Nil
        
          
Executes a variable declaration.
 - 
        #visit_variable_expr(expr : Expr::Variable) : VG
        
          
Evaluates a variable expression i.e.
 - 
        #visit_while_stmt(stmt : Stmt::While) : Nil
        
          
Executes a while statement.
 
Instance methods inherited from module Kaze::Stmt::Visitor
  
  
    
      visit_block_stmt(stmt : Block) : VG
    visit_block_stmt, 
    
  
    
      visit_break_stmt(stmt : Break) : VG
    visit_break_stmt, 
    
  
    
      visit_class_stmt(stmt : Class) : VG
    visit_class_stmt, 
    
  
    
      visit_expression_stmt(stmt : Expression) : VG
    visit_expression_stmt, 
    
  
    
      visit_function_stmt(stmt : Function) : VG
    visit_function_stmt, 
    
  
    
      visit_if_stmt(stmt : If) : VG
    visit_if_stmt, 
    
  
    
      visit_return_stmt(stmt : Return) : VG
    visit_return_stmt, 
    
  
    
      visit_var_stmt(stmt : Var) : VG
    visit_var_stmt, 
    
  
    
      visit_while_stmt(stmt : While) : VG
    visit_while_stmt
    
  
    
    
  
    
  Instance methods inherited from module Kaze::Expr::Visitor
  
  
    
      visit_assign_expr(expr : Assign) : VG
    visit_assign_expr, 
    
  
    
      visit_binary_expr(expr : Binary) : VG
    visit_binary_expr, 
    
  
    
      visit_call_expr(expr : Call) : VG
    visit_call_expr, 
    
  
    
      visit_get_expr(expr : Get) : VG
    visit_get_expr, 
    
  
    
      visit_grouping_expr(expr : Grouping) : VG
    visit_grouping_expr, 
    
  
    
      visit_lambda_expr(expr : Lambda) : VG
    visit_lambda_expr, 
    
  
    
      visit_literal_expr(expr : Literal) : VG
    visit_literal_expr, 
    
  
    
      visit_logical_expr(expr : Logical) : VG
    visit_logical_expr, 
    
  
    
      visit_self_expr(expr : Self) : VG
    visit_self_expr, 
    
  
    
      visit_set_expr(expr : Set) : VG
    visit_set_expr, 
    
  
    
      visit_super_expr(expr : Super) : VG
    visit_super_expr, 
    
  
    
      visit_ternary_expr(expr : Ternary) : VG
    visit_ternary_expr, 
    
  
    
      visit_unary_expr(expr : Unary) : VG
    visit_unary_expr, 
    
  
    
      visit_variable_expr(expr : Variable) : VG
    visit_variable_expr
    
  
    
    
  
    
    
    
  
    
    
    
  
Constructor Detail
Constructor function for the interpreter. Assigns @globals as the current environment. Also defines the standard library functions in the global environment.
Instance Method Detail
Creates a new environment for a block, and executes the block's statement array.
Interprets a line in the REPL. Can execute statements and also evaluate expressions.
Executes a function statement i.e. a function definition.
Evaluates a get expression. Raises an exception if the expression's object is not a class instance.
Evaluates a grouping (parenthesized) expression.
Evaluates a anonymous lambda function. This simply creates a new function without a name.
Evaluates a logical AND or OR expression.
Evaluates a ternary i.e. conditional expression. The expression on the right only evaluates if the one on the left is false.
Evaluates a variable expression i.e. a variable being used as an expression.