%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> exprsym3_list_r exprsym3
-%type <node> name onew_name new_name new_name_list_r new_field
+%type <node> name labelname onew_name new_name new_name_list_r new_field
%type <node> vardcl_list_r vardcl Avardcl Bvardcl
%type <node> interfacedcl_list_r interfacedcl interfacedcl1
%type <node> structdcl_list_r structdcl embed
%left '{'
%left Condition
+/*
+ * resolve LPACKAGE vs not in favor of LPACKAGE
+ */
+%left NotPackage
+%left LPACKAGE
+
+/*
+ * resolve '.' vs not in favor of '.'
+ */
+%left NotDot
+%left '.'
+
+/*
+ * resolve '(' vs not in favor of '('
+ */
+%left NotParen
+%left '('
%%
file:
}
package:
+ %prec NotPackage
{
yyerror("package statement must be first");
mkpackage("main");
{
$$ = nod(OLITERAL, N, N);
$$->val = $1;
+ if($1.ctype == CTSTR)
+ $$->type = types[TSTRING];
}
| laconst
{
{
$$ = oldname($1);
}
+ /*
+ * this rule introduces 1 reduce/reduce conflict
+ * with the rule lpack: LPACK above.
+ * the reduce/reduce conflict is only with
+ * lookahead '.', in which case the correct
+ * resolution is the lpack rule. (and it wins
+ * because it is above.)
+ */
+| LPACK %prec NotDot
+ {
+ $$ = oldname($1);
+ }
+
+labelname:
+ name
+| keyword
+ {
+ $$ = oldname($1);
+ }
convtype:
latype
}
Bfnres:
+ %prec NotParen
{
$$ = N;
}
{
$$ = N;
}
-| new_name ':'
+| labelname ':'
{
$$ = nod(OLABEL, $1, N);
}
}
laconst:
- LPACK
- {
- // for LALR(1) reasons, using laconst works here
- // but lname does not. even so, the messages make
- // more sense saying "var" instead of "const".
- yyerror("%s is package, not var", $1->name);
- YYERROR;
- }
-| LATYPE
+ LATYPE
{
yyerror("%s is type, not var", $1->name);
YYERROR;
./convlit.go:11: overflow converting constant to int
./convlit.go:12: overflow converting constant to float
./convlit.go:8: cannot convert non-integer constant to int
-./convlit.go:9: cannot convert non-integer constant to int
-./convlit.go:11: overflow converting constant to int
-./convlit.go:11: fatal error: too many errors
+./convlit.go:8: fatal error: too many errors
==================================================
=========== ./helloworld.go
=========== chan/nonblock.go
PASS
-=========== bugs/bug085.go
-bugs/bug085.go:8: P: undefined
-BUG: fails incorrectly
-
=========== bugs/bug087.go
bugs/bug087.go:8: illegal combination of literals LEN 9
bugs/bug087.go:8: illegal combination of literals LEN 9
=========== bugs/bug125.go
BUG: errchk: command succeeded unexpectedly: 6g bugs/bug125.go
-=========== bugs/bug129.go
-bugs/bug129.go:6: syscall is package, not var
-BUG129
-
=========== bugs/bug131.go
BUG: should not compile