OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * Go language grammar. | 6 * Go language grammar. |
7 * | 7 * |
8 * The Go semicolon rules are: | 8 * The Go semicolon rules are: |
9 * | 9 * |
10 * 1. all statements and declarations are terminated by semicolons. | 10 * 1. all statements and declarations are terminated by semicolons. |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 $$->list = $1; | 606 $$->list = $1; |
607 $$->etype = 0; // := flag | 607 $$->etype = 0; // := flag |
608 } | 608 } |
609 | expr_list LCOLAS LRANGE expr | 609 | expr_list LCOLAS LRANGE expr |
610 { | 610 { |
611 $$ = nod(ORANGE, N, $4); | 611 $$ = nod(ORANGE, N, $4); |
612 $$->list = $1; | 612 $$->list = $1; |
613 $$->colas = 1; | 613 $$->colas = 1; |
614 colasdefn($1, $$); | 614 colasdefn($1, $$); |
615 } | 615 } |
| 616 | LRANGE expr |
| 617 { |
| 618 $$ = nod(ORANGE, N, $2); |
| 619 $$->etype = 0; // := flag |
| 620 } |
616 | 621 |
617 for_header: | 622 for_header: |
618 osimple_stmt ';' osimple_stmt ';' osimple_stmt | 623 osimple_stmt ';' osimple_stmt ';' osimple_stmt |
619 { | 624 { |
620 // init ; test ; incr | 625 // init ; test ; incr |
621 if($5 != N && $5->colas != 0) | 626 if($5 != N && $5->colas != 0) |
622 yyerror("cannot declare in the for-increment"); | 627 yyerror("cannot declare in the for-increment"); |
623 $$ = nod(OFOR, N, N); | 628 $$ = nod(OFOR, N, N); |
624 if($1 != N) | 629 if($1 != N) |
625 $$->ninit = list1($1); | 630 $$->ninit = list1($1); |
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2207 static void | 2212 static void |
2208 fixlbrace(int lbr) | 2213 fixlbrace(int lbr) |
2209 { | 2214 { |
2210 // If the opening brace was an LBODY, | 2215 // If the opening brace was an LBODY, |
2211 // set up for another one now that we're done. | 2216 // set up for another one now that we're done. |
2212 // See comment in lex.c about loophack. | 2217 // See comment in lex.c about loophack. |
2213 if(lbr == LBODY) | 2218 if(lbr == LBODY) |
2214 loophack = 1; | 2219 loophack = 1; |
2215 } | 2220 } |
2216 | 2221 |
OLD | NEW |