module

TokenNavigation

methods for peek, next_token, consume, and error-handling

Instance methods

consume!(expected)
Source
consume?
Source
consume?(expected_kind : Token.class) : Token | Nil

Consumes the current token if it's of the expected kind. If not, reports an error and returns nil.

Source
consume?(expected_data : KeyWord | Operator | String) : Token | Nil

Overload for specific token data

Source
consume_identifier(context_message : String = "identifier") : String

--- Identifier Consumption --- Consumes the next token as if it is an identifier. Works for variable names, type names, keywords, and operators; raises a ParseError otherwise

Source
consume_indent?(block_indent : UInt32) : UInt32 | Nil

Consumes a newline only if it begins a new block and returns that indent. Otherwise returns nil.

Source
consume_list_separator?(list_indent) : Token::Comma | Token::Newline | Nil

Consumes a comma or newline acting as a list separator Returns the consumed token or nil if end of list Trailing comma and/or newline are consumed but not returned.

Source
consume_type_name!
Source
consume_type_name?(ignore_newline = false) : String | Nil
Source
consume_until(kind1 : Token.class, kind2 : Token.class)
Source
consume_until(kind : Token.class)
Source
consume_until(*target_kinds : Token.class) : Token

Consumes tokens until one of the target_kinds is encountered or EOF. Returns the token that matched or the EOF token.

Source
eof?

Checks if the parser has reached the end of the token stream.

Source
next_token

Consumes the current token and returns it. Advances the index. Returns the last token if already at EOF to prevent errors on multiple calls.

Source
peek

Peeks at the current token without consuming

Source
peek2
Source
read_binding?
Source
read_convention?

Reads an optional convention keyword (let, mut, move, copy, ref)

Source
recover_to_next_declaration
Source
recover_to_next_fn_or_sub_item
Source
report_error(location : Location, message : String) : Parser::ParseError

--- Error Reporting & Recovery ---

Source
skip_newline_unless_block_end?(block_indent : UInt32, raise_on_outdent : String | Nil = nil) : Bool

Consumes a newline only if it's not the end of a block Returns true if end of block found End of block is determined to be a newline with indent ≤ block_indent EXCEPT if the token after newline is a closing bracket or else

Source