summaryrefslogtreecommitdiff
path: root/parse/gram.y
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
committerOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
commit7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9 (patch)
treec9434a55ea6850aee7103f608c6333cfe3148d60 /parse/gram.y
parentc96238b89583ed91e92ad909c507797d00015e95 (diff)
downloadmc-7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9.tar.gz
New syntax for casts.
Diffstat (limited to 'parse/gram.y')
-rw-r--r--parse/gram.y9
1 files changed, 7 insertions, 2 deletions
diff --git a/parse/gram.y b/parse/gram.y
index be5054e..ba61966 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -146,8 +146,8 @@ static void setupinit(Node *n);
%type <node> funclit seqlit tuplit name block stmt label use
%type <node> fnparam declbody declcore typedeclcore structent arrayelt structelt tuphead
%type <node> ifstmt forstmt whilestmt matchstmt elifs optexprln loopcond optexpr
-%type <node> match
%type <node> castexpr
+%type <node> match
%type <ucon> unionelt
%type <node> blkbody
%type <node> implstmt
@@ -644,7 +644,7 @@ landexpr: landexpr Tland cmpexpr
| cmpexpr
;
-cmpexpr : cmpexpr cmpop castexpr
+cmpexpr : cmpexpr cmpop unionexpr
{$$ = mkexpr($1->loc, binop($2->type), $1, $3, NULL);}
| unionexpr
;
@@ -658,6 +658,7 @@ unionexpr
;
castexpr: castexpr Tcast Toparen type Tcparen {
+ fprintf(stdout, "%s:%d: deprecated cast syntax being removed\n", fname($2->loc), lnum($2->loc));
$$ = mkexpr($1->loc, Ocast, $1, NULL);
$$->expr.type = $4;
}
@@ -745,6 +746,10 @@ atomicexpr
| literal
| Toparen expr Tcparen
{$$ = $2;}
+ | Toparen expr Tcolon type Tcparen {
+ $$ = mkexpr($1->loc, Ocast, $2, NULL);
+ $$->expr.type = $4;
+ }
| Tsizeof Toparen type Tcparen
{$$ = mkexpr($1->loc, Osize, mkpseudodecl($1->loc, $3), NULL);}
;