summaryrefslogtreecommitdiff
path: root/perly.tab
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-09-12 14:30:41 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-09-13 01:25:36 -0700
commit95a31aad58c629646a232acf2fdd010a10b1b9b5 (patch)
treea037675ea63340540ad63ea11a8f8244d7817884 /perly.tab
parentadad97db02f9834fe787095ccf3593bf7f8d666c (diff)
downloadperl-95a31aad58c629646a232acf2fdd010a10b1b9b5.tar.gz
Fewer false positives for %hash{$scalar} warning
Instead of warning in the lexer, flag the op and then warn in op.c, when the op tree is available, so we don’t end up warning for actual lists or for sub calls. Also, only warn in scalar context, as in list context $hash{$scalar} and %hash{$scalar} do different things. In op.c we no longer have easy access to the source code, so recon- struct the hash/array access based on the op tree. This means %hash{foo} becomes %hash{"foo"}. We only reconstruct constant keys, so %hash{++$x} becomes %hash{...}. This also corrects erroneous dumps, like %hash{"} for %hash{"}"}. Instead of triggering the warning solely based on the op tree, we still keep the heuristic in toke.c, so that common workarounds for that warning (e.g., {q<key>} and {("key")}) continue to work. The heuristic in toke.c is tweaked to avoid warning for qw(). In a future commit I plan to extend this to the existing @array[0] and @hash{key} warnings, to avoid false positives.
Diffstat (limited to 'perly.tab')
-rw-r--r--perly.tab37
1 files changed, 16 insertions, 21 deletions
diff --git a/perly.tab b/perly.tab
index 3a1d6206a3..fc94499f32 100644
--- a/perly.tab
+++ b/perly.tab
@@ -197,16 +197,16 @@ static const yytype_uint16 yyrline[] =
1030, 1037, 1041, 1045, 1050, 1055, 1060, 1069, 1074, 1079,
1085, 1091, 1102, 1106, 1110, 1122, 1135, 1143, 1155, 1156,
1157, 1158, 1159, 1164, 1168, 1170, 1174, 1179, 1181, 1186,
- 1188, 1190, 1192, 1194, 1196, 1198, 1207, 1216, 1227, 1238,
- 1240, 1242, 1247, 1260, 1265, 1270, 1274, 1278, 1282, 1286,
- 1290, 1294, 1298, 1300, 1303, 1307, 1313, 1315, 1320, 1323,
- 1332, 1339, 1338, 1354, 1355, 1356, 1362, 1366, 1374, 1381,
- 1386, 1391, 1393, 1395, 1400, 1402, 1407, 1408, 1414, 1418,
- 1424, 1430, 1436, 1442, 1448, 1455, 1457, 1459, 1462
+ 1188, 1190, 1192, 1194, 1196, 1198, 1207, 1219, 1230, 1244,
+ 1246, 1248, 1253, 1266, 1271, 1276, 1280, 1284, 1288, 1292,
+ 1296, 1300, 1304, 1306, 1309, 1313, 1319, 1321, 1326, 1329,
+ 1338, 1345, 1344, 1360, 1361, 1362, 1368, 1372, 1380, 1387,
+ 1392, 1397, 1399, 1401, 1406, 1408, 1413, 1414, 1420, 1424,
+ 1430, 1436, 1442, 1449, 1455, 1462, 1464, 1466, 1469
};
#endif
-#if YYDEBUG || YYERROR_VERBOSE || 0
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
@@ -225,17 +225,17 @@ static const char *const yytname[] =
"ANDOP", "NOTOP", "','", "ASSIGNOP", "'?'", "':'", "DORDOR", "OROR",
"ANDAND", "BITOROP", "BITANDOP", "SHIFTOP", "MATCHOP", "'!'", "'~'",
"REFGEN", "UMINUS", "POWOP", "POSTDEC", "POSTINC", "PREDEC", "PREINC",
- "ARROW", "')'", "'('", "PEG", "$accept", "grammar", "$@1", "$@2", "$@3",
- "$@4", "$@5", "$@6", "block", "formblock", "remember", "mblock",
+ "ARROW", "')'", "'('", "PEG", "$accept", "grammar", "@1", "@2", "@3",
+ "@4", "@5", "@6", "block", "formblock", "remember", "mblock",
"mremember", "stmtseq", "formstmtseq", "fullstmt", "labfullstmt",
- "barestmt", "$@7", "$@8", "$@9", "formline", "formarg", "sideff", "else",
+ "barestmt", "@7", "@8", "@9", "formline", "formarg", "sideff", "else",
"cont", "mintro", "nexpr", "texpr", "iexpr", "mexpr", "mnexpr", "miexpr",
"formname", "startsub", "startanonsub", "startformsub", "subname",
"proto", "subattrlist", "myattrlist", "subbody", "expr", "listexpr",
"listop", "@10", "method", "subscripted", "termbinop", "termunop",
"anonymous", "termdo", "term", "@11", "myattrterm", "myterm",
"optlistexpr", "optexpr", "my_scalar", "amper", "scalar", "ary", "hsh",
- "arylen", "star", "indirob", YY_NULL
+ "arylen", "star", "indirob", 0
};
#endif
@@ -314,8 +314,8 @@ static const yytype_uint8 yyr2[] =
2, 2, 2, 2, 2, 1, 1, 1, 1
};
-/* 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_uint8 yydefact[] =
{
@@ -448,7 +448,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 -204
static const yytype_int16 yytable[] =
{
@@ -742,12 +743,6 @@ static const yytype_int16 yytable[] =
0, 0, 184
};
-#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-387)))
-
-#define yytable_value_is_error(Yytable_value) \
- (!!((Yytable_value) == (-204)))
-
static const yytype_int16 yycheck[] =
{
10, 11, 12, 15, 42, 295, 295, 11, 297, 298,
@@ -1128,6 +1123,6 @@ static const toketypes yy_type_tab[] =
};
/* Generated from:
- * 1c6010b3d1651d4fc7cbfc329723c507767b4230ac920ae0ffde8f344f4a0ab4 perly.y
+ * 80609b739b642fa427503886445869dfd47021624a1977b902211b38043ed9f1 perly.y
* 5c9d2a0262457fe9b70073fc8ad6c188f812f38ad57712b7e2f53daa01b297cc regen_perly.pl
* ex: set ro: */