token_t* lexer_nextif(lexer_state_t* lex, token_types_t tokentype) { if ( lex->error ) return NULL; if ( lexer_matches(lex, tokentype) ) { return lexer_next(lex); } return NULL; }
token_t* lexer_nextif_special(lexer_state_t* lex, const char* token) { if ( lex->error ) return NULL; if ( lexer_matches(lex, special_token) ) { if ( strcmp((char*) lexer_cur(lex)->value, token) == 0 ) { return lexer_next(lex); } } return NULL; }
struct node *parse_argument(struct compiler *compiler) { struct node *result = alloc_node(compiler, N_ARGUMENT); result->left = parse_expression(compiler); result->right = 0; if(lexer_matches(compiler, T_COMMA)) result->right = parse_argument(compiler); else result->right = 0; return result; }