diff options
author | Brad King <brad.king@kitware.com> | 2018-07-16 17:06:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-07-16 18:46:43 (GMT) |
commit | 406f397e8b5524107457cc2d70bd22878350e9e1 (patch) | |
tree | 9ff09e0750b1b7e98c690f50da265869643afc43 /Source/LexerParser | |
parent | dd5c54600b6f651898925bfd9ec4406ccfc7be95 (diff) | |
download | CMake-406f397e8b5524107457cc2d70bd22878350e9e1.zip CMake-406f397e8b5524107457cc2d70bd22878350e9e1.tar.gz CMake-406f397e8b5524107457cc2d70bd22878350e9e1.tar.bz2 |
math: Restore toleration of unexpected characters in an expression
Prior to commit 7c4c13ffef (math: Reject unexpected expression input
explicitly, 2018-05-18) we ignored unexpected characters in an
expression that otherwise can be parsed. In order to preserve
compatibility with projects that accidentally used this, convert the
error to a warning.
Diffstat (limited to 'Source/LexerParser')
-rw-r--r-- | Source/LexerParser/cmExprLexer.cxx | 2 | ||||
-rw-r--r-- | Source/LexerParser/cmExprLexer.in.l | 2 | ||||
-rw-r--r-- | Source/LexerParser/cmExprParser.cxx | 131 | ||||
-rw-r--r-- | Source/LexerParser/cmExprParser.y | 1 | ||||
-rw-r--r-- | Source/LexerParser/cmExprParserTokens.h | 4 |
5 files changed, 67 insertions, 73 deletions
diff --git a/Source/LexerParser/cmExprLexer.cxx b/Source/LexerParser/cmExprLexer.cxx index 1548daf..cb24687 100644 --- a/Source/LexerParser/cmExprLexer.cxx +++ b/Source/LexerParser/cmExprLexer.cxx @@ -1050,7 +1050,7 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -{return exp_UNEXPECTED;} +{ yyextra->UnexpectedChar(yytext[0]); } YY_BREAK case 18: YY_RULE_SETUP diff --git a/Source/LexerParser/cmExprLexer.in.l b/Source/LexerParser/cmExprLexer.in.l index 87237d1..2197c2a 100644 --- a/Source/LexerParser/cmExprLexer.in.l +++ b/Source/LexerParser/cmExprLexer.in.l @@ -58,6 +58,6 @@ Modify cmExprLexer.cxx: ">>" { return exp_SHIFTRIGHT; } "(" { return exp_OPENPARENT; } ")" { return exp_CLOSEPARENT; } -. {return exp_UNEXPECTED;} +. { yyextra->UnexpectedChar(yytext[0]); } %% diff --git a/Source/LexerParser/cmExprParser.cxx b/Source/LexerParser/cmExprParser.cxx index cbb8078..fbc3628 100644 --- a/Source/LexerParser/cmExprParser.cxx +++ b/Source/LexerParser/cmExprParser.cxx @@ -157,8 +157,7 @@ extern int cmExpr_yydebug; exp_AND = 268, exp_XOR = 269, exp_NOT = 270, - exp_NUMBER = 271, - exp_UNEXPECTED = 272 + exp_NUMBER = 271 }; #endif /* Tokens. */ @@ -176,7 +175,6 @@ extern int cmExpr_yydebug; #define exp_XOR 269 #define exp_NOT 270 #define exp_NUMBER 271 -#define exp_UNEXPECTED 272 /* Value type. */ @@ -188,7 +186,7 @@ int cmExpr_yyparse (yyscan_t yyscanner); /* Copy the second part of user declarations. */ -#line 192 "cmExprParser.cxx" /* yacc.c:358 */ +#line 190 "cmExprParser.cxx" /* yacc.c:358 */ #ifdef short # undef short @@ -433,7 +431,7 @@ union yyalloc #define YYLAST 30 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 18 +#define YYNTOKENS 17 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 10 /* YYNRULES -- Number of rules. */ @@ -444,7 +442,7 @@ union yyalloc /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 272 +#define YYMAXUTOK 271 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -480,16 +478,16 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17 + 15, 16 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 75, 75, 80, 83, 88, 91, 96, 99, 104, - 107, 110, 115, 118, 121, 126, 129, 132, 138, 143, - 146, 149, 154, 157 + 0, 74, 74, 79, 82, 87, 90, 95, 98, 103, + 106, 109, 114, 117, 120, 125, 128, 131, 137, 142, + 145, 148, 153, 156 }; #endif @@ -501,9 +499,8 @@ static const char *const yytname[] = "$end", "error", "$undefined", "exp_PLUS", "exp_MINUS", "exp_TIMES", "exp_DIVIDE", "exp_MOD", "exp_SHIFTLEFT", "exp_SHIFTRIGHT", "exp_OPENPARENT", "exp_CLOSEPARENT", "exp_OR", "exp_AND", "exp_XOR", - "exp_NOT", "exp_NUMBER", "\"character\"", "$accept", "start", "exp", - "bitwiseor", "bitwisexor", "bitwiseand", "shift", "term", "unary", - "factor", YY_NULLPTR + "exp_NOT", "exp_NUMBER", "$accept", "start", "exp", "bitwiseor", + "bitwisexor", "bitwiseand", "shift", "term", "unary", "factor", YY_NULLPTR }; #endif @@ -513,7 +510,7 @@ static const char *const yytname[] = static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272 + 265, 266, 267, 268, 269, 270, 271 }; # endif @@ -583,18 +580,18 @@ static const yytype_int8 yycheck[] = symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 3, 4, 10, 16, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 26, 26, 20, 0, 12, 14, - 13, 8, 9, 3, 4, 5, 6, 7, 11, 21, - 22, 23, 24, 24, 25, 25, 26, 26, 26 + 0, 3, 4, 10, 16, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 25, 25, 19, 0, 12, 14, + 13, 8, 9, 3, 4, 5, 6, 7, 11, 20, + 21, 22, 23, 23, 24, 24, 25, 25, 25 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 18, 19, 20, 20, 21, 21, 22, 22, 23, - 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, - 26, 26, 27, 27 + 0, 17, 18, 19, 19, 20, 20, 21, 21, 22, + 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, + 25, 25, 26, 26 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ @@ -1285,186 +1282,186 @@ yyreduce: switch (yyn) { case 2: -#line 75 "cmExprParser.y" /* yacc.c:1646 */ +#line 74 "cmExprParser.y" /* yacc.c:1646 */ { cmExpr_yyget_extra(yyscanner)->SetResult((yyvsp[0].Number)); } -#line 1293 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1290 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 3: -#line 80 "cmExprParser.y" /* yacc.c:1646 */ +#line 79 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1301 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1298 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 4: -#line 83 "cmExprParser.y" /* yacc.c:1646 */ +#line 82 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) | (yyvsp[0].Number); } -#line 1309 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1306 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 5: -#line 88 "cmExprParser.y" /* yacc.c:1646 */ +#line 87 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1317 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1314 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 6: -#line 91 "cmExprParser.y" /* yacc.c:1646 */ +#line 90 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) ^ (yyvsp[0].Number); } -#line 1325 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1322 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 7: -#line 96 "cmExprParser.y" /* yacc.c:1646 */ +#line 95 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1333 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1330 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 8: -#line 99 "cmExprParser.y" /* yacc.c:1646 */ +#line 98 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) & (yyvsp[0].Number); } -#line 1341 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1338 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 9: -#line 104 "cmExprParser.y" /* yacc.c:1646 */ +#line 103 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1349 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1346 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 10: -#line 107 "cmExprParser.y" /* yacc.c:1646 */ +#line 106 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) << (yyvsp[0].Number); } -#line 1357 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1354 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 11: -#line 110 "cmExprParser.y" /* yacc.c:1646 */ +#line 109 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) >> (yyvsp[0].Number); } -#line 1365 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1362 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 12: -#line 115 "cmExprParser.y" /* yacc.c:1646 */ +#line 114 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1373 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1370 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 13: -#line 118 "cmExprParser.y" /* yacc.c:1646 */ +#line 117 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) + (yyvsp[0].Number); } -#line 1381 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1378 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 14: -#line 121 "cmExprParser.y" /* yacc.c:1646 */ +#line 120 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) - (yyvsp[0].Number); } -#line 1389 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1386 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 15: -#line 126 "cmExprParser.y" /* yacc.c:1646 */ +#line 125 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1397 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1394 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 16: -#line 129 "cmExprParser.y" /* yacc.c:1646 */ +#line 128 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) * (yyvsp[0].Number); } -#line 1405 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1402 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 17: -#line 132 "cmExprParser.y" /* yacc.c:1646 */ +#line 131 "cmExprParser.y" /* yacc.c:1646 */ { if (yyvsp[0].Number == 0) { throw std::overflow_error("divide by zero"); } (yyval.Number) = (yyvsp[-2].Number) / (yyvsp[0].Number); } -#line 1416 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1413 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 18: -#line 138 "cmExprParser.y" /* yacc.c:1646 */ +#line 137 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-2].Number) % (yyvsp[0].Number); } -#line 1424 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1421 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 19: -#line 143 "cmExprParser.y" /* yacc.c:1646 */ +#line 142 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1432 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1429 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 20: -#line 146 "cmExprParser.y" /* yacc.c:1646 */ +#line 145 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = + (yyvsp[0].Number); } -#line 1440 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1437 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 21: -#line 149 "cmExprParser.y" /* yacc.c:1646 */ +#line 148 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = - (yyvsp[0].Number); } -#line 1448 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1445 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 22: -#line 154 "cmExprParser.y" /* yacc.c:1646 */ +#line 153 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[0].Number); } -#line 1456 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1453 "cmExprParser.cxx" /* yacc.c:1646 */ break; case 23: -#line 157 "cmExprParser.y" /* yacc.c:1646 */ +#line 156 "cmExprParser.y" /* yacc.c:1646 */ { (yyval.Number) = (yyvsp[-1].Number); } -#line 1464 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1461 "cmExprParser.cxx" /* yacc.c:1646 */ break; -#line 1468 "cmExprParser.cxx" /* yacc.c:1646 */ +#line 1465 "cmExprParser.cxx" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1694,7 +1691,7 @@ yyreturn: #endif return yyresult; } -#line 162 "cmExprParser.y" /* yacc.c:1906 */ +#line 161 "cmExprParser.y" /* yacc.c:1906 */ /* End of grammar */ diff --git a/Source/LexerParser/cmExprParser.y b/Source/LexerParser/cmExprParser.y index 510daaa..921b31d 100644 --- a/Source/LexerParser/cmExprParser.y +++ b/Source/LexerParser/cmExprParser.y @@ -64,7 +64,6 @@ static void cmExpr_yyerror(yyscan_t yyscanner, const char* message); %token exp_XOR; %token exp_NOT; %token exp_NUMBER; -%token exp_UNEXPECTED "character"; /*-------------------------------------------------------------------------*/ /* grammar */ diff --git a/Source/LexerParser/cmExprParserTokens.h b/Source/LexerParser/cmExprParserTokens.h index 00be4e9..84b2bbd 100644 --- a/Source/LexerParser/cmExprParserTokens.h +++ b/Source/LexerParser/cmExprParserTokens.h @@ -58,8 +58,7 @@ extern int cmExpr_yydebug; exp_AND = 268, exp_XOR = 269, exp_NOT = 270, - exp_NUMBER = 271, - exp_UNEXPECTED = 272 + exp_NUMBER = 271 }; #endif /* Tokens. */ @@ -77,7 +76,6 @@ extern int cmExpr_yydebug; #define exp_XOR 269 #define exp_NOT 270 #define exp_NUMBER 271 -#define exp_UNEXPECTED 272 /* Value type. */ |