Jai_Lexer module

peek_token

procedureSource

Returns the token lookahead_index places ahead without consuming it; 0 is the next token. The index must be below MAX_CONCURRENT_TOKENS, and the pointer stays valid until you eat past it.

peek_token :: (lexer: *J.Lexer, lookahead_index: s32) -> *J.Token

Parameters

lexer: *J.Lexer
lookahead_index: s32

Returns

Example↗
lexer: Lexer;
set_input_from_string(*lexer, "a + b");
assert(peek_token(*lexer, 1).type == #char "+");
assert(peek_token(*lexer, 0).ident_value.name == "a");

See also