Commit d00bd1d1 authored by Rob Pike's avatar Rob Pike

cmd/gc: better error messages for C-style if statements.

Given
        if (i == 0)
                x++
The old message was
        x.go:6: syntax error: unexpected semicolon or newline before {
Now we see
        x.go:6: syntax error: missing { after if clause

Fixes #5687

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12822045
parent bc6bb3ef
......@@ -21,16 +21,16 @@ static struct {
"missing import path; require quoted string",
% loadsys package imports LFUNC LNAME '(' ')' '{' LIF if_header ';'
"unexpected semicolon or newline before {",
"missing { after if clause",
% loadsys package imports LFUNC LNAME '(' ')' '{' LSWITCH if_header ';'
"unexpected semicolon or newline before {",
"missing { after switch clause",
% loadsys package imports LFUNC LNAME '(' ')' '{' LFOR for_header ';'
"unexpected semicolon or newline before {",
"missing { after for clause",
% loadsys package imports LFUNC LNAME '(' ')' '{' LFOR ';' LBODY
"unexpected semicolon or newline before {",
"missing { after for clause",
% loadsys package imports LFUNC LNAME '(' ')' ';' '{'
"unexpected semicolon or newline before {",
......
/* A Bison parser, made by GNU Bison 2.5. */
/* A Bison parser, made by GNU Bison 2.3. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
/* Skeleton implementation for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
......@@ -26,7 +29,7 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
......@@ -44,7 +47,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.5"
#define YYBISON_VERSION "2.3"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
......@@ -52,54 +55,11 @@
/* Pure parsers. */
#define YYPURE 0
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Using locations. */
#define YYLSP_NEEDED 0
/* Copy the first part of user declarations. */
/* Line 268 of yacc.c */
#line 20 "go.y"
#include <u.h>
#include <stdio.h> /* if we don't, bison will, and go.h re-#defines getc */
#include <libc.h>
#include "go.h"
static int isrelease = -1;
static void fixlbrace(int);
/* Line 268 of yacc.c */
#line 83 "y.tab.c"
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 1
#endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE 0
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
......@@ -211,36 +171,63 @@ static void fixlbrace(int);
/* Copy the first part of user declarations. */
#line 20 "go.y"
#include <u.h>
#include <stdio.h> /* if we don't, bison will, and go.h re-#defines getc */
#include <libc.h>
#include "go.h"
static int isrelease = -1;
static void fixlbrace(int);
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 1
#endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE 0
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 293 of yacc.c */
#line 30 "go.y"
{
Node* node;
NodeList* list;
Type* type;
Sym* sym;
struct Val val;
int i;
/* Line 293 of yacc.c */
#line 232 "y.tab.c"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
}
/* Line 193 of yacc.c. */
#line 218 "y.tab.c"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
/* Copy the second part of user declarations. */
/* Line 343 of yacc.c */
#line 244 "y.tab.c"
/* Line 216 of yacc.c. */
#line 231 "y.tab.c"
#ifdef short
# undef short
......@@ -315,14 +302,14 @@ typedef short int yytype_int16;
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
YYID (int yyi)
YYID (int i)
#else
static int
YYID (yyi)
int yyi;
YYID (i)
int i;
#endif
{
return yyi;
return i;
}
#endif
......@@ -343,11 +330,11 @@ YYID (yyi)
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# ifndef _STDLIB_H
# define _STDLIB_H 1
# endif
# endif
# endif
......@@ -370,24 +357,24 @@ YYID (yyi)
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
# if (defined __cplusplus && ! defined _STDLIB_H \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# ifndef _STDLIB_H
# define _STDLIB_H 1
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
......@@ -403,9 +390,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc;
};
yytype_int16 yyss;
YYSTYPE yyvs;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
......@@ -416,27 +403,6 @@ union yyalloc
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (YYID (0))
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
......@@ -454,7 +420,24 @@ union yyalloc
while (YYID (0))
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack, Stack, yysize); \
Stack = &yyptr->Stack; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (YYID (0))
#endif
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 4
......@@ -677,42 +660,42 @@ static const yytype_int16 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 126, 126, 135, 142, 153, 153, 168, 169, 172,
173, 174, 177, 214, 225, 226, 229, 236, 243, 252,
266, 267, 274, 274, 287, 291, 292, 296, 301, 307,
311, 315, 319, 325, 331, 337, 342, 346, 350, 356,
362, 366, 370, 376, 380, 386, 387, 391, 397, 406,
412, 430, 435, 447, 463, 468, 475, 495, 513, 522,
541, 540, 555, 554, 585, 588, 595, 594, 605, 611,
620, 631, 637, 640, 648, 647, 658, 664, 676, 680,
685, 675, 706, 705, 718, 721, 727, 730, 742, 746,
741, 764, 763, 779, 780, 784, 788, 792, 796, 800,
804, 808, 812, 816, 820, 824, 828, 832, 836, 840,
844, 848, 852, 857, 863, 864, 868, 879, 883, 887,
891, 896, 900, 910, 914, 919, 927, 931, 932, 943,
947, 951, 955, 959, 974, 975, 981, 988, 994, 1001,
1004, 1011, 1017, 1034, 1041, 1042, 1049, 1050, 1069, 1070,
1073, 1076, 1080, 1091, 1100, 1106, 1109, 1112, 1119, 1120,
1126, 1141, 1149, 1161, 1166, 1172, 1173, 1174, 1175, 1176,
1177, 1183, 1184, 1185, 1186, 1192, 1193, 1194, 1195, 1196,
1202, 1203, 1206, 1209, 1210, 1211, 1212, 1213, 1216, 1217,
1230, 1234, 1239, 1244, 1249, 1253, 1254, 1257, 1263, 1270,
1276, 1283, 1289, 1300, 1314, 1343, 1383, 1408, 1426, 1435,
1438, 1446, 1450, 1454, 1461, 1467, 1472, 1484, 1487, 1497,
1498, 1504, 1505, 1511, 1515, 1521, 1522, 1528, 1532, 1538,
1561, 1566, 1572, 1578, 1585, 1594, 1603, 1618, 1624, 1629,
1633, 1640, 1653, 1654, 1660, 1666, 1669, 1673, 1679, 1682,
1691, 1694, 1695, 1699, 1700, 1706, 1707, 1708, 1709, 1710,
1712, 1711, 1726, 1731, 1735, 1739, 1743, 1747, 1752, 1771,
1777, 1785, 1789, 1795, 1799, 1805, 1809, 1815, 1819, 1828,
1832, 1836, 1840, 1846, 1849, 1857, 1858, 1860, 1861, 1864,
1867, 1870, 1873, 1876, 1879, 1882, 1885, 1888, 1891, 1894,
1897, 1900, 1903, 1909, 1913, 1917, 1921, 1925, 1929, 1949,
1956, 1967, 1968, 1969, 1972, 1973, 1976, 1980, 1990, 1994,
1998, 2002, 2006, 2010, 2014, 2020, 2026, 2034, 2042, 2048,
2055, 2071, 2089, 2093, 2099, 2102, 2105, 2109, 2119, 2123,
2138, 2146, 2147, 2159, 2160, 2163, 2167, 2173, 2177, 2183,
2187
0, 126, 126, 135, 141, 152, 152, 167, 168, 171,
172, 173, 176, 213, 224, 225, 228, 235, 242, 251,
265, 266, 273, 273, 286, 290, 291, 295, 300, 306,
310, 314, 318, 324, 330, 336, 341, 345, 349, 355,
361, 365, 369, 375, 379, 385, 386, 390, 396, 405,
411, 429, 434, 446, 462, 467, 474, 494, 512, 521,
540, 539, 554, 553, 584, 587, 594, 593, 604, 610,
619, 630, 636, 639, 647, 646, 657, 663, 675, 679,
684, 674, 705, 704, 717, 720, 726, 729, 741, 745,
740, 763, 762, 778, 779, 783, 787, 791, 795, 799,
803, 807, 811, 815, 819, 823, 827, 831, 835, 839,
843, 847, 851, 856, 862, 863, 867, 878, 882, 886,
890, 895, 899, 909, 913, 918, 926, 930, 931, 942,
946, 950, 954, 958, 973, 974, 980, 987, 993, 1000,
1003, 1010, 1016, 1033, 1040, 1041, 1048, 1049, 1068, 1069,
1072, 1075, 1079, 1090, 1099, 1105, 1108, 1111, 1118, 1119,
1125, 1140, 1148, 1160, 1165, 1171, 1172, 1173, 1174, 1175,
1176, 1182, 1183, 1184, 1185, 1191, 1192, 1193, 1194, 1195,
1201, 1202, 1205, 1208, 1209, 1210, 1211, 1212, 1215, 1216,
1229, 1233, 1238, 1243, 1248, 1252, 1253, 1256, 1262, 1269,
1275, 1282, 1288, 1299, 1313, 1342, 1382, 1407, 1425, 1434,
1437, 1445, 1449, 1453, 1460, 1466, 1471, 1483, 1486, 1496,
1497, 1503, 1504, 1510, 1514, 1520, 1521, 1527, 1531, 1537,
1560, 1565, 1571, 1577, 1584, 1593, 1602, 1617, 1623, 1628,
1632, 1639, 1652, 1653, 1659, 1665, 1668, 1672, 1678, 1681,
1690, 1693, 1694, 1698, 1699, 1705, 1706, 1707, 1708, 1709,
1711, 1710, 1725, 1730, 1734, 1738, 1742, 1746, 1751, 1770,
1776, 1784, 1788, 1794, 1798, 1804, 1808, 1814, 1818, 1827,
1831, 1835, 1839, 1845, 1848, 1856, 1857, 1859, 1860, 1863,
1866, 1869, 1872, 1875, 1878, 1881, 1884, 1887, 1890, 1893,
1896, 1899, 1902, 1908, 1912, 1916, 1920, 1924, 1928, 1948,
1955, 1966, 1967, 1968, 1971, 1972, 1975, 1979, 1989, 1993,
1997, 2001, 2005, 2009, 2013, 2019, 2025, 2033, 2041, 2047,
2054, 2070, 2088, 2092, 2098, 2101, 2104, 2108, 2118, 2122,
2137, 2145, 2146, 2158, 2159, 2162, 2166, 2172, 2176, 2182,
2186
};
#endif
......@@ -731,16 +714,16 @@ const char *yytname[] =
"'/'", "'%'", "'&'", "NotPackage", "NotParen", "'('", "')'",
"PreferToRightParen", "';'", "'.'", "'$'", "'='", "':'", "'{'", "'}'",
"'!'", "'~'", "'['", "']'", "'?'", "'@'", "','", "$accept", "file",
"package", "loadsys", "$@1", "imports", "import", "import_stmt",
"package", "loadsys", "@1", "imports", "import", "import_stmt",
"import_stmt_list", "import_here", "import_package", "import_safety",
"import_there", "$@2", "xdcl", "common_dcl", "lconst", "vardcl",
"import_there", "@2", "xdcl", "common_dcl", "lconst", "vardcl",
"constdcl", "constdcl1", "typedclname", "typedcl", "simple_stmt", "case",
"compound_stmt", "$@3", "caseblock", "$@4", "caseblock_list",
"loop_body", "$@5", "range_stmt", "for_header", "for_body", "for_stmt",
"$@6", "if_header", "if_stmt", "$@7", "$@8", "$@9", "elseif", "$@10",
"elseif_list", "else", "switch_stmt", "$@11", "$@12", "select_stmt",
"$@13", "expr", "uexpr", "pseudocall", "pexpr_no_paren", "start_complit",
"keyval", "bare_complitexpr", "complitexpr", "pexpr", "expr_or_type",
"compound_stmt", "@3", "caseblock", "@4", "caseblock_list", "loop_body",
"@5", "range_stmt", "for_header", "for_body", "for_stmt", "@6",
"if_header", "if_stmt", "@7", "@8", "@9", "elseif", "@10", "elseif_list",
"else", "switch_stmt", "@11", "@12", "select_stmt", "@13", "expr",
"uexpr", "pseudocall", "pexpr_no_paren", "start_complit", "keyval",
"bare_complitexpr", "complitexpr", "pexpr", "expr_or_type",
"name_or_type", "lbrace", "new_name", "dcl_name", "onew_name", "sym",
"hidden_importsym", "name", "labelname", "dotdotdot", "ntype",
"non_expr_type", "non_recvchantype", "convtype", "comptype",
......@@ -750,7 +733,7 @@ const char *yytname[] =
"vardcl_list", "constdcl_list", "typedcl_list", "structdcl_list",
"interfacedcl_list", "structdcl", "packname", "embed", "interfacedcl",
"indcl", "arg_type", "arg_type_list", "oarg_type_list_ocomma", "stmt",
"non_dcl_stmt", "$@14", "stmt_list", "new_name_list", "dcl_name_list",
"non_dcl_stmt", "@14", "stmt_list", "new_name_list", "dcl_name_list",
"expr_list", "expr_or_type_list", "keyval_list", "braced_keyval_list",
"osemi", "ocomma", "oexpr", "oexpr_list", "osimple_stmt",
"ohidden_funarg_list", "ohidden_structdcl_list",
......@@ -863,8 +846,8 @@ static const yytype_uint8 yyr2[] =
3
};
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE doesn't specify something else to do. Zero
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */
static const yytype_uint16 yydefact[] =
{
......@@ -1053,7 +1036,8 @@ static const yytype_int16 yypgoto[] =
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If YYTABLE_NINF, syntax error. */
number is the opposite. If zero, do what YYDEFACT says.
If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -276
static const yytype_int16 yytable[] =
{
......@@ -1279,12 +1263,6 @@ static const yytype_int16 yytable[] =
189, 190, 191, 192, 193, 194, 195, 196, 197
};
#define yypact_value_is_default(yystate) \
((yystate) == (-552))
#define yytable_value_is_error(yytable_value) \
YYID (0)
static const yytype_int16 yycheck[] =
{
37, 37, 61, 142, 67, 37, 37, 201, 250, 143,
......@@ -1594,18 +1572,9 @@ static const yytype_uint8 yystos[] =
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. However,
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
discussed. */
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
#if defined YYFAIL
/* This is here to suppress warnings from the GCC cpp's
-Wunused-macros. Normally we don't worry about that warning, but
some users do, and we want to make it easy for users to remove
YYFAIL uses, which will produce warnings from Bison 2.5. */
#endif
#define YYRECOVERING() (!!yyerrstatus)
......@@ -1615,6 +1584,7 @@ do \
{ \
yychar = (Token); \
yylval = (Value); \
yytoken = YYTRANSLATE (yychar); \
YYPOPSTACK (1); \
goto yybackup; \
} \
......@@ -1656,10 +1626,19 @@ while (YYID (0))
#endif
/* This macro is provided for backward compatibility. */
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
#endif
......@@ -1763,20 +1742,17 @@ yy_symbol_print (yyoutput, yytype, yyvaluep)
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
#else
static void
yy_stack_print (yybottom, yytop)
yytype_int16 *yybottom;
yytype_int16 *yytop;
yy_stack_print (bottom, top)
yytype_int16 *bottom;
yytype_int16 *top;
#endif
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
{
int yybot = *yybottom;
YYFPRINTF (stderr, " %d", yybot);
}
for (; bottom <= top; ++bottom)
YYFPRINTF (stderr, " %d", *bottom);
YYFPRINTF (stderr, "\n");
}
......@@ -1810,11 +1786,11 @@ yy_reduce_print (yyvsp, yyrule)
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
fprintf (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
);
YYFPRINTF (stderr, "\n");
fprintf (stderr, "\n");
}
}
......@@ -1851,6 +1827,7 @@ int yydebug;
# define YYMAXDEPTH 10000
#endif
#if YYERROR_VERBOSE
......@@ -1953,142 +1930,115 @@ yytnamerr (char *yyres, const char *yystr)
}
# endif
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
about the unexpected token YYTOKEN for the state stack whose top is
YYSSP.
Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
not large enough to hold the message. In that case, also set
*YYMSG_ALLOC to the required number of bytes. Return 2 if the
required number of bytes is too large to store. */
static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
/* Copy into YYRESULT an error message about the unexpected token
YYCHAR while in state YYSTATE. Return the number of bytes copied,
including the terminating null byte. If YYRESULT is null, do not
copy anything; just return the number of bytes that would be
copied. As a special case, return 0 if an ordinary "syntax error"
message will do. Return YYSIZE_MAXIMUM if overflow occurs during
size calculation. */
static YYSIZE_T
yysyntax_error (char *yyresult, int yystate, int yychar)
{
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = 0;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int yycount = 0;
/* There are many possibilities here to consider:
- Assume YYFAIL is not used. It's too flawed to consider. See
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
for details. YYERROR is fine as it does not invoke this
function.
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yychar) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yytoken != YYEMPTY)
{
int yyn = yypact[*yyssp];
yyarg[yycount++] = yytname[yytoken];
if (!yypact_value_is_default (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1;
}
}
}
int yyn = yypact[yystate];
switch (yycount)
{
# define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
}
if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
return 0;
else
{
int yytype = YYTRANSLATE (yychar);
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
int yysize_overflow = 0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
int yyx;
# if 0
/* This is so xgettext sees the translatable formats that are
constructed on the fly. */
YY_("syntax error, unexpected %s");
YY_("syntax error, unexpected %s, expecting %s");
YY_("syntax error, unexpected %s, expecting %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
# endif
char *yyfmt;
char const *yyf;
static char const yyunexpected[] = "syntax error, unexpected %s";
static char const yyexpecting[] = ", expecting %s";
static char const yyor[] = " or %s";
char yyformat[sizeof yyunexpected
+ sizeof yyexpecting - 1
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
* (sizeof yyor - 1))];
char const *yyprefix = yyexpecting;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yycount = 1;
yyarg[0] = yytname[yytype];
yyfmt = yystpcpy (yyformat, yyunexpected);
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
yyformat[sizeof yyunexpected - 1] = '\0';
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
yysize_overflow |= (yysize1 < yysize);
yysize = yysize1;
yyfmt = yystpcpy (yyfmt, yyprefix);
yyprefix = yyor;
}
yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1;
yyf = YY_(yyformat);
yysize1 = yysize + yystrlen (yyf);
yysize_overflow |= (yysize1 < yysize);
yysize = yysize1;
if (*yymsg_alloc < yysize)
{
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
return 1;
}
if (yysize_overflow)
return YYSIZE_MAXIMUM;
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
{
char *yyp = *yymsg;
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
return 0;
if (yyresult)
{
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
char *yyp = yyresult;
int yyi = 0;
while ((*yyp = *yyf) != '\0')
{
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyf += 2;
}
else
{
yyp++;
yyf++;
}
}
}
return yysize;
}
}
#endif /* YYERROR_VERBOSE */
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
......@@ -2120,9 +2070,10 @@ yydestruct (yymsg, yytype, yyvaluep)
break;
}
}
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
......@@ -2138,16 +2089,18 @@ int yyparse ();
#endif /* ! YYPARSE_PARAM */
/* The lookahead symbol. */
/* The look-ahead symbol. */
int yychar, yystate;
/* The semantic value of the lookahead symbol. */
/* The semantic value of the look-ahead symbol. */
YYSTYPE yylval;
/* Number of syntax errors so far. */
int yynerrs;
/*----------.
| yyparse. |
`----------*/
......@@ -2174,36 +2127,13 @@ yyparse ()
#endif
#endif
{
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
`yyss': related to states.
`yyvs': related to semantic values.
Refer to the stacks thru separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* Look-ahead token as an internal (translated) token number. */
int yytoken = 0;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
......@@ -2211,28 +2141,51 @@ yyparse ()
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
/* Three stacks and their tools:
`yyss': related to states,
`yyvs': related to semantic values,
`yyls': related to locations.
Refer to the stacks thru separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss = yyssa;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs = yyvsa;
YYSTYPE *yyvsp;
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
YYSIZE_T yystacksize = YYINITDEPTH;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
......@@ -2262,6 +2215,7 @@ yyparse ()
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
......@@ -2269,6 +2223,7 @@ yyparse ()
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
yyss = yyss1;
......@@ -2291,8 +2246,9 @@ yyparse ()
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
YYSTACK_RELOCATE (yyss);
YYSTACK_RELOCATE (yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
......@@ -2303,6 +2259,7 @@ yyparse ()
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
......@@ -2312,9 +2269,6 @@ yyparse ()
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
......@@ -2323,16 +2277,16 @@ yyparse ()
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
look-ahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
/* First try to decide what to do without reference to look-ahead token. */
yyn = yypact[yystate];
if (yypact_value_is_default (yyn))
if (yyn == YYPACT_NINF)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* Not known => get a look-ahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
......@@ -2358,22 +2312,26 @@ yybackup:
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yytable_value_is_error (yyn))
goto yyerrlab;
if (yyn == 0 || yyn == YYTABLE_NINF)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
if (yyn == YYFINAL)
YYACCEPT;
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
/* Shift the look-ahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token. */
yychar = YYEMPTY;
/* Discard the shifted token unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
......@@ -2413,8 +2371,6 @@ yyreduce:
switch (yyn)
{
case 2:
/* Line 1806 of yacc.c */
#line 130 "go.y"
{
xtop = concat(xtop, (yyvsp[(4) - (4)].list));
......@@ -2422,8 +2378,6 @@ yyreduce:
break;
case 3:
/* Line 1806 of yacc.c */
#line 136 "go.y"
{
prevlineno = lineno;
......@@ -2433,18 +2387,14 @@ yyreduce:
break;
case 4:
/* Line 1806 of yacc.c */
#line 143 "go.y"
#line 142 "go.y"
{
mkpackage((yyvsp[(2) - (3)].sym)->name);
}
break;
case 5:
/* Line 1806 of yacc.c */
#line 153 "go.y"
#line 152 "go.y"
{
importpkg = runtimepkg;
......@@ -2457,18 +2407,14 @@ yyreduce:
break;
case 6:
/* Line 1806 of yacc.c */
#line 164 "go.y"
#line 163 "go.y"
{
importpkg = nil;
}
break;
case 12:
/* Line 1806 of yacc.c */
#line 178 "go.y"
#line 177 "go.y"
{
Pkg *ipkg;
Sym *my;
......@@ -2508,9 +2454,7 @@ yyreduce:
break;
case 13:
/* Line 1806 of yacc.c */
#line 215 "go.y"
#line 214 "go.y"
{
// When an invalid import path is passed to importfile,
// it calls yyerror and then sets up a fake import with
......@@ -2522,9 +2466,7 @@ yyreduce:
break;
case 16:
/* Line 1806 of yacc.c */
#line 230 "go.y"
#line 229 "go.y"
{
// import with original name
(yyval.i) = parserline();
......@@ -2534,9 +2476,7 @@ yyreduce:
break;
case 17:
/* Line 1806 of yacc.c */
#line 237 "go.y"
#line 236 "go.y"
{
// import with given name
(yyval.i) = parserline();
......@@ -2546,9 +2486,7 @@ yyreduce:
break;
case 18:
/* Line 1806 of yacc.c */
#line 244 "go.y"
#line 243 "go.y"
{
// import into my name space
(yyval.i) = parserline();
......@@ -2558,9 +2496,7 @@ yyreduce:
break;
case 19:
/* Line 1806 of yacc.c */
#line 253 "go.y"
#line 252 "go.y"
{
if(importpkg->name == nil) {
importpkg->name = (yyvsp[(2) - (4)].sym)->name;
......@@ -2576,9 +2512,7 @@ yyreduce:
break;
case 21:
/* Line 1806 of yacc.c */
#line 268 "go.y"
#line 267 "go.y"
{
if(strcmp((yyvsp[(1) - (1)].sym)->name, "safe") == 0)
curio.importsafe = 1;
......@@ -2586,18 +2520,14 @@ yyreduce:
break;
case 22:
/* Line 1806 of yacc.c */
#line 274 "go.y"
#line 273 "go.y"
{
defercheckwidth();
}
break;
case 23:
/* Line 1806 of yacc.c */
#line 278 "go.y"
#line 277 "go.y"
{
resumecheckwidth();
unimportfile();
......@@ -2605,9 +2535,7 @@ yyreduce:
break;
case 24:
/* Line 1806 of yacc.c */
#line 287 "go.y"
#line 286 "go.y"
{
yyerror("empty top-level declaration");
(yyval.list) = nil;
......@@ -2615,18 +2543,14 @@ yyreduce:
break;
case 26:
/* Line 1806 of yacc.c */
#line 293 "go.y"
#line 292 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 27:
/* Line 1806 of yacc.c */
#line 297 "go.y"
#line 296 "go.y"
{
yyerror("non-declaration statement outside function body");
(yyval.list) = nil;
......@@ -2634,45 +2558,35 @@ yyreduce:
break;
case 28:
/* Line 1806 of yacc.c */
#line 302 "go.y"
#line 301 "go.y"
{
(yyval.list) = nil;
}
break;
case 29:
/* Line 1806 of yacc.c */
#line 308 "go.y"
#line 307 "go.y"
{
(yyval.list) = (yyvsp[(2) - (2)].list);
}
break;
case 30:
/* Line 1806 of yacc.c */
#line 312 "go.y"
#line 311 "go.y"
{
(yyval.list) = (yyvsp[(3) - (5)].list);
}
break;
case 31:
/* Line 1806 of yacc.c */
#line 316 "go.y"
#line 315 "go.y"
{
(yyval.list) = nil;
}
break;
case 32:
/* Line 1806 of yacc.c */
#line 320 "go.y"
#line 319 "go.y"
{
(yyval.list) = (yyvsp[(2) - (2)].list);
iota = -100000;
......@@ -2681,9 +2595,7 @@ yyreduce:
break;
case 33:
/* Line 1806 of yacc.c */
#line 326 "go.y"
#line 325 "go.y"
{
(yyval.list) = (yyvsp[(3) - (5)].list);
iota = -100000;
......@@ -2692,9 +2604,7 @@ yyreduce:
break;
case 34:
/* Line 1806 of yacc.c */
#line 332 "go.y"
#line 331 "go.y"
{
(yyval.list) = concat((yyvsp[(3) - (7)].list), (yyvsp[(5) - (7)].list));
iota = -100000;
......@@ -2703,9 +2613,7 @@ yyreduce:
break;
case 35:
/* Line 1806 of yacc.c */
#line 338 "go.y"
#line 337 "go.y"
{
(yyval.list) = nil;
iota = -100000;
......@@ -2713,108 +2621,84 @@ yyreduce:
break;
case 36:
/* Line 1806 of yacc.c */
#line 343 "go.y"
#line 342 "go.y"
{
(yyval.list) = list1((yyvsp[(2) - (2)].node));
}
break;
case 37:
/* Line 1806 of yacc.c */
#line 347 "go.y"
#line 346 "go.y"
{
(yyval.list) = (yyvsp[(3) - (5)].list);
}
break;
case 38:
/* Line 1806 of yacc.c */
#line 351 "go.y"
#line 350 "go.y"
{
(yyval.list) = nil;
}
break;
case 39:
/* Line 1806 of yacc.c */
#line 357 "go.y"
#line 356 "go.y"
{
iota = 0;
}
break;
case 40:
/* Line 1806 of yacc.c */
#line 363 "go.y"
#line 362 "go.y"
{
(yyval.list) = variter((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].node), nil);
}
break;
case 41:
/* Line 1806 of yacc.c */
#line 367 "go.y"
#line 366 "go.y"
{
(yyval.list) = variter((yyvsp[(1) - (4)].list), (yyvsp[(2) - (4)].node), (yyvsp[(4) - (4)].list));
}
break;
case 42:
/* Line 1806 of yacc.c */
#line 371 "go.y"
#line 370 "go.y"
{
(yyval.list) = variter((yyvsp[(1) - (3)].list), nil, (yyvsp[(3) - (3)].list));
}
break;
case 43:
/* Line 1806 of yacc.c */
#line 377 "go.y"
#line 376 "go.y"
{
(yyval.list) = constiter((yyvsp[(1) - (4)].list), (yyvsp[(2) - (4)].node), (yyvsp[(4) - (4)].list));
}
break;
case 44:
/* Line 1806 of yacc.c */
#line 381 "go.y"
#line 380 "go.y"
{
(yyval.list) = constiter((yyvsp[(1) - (3)].list), N, (yyvsp[(3) - (3)].list));
}
break;
case 46:
/* Line 1806 of yacc.c */
#line 388 "go.y"
#line 387 "go.y"
{
(yyval.list) = constiter((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].node), nil);
}
break;
case 47:
/* Line 1806 of yacc.c */
#line 392 "go.y"
#line 391 "go.y"
{
(yyval.list) = constiter((yyvsp[(1) - (1)].list), N, nil);
}
break;
case 48:
/* Line 1806 of yacc.c */
#line 398 "go.y"
#line 397 "go.y"
{
// different from dclname because the name
// becomes visible right here, not at the end
......@@ -2824,18 +2708,14 @@ yyreduce:
break;
case 49:
/* Line 1806 of yacc.c */
#line 407 "go.y"
#line 406 "go.y"
{
(yyval.node) = typedcl1((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].node), 1);
}
break;
case 50:
/* Line 1806 of yacc.c */
#line 413 "go.y"
#line 412 "go.y"
{
(yyval.node) = (yyvsp[(1) - (1)].node);
......@@ -2856,9 +2736,7 @@ yyreduce:
break;
case 51:
/* Line 1806 of yacc.c */
#line 431 "go.y"
#line 430 "go.y"
{
(yyval.node) = nod(OASOP, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
(yyval.node)->etype = (yyvsp[(2) - (3)].i); // rathole to pass opcode
......@@ -2866,9 +2744,7 @@ yyreduce:
break;
case 52:
/* Line 1806 of yacc.c */
#line 436 "go.y"
#line 435 "go.y"
{
if((yyvsp[(1) - (3)].list)->next == nil && (yyvsp[(3) - (3)].list)->next == nil) {
// simple
......@@ -2883,9 +2759,7 @@ yyreduce:
break;
case 53:
/* Line 1806 of yacc.c */
#line 448 "go.y"
#line 447 "go.y"
{
if((yyvsp[(3) - (3)].list)->n->op == OTYPESW) {
(yyval.node) = nod(OTYPESW, N, (yyvsp[(3) - (3)].list)->n->right);
......@@ -2904,9 +2778,7 @@ yyreduce:
break;
case 54:
/* Line 1806 of yacc.c */
#line 464 "go.y"
#line 463 "go.y"
{
(yyval.node) = nod(OASOP, (yyvsp[(1) - (2)].node), nodintconst(1));
(yyval.node)->etype = OADD;
......@@ -2914,9 +2786,7 @@ yyreduce:
break;
case 55:
/* Line 1806 of yacc.c */
#line 469 "go.y"
#line 468 "go.y"
{
(yyval.node) = nod(OASOP, (yyvsp[(1) - (2)].node), nodintconst(1));
(yyval.node)->etype = OSUB;
......@@ -2924,9 +2794,7 @@ yyreduce:
break;
case 56:
/* Line 1806 of yacc.c */
#line 476 "go.y"
#line 475 "go.y"
{
Node *n, *nn;
......@@ -2949,9 +2817,7 @@ yyreduce:
break;
case 57:
/* Line 1806 of yacc.c */
#line 496 "go.y"
#line 495 "go.y"
{
Node *n;
......@@ -2972,9 +2838,7 @@ yyreduce:
break;
case 58:
/* Line 1806 of yacc.c */
#line 514 "go.y"
#line 513 "go.y"
{
// will be converted to OCASE
// right will point to next case
......@@ -2986,9 +2850,7 @@ yyreduce:
break;
case 59:
/* Line 1806 of yacc.c */
#line 523 "go.y"
#line 522 "go.y"
{
Node *n, *nn;
......@@ -3007,18 +2869,14 @@ yyreduce:
break;
case 60:
/* Line 1806 of yacc.c */
#line 541 "go.y"
#line 540 "go.y"
{
markdcl();
}
break;
case 61:
/* Line 1806 of yacc.c */
#line 545 "go.y"
#line 544 "go.y"
{
if((yyvsp[(3) - (4)].list) == nil)
(yyval.node) = nod(OEMPTY, N, N);
......@@ -3029,9 +2887,7 @@ yyreduce:
break;
case 62:
/* Line 1806 of yacc.c */
#line 555 "go.y"
#line 554 "go.y"
{
// If the last token read by the lexer was consumed
// as part of the case, clear it (parser has cleared yychar).
......@@ -3044,9 +2900,7 @@ yyreduce:
break;
case 63:
/* Line 1806 of yacc.c */
#line 565 "go.y"
#line 564 "go.y"
{
int last;
......@@ -3068,36 +2922,28 @@ yyreduce:
break;
case 64:
/* Line 1806 of yacc.c */
#line 585 "go.y"
#line 584 "go.y"
{
(yyval.list) = nil;
}
break;
case 65:
/* Line 1806 of yacc.c */
#line 589 "go.y"
#line 588 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].node));
}
break;
case 66:
/* Line 1806 of yacc.c */
#line 595 "go.y"
#line 594 "go.y"
{
markdcl();
}
break;
case 67:
/* Line 1806 of yacc.c */
#line 599 "go.y"
#line 598 "go.y"
{
(yyval.list) = (yyvsp[(3) - (4)].list);
popdcl();
......@@ -3105,9 +2951,7 @@ yyreduce:
break;
case 68:
/* Line 1806 of yacc.c */
#line 606 "go.y"
#line 605 "go.y"
{
(yyval.node) = nod(ORANGE, N, (yyvsp[(4) - (4)].node));
(yyval.node)->list = (yyvsp[(1) - (4)].list);
......@@ -3116,9 +2960,7 @@ yyreduce:
break;
case 69:
/* Line 1806 of yacc.c */
#line 612 "go.y"
#line 611 "go.y"
{
(yyval.node) = nod(ORANGE, N, (yyvsp[(4) - (4)].node));
(yyval.node)->list = (yyvsp[(1) - (4)].list);
......@@ -3128,9 +2970,7 @@ yyreduce:
break;
case 70:
/* Line 1806 of yacc.c */
#line 621 "go.y"
#line 620 "go.y"
{
// init ; test ; incr
if((yyvsp[(5) - (5)].node) != N && (yyvsp[(5) - (5)].node)->colas != 0)
......@@ -3144,9 +2984,7 @@ yyreduce:
break;
case 71:
/* Line 1806 of yacc.c */
#line 632 "go.y"
#line 631 "go.y"
{
// normal test
(yyval.node) = nod(OFOR, N, N);
......@@ -3155,9 +2993,7 @@ yyreduce:
break;
case 73:
/* Line 1806 of yacc.c */
#line 641 "go.y"
#line 640 "go.y"
{
(yyval.node) = (yyvsp[(1) - (2)].node);
(yyval.node)->nbody = concat((yyval.node)->nbody, (yyvsp[(2) - (2)].list));
......@@ -3165,18 +3001,14 @@ yyreduce:
break;
case 74:
/* Line 1806 of yacc.c */
#line 648 "go.y"
#line 647 "go.y"
{
markdcl();
}
break;
case 75:
/* Line 1806 of yacc.c */
#line 652 "go.y"
#line 651 "go.y"
{
(yyval.node) = (yyvsp[(3) - (3)].node);
popdcl();
......@@ -3184,9 +3016,7 @@ yyreduce:
break;
case 76:
/* Line 1806 of yacc.c */
#line 659 "go.y"
#line 658 "go.y"
{
// test
(yyval.node) = nod(OIF, N, N);
......@@ -3195,9 +3025,7 @@ yyreduce:
break;
case 77:
/* Line 1806 of yacc.c */
#line 665 "go.y"
#line 664 "go.y"
{
// init ; test
(yyval.node) = nod(OIF, N, N);
......@@ -3208,18 +3036,14 @@ yyreduce:
break;
case 78:
/* Line 1806 of yacc.c */
#line 676 "go.y"
#line 675 "go.y"
{
markdcl();
}
break;
case 79:
/* Line 1806 of yacc.c */
#line 680 "go.y"
#line 679 "go.y"
{
if((yyvsp[(3) - (3)].node)->ntest == N)
yyerror("missing condition in if statement");
......@@ -3227,18 +3051,14 @@ yyreduce:
break;
case 80:
/* Line 1806 of yacc.c */
#line 685 "go.y"
#line 684 "go.y"
{
(yyvsp[(3) - (5)].node)->nbody = (yyvsp[(5) - (5)].list);
}
break;
case 81:
/* Line 1806 of yacc.c */
#line 689 "go.y"
#line 688 "go.y"
{
Node *n;
NodeList *nn;
......@@ -3256,18 +3076,14 @@ yyreduce:
break;
case 82:
/* Line 1806 of yacc.c */
#line 706 "go.y"
#line 705 "go.y"
{
markdcl();
}
break;
case 83:
/* Line 1806 of yacc.c */
#line 710 "go.y"
#line 709 "go.y"
{
if((yyvsp[(4) - (5)].node)->ntest == N)
yyerror("missing condition in if statement");
......@@ -3277,36 +3093,28 @@ yyreduce:
break;
case 84:
/* Line 1806 of yacc.c */
#line 718 "go.y"
#line 717 "go.y"
{
(yyval.list) = nil;
}
break;
case 85:
/* Line 1806 of yacc.c */
#line 722 "go.y"
#line 721 "go.y"
{
(yyval.list) = concat((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list));
}
break;
case 86:
/* Line 1806 of yacc.c */
#line 727 "go.y"
#line 726 "go.y"
{
(yyval.list) = nil;
}
break;
case 87:
/* Line 1806 of yacc.c */
#line 731 "go.y"
#line 730 "go.y"
{
NodeList *node;
......@@ -3318,18 +3126,14 @@ yyreduce:
break;
case 88:
/* Line 1806 of yacc.c */
#line 742 "go.y"
#line 741 "go.y"
{
markdcl();
}
break;
case 89:
/* Line 1806 of yacc.c */
#line 746 "go.y"
#line 745 "go.y"
{
Node *n;
n = (yyvsp[(3) - (3)].node)->ntest;
......@@ -3340,9 +3144,7 @@ yyreduce:
break;
case 90:
/* Line 1806 of yacc.c */
#line 754 "go.y"
#line 753 "go.y"
{
(yyval.node) = (yyvsp[(3) - (7)].node);
(yyval.node)->op = OSWITCH;
......@@ -3353,18 +3155,14 @@ yyreduce:
break;
case 91:
/* Line 1806 of yacc.c */
#line 764 "go.y"
#line 763 "go.y"
{
typesw = nod(OXXX, typesw, N);
}
break;
case 92:
/* Line 1806 of yacc.c */
#line 768 "go.y"
#line 767 "go.y"
{
(yyval.node) = nod(OSELECT, N, N);
(yyval.node)->lineno = typesw->lineno;
......@@ -3374,198 +3172,154 @@ yyreduce:
break;
case 94:
/* Line 1806 of yacc.c */
#line 781 "go.y"
#line 780 "go.y"
{
(yyval.node) = nod(OOROR, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 95:
/* Line 1806 of yacc.c */
#line 785 "go.y"
#line 784 "go.y"
{
(yyval.node) = nod(OANDAND, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 96:
/* Line 1806 of yacc.c */
#line 789 "go.y"
#line 788 "go.y"
{
(yyval.node) = nod(OEQ, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 97:
/* Line 1806 of yacc.c */
#line 793 "go.y"
#line 792 "go.y"
{
(yyval.node) = nod(ONE, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 98:
/* Line 1806 of yacc.c */
#line 797 "go.y"
#line 796 "go.y"
{
(yyval.node) = nod(OLT, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 99:
/* Line 1806 of yacc.c */
#line 801 "go.y"
#line 800 "go.y"
{
(yyval.node) = nod(OLE, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 100:
/* Line 1806 of yacc.c */
#line 805 "go.y"
#line 804 "go.y"
{
(yyval.node) = nod(OGE, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 101:
/* Line 1806 of yacc.c */
#line 809 "go.y"
#line 808 "go.y"
{
(yyval.node) = nod(OGT, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 102:
/* Line 1806 of yacc.c */
#line 813 "go.y"
#line 812 "go.y"
{
(yyval.node) = nod(OADD, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 103:
/* Line 1806 of yacc.c */
#line 817 "go.y"
#line 816 "go.y"
{
(yyval.node) = nod(OSUB, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 104:
/* Line 1806 of yacc.c */
#line 821 "go.y"
#line 820 "go.y"
{
(yyval.node) = nod(OOR, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 105:
/* Line 1806 of yacc.c */
#line 825 "go.y"
#line 824 "go.y"
{
(yyval.node) = nod(OXOR, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 106:
/* Line 1806 of yacc.c */
#line 829 "go.y"
#line 828 "go.y"
{
(yyval.node) = nod(OMUL, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 107:
/* Line 1806 of yacc.c */
#line 833 "go.y"
#line 832 "go.y"
{
(yyval.node) = nod(ODIV, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 108:
/* Line 1806 of yacc.c */
#line 837 "go.y"
#line 836 "go.y"
{
(yyval.node) = nod(OMOD, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 109:
/* Line 1806 of yacc.c */
#line 841 "go.y"
#line 840 "go.y"
{
(yyval.node) = nod(OAND, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 110:
/* Line 1806 of yacc.c */
#line 845 "go.y"
#line 844 "go.y"
{
(yyval.node) = nod(OANDNOT, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 111:
/* Line 1806 of yacc.c */
#line 849 "go.y"
#line 848 "go.y"
{
(yyval.node) = nod(OLSH, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 112:
/* Line 1806 of yacc.c */
#line 853 "go.y"
#line 852 "go.y"
{
(yyval.node) = nod(ORSH, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 113:
/* Line 1806 of yacc.c */
#line 858 "go.y"
#line 857 "go.y"
{
(yyval.node) = nod(OSEND, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 115:
/* Line 1806 of yacc.c */
#line 865 "go.y"
#line 864 "go.y"
{
(yyval.node) = nod(OIND, (yyvsp[(2) - (2)].node), N);
}
break;
case 116:
/* Line 1806 of yacc.c */
#line 869 "go.y"
#line 868 "go.y"
{
if((yyvsp[(2) - (2)].node)->op == OCOMPLIT) {
// Special case for &T{...}: turn into (*T){...}.
......@@ -3579,36 +3333,28 @@ yyreduce:
break;
case 117:
/* Line 1806 of yacc.c */
#line 880 "go.y"
#line 879 "go.y"
{
(yyval.node) = nod(OPLUS, (yyvsp[(2) - (2)].node), N);
}
break;
case 118:
/* Line 1806 of yacc.c */
#line 884 "go.y"
#line 883 "go.y"
{
(yyval.node) = nod(OMINUS, (yyvsp[(2) - (2)].node), N);
}
break;
case 119:
/* Line 1806 of yacc.c */
#line 888 "go.y"
#line 887 "go.y"
{
(yyval.node) = nod(ONOT, (yyvsp[(2) - (2)].node), N);
}
break;
case 120:
/* Line 1806 of yacc.c */
#line 892 "go.y"
#line 891 "go.y"
{
yyerror("the bitwise complement operator is ^");
(yyval.node) = nod(OCOM, (yyvsp[(2) - (2)].node), N);
......@@ -3616,36 +3362,28 @@ yyreduce:
break;
case 121:
/* Line 1806 of yacc.c */
#line 897 "go.y"
#line 896 "go.y"
{
(yyval.node) = nod(OCOM, (yyvsp[(2) - (2)].node), N);
}
break;
case 122:
/* Line 1806 of yacc.c */
#line 901 "go.y"
#line 900 "go.y"
{
(yyval.node) = nod(ORECV, (yyvsp[(2) - (2)].node), N);
}
break;
case 123:
/* Line 1806 of yacc.c */
#line 911 "go.y"
#line 910 "go.y"
{
(yyval.node) = nod(OCALL, (yyvsp[(1) - (3)].node), N);
}
break;
case 124:
/* Line 1806 of yacc.c */
#line 915 "go.y"
#line 914 "go.y"
{
(yyval.node) = nod(OCALL, (yyvsp[(1) - (5)].node), N);
(yyval.node)->list = (yyvsp[(3) - (5)].list);
......@@ -3653,9 +3391,7 @@ yyreduce:
break;
case 125:
/* Line 1806 of yacc.c */
#line 920 "go.y"
#line 919 "go.y"
{
(yyval.node) = nod(OCALL, (yyvsp[(1) - (6)].node), N);
(yyval.node)->list = (yyvsp[(3) - (6)].list);
......@@ -3664,18 +3400,14 @@ yyreduce:
break;
case 126:
/* Line 1806 of yacc.c */
#line 928 "go.y"
#line 927 "go.y"
{
(yyval.node) = nodlit((yyvsp[(1) - (1)].val));
}
break;
case 128:
/* Line 1806 of yacc.c */
#line 933 "go.y"
#line 932 "go.y"
{
if((yyvsp[(1) - (3)].node)->op == OPACK) {
Sym *s;
......@@ -3689,45 +3421,35 @@ yyreduce:
break;
case 129:
/* Line 1806 of yacc.c */
#line 944 "go.y"
#line 943 "go.y"
{
(yyval.node) = nod(ODOTTYPE, (yyvsp[(1) - (5)].node), (yyvsp[(4) - (5)].node));
}
break;
case 130:
/* Line 1806 of yacc.c */
#line 948 "go.y"
#line 947 "go.y"
{
(yyval.node) = nod(OTYPESW, N, (yyvsp[(1) - (5)].node));
}
break;
case 131:
/* Line 1806 of yacc.c */
#line 952 "go.y"
#line 951 "go.y"
{
(yyval.node) = nod(OINDEX, (yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].node));
}
break;
case 132:
/* Line 1806 of yacc.c */
#line 956 "go.y"
#line 955 "go.y"
{
(yyval.node) = nod(OSLICE, (yyvsp[(1) - (6)].node), nod(OKEY, (yyvsp[(3) - (6)].node), (yyvsp[(5) - (6)].node)));
}
break;
case 133:
/* Line 1806 of yacc.c */
#line 960 "go.y"
#line 959 "go.y"
{
// Make sure we don't accidentally release this experimental feature.
// http://golang.org/s/go12slice.
......@@ -3745,9 +3467,7 @@ yyreduce:
break;
case 135:
/* Line 1806 of yacc.c */
#line 976 "go.y"
#line 975 "go.y"
{
// conversion
(yyval.node) = nod(OCALL, (yyvsp[(1) - (5)].node), N);
......@@ -3756,9 +3476,7 @@ yyreduce:
break;
case 136:
/* Line 1806 of yacc.c */
#line 982 "go.y"
#line 981 "go.y"
{
(yyval.node) = (yyvsp[(3) - (5)].node);
(yyval.node)->right = (yyvsp[(1) - (5)].node);
......@@ -3768,9 +3486,7 @@ yyreduce:
break;
case 137:
/* Line 1806 of yacc.c */
#line 989 "go.y"
#line 988 "go.y"
{
(yyval.node) = (yyvsp[(3) - (5)].node);
(yyval.node)->right = (yyvsp[(1) - (5)].node);
......@@ -3779,9 +3495,7 @@ yyreduce:
break;
case 138:
/* Line 1806 of yacc.c */
#line 995 "go.y"
#line 994 "go.y"
{
yyerror("cannot parenthesize type in composite literal");
(yyval.node) = (yyvsp[(5) - (7)].node);
......@@ -3791,9 +3505,7 @@ yyreduce:
break;
case 140:
/* Line 1806 of yacc.c */
#line 1004 "go.y"
#line 1003 "go.y"
{
// composite expression.
// make node early so we get the right line number.
......@@ -3802,18 +3514,14 @@ yyreduce:
break;
case 141:
/* Line 1806 of yacc.c */
#line 1012 "go.y"
#line 1011 "go.y"
{
(yyval.node) = nod(OKEY, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
}
break;
case 142:
/* Line 1806 of yacc.c */
#line 1018 "go.y"
#line 1017 "go.y"
{
// These nodes do not carry line numbers.
// Since a composite literal commonly spans several lines,
......@@ -3833,9 +3541,7 @@ yyreduce:
break;
case 143:
/* Line 1806 of yacc.c */
#line 1035 "go.y"
#line 1034 "go.y"
{
(yyval.node) = (yyvsp[(2) - (4)].node);
(yyval.node)->list = (yyvsp[(3) - (4)].list);
......@@ -3843,9 +3549,7 @@ yyreduce:
break;
case 145:
/* Line 1806 of yacc.c */
#line 1043 "go.y"
#line 1042 "go.y"
{
(yyval.node) = (yyvsp[(2) - (4)].node);
(yyval.node)->list = (yyvsp[(3) - (4)].list);
......@@ -3853,9 +3557,7 @@ yyreduce:
break;
case 147:
/* Line 1806 of yacc.c */
#line 1051 "go.y"
#line 1050 "go.y"
{
(yyval.node) = (yyvsp[(2) - (3)].node);
......@@ -3875,27 +3577,21 @@ yyreduce:
break;
case 151:
/* Line 1806 of yacc.c */
#line 1077 "go.y"
#line 1076 "go.y"
{
(yyval.i) = LBODY;
}
break;
case 152:
/* Line 1806 of yacc.c */
#line 1081 "go.y"
#line 1080 "go.y"
{
(yyval.i) = '{';
}
break;
case 153:
/* Line 1806 of yacc.c */
#line 1092 "go.y"
#line 1091 "go.y"
{
if((yyvsp[(1) - (1)].sym) == S)
(yyval.node) = N;
......@@ -3905,27 +3601,21 @@ yyreduce:
break;
case 154:
/* Line 1806 of yacc.c */
#line 1101 "go.y"
#line 1100 "go.y"
{
(yyval.node) = dclname((yyvsp[(1) - (1)].sym));
}
break;
case 155:
/* Line 1806 of yacc.c */
#line 1106 "go.y"
#line 1105 "go.y"
{
(yyval.node) = N;
}
break;
case 157:
/* Line 1806 of yacc.c */
#line 1113 "go.y"
#line 1112 "go.y"
{
(yyval.sym) = (yyvsp[(1) - (1)].sym);
// during imports, unqualified non-exported identifiers are from builtinpkg
......@@ -3935,18 +3625,14 @@ yyreduce:
break;
case 159:
/* Line 1806 of yacc.c */
#line 1121 "go.y"
#line 1120 "go.y"
{
(yyval.sym) = S;
}
break;
case 160:
/* Line 1806 of yacc.c */
#line 1127 "go.y"
#line 1126 "go.y"
{
Pkg *p;
......@@ -3962,9 +3648,7 @@ yyreduce:
break;
case 161:
/* Line 1806 of yacc.c */
#line 1142 "go.y"
#line 1141 "go.y"
{
(yyval.node) = oldname((yyvsp[(1) - (1)].sym));
if((yyval.node)->pack != N)
......@@ -3973,9 +3657,7 @@ yyreduce:
break;
case 163:
/* Line 1806 of yacc.c */
#line 1162 "go.y"
#line 1161 "go.y"
{
yyerror("final argument in variadic function missing type");
(yyval.node) = nod(ODDD, typenod(typ(TINTER)), N);
......@@ -3983,45 +3665,35 @@ yyreduce:
break;
case 164:
/* Line 1806 of yacc.c */
#line 1167 "go.y"
#line 1166 "go.y"
{
(yyval.node) = nod(ODDD, (yyvsp[(2) - (2)].node), N);
}
break;
case 170:
/* Line 1806 of yacc.c */
#line 1178 "go.y"
#line 1177 "go.y"
{
(yyval.node) = nod(OTPAREN, (yyvsp[(2) - (3)].node), N);
}
break;
case 174:
/* Line 1806 of yacc.c */
#line 1187 "go.y"
#line 1186 "go.y"
{
(yyval.node) = nod(OIND, (yyvsp[(2) - (2)].node), N);
}
break;
case 179:
/* Line 1806 of yacc.c */
#line 1197 "go.y"
#line 1196 "go.y"
{
(yyval.node) = nod(OTPAREN, (yyvsp[(2) - (3)].node), N);
}
break;
case 189:
/* Line 1806 of yacc.c */
#line 1218 "go.y"
#line 1217 "go.y"
{
if((yyvsp[(1) - (3)].node)->op == OPACK) {
Sym *s;
......@@ -4035,18 +3707,14 @@ yyreduce:
break;
case 190:
/* Line 1806 of yacc.c */
#line 1231 "go.y"
#line 1230 "go.y"
{
(yyval.node) = nod(OTARRAY, (yyvsp[(2) - (4)].node), (yyvsp[(4) - (4)].node));
}
break;
case 191:
/* Line 1806 of yacc.c */
#line 1235 "go.y"
#line 1234 "go.y"
{
// array literal of nelem
(yyval.node) = nod(OTARRAY, nod(ODDD, N, N), (yyvsp[(4) - (4)].node));
......@@ -4054,9 +3722,7 @@ yyreduce:
break;
case 192:
/* Line 1806 of yacc.c */
#line 1240 "go.y"
#line 1239 "go.y"
{
(yyval.node) = nod(OTCHAN, (yyvsp[(2) - (2)].node), N);
(yyval.node)->etype = Cboth;
......@@ -4064,9 +3730,7 @@ yyreduce:
break;
case 193:
/* Line 1806 of yacc.c */
#line 1245 "go.y"
#line 1244 "go.y"
{
(yyval.node) = nod(OTCHAN, (yyvsp[(3) - (3)].node), N);
(yyval.node)->etype = Csend;
......@@ -4074,27 +3738,21 @@ yyreduce:
break;
case 194:
/* Line 1806 of yacc.c */
#line 1250 "go.y"
#line 1249 "go.y"
{
(yyval.node) = nod(OTMAP, (yyvsp[(3) - (5)].node), (yyvsp[(5) - (5)].node));
}
break;
case 197:
/* Line 1806 of yacc.c */
#line 1258 "go.y"
#line 1257 "go.y"
{
(yyval.node) = nod(OIND, (yyvsp[(2) - (2)].node), N);
}
break;
case 198:
/* Line 1806 of yacc.c */
#line 1264 "go.y"
#line 1263 "go.y"
{
(yyval.node) = nod(OTCHAN, (yyvsp[(3) - (3)].node), N);
(yyval.node)->etype = Crecv;
......@@ -4102,9 +3760,7 @@ yyreduce:
break;
case 199:
/* Line 1806 of yacc.c */
#line 1271 "go.y"
#line 1270 "go.y"
{
(yyval.node) = nod(OTSTRUCT, N, N);
(yyval.node)->list = (yyvsp[(3) - (5)].list);
......@@ -4113,9 +3769,7 @@ yyreduce:
break;
case 200:
/* Line 1806 of yacc.c */
#line 1277 "go.y"
#line 1276 "go.y"
{
(yyval.node) = nod(OTSTRUCT, N, N);
fixlbrace((yyvsp[(2) - (3)].i));
......@@ -4123,9 +3777,7 @@ yyreduce:
break;
case 201:
/* Line 1806 of yacc.c */
#line 1284 "go.y"
#line 1283 "go.y"
{
(yyval.node) = nod(OTINTER, N, N);
(yyval.node)->list = (yyvsp[(3) - (5)].list);
......@@ -4134,9 +3786,7 @@ yyreduce:
break;
case 202:
/* Line 1806 of yacc.c */
#line 1290 "go.y"
#line 1289 "go.y"
{
(yyval.node) = nod(OTINTER, N, N);
fixlbrace((yyvsp[(2) - (3)].i));
......@@ -4144,9 +3794,7 @@ yyreduce:
break;
case 203:
/* Line 1806 of yacc.c */
#line 1301 "go.y"
#line 1300 "go.y"
{
(yyval.node) = (yyvsp[(2) - (3)].node);
if((yyval.node) == N)
......@@ -4161,9 +3809,7 @@ yyreduce:
break;
case 204:
/* Line 1806 of yacc.c */
#line 1315 "go.y"
#line 1314 "go.y"
{
Node *t;
......@@ -4195,9 +3841,7 @@ yyreduce:
break;
case 205:
/* Line 1806 of yacc.c */
#line 1344 "go.y"
#line 1343 "go.y"
{
Node *rcvr, *t;
......@@ -4238,9 +3882,7 @@ yyreduce:
break;
case 206:
/* Line 1806 of yacc.c */
#line 1384 "go.y"
#line 1383 "go.y"
{
Sym *s;
Type *t;
......@@ -4268,9 +3910,7 @@ yyreduce:
break;
case 207:
/* Line 1806 of yacc.c */
#line 1409 "go.y"
#line 1408 "go.y"
{
(yyval.node) = methodname1(newname((yyvsp[(4) - (8)].sym)), (yyvsp[(2) - (8)].list)->n->right);
(yyval.node)->type = functype((yyvsp[(2) - (8)].list)->n, (yyvsp[(6) - (8)].list), (yyvsp[(8) - (8)].list));
......@@ -4289,9 +3929,7 @@ yyreduce:
break;
case 208:
/* Line 1806 of yacc.c */
#line 1427 "go.y"
#line 1426 "go.y"
{
(yyvsp[(3) - (5)].list) = checkarglist((yyvsp[(3) - (5)].list), 1);
(yyval.node) = nod(OTFUNC, N, N);
......@@ -4301,18 +3939,14 @@ yyreduce:
break;
case 209:
/* Line 1806 of yacc.c */
#line 1435 "go.y"
#line 1434 "go.y"
{
(yyval.list) = nil;
}
break;
case 210:
/* Line 1806 of yacc.c */
#line 1439 "go.y"
#line 1438 "go.y"
{
(yyval.list) = (yyvsp[(2) - (3)].list);
if((yyval.list) == nil)
......@@ -4321,27 +3955,21 @@ yyreduce:
break;
case 211:
/* Line 1806 of yacc.c */
#line 1447 "go.y"
#line 1446 "go.y"
{
(yyval.list) = nil;
}
break;
case 212:
/* Line 1806 of yacc.c */
#line 1451 "go.y"
#line 1450 "go.y"
{
(yyval.list) = list1(nod(ODCLFIELD, N, (yyvsp[(1) - (1)].node)));
}
break;
case 213:
/* Line 1806 of yacc.c */
#line 1455 "go.y"
#line 1454 "go.y"
{
(yyvsp[(2) - (3)].list) = checkarglist((yyvsp[(2) - (3)].list), 0);
(yyval.list) = (yyvsp[(2) - (3)].list);
......@@ -4349,18 +3977,14 @@ yyreduce:
break;
case 214:
/* Line 1806 of yacc.c */
#line 1462 "go.y"
#line 1461 "go.y"
{
closurehdr((yyvsp[(1) - (1)].node));
}
break;
case 215:
/* Line 1806 of yacc.c */
#line 1468 "go.y"
#line 1467 "go.y"
{
(yyval.node) = closurebody((yyvsp[(3) - (4)].list));
fixlbrace((yyvsp[(2) - (4)].i));
......@@ -4368,27 +3992,21 @@ yyreduce:
break;
case 216:
/* Line 1806 of yacc.c */
#line 1473 "go.y"
#line 1472 "go.y"
{
(yyval.node) = closurebody(nil);
}
break;
case 217:
/* Line 1806 of yacc.c */
#line 1484 "go.y"
#line 1483 "go.y"
{
(yyval.list) = nil;
}
break;
case 218:
/* Line 1806 of yacc.c */
#line 1488 "go.y"
#line 1487 "go.y"
{
(yyval.list) = concat((yyvsp[(1) - (3)].list), (yyvsp[(2) - (3)].list));
if(nsyntaxerrors == 0)
......@@ -4399,72 +4017,56 @@ yyreduce:
break;
case 220:
/* Line 1806 of yacc.c */
#line 1499 "go.y"
#line 1498 "go.y"
{
(yyval.list) = concat((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].list));
}
break;
case 222:
/* Line 1806 of yacc.c */
#line 1506 "go.y"
#line 1505 "go.y"
{
(yyval.list) = concat((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].list));
}
break;
case 223:
/* Line 1806 of yacc.c */
#line 1512 "go.y"
#line 1511 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 224:
/* Line 1806 of yacc.c */
#line 1516 "go.y"
#line 1515 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 226:
/* Line 1806 of yacc.c */
#line 1523 "go.y"
#line 1522 "go.y"
{
(yyval.list) = concat((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].list));
}
break;
case 227:
/* Line 1806 of yacc.c */
#line 1529 "go.y"
#line 1528 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 228:
/* Line 1806 of yacc.c */
#line 1533 "go.y"
#line 1532 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 229:
/* Line 1806 of yacc.c */
#line 1539 "go.y"
#line 1538 "go.y"
{
NodeList *l;
......@@ -4490,9 +4092,7 @@ yyreduce:
break;
case 230:
/* Line 1806 of yacc.c */
#line 1562 "go.y"
#line 1561 "go.y"
{
(yyvsp[(1) - (2)].node)->val = (yyvsp[(2) - (2)].val);
(yyval.list) = list1((yyvsp[(1) - (2)].node));
......@@ -4500,9 +4100,7 @@ yyreduce:
break;
case 231:
/* Line 1806 of yacc.c */
#line 1567 "go.y"
#line 1566 "go.y"
{
(yyvsp[(2) - (4)].node)->val = (yyvsp[(4) - (4)].val);
(yyval.list) = list1((yyvsp[(2) - (4)].node));
......@@ -4511,9 +4109,7 @@ yyreduce:
break;
case 232:
/* Line 1806 of yacc.c */
#line 1573 "go.y"
#line 1572 "go.y"
{
(yyvsp[(2) - (3)].node)->right = nod(OIND, (yyvsp[(2) - (3)].node)->right, N);
(yyvsp[(2) - (3)].node)->val = (yyvsp[(3) - (3)].val);
......@@ -4522,9 +4118,7 @@ yyreduce:
break;
case 233:
/* Line 1806 of yacc.c */
#line 1579 "go.y"
#line 1578 "go.y"
{
(yyvsp[(3) - (5)].node)->right = nod(OIND, (yyvsp[(3) - (5)].node)->right, N);
(yyvsp[(3) - (5)].node)->val = (yyvsp[(5) - (5)].val);
......@@ -4534,9 +4128,7 @@ yyreduce:
break;
case 234:
/* Line 1806 of yacc.c */
#line 1586 "go.y"
#line 1585 "go.y"
{
(yyvsp[(3) - (5)].node)->right = nod(OIND, (yyvsp[(3) - (5)].node)->right, N);
(yyvsp[(3) - (5)].node)->val = (yyvsp[(5) - (5)].val);
......@@ -4546,9 +4138,7 @@ yyreduce:
break;
case 235:
/* Line 1806 of yacc.c */
#line 1595 "go.y"
#line 1594 "go.y"
{
Node *n;
......@@ -4560,9 +4150,7 @@ yyreduce:
break;
case 236:
/* Line 1806 of yacc.c */
#line 1604 "go.y"
#line 1603 "go.y"
{
Pkg *pkg;
......@@ -4578,18 +4166,14 @@ yyreduce:
break;
case 237:
/* Line 1806 of yacc.c */
#line 1619 "go.y"
#line 1618 "go.y"
{
(yyval.node) = embedded((yyvsp[(1) - (1)].sym));
}
break;
case 238:
/* Line 1806 of yacc.c */
#line 1625 "go.y"
#line 1624 "go.y"
{
(yyval.node) = nod(ODCLFIELD, (yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].node));
ifacedcl((yyval.node));
......@@ -4597,18 +4181,14 @@ yyreduce:
break;
case 239:
/* Line 1806 of yacc.c */
#line 1630 "go.y"
#line 1629 "go.y"
{
(yyval.node) = nod(ODCLFIELD, N, oldname((yyvsp[(1) - (1)].sym)));
}
break;
case 240:
/* Line 1806 of yacc.c */
#line 1634 "go.y"
#line 1633 "go.y"
{
(yyval.node) = nod(ODCLFIELD, N, oldname((yyvsp[(2) - (3)].sym)));
yyerror("cannot parenthesize embedded type");
......@@ -4616,9 +4196,7 @@ yyreduce:
break;
case 241:
/* Line 1806 of yacc.c */
#line 1641 "go.y"
#line 1640 "go.y"
{
// without func keyword
(yyvsp[(2) - (4)].list) = checkarglist((yyvsp[(2) - (4)].list), 1);
......@@ -4629,9 +4207,7 @@ yyreduce:
break;
case 243:
/* Line 1806 of yacc.c */
#line 1655 "go.y"
#line 1654 "go.y"
{
(yyval.node) = nod(ONONAME, N, N);
(yyval.node)->sym = (yyvsp[(1) - (2)].sym);
......@@ -4640,9 +4216,7 @@ yyreduce:
break;
case 244:
/* Line 1806 of yacc.c */
#line 1661 "go.y"
#line 1660 "go.y"
{
(yyval.node) = nod(ONONAME, N, N);
(yyval.node)->sym = (yyvsp[(1) - (2)].sym);
......@@ -4651,72 +4225,56 @@ yyreduce:
break;
case 246:
/* Line 1806 of yacc.c */
#line 1670 "go.y"
#line 1669 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 247:
/* Line 1806 of yacc.c */
#line 1674 "go.y"
#line 1673 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 248:
/* Line 1806 of yacc.c */
#line 1679 "go.y"
#line 1678 "go.y"
{
(yyval.list) = nil;
}
break;
case 249:
/* Line 1806 of yacc.c */
#line 1683 "go.y"
#line 1682 "go.y"
{
(yyval.list) = (yyvsp[(1) - (2)].list);
}
break;
case 250:
/* Line 1806 of yacc.c */
#line 1691 "go.y"
#line 1690 "go.y"
{
(yyval.node) = N;
}
break;
case 252:
/* Line 1806 of yacc.c */
#line 1696 "go.y"
#line 1695 "go.y"
{
(yyval.node) = liststmt((yyvsp[(1) - (1)].list));
}
break;
case 254:
/* Line 1806 of yacc.c */
#line 1701 "go.y"
#line 1700 "go.y"
{
(yyval.node) = N;
}
break;
case 260:
/* Line 1806 of yacc.c */
#line 1712 "go.y"
#line 1711 "go.y"
{
(yyvsp[(1) - (2)].node) = nod(OLABEL, (yyvsp[(1) - (2)].node), N);
(yyvsp[(1) - (2)].node)->sym = dclstack; // context, for goto restrictions
......@@ -4724,9 +4282,7 @@ yyreduce:
break;
case 261:
/* Line 1806 of yacc.c */
#line 1717 "go.y"
#line 1716 "go.y"
{
NodeList *l;
......@@ -4739,9 +4295,7 @@ yyreduce:
break;
case 262:
/* Line 1806 of yacc.c */
#line 1727 "go.y"
#line 1726 "go.y"
{
// will be converted to OFALL
(yyval.node) = nod(OXFALL, N, N);
......@@ -4749,45 +4303,35 @@ yyreduce:
break;
case 263:
/* Line 1806 of yacc.c */
#line 1732 "go.y"
#line 1731 "go.y"
{
(yyval.node) = nod(OBREAK, (yyvsp[(2) - (2)].node), N);
}
break;
case 264:
/* Line 1806 of yacc.c */
#line 1736 "go.y"
#line 1735 "go.y"
{
(yyval.node) = nod(OCONTINUE, (yyvsp[(2) - (2)].node), N);
}
break;
case 265:
/* Line 1806 of yacc.c */
#line 1740 "go.y"
#line 1739 "go.y"
{
(yyval.node) = nod(OPROC, (yyvsp[(2) - (2)].node), N);
}
break;
case 266:
/* Line 1806 of yacc.c */
#line 1744 "go.y"
#line 1743 "go.y"
{
(yyval.node) = nod(ODEFER, (yyvsp[(2) - (2)].node), N);
}
break;
case 267:
/* Line 1806 of yacc.c */
#line 1748 "go.y"
#line 1747 "go.y"
{
(yyval.node) = nod(OGOTO, (yyvsp[(2) - (2)].node), N);
(yyval.node)->sym = dclstack; // context, for goto restrictions
......@@ -4795,9 +4339,7 @@ yyreduce:
break;
case 268:
/* Line 1806 of yacc.c */
#line 1753 "go.y"
#line 1752 "go.y"
{
(yyval.node) = nod(ORETURN, N, N);
(yyval.node)->list = (yyvsp[(2) - (2)].list);
......@@ -4817,9 +4359,7 @@ yyreduce:
break;
case 269:
/* Line 1806 of yacc.c */
#line 1772 "go.y"
#line 1771 "go.y"
{
(yyval.list) = nil;
if((yyvsp[(1) - (1)].node) != N)
......@@ -4828,9 +4368,7 @@ yyreduce:
break;
case 270:
/* Line 1806 of yacc.c */
#line 1778 "go.y"
#line 1777 "go.y"
{
(yyval.list) = (yyvsp[(1) - (3)].list);
if((yyvsp[(3) - (3)].node) != N)
......@@ -4839,243 +4377,189 @@ yyreduce:
break;
case 271:
/* Line 1806 of yacc.c */
#line 1786 "go.y"
#line 1785 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 272:
/* Line 1806 of yacc.c */
#line 1790 "go.y"
#line 1789 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 273:
/* Line 1806 of yacc.c */
#line 1796 "go.y"
#line 1795 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 274:
/* Line 1806 of yacc.c */
#line 1800 "go.y"
#line 1799 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 275:
/* Line 1806 of yacc.c */
#line 1806 "go.y"
#line 1805 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 276:
/* Line 1806 of yacc.c */
#line 1810 "go.y"
#line 1809 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 277:
/* Line 1806 of yacc.c */
#line 1816 "go.y"
#line 1815 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 278:
/* Line 1806 of yacc.c */
#line 1820 "go.y"
#line 1819 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 279:
/* Line 1806 of yacc.c */
#line 1829 "go.y"
#line 1828 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 280:
/* Line 1806 of yacc.c */
#line 1833 "go.y"
#line 1832 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 281:
/* Line 1806 of yacc.c */
#line 1837 "go.y"
#line 1836 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 282:
/* Line 1806 of yacc.c */
#line 1841 "go.y"
#line 1840 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 283:
/* Line 1806 of yacc.c */
#line 1846 "go.y"
#line 1845 "go.y"
{
(yyval.list) = nil;
}
break;
case 284:
/* Line 1806 of yacc.c */
#line 1850 "go.y"
#line 1849 "go.y"
{
(yyval.list) = (yyvsp[(1) - (2)].list);
}
break;
case 289:
/* Line 1806 of yacc.c */
#line 1864 "go.y"
#line 1863 "go.y"
{
(yyval.node) = N;
}
break;
case 291:
/* Line 1806 of yacc.c */
#line 1870 "go.y"
#line 1869 "go.y"
{
(yyval.list) = nil;
}
break;
case 293:
/* Line 1806 of yacc.c */
#line 1876 "go.y"
#line 1875 "go.y"
{
(yyval.node) = N;
}
break;
case 295:
/* Line 1806 of yacc.c */
#line 1882 "go.y"
#line 1881 "go.y"
{
(yyval.list) = nil;
}
break;
case 297:
/* Line 1806 of yacc.c */
#line 1888 "go.y"
#line 1887 "go.y"
{
(yyval.list) = nil;
}
break;
case 299:
/* Line 1806 of yacc.c */
#line 1894 "go.y"
#line 1893 "go.y"
{
(yyval.list) = nil;
}
break;
case 301:
/* Line 1806 of yacc.c */
#line 1900 "go.y"
#line 1899 "go.y"
{
(yyval.val).ctype = CTxxx;
}
break;
case 303:
/* Line 1806 of yacc.c */
#line 1910 "go.y"
#line 1909 "go.y"
{
importimport((yyvsp[(2) - (4)].sym), (yyvsp[(3) - (4)].val).u.sval);
}
break;
case 304:
/* Line 1806 of yacc.c */
#line 1914 "go.y"
#line 1913 "go.y"
{
importvar((yyvsp[(2) - (4)].sym), (yyvsp[(3) - (4)].type));
}
break;
case 305:
/* Line 1806 of yacc.c */
#line 1918 "go.y"
#line 1917 "go.y"
{
importconst((yyvsp[(2) - (5)].sym), types[TIDEAL], (yyvsp[(4) - (5)].node));
}
break;
case 306:
/* Line 1806 of yacc.c */
#line 1922 "go.y"
#line 1921 "go.y"
{
importconst((yyvsp[(2) - (6)].sym), (yyvsp[(3) - (6)].type), (yyvsp[(5) - (6)].node));
}
break;
case 307:
/* Line 1806 of yacc.c */
#line 1926 "go.y"
#line 1925 "go.y"
{
importtype((yyvsp[(2) - (4)].type), (yyvsp[(3) - (4)].type));
}
break;
case 308:
/* Line 1806 of yacc.c */
#line 1930 "go.y"
#line 1929 "go.y"
{
if((yyvsp[(2) - (4)].node) == N) {
dclcontext = PEXTERN; // since we skip the funcbody below
......@@ -5096,9 +4580,7 @@ yyreduce:
break;
case 309:
/* Line 1806 of yacc.c */
#line 1950 "go.y"
#line 1949 "go.y"
{
(yyval.sym) = (yyvsp[(1) - (1)].sym);
structpkg = (yyval.sym)->pkg;
......@@ -5106,9 +4588,7 @@ yyreduce:
break;
case 310:
/* Line 1806 of yacc.c */
#line 1957 "go.y"
#line 1956 "go.y"
{
(yyval.type) = pkgtype((yyvsp[(1) - (1)].sym));
importsym((yyvsp[(1) - (1)].sym), OTYPE);
......@@ -5116,18 +4596,14 @@ yyreduce:
break;
case 316:
/* Line 1806 of yacc.c */
#line 1977 "go.y"
#line 1976 "go.y"
{
(yyval.type) = pkgtype((yyvsp[(1) - (1)].sym));
}
break;
case 317:
/* Line 1806 of yacc.c */
#line 1981 "go.y"
#line 1980 "go.y"
{
// predefined name like uint8
(yyvsp[(1) - (1)].sym) = pkglookup((yyvsp[(1) - (1)].sym)->name, builtinpkg);
......@@ -5140,63 +4616,49 @@ yyreduce:
break;
case 318:
/* Line 1806 of yacc.c */
#line 1991 "go.y"
#line 1990 "go.y"
{
(yyval.type) = aindex(N, (yyvsp[(3) - (3)].type));
}
break;
case 319:
/* Line 1806 of yacc.c */
#line 1995 "go.y"
#line 1994 "go.y"
{
(yyval.type) = aindex(nodlit((yyvsp[(2) - (4)].val)), (yyvsp[(4) - (4)].type));
}
break;
case 320:
/* Line 1806 of yacc.c */
#line 1999 "go.y"
#line 1998 "go.y"
{
(yyval.type) = maptype((yyvsp[(3) - (5)].type), (yyvsp[(5) - (5)].type));
}
break;
case 321:
/* Line 1806 of yacc.c */
#line 2003 "go.y"
#line 2002 "go.y"
{
(yyval.type) = tostruct((yyvsp[(3) - (4)].list));
}
break;
case 322:
/* Line 1806 of yacc.c */
#line 2007 "go.y"
#line 2006 "go.y"
{
(yyval.type) = tointerface((yyvsp[(3) - (4)].list));
}
break;
case 323:
/* Line 1806 of yacc.c */
#line 2011 "go.y"
#line 2010 "go.y"
{
(yyval.type) = ptrto((yyvsp[(2) - (2)].type));
}
break;
case 324:
/* Line 1806 of yacc.c */
#line 2015 "go.y"
#line 2014 "go.y"
{
(yyval.type) = typ(TCHAN);
(yyval.type)->type = (yyvsp[(2) - (2)].type);
......@@ -5205,9 +4667,7 @@ yyreduce:
break;
case 325:
/* Line 1806 of yacc.c */
#line 2021 "go.y"
#line 2020 "go.y"
{
(yyval.type) = typ(TCHAN);
(yyval.type)->type = (yyvsp[(3) - (4)].type);
......@@ -5216,9 +4676,7 @@ yyreduce:
break;
case 326:
/* Line 1806 of yacc.c */
#line 2027 "go.y"
#line 2026 "go.y"
{
(yyval.type) = typ(TCHAN);
(yyval.type)->type = (yyvsp[(3) - (3)].type);
......@@ -5227,9 +4685,7 @@ yyreduce:
break;
case 327:
/* Line 1806 of yacc.c */
#line 2035 "go.y"
#line 2034 "go.y"
{
(yyval.type) = typ(TCHAN);
(yyval.type)->type = (yyvsp[(3) - (3)].type);
......@@ -5238,18 +4694,14 @@ yyreduce:
break;
case 328:
/* Line 1806 of yacc.c */
#line 2043 "go.y"
#line 2042 "go.y"
{
(yyval.type) = functype(nil, (yyvsp[(3) - (5)].list), (yyvsp[(5) - (5)].list));
}
break;
case 329:
/* Line 1806 of yacc.c */
#line 2049 "go.y"
#line 2048 "go.y"
{
(yyval.node) = nod(ODCLFIELD, N, typenod((yyvsp[(2) - (3)].type)));
if((yyvsp[(1) - (3)].sym))
......@@ -5259,9 +4711,7 @@ yyreduce:
break;
case 330:
/* Line 1806 of yacc.c */
#line 2056 "go.y"
#line 2055 "go.y"
{
Type *t;
......@@ -5278,9 +4728,7 @@ yyreduce:
break;
case 331:
/* Line 1806 of yacc.c */
#line 2072 "go.y"
#line 2071 "go.y"
{
Sym *s;
......@@ -5299,63 +4747,49 @@ yyreduce:
break;
case 332:
/* Line 1806 of yacc.c */
#line 2090 "go.y"
#line 2089 "go.y"
{
(yyval.node) = nod(ODCLFIELD, newname((yyvsp[(1) - (5)].sym)), typenod(functype(fakethis(), (yyvsp[(3) - (5)].list), (yyvsp[(5) - (5)].list))));
}
break;
case 333:
/* Line 1806 of yacc.c */
#line 2094 "go.y"
#line 2093 "go.y"
{
(yyval.node) = nod(ODCLFIELD, N, typenod((yyvsp[(1) - (1)].type)));
}
break;
case 334:
/* Line 1806 of yacc.c */
#line 2099 "go.y"
#line 2098 "go.y"
{
(yyval.list) = nil;
}
break;
case 336:
/* Line 1806 of yacc.c */
#line 2106 "go.y"
#line 2105 "go.y"
{
(yyval.list) = (yyvsp[(2) - (3)].list);
}
break;
case 337:
/* Line 1806 of yacc.c */
#line 2110 "go.y"
#line 2109 "go.y"
{
(yyval.list) = list1(nod(ODCLFIELD, N, typenod((yyvsp[(1) - (1)].type))));
}
break;
case 338:
/* Line 1806 of yacc.c */
#line 2120 "go.y"
#line 2119 "go.y"
{
(yyval.node) = nodlit((yyvsp[(1) - (1)].val));
}
break;
case 339:
/* Line 1806 of yacc.c */
#line 2124 "go.y"
#line 2123 "go.y"
{
(yyval.node) = nodlit((yyvsp[(2) - (2)].val));
switch((yyval.node)->val.ctype){
......@@ -5373,9 +4807,7 @@ yyreduce:
break;
case 340:
/* Line 1806 of yacc.c */
#line 2139 "go.y"
#line 2138 "go.y"
{
(yyval.node) = oldname(pkglookup((yyvsp[(1) - (1)].sym)->name, builtinpkg));
if((yyval.node)->op != OLITERAL)
......@@ -5384,9 +4816,7 @@ yyreduce:
break;
case 342:
/* Line 1806 of yacc.c */
#line 2148 "go.y"
#line 2147 "go.y"
{
if((yyvsp[(2) - (5)].node)->val.ctype == CTRUNE && (yyvsp[(4) - (5)].node)->val.ctype == CTINT) {
(yyval.node) = (yyvsp[(2) - (5)].node);
......@@ -5400,76 +4830,52 @@ yyreduce:
break;
case 345:
/* Line 1806 of yacc.c */
#line 2164 "go.y"
#line 2163 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 346:
/* Line 1806 of yacc.c */
#line 2168 "go.y"
#line 2167 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 347:
/* Line 1806 of yacc.c */
#line 2174 "go.y"
#line 2173 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 348:
/* Line 1806 of yacc.c */
#line 2178 "go.y"
#line 2177 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
case 349:
/* Line 1806 of yacc.c */
#line 2184 "go.y"
#line 2183 "go.y"
{
(yyval.list) = list1((yyvsp[(1) - (1)].node));
}
break;
case 350:
/* Line 1806 of yacc.c */
#line 2188 "go.y"
#line 2187 "go.y"
{
(yyval.list) = list((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].node));
}
break;
/* Line 1806 of yacc.c */
#line 5462 "y.tab.c"
/* Line 1267 of yacc.c. */
#line 4878 "y.tab.c"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
......@@ -5478,6 +4884,7 @@ yyreduce:
*++yyvsp = yyval;
/* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
......@@ -5497,10 +4904,6 @@ yyreduce:
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
......@@ -5508,36 +4911,37 @@ yyerrlab:
#if ! YYERROR_VERBOSE
yyerror (YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{
char *yymsgp = YY_("syntax error");
int yysyntax_error_status;
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (!yymsg)
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
yysyntax_error_status = 2;
}
else
{
yysyntax_error_status = YYSYNTAX_ERROR;
yymsgp = yymsg;
}
}
yyerror (yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
{
YYSIZE_T yyalloc = 2 * yysize;
if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
yyalloc = YYSTACK_ALLOC_MAXIMUM;
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yyalloc);
if (yymsg)
yymsg_alloc = yyalloc;
else
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
}
}
if (0 < yysize && yysize <= yymsg_alloc)
{
(void) yysyntax_error (yymsg, yystate, yychar);
yyerror (yymsg);
}
else
{
yyerror (YY_("syntax error"));
if (yysize != 0)
goto yyexhaustedlab;
}
}
# undef YYSYNTAX_ERROR
#endif
}
......@@ -5545,7 +4949,7 @@ yyerrlab:
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
/* If just tried and failed to reuse look-ahead token after an
error, discard it. */
if (yychar <= YYEOF)
......@@ -5562,7 +4966,7 @@ yyerrlab:
}
}
/* Else will try to reuse lookahead token after shifting the error
/* Else will try to reuse look-ahead token after shifting the error
token. */
goto yyerrlab1;
......@@ -5596,7 +5000,7 @@ yyerrlab1:
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
if (yyn != YYPACT_NINF)
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
......@@ -5619,6 +5023,9 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
if (yyn == YYFINAL)
YYACCEPT;
*++yyvsp = yylval;
......@@ -5643,7 +5050,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined(yyoverflow) || YYERROR_VERBOSE
#ifndef yyoverflow
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
......@@ -5654,14 +5061,9 @@ yyexhaustedlab:
#endif
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
}
if (yychar != YYEOF && yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
......@@ -5685,9 +5087,7 @@ yyreturn:
}
/* Line 2067 of yacc.c */
#line 2192 "go.y"
#line 2191 "go.y"
static void
......
/* A Bison parser, made by GNU Bison 2.5. */
/* A Bison parser, made by GNU Bison 2.3. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
......@@ -26,11 +29,10 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
......@@ -144,28 +146,22 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2068 of yacc.c */
#line 30 "go.y"
{
Node* node;
NodeList* list;
Type* type;
Sym* sym;
struct Val val;
int i;
/* Line 2068 of yacc.c */
#line 163 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
}
/* Line 1529 of yacc.c. */
#line 160 "y.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE yylval;
......@@ -21,16 +21,16 @@ static struct {
"missing import path; require quoted string",
377, ';',
"unexpected semicolon or newline before {",
"missing { after if clause",
398, ';',
"unexpected semicolon or newline before {",
"missing { after switch clause",
237, ';',
"unexpected semicolon or newline before {",
"missing { after for clause",
475, LBODY,
"unexpected semicolon or newline before {",
"missing { after for clause",
22, '{',
"unexpected semicolon or newline before {",
......
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