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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 } | 1063 } |
1064 | 1064 |
1065 fndcl: | 1065 fndcl: |
1066 dcl_name '(' oarg_type_list_ocomma ')' fnres | 1066 dcl_name '(' oarg_type_list_ocomma ')' fnres |
1067 { | 1067 { |
1068 Node *n; | 1068 Node *n; |
1069 | 1069 |
1070 $3 = checkarglist($3, 1); | 1070 $3 = checkarglist($3, 1); |
1071 $$ = nod(ODCLFUNC, N, N); | 1071 $$ = nod(ODCLFUNC, N, N); |
1072 $$->nname = $1; | 1072 $$->nname = $1; |
1073 if($3 == nil && $5 == nil) | |
1074 $$->nname = renameinit($1); | |
1075 n = nod(OTFUNC, N, N); | 1073 n = nod(OTFUNC, N, N); |
1076 n->list = $3; | 1074 n->list = $3; |
1077 n->rlist = $5; | 1075 n->rlist = $5; |
| 1076 if(strcmp($1->sym->name, "init") == 0) { |
| 1077 $$->nname = renameinit($1); |
| 1078 if($3 != nil || $5 != nil) |
| 1079 yyerror("func init must have no arguments and no
return values"); |
| 1080 } |
| 1081 if(strcmp(localpkg->name, "main") == 0 && strcmp($1->sym->name,
"main") == 0) { |
| 1082 if($3 != nil || $5 != nil) |
| 1083 yyerror("func main must have no arguments and no
return values"); |
| 1084 } |
1078 // TODO: check if nname already has an ntype | 1085 // TODO: check if nname already has an ntype |
1079 $$->nname->ntype = n; | 1086 $$->nname->ntype = n; |
1080 funchdr($$); | 1087 funchdr($$); |
1081 } | 1088 } |
1082 | '(' oarg_type_list_ocomma ')' new_name '(' oarg_type_list_ocomma ')' fnr
es | 1089 | '(' oarg_type_list_ocomma ')' new_name '(' oarg_type_list_ocomma ')' fnr
es |
1083 { | 1090 { |
1084 Node *rcvr, *t; | 1091 Node *rcvr, *t; |
1085 | 1092 |
1086 $2 = checkarglist($2, 0); | 1093 $2 = checkarglist($2, 0); |
1087 $6 = checkarglist($6, 1); | 1094 $6 = checkarglist($6, 1); |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 | 1828 |
1822 hidden_interfacedcl_list: | 1829 hidden_interfacedcl_list: |
1823 hidden_interfacedcl | 1830 hidden_interfacedcl |
1824 { | 1831 { |
1825 $$ = list1($1); | 1832 $$ = list1($1); |
1826 } | 1833 } |
1827 | hidden_interfacedcl_list ';' hidden_interfacedcl | 1834 | hidden_interfacedcl_list ';' hidden_interfacedcl |
1828 { | 1835 { |
1829 $$ = list($1, $3); | 1836 $$ = list($1, $3); |
1830 } | 1837 } |
OLD | NEW |