ref: 70ffb7afdd7e6a92988c808370837fe638b9629f
parent: 80f1e8ed2ff1a49b39ad424f388f10d434766e43
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jan 17 17:52:47 EST 2017
Clean up grammar a little. Remove dead and obsolete constructs.
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -110,7 +110,6 @@
%token<tok> Tconst /* const */
%token<tok> Tvar /* var */
%token<tok> Tgeneric /* var */
-%token<tok> Tcast /* castto */
%token<tok> Tgap /* _ */
%token<tok> Tellipsis /* ... */
@@ -140,14 +139,14 @@
%type <tydef> tydef pkgtydef typeid
%type <trait> traitdef
-%type <node> exprln retexpr goto continue break expr atomicexpr
-%type <node> littok literal asnexpr lorexpr landexpr borexpr strlit
-%type <node> bandexpr cmpexpr unionexpr addexpr mulexpr shiftexpr prefixexpr postfixexpr
-%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> castexpr
-%type <node> match
+%type<node> exprln retexpr goto continue break expr atomicexpr
+%type<node> littok literal lorexpr landexpr borexpr strlit bandexpr
+%type<node> cmpexpr unionexpr addexpr mulexpr shiftexpr prefixexpr
+%type<node> postfixexpr funclit seqlit tuplit name block stmt label
+%type<node> use fnparam declbody declcore typedeclcore structent
+%type<node> arrayelt structelt tuphead ifstmt forstmt whilestmt
+%type<node> matchstmt elifs optexprln loopcond optexpr match
+
%type <ucon> unionelt
%type <node> blkbody
%type <node> implstmt
@@ -614,10 +613,7 @@
exprln : expr Tendln
;
-expr : asnexpr
- ;
-
-asnexpr : lorexpr asnop asnexpr
+expr : lorexpr asnop expr
{$$ = mkexpr($1->loc, binop($2->type), $1, $3, NULL);}
| lorexpr
;
@@ -655,14 +651,6 @@
unionexpr
: Ttick name unionexpr {$$ = mkexpr($1->loc, Oucon, $2, $3, NULL);}
| Ttick name {$$ = mkexpr($1->loc, Oucon, $2, NULL);}
- | castexpr
- ;
-
-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;
- }
| borexpr
;
@@ -731,9 +719,9 @@
| atomicexpr
;
-arglist : asnexpr
+arglist : expr
{$$.nl = NULL; $$.nn = 0; lappend(&$$.nl, &$$.nn, $1);}
- | arglist Tcomma asnexpr
+ | arglist Tcomma expr
{lappend(&$$.nl, &$$.nn, $3);}
| /* empty */
{$$.nl = NULL; $$.nn = 0;}
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -166,7 +166,6 @@
{"$noret", Tattr},
{"_", Tgap},
{"break", Tbreak},
- {"castto", Tcast},
{"const", Tconst},
{"continue", Tcontinue},
{"elif", Telif},