module

Lox::Compiler

Constants

ARBITRARY = Token.new(TokenType::Nil, "", 0, 0)

The initial state of previous and current doesn't really matter, because they get filled in with actual tokens from the scanner when we do the compilation.

Instance methods

add_local!(name : Token)

The instructions to work with local variables refer to them by slot index, and that index is stored in a single-byte operand, which means our VM only supports up to Byte::MAX local variables in scope at a time.

Source
advance!
Source
and!(precedence : Precedence) : Nil
Source
argument_list!

Compiles the arguments passed to a function and returns the number of arguments compiled.

Source
begin_scope!
Source
binary!(precedence : Precedence) : Nil
Source
block!
Source
call!(precedence : Precedence) : Nil
Source
compile(input : String) : FunctionObject | Nil

TODO: Maybe this should return an error of some kind instead of Nil if the input fails to compile?

Source
consume!(type : TokenType, message : String)
Source
current_chunk
Source
current_token_is(type : TokenType) : Bool
Source
declaration!
Source
declare_variable!
Source
define_variable!(index : Byte)
Source
emit_byte!(byte : Byte)
Source
emit_bytes!(*bytes : Byte)
Source
emit_constant!(value : Lox::Value)
Source
emit_jump!(instruction : Opcode) : Int
Source
emit_loop!(loop_start : Int)
Source
emit_return!
Source
end_scope!
Source
error!(message : String)
Source
error_at!(token : Token, message : String)
Source
error_at_current!(message : String)
Source
expression!
Source
expression_statement!
Source
for_statement!
Source
function!(type : FunctionType)
Source
function_declaration!
Source
function_scope(name : String) : Scope
Source
grouping!(precedence : Precedence) : Nil
Source
identifier_constant!(name : Token) : Byte
Source
if_statement!
Source
literal!(precedence : Precedence) : Nil
Source
make_constant!(value : Lox::Value) : Byte
Source
mark_initialized!
Source
match!(type : TokenType) : Bool
Source
named_variable!(name : Token, precedence : Precedence)
Source
number!(precedence : Precedence) : Nil
Source
or!(precedence : Precedence) : Nil
Source
parse_precedence!(precedence : Precedence)
Source
parse_rule(operator_type : TokenType) : ParseRule
Source
parse_variable!(error_msg : String) : Byte
Source
patch_jump!(offset : Int)
Source
previous_token_is(type : TokenType) : Bool
Source
resolve_local(scope : Scope, name : Token) : Byte | Nil
Source
return_statement!
Source
scope(enclosing : Scope | Nil, name : String, function_type : FunctionType) : Scope
Source
script_scope
Source
statement!
Source
string!(precedence : Precedence) : Nil
Source
synchronize!
Source
unary!(precedence : Precedence) : Nil
Source
variable!(precedence : Precedence) : Nil
Source
variable_declaration!
Source
while_statement!
Source

Nested types