aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-02-04 21:49:27 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-02-04 21:49:27 -0500
commit419e75eb2313b4910921185211201317cbbb400c (patch)
tree3ad2166c30e84a6d7ce075fb48741e336eb87027 /src/parser.cpp
parent0d7abc6368a826490f8985634882300b50d81cba (diff)
downloadzig-419e75eb2313b4910921185211201317cbbb400c.tar.gz
zig-419e75eb2313b4910921185211201317cbbb400c.zip
remove volatileStore builtin; add volatile pointers
closes #238
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 7b7126ca40..aa0d7ddff3 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -996,7 +996,7 @@ static PrefixOp tok_to_prefix_op(Token *token) {
/*
PrefixOpExpression : PrefixOp PrefixOpExpression | SuffixOpExpression
-PrefixOp = "!" | "-" | "~" | "*" | ("&" option("const")) | "?" | "%" | "%%" | "??" | "-%"
+PrefixOp = "!" | "-" | "~" | "*" | ("&" option("const") option("volatile")) | "?" | "%" | "%%" | "??" | "-%"
*/
static AstNode *ast_parse_prefix_op_expr(ParseContext *pc, size_t *token_index, bool mandatory) {
Token *token = &pc->tokens->at(*token_index);
@@ -1036,10 +1036,19 @@ static AstNode *ast_parse_prefix_op_expr(ParseContext *pc, size_t *token_index,
}
if (prefix_op == PrefixOpAddressOf) {
- Token *token = &pc->tokens->at(*token_index);
- if (token->id == TokenIdKeywordConst) {
+ Token *const_or_volatile_tok = &pc->tokens->at(*token_index);
+ if (const_or_volatile_tok->id == TokenIdKeywordConst) {
+ *token_index += 1;
+ Token *volatile_token = &pc->tokens->at(*token_index);
+ if (volatile_token->id == TokenIdKeywordVolatile) {
+ *token_index += 1;
+ prefix_op = PrefixOpConstVolatileAddressOf;
+ } else {
+ prefix_op = PrefixOpConstAddressOf;
+ }
+ } else if (const_or_volatile_tok->id == TokenIdKeywordVolatile) {
+ prefix_op = PrefixOpVolatileAddressOf;
*token_index += 1;
- prefix_op = PrefixOpConstAddressOf;
}
}