summaryrefslogtreecommitdiff
path: root/src/parser/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/parser.c')
-rw-r--r--src/parser/parser.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/parser/parser.c b/src/parser/parser.c
index ccdc037..b947ea2 100644
--- a/src/parser/parser.c
+++ b/src/parser/parser.c
@@ -96,6 +96,7 @@ static bool
parse_decl(struct parser *ctx)
{
struct type *type;
+ int ptr_levels;
struct ast_node *node;
/*
@@ -112,6 +113,12 @@ parse_decl(struct parser *ctx)
}
parser_advance(ctx);
+ ptr_levels = 0;
+ while (ctx->tok.kind == TOK_ASTERISK) {
+ ptr_levels++;
+ parser_advance(ctx);
+ }
+
if (ctx->tok.kind != TOK_IDENTIFIER) {
tok_error(&ctx->tok, "expected identifier after type\n");
return false;
@@ -127,7 +134,7 @@ parse_decl(struct parser *ctx)
node->name = ctx->tok.pos;
node->name_len = ctx->tok.len;
node->type = type;
- node->ptr_levels = 0;
+ node->ptr_levels = ptr_levels;
parser_advance(ctx);
if (ctx->tok.kind == TOK_LPAREN) {