src/onyxparser.c
// Advances to next token no matter what
Advances to next token no matter what
Advances to next token no matter what
static OnyxToken* expect_token(OnyxParser* parser, TokenType token_type) {
    if (parser->hit_unexpected_token) return NULL;
    OnyxToken* token = parser->curr;
    consume_token(parser);
    if (token->type != token_type) {
        onyx_report_error(token->pos, "expected token '%s', got '%s'.", token_name(token_type), token_name(token->type));
        parser->hit_unexpected_token = 1;
        parser->curr = &parser->tokenizer->tokens[bh_arr_length(parser->tokenizer->tokens) - 1];
        return NULL;
    }
    return token;
}
static OnyxToken * expect_token ( OnyxParser * parser , TokenType token_type ) { if ( parser -> hit_unexpected_token ) return NULL ; OnyxToken * token = parser -> curr ; consume_token ( parser ) ; if ( token -> type != token_type ) { onyx_report_error ( token -> pos , " " , token_name ( token_type ) , token_name ( token -> type ) ) ; parser -> hit_unexpected_token = 1 ; parser -> curr = & parser -> tokenizer -> tokens [ bh_arr_length ( parser -> tokenizer -> tokens ) - 1 ] ; return NULL ; } return token ; }
Advances to next token no matter what
Advances to next token no matter what