diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2015-12-15 20:08:53 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2015-12-15 20:08:53 -0700 |
| commit | aa56f016f73063371431b8b2587538c79af97bd9 (patch) | |
| tree | 30ab1eecc5161a9cf60971735537c29af484b187 /src/parser.cpp | |
| parent | 5a8822c714e4ee2d442e76f36213d119530f0fea (diff) | |
| download | zig-aa56f016f73063371431b8b2587538c79af97bd9.tar.gz zig-aa56f016f73063371431b8b2587538c79af97bd9.zip | |
support addressof operator and struct pointer field access
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 572309bed7..3231cc0d2f 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1153,12 +1153,13 @@ static PrefixOp tok_to_prefix_op(Token *token) { case TokenIdBang: return PrefixOpBoolNot; case TokenIdDash: return PrefixOpNegation; case TokenIdTilde: return PrefixOpBinNot; + case TokenIdAmpersand: return PrefixOpAddressOf; default: return PrefixOpInvalid; } } /* -PrefixOp : token(Not) | token(Dash) | token(Tilde) +PrefixOp : token(Not) | token(Dash) | token(Tilde) | (token(Ampersand) option(token(Const))) */ static PrefixOp ast_parse_prefix_op(ParseContext *pc, int *token_index, bool mandatory) { Token *token = &pc->tokens->at(*token_index); @@ -1171,6 +1172,15 @@ static PrefixOp ast_parse_prefix_op(ParseContext *pc, int *token_index, bool man } } *token_index += 1; + + if (result == PrefixOpAddressOf) { + Token *token = &pc->tokens->at(*token_index); + if (token->id == TokenIdKeywordConst) { + *token_index += 1; + result = PrefixOpConstAddressOf; + } + } + return result; } |
