# Simple calculator. -*- Autotest -*-
-# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
# Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
%token <ival> NUM "number"
%type <ival> exp
-%nonassoc '=' /* comparison */
+%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
-%left NEG /* negation--unary minus */
-%right '^' /* exponentiation */
+%precedence NEG /* negation--unary minus */
+%right '^' /* exponentiation */
/* Grammar follows */
%%
| '-' exp %prec NEG { $$ = -$2; }
| exp '^' exp { $$ = power ($1, $3); }
| '(' exp ')' { $$ = $2; }
-| '(' error ')' { $$ = 1111; }
+| '(' error ')' { $$ = 1111; yyerrok; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
AT_BISON_OPTION_PUSHDEFS([$1])
AT_DATA_CALC_Y([$1])
-
-AT_SKEL_CC_IF(
- [AT_BISON_CHECK([-o calc.cc calc.y])
- AT_COMPILE_CXX([calc])],
- [AT_BISON_CHECK([-o calc.c calc.y])
- AT_COMPILE([calc])])
+AT_FULL_COMPILE([calc])
# Test the priorities.
_AT_CHECK_CALC([$1],
[1.4: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.12: syntax error, unexpected number
calc: error: 2222 != 1])
+
+# Check that yyerrok works properly: second error is not reported,
+# third and fourth are. Parse status is succesfull.
+_AT_CHECK_CALC_ERROR([$1], [0], [(* *) + (*) + (*)], [113],
+[1.2: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
+1.10: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
+1.16: syntax error, unexpected '*', expecting number or '-' or '(' or '!'])
+
AT_BISON_OPTION_POPDEFS
AT_CLEANUP