Commit 3ec46752 authored by Russ Cox's avatar Russ Cox

clean up range grammar

R=ken
OCL=23712
CL=23714
parent 9f726c2c
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
%type <node> Astmt Bstmt %type <node> Astmt Bstmt
%type <node> for_stmt for_body for_header %type <node> for_stmt for_body for_header
%type <node> if_stmt if_body if_header select_stmt %type <node> if_stmt if_body if_header select_stmt
%type <node> simple_stmt osimple_stmt orange_stmt semi_stmt %type <node> simple_stmt osimple_stmt range_stmt semi_stmt
%type <node> expr uexpr pexpr expr_list oexpr oexpr_list expr_list_r %type <node> expr uexpr pexpr expr_list oexpr oexpr_list expr_list_r
%type <node> exprsym3_list_r exprsym3 %type <node> exprsym3_list_r exprsym3
%type <node> name onew_name new_name new_name_list_r new_field %type <node> name onew_name new_name new_name_list_r new_field
...@@ -536,9 +536,8 @@ compound_stmt: ...@@ -536,9 +536,8 @@ compound_stmt:
popdcl(); popdcl();
} }
orange_stmt: range_stmt:
osimple_stmt exprsym3_list_r '=' LRANGE expr
| exprsym3_list_r '=' LRANGE expr
{ {
$$ = nod(ORANGE, $1, $4); $$ = nod(ORANGE, $1, $4);
$$->etype = 0; // := flag $$->etype = 0; // := flag
...@@ -550,14 +549,8 @@ orange_stmt: ...@@ -550,14 +549,8 @@ orange_stmt:
} }
for_header: for_header:
osimple_stmt ';' orange_stmt ';' osimple_stmt osimple_stmt ';' osimple_stmt ';' osimple_stmt
{ {
if($3 != N && $3->op == ORANGE) {
$$ = dorange($3);
$$->ninit = list($$->ninit, $1);
$$->nincr = list($$->nincr, $5);
break;
}
// init ; test ; incr // init ; test ; incr
if($5 != N && $5->colas != 0) if($5 != N && $5->colas != 0)
yyerror("cannot declare in the for-increment"); yyerror("cannot declare in the for-increment");
...@@ -566,19 +559,19 @@ for_header: ...@@ -566,19 +559,19 @@ for_header:
$$->ntest = $3; $$->ntest = $3;
$$->nincr = $5; $$->nincr = $5;
} }
| orange_stmt | osimple_stmt
{ {
// range
if($1 != N && $1->op == ORANGE) {
$$ = dorange($1);
break;
}
// normal test // normal test
$$ = nod(OFOR, N, N); $$ = nod(OFOR, N, N);
$$->ninit = N; $$->ninit = N;
$$->ntest = $1; $$->ntest = $1;
$$->nincr = N; $$->nincr = N;
} }
| range_stmt
{
$$ = dorange($1);
addtotop($$);
}
for_body: for_body:
for_header compound_stmt for_header compound_stmt
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment