Skip to content

Commit c52b7d1

Browse files
gh-120: Fix extension hook registration.
1 parent a3fb61f commit c52b7d1

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/parser.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,17 @@ static Expr* parse_typed_ident_expr(Parser* parser) {
258258

259259
static Expr* parse_extension_spec_expr(Parser* parser) {
260260
Token type_tok = parser->current_token;
261-
advance(parser);
262-
consume(parser, TOKEN_COLON, "Expected ':' after EXTENSION");
263261

264-
if (parser->current_token.type != TOKEN_IDENT) {
265-
report_error(parser, "Expected extension specifier after EXTENSION:");
262+
if (type_tok.type == TOKEN_IDENT && type_tok.literal && strcmp(type_tok.literal, "EXTENSION") == 0 && parser->next_token.type == TOKEN_COLON) {
263+
advance(parser);
264+
consume(parser, TOKEN_COLON, "Expected ':' after EXTENSION");
265+
266+
if (parser->current_token.type != TOKEN_IDENT) {
267+
report_error(parser, "Expected extension specifier after EXTENSION:");
268+
return NULL;
269+
}
270+
} else if (parser->current_token.type != TOKEN_IDENT) {
271+
report_error(parser, "Expected extension specifier");
266272
return NULL;
267273
}
268274

@@ -503,9 +509,7 @@ static Expr* parse_call(Parser* parser) {
503509
call->as.call.args.count == 0 &&
504510
call->as.call.kw_count == 0 &&
505511
parser->current_token.type == TOKEN_IDENT &&
506-
parser->current_token.literal != NULL &&
507-
strcmp(parser->current_token.literal, "EXTENSION") == 0 &&
508-
parser->next_token.type == TOKEN_COLON;
512+
parser->next_token.type != TOKEN_EQUALS;
509513

510514
if (is_typed_assign_target || is_extend_specifier) {
511515
Expr* arg = is_extend_specifier ? parse_extension_spec_expr(parser)

0 commit comments

Comments
 (0)