diff --git a/tests/README.md b/tests/README.md index 314dc606..76990a04 100644 --- a/tests/README.md +++ b/tests/README.md @@ -7,6 +7,8 @@ define a number of other macros to: - what skeleton is used # Keywords +The following keywords are used to label tests. Please follow them +and avoid creating synonyms. - action - api.value.type - c++ @@ -24,3 +26,9 @@ define a number of other macros to: - report - %union - variant + +# Calculator +The grammar features several special directives: +- `!!` YYERROR +- `!+` YYACCEPT +- `!-` YYABORT diff --git a/tests/calc.at b/tests/calc.at index 005e6bee..2643d570 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -444,8 +444,10 @@ exp: | exp '^' exp { $$ = power ($1, $3); } | '(' exp ')' { $$ = $2; } | '(' error ')' { $$ = 1111; yyerrok; } -| '!' { $$ = 0; YYERROR; } | '-' error { $$ = 0; YYERROR; } +| '!' '!' { $$ = 0; YYERROR; } +| '!' '+' { $$ = 0; YYACCEPT; } +| '!' '-' { $$ = 0; YYABORT; } ; %% @@ -727,8 +729,10 @@ exp: | exp "^" exp { $$ = power ($1, $3); } | "(" exp ")" { $$ = $2; } | "(" error ")" { $$ = 1111; yyerrok(); } -| "!" { $$ = 0; return YYERROR; } | "-" error { $$ = 0; return YYERROR; } +| "!" "!" { $$ = 0; return YYERROR; } +| "!" "+" { $$ = 0; return YYACCEPT; } +| "!" "-" { $$ = 0; return YYABORT; } ; %% @@ -909,8 +913,10 @@ exp: | exp '^' exp { $$ = (int) Math.pow ($1, $3); } | '(' exp ')' { $$ = $2; } | '(' error ')' { $$ = 1111; } -| '!' { $$ = 0; return YYERROR; } | '-' error { $$ = 0; return YYERROR; } +| '!' '!' { $$ = 0; return YYERROR; } +| '!' '+' { $$ = 0; return YYACCEPT; } +| '!' '-' { $$ = 0; return YYABORT; } ; ]AT_CALC_YYLEX[ ]AT_LOCATION_IF([[ @@ -953,6 +959,8 @@ m4_define([_AT_CHECK_CALC], [AT_DATA([[input]], [$2 ]) +echo "input:" +sed -e 's/^/ | /' YYACCEPT, !- => YYABORT, !! => YYERROR. + +# YYACCEPT. +# Java lacks the traces at the end for cleaning the stack +# -Stack now 0 8 20 +# -Cleanup: popping token '+' (1.1: ) +# -Cleanup: popping nterm exp (1.1: 7) +_AT_CHECK_CALC([], [1 + 2 * 3 + !+ ++], + [AT_PARAM_IF([final: 0 0 0])], + [AT_JAVA_IF([77], [80])]) +# YYABORT. +_AT_CHECK_CALC_ERROR([$1], [1], [1 + 2 * 3 + !- ++], + [AT_PARAM_IF([final: 0 0 0])], + [102]) + + # YYerror. # -------- # Check that returning YYerror from the scanner properly enters