Home | History | Annotate | Download | only in tests
      1 #! /bin/sh
      2 ## --------------------- ##
      3 ## M4sh Initialization.  ##
      4 ## --------------------- ##
      5 
      6 # Be Bourne compatible
      7 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
      8   emulate sh
      9   NULLCMD=:
     10   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
     11   # is contrary to our usage.  Disable this feature.
     12   alias -g '${1+"$@"}'='"$@"'
     13 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
     14   set -o posix
     15 fi
     16 DUALCASE=1; export DUALCASE # for MKS sh
     17 
     18 # Support unset when possible.
     19 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
     20   as_unset=unset
     21 else
     22   as_unset=false
     23 fi
     24 
     25 
     26 # Work around bugs in pre-3.0 UWIN ksh.
     27 $as_unset ENV MAIL MAILPATH
     28 PS1='$ '
     29 PS2='> '
     30 PS4='+ '
     31 
     32 # NLS nuisances.
     33 for as_var in \
     34   LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
     35   LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
     36   LC_TELEPHONE LC_TIME
     37 do
     38   if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
     39     eval $as_var=C; export $as_var
     40   else
     41     $as_unset $as_var
     42   fi
     43 done
     44 
     45 # Required to use basename.
     46 if expr a : '\(a\)' >/dev/null 2>&1; then
     47   as_expr=expr
     48 else
     49   as_expr=false
     50 fi
     51 
     52 if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
     53   as_basename=basename
     54 else
     55   as_basename=false
     56 fi
     57 
     58 
     59 # Name of the executable.
     60 as_me=`$as_basename "$0" ||
     61 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
     62 	 X"$0" : 'X\(//\)$' \| \
     63 	 X"$0" : 'X\(/\)$' \| \
     64 	 .     : '\(.\)' 2>/dev/null ||
     65 echo X/"$0" |
     66     sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
     67   	  /^X\/\(\/\/\)$/{ s//\1/; q; }
     68   	  /^X\/\(\/\).*/{ s//\1/; q; }
     69   	  s/.*/./; q'`
     70 
     71 
     72 # PATH needs CR, and LINENO needs CR and PATH.
     73 # Avoid depending upon Character Ranges.
     74 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
     75 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
     76 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
     77 as_cr_digits='0123456789'
     78 as_cr_alnum=$as_cr_Letters$as_cr_digits
     79 
     80 # The user is always right.
     81 if test "${PATH_SEPARATOR+set}" != set; then
     82   echo "#! /bin/sh" >conf$$.sh
     83   echo  "exit 0"   >>conf$$.sh
     84   chmod +x conf$$.sh
     85   if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
     86     PATH_SEPARATOR=';'
     87   else
     88     PATH_SEPARATOR=:
     89   fi
     90   rm -f conf$$.sh
     91 fi
     92 
     93 
     94   as_lineno_1=$LINENO
     95   as_lineno_2=$LINENO
     96   as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
     97   test "x$as_lineno_1" != "x$as_lineno_2" &&
     98   test "x$as_lineno_3"  = "x$as_lineno_2"  || {
     99   # Find who we are.  Look in the path if we contain no path at all
    100   # relative or not.
    101   case $0 in
    102     *[\\/]* ) as_myself=$0 ;;
    103     *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    104 for as_dir in $PATH
    105 do
    106   IFS=$as_save_IFS
    107   test -z "$as_dir" && as_dir=.
    108   test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
    109 done
    110 
    111        ;;
    112   esac
    113   # We did not find ourselves, most probably we were run as `sh COMMAND'
    114   # in which case we are not to be found in the path.
    115   if test "x$as_myself" = x; then
    116     as_myself=$0
    117   fi
    118   if test ! -f "$as_myself"; then
    119     { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
    120    { (exit 1); exit 1; }; }
    121   fi
    122   case $CONFIG_SHELL in
    123   '')
    124     as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    125 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
    126 do
    127   IFS=$as_save_IFS
    128   test -z "$as_dir" && as_dir=.
    129   for as_base in sh bash ksh sh5; do
    130 	 case $as_dir in
    131 	 /*)
    132 	   if ("$as_dir/$as_base" -c '
    133   as_lineno_1=$LINENO
    134   as_lineno_2=$LINENO
    135   as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
    136   test "x$as_lineno_1" != "x$as_lineno_2" &&
    137   test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
    138 	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
    139 	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
    140 	     CONFIG_SHELL=$as_dir/$as_base
    141 	     export CONFIG_SHELL
    142 	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
    143 	   fi;;
    144 	 esac
    145        done
    146 done
    147 ;;
    148   esac
    149 
    150   # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
    151   # uniformly replaced by the line number.  The first 'sed' inserts a
    152   # line-number line before each line; the second 'sed' does the real
    153   # work.  The second script uses 'N' to pair each line-number line
    154   # with the numbered line, and appends trailing '-' during
    155   # substitution so that $LINENO is not a special case at line end.
    156   # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
    157   # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
    158   sed '=' <$as_myself |
    159     sed '
    160       N
    161       s,$,-,
    162       : loop
    163       s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
    164       t loop
    165       s,-$,,
    166       s,^['$as_cr_digits']*\n,,
    167     ' >$as_me.lineno &&
    168   chmod +x $as_me.lineno ||
    169     { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
    170    { (exit 1); exit 1; }; }
    171 
    172   # Don't try to exec as it changes $[0], causing all sort of problems
    173   # (the dirname of $[0] is not the place where we might find the
    174   # original and so on.  Autoconf is especially sensible to this).
    175   . ./$as_me.lineno
    176   # Exit status is that of the last command.
    177   exit
    178 }
    179 
    180 
    181 case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
    182   *c*,-n*) ECHO_N= ECHO_C='
    183 ' ECHO_T='	' ;;
    184   *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
    185   *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
    186 esac
    187 
    188 if expr a : '\(a\)' >/dev/null 2>&1; then
    189   as_expr=expr
    190 else
    191   as_expr=false
    192 fi
    193 
    194 rm -f conf$$ conf$$.exe conf$$.file
    195 echo >conf$$.file
    196 if ln -s conf$$.file conf$$ 2>/dev/null; then
    197   # We could just check for DJGPP; but this test a) works b) is more generic
    198   # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
    199   if test -f conf$$.exe; then
    200     # Don't use ln at all; we don't have any links
    201     as_ln_s='cp -p'
    202   else
    203     as_ln_s='ln -s'
    204   fi
    205 elif ln conf$$.file conf$$ 2>/dev/null; then
    206   as_ln_s=ln
    207 else
    208   as_ln_s='cp -p'
    209 fi
    210 rm -f conf$$ conf$$.exe conf$$.file
    211 
    212 if mkdir -p . 2>/dev/null; then
    213   as_mkdir_p=:
    214 else
    215   test -d ./-p && rmdir ./-p
    216   as_mkdir_p=false
    217 fi
    218 
    219 as_executable_p="test -f"
    220 
    221 # Sed expression to map a string onto a valid CPP name.
    222 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
    223 
    224 # Sed expression to map a string onto a valid variable name.
    225 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
    226 
    227 
    228 # IFS
    229 # We need space, tab and new line, in precisely that order.
    230 as_nl='
    231 '
    232 IFS=" 	$as_nl"
    233 
    234 # CDPATH.
    235 $as_unset CDPATH
    236 
    237 
    238 SHELL=${CONFIG_SHELL-/bin/sh}
    239 
    240 # How were we run?
    241 at_cli_args="$@"
    242 
    243 # Load the config file.
    244 for at_file in atconfig atlocal
    245 do
    246   test -r $at_file || continue
    247   . ./$at_file || { echo "$as_me: error: invalid content: $at_file" >&2
    248    { (exit 1); exit 1; }; }
    249 done
    250 
    251 # atconfig delivers paths relative to the directory the test suite is
    252 # in, but the groups themselves are run in testsuite-dir/group-dir.
    253 if test -n "$at_top_srcdir"; then
    254   builddir=../..
    255   for at_dir in srcdir top_srcdir top_builddir
    256   do
    257     at_val=`eval echo '${'at_$at_dir'}'`
    258     eval "$at_dir=\$at_val/../.."
    259   done
    260 fi
    261 
    262 # Not all shells have the 'times' builtin; the subshell is needed to make
    263 # sure we discard the 'times: not found' message from the shell.
    264 at_times_p=false
    265 (times) >/dev/null 2>&1 && at_times_p=:
    266 
    267 # CLI Arguments to pass to the debugging scripts.
    268 at_debug_args=
    269 # -e sets to true
    270 at_errexit_p=false
    271 # Shall we be verbose?
    272 at_verbose=:
    273 at_quiet=echo
    274 
    275 # Shall we keep the debug scripts?  Must be `:' when the suite is
    276 # run by a debug script, so that the script doesn't remove itself.
    277 at_debug_p=false
    278 # Display help message?
    279 at_help_p=false
    280 # List test groups?
    281 at_list_p=false
    282 # Test groups to run
    283 at_groups=
    284 
    285 # The directory we are in.
    286 at_dir=`pwd`
    287 # The directory the whole suite works in.
    288 # Should be absolutely to let the user `cd' at will.
    289 at_suite_dir=$at_dir/$as_me.dir
    290 # The file containing the suite.
    291 at_suite_log=$at_dir/$as_me.log
    292 # The file containing the location of the last AT_CHECK.
    293 at_check_line_file=$at_suite_dir/at-check-line
    294 # The file containing the exit status of the last command.
    295 at_status_file=$at_suite_dir/at-status
    296 # The files containing the output of the tested commands.
    297 at_stdout=$at_suite_dir/at-stdout
    298 at_stder1=$at_suite_dir/at-stder1
    299 at_stderr=$at_suite_dir/at-stderr
    300 # The file containing dates.
    301 at_times_file=$at_suite_dir/at-times
    302 
    303 # List of the tested programs.
    304 at_tested='bison'
    305 # List of the all the test groups.
    306 at_groups_all=' banner-1 1 2 3 4 5 6 7 8 9 10 banner-2 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 banner-3 31 32 33 34 banner-4 35 36 37 38 39 40 banner-5 41 42 43 44 45 banner-6 46 47 48 49 banner-7 50 51 52 53 54 55 56 57 banner-8 58 59 60 61 62 63 64 65 66 67 68 69 banner-9 70 71 72 73 74 75 76 77 78 79 80 81 82 83 banner-10 84 85 86 87 88 89 90 91 92 93 94 95 96 97 banner-11 98 99 100 101 102 banner-12 103 104 banner-13 105 106 107 108 109 banner-14 110 111 112 banner-15 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 banner-16 131 132 banner-17 133 134 135 136 137 138 139 140 141 banner-18 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158'
    307 # As many dots as there are digits in the last test group number.
    308 # Used to normalize the test group numbers so that `ls' lists them in
    309 # numerical order.
    310 at_format='...'
    311 # Description of all the test groups.
    312 at_help_all='1;input.at:28;Invalid dollar-n;;
    313 2;input.at:46;Invalid @n;;
    314 3;input.at:64;Type Clashes;;
    315 4;input.at:89;Unused values;;
    316 5;input.at:157;Incompatible Aliases;;
    317 6;input.at:198;Torturing the Scanner;;
    318 7;input.at:357;Typed symbol aliases;;
    319 8;input.at:393;Require 1.0;;
    320 9;input.at:394;Require 2.3;;
    321 10;input.at:396;Require 100.0;;
    322 11;output.at:43;Output files:  -dv ;;
    323 12;output.at:46;Output files:  -dv >&-;;
    324 13;output.at:48;Output files:  -dv -o foo.c ;;
    325 14;output.at:50;Output files:  -dv -o foo.tab.c ;;
    326 15;output.at:52;Output files:  -dv -y ;;
    327 16;output.at:54;Output files:  -dv -b bar ;;
    328 17;output.at:56;Output files:  -dv -g -o foo.c ;;
    329 18;output.at:60;Output files: %defines %verbose  ;;
    330 19;output.at:62;Output files: %defines %verbose %yacc  ;;
    331 20;output.at:65;Output files: %defines %verbose %yacc  ;;
    332 21;output.at:69;Output files: %file-prefix="bar" %defines %verbose  ;;
    333 22;output.at:71;Output files: %output="bar.c" %defines %verbose %yacc  ;;
    334 23;output.at:75;Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc  ;;
    335 24;output.at:80;Output files: %defines %verbose  ;;
    336 25;output.at:83;Output files: %defines %verbose  -o foo.c ;;
    337 26;output.at:87;Output files:  --defines=foo.hpp -o foo.c++ ;;
    338 27;output.at:91;Output files:  -o foo.c++ --graph=foo.gph ;;
    339 28;output.at:105;Output files: %skeleton "lalr1.cc" %defines %verbose  ;;
    340 29;output.at:109;Output files: %skeleton "lalr1.cc" %defines %verbose  ;;
    341 30;output.at:114;Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc ;;
    342 31;sets.at:66;Nullable;;
    343 32;sets.at:151;Broken Closure;;
    344 33;sets.at:193;Firsts;;
    345 34;sets.at:269;Accept;;
    346 35;reduce.at:26;Useless Terminals;;
    347 36;reduce.at:70;Useless Nonterminals;;
    348 37;reduce.at:125;Useless Rules;report;
    349 38;reduce.at:212;Reduced Automaton;report;
    350 39;reduce.at:301;Underivable Rules;report;
    351 40;reduce.at:342;Empty Language;;
    352 41;synclines.at:95;Prologue synch line;;
    353 42;synclines.at:115;%union synch line;;
    354 43;synclines.at:138;Postprologue synch line;;
    355 44;synclines.at:157;Action synch line;;
    356 45;synclines.at:175;Epilogue synch line;;
    357 46;headers.at:27;%union and --defines;;
    358 47;headers.at:77;Invalid CPP guards: input/input;;
    359 48;headers.at:78;Invalid CPP guards: 9foo;;
    360 49;headers.at:87;export YYLTYPE;;
    361 50;actions.at:25;Mid-rule actions;;
    362 51;actions.at:91;Exotic Dollars;;
    363 52;actions.at:527;Printers and Destructors : ;;
    364 53;actions.at:528;Printers and Destructors with union: ;;
    365 54;actions.at:533;Printers and Destructors : %defines %skeleton "lalr1.cc";c++;
    366 55;actions.at:534;Printers and Destructors with union: %defines %skeleton "lalr1.cc";c++;
    367 56;actions.at:536;Printers and Destructors : %glr-parser;;
    368 57;actions.at:537;Printers and Destructors with union: %glr-parser;;
    369 58;conflicts.at:32;S/R in initial;;
    370 59;conflicts.at:52;%nonassoc and eof;;
    371 60;conflicts.at:128;Unresolved SR Conflicts;report;
    372 61;conflicts.at:235;Resolved SR Conflicts;report;
    373 62;conflicts.at:357;Defaulted Conflicted Reduction;report;
    374 63;conflicts.at:476;%expect not enough;;
    375 64;conflicts.at:496;%expect right;;
    376 65;conflicts.at:513;%expect too much;;
    377 66;conflicts.at:533;%expect with reduce conflicts;;
    378 67;conflicts.at:553;%no-default-prec without %prec;;
    379 68;conflicts.at:579;%no-default-prec with %prec;;
    380 69;conflicts.at:603;%default-prec;;
    381 70;calc.at:550;Calculator ;;
    382 71;calc.at:552;Calculator %defines;;
    383 72;calc.at:553;Calculator %locations;;
    384 73;calc.at:554;Calculator %name-prefix="calc";;
    385 74;calc.at:555;Calculator %verbose;;
    386 75;calc.at:556;Calculator %yacc;;
    387 76;calc.at:557;Calculator %error-verbose;;
    388 77;calc.at:559;Calculator %pure-parser %locations;;
    389 78;calc.at:560;Calculator %error-verbose %locations;;
    390 79;calc.at:562;Calculator %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc;;
    391 80;calc.at:564;Calculator %debug;;
    392 81;calc.at:565;Calculator %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
    393 82;calc.at:567;Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
    394 83;calc.at:569;Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};;
    395 84;calc.at:586;Calculator %glr-parser ;;
    396 85;calc.at:588;Calculator %glr-parser %defines;;
    397 86;calc.at:589;Calculator %glr-parser %locations;;
    398 87;calc.at:590;Calculator %glr-parser %name-prefix="calc";;
    399 88;calc.at:591;Calculator %glr-parser %verbose;;
    400 89;calc.at:592;Calculator %glr-parser %yacc;;
    401 90;calc.at:593;Calculator %glr-parser %error-verbose;;
    402 91;calc.at:595;Calculator %glr-parser %pure-parser %locations;;
    403 92;calc.at:596;Calculator %glr-parser %error-verbose %locations;;
    404 93;calc.at:598;Calculator %glr-parser %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc;;
    405 94;calc.at:600;Calculator %glr-parser %debug;;
    406 95;calc.at:601;Calculator %glr-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
    407 96;calc.at:603;Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
    408 97;calc.at:605;Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};;
    409 98;calc.at:621;Calculator %skeleton "lalr1.cc" %defines %locations ;c++;
    410 99;calc.at:622;Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %name-prefix="calc" %verbose %yacc;c++;
    411 100;calc.at:624;Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %debug %name-prefix="calc" %verbose %yacc;c++;
    412 101;calc.at:626;Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc;c++;
    413 102;calc.at:628;Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};c++;
    414 103;calc.at:651;Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc;c++;
    415 104;calc.at:653;Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};c++;
    416 105;torture.at:140;Big triangle;;
    417 106;torture.at:232;Big horizontal;;
    418 107;torture.at:368;Many look-ahead tokens;;
    419 108;torture.at:445;Exploding the Stack Size with Alloca;;
    420 109;torture.at:471;Exploding the Stack Size with Malloc;;
    421 110;existing.at:26;GNU AWK Grammar;;
    422 111;existing.at:364;GNU Cim Grammar;;
    423 112;existing.at:980;GNU pic Grammar;;
    424 113;regression.at:28;Trivial grammars;;
    425 114;regression.at:57;Early token definitions;;
    426 115;regression.at:95;Braces parsing;;
    427 116;regression.at:117;Duplicate string;;
    428 117;regression.at:143;Rule Line Numbers;report;
    429 118;regression.at:287;Mixing %token styles;;
    430 119;regression.at:310;Invalid inputs;;
    431 120;regression.at:336;Invalid inputs with {};;
    432 121;regression.at:363;Token definitions;;
    433 122;regression.at:416;Characters Escapes;;
    434 123;regression.at:447;Web2c Report;report;
    435 124;regression.at:624;Web2c Actions;report;
    436 125;regression.at:866;Dancer ;;
    437 126;regression.at:867;Dancer %glr-parser;;
    438 127;regression.at:868;Dancer %skeleton "lalr1.cc";c++;
    439 128;regression.at:963;Expecting two tokens ;;
    440 129;regression.at:964;Expecting two tokens %glr-parser;;
    441 130;regression.at:965;Expecting two tokens %skeleton "lalr1.cc";c++;
    442 131;c++.at:102;Doxygen Public Documentation;;
    443 132;c++.at:103;Doxygen Private Documentation;;
    444 133;cxx-type.at:412;GLR: Resolve ambiguity, impure, no locations;;
    445 134;cxx-type.at:419;GLR: Resolve ambiguity, impure, locations;;
    446 135;cxx-type.at:425;GLR: Resolve ambiguity, pure, no locations;;
    447 136;cxx-type.at:432;GLR: Resolve ambiguity, pure, locations;;
    448 137;cxx-type.at:439;GLR: Merge conflicting parses, impure, no locations;;
    449 138;cxx-type.at:446;GLR: Merge conflicting parses, impure, locations;;
    450 139;cxx-type.at:453;GLR: Merge conflicting parses, pure, no locations;;
    451 140;cxx-type.at:459;GLR: Merge conflicting parses, pure, locations;;
    452 141;cxx-type.at:466;GLR: Verbose messages, resolve ambiguity, impure, no locations;;
    453 142;glr-regression.at:25;Badly Collapsed GLR States;;
    454 143;glr-regression.at:116;Improper handling of embedded actions and dollar(-N) in GLR parsers;;
    455 144;glr-regression.at:232;Improper merging of GLR delayed action sets;;
    456 145;glr-regression.at:337;Duplicate representation of merged trees;;
    457 146;glr-regression.at:432;User destructor for unresolved GLR semantic value;;
    458 147;glr-regression.at:502;User destructor after an error during a split parse;;
    459 148;glr-regression.at:566;Duplicated user destructor for lookahead;;
    460 149;glr-regression.at:644;Incorrectly initialized location for empty right-hand side in GLR;;
    461 150;glr-regression.at:740;No users destructors if stack 0 deleted;;
    462 151;glr-regression.at:820;Corrupted semantic options if user action cuts parse;;
    463 152;glr-regression.at:881;Undesirable destructors if user action cuts parse;;
    464 153;glr-regression.at:947;Leaked semantic values if user action cuts parse;;
    465 154;glr-regression.at:1078;Incorrect lookahead during deterministic GLR;;
    466 155;glr-regression.at:1212;Incorrect lookahead during nondeterministic GLR;;
    467 156;glr-regression.at:1429;Leaked semantic values when reporting ambiguity;;
    468 157;glr-regression.at:1519;Leaked lookahead after nondeterministic parse syntax error;;
    469 158;glr-regression.at:1585;Uninitialized location when reporting ambiguity;;
    470 '
    471 
    472 at_keywords=
    473 at_prev=
    474 for at_option
    475 do
    476   # If the previous option needs an argument, assign it.
    477   if test -n "$at_prev"; then
    478     at_option=$at_prev=$at_option
    479     at_prev=
    480   fi
    481 
    482   at_optarg=`expr "x$at_option" : 'x[^=]*=\(.*\)'`
    483 
    484   # Accept the important Cygnus configure options, so we can diagnose typos.
    485 
    486   case $at_option in
    487     --help | -h )
    488 	at_help_p=:
    489 	;;
    490 
    491     --list | -l )
    492 	at_list_p=:
    493 	;;
    494 
    495     --version | -V )
    496 	echo "$as_me (GNU Bison 2.3)"
    497 	exit 0
    498 	;;
    499 
    500     --clean | -c )
    501 	rm -rf $at_suite_dir $at_suite_log
    502 	exit 0
    503 	;;
    504 
    505     --debug | -d )
    506 	at_debug_p=:
    507 	;;
    508 
    509     --errexit | -e )
    510 	at_debug_p=:
    511 	at_errexit_p=:
    512 	;;
    513 
    514     --verbose | -v )
    515 	at_verbose=echo; at_quiet=:
    516 	;;
    517 
    518     --trace | -x )
    519 	at_traceon='set -vx'; at_traceoff='set +vx'
    520 	;;
    521 
    522     [0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9])
    523 	at_groups="$at_groups$at_option "
    524 	;;
    525 
    526     # Ranges
    527     [0-9]- | [0-9][0-9]- | [0-9][0-9][0-9]- | [0-9][0-9][0-9][0-9]-)
    528 	at_range_start=`echo $at_option |tr -d '-'`
    529 	at_range=`echo " $at_groups_all " | \
    530 	  sed -e 's,^.* '$at_range_start' ,'$at_range_start' ,'`
    531 	at_groups="$at_groups$at_range "
    532 	;;
    533 
    534     -[0-9] | -[0-9][0-9] | -[0-9][0-9][0-9] | -[0-9][0-9][0-9][0-9])
    535 	at_range_end=`echo $at_option |tr -d '-'`
    536 	at_range=`echo " $at_groups_all " | \
    537 	  sed -e 's, '$at_range_end' .*$, '$at_range_end','`
    538 	at_groups="$at_groups$at_range "
    539 	;;
    540 
    541     [0-9]-[0-9] | [0-9]-[0-9][0-9] | [0-9]-[0-9][0-9][0-9] | \
    542     [0-9]-[0-9][0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9] | \
    543     [0-9][0-9]-[0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9][0-9][0-9] | \
    544     [0-9][0-9][0-9]-[0-9][0-9][0-9] | \
    545     [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9] | \
    546     [0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9] )
    547 	at_range_start=`echo $at_option |sed 's,-.*,,'`
    548 	at_range_end=`echo $at_option |sed 's,.*-,,'`
    549 	# FIXME: Maybe test to make sure start <= end?
    550 	at_range=`echo " $at_groups_all " | \
    551 	  sed -e 's,^.* '$at_range_start' ,'$at_range_start' ,' \
    552 	      -e 's, '$at_range_end' .*$, '$at_range_end','`
    553 	at_groups="$at_groups$at_range "
    554 	;;
    555 
    556     # Keywords.
    557     --keywords | -k )
    558 	at_prev=--keywords
    559 	;;
    560     --keywords=* )
    561 	at_keywords="$at_keywords,$at_optarg"
    562 	;;
    563 
    564     *=*)
    565   	at_envvar=`expr "x$at_option" : 'x\([^=]*\)='`
    566   	# Reject names that are not valid shell variable names.
    567   	expr "x$at_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
    568   	  { echo "$as_me: error: invalid variable name: $at_envvar" >&2
    569    { (exit 1); exit 1; }; }
    570   	at_value=`echo "$at_optarg" | sed "s/'/'\\\\\\\\''/g"`
    571   	eval "$at_envvar='$at_value'"
    572   	export $at_envvar
    573 	# Propagate to debug scripts.
    574   	at_debug_args="$at_debug_args $at_option"
    575   	;;
    576 
    577      *) echo "$as_me: invalid option: $at_option" >&2
    578 	echo "Try \`$0 --help' for more information." >&2
    579 	exit 1
    580 	;;
    581   esac
    582 done
    583 
    584 # Process the --keywords
    585 if test -n "$at_keywords"; then
    586   at_groups_selected=$at_help_all
    587   for at_keyword in `IFS=,; set X $at_keywords; shift; echo ${1+$@}`
    588   do
    589     # It is on purpose that we match the test group titles too.
    590     at_groups_selected=`echo "$at_groups_selected" |
    591 			grep -i "^[^;]*;[^;]*.*[; ]$at_keyword[ ;]"`
    592   done
    593   at_groups_selected=`echo "$at_groups_selected" | sed 's/;.*//'`
    594   # Smash the end of lines.
    595   at_groups_selected=`echo $at_groups_selected`
    596   at_groups="$at_groups$at_groups_selected "
    597 fi
    598 
    599 # Selected test groups.
    600 test -z "$at_groups" && at_groups=$at_groups_all
    601 
    602 # Help message.
    603 if $at_help_p; then
    604   cat <<_ATEOF
    605 Usage: $0 [OPTION]... [VARIABLE=VALUE]... [TESTS]
    606 
    607 Run all the tests, or the selected TESTS, and save a detailed log file.
    608 Upon failure, create debugging scripts.
    609 
    610 You should not change environment variables unless explicitly passed
    611 as command line arguments.  Set \`AUTOTEST_PATH' to select the executables
    612 to exercise.  Each relative directory is expanded as build and source
    613 directories relatively to the top level of this distribution.  E.g.,
    614 
    615   $ $0 AUTOTEST_PATH=bin
    616 
    617 possibly amounts into
    618 
    619   PATH=/tmp/foo-1.0/bin:/src/foo-1.0/bin:\$PATH
    620 _ATEOF
    621 cat <<_ATEOF
    622 
    623 Operation modes:
    624   -h, --help     print the help message, then exit
    625   -V, --version  print version number, then exit
    626   -c, --clean    remove all the files this test suite might create and exit
    627   -l, --list     describes all the tests, or the selected TESTS
    628 _ATEOF
    629 cat <<_ATEOF
    630 
    631 Execution tuning:
    632   -k, --keywords=KEYWORDS
    633 	         select the tests matching all the comma separated KEYWORDS
    634 	         accumulates
    635   -e, --errexit  abort as soon as a test fails; implies --debug
    636   -v, --verbose  force more detailed output
    637 	         default for debugging scripts
    638   -d, --debug    inhibit clean up and debug script creation
    639 	         default for debugging scripts
    640   -x, --trace    enable tests shell tracing
    641 _ATEOF
    642 cat <<_ATEOF
    643 
    644 Report bugs to <bug-bison@gnu.org>.
    645 _ATEOF
    646   exit 0
    647 fi
    648 
    649 # List of tests.
    650 if $at_list_p; then
    651   cat <<_ATEOF
    652 GNU Bison 2.3 test suite test groups:
    653 
    654  NUM: FILENAME:LINE      TEST-GROUP-NAME
    655       KEYWORDS
    656 
    657 _ATEOF
    658   # "  1 42  45 " => "^(1|42|45);".
    659   at_groups_pattern=`echo "$at_groups" | sed 's/^  *//;s/  *$//;s/  */|/g'`
    660   echo "$at_help_all" |
    661     awk 'BEGIN { FS = ";" }
    662 	 { if ($1 !~ /^('"$at_groups_pattern"')$/) next }
    663 	 { if ($1) printf " %3d: %-18s %s\n", $1, $2, $3
    664 	   if ($4) printf "      %s\n", $4 } '
    665   exit 0
    666 fi
    667 
    668 # Don't take risks: use only absolute directories in PATH.
    669 #
    670 # For stand-alone test suites, AUTOTEST_PATH is relative to `.'.
    671 #
    672 # For embedded test suites, AUTOTEST_PATH is relative to the top level
    673 # of the package.  Then expand it into build/src parts, since users
    674 # may create executables in both places.
    675 #
    676 # There might be directories that don't exist, but don't redirect
    677 # builtins' (eg., cd) stderr directly: Ultrix's sh hates that.
    678 AUTOTEST_PATH=`echo $AUTOTEST_PATH | tr ':' $PATH_SEPARATOR`
    679 at_path=
    680 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    681 for as_dir in $AUTOTEST_PATH $PATH
    682 do
    683   IFS=$as_save_IFS
    684   test -z "$as_dir" && as_dir=.
    685   case $as_dir in
    686   [\\/]* | ?:[\\/]* )
    687     at_path=$at_path$PATH_SEPARATOR$as_dir
    688     ;;
    689   * )
    690     if test -z "$at_top_builddir"; then
    691       # Stand-alone test suite.
    692       at_path=$at_path$PATH_SEPARATOR$as_dir
    693     else
    694       # Embedded test suite.
    695       at_path=$at_path$PATH_SEPARATOR$at_top_builddir/$as_dir
    696       at_path=$at_path$PATH_SEPARATOR$at_top_srcdir/$as_dir
    697     fi
    698     ;;
    699 esac
    700 done
    701 
    702 
    703 # Now build and simplify PATH.
    704 PATH=
    705 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    706 for as_dir in $at_path
    707 do
    708   IFS=$as_save_IFS
    709   test -z "$as_dir" && as_dir=.
    710   as_dir=`(cd "$as_dir" && pwd) 2>/dev/null`
    711 test -d "$as_dir" || continue
    712 case $PATH in
    713 	          $as_dir                 | \
    714 	          $as_dir$PATH_SEPARATOR* | \
    715   *$PATH_SEPARATOR$as_dir                 | \
    716   *$PATH_SEPARATOR$as_dir$PATH_SEPARATOR* ) ;;
    717 
    718   '') PATH=$as_dir ;;
    719    *) PATH=$PATH$PATH_SEPARATOR$as_dir ;;
    720 esac
    721 done
    722 
    723 export PATH
    724 
    725 # Setting up the FDs.
    726 # 5 is the log file.  Not to be overwritten if `-d'.
    727 
    728 $at_debug_p && at_suite_log=/dev/null
    729 exec 5>$at_suite_log
    730 
    731 # Banners and logs.
    732 cat <<\_ASBOX
    733 ## ------------------------- ##
    734 ## GNU Bison 2.3 test suite. ##
    735 ## ------------------------- ##
    736 _ASBOX
    737 {
    738   cat <<\_ASBOX
    739 ## ------------------------- ##
    740 ## GNU Bison 2.3 test suite. ##
    741 ## ------------------------- ##
    742 _ASBOX
    743   echo
    744 
    745   echo "$as_me: command line was:"
    746   echo "  $ $0 $at_cli_args"
    747   echo
    748 
    749   # Try to find a few ChangeLogs in case it might help determining the
    750   # exact version.  Use the relative dir: if the top dir is a symlink,
    751   # find will not follow it (and options to follow the links are not
    752   # portable), which would result in no output here.
    753   if test -n "$at_top_srcdir"; then
    754     cat <<\_ASBOX
    755 ## ----------- ##
    756 ## ChangeLogs. ##
    757 ## ----------- ##
    758 _ASBOX
    759     echo
    760     for at_file in `find "$at_top_srcdir" -name ChangeLog -print`
    761     do
    762       echo "$as_me: $at_file:"
    763       sed 's/^/| /;10q' $at_file
    764       echo
    765     done
    766 
    767     {
    768 cat <<_ASUNAME
    769 ## --------- ##
    770 ## Platform. ##
    771 ## --------- ##
    772 
    773 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
    774 uname -m = `(uname -m) 2>/dev/null || echo unknown`
    775 uname -r = `(uname -r) 2>/dev/null || echo unknown`
    776 uname -s = `(uname -s) 2>/dev/null || echo unknown`
    777 uname -v = `(uname -v) 2>/dev/null || echo unknown`
    778 
    779 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
    780 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
    781 
    782 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
    783 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
    784 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
    785 hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
    786 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
    787 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
    788 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
    789 
    790 _ASUNAME
    791 
    792 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    793 for as_dir in $PATH
    794 do
    795   IFS=$as_save_IFS
    796   test -z "$as_dir" && as_dir=.
    797   echo "PATH: $as_dir"
    798 done
    799 
    800 }
    801     echo
    802   fi
    803 
    804   # Contents of the config files.
    805   for at_file in atconfig atlocal
    806   do
    807     test -r $at_file || continue
    808     echo "$as_me: $at_file:"
    809     sed 's/^/| /' $at_file
    810     echo
    811   done
    812 
    813   cat <<\_ASBOX
    814 ## ---------------- ##
    815 ## Tested programs. ##
    816 ## ---------------- ##
    817 _ASBOX
    818   echo
    819 } >&5
    820 
    821 # Report what programs are being tested.
    822 for at_program in : $at_tested
    823 do
    824   test "$at_program" = : && continue
    825   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    826 for as_dir in $PATH
    827 do
    828   IFS=$as_save_IFS
    829   test -z "$as_dir" && as_dir=.
    830   test -f $as_dir/$at_program && break
    831 done
    832 
    833   if test -f $as_dir/$at_program; then
    834     {
    835       echo "local.at:216: $as_dir/$at_program --version"
    836       $as_dir/$at_program --version
    837       echo
    838     } >&5 2>&1
    839   else
    840     { { echo "$as_me:$LINENO: error: cannot find $at_program" >&5
    841 echo "$as_me: error: cannot find $at_program" >&2;}
    842    { (exit 1); exit 1; }; }
    843   fi
    844 done
    845 
    846 {
    847   cat <<\_ASBOX
    848 ## ------------------ ##
    849 ## Running the tests. ##
    850 ## ------------------ ##
    851 _ASBOX
    852 } >&5
    853 
    854 at_start_date=`date`
    855 at_start_time=`(date +%s) 2>/dev/null`
    856 echo "$as_me: starting at: $at_start_date" >&5
    857 at_xpass_list=
    858 at_xfail_list=
    859 at_pass_list=
    860 at_fail_list=
    861 at_skip_list=
    862 at_group_count=0
    863 
    864 # Create the master directory if it doesn't already exist.
    865 test -d $at_suite_dir ||
    866   mkdir $at_suite_dir ||
    867   { { echo "$as_me:$LINENO: error: cannot create $at_suite_dir" >&5
    868 echo "$as_me: error: cannot create $at_suite_dir" >&2;}
    869    { (exit 1); exit 1; }; }
    870 
    871 # Can we diff with `/dev/null'?  DU 5.0 refuses.
    872 if diff /dev/null /dev/null >/dev/null 2>&1; then
    873   at_devnull=/dev/null
    874 else
    875   at_devnull=$at_suite_dir/devnull
    876   cp /dev/null $at_devnull
    877 fi
    878 
    879 # Use `diff -u' when possible.
    880 if diff -u $at_devnull $at_devnull >/dev/null 2>&1; then
    881   at_diff='diff -u'
    882 else
    883   at_diff=diff
    884 fi
    885 
    886 
    887 for at_group in $at_groups
    888 do
    889   # Be sure to come back to the top test directory.
    890   cd $at_suite_dir
    891 
    892   case $at_group in
    893     banner-*)
    894       at_group_log=$at_suite_log
    895       ;;
    896 
    897     *)
    898       # Skip tests we already run (using --keywords makes it easy to get
    899       # duplication).
    900       case " $at_pass_test $at_skip_test $at_fail_test " in
    901 	*" $at_group "* ) continue;;
    902       esac
    903 
    904       # Normalize the test group number.
    905       at_group_normalized=`expr "00000$at_group" : ".*\($at_format\)"`
    906 
    907       # Create a fresh directory for the next test group, and enter.
    908       at_group_dir=$at_suite_dir/$at_group_normalized
    909       at_group_log=$at_group_dir/$as_me.log
    910       rm -rf $at_group_dir
    911       mkdir $at_group_dir ||
    912 	{ { echo "$as_me:$LINENO: error: cannot create $at_group_dir" >&5
    913 echo "$as_me: error: cannot create $at_group_dir" >&2;}
    914    { (exit 1); exit 1; }; }
    915       cd $at_group_dir
    916       ;;
    917   esac
    918 
    919   echo 0 > $at_status_file
    920 
    921   # Clearly separate the test groups when verbose.
    922   test $at_group_count != 0 && $at_verbose
    923 
    924   # In verbose mode, append to the log file *and* show on
    925   # the standard output; in quiet mode only write to the log
    926   if test $at_verbose = echo; then
    927     at_tee_pipe="tee -a $at_group_log"
    928   else
    929     at_tee_pipe="cat >> $at_group_log"
    930   fi
    931 
    932   case $at_group in
    933 
    934   banner-1 ) # Banner 1. input.at:19
    935     cat <<\_ATEOF
    936 
    937 Input Processing.
    938 
    939 _ATEOF
    940     ;;
    941 
    942   1 ) # 1. input.at:28: Invalid dollar-n
    943     at_setup_line='input.at:28'
    944     at_desc='Invalid dollar-n'
    945     $at_quiet $ECHO_N "  1: Invalid dollar-n                             $ECHO_C"
    946     at_xfail=no
    947     (
    948       echo "1. input.at:28: testing ..."
    949       $at_traceon
    950 
    951 
    952 cat >input.y <<'_ATEOF'
    953 %%
    954 exp: { $$ = $1 ; };
    955 _ATEOF
    956 
    957 
    958 $at_traceoff
    959 echo "input.at:37: bison input.y"
    960 echo input.at:37 >$at_check_line_file
    961 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
    962 at_status=$?
    963 grep '^ *+' $at_stder1 >&2
    964 grep -v '^ *+' $at_stder1 >$at_stderr
    965 at_failed=false
    966 echo >>$at_stderr; echo "input.y:2.13-14: integer out of range: \`\$1'
    967 " | $at_diff - $at_stderr || at_failed=:
    968 $at_diff $at_devnull $at_stdout || at_failed=:
    969 case $at_status in
    970    77) echo 77 > $at_status_file
    971             exit 77;;
    972    1) ;;
    973    *) echo "input.at:37: exit code was $at_status, expected 1"
    974       at_failed=:;;
    975 esac
    976 if $at_failed; then
    977 
    978   echo 1 > $at_status_file
    979   exit 1
    980 fi
    981 
    982 $at_traceon
    983 
    984 
    985       $at_traceoff
    986       $at_times_p && times >$at_times_file
    987     ) 5>&1 2>&1 | eval $at_tee_pipe
    988     at_status=`cat $at_status_file`
    989     ;;
    990 
    991   2 ) # 2. input.at:46: Invalid @n
    992     at_setup_line='input.at:46'
    993     at_desc='Invalid @n'
    994     $at_quiet $ECHO_N "  2: Invalid @n                                   $ECHO_C"
    995     at_xfail=no
    996     (
    997       echo "2. input.at:46: testing ..."
    998       $at_traceon
    999 
   1000 
   1001 cat >input.y <<'_ATEOF'
   1002 %%
   1003 exp: { @$ = @1 ; };
   1004 _ATEOF
   1005 
   1006 
   1007 $at_traceoff
   1008 echo "input.at:55: bison input.y"
   1009 echo input.at:55 >$at_check_line_file
   1010 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1011 at_status=$?
   1012 grep '^ *+' $at_stder1 >&2
   1013 grep -v '^ *+' $at_stder1 >$at_stderr
   1014 at_failed=false
   1015 echo >>$at_stderr; echo "input.y:2.13-14: integer out of range: \`@1'
   1016 " | $at_diff - $at_stderr || at_failed=:
   1017 $at_diff $at_devnull $at_stdout || at_failed=:
   1018 case $at_status in
   1019    77) echo 77 > $at_status_file
   1020             exit 77;;
   1021    1) ;;
   1022    *) echo "input.at:55: exit code was $at_status, expected 1"
   1023       at_failed=:;;
   1024 esac
   1025 if $at_failed; then
   1026 
   1027   echo 1 > $at_status_file
   1028   exit 1
   1029 fi
   1030 
   1031 $at_traceon
   1032 
   1033 
   1034       $at_traceoff
   1035       $at_times_p && times >$at_times_file
   1036     ) 5>&1 2>&1 | eval $at_tee_pipe
   1037     at_status=`cat $at_status_file`
   1038     ;;
   1039 
   1040   3 ) # 3. input.at:64: Type Clashes
   1041     at_setup_line='input.at:64'
   1042     at_desc='Type Clashes'
   1043     $at_quiet $ECHO_N "  3: Type Clashes                                 $ECHO_C"
   1044     at_xfail=no
   1045     (
   1046       echo "3. input.at:64: testing ..."
   1047       $at_traceon
   1048 
   1049 
   1050 cat >input.y <<'_ATEOF'
   1051 %token foo
   1052 %type <bar> exp
   1053 %%
   1054 exp: foo {} foo
   1055    | foo
   1056    | /* Empty. */
   1057    ;
   1058 _ATEOF
   1059 
   1060 
   1061 $at_traceoff
   1062 echo "input.at:80: bison input.y"
   1063 echo input.at:80 >$at_check_line_file
   1064 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1065 at_status=$?
   1066 grep '^ *+' $at_stder1 >&2
   1067 grep -v '^ *+' $at_stder1 >$at_stderr
   1068 at_failed=false
   1069 echo >>$at_stderr; echo "input.y:4.6-15: warning: type clash on default action: <bar> != <>
   1070 input.y:5.6-8: warning: type clash on default action: <bar> != <>
   1071 input.y:6.5: warning: empty rule for typed nonterminal, and no action
   1072 " | $at_diff - $at_stderr || at_failed=:
   1073 $at_diff $at_devnull $at_stdout || at_failed=:
   1074 case $at_status in
   1075    77) echo 77 > $at_status_file
   1076             exit 77;;
   1077    0) ;;
   1078    *) echo "input.at:80: exit code was $at_status, expected 0"
   1079       at_failed=:;;
   1080 esac
   1081 if $at_failed; then
   1082 
   1083   echo 1 > $at_status_file
   1084   exit 1
   1085 fi
   1086 
   1087 $at_traceon
   1088 
   1089 
   1090       $at_traceoff
   1091       $at_times_p && times >$at_times_file
   1092     ) 5>&1 2>&1 | eval $at_tee_pipe
   1093     at_status=`cat $at_status_file`
   1094     ;;
   1095 
   1096   4 ) # 4. input.at:89: Unused values
   1097     at_setup_line='input.at:89'
   1098     at_desc='Unused values'
   1099     $at_quiet $ECHO_N "  4: Unused values                                $ECHO_C"
   1100     at_xfail=no
   1101     (
   1102       echo "4. input.at:89: testing ..."
   1103       $at_traceon
   1104 
   1105 
   1106 cat >input.y <<'_ATEOF'
   1107 %token <integer> INT
   1108 %type <integer> a b c d e f g h i j k l
   1109 %destructor { destroy ($$); } INT a b c d e f g h i j k l
   1110 %%
   1111 start:
   1112   'a' a { $2 } | 'b' b { $2 } | 'c' c { $2 } | 'd' d { $2 } | 'e' e { $2 }
   1113 | 'f' f { $2 } | 'g' g { $2 } | 'h' h { $2 } | 'i' i { $2 } | 'j' j { $2 }
   1114 | 'k' k { $2 } | 'l' l { $2 }
   1115 ;
   1116 
   1117 a: INT | INT { } INT { } INT { };
   1118 b: INT | /* empty */;
   1119 c: INT | INT { $1 } INT { } INT { };
   1120 d: INT | INT { } INT { $1 } INT { };
   1121 e: INT | INT { } INT {  } INT { $1 };
   1122 f: INT | INT { } INT {  } INT { $$ = $1 + $3 + $5; };
   1123 g: INT | INT { $$ } INT { $$ } INT { };
   1124 h: INT | INT { $$ } INT { $$ = $2 } INT { };
   1125 i: INT | INT INT { } { $$ = $1 + $2; };
   1126 j: INT | INT INT { $<integer>$ = 1; } { $$ = $1 + $2; };
   1127 k: INT | INT INT { $$; } { $$ = $3; } { };
   1128 l: INT | INT { $$ = $1; } INT { $$ = $2 + $3; } INT { $$ = $4 + $5; };
   1129 
   1130 _ATEOF
   1131 
   1132 
   1133 $at_traceoff
   1134 echo "input.at:148: bison input.y"
   1135 echo input.at:148 >$at_check_line_file
   1136 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1137 at_status=$?
   1138 grep '^ *+' $at_stder1 >&2
   1139 grep -v '^ *+' $at_stder1 >$at_stderr
   1140 at_failed=false
   1141 echo >>$at_stderr; echo "input.y:11.10-32: warning: unset value: \$\$
   1142 input.y:11.10-32: warning: unused value: \$1
   1143 input.y:11.10-32: warning: unused value: \$3
   1144 input.y:11.10-32: warning: unused value: \$5
   1145 input.y:12.9: warning: empty rule for typed nonterminal, and no action
   1146 input.y:13.10-35: warning: unset value: \$\$
   1147 input.y:13.10-35: warning: unused value: \$3
   1148 input.y:13.10-35: warning: unused value: \$5
   1149 input.y:14.10-35: warning: unset value: \$\$
   1150 input.y:14.10-35: warning: unused value: \$3
   1151 input.y:14.10-35: warning: unused value: \$5
   1152 input.y:15.10-36: warning: unset value: \$\$
   1153 input.y:15.10-36: warning: unused value: \$3
   1154 input.y:15.10-36: warning: unused value: \$5
   1155 input.y:17.10-38: warning: unset value: \$\$
   1156 input.y:17.10-38: warning: unused value: \$1
   1157 input.y:17.10-38: warning: unused value: \$2
   1158 input.y:17.10-38: warning: unused value: \$3
   1159 input.y:17.10-38: warning: unused value: \$4
   1160 input.y:17.10-38: warning: unused value: \$5
   1161 input.y:18.10-43: warning: unset value: \$\$
   1162 input.y:18.10-43: warning: unused value: \$1
   1163 input.y:18.10-43: warning: unused value: \$3
   1164 input.y:18.10-43: warning: unused value: \$4
   1165 input.y:18.10-43: warning: unused value: \$5
   1166 input.y:20.10-55: warning: unused value: \$3
   1167 input.y:21.10-41: warning: unset value: \$\$
   1168 input.y:21.10-41: warning: unused value: \$1
   1169 input.y:21.10-41: warning: unused value: \$2
   1170 input.y:21.10-41: warning: unused value: \$4
   1171 " | $at_diff - $at_stderr || at_failed=:
   1172 $at_diff $at_devnull $at_stdout || at_failed=:
   1173 case $at_status in
   1174    77) echo 77 > $at_status_file
   1175             exit 77;;
   1176    0) ;;
   1177    *) echo "input.at:148: exit code was $at_status, expected 0"
   1178       at_failed=:;;
   1179 esac
   1180 if $at_failed; then
   1181 
   1182   echo 1 > $at_status_file
   1183   exit 1
   1184 fi
   1185 
   1186 $at_traceon
   1187 
   1188 
   1189       $at_traceoff
   1190       $at_times_p && times >$at_times_file
   1191     ) 5>&1 2>&1 | eval $at_tee_pipe
   1192     at_status=`cat $at_status_file`
   1193     ;;
   1194 
   1195   5 ) # 5. input.at:157: Incompatible Aliases
   1196     at_setup_line='input.at:157'
   1197     at_desc='Incompatible Aliases'
   1198     $at_quiet $ECHO_N "  5: Incompatible Aliases                         $ECHO_C"
   1199     at_xfail=no
   1200     (
   1201       echo "5. input.at:157: testing ..."
   1202       $at_traceon
   1203 
   1204 
   1205 cat >input.y <<'_ATEOF'
   1206 %token foo "foo"
   1207 
   1208 %type <bar>       foo
   1209 %printer {bar}    foo
   1210 %destructor {bar} foo
   1211 %left             foo
   1212 
   1213 %type <baz>       "foo"
   1214 %printer {baz}    "foo"
   1215 %destructor {baz} "foo"
   1216 %left             "foo"
   1217 
   1218 %%
   1219 exp: foo;
   1220 _ATEOF
   1221 
   1222 
   1223 $at_traceoff
   1224 echo "input.at:185: bison input.y"
   1225 echo input.at:185 >$at_check_line_file
   1226 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1227 at_status=$?
   1228 grep '^ *+' $at_stder1 >&2
   1229 grep -v '^ *+' $at_stder1 >$at_stderr
   1230 at_failed=false
   1231 echo >>$at_stderr; echo "input.y:8.7-11: %type redeclaration for foo
   1232 input.y:3.7-11: first declaration
   1233 input.y:10.13-17: %destructor redeclaration for foo
   1234 input.y:5.13-17: first declaration
   1235 input.y:9.10-14: %printer redeclaration for foo
   1236 input.y:10.13-17: first declaration
   1237 input.y:11.1-5: %left redeclaration for foo
   1238 input.y:6.1-5: first declaration
   1239 " | $at_diff - $at_stderr || at_failed=:
   1240 $at_diff $at_devnull $at_stdout || at_failed=:
   1241 case $at_status in
   1242    77) echo 77 > $at_status_file
   1243             exit 77;;
   1244    1) ;;
   1245    *) echo "input.at:185: exit code was $at_status, expected 1"
   1246       at_failed=:;;
   1247 esac
   1248 if $at_failed; then
   1249 
   1250   echo 1 > $at_status_file
   1251   exit 1
   1252 fi
   1253 
   1254 $at_traceon
   1255 
   1256 
   1257       $at_traceoff
   1258       $at_times_p && times >$at_times_file
   1259     ) 5>&1 2>&1 | eval $at_tee_pipe
   1260     at_status=`cat $at_status_file`
   1261     ;;
   1262 
   1263   6 ) # 6. input.at:198: Torturing the Scanner
   1264     at_setup_line='input.at:198'
   1265     at_desc='Torturing the Scanner'
   1266     $at_quiet $ECHO_N "  6: Torturing the Scanner                        $ECHO_C"
   1267     at_xfail=no
   1268     (
   1269       echo "6. input.at:198: testing ..."
   1270       $at_traceon
   1271 
   1272 
   1273 
   1274 cat >input.y <<'_ATEOF'
   1275 _ATEOF
   1276 
   1277 $at_traceoff
   1278 echo "input.at:204: bison input.y"
   1279 echo input.at:204 >$at_check_line_file
   1280 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1281 at_status=$?
   1282 grep '^ *+' $at_stder1 >&2
   1283 grep -v '^ *+' $at_stder1 >$at_stderr
   1284 at_failed=false
   1285 echo >>$at_stderr; echo "input.y:1.1: syntax error, unexpected end of file
   1286 " | $at_diff - $at_stderr || at_failed=:
   1287 $at_diff $at_devnull $at_stdout || at_failed=:
   1288 case $at_status in
   1289    77) echo 77 > $at_status_file
   1290             exit 77;;
   1291    1) ;;
   1292    *) echo "input.at:204: exit code was $at_status, expected 1"
   1293       at_failed=:;;
   1294 esac
   1295 if $at_failed; then
   1296 
   1297   echo 1 > $at_status_file
   1298   exit 1
   1299 fi
   1300 
   1301 $at_traceon
   1302 
   1303 
   1304 
   1305 cat >input.y <<'_ATEOF'
   1306 {}
   1307 _ATEOF
   1308 
   1309 $at_traceoff
   1310 echo "input.at:212: bison input.y"
   1311 echo input.at:212 >$at_check_line_file
   1312 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1313 at_status=$?
   1314 grep '^ *+' $at_stder1 >&2
   1315 grep -v '^ *+' $at_stder1 >$at_stderr
   1316 at_failed=false
   1317 echo >>$at_stderr; echo "input.y:1.1-2: syntax error, unexpected {...}
   1318 " | $at_diff - $at_stderr || at_failed=:
   1319 $at_diff $at_devnull $at_stdout || at_failed=:
   1320 case $at_status in
   1321    77) echo 77 > $at_status_file
   1322             exit 77;;
   1323    1) ;;
   1324    *) echo "input.at:212: exit code was $at_status, expected 1"
   1325       at_failed=:;;
   1326 esac
   1327 if $at_failed; then
   1328 
   1329   echo 1 > $at_status_file
   1330   exit 1
   1331 fi
   1332 
   1333 $at_traceon
   1334 
   1335 
   1336 
   1337 cat >input.y <<'_ATEOF'
   1338 %{
   1339 #ifdef HAVE_CONFIG_H
   1340 # include <config.h>
   1341   /* We don't need perfect functions for these tests. */
   1342 # undef malloc
   1343 # undef memcmp
   1344 # undef realloc
   1345 #endif
   1346 %}
   1347 
   1348 %{
   1349 /* This is seen in GCC: a %{ and %} in middle of a comment. */
   1350 const char *foo = "So %{ and %} can be here too.";
   1351 
   1352 #if 0
   1353 /* These examples test Bison while not stressing C compilers too much.
   1354    Many C compilers mishandle backslash-newlines, so this part of the
   1355    test is inside "#if 0".  The comment and string are written so that
   1356    the "#endif" will be seen regardless of the C compiler bugs that we
   1357    know about, namely:
   1358 
   1359      HP C (as of late 2002) mishandles *\[newline]\[newline]/ within a
   1360      comment.
   1361 
   1362      The Apple Darwin compiler (as of late 2002) mishandles
   1363      \\[newline]' within a character constant.
   1364 
   1365    */
   1366 
   1367 /\
   1368 * A comment with backslash-newlines in it. %} *\
   1369 \
   1370 /
   1371 /* { Close the above comment, if the C compiler mishandled it.  */
   1372 
   1373 char str[] = "\\
   1374 " A string with backslash-newlines in it %{ %} \\
   1375 \
   1376 "";
   1377 
   1378 char apostrophe = '\'';
   1379 #endif
   1380 
   1381 #include <stdio.h>
   1382 %}
   1383 /* %{ and %} can be here too. */
   1384 
   1385 %{
   1386 /* Exercise pre-prologue dependency to %union.  */
   1387 typedef int value;
   1388 %}
   1389 
   1390 /* Exercise M4 quoting: ']]', 0.  */
   1391 
   1392 /* Also exercise %union. */
   1393 %union
   1394 {
   1395   value ival; /* A comment to exercise an old bug. */
   1396 };
   1397 
   1398 
   1399 /* Exercise post-prologue dependency to %union.  */
   1400 %{
   1401 static YYSTYPE value_as_yystype (value val);
   1402 
   1403 /* Exercise quotes in declarations.  */
   1404 char quote[] = "]],";
   1405 %}
   1406 
   1407 %{
   1408 static void yyerror (const char *s);
   1409 static int yylex (void);
   1410 %}
   1411 
   1412 %type <ival> '['
   1413 
   1414 /* Exercise quotes in strings.  */
   1415 %token FAKE "fake [] \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
   1416 
   1417 %%
   1418 /* Exercise M4 quoting: ']]', [, 1.  */
   1419 exp: '[' '\1' two '$' '@' '{' oline output.or.oline.opt
   1420   {
   1421     /* Exercise quotes in braces.  */
   1422     char tmp[] = "[%c],\n";
   1423     printf (tmp, $1);
   1424   }
   1425 ;
   1426 
   1427 two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
   1428 oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
   1429 output.or.oline.opt: ;|oline;;|output;;;
   1430 output: '#' 'o' 'u' 't' 'p' 'u' 't' ' ';
   1431 %%
   1432 /* Exercise M4 quoting: ']]', [, 2.  */
   1433 
   1434 static YYSTYPE
   1435 value_as_yystype (value val)
   1436 {
   1437   YYSTYPE res;
   1438   res.ival = val;
   1439   return res;
   1440 }
   1441 
   1442 static int
   1443 yylex (void)
   1444 {
   1445   static const char *input = "[\1\2$@{@oline@__oline__\
   1446 #output "; /* "
   1447   */
   1448   yylval = value_as_yystype (*input);
   1449   return *input++;
   1450 }
   1451 
   1452 static void
   1453 yyerror (const char *msg)
   1454 {
   1455   fprintf (stderr, "%s\n", msg);
   1456 }
   1457 _ATEOF
   1458 
   1459 
   1460 
   1461 # Pacify Emacs'font-lock-mode: "
   1462 
   1463 cat >main.c <<'_ATEOF'
   1464 typedef int value;
   1465 #include "input.h"
   1466 
   1467 int yyparse (void);
   1468 
   1469 int
   1470 main (void)
   1471 {
   1472   return yyparse ();
   1473 }
   1474 _ATEOF
   1475 
   1476 
   1477 $at_traceoff
   1478 echo "input.at:342: bison -d -v -o input.c input.y"
   1479 echo input.at:342 >$at_check_line_file
   1480 ( $at_traceon; bison -d -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   1481 at_status=$?
   1482 grep '^ *+' $at_stder1 >&2
   1483 grep -v '^ *+' $at_stder1 >$at_stderr
   1484 at_failed=false
   1485 $at_diff $at_devnull $at_stderr || at_failed=:
   1486 $at_diff $at_devnull $at_stdout || at_failed=:
   1487 case $at_status in
   1488    77) echo 77 > $at_status_file
   1489             exit 77;;
   1490    0) ;;
   1491    *) echo "input.at:342: exit code was $at_status, expected 0"
   1492       at_failed=:;;
   1493 esac
   1494 if $at_failed; then
   1495 
   1496   echo 1 > $at_status_file
   1497   exit 1
   1498 fi
   1499 
   1500 $at_traceon
   1501 
   1502 $at_traceoff
   1503 echo "input.at:343: \$CC \$CFLAGS \$CPPFLAGS -o input.o -c input.c"
   1504 echo input.at:343 >$at_check_line_file
   1505 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -c input.c ) >$at_stdout 2>$at_stder1
   1506 at_status=$?
   1507 grep '^ *+' $at_stder1 >&2
   1508 grep -v '^ *+' $at_stder1 >$at_stderr
   1509 at_failed=false
   1510 echo stderr:; cat $at_stderr
   1511 echo stdout:; cat $at_stdout
   1512 case $at_status in
   1513    77) echo 77 > $at_status_file
   1514             exit 77;;
   1515    0) ;;
   1516    *) echo "input.at:343: exit code was $at_status, expected 0"
   1517       at_failed=:;;
   1518 esac
   1519 if $at_failed; then
   1520 
   1521   echo 1 > $at_status_file
   1522   exit 1
   1523 fi
   1524 
   1525 $at_traceon
   1526 
   1527 $at_traceoff
   1528 echo "input.at:344: \$CC \$CFLAGS \$CPPFLAGS -o main.o -c main.c"
   1529 echo input.at:344 >$at_check_line_file
   1530 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o main.o -c main.c ) >$at_stdout 2>$at_stder1
   1531 at_status=$?
   1532 grep '^ *+' $at_stder1 >&2
   1533 grep -v '^ *+' $at_stder1 >$at_stderr
   1534 at_failed=false
   1535 echo stderr:; cat $at_stderr
   1536 echo stdout:; cat $at_stdout
   1537 case $at_status in
   1538    77) echo 77 > $at_status_file
   1539             exit 77;;
   1540    0) ;;
   1541    *) echo "input.at:344: exit code was $at_status, expected 0"
   1542       at_failed=:;;
   1543 esac
   1544 if $at_failed; then
   1545 
   1546   echo 1 > $at_status_file
   1547   exit 1
   1548 fi
   1549 
   1550 $at_traceon
   1551 
   1552 $at_traceoff
   1553 echo "input.at:345: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.o main.o \$LIBS"
   1554 echo input.at:345 >$at_check_line_file
   1555 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.o main.o $LIBS ) >$at_stdout 2>$at_stder1
   1556 at_status=$?
   1557 grep '^ *+' $at_stder1 >&2
   1558 grep -v '^ *+' $at_stder1 >$at_stderr
   1559 at_failed=false
   1560 echo stderr:; cat $at_stderr
   1561 echo stdout:; cat $at_stdout
   1562 case $at_status in
   1563    77) echo 77 > $at_status_file
   1564             exit 77;;
   1565    0) ;;
   1566    *) echo "input.at:345: exit code was $at_status, expected 0"
   1567       at_failed=:;;
   1568 esac
   1569 if $at_failed; then
   1570 
   1571   echo 1 > $at_status_file
   1572   exit 1
   1573 fi
   1574 
   1575 $at_traceon
   1576 
   1577 $at_traceoff
   1578 echo "input.at:348: \$PREPARSER ./input"
   1579 echo input.at:348 >$at_check_line_file
   1580 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   1581 at_status=$?
   1582 grep '^ *+' $at_stder1 >&2
   1583 grep -v '^ *+' $at_stder1 >$at_stderr
   1584 at_failed=false
   1585 $at_diff $at_devnull $at_stderr || at_failed=:
   1586 echo >>$at_stdout; echo "[[],
   1587 " | $at_diff - $at_stdout || at_failed=:
   1588 case $at_status in
   1589    77) echo 77 > $at_status_file
   1590             exit 77;;
   1591    0) ;;
   1592    *) echo "input.at:348: exit code was $at_status, expected 0"
   1593       at_failed=:;;
   1594 esac
   1595 if $at_failed; then
   1596 
   1597   echo 1 > $at_status_file
   1598   exit 1
   1599 fi
   1600 
   1601 $at_traceon
   1602 
   1603 
   1604       $at_traceoff
   1605       $at_times_p && times >$at_times_file
   1606     ) 5>&1 2>&1 | eval $at_tee_pipe
   1607     at_status=`cat $at_status_file`
   1608     ;;
   1609 
   1610   7 ) # 7. input.at:357: Typed symbol aliases
   1611     at_setup_line='input.at:357'
   1612     at_desc='Typed symbol aliases'
   1613     $at_quiet $ECHO_N "  7: Typed symbol aliases                         $ECHO_C"
   1614     at_xfail=no
   1615     (
   1616       echo "7. input.at:357: testing ..."
   1617       $at_traceon
   1618 
   1619 
   1620 # Bison 2.0 broke typed symbol aliases - ensure they work.
   1621 
   1622 cat >input.y <<'_ATEOF'
   1623 %{
   1624 #ifdef HAVE_CONFIG_H
   1625 # include <config.h>
   1626   /* We don't need perfect functions for these tests. */
   1627 # undef malloc
   1628 # undef memcmp
   1629 # undef realloc
   1630 #endif
   1631 %}
   1632 
   1633 %union
   1634 {
   1635   int val;
   1636 };
   1637 %token <val> MY_TOKEN "MY TOKEN"
   1638 %type <val> exp
   1639 %%
   1640 exp: "MY TOKEN";
   1641 %%
   1642 _ATEOF
   1643 
   1644 
   1645 
   1646 $at_traceoff
   1647 echo "input.at:373: bison -o input.c input.y"
   1648 echo input.at:373 >$at_check_line_file
   1649 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   1650 at_status=$?
   1651 grep '^ *+' $at_stder1 >&2
   1652 grep -v '^ *+' $at_stder1 >$at_stderr
   1653 at_failed=false
   1654 $at_diff $at_devnull $at_stderr || at_failed=:
   1655 $at_diff $at_devnull $at_stdout || at_failed=:
   1656 case $at_status in
   1657    77) echo 77 > $at_status_file
   1658             exit 77;;
   1659    0) ;;
   1660    *) echo "input.at:373: exit code was $at_status, expected 0"
   1661       at_failed=:;;
   1662 esac
   1663 if $at_failed; then
   1664 
   1665   echo 1 > $at_status_file
   1666   exit 1
   1667 fi
   1668 
   1669 $at_traceon
   1670 
   1671 
   1672       $at_traceoff
   1673       $at_times_p && times >$at_times_file
   1674     ) 5>&1 2>&1 | eval $at_tee_pipe
   1675     at_status=`cat $at_status_file`
   1676     ;;
   1677 
   1678   8 ) # 8. input.at:393: Require 1.0
   1679     at_setup_line='input.at:393'
   1680     at_desc='Require 1.0'
   1681     $at_quiet $ECHO_N "  8: Require 1.0                                  $ECHO_C"
   1682     at_xfail=no
   1683     (
   1684       echo "8. input.at:393: testing ..."
   1685       $at_traceon
   1686 
   1687 cat >input.y <<'_ATEOF'
   1688 %{
   1689 #ifdef HAVE_CONFIG_H
   1690 # include <config.h>
   1691   /* We don't need perfect functions for these tests. */
   1692 # undef malloc
   1693 # undef memcmp
   1694 # undef realloc
   1695 #endif
   1696 %}
   1697 
   1698 %require "1.0";
   1699 %%
   1700 empty_file:;
   1701 _ATEOF
   1702 
   1703 
   1704 $at_traceoff
   1705 echo "input.at:393: bison -o input.c input.y"
   1706 echo input.at:393 >$at_check_line_file
   1707 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   1708 at_status=$?
   1709 grep '^ *+' $at_stder1 >&2
   1710 grep -v '^ *+' $at_stder1 >$at_stderr
   1711 at_failed=false
   1712 echo stderr:; cat $at_stderr
   1713 $at_diff $at_devnull $at_stdout || at_failed=:
   1714 case $at_status in
   1715    77) echo 77 > $at_status_file
   1716             exit 77;;
   1717    0) ;;
   1718    *) echo "input.at:393: exit code was $at_status, expected 0"
   1719       at_failed=:;;
   1720 esac
   1721 if $at_failed; then
   1722 
   1723   echo 1 > $at_status_file
   1724   exit 1
   1725 fi
   1726 
   1727 $at_traceon
   1728 
   1729       $at_traceoff
   1730       $at_times_p && times >$at_times_file
   1731     ) 5>&1 2>&1 | eval $at_tee_pipe
   1732     at_status=`cat $at_status_file`
   1733     ;;
   1734 
   1735   9 ) # 9. input.at:394: Require 2.3
   1736     at_setup_line='input.at:394'
   1737     at_desc='Require 2.3'
   1738     $at_quiet $ECHO_N "  9: Require 2.3                                  $ECHO_C"
   1739     at_xfail=no
   1740     (
   1741       echo "9. input.at:394: testing ..."
   1742       $at_traceon
   1743 
   1744 cat >input.y <<'_ATEOF'
   1745 %{
   1746 #ifdef HAVE_CONFIG_H
   1747 # include <config.h>
   1748   /* We don't need perfect functions for these tests. */
   1749 # undef malloc
   1750 # undef memcmp
   1751 # undef realloc
   1752 #endif
   1753 %}
   1754 
   1755 %require "2.3";
   1756 %%
   1757 empty_file:;
   1758 _ATEOF
   1759 
   1760 
   1761 $at_traceoff
   1762 echo "input.at:394: bison -o input.c input.y"
   1763 echo input.at:394 >$at_check_line_file
   1764 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   1765 at_status=$?
   1766 grep '^ *+' $at_stder1 >&2
   1767 grep -v '^ *+' $at_stder1 >$at_stderr
   1768 at_failed=false
   1769 echo stderr:; cat $at_stderr
   1770 $at_diff $at_devnull $at_stdout || at_failed=:
   1771 case $at_status in
   1772    77) echo 77 > $at_status_file
   1773             exit 77;;
   1774    0) ;;
   1775    *) echo "input.at:394: exit code was $at_status, expected 0"
   1776       at_failed=:;;
   1777 esac
   1778 if $at_failed; then
   1779 
   1780   echo 1 > $at_status_file
   1781   exit 1
   1782 fi
   1783 
   1784 $at_traceon
   1785 
   1786       $at_traceoff
   1787       $at_times_p && times >$at_times_file
   1788     ) 5>&1 2>&1 | eval $at_tee_pipe
   1789     at_status=`cat $at_status_file`
   1790     ;;
   1791 
   1792   10 ) # 10. input.at:396: Require 100.0
   1793     at_setup_line='input.at:396'
   1794     at_desc='Require 100.0'
   1795     $at_quiet $ECHO_N " 10: Require 100.0                                $ECHO_C"
   1796     at_xfail=no
   1797     (
   1798       echo "10. input.at:396: testing ..."
   1799       $at_traceon
   1800 
   1801 cat >input.y <<'_ATEOF'
   1802 %{
   1803 #ifdef HAVE_CONFIG_H
   1804 # include <config.h>
   1805   /* We don't need perfect functions for these tests. */
   1806 # undef malloc
   1807 # undef memcmp
   1808 # undef realloc
   1809 #endif
   1810 %}
   1811 
   1812 %require "100.0";
   1813 %%
   1814 empty_file:;
   1815 _ATEOF
   1816 
   1817 
   1818 $at_traceoff
   1819 echo "input.at:396: bison -o input.c input.y"
   1820 echo input.at:396 >$at_check_line_file
   1821 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   1822 at_status=$?
   1823 grep '^ *+' $at_stder1 >&2
   1824 grep -v '^ *+' $at_stder1 >$at_stderr
   1825 at_failed=false
   1826 echo stderr:; cat $at_stderr
   1827 $at_diff $at_devnull $at_stdout || at_failed=:
   1828 case $at_status in
   1829    77) echo 77 > $at_status_file
   1830             exit 77;;
   1831    63) ;;
   1832    *) echo "input.at:396: exit code was $at_status, expected 63"
   1833       at_failed=:;;
   1834 esac
   1835 if $at_failed; then
   1836 
   1837   echo 1 > $at_status_file
   1838   exit 1
   1839 fi
   1840 
   1841 $at_traceon
   1842 
   1843       $at_traceoff
   1844       $at_times_p && times >$at_times_file
   1845     ) 5>&1 2>&1 | eval $at_tee_pipe
   1846     at_status=`cat $at_status_file`
   1847     ;;
   1848 
   1849 
   1850   banner-2 ) # Banner 2. output.at:19
   1851     cat <<\_ATEOF
   1852 
   1853 Output file names.
   1854 
   1855 _ATEOF
   1856     ;;
   1857 
   1858   11 ) # 11. output.at:43: Output files:  -dv
   1859     at_setup_line='output.at:43'
   1860     at_desc='Output files:  -dv '
   1861     $at_quiet $ECHO_N " 11: Output files:  -dv                           $ECHO_C"
   1862     at_xfail=no
   1863     (
   1864       echo "11. output.at:43: testing ..."
   1865       $at_traceon
   1866 
   1867 case "foo.y" in
   1868   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   1869 esac
   1870 cat >foo.y <<'_ATEOF'
   1871 
   1872 %%
   1873 foo: {};
   1874 _ATEOF
   1875 
   1876 
   1877 $at_traceoff
   1878 echo "output.at:43: bison -dv foo.y "
   1879 echo output.at:43 >$at_check_line_file
   1880 ( $at_traceon; bison -dv foo.y  ) >$at_stdout 2>$at_stder1
   1881 at_status=$?
   1882 grep '^ *+' $at_stder1 >&2
   1883 grep -v '^ *+' $at_stder1 >$at_stderr
   1884 at_failed=false
   1885 $at_diff $at_devnull $at_stderr || at_failed=:
   1886 $at_diff $at_devnull $at_stdout || at_failed=:
   1887 case $at_status in
   1888    77) echo 77 > $at_status_file
   1889             exit 77;;
   1890    0) ;;
   1891    *) echo "output.at:43: exit code was $at_status, expected 0"
   1892       at_failed=:;;
   1893 esac
   1894 if $at_failed; then
   1895 
   1896   echo 1 > $at_status_file
   1897   exit 1
   1898 fi
   1899 
   1900 $at_traceon
   1901 
   1902 $at_traceoff
   1903 echo "output.at:43: ls foo.output foo.tab.c foo.tab.h"
   1904 echo output.at:43 >$at_check_line_file
   1905 ( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
   1906 at_status=$?
   1907 grep '^ *+' $at_stder1 >&2
   1908 grep -v '^ *+' $at_stder1 >$at_stderr
   1909 at_failed=false
   1910 $at_diff $at_devnull $at_stderr || at_failed=:
   1911 echo stdout:; cat $at_stdout
   1912 case $at_status in
   1913    77) echo 77 > $at_status_file
   1914             exit 77;;
   1915    0) ;;
   1916    *) echo "output.at:43: exit code was $at_status, expected 0"
   1917       at_failed=:;;
   1918 esac
   1919 if $at_failed; then
   1920 
   1921   echo 1 > $at_status_file
   1922   exit 1
   1923 fi
   1924 
   1925 $at_traceon
   1926 
   1927 
   1928       $at_traceoff
   1929       $at_times_p && times >$at_times_file
   1930     ) 5>&1 2>&1 | eval $at_tee_pipe
   1931     at_status=`cat $at_status_file`
   1932     ;;
   1933 
   1934   12 ) # 12. output.at:46: Output files:  -dv >&-
   1935     at_setup_line='output.at:46'
   1936     at_desc='Output files:  -dv >&-'
   1937     $at_quiet $ECHO_N " 12: Output files:  -dv >&-                       $ECHO_C"
   1938     at_xfail=no
   1939     (
   1940       echo "12. output.at:46: testing ..."
   1941       $at_traceon
   1942 
   1943 case "foo.y" in
   1944   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   1945 esac
   1946 cat >foo.y <<'_ATEOF'
   1947 
   1948 %%
   1949 foo: {};
   1950 _ATEOF
   1951 
   1952 
   1953 $at_traceoff
   1954 echo "output.at:46: bison -dv foo.y >&-"
   1955 echo output.at:46 >$at_check_line_file
   1956 ( $at_traceon; bison -dv foo.y >&- ) >$at_stdout 2>$at_stder1
   1957 at_status=$?
   1958 grep '^ *+' $at_stder1 >&2
   1959 grep -v '^ *+' $at_stder1 >$at_stderr
   1960 at_failed=false
   1961 $at_diff $at_devnull $at_stderr || at_failed=:
   1962 $at_diff $at_devnull $at_stdout || at_failed=:
   1963 case $at_status in
   1964    77) echo 77 > $at_status_file
   1965             exit 77;;
   1966    0) ;;
   1967    *) echo "output.at:46: exit code was $at_status, expected 0"
   1968       at_failed=:;;
   1969 esac
   1970 if $at_failed; then
   1971 
   1972   echo 1 > $at_status_file
   1973   exit 1
   1974 fi
   1975 
   1976 $at_traceon
   1977 
   1978 $at_traceoff
   1979 echo "output.at:46: ls foo.output foo.tab.c foo.tab.h"
   1980 echo output.at:46 >$at_check_line_file
   1981 ( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
   1982 at_status=$?
   1983 grep '^ *+' $at_stder1 >&2
   1984 grep -v '^ *+' $at_stder1 >$at_stderr
   1985 at_failed=false
   1986 $at_diff $at_devnull $at_stderr || at_failed=:
   1987 echo stdout:; cat $at_stdout
   1988 case $at_status in
   1989    77) echo 77 > $at_status_file
   1990             exit 77;;
   1991    0) ;;
   1992    *) echo "output.at:46: exit code was $at_status, expected 0"
   1993       at_failed=:;;
   1994 esac
   1995 if $at_failed; then
   1996 
   1997   echo 1 > $at_status_file
   1998   exit 1
   1999 fi
   2000 
   2001 $at_traceon
   2002 
   2003 
   2004       $at_traceoff
   2005       $at_times_p && times >$at_times_file
   2006     ) 5>&1 2>&1 | eval $at_tee_pipe
   2007     at_status=`cat $at_status_file`
   2008     ;;
   2009 
   2010   13 ) # 13. output.at:48: Output files:  -dv -o foo.c
   2011     at_setup_line='output.at:48'
   2012     at_desc='Output files:  -dv -o foo.c '
   2013     $at_quiet $ECHO_N " 13: Output files:  -dv -o foo.c                  $ECHO_C"
   2014     at_xfail=no
   2015     (
   2016       echo "13. output.at:48: testing ..."
   2017       $at_traceon
   2018 
   2019 case "foo.y" in
   2020   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2021 esac
   2022 cat >foo.y <<'_ATEOF'
   2023 
   2024 %%
   2025 foo: {};
   2026 _ATEOF
   2027 
   2028 
   2029 $at_traceoff
   2030 echo "output.at:48: bison -dv -o foo.c foo.y "
   2031 echo output.at:48 >$at_check_line_file
   2032 ( $at_traceon; bison -dv -o foo.c foo.y  ) >$at_stdout 2>$at_stder1
   2033 at_status=$?
   2034 grep '^ *+' $at_stder1 >&2
   2035 grep -v '^ *+' $at_stder1 >$at_stderr
   2036 at_failed=false
   2037 $at_diff $at_devnull $at_stderr || at_failed=:
   2038 $at_diff $at_devnull $at_stdout || at_failed=:
   2039 case $at_status in
   2040    77) echo 77 > $at_status_file
   2041             exit 77;;
   2042    0) ;;
   2043    *) echo "output.at:48: exit code was $at_status, expected 0"
   2044       at_failed=:;;
   2045 esac
   2046 if $at_failed; then
   2047 
   2048   echo 1 > $at_status_file
   2049   exit 1
   2050 fi
   2051 
   2052 $at_traceon
   2053 
   2054 $at_traceoff
   2055 echo "output.at:48: ls foo.c foo.h foo.output"
   2056 echo output.at:48 >$at_check_line_file
   2057 ( $at_traceon; ls foo.c foo.h foo.output ) >$at_stdout 2>$at_stder1
   2058 at_status=$?
   2059 grep '^ *+' $at_stder1 >&2
   2060 grep -v '^ *+' $at_stder1 >$at_stderr
   2061 at_failed=false
   2062 $at_diff $at_devnull $at_stderr || at_failed=:
   2063 echo stdout:; cat $at_stdout
   2064 case $at_status in
   2065    77) echo 77 > $at_status_file
   2066             exit 77;;
   2067    0) ;;
   2068    *) echo "output.at:48: exit code was $at_status, expected 0"
   2069       at_failed=:;;
   2070 esac
   2071 if $at_failed; then
   2072 
   2073   echo 1 > $at_status_file
   2074   exit 1
   2075 fi
   2076 
   2077 $at_traceon
   2078 
   2079 
   2080       $at_traceoff
   2081       $at_times_p && times >$at_times_file
   2082     ) 5>&1 2>&1 | eval $at_tee_pipe
   2083     at_status=`cat $at_status_file`
   2084     ;;
   2085 
   2086   14 ) # 14. output.at:50: Output files:  -dv -o foo.tab.c
   2087     at_setup_line='output.at:50'
   2088     at_desc='Output files:  -dv -o foo.tab.c '
   2089     $at_quiet $ECHO_N " 14: Output files:  -dv -o foo.tab.c              $ECHO_C"
   2090     at_xfail=no
   2091     (
   2092       echo "14. output.at:50: testing ..."
   2093       $at_traceon
   2094 
   2095 case "foo.y" in
   2096   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2097 esac
   2098 cat >foo.y <<'_ATEOF'
   2099 
   2100 %%
   2101 foo: {};
   2102 _ATEOF
   2103 
   2104 
   2105 $at_traceoff
   2106 echo "output.at:50: bison -dv -o foo.tab.c foo.y "
   2107 echo output.at:50 >$at_check_line_file
   2108 ( $at_traceon; bison -dv -o foo.tab.c foo.y  ) >$at_stdout 2>$at_stder1
   2109 at_status=$?
   2110 grep '^ *+' $at_stder1 >&2
   2111 grep -v '^ *+' $at_stder1 >$at_stderr
   2112 at_failed=false
   2113 $at_diff $at_devnull $at_stderr || at_failed=:
   2114 $at_diff $at_devnull $at_stdout || at_failed=:
   2115 case $at_status in
   2116    77) echo 77 > $at_status_file
   2117             exit 77;;
   2118    0) ;;
   2119    *) echo "output.at:50: exit code was $at_status, expected 0"
   2120       at_failed=:;;
   2121 esac
   2122 if $at_failed; then
   2123 
   2124   echo 1 > $at_status_file
   2125   exit 1
   2126 fi
   2127 
   2128 $at_traceon
   2129 
   2130 $at_traceoff
   2131 echo "output.at:50: ls foo.output foo.tab.c foo.tab.h"
   2132 echo output.at:50 >$at_check_line_file
   2133 ( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
   2134 at_status=$?
   2135 grep '^ *+' $at_stder1 >&2
   2136 grep -v '^ *+' $at_stder1 >$at_stderr
   2137 at_failed=false
   2138 $at_diff $at_devnull $at_stderr || at_failed=:
   2139 echo stdout:; cat $at_stdout
   2140 case $at_status in
   2141    77) echo 77 > $at_status_file
   2142             exit 77;;
   2143    0) ;;
   2144    *) echo "output.at:50: exit code was $at_status, expected 0"
   2145       at_failed=:;;
   2146 esac
   2147 if $at_failed; then
   2148 
   2149   echo 1 > $at_status_file
   2150   exit 1
   2151 fi
   2152 
   2153 $at_traceon
   2154 
   2155 
   2156       $at_traceoff
   2157       $at_times_p && times >$at_times_file
   2158     ) 5>&1 2>&1 | eval $at_tee_pipe
   2159     at_status=`cat $at_status_file`
   2160     ;;
   2161 
   2162   15 ) # 15. output.at:52: Output files:  -dv -y
   2163     at_setup_line='output.at:52'
   2164     at_desc='Output files:  -dv -y '
   2165     $at_quiet $ECHO_N " 15: Output files:  -dv -y                        $ECHO_C"
   2166     at_xfail=no
   2167     (
   2168       echo "15. output.at:52: testing ..."
   2169       $at_traceon
   2170 
   2171 case "foo.y" in
   2172   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2173 esac
   2174 cat >foo.y <<'_ATEOF'
   2175 
   2176 %%
   2177 foo: {};
   2178 _ATEOF
   2179 
   2180 
   2181 $at_traceoff
   2182 echo "output.at:52: bison -dv -y foo.y "
   2183 echo output.at:52 >$at_check_line_file
   2184 ( $at_traceon; bison -dv -y foo.y  ) >$at_stdout 2>$at_stder1
   2185 at_status=$?
   2186 grep '^ *+' $at_stder1 >&2
   2187 grep -v '^ *+' $at_stder1 >$at_stderr
   2188 at_failed=false
   2189 $at_diff $at_devnull $at_stderr || at_failed=:
   2190 $at_diff $at_devnull $at_stdout || at_failed=:
   2191 case $at_status in
   2192    77) echo 77 > $at_status_file
   2193             exit 77;;
   2194    0) ;;
   2195    *) echo "output.at:52: exit code was $at_status, expected 0"
   2196       at_failed=:;;
   2197 esac
   2198 if $at_failed; then
   2199 
   2200   echo 1 > $at_status_file
   2201   exit 1
   2202 fi
   2203 
   2204 $at_traceon
   2205 
   2206 $at_traceoff
   2207 echo "output.at:52: ls y.output y.tab.c y.tab.h"
   2208 echo output.at:52 >$at_check_line_file
   2209 ( $at_traceon; ls y.output y.tab.c y.tab.h ) >$at_stdout 2>$at_stder1
   2210 at_status=$?
   2211 grep '^ *+' $at_stder1 >&2
   2212 grep -v '^ *+' $at_stder1 >$at_stderr
   2213 at_failed=false
   2214 $at_diff $at_devnull $at_stderr || at_failed=:
   2215 echo stdout:; cat $at_stdout
   2216 case $at_status in
   2217    77) echo 77 > $at_status_file
   2218             exit 77;;
   2219    0) ;;
   2220    *) echo "output.at:52: exit code was $at_status, expected 0"
   2221       at_failed=:;;
   2222 esac
   2223 if $at_failed; then
   2224 
   2225   echo 1 > $at_status_file
   2226   exit 1
   2227 fi
   2228 
   2229 $at_traceon
   2230 
   2231 
   2232       $at_traceoff
   2233       $at_times_p && times >$at_times_file
   2234     ) 5>&1 2>&1 | eval $at_tee_pipe
   2235     at_status=`cat $at_status_file`
   2236     ;;
   2237 
   2238   16 ) # 16. output.at:54: Output files:  -dv -b bar
   2239     at_setup_line='output.at:54'
   2240     at_desc='Output files:  -dv -b bar '
   2241     $at_quiet $ECHO_N " 16: Output files:  -dv -b bar                    $ECHO_C"
   2242     at_xfail=no
   2243     (
   2244       echo "16. output.at:54: testing ..."
   2245       $at_traceon
   2246 
   2247 case "foo.y" in
   2248   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2249 esac
   2250 cat >foo.y <<'_ATEOF'
   2251 
   2252 %%
   2253 foo: {};
   2254 _ATEOF
   2255 
   2256 
   2257 $at_traceoff
   2258 echo "output.at:54: bison -dv -b bar foo.y "
   2259 echo output.at:54 >$at_check_line_file
   2260 ( $at_traceon; bison -dv -b bar foo.y  ) >$at_stdout 2>$at_stder1
   2261 at_status=$?
   2262 grep '^ *+' $at_stder1 >&2
   2263 grep -v '^ *+' $at_stder1 >$at_stderr
   2264 at_failed=false
   2265 $at_diff $at_devnull $at_stderr || at_failed=:
   2266 $at_diff $at_devnull $at_stdout || at_failed=:
   2267 case $at_status in
   2268    77) echo 77 > $at_status_file
   2269             exit 77;;
   2270    0) ;;
   2271    *) echo "output.at:54: exit code was $at_status, expected 0"
   2272       at_failed=:;;
   2273 esac
   2274 if $at_failed; then
   2275 
   2276   echo 1 > $at_status_file
   2277   exit 1
   2278 fi
   2279 
   2280 $at_traceon
   2281 
   2282 $at_traceoff
   2283 echo "output.at:54: ls bar.output bar.tab.c bar.tab.h"
   2284 echo output.at:54 >$at_check_line_file
   2285 ( $at_traceon; ls bar.output bar.tab.c bar.tab.h ) >$at_stdout 2>$at_stder1
   2286 at_status=$?
   2287 grep '^ *+' $at_stder1 >&2
   2288 grep -v '^ *+' $at_stder1 >$at_stderr
   2289 at_failed=false
   2290 $at_diff $at_devnull $at_stderr || at_failed=:
   2291 echo stdout:; cat $at_stdout
   2292 case $at_status in
   2293    77) echo 77 > $at_status_file
   2294             exit 77;;
   2295    0) ;;
   2296    *) echo "output.at:54: exit code was $at_status, expected 0"
   2297       at_failed=:;;
   2298 esac
   2299 if $at_failed; then
   2300 
   2301   echo 1 > $at_status_file
   2302   exit 1
   2303 fi
   2304 
   2305 $at_traceon
   2306 
   2307 
   2308       $at_traceoff
   2309       $at_times_p && times >$at_times_file
   2310     ) 5>&1 2>&1 | eval $at_tee_pipe
   2311     at_status=`cat $at_status_file`
   2312     ;;
   2313 
   2314   17 ) # 17. output.at:56: Output files:  -dv -g -o foo.c
   2315     at_setup_line='output.at:56'
   2316     at_desc='Output files:  -dv -g -o foo.c '
   2317     $at_quiet $ECHO_N " 17: Output files:  -dv -g -o foo.c               $ECHO_C"
   2318     at_xfail=no
   2319     (
   2320       echo "17. output.at:56: testing ..."
   2321       $at_traceon
   2322 
   2323 case "foo.y" in
   2324   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2325 esac
   2326 cat >foo.y <<'_ATEOF'
   2327 
   2328 %%
   2329 foo: {};
   2330 _ATEOF
   2331 
   2332 
   2333 $at_traceoff
   2334 echo "output.at:56: bison -dv -g -o foo.c foo.y "
   2335 echo output.at:56 >$at_check_line_file
   2336 ( $at_traceon; bison -dv -g -o foo.c foo.y  ) >$at_stdout 2>$at_stder1
   2337 at_status=$?
   2338 grep '^ *+' $at_stder1 >&2
   2339 grep -v '^ *+' $at_stder1 >$at_stderr
   2340 at_failed=false
   2341 $at_diff $at_devnull $at_stderr || at_failed=:
   2342 $at_diff $at_devnull $at_stdout || at_failed=:
   2343 case $at_status in
   2344    77) echo 77 > $at_status_file
   2345             exit 77;;
   2346    0) ;;
   2347    *) echo "output.at:56: exit code was $at_status, expected 0"
   2348       at_failed=:;;
   2349 esac
   2350 if $at_failed; then
   2351 
   2352   echo 1 > $at_status_file
   2353   exit 1
   2354 fi
   2355 
   2356 $at_traceon
   2357 
   2358 $at_traceoff
   2359 echo "output.at:56: ls foo.c foo.h foo.output foo.vcg"
   2360 echo output.at:56 >$at_check_line_file
   2361 ( $at_traceon; ls foo.c foo.h foo.output foo.vcg ) >$at_stdout 2>$at_stder1
   2362 at_status=$?
   2363 grep '^ *+' $at_stder1 >&2
   2364 grep -v '^ *+' $at_stder1 >$at_stderr
   2365 at_failed=false
   2366 $at_diff $at_devnull $at_stderr || at_failed=:
   2367 echo stdout:; cat $at_stdout
   2368 case $at_status in
   2369    77) echo 77 > $at_status_file
   2370             exit 77;;
   2371    0) ;;
   2372    *) echo "output.at:56: exit code was $at_status, expected 0"
   2373       at_failed=:;;
   2374 esac
   2375 if $at_failed; then
   2376 
   2377   echo 1 > $at_status_file
   2378   exit 1
   2379 fi
   2380 
   2381 $at_traceon
   2382 
   2383 
   2384       $at_traceoff
   2385       $at_times_p && times >$at_times_file
   2386     ) 5>&1 2>&1 | eval $at_tee_pipe
   2387     at_status=`cat $at_status_file`
   2388     ;;
   2389 
   2390   18 ) # 18. output.at:60: Output files: %defines %verbose
   2391     at_setup_line='output.at:60'
   2392     at_desc='Output files: %defines %verbose  '
   2393     $at_quiet $ECHO_N " 18: Output files: %defines %verbose              $ECHO_C"
   2394     at_xfail=no
   2395     (
   2396       echo "18. output.at:60: testing ..."
   2397       $at_traceon
   2398 
   2399 case "foo.y" in
   2400   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2401 esac
   2402 cat >foo.y <<'_ATEOF'
   2403 %defines %verbose
   2404 %%
   2405 foo: {};
   2406 _ATEOF
   2407 
   2408 
   2409 $at_traceoff
   2410 echo "output.at:60: bison  foo.y "
   2411 echo output.at:60 >$at_check_line_file
   2412 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2413 at_status=$?
   2414 grep '^ *+' $at_stder1 >&2
   2415 grep -v '^ *+' $at_stder1 >$at_stderr
   2416 at_failed=false
   2417 $at_diff $at_devnull $at_stderr || at_failed=:
   2418 $at_diff $at_devnull $at_stdout || at_failed=:
   2419 case $at_status in
   2420    77) echo 77 > $at_status_file
   2421             exit 77;;
   2422    0) ;;
   2423    *) echo "output.at:60: exit code was $at_status, expected 0"
   2424       at_failed=:;;
   2425 esac
   2426 if $at_failed; then
   2427 
   2428   echo 1 > $at_status_file
   2429   exit 1
   2430 fi
   2431 
   2432 $at_traceon
   2433 
   2434 $at_traceoff
   2435 echo "output.at:60: ls foo.output foo.tab.c foo.tab.h"
   2436 echo output.at:60 >$at_check_line_file
   2437 ( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
   2438 at_status=$?
   2439 grep '^ *+' $at_stder1 >&2
   2440 grep -v '^ *+' $at_stder1 >$at_stderr
   2441 at_failed=false
   2442 $at_diff $at_devnull $at_stderr || at_failed=:
   2443 echo stdout:; cat $at_stdout
   2444 case $at_status in
   2445    77) echo 77 > $at_status_file
   2446             exit 77;;
   2447    0) ;;
   2448    *) echo "output.at:60: exit code was $at_status, expected 0"
   2449       at_failed=:;;
   2450 esac
   2451 if $at_failed; then
   2452 
   2453   echo 1 > $at_status_file
   2454   exit 1
   2455 fi
   2456 
   2457 $at_traceon
   2458 
   2459 
   2460       $at_traceoff
   2461       $at_times_p && times >$at_times_file
   2462     ) 5>&1 2>&1 | eval $at_tee_pipe
   2463     at_status=`cat $at_status_file`
   2464     ;;
   2465 
   2466   19 ) # 19. output.at:62: Output files: %defines %verbose %yacc
   2467     at_setup_line='output.at:62'
   2468     at_desc='Output files: %defines %verbose %yacc  '
   2469     $at_quiet $ECHO_N " 19: Output files: %defines %verbose %yacc        $ECHO_C"
   2470     at_xfail=no
   2471     (
   2472       echo "19. output.at:62: testing ..."
   2473       $at_traceon
   2474 
   2475 case "foo.y" in
   2476   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2477 esac
   2478 cat >foo.y <<'_ATEOF'
   2479 %defines %verbose %yacc
   2480 %%
   2481 foo: {};
   2482 _ATEOF
   2483 
   2484 
   2485 $at_traceoff
   2486 echo "output.at:62: bison  foo.y "
   2487 echo output.at:62 >$at_check_line_file
   2488 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2489 at_status=$?
   2490 grep '^ *+' $at_stder1 >&2
   2491 grep -v '^ *+' $at_stder1 >$at_stderr
   2492 at_failed=false
   2493 $at_diff $at_devnull $at_stderr || at_failed=:
   2494 $at_diff $at_devnull $at_stdout || at_failed=:
   2495 case $at_status in
   2496    77) echo 77 > $at_status_file
   2497             exit 77;;
   2498    0) ;;
   2499    *) echo "output.at:62: exit code was $at_status, expected 0"
   2500       at_failed=:;;
   2501 esac
   2502 if $at_failed; then
   2503 
   2504   echo 1 > $at_status_file
   2505   exit 1
   2506 fi
   2507 
   2508 $at_traceon
   2509 
   2510 $at_traceoff
   2511 echo "output.at:62: ls y.output y.tab.c y.tab.h"
   2512 echo output.at:62 >$at_check_line_file
   2513 ( $at_traceon; ls y.output y.tab.c y.tab.h ) >$at_stdout 2>$at_stder1
   2514 at_status=$?
   2515 grep '^ *+' $at_stder1 >&2
   2516 grep -v '^ *+' $at_stder1 >$at_stderr
   2517 at_failed=false
   2518 $at_diff $at_devnull $at_stderr || at_failed=:
   2519 echo stdout:; cat $at_stdout
   2520 case $at_status in
   2521    77) echo 77 > $at_status_file
   2522             exit 77;;
   2523    0) ;;
   2524    *) echo "output.at:62: exit code was $at_status, expected 0"
   2525       at_failed=:;;
   2526 esac
   2527 if $at_failed; then
   2528 
   2529   echo 1 > $at_status_file
   2530   exit 1
   2531 fi
   2532 
   2533 $at_traceon
   2534 
   2535 
   2536       $at_traceoff
   2537       $at_times_p && times >$at_times_file
   2538     ) 5>&1 2>&1 | eval $at_tee_pipe
   2539     at_status=`cat $at_status_file`
   2540     ;;
   2541 
   2542   20 ) # 20. output.at:65: Output files: %defines %verbose %yacc
   2543     at_setup_line='output.at:65'
   2544     at_desc='Output files: %defines %verbose %yacc  '
   2545     $at_quiet $ECHO_N " 20: Output files: %defines %verbose %yacc        $ECHO_C"
   2546     at_xfail=no
   2547     (
   2548       echo "20. output.at:65: testing ..."
   2549       $at_traceon
   2550 
   2551 case "foo.yy" in
   2552   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   2553 esac
   2554 cat >foo.yy <<'_ATEOF'
   2555 %defines %verbose %yacc
   2556 %%
   2557 foo: {};
   2558 _ATEOF
   2559 
   2560 
   2561 $at_traceoff
   2562 echo "output.at:65: bison  foo.yy "
   2563 echo output.at:65 >$at_check_line_file
   2564 ( $at_traceon; bison  foo.yy  ) >$at_stdout 2>$at_stder1
   2565 at_status=$?
   2566 grep '^ *+' $at_stder1 >&2
   2567 grep -v '^ *+' $at_stder1 >$at_stderr
   2568 at_failed=false
   2569 $at_diff $at_devnull $at_stderr || at_failed=:
   2570 $at_diff $at_devnull $at_stdout || at_failed=:
   2571 case $at_status in
   2572    77) echo 77 > $at_status_file
   2573             exit 77;;
   2574    0) ;;
   2575    *) echo "output.at:65: exit code was $at_status, expected 0"
   2576       at_failed=:;;
   2577 esac
   2578 if $at_failed; then
   2579 
   2580   echo 1 > $at_status_file
   2581   exit 1
   2582 fi
   2583 
   2584 $at_traceon
   2585 
   2586 $at_traceoff
   2587 echo "output.at:65: ls y.output y.tab.c y.tab.h"
   2588 echo output.at:65 >$at_check_line_file
   2589 ( $at_traceon; ls y.output y.tab.c y.tab.h ) >$at_stdout 2>$at_stder1
   2590 at_status=$?
   2591 grep '^ *+' $at_stder1 >&2
   2592 grep -v '^ *+' $at_stder1 >$at_stderr
   2593 at_failed=false
   2594 $at_diff $at_devnull $at_stderr || at_failed=:
   2595 echo stdout:; cat $at_stdout
   2596 case $at_status in
   2597    77) echo 77 > $at_status_file
   2598             exit 77;;
   2599    0) ;;
   2600    *) echo "output.at:65: exit code was $at_status, expected 0"
   2601       at_failed=:;;
   2602 esac
   2603 if $at_failed; then
   2604 
   2605   echo 1 > $at_status_file
   2606   exit 1
   2607 fi
   2608 
   2609 $at_traceon
   2610 
   2611 
   2612       $at_traceoff
   2613       $at_times_p && times >$at_times_file
   2614     ) 5>&1 2>&1 | eval $at_tee_pipe
   2615     at_status=`cat $at_status_file`
   2616     ;;
   2617 
   2618   21 ) # 21. output.at:69: Output files: %file-prefix="bar" %defines %verbose
   2619     at_setup_line='output.at:69'
   2620     at_desc='Output files: %file-prefix="bar" %defines %verbose  '
   2621     $at_quiet $ECHO_N " 21: Output files: %file-prefix="bar" %defines %verbose  $ECHO_C"
   2622     at_xfail=no
   2623     (
   2624       echo "21. output.at:69: testing ..."
   2625       $at_traceon
   2626 
   2627 case "foo.y" in
   2628   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2629 esac
   2630 cat >foo.y <<'_ATEOF'
   2631 %file-prefix="bar" %defines %verbose
   2632 %%
   2633 foo: {};
   2634 _ATEOF
   2635 
   2636 
   2637 $at_traceoff
   2638 echo "output.at:69: bison  foo.y "
   2639 echo output.at:69 >$at_check_line_file
   2640 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2641 at_status=$?
   2642 grep '^ *+' $at_stder1 >&2
   2643 grep -v '^ *+' $at_stder1 >$at_stderr
   2644 at_failed=false
   2645 $at_diff $at_devnull $at_stderr || at_failed=:
   2646 $at_diff $at_devnull $at_stdout || at_failed=:
   2647 case $at_status in
   2648    77) echo 77 > $at_status_file
   2649             exit 77;;
   2650    0) ;;
   2651    *) echo "output.at:69: exit code was $at_status, expected 0"
   2652       at_failed=:;;
   2653 esac
   2654 if $at_failed; then
   2655 
   2656   echo 1 > $at_status_file
   2657   exit 1
   2658 fi
   2659 
   2660 $at_traceon
   2661 
   2662 $at_traceoff
   2663 echo "output.at:69: ls bar.output bar.tab.c bar.tab.h"
   2664 echo output.at:69 >$at_check_line_file
   2665 ( $at_traceon; ls bar.output bar.tab.c bar.tab.h ) >$at_stdout 2>$at_stder1
   2666 at_status=$?
   2667 grep '^ *+' $at_stder1 >&2
   2668 grep -v '^ *+' $at_stder1 >$at_stderr
   2669 at_failed=false
   2670 $at_diff $at_devnull $at_stderr || at_failed=:
   2671 echo stdout:; cat $at_stdout
   2672 case $at_status in
   2673    77) echo 77 > $at_status_file
   2674             exit 77;;
   2675    0) ;;
   2676    *) echo "output.at:69: exit code was $at_status, expected 0"
   2677       at_failed=:;;
   2678 esac
   2679 if $at_failed; then
   2680 
   2681   echo 1 > $at_status_file
   2682   exit 1
   2683 fi
   2684 
   2685 $at_traceon
   2686 
   2687 
   2688       $at_traceoff
   2689       $at_times_p && times >$at_times_file
   2690     ) 5>&1 2>&1 | eval $at_tee_pipe
   2691     at_status=`cat $at_status_file`
   2692     ;;
   2693 
   2694   22 ) # 22. output.at:71: Output files: %output="bar.c" %defines %verbose %yacc
   2695     at_setup_line='output.at:71'
   2696     at_desc='Output files: %output="bar.c" %defines %verbose %yacc  '
   2697     $at_quiet $ECHO_N " 22: Output files: %output="bar.c" %defines %verbose %yacc  $ECHO_C"
   2698     at_xfail=no
   2699     (
   2700       echo "22. output.at:71: testing ..."
   2701       $at_traceon
   2702 
   2703 case "foo.y" in
   2704   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2705 esac
   2706 cat >foo.y <<'_ATEOF'
   2707 %output="bar.c" %defines %verbose %yacc
   2708 %%
   2709 foo: {};
   2710 _ATEOF
   2711 
   2712 
   2713 $at_traceoff
   2714 echo "output.at:71: bison  foo.y "
   2715 echo output.at:71 >$at_check_line_file
   2716 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2717 at_status=$?
   2718 grep '^ *+' $at_stder1 >&2
   2719 grep -v '^ *+' $at_stder1 >$at_stderr
   2720 at_failed=false
   2721 $at_diff $at_devnull $at_stderr || at_failed=:
   2722 $at_diff $at_devnull $at_stdout || at_failed=:
   2723 case $at_status in
   2724    77) echo 77 > $at_status_file
   2725             exit 77;;
   2726    0) ;;
   2727    *) echo "output.at:71: exit code was $at_status, expected 0"
   2728       at_failed=:;;
   2729 esac
   2730 if $at_failed; then
   2731 
   2732   echo 1 > $at_status_file
   2733   exit 1
   2734 fi
   2735 
   2736 $at_traceon
   2737 
   2738 $at_traceoff
   2739 echo "output.at:71: ls bar.output bar.c bar.h"
   2740 echo output.at:71 >$at_check_line_file
   2741 ( $at_traceon; ls bar.output bar.c bar.h ) >$at_stdout 2>$at_stder1
   2742 at_status=$?
   2743 grep '^ *+' $at_stder1 >&2
   2744 grep -v '^ *+' $at_stder1 >$at_stderr
   2745 at_failed=false
   2746 $at_diff $at_devnull $at_stderr || at_failed=:
   2747 echo stdout:; cat $at_stdout
   2748 case $at_status in
   2749    77) echo 77 > $at_status_file
   2750             exit 77;;
   2751    0) ;;
   2752    *) echo "output.at:71: exit code was $at_status, expected 0"
   2753       at_failed=:;;
   2754 esac
   2755 if $at_failed; then
   2756 
   2757   echo 1 > $at_status_file
   2758   exit 1
   2759 fi
   2760 
   2761 $at_traceon
   2762 
   2763 
   2764       $at_traceoff
   2765       $at_times_p && times >$at_times_file
   2766     ) 5>&1 2>&1 | eval $at_tee_pipe
   2767     at_status=`cat $at_status_file`
   2768     ;;
   2769 
   2770   23 ) # 23. output.at:75: Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc
   2771     at_setup_line='output.at:75'
   2772     at_desc='Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc  '
   2773     $at_quiet $ECHO_N " 23: Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc  $ECHO_C"
   2774     at_xfail=no
   2775     (
   2776       echo "23. output.at:75: testing ..."
   2777       $at_traceon
   2778 
   2779 case "foo.y" in
   2780   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2781 esac
   2782 cat >foo.y <<'_ATEOF'
   2783 %file-prefix="baz" %output="bar.c" %defines %verbose %yacc
   2784 %%
   2785 foo: {};
   2786 _ATEOF
   2787 
   2788 
   2789 $at_traceoff
   2790 echo "output.at:75: bison  foo.y "
   2791 echo output.at:75 >$at_check_line_file
   2792 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2793 at_status=$?
   2794 grep '^ *+' $at_stder1 >&2
   2795 grep -v '^ *+' $at_stder1 >$at_stderr
   2796 at_failed=false
   2797 $at_diff $at_devnull $at_stderr || at_failed=:
   2798 $at_diff $at_devnull $at_stdout || at_failed=:
   2799 case $at_status in
   2800    77) echo 77 > $at_status_file
   2801             exit 77;;
   2802    0) ;;
   2803    *) echo "output.at:75: exit code was $at_status, expected 0"
   2804       at_failed=:;;
   2805 esac
   2806 if $at_failed; then
   2807 
   2808   echo 1 > $at_status_file
   2809   exit 1
   2810 fi
   2811 
   2812 $at_traceon
   2813 
   2814 $at_traceoff
   2815 echo "output.at:75: ls bar.output bar.c bar.h"
   2816 echo output.at:75 >$at_check_line_file
   2817 ( $at_traceon; ls bar.output bar.c bar.h ) >$at_stdout 2>$at_stder1
   2818 at_status=$?
   2819 grep '^ *+' $at_stder1 >&2
   2820 grep -v '^ *+' $at_stder1 >$at_stderr
   2821 at_failed=false
   2822 $at_diff $at_devnull $at_stderr || at_failed=:
   2823 echo stdout:; cat $at_stdout
   2824 case $at_status in
   2825    77) echo 77 > $at_status_file
   2826             exit 77;;
   2827    0) ;;
   2828    *) echo "output.at:75: exit code was $at_status, expected 0"
   2829       at_failed=:;;
   2830 esac
   2831 if $at_failed; then
   2832 
   2833   echo 1 > $at_status_file
   2834   exit 1
   2835 fi
   2836 
   2837 $at_traceon
   2838 
   2839 
   2840       $at_traceoff
   2841       $at_times_p && times >$at_times_file
   2842     ) 5>&1 2>&1 | eval $at_tee_pipe
   2843     at_status=`cat $at_status_file`
   2844     ;;
   2845 
   2846   24 ) # 24. output.at:80: Output files: %defines %verbose
   2847     at_setup_line='output.at:80'
   2848     at_desc='Output files: %defines %verbose  '
   2849     $at_quiet $ECHO_N " 24: Output files: %defines %verbose              $ECHO_C"
   2850     at_xfail=no
   2851     (
   2852       echo "24. output.at:80: testing ..."
   2853       $at_traceon
   2854 
   2855 case "foo.yy" in
   2856   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   2857 esac
   2858 cat >foo.yy <<'_ATEOF'
   2859 %defines %verbose
   2860 %%
   2861 foo: {};
   2862 _ATEOF
   2863 
   2864 
   2865 $at_traceoff
   2866 echo "output.at:80: bison  foo.yy "
   2867 echo output.at:80 >$at_check_line_file
   2868 ( $at_traceon; bison  foo.yy  ) >$at_stdout 2>$at_stder1
   2869 at_status=$?
   2870 grep '^ *+' $at_stder1 >&2
   2871 grep -v '^ *+' $at_stder1 >$at_stderr
   2872 at_failed=false
   2873 $at_diff $at_devnull $at_stderr || at_failed=:
   2874 $at_diff $at_devnull $at_stdout || at_failed=:
   2875 case $at_status in
   2876    77) echo 77 > $at_status_file
   2877             exit 77;;
   2878    0) ;;
   2879    *) echo "output.at:80: exit code was $at_status, expected 0"
   2880       at_failed=:;;
   2881 esac
   2882 if $at_failed; then
   2883 
   2884   echo 1 > $at_status_file
   2885   exit 1
   2886 fi
   2887 
   2888 $at_traceon
   2889 
   2890 $at_traceoff
   2891 echo "output.at:80: ls foo.output foo.tab.cc foo.tab.hh"
   2892 echo output.at:80 >$at_check_line_file
   2893 ( $at_traceon; ls foo.output foo.tab.cc foo.tab.hh ) >$at_stdout 2>$at_stder1
   2894 at_status=$?
   2895 grep '^ *+' $at_stder1 >&2
   2896 grep -v '^ *+' $at_stder1 >$at_stderr
   2897 at_failed=false
   2898 $at_diff $at_devnull $at_stderr || at_failed=:
   2899 echo stdout:; cat $at_stdout
   2900 case $at_status in
   2901    77) echo 77 > $at_status_file
   2902             exit 77;;
   2903    0) ;;
   2904    *) echo "output.at:80: exit code was $at_status, expected 0"
   2905       at_failed=:;;
   2906 esac
   2907 if $at_failed; then
   2908 
   2909   echo 1 > $at_status_file
   2910   exit 1
   2911 fi
   2912 
   2913 $at_traceon
   2914 
   2915 
   2916       $at_traceoff
   2917       $at_times_p && times >$at_times_file
   2918     ) 5>&1 2>&1 | eval $at_tee_pipe
   2919     at_status=`cat $at_status_file`
   2920     ;;
   2921 
   2922   25 ) # 25. output.at:83: Output files: %defines %verbose  -o foo.c
   2923     at_setup_line='output.at:83'
   2924     at_desc='Output files: %defines %verbose  -o foo.c '
   2925     $at_quiet $ECHO_N " 25: Output files: %defines %verbose  -o foo.c    $ECHO_C"
   2926     at_xfail=no
   2927     (
   2928       echo "25. output.at:83: testing ..."
   2929       $at_traceon
   2930 
   2931 case "foo.yy" in
   2932   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   2933 esac
   2934 cat >foo.yy <<'_ATEOF'
   2935 %defines %verbose
   2936 %%
   2937 foo: {};
   2938 _ATEOF
   2939 
   2940 
   2941 $at_traceoff
   2942 echo "output.at:83: bison -o foo.c foo.yy "
   2943 echo output.at:83 >$at_check_line_file
   2944 ( $at_traceon; bison -o foo.c foo.yy  ) >$at_stdout 2>$at_stder1
   2945 at_status=$?
   2946 grep '^ *+' $at_stder1 >&2
   2947 grep -v '^ *+' $at_stder1 >$at_stderr
   2948 at_failed=false
   2949 $at_diff $at_devnull $at_stderr || at_failed=:
   2950 $at_diff $at_devnull $at_stdout || at_failed=:
   2951 case $at_status in
   2952    77) echo 77 > $at_status_file
   2953             exit 77;;
   2954    0) ;;
   2955    *) echo "output.at:83: exit code was $at_status, expected 0"
   2956       at_failed=:;;
   2957 esac
   2958 if $at_failed; then
   2959 
   2960   echo 1 > $at_status_file
   2961   exit 1
   2962 fi
   2963 
   2964 $at_traceon
   2965 
   2966 $at_traceoff
   2967 echo "output.at:83: ls foo.c foo.h foo.output"
   2968 echo output.at:83 >$at_check_line_file
   2969 ( $at_traceon; ls foo.c foo.h foo.output ) >$at_stdout 2>$at_stder1
   2970 at_status=$?
   2971 grep '^ *+' $at_stder1 >&2
   2972 grep -v '^ *+' $at_stder1 >$at_stderr
   2973 at_failed=false
   2974 $at_diff $at_devnull $at_stderr || at_failed=:
   2975 echo stdout:; cat $at_stdout
   2976 case $at_status in
   2977    77) echo 77 > $at_status_file
   2978             exit 77;;
   2979    0) ;;
   2980    *) echo "output.at:83: exit code was $at_status, expected 0"
   2981       at_failed=:;;
   2982 esac
   2983 if $at_failed; then
   2984 
   2985   echo 1 > $at_status_file
   2986   exit 1
   2987 fi
   2988 
   2989 $at_traceon
   2990 
   2991 
   2992       $at_traceoff
   2993       $at_times_p && times >$at_times_file
   2994     ) 5>&1 2>&1 | eval $at_tee_pipe
   2995     at_status=`cat $at_status_file`
   2996     ;;
   2997 
   2998   26 ) # 26. output.at:87: Output files:  --defines=foo.hpp -o foo.c++
   2999     at_setup_line='output.at:87'
   3000     at_desc='Output files:  --defines=foo.hpp -o foo.c++ '
   3001     $at_quiet $ECHO_N " 26: Output files:  --defines=foo.hpp -o foo.c++  $ECHO_C"
   3002     at_xfail=no
   3003     (
   3004       echo "26. output.at:87: testing ..."
   3005       $at_traceon
   3006 
   3007 case "foo.yy" in
   3008   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   3009 esac
   3010 cat >foo.yy <<'_ATEOF'
   3011 
   3012 %%
   3013 foo: {};
   3014 _ATEOF
   3015 
   3016 
   3017 $at_traceoff
   3018 echo "output.at:87: bison --defines=foo.hpp -o foo.c++ foo.yy "
   3019 echo output.at:87 >$at_check_line_file
   3020 ( $at_traceon; bison --defines=foo.hpp -o foo.c++ foo.yy  ) >$at_stdout 2>$at_stder1
   3021 at_status=$?
   3022 grep '^ *+' $at_stder1 >&2
   3023 grep -v '^ *+' $at_stder1 >$at_stderr
   3024 at_failed=false
   3025 $at_diff $at_devnull $at_stderr || at_failed=:
   3026 $at_diff $at_devnull $at_stdout || at_failed=:
   3027 case $at_status in
   3028    77) echo 77 > $at_status_file
   3029             exit 77;;
   3030    0) ;;
   3031    *) echo "output.at:87: exit code was $at_status, expected 0"
   3032       at_failed=:;;
   3033 esac
   3034 if $at_failed; then
   3035 
   3036   echo 1 > $at_status_file
   3037   exit 1
   3038 fi
   3039 
   3040 $at_traceon
   3041 
   3042 $at_traceoff
   3043 echo "output.at:87: ls foo.c++ foo.hpp"
   3044 echo output.at:87 >$at_check_line_file
   3045 ( $at_traceon; ls foo.c++ foo.hpp ) >$at_stdout 2>$at_stder1
   3046 at_status=$?
   3047 grep '^ *+' $at_stder1 >&2
   3048 grep -v '^ *+' $at_stder1 >$at_stderr
   3049 at_failed=false
   3050 $at_diff $at_devnull $at_stderr || at_failed=:
   3051 echo stdout:; cat $at_stdout
   3052 case $at_status in
   3053    77) echo 77 > $at_status_file
   3054             exit 77;;
   3055    0) ;;
   3056    *) echo "output.at:87: exit code was $at_status, expected 0"
   3057       at_failed=:;;
   3058 esac
   3059 if $at_failed; then
   3060 
   3061   echo 1 > $at_status_file
   3062   exit 1
   3063 fi
   3064 
   3065 $at_traceon
   3066 
   3067 
   3068       $at_traceoff
   3069       $at_times_p && times >$at_times_file
   3070     ) 5>&1 2>&1 | eval $at_tee_pipe
   3071     at_status=`cat $at_status_file`
   3072     ;;
   3073 
   3074   27 ) # 27. output.at:91: Output files:  -o foo.c++ --graph=foo.gph
   3075     at_setup_line='output.at:91'
   3076     at_desc='Output files:  -o foo.c++ --graph=foo.gph '
   3077     $at_quiet $ECHO_N " 27: Output files:  -o foo.c++ --graph=foo.gph    $ECHO_C"
   3078     at_xfail=no
   3079     (
   3080       echo "27. output.at:91: testing ..."
   3081       $at_traceon
   3082 
   3083 case "foo.yy" in
   3084   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   3085 esac
   3086 cat >foo.yy <<'_ATEOF'
   3087 
   3088 %%
   3089 foo: {};
   3090 _ATEOF
   3091 
   3092 
   3093 $at_traceoff
   3094 echo "output.at:91: bison -o foo.c++ --graph=foo.gph foo.yy "
   3095 echo output.at:91 >$at_check_line_file
   3096 ( $at_traceon; bison -o foo.c++ --graph=foo.gph foo.yy  ) >$at_stdout 2>$at_stder1
   3097 at_status=$?
   3098 grep '^ *+' $at_stder1 >&2
   3099 grep -v '^ *+' $at_stder1 >$at_stderr
   3100 at_failed=false
   3101 $at_diff $at_devnull $at_stderr || at_failed=:
   3102 $at_diff $at_devnull $at_stdout || at_failed=:
   3103 case $at_status in
   3104    77) echo 77 > $at_status_file
   3105             exit 77;;
   3106    0) ;;
   3107    *) echo "output.at:91: exit code was $at_status, expected 0"
   3108       at_failed=:;;
   3109 esac
   3110 if $at_failed; then
   3111 
   3112   echo 1 > $at_status_file
   3113   exit 1
   3114 fi
   3115 
   3116 $at_traceon
   3117 
   3118 $at_traceoff
   3119 echo "output.at:91: ls foo.c++ foo.gph"
   3120 echo output.at:91 >$at_check_line_file
   3121 ( $at_traceon; ls foo.c++ foo.gph ) >$at_stdout 2>$at_stder1
   3122 at_status=$?
   3123 grep '^ *+' $at_stder1 >&2
   3124 grep -v '^ *+' $at_stder1 >$at_stderr
   3125 at_failed=false
   3126 $at_diff $at_devnull $at_stderr || at_failed=:
   3127 echo stdout:; cat $at_stdout
   3128 case $at_status in
   3129    77) echo 77 > $at_status_file
   3130             exit 77;;
   3131    0) ;;
   3132    *) echo "output.at:91: exit code was $at_status, expected 0"
   3133       at_failed=:;;
   3134 esac
   3135 if $at_failed; then
   3136 
   3137   echo 1 > $at_status_file
   3138   exit 1
   3139 fi
   3140 
   3141 $at_traceon
   3142 
   3143 
   3144       $at_traceoff
   3145       $at_times_p && times >$at_times_file
   3146     ) 5>&1 2>&1 | eval $at_tee_pipe
   3147     at_status=`cat $at_status_file`
   3148     ;;
   3149 
   3150   28 ) # 28. output.at:105: Output files: %skeleton "lalr1.cc" %defines %verbose
   3151     at_setup_line='output.at:105'
   3152     at_desc='Output files: %skeleton "lalr1.cc" %defines %verbose  '
   3153     $at_quiet $ECHO_N " 28: Output files: %skeleton "lalr1.cc" %defines %verbose  $ECHO_C"
   3154     at_xfail=no
   3155     (
   3156       echo "28. output.at:105: testing ..."
   3157       $at_traceon
   3158 
   3159 case "foo.yy" in
   3160   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   3161 esac
   3162 cat >foo.yy <<'_ATEOF'
   3163 %skeleton "lalr1.cc" %defines %verbose
   3164 %%
   3165 foo: {};
   3166 _ATEOF
   3167 
   3168 
   3169 $at_traceoff
   3170 echo "output.at:105: bison  foo.yy "
   3171 echo output.at:105 >$at_check_line_file
   3172 ( $at_traceon; bison  foo.yy  ) >$at_stdout 2>$at_stder1
   3173 at_status=$?
   3174 grep '^ *+' $at_stder1 >&2
   3175 grep -v '^ *+' $at_stder1 >$at_stderr
   3176 at_failed=false
   3177 $at_diff $at_devnull $at_stderr || at_failed=:
   3178 $at_diff $at_devnull $at_stdout || at_failed=:
   3179 case $at_status in
   3180    77) echo 77 > $at_status_file
   3181             exit 77;;
   3182    0) ;;
   3183    *) echo "output.at:105: exit code was $at_status, expected 0"
   3184       at_failed=:;;
   3185 esac
   3186 if $at_failed; then
   3187 
   3188   echo 1 > $at_status_file
   3189   exit 1
   3190 fi
   3191 
   3192 $at_traceon
   3193 
   3194 $at_traceoff
   3195 echo "output.at:105: ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh"
   3196 echo output.at:105 >$at_check_line_file
   3197 ( $at_traceon; ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh ) >$at_stdout 2>$at_stder1
   3198 at_status=$?
   3199 grep '^ *+' $at_stder1 >&2
   3200 grep -v '^ *+' $at_stder1 >$at_stderr
   3201 at_failed=false
   3202 $at_diff $at_devnull $at_stderr || at_failed=:
   3203 echo stdout:; cat $at_stdout
   3204 case $at_status in
   3205    77) echo 77 > $at_status_file
   3206             exit 77;;
   3207    0) ;;
   3208    *) echo "output.at:105: exit code was $at_status, expected 0"
   3209       at_failed=:;;
   3210 esac
   3211 if $at_failed; then
   3212 
   3213   echo 1 > $at_status_file
   3214   exit 1
   3215 fi
   3216 
   3217 $at_traceon
   3218 
   3219 
   3220       $at_traceoff
   3221       $at_times_p && times >$at_times_file
   3222     ) 5>&1 2>&1 | eval $at_tee_pipe
   3223     at_status=`cat $at_status_file`
   3224     ;;
   3225 
   3226   29 ) # 29. output.at:109: Output files: %skeleton "lalr1.cc" %defines %verbose
   3227     at_setup_line='output.at:109'
   3228     at_desc='Output files: %skeleton "lalr1.cc" %defines %verbose  '
   3229     $at_quiet $ECHO_N " 29: Output files: %skeleton "lalr1.cc" %defines %verbose  $ECHO_C"
   3230     at_xfail=no
   3231     (
   3232       echo "29. output.at:109: testing ..."
   3233       $at_traceon
   3234 
   3235 case "subdir/foo.yy" in
   3236   */*) mkdir `echo "subdir/foo.yy" | sed 's,/.*,,'`;;
   3237 esac
   3238 cat >subdir/foo.yy <<'_ATEOF'
   3239 %skeleton "lalr1.cc" %defines %verbose
   3240 %%
   3241 foo: {};
   3242 _ATEOF
   3243 
   3244 
   3245 $at_traceoff
   3246 echo "output.at:109: bison  subdir/foo.yy "
   3247 echo output.at:109 >$at_check_line_file
   3248 ( $at_traceon; bison  subdir/foo.yy  ) >$at_stdout 2>$at_stder1
   3249 at_status=$?
   3250 grep '^ *+' $at_stder1 >&2
   3251 grep -v '^ *+' $at_stder1 >$at_stderr
   3252 at_failed=false
   3253 $at_diff $at_devnull $at_stderr || at_failed=:
   3254 $at_diff $at_devnull $at_stdout || at_failed=:
   3255 case $at_status in
   3256    77) echo 77 > $at_status_file
   3257             exit 77;;
   3258    0) ;;
   3259    *) echo "output.at:109: exit code was $at_status, expected 0"
   3260       at_failed=:;;
   3261 esac
   3262 if $at_failed; then
   3263 
   3264   echo 1 > $at_status_file
   3265   exit 1
   3266 fi
   3267 
   3268 $at_traceon
   3269 
   3270 $at_traceoff
   3271 echo "output.at:109: ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh"
   3272 echo output.at:109 >$at_check_line_file
   3273 ( $at_traceon; ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh ) >$at_stdout 2>$at_stder1
   3274 at_status=$?
   3275 grep '^ *+' $at_stder1 >&2
   3276 grep -v '^ *+' $at_stder1 >$at_stderr
   3277 at_failed=false
   3278 $at_diff $at_devnull $at_stderr || at_failed=:
   3279 echo stdout:; cat $at_stdout
   3280 case $at_status in
   3281    77) echo 77 > $at_status_file
   3282             exit 77;;
   3283    0) ;;
   3284    *) echo "output.at:109: exit code was $at_status, expected 0"
   3285       at_failed=:;;
   3286 esac
   3287 if $at_failed; then
   3288 
   3289   echo 1 > $at_status_file
   3290   exit 1
   3291 fi
   3292 
   3293 $at_traceon
   3294 
   3295 # Also make sure that the includes do not refer to the subdirectory.
   3296 $at_traceoff
   3297 echo "output.at:109: grep 'include .subdir/' foo.tab.cc"
   3298 echo output.at:109 >$at_check_line_file
   3299 ( $at_traceon; grep 'include .subdir/' foo.tab.cc ) >$at_stdout 2>$at_stder1
   3300 at_status=$?
   3301 grep '^ *+' $at_stder1 >&2
   3302 grep -v '^ *+' $at_stder1 >$at_stderr
   3303 at_failed=false
   3304 $at_diff $at_devnull $at_stderr || at_failed=:
   3305 $at_diff $at_devnull $at_stdout || at_failed=:
   3306 case $at_status in
   3307    77) echo 77 > $at_status_file
   3308             exit 77;;
   3309    1) ;;
   3310    *) echo "output.at:109: exit code was $at_status, expected 1"
   3311       at_failed=:;;
   3312 esac
   3313 if $at_failed; then
   3314 
   3315   echo 1 > $at_status_file
   3316   exit 1
   3317 fi
   3318 
   3319 $at_traceon
   3320 
   3321 $at_traceoff
   3322 echo "output.at:109: grep 'include .subdir/' foo.tab.hh"
   3323 echo output.at:109 >$at_check_line_file
   3324 ( $at_traceon; grep 'include .subdir/' foo.tab.hh ) >$at_stdout 2>$at_stder1
   3325 at_status=$?
   3326 grep '^ *+' $at_stder1 >&2
   3327 grep -v '^ *+' $at_stder1 >$at_stderr
   3328 at_failed=false
   3329 $at_diff $at_devnull $at_stderr || at_failed=:
   3330 $at_diff $at_devnull $at_stdout || at_failed=:
   3331 case $at_status in
   3332    77) echo 77 > $at_status_file
   3333             exit 77;;
   3334    1) ;;
   3335    *) echo "output.at:109: exit code was $at_status, expected 1"
   3336       at_failed=:;;
   3337 esac
   3338 if $at_failed; then
   3339 
   3340   echo 1 > $at_status_file
   3341   exit 1
   3342 fi
   3343 
   3344 $at_traceon
   3345 
   3346 
   3347       $at_traceoff
   3348       $at_times_p && times >$at_times_file
   3349     ) 5>&1 2>&1 | eval $at_tee_pipe
   3350     at_status=`cat $at_status_file`
   3351     ;;
   3352 
   3353   30 ) # 30. output.at:114: Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc
   3354     at_setup_line='output.at:114'
   3355     at_desc='Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc '
   3356     $at_quiet $ECHO_N " 30: Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc $ECHO_C"
   3357     at_xfail=no
   3358     (
   3359       echo "30. output.at:114: testing ..."
   3360       $at_traceon
   3361 
   3362 case "subdir/foo.yy" in
   3363   */*) mkdir `echo "subdir/foo.yy" | sed 's,/.*,,'`;;
   3364 esac
   3365 cat >subdir/foo.yy <<'_ATEOF'
   3366 %skeleton "lalr1.cc" %defines %verbose
   3367 %%
   3368 foo: {};
   3369 _ATEOF
   3370 
   3371 
   3372 $at_traceoff
   3373 echo "output.at:114: bison -o subdir/foo.cc subdir/foo.yy "
   3374 echo output.at:114 >$at_check_line_file
   3375 ( $at_traceon; bison -o subdir/foo.cc subdir/foo.yy  ) >$at_stdout 2>$at_stder1
   3376 at_status=$?
   3377 grep '^ *+' $at_stder1 >&2
   3378 grep -v '^ *+' $at_stder1 >$at_stderr
   3379 at_failed=false
   3380 $at_diff $at_devnull $at_stderr || at_failed=:
   3381 $at_diff $at_devnull $at_stdout || at_failed=:
   3382 case $at_status in
   3383    77) echo 77 > $at_status_file
   3384             exit 77;;
   3385    0) ;;
   3386    *) echo "output.at:114: exit code was $at_status, expected 0"
   3387       at_failed=:;;
   3388 esac
   3389 if $at_failed; then
   3390 
   3391   echo 1 > $at_status_file
   3392   exit 1
   3393 fi
   3394 
   3395 $at_traceon
   3396 
   3397 $at_traceoff
   3398 echo "output.at:114: ls subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh"
   3399 echo output.at:114 >$at_check_line_file
   3400 ( $at_traceon; ls subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh ) >$at_stdout 2>$at_stder1
   3401 at_status=$?
   3402 grep '^ *+' $at_stder1 >&2
   3403 grep -v '^ *+' $at_stder1 >$at_stderr
   3404 at_failed=false
   3405 $at_diff $at_devnull $at_stderr || at_failed=:
   3406 echo stdout:; cat $at_stdout
   3407 case $at_status in
   3408    77) echo 77 > $at_status_file
   3409             exit 77;;
   3410    0) ;;
   3411    *) echo "output.at:114: exit code was $at_status, expected 0"
   3412       at_failed=:;;
   3413 esac
   3414 if $at_failed; then
   3415 
   3416   echo 1 > $at_status_file
   3417   exit 1
   3418 fi
   3419 
   3420 $at_traceon
   3421 
   3422 # Also make sure that the includes do not refer to the subdirectory.
   3423 $at_traceoff
   3424 echo "output.at:114: grep 'include .subdir/' subdir/foo.cc"
   3425 echo output.at:114 >$at_check_line_file
   3426 ( $at_traceon; grep 'include .subdir/' subdir/foo.cc ) >$at_stdout 2>$at_stder1
   3427 at_status=$?
   3428 grep '^ *+' $at_stder1 >&2
   3429 grep -v '^ *+' $at_stder1 >$at_stderr
   3430 at_failed=false
   3431 $at_diff $at_devnull $at_stderr || at_failed=:
   3432 $at_diff $at_devnull $at_stdout || at_failed=:
   3433 case $at_status in
   3434    77) echo 77 > $at_status_file
   3435             exit 77;;
   3436    1) ;;
   3437    *) echo "output.at:114: exit code was $at_status, expected 1"
   3438       at_failed=:;;
   3439 esac
   3440 if $at_failed; then
   3441 
   3442   echo 1 > $at_status_file
   3443   exit 1
   3444 fi
   3445 
   3446 $at_traceon
   3447 
   3448 $at_traceoff
   3449 echo "output.at:114: grep 'include .subdir/' subdir/foo.hh"
   3450 echo output.at:114 >$at_check_line_file
   3451 ( $at_traceon; grep 'include .subdir/' subdir/foo.hh ) >$at_stdout 2>$at_stder1
   3452 at_status=$?
   3453 grep '^ *+' $at_stder1 >&2
   3454 grep -v '^ *+' $at_stder1 >$at_stderr
   3455 at_failed=false
   3456 $at_diff $at_devnull $at_stderr || at_failed=:
   3457 $at_diff $at_devnull $at_stdout || at_failed=:
   3458 case $at_status in
   3459    77) echo 77 > $at_status_file
   3460             exit 77;;
   3461    1) ;;
   3462    *) echo "output.at:114: exit code was $at_status, expected 1"
   3463       at_failed=:;;
   3464 esac
   3465 if $at_failed; then
   3466 
   3467   echo 1 > $at_status_file
   3468   exit 1
   3469 fi
   3470 
   3471 $at_traceon
   3472 
   3473 
   3474       $at_traceoff
   3475       $at_times_p && times >$at_times_file
   3476     ) 5>&1 2>&1 | eval $at_tee_pipe
   3477     at_status=`cat $at_status_file`
   3478     ;;
   3479 
   3480 
   3481   banner-3 ) # Banner 3. sets.at:59
   3482     cat <<\_ATEOF
   3483 
   3484 Grammar Sets (Firsts etc.).
   3485 
   3486 _ATEOF
   3487     ;;
   3488 
   3489   31 ) # 31. sets.at:66: Nullable
   3490     at_setup_line='sets.at:66'
   3491     at_desc='Nullable'
   3492     $at_quiet $ECHO_N " 31: Nullable                                     $ECHO_C"
   3493     at_xfail=no
   3494     (
   3495       echo "31. sets.at:66: testing ..."
   3496       $at_traceon
   3497 
   3498 
   3499 # At some point, nullable had been smoking grass, and managed to say:
   3500 #
   3501 # Entering set_nullable
   3502 # NULLABLE
   3503 #         'e': yes
   3504 #         (null): no
   3505 # ...
   3506 
   3507 cat >input.y <<'_ATEOF'
   3508 %%
   3509 e: 'e' | /* Nothing */;
   3510 _ATEOF
   3511 
   3512 
   3513 $at_traceoff
   3514 echo "sets.at:81: bison --trace=sets input.y"
   3515 echo sets.at:81 >$at_check_line_file
   3516 ( $at_traceon; bison --trace=sets input.y ) >$at_stdout 2>$at_stder1
   3517 at_status=$?
   3518 grep '^ *+' $at_stder1 >&2
   3519 grep -v '^ *+' $at_stder1 >$at_stderr
   3520 at_failed=false
   3521 echo stderr:; tee stderr <$at_stderr
   3522 $at_diff $at_devnull $at_stdout || at_failed=:
   3523 case $at_status in
   3524    77) echo 77 > $at_status_file
   3525             exit 77;;
   3526    0) ;;
   3527    *) echo "sets.at:81: exit code was $at_status, expected 0"
   3528       at_failed=:;;
   3529 esac
   3530 if $at_failed; then
   3531 
   3532   echo 1 > $at_status_file
   3533   exit 1
   3534 fi
   3535 
   3536 $at_traceon
   3537 
   3538 cat >extract.sed <<'_ATEOF'
   3539 #n
   3540 /^NULLABLE$/ {
   3541    :null
   3542    p
   3543    n
   3544    /^[	 ]*$/ !b null
   3545 }
   3546 /^FIRSTS$/ {
   3547    :firsts
   3548    p
   3549    n
   3550    /^[	 ]*$/ !b firsts
   3551 }
   3552 /^FDERIVES$/ {
   3553    :fderiv
   3554    p
   3555    n
   3556    /^[	 ]*$/ !b fderiv
   3557 }
   3558 /^DERIVES$/ {
   3559    :deriv
   3560    p
   3561    n
   3562    /^[	 ]*$/ !b deriv
   3563 }
   3564 _ATEOF
   3565 
   3566 $at_traceoff
   3567 echo "sets.at:82: sed -f extract.sed stderr"
   3568 echo sets.at:82 >$at_check_line_file
   3569 ( $at_traceon; sed -f extract.sed stderr ) >$at_stdout 2>$at_stder1
   3570 at_status=$?
   3571 grep '^ *+' $at_stder1 >&2
   3572 grep -v '^ *+' $at_stder1 >$at_stderr
   3573 at_failed=false
   3574 $at_diff $at_devnull $at_stderr || at_failed=:
   3575 echo stdout:; tee stdout <$at_stdout
   3576 case $at_status in
   3577    77) echo 77 > $at_status_file
   3578             exit 77;;
   3579    0) ;;
   3580    *) echo "sets.at:82: exit code was $at_status, expected 0"
   3581       at_failed=:;;
   3582 esac
   3583 if $at_failed; then
   3584 
   3585   echo 1 > $at_status_file
   3586   exit 1
   3587 fi
   3588 
   3589 $at_traceon
   3590 
   3591 $at_traceoff
   3592 echo "sets.at:82: mv stdout sets"
   3593 echo sets.at:82 >$at_check_line_file
   3594 ( $at_traceon; mv stdout sets ) >$at_stdout 2>$at_stder1
   3595 at_status=$?
   3596 grep '^ *+' $at_stder1 >&2
   3597 grep -v '^ *+' $at_stder1 >$at_stderr
   3598 at_failed=false
   3599 $at_diff $at_devnull $at_stderr || at_failed=:
   3600 $at_diff $at_devnull $at_stdout || at_failed=:
   3601 case $at_status in
   3602    77) echo 77 > $at_status_file
   3603             exit 77;;
   3604    0) ;;
   3605    *) echo "sets.at:82: exit code was $at_status, expected 0"
   3606       at_failed=:;;
   3607 esac
   3608 if $at_failed; then
   3609 
   3610   echo 1 > $at_status_file
   3611   exit 1
   3612 fi
   3613 
   3614 $at_traceon
   3615 
   3616 
   3617 $at_traceoff
   3618 echo "sets.at:107: cat sets"
   3619 echo sets.at:107 >$at_check_line_file
   3620 ( $at_traceon; cat sets ) >$at_stdout 2>$at_stder1
   3621 at_status=$?
   3622 grep '^ *+' $at_stder1 >&2
   3623 grep -v '^ *+' $at_stder1 >$at_stderr
   3624 at_failed=false
   3625 $at_diff $at_devnull $at_stderr || at_failed=:
   3626 echo >>$at_stdout; echo "DERIVES
   3627 	\$accept derives
   3628 		  0  e \$end
   3629 	e derives
   3630 		  1  'e'
   3631 		  2  /* empty */
   3632 NULLABLE
   3633 	\$accept: no
   3634 	e: yes
   3635 FIRSTS
   3636 	\$accept firsts
   3637 		\$accept
   3638 		e
   3639 	e firsts
   3640 		e
   3641 FDERIVES
   3642 	\$accept derives
   3643 		  0  e \$end
   3644 		  1  'e'
   3645 		  2  /* empty */
   3646 	e derives
   3647 		  1  'e'
   3648 		  2  /* empty */
   3649 " | $at_diff - $at_stdout || at_failed=:
   3650 case $at_status in
   3651    77) echo 77 > $at_status_file
   3652             exit 77;;
   3653    0) ;;
   3654    *) echo "sets.at:107: exit code was $at_status, expected 0"
   3655       at_failed=:;;
   3656 esac
   3657 if $at_failed; then
   3658 
   3659   echo 1 > $at_status_file
   3660   exit 1
   3661 fi
   3662 
   3663 $at_traceon
   3664 
   3665 
   3666       $at_traceoff
   3667       $at_times_p && times >$at_times_file
   3668     ) 5>&1 2>&1 | eval $at_tee_pipe
   3669     at_status=`cat $at_status_file`
   3670     ;;
   3671 
   3672   32 ) # 32. sets.at:151: Broken Closure
   3673     at_setup_line='sets.at:151'
   3674     at_desc='Broken Closure'
   3675     $at_quiet $ECHO_N " 32: Broken Closure                               $ECHO_C"
   3676     at_xfail=no
   3677     (
   3678       echo "32. sets.at:151: testing ..."
   3679       $at_traceon
   3680 
   3681 
   3682 cat >input.y <<'_ATEOF'
   3683 %%
   3684 a: b;
   3685 b: c;
   3686 c: d;
   3687 d: e;
   3688 e: f;
   3689 f: g;
   3690 g: h;
   3691 h: 'h';
   3692 _ATEOF
   3693 
   3694 
   3695 $at_traceoff
   3696 echo "sets.at:165: bison --trace=sets input.y"
   3697 echo sets.at:165 >$at_check_line_file
   3698 ( $at_traceon; bison --trace=sets input.y ) >$at_stdout 2>$at_stder1
   3699 at_status=$?
   3700 grep '^ *+' $at_stder1 >&2
   3701 grep -v '^ *+' $at_stder1 >$at_stderr
   3702 at_failed=false
   3703 echo stderr:; tee stderr <$at_stderr
   3704 $at_diff $at_devnull $at_stdout || at_failed=:
   3705 case $at_status in
   3706    77) echo 77 > $at_status_file
   3707             exit 77;;
   3708    0) ;;
   3709    *) echo "sets.at:165: exit code was $at_status, expected 0"
   3710       at_failed=:;;
   3711 esac
   3712 if $at_failed; then
   3713 
   3714   echo 1 > $at_status_file
   3715   exit 1
   3716 fi
   3717 
   3718 $at_traceon
   3719 
   3720 
   3721 $at_traceoff
   3722 echo "sets.at:183: sed -n 's/[	 ]*\$//;/^RTC: Firsts Output BEGIN/,/^RTC: Firsts Output END/p' stderr"
   3723 echo sets.at:183 >$at_check_line_file
   3724 ( $at_traceon; sed -n 's/[	 ]*$//;/^RTC: Firsts Output BEGIN/,/^RTC: Firsts Output END/p' stderr ) >$at_stdout 2>$at_stder1
   3725 at_status=$?
   3726 grep '^ *+' $at_stder1 >&2
   3727 grep -v '^ *+' $at_stder1 >$at_stderr
   3728 at_failed=false
   3729 $at_diff $at_devnull $at_stderr || at_failed=:
   3730 echo >>$at_stdout; echo "RTC: Firsts Output BEGIN
   3731 
   3732    012345678
   3733   .---------.
   3734  0|111111111|
   3735  1| 11111111|
   3736  2|  1111111|
   3737  3|   111111|
   3738  4|    11111|
   3739  5|     1111|
   3740  6|      111|
   3741  7|       11|
   3742  8|        1|
   3743   \`---------'
   3744 RTC: Firsts Output END
   3745 " | $at_diff - $at_stdout || at_failed=:
   3746 case $at_status in
   3747    77) echo 77 > $at_status_file
   3748             exit 77;;
   3749    0) ;;
   3750    *) echo "sets.at:183: exit code was $at_status, expected 0"
   3751       at_failed=:;;
   3752 esac
   3753 if $at_failed; then
   3754 
   3755   echo 1 > $at_status_file
   3756   exit 1
   3757 fi
   3758 
   3759 $at_traceon
   3760 
   3761 
   3762       $at_traceoff
   3763       $at_times_p && times >$at_times_file
   3764     ) 5>&1 2>&1 | eval $at_tee_pipe
   3765     at_status=`cat $at_status_file`
   3766     ;;
   3767 
   3768   33 ) # 33. sets.at:193: Firsts
   3769     at_setup_line='sets.at:193'
   3770     at_desc='Firsts'
   3771     $at_quiet $ECHO_N " 33: Firsts                                       $ECHO_C"
   3772     at_xfail=no
   3773     (
   3774       echo "33. sets.at:193: testing ..."
   3775       $at_traceon
   3776 
   3777 
   3778 cat >input.y <<'_ATEOF'
   3779 %nonassoc '<' '>'
   3780 %left '+' '-'
   3781 %right '^' '='
   3782 %%
   3783 exp:
   3784    exp '<' exp
   3785  | exp '>' exp
   3786  | exp '+' exp
   3787  | exp '-' exp
   3788  | exp '^' exp
   3789  | exp '=' exp
   3790  | "exp"
   3791  ;
   3792 _ATEOF
   3793 
   3794 
   3795 $at_traceoff
   3796 echo "sets.at:211: bison --trace=sets input.y"
   3797 echo sets.at:211 >$at_check_line_file
   3798 ( $at_traceon; bison --trace=sets input.y ) >$at_stdout 2>$at_stder1
   3799 at_status=$?
   3800 grep '^ *+' $at_stder1 >&2
   3801 grep -v '^ *+' $at_stder1 >$at_stderr
   3802 at_failed=false
   3803 echo stderr:; tee stderr <$at_stderr
   3804 $at_diff $at_devnull $at_stdout || at_failed=:
   3805 case $at_status in
   3806    77) echo 77 > $at_status_file
   3807             exit 77;;
   3808    0) ;;
   3809    *) echo "sets.at:211: exit code was $at_status, expected 0"
   3810       at_failed=:;;
   3811 esac
   3812 if $at_failed; then
   3813 
   3814   echo 1 > $at_status_file
   3815   exit 1
   3816 fi
   3817 
   3818 $at_traceon
   3819 
   3820 cat >extract.sed <<'_ATEOF'
   3821 #n
   3822 /^NULLABLE$/ {
   3823    :null
   3824    p
   3825    n
   3826    /^[	 ]*$/ !b null
   3827 }
   3828 /^FIRSTS$/ {
   3829    :firsts
   3830    p
   3831    n
   3832    /^[	 ]*$/ !b firsts
   3833 }
   3834 /^FDERIVES$/ {
   3835    :fderiv
   3836    p
   3837    n
   3838    /^[	 ]*$/ !b fderiv
   3839 }
   3840 /^DERIVES$/ {
   3841    :deriv
   3842    p
   3843    n
   3844    /^[	 ]*$/ !b deriv
   3845 }
   3846 _ATEOF
   3847 
   3848 $at_traceoff
   3849 echo "sets.at:212: sed -f extract.sed stderr"
   3850 echo sets.at:212 >$at_check_line_file
   3851 ( $at_traceon; sed -f extract.sed stderr ) >$at_stdout 2>$at_stder1
   3852 at_status=$?
   3853 grep '^ *+' $at_stder1 >&2
   3854 grep -v '^ *+' $at_stder1 >$at_stderr
   3855 at_failed=false
   3856 $at_diff $at_devnull $at_stderr || at_failed=:
   3857 echo stdout:; tee stdout <$at_stdout
   3858 case $at_status in
   3859    77) echo 77 > $at_status_file
   3860             exit 77;;
   3861    0) ;;
   3862    *) echo "sets.at:212: exit code was $at_status, expected 0"
   3863       at_failed=:;;
   3864 esac
   3865 if $at_failed; then
   3866 
   3867   echo 1 > $at_status_file
   3868   exit 1
   3869 fi
   3870 
   3871 $at_traceon
   3872 
   3873 $at_traceoff
   3874 echo "sets.at:212: mv stdout sets"
   3875 echo sets.at:212 >$at_check_line_file
   3876 ( $at_traceon; mv stdout sets ) >$at_stdout 2>$at_stder1
   3877 at_status=$?
   3878 grep '^ *+' $at_stder1 >&2
   3879 grep -v '^ *+' $at_stder1 >$at_stderr
   3880 at_failed=false
   3881 $at_diff $at_devnull $at_stderr || at_failed=:
   3882 $at_diff $at_devnull $at_stdout || at_failed=:
   3883 case $at_status in
   3884    77) echo 77 > $at_status_file
   3885             exit 77;;
   3886    0) ;;
   3887    *) echo "sets.at:212: exit code was $at_status, expected 0"
   3888       at_failed=:;;
   3889 esac
   3890 if $at_failed; then
   3891 
   3892   echo 1 > $at_status_file
   3893   exit 1
   3894 fi
   3895 
   3896 $at_traceon
   3897 
   3898 
   3899 $at_traceoff
   3900 echo "sets.at:252: cat sets"
   3901 echo sets.at:252 >$at_check_line_file
   3902 ( $at_traceon; cat sets ) >$at_stdout 2>$at_stder1
   3903 at_status=$?
   3904 grep '^ *+' $at_stder1 >&2
   3905 grep -v '^ *+' $at_stder1 >$at_stderr
   3906 at_failed=false
   3907 $at_diff $at_devnull $at_stderr || at_failed=:
   3908 echo >>$at_stdout; echo "DERIVES
   3909 	\$accept derives
   3910 		  0  exp \$end
   3911 	exp derives
   3912 		  1  exp '<' exp
   3913 		  2  exp '>' exp
   3914 		  3  exp '+' exp
   3915 		  4  exp '-' exp
   3916 		  5  exp '^' exp
   3917 		  6  exp '=' exp
   3918 		  7  \"exp\"
   3919 NULLABLE
   3920 	\$accept: no
   3921 	exp: no
   3922 FIRSTS
   3923 	\$accept firsts
   3924 		\$accept
   3925 		exp
   3926 	exp firsts
   3927 		exp
   3928 FDERIVES
   3929 	\$accept derives
   3930 		  0  exp \$end
   3931 		  1  exp '<' exp
   3932 		  2  exp '>' exp
   3933 		  3  exp '+' exp
   3934 		  4  exp '-' exp
   3935 		  5  exp '^' exp
   3936 		  6  exp '=' exp
   3937 		  7  \"exp\"
   3938 	exp derives
   3939 		  1  exp '<' exp
   3940 		  2  exp '>' exp
   3941 		  3  exp '+' exp
   3942 		  4  exp '-' exp
   3943 		  5  exp '^' exp
   3944 		  6  exp '=' exp
   3945 		  7  \"exp\"
   3946 " | $at_diff - $at_stdout || at_failed=:
   3947 case $at_status in
   3948    77) echo 77 > $at_status_file
   3949             exit 77;;
   3950    0) ;;
   3951    *) echo "sets.at:252: exit code was $at_status, expected 0"
   3952       at_failed=:;;
   3953 esac
   3954 if $at_failed; then
   3955 
   3956   echo 1 > $at_status_file
   3957   exit 1
   3958 fi
   3959 
   3960 $at_traceon
   3961 
   3962 
   3963       $at_traceoff
   3964       $at_times_p && times >$at_times_file
   3965     ) 5>&1 2>&1 | eval $at_tee_pipe
   3966     at_status=`cat $at_status_file`
   3967     ;;
   3968 
   3969   34 ) # 34. sets.at:269: Accept
   3970     at_setup_line='sets.at:269'
   3971     at_desc='Accept'
   3972     $at_quiet $ECHO_N " 34: Accept                                       $ECHO_C"
   3973     at_xfail=no
   3974     (
   3975       echo "34. sets.at:269: testing ..."
   3976       $at_traceon
   3977 
   3978 
   3979 cat >input.y <<'_ATEOF'
   3980 %token END 0
   3981 %%
   3982 input:
   3983   'a'
   3984 | '(' input ')'
   3985 | '(' error END
   3986 ;
   3987 _ATEOF
   3988 
   3989 
   3990 $at_traceoff
   3991 echo "sets.at:281: bison -v -o input.c input.y"
   3992 echo sets.at:281 >$at_check_line_file
   3993 ( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   3994 at_status=$?
   3995 grep '^ *+' $at_stder1 >&2
   3996 grep -v '^ *+' $at_stder1 >$at_stderr
   3997 at_failed=false
   3998 $at_diff $at_devnull $at_stderr || at_failed=:
   3999 $at_diff $at_devnull $at_stdout || at_failed=:
   4000 case $at_status in
   4001    77) echo 77 > $at_status_file
   4002             exit 77;;
   4003    0) ;;
   4004    *) echo "sets.at:281: exit code was $at_status, expected 0"
   4005       at_failed=:;;
   4006 esac
   4007 if $at_failed; then
   4008 
   4009   echo 1 > $at_status_file
   4010   exit 1
   4011 fi
   4012 
   4013 $at_traceon
   4014 
   4015 
   4016 # Get the final state in the parser.
   4017 $at_traceoff
   4018 echo "sets.at:285: sed -n 's/.*define YYFINAL *\\([0-9][0-9]*\\)/final state \\1/p' input.c"
   4019 echo sets.at:285 >$at_check_line_file
   4020 ( $at_traceon; sed -n 's/.*define YYFINAL *\([0-9][0-9]*\)/final state \1/p' input.c ) >$at_stdout 2>$at_stder1
   4021 at_status=$?
   4022 grep '^ *+' $at_stder1 >&2
   4023 grep -v '^ *+' $at_stder1 >$at_stderr
   4024 at_failed=false
   4025 $at_diff $at_devnull $at_stderr || at_failed=:
   4026 echo stdout:; tee stdout <$at_stdout
   4027 case $at_status in
   4028    77) echo 77 > $at_status_file
   4029             exit 77;;
   4030    0) ;;
   4031    *) echo "sets.at:285: exit code was $at_status, expected 0"
   4032       at_failed=:;;
   4033 esac
   4034 if $at_failed; then
   4035 
   4036   echo 1 > $at_status_file
   4037   exit 1
   4038 fi
   4039 
   4040 $at_traceon
   4041 
   4042 mv stdout expout
   4043 
   4044 # Get the final state in the report, from the "accept" action..
   4045 $at_traceoff
   4046 echo "sets.at:300: sed -n '
   4047            /^state \\(.*\\)/{
   4048 	     s//final state \\1/
   4049 	     x
   4050 	   }
   4051 	   / accept/{
   4052 	     x
   4053 	     p
   4054 	     q
   4055 	   }
   4056 	' input.output"
   4057 echo sets.at:300 >$at_check_line_file
   4058 ( $at_traceon; sed -n '
   4059            /^state \(.*\)/{
   4060 	     s//final state \1/
   4061 	     x
   4062 	   }
   4063 	   / accept/{
   4064 	     x
   4065 	     p
   4066 	     q
   4067 	   }
   4068 	' input.output ) >$at_stdout 2>$at_stder1
   4069 at_status=$?
   4070 grep '^ *+' $at_stder1 >&2
   4071 grep -v '^ *+' $at_stder1 >$at_stderr
   4072 at_failed=false
   4073 $at_diff $at_devnull $at_stderr || at_failed=:
   4074 $at_diff expout $at_stdout || at_failed=:
   4075 case $at_status in
   4076    77) echo 77 > $at_status_file
   4077             exit 77;;
   4078    0) ;;
   4079    *) echo "sets.at:300: exit code was $at_status, expected 0"
   4080       at_failed=:;;
   4081 esac
   4082 if $at_failed; then
   4083 
   4084   echo 1 > $at_status_file
   4085   exit 1
   4086 fi
   4087 
   4088 $at_traceon
   4089 
   4090 
   4091       $at_traceoff
   4092       $at_times_p && times >$at_times_file
   4093     ) 5>&1 2>&1 | eval $at_tee_pipe
   4094     at_status=`cat $at_status_file`
   4095     ;;
   4096 
   4097 
   4098   banner-4 ) # Banner 4. reduce.at:19
   4099     cat <<\_ATEOF
   4100 
   4101 Grammar Reduction.
   4102 
   4103 _ATEOF
   4104     ;;
   4105 
   4106   35 ) # 35. reduce.at:26: Useless Terminals
   4107     at_setup_line='reduce.at:26'
   4108     at_desc='Useless Terminals'
   4109     $at_quiet $ECHO_N " 35: Useless Terminals                            $ECHO_C"
   4110     at_xfail=no
   4111     (
   4112       echo "35. reduce.at:26: testing ..."
   4113       $at_traceon
   4114 
   4115 
   4116 cat >input.y <<'_ATEOF'
   4117 %verbose
   4118 %output="input.c"
   4119 
   4120 %token useless1
   4121 %token useless2
   4122 %token useless3
   4123 %token useless4
   4124 %token useless5
   4125 %token useless6
   4126 %token useless7
   4127 %token useless8
   4128 %token useless9
   4129 
   4130 %token useful
   4131 %%
   4132 exp: useful;
   4133 _ATEOF
   4134 
   4135 
   4136 $at_traceoff
   4137 echo "reduce.at:47: bison input.y"
   4138 echo reduce.at:47 >$at_check_line_file
   4139 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4140 at_status=$?
   4141 grep '^ *+' $at_stder1 >&2
   4142 grep -v '^ *+' $at_stder1 >$at_stderr
   4143 at_failed=false
   4144 $at_diff $at_devnull $at_stderr || at_failed=:
   4145 $at_diff $at_devnull $at_stdout || at_failed=:
   4146 case $at_status in
   4147    77) echo 77 > $at_status_file
   4148             exit 77;;
   4149    0) ;;
   4150    *) echo "reduce.at:47: exit code was $at_status, expected 0"
   4151       at_failed=:;;
   4152 esac
   4153 if $at_failed; then
   4154 
   4155   echo 1 > $at_status_file
   4156   exit 1
   4157 fi
   4158 
   4159 $at_traceon
   4160 
   4161 
   4162 $at_traceoff
   4163 echo "reduce.at:60: sed -n '/^Grammar/q;/^\$/!p' input.output"
   4164 echo reduce.at:60 >$at_check_line_file
   4165 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
   4166 at_status=$?
   4167 grep '^ *+' $at_stder1 >&2
   4168 grep -v '^ *+' $at_stder1 >$at_stderr
   4169 at_failed=false
   4170 $at_diff $at_devnull $at_stderr || at_failed=:
   4171 echo >>$at_stdout; echo "Terminals which are not used
   4172    useless1
   4173    useless2
   4174    useless3
   4175    useless4
   4176    useless5
   4177    useless6
   4178    useless7
   4179    useless8
   4180    useless9
   4181 " | $at_diff - $at_stdout || at_failed=:
   4182 case $at_status in
   4183    77) echo 77 > $at_status_file
   4184             exit 77;;
   4185    0) ;;
   4186    *) echo "reduce.at:60: exit code was $at_status, expected 0"
   4187       at_failed=:;;
   4188 esac
   4189 if $at_failed; then
   4190 
   4191   echo 1 > $at_status_file
   4192   exit 1
   4193 fi
   4194 
   4195 $at_traceon
   4196 
   4197 
   4198       $at_traceoff
   4199       $at_times_p && times >$at_times_file
   4200     ) 5>&1 2>&1 | eval $at_tee_pipe
   4201     at_status=`cat $at_status_file`
   4202     ;;
   4203 
   4204   36 ) # 36. reduce.at:70: Useless Nonterminals
   4205     at_setup_line='reduce.at:70'
   4206     at_desc='Useless Nonterminals'
   4207     $at_quiet $ECHO_N " 36: Useless Nonterminals                         $ECHO_C"
   4208     at_xfail=no
   4209     (
   4210       echo "36. reduce.at:70: testing ..."
   4211       $at_traceon
   4212 
   4213 
   4214 cat >input.y <<'_ATEOF'
   4215 %verbose
   4216 %output="input.c"
   4217 
   4218 %nterm useless1
   4219 %nterm useless2
   4220 %nterm useless3
   4221 %nterm useless4
   4222 %nterm useless5
   4223 %nterm useless6
   4224 %nterm useless7
   4225 %nterm useless8
   4226 %nterm useless9
   4227 
   4228 %token useful
   4229 %%
   4230 exp: useful;
   4231 _ATEOF
   4232 
   4233 
   4234 $at_traceoff
   4235 echo "reduce.at:102: bison input.y"
   4236 echo reduce.at:102 >$at_check_line_file
   4237 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4238 at_status=$?
   4239 grep '^ *+' $at_stder1 >&2
   4240 grep -v '^ *+' $at_stder1 >$at_stderr
   4241 at_failed=false
   4242 echo >>$at_stderr; echo "input.y: warning: 9 useless nonterminals
   4243 input.y:4.8-15: warning: useless nonterminal: useless1
   4244 input.y:5.8-15: warning: useless nonterminal: useless2
   4245 input.y:6.8-15: warning: useless nonterminal: useless3
   4246 input.y:7.8-15: warning: useless nonterminal: useless4
   4247 input.y:8.8-15: warning: useless nonterminal: useless5
   4248 input.y:9.8-15: warning: useless nonterminal: useless6
   4249 input.y:10.8-15: warning: useless nonterminal: useless7
   4250 input.y:11.8-15: warning: useless nonterminal: useless8
   4251 input.y:12.8-15: warning: useless nonterminal: useless9
   4252 " | $at_diff - $at_stderr || at_failed=:
   4253 $at_diff $at_devnull $at_stdout || at_failed=:
   4254 case $at_status in
   4255    77) echo 77 > $at_status_file
   4256             exit 77;;
   4257    0) ;;
   4258    *) echo "reduce.at:102: exit code was $at_status, expected 0"
   4259       at_failed=:;;
   4260 esac
   4261 if $at_failed; then
   4262 
   4263   echo 1 > $at_status_file
   4264   exit 1
   4265 fi
   4266 
   4267 $at_traceon
   4268 
   4269 
   4270 $at_traceoff
   4271 echo "reduce.at:115: sed -n '/^Grammar/q;/^\$/!p' input.output"
   4272 echo reduce.at:115 >$at_check_line_file
   4273 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
   4274 at_status=$?
   4275 grep '^ *+' $at_stder1 >&2
   4276 grep -v '^ *+' $at_stder1 >$at_stderr
   4277 at_failed=false
   4278 $at_diff $at_devnull $at_stderr || at_failed=:
   4279 echo >>$at_stdout; echo "Useless nonterminals
   4280    useless1
   4281    useless2
   4282    useless3
   4283    useless4
   4284    useless5
   4285    useless6
   4286    useless7
   4287    useless8
   4288    useless9
   4289 " | $at_diff - $at_stdout || at_failed=:
   4290 case $at_status in
   4291    77) echo 77 > $at_status_file
   4292             exit 77;;
   4293    0) ;;
   4294    *) echo "reduce.at:115: exit code was $at_status, expected 0"
   4295       at_failed=:;;
   4296 esac
   4297 if $at_failed; then
   4298 
   4299   echo 1 > $at_status_file
   4300   exit 1
   4301 fi
   4302 
   4303 $at_traceon
   4304 
   4305 
   4306       $at_traceoff
   4307       $at_times_p && times >$at_times_file
   4308     ) 5>&1 2>&1 | eval $at_tee_pipe
   4309     at_status=`cat $at_status_file`
   4310     ;;
   4311 
   4312   37 ) # 37. reduce.at:125: Useless Rules
   4313     at_setup_line='reduce.at:125'
   4314     at_desc='Useless Rules'
   4315     $at_quiet $ECHO_N " 37: Useless Rules                                $ECHO_C"
   4316     at_xfail=no
   4317     (
   4318       echo "37. reduce.at:125: testing ..."
   4319       $at_traceon
   4320 
   4321 
   4322 
   4323 
   4324 cat >input.y <<'_ATEOF'
   4325 %verbose
   4326 %output="input.c"
   4327 %token useful
   4328 %%
   4329 exp: useful;
   4330 useless1: '1';
   4331 useless2: '2';
   4332 useless3: '3';
   4333 useless4: '4';
   4334 useless5: '5';
   4335 useless6: '6';
   4336 useless7: '7';
   4337 useless8: '8';
   4338 useless9: '9';
   4339 _ATEOF
   4340 
   4341 
   4342 $at_traceoff
   4343 echo "reduce.at:166: bison input.y"
   4344 echo reduce.at:166 >$at_check_line_file
   4345 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4346 at_status=$?
   4347 grep '^ *+' $at_stder1 >&2
   4348 grep -v '^ *+' $at_stder1 >$at_stderr
   4349 at_failed=false
   4350 echo >>$at_stderr; echo "input.y: warning: 9 useless nonterminals and 9 useless rules
   4351 input.y:6.1-8: warning: useless nonterminal: useless1
   4352 input.y:7.1-8: warning: useless nonterminal: useless2
   4353 input.y:8.1-8: warning: useless nonterminal: useless3
   4354 input.y:9.1-8: warning: useless nonterminal: useless4
   4355 input.y:10.1-8: warning: useless nonterminal: useless5
   4356 input.y:11.1-8: warning: useless nonterminal: useless6
   4357 input.y:12.1-8: warning: useless nonterminal: useless7
   4358 input.y:13.1-8: warning: useless nonterminal: useless8
   4359 input.y:14.1-8: warning: useless nonterminal: useless9
   4360 input.y:6.11-13: warning: useless rule: useless1: '1'
   4361 input.y:7.11-13: warning: useless rule: useless2: '2'
   4362 input.y:8.11-13: warning: useless rule: useless3: '3'
   4363 input.y:9.11-13: warning: useless rule: useless4: '4'
   4364 input.y:10.11-13: warning: useless rule: useless5: '5'
   4365 input.y:11.11-13: warning: useless rule: useless6: '6'
   4366 input.y:12.11-13: warning: useless rule: useless7: '7'
   4367 input.y:13.11-13: warning: useless rule: useless8: '8'
   4368 input.y:14.11-13: warning: useless rule: useless9: '9'
   4369 " | $at_diff - $at_stderr || at_failed=:
   4370 $at_diff $at_devnull $at_stdout || at_failed=:
   4371 case $at_status in
   4372    77) echo 77 > $at_status_file
   4373             exit 77;;
   4374    0) ;;
   4375    *) echo "reduce.at:166: exit code was $at_status, expected 0"
   4376       at_failed=:;;
   4377 esac
   4378 if $at_failed; then
   4379 
   4380   echo 1 > $at_status_file
   4381   exit 1
   4382 fi
   4383 
   4384 $at_traceon
   4385 
   4386 
   4387 $at_traceoff
   4388 echo "reduce.at:199: sed -n '/^Grammar/q;/^\$/!p' input.output"
   4389 echo reduce.at:199 >$at_check_line_file
   4390 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
   4391 at_status=$?
   4392 grep '^ *+' $at_stder1 >&2
   4393 grep -v '^ *+' $at_stder1 >$at_stderr
   4394 at_failed=false
   4395 $at_diff $at_devnull $at_stderr || at_failed=:
   4396 echo >>$at_stdout; echo "Useless nonterminals
   4397    useless1
   4398    useless2
   4399    useless3
   4400    useless4
   4401    useless5
   4402    useless6
   4403    useless7
   4404    useless8
   4405    useless9
   4406 Terminals which are not used
   4407    '1'
   4408    '2'
   4409    '3'
   4410    '4'
   4411    '5'
   4412    '6'
   4413    '7'
   4414    '8'
   4415    '9'
   4416 Useless rules
   4417     2 useless1: '1'
   4418     3 useless2: '2'
   4419     4 useless3: '3'
   4420     5 useless4: '4'
   4421     6 useless5: '5'
   4422     7 useless6: '6'
   4423     8 useless7: '7'
   4424     9 useless8: '8'
   4425    10 useless9: '9'
   4426 " | $at_diff - $at_stdout || at_failed=:
   4427 case $at_status in
   4428    77) echo 77 > $at_status_file
   4429             exit 77;;
   4430    0) ;;
   4431    *) echo "reduce.at:199: exit code was $at_status, expected 0"
   4432       at_failed=:;;
   4433 esac
   4434 if $at_failed; then
   4435 
   4436   echo 1 > $at_status_file
   4437   exit 1
   4438 fi
   4439 
   4440 $at_traceon
   4441 
   4442 
   4443       $at_traceoff
   4444       $at_times_p && times >$at_times_file
   4445     ) 5>&1 2>&1 | eval $at_tee_pipe
   4446     at_status=`cat $at_status_file`
   4447     ;;
   4448 
   4449   38 ) # 38. reduce.at:212: Reduced Automaton
   4450     at_setup_line='reduce.at:212'
   4451     at_desc='Reduced Automaton'
   4452     $at_quiet $ECHO_N " 38: Reduced Automaton                            $ECHO_C"
   4453     at_xfail=no
   4454     (
   4455       echo "38. reduce.at:212: testing ..."
   4456       $at_traceon
   4457 
   4458 
   4459 
   4460 
   4461 # The non reduced grammar.
   4462 # ------------------------
   4463 cat >not-reduced.y <<'_ATEOF'
   4464 /* A useless token. */
   4465 %token useless_token
   4466 /* A useful one. */
   4467 %token useful
   4468 %verbose
   4469 %output="not-reduced.c"
   4470 
   4471 %%
   4472 
   4473 exp: useful            { /* A useful action. */ }
   4474    | non_productive    { /* A non productive action. */ }
   4475    ;
   4476 
   4477 not_reachable: useful  { /* A not reachable action. */ }
   4478              ;
   4479 
   4480 non_productive: non_productive useless_token
   4481                        { /* Another non productive action. */ }
   4482               ;
   4483 %%
   4484 _ATEOF
   4485 
   4486 
   4487 $at_traceoff
   4488 echo "reduce.at:248: bison not-reduced.y"
   4489 echo reduce.at:248 >$at_check_line_file
   4490 ( $at_traceon; bison not-reduced.y ) >$at_stdout 2>$at_stder1
   4491 at_status=$?
   4492 grep '^ *+' $at_stder1 >&2
   4493 grep -v '^ *+' $at_stder1 >$at_stderr
   4494 at_failed=false
   4495 echo >>$at_stderr; echo "not-reduced.y: warning: 2 useless nonterminals and 3 useless rules
   4496 not-reduced.y:14.1-13: warning: useless nonterminal: not_reachable
   4497 not-reduced.y:11.6-19: warning: useless nonterminal: non_productive
   4498 not-reduced.y:11.6-57: warning: useless rule: exp: non_productive
   4499 not-reduced.y:14.16-56: warning: useless rule: not_reachable: useful
   4500 not-reduced.y:17.17-18.63: warning: useless rule: non_productive: non_productive useless_token
   4501 " | $at_diff - $at_stderr || at_failed=:
   4502 $at_diff $at_devnull $at_stdout || at_failed=:
   4503 case $at_status in
   4504    77) echo 77 > $at_status_file
   4505             exit 77;;
   4506    0) ;;
   4507    *) echo "reduce.at:248: exit code was $at_status, expected 0"
   4508       at_failed=:;;
   4509 esac
   4510 if $at_failed; then
   4511 
   4512   echo 1 > $at_status_file
   4513   exit 1
   4514 fi
   4515 
   4516 $at_traceon
   4517 
   4518 
   4519 $at_traceoff
   4520 echo "reduce.at:260: sed -n '/^Grammar/q;/^\$/!p' not-reduced.output"
   4521 echo reduce.at:260 >$at_check_line_file
   4522 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' not-reduced.output ) >$at_stdout 2>$at_stder1
   4523 at_status=$?
   4524 grep '^ *+' $at_stder1 >&2
   4525 grep -v '^ *+' $at_stder1 >$at_stderr
   4526 at_failed=false
   4527 $at_diff $at_devnull $at_stderr || at_failed=:
   4528 echo >>$at_stdout; echo "Useless nonterminals
   4529    not_reachable
   4530    non_productive
   4531 Terminals which are not used
   4532    useless_token
   4533 Useless rules
   4534     2 exp: non_productive
   4535     3 not_reachable: useful
   4536     4 non_productive: non_productive useless_token
   4537 " | $at_diff - $at_stdout || at_failed=:
   4538 case $at_status in
   4539    77) echo 77 > $at_status_file
   4540             exit 77;;
   4541    0) ;;
   4542    *) echo "reduce.at:260: exit code was $at_status, expected 0"
   4543       at_failed=:;;
   4544 esac
   4545 if $at_failed; then
   4546 
   4547   echo 1 > $at_status_file
   4548   exit 1
   4549 fi
   4550 
   4551 $at_traceon
   4552 
   4553 
   4554 # The reduced grammar.
   4555 # --------------------
   4556 cat >reduced.y <<'_ATEOF'
   4557 /* A useless token. */
   4558 %token useless_token
   4559 /* A useful one. */
   4560 %token useful
   4561 %verbose
   4562 %output="reduced.c"
   4563 
   4564 %%
   4565 
   4566 exp: useful            { /* A useful action. */ }
   4567 //   | non_productive    { /* A non productive action. */ } */
   4568    ;
   4569 
   4570 //not_reachable: useful  { /* A not reachable action. */ }
   4571 //             ;
   4572 
   4573 //non_productive: non_productive useless_token
   4574 //                       { /* Another non productive action. */ }
   4575 //              ;
   4576 %%
   4577 _ATEOF
   4578 
   4579 
   4580 $at_traceoff
   4581 echo "reduce.at:287: bison reduced.y"
   4582 echo reduce.at:287 >$at_check_line_file
   4583 ( $at_traceon; bison reduced.y ) >$at_stdout 2>$at_stder1
   4584 at_status=$?
   4585 grep '^ *+' $at_stder1 >&2
   4586 grep -v '^ *+' $at_stder1 >$at_stderr
   4587 at_failed=false
   4588 $at_diff $at_devnull $at_stderr || at_failed=:
   4589 $at_diff $at_devnull $at_stdout || at_failed=:
   4590 case $at_status in
   4591    77) echo 77 > $at_status_file
   4592             exit 77;;
   4593    0) ;;
   4594    *) echo "reduce.at:287: exit code was $at_status, expected 0"
   4595       at_failed=:;;
   4596 esac
   4597 if $at_failed; then
   4598 
   4599   echo 1 > $at_status_file
   4600   exit 1
   4601 fi
   4602 
   4603 $at_traceon
   4604 
   4605 
   4606 # Comparing the parsers.
   4607 cp reduced.c expout
   4608 $at_traceoff
   4609 echo "reduce.at:291: sed 's/not-reduced/reduced/g' not-reduced.c"
   4610 echo reduce.at:291 >$at_check_line_file
   4611 ( $at_traceon; sed 's/not-reduced/reduced/g' not-reduced.c ) >$at_stdout 2>$at_stder1
   4612 at_status=$?
   4613 grep '^ *+' $at_stder1 >&2
   4614 grep -v '^ *+' $at_stder1 >$at_stderr
   4615 at_failed=false
   4616 $at_diff $at_devnull $at_stderr || at_failed=:
   4617 $at_diff expout $at_stdout || at_failed=:
   4618 case $at_status in
   4619    77) echo 77 > $at_status_file
   4620             exit 77;;
   4621    0) ;;
   4622    *) echo "reduce.at:291: exit code was $at_status, expected 0"
   4623       at_failed=:;;
   4624 esac
   4625 if $at_failed; then
   4626 
   4627   echo 1 > $at_status_file
   4628   exit 1
   4629 fi
   4630 
   4631 $at_traceon
   4632 
   4633 
   4634       $at_traceoff
   4635       $at_times_p && times >$at_times_file
   4636     ) 5>&1 2>&1 | eval $at_tee_pipe
   4637     at_status=`cat $at_status_file`
   4638     ;;
   4639 
   4640   39 ) # 39. reduce.at:301: Underivable Rules
   4641     at_setup_line='reduce.at:301'
   4642     at_desc='Underivable Rules'
   4643     $at_quiet $ECHO_N " 39: Underivable Rules                            $ECHO_C"
   4644     at_xfail=no
   4645     (
   4646       echo "39. reduce.at:301: testing ..."
   4647       $at_traceon
   4648 
   4649 
   4650 
   4651 
   4652 cat >input.y <<'_ATEOF'
   4653 %verbose
   4654 %output="input.c"
   4655 %token useful
   4656 %%
   4657 exp: useful | underivable;
   4658 underivable: indirection;
   4659 indirection: underivable;
   4660 _ATEOF
   4661 
   4662 
   4663 $at_traceoff
   4664 echo "reduce.at:322: bison input.y"
   4665 echo reduce.at:322 >$at_check_line_file
   4666 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4667 at_status=$?
   4668 grep '^ *+' $at_stder1 >&2
   4669 grep -v '^ *+' $at_stder1 >$at_stderr
   4670 at_failed=false
   4671 echo >>$at_stderr; echo "input.y: warning: 2 useless nonterminals and 3 useless rules
   4672 input.y:5.15-25: warning: useless nonterminal: underivable
   4673 input.y:6.14-24: warning: useless nonterminal: indirection
   4674 input.y:5.15-25: warning: useless rule: exp: underivable
   4675 input.y:6.14-24: warning: useless rule: underivable: indirection
   4676 input.y:7.14-24: warning: useless rule: indirection: underivable
   4677 " | $at_diff - $at_stderr || at_failed=:
   4678 $at_diff $at_devnull $at_stdout || at_failed=:
   4679 case $at_status in
   4680    77) echo 77 > $at_status_file
   4681             exit 77;;
   4682    0) ;;
   4683    *) echo "reduce.at:322: exit code was $at_status, expected 0"
   4684       at_failed=:;;
   4685 esac
   4686 if $at_failed; then
   4687 
   4688   echo 1 > $at_status_file
   4689   exit 1
   4690 fi
   4691 
   4692 $at_traceon
   4693 
   4694 
   4695 $at_traceoff
   4696 echo "reduce.at:332: sed -n '/^Grammar/q;/^\$/!p' input.output"
   4697 echo reduce.at:332 >$at_check_line_file
   4698 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
   4699 at_status=$?
   4700 grep '^ *+' $at_stder1 >&2
   4701 grep -v '^ *+' $at_stder1 >$at_stderr
   4702 at_failed=false
   4703 $at_diff $at_devnull $at_stderr || at_failed=:
   4704 echo >>$at_stdout; echo "Useless nonterminals
   4705    underivable
   4706    indirection
   4707 Useless rules
   4708     2 exp: underivable
   4709     3 underivable: indirection
   4710     4 indirection: underivable
   4711 " | $at_diff - $at_stdout || at_failed=:
   4712 case $at_status in
   4713    77) echo 77 > $at_status_file
   4714             exit 77;;
   4715    0) ;;
   4716    *) echo "reduce.at:332: exit code was $at_status, expected 0"
   4717       at_failed=:;;
   4718 esac
   4719 if $at_failed; then
   4720 
   4721   echo 1 > $at_status_file
   4722   exit 1
   4723 fi
   4724 
   4725 $at_traceon
   4726 
   4727 
   4728       $at_traceoff
   4729       $at_times_p && times >$at_times_file
   4730     ) 5>&1 2>&1 | eval $at_tee_pipe
   4731     at_status=`cat $at_status_file`
   4732     ;;
   4733 
   4734   40 ) # 40. reduce.at:342: Empty Language
   4735     at_setup_line='reduce.at:342'
   4736     at_desc='Empty Language'
   4737     $at_quiet $ECHO_N " 40: Empty Language                               $ECHO_C"
   4738     at_xfail=no
   4739     (
   4740       echo "40. reduce.at:342: testing ..."
   4741       $at_traceon
   4742 
   4743 
   4744 cat >input.y <<'_ATEOF'
   4745 %output="input.c"
   4746 %%
   4747 exp: exp;
   4748 _ATEOF
   4749 
   4750 
   4751 $at_traceoff
   4752 echo "reduce.at:353: bison input.y"
   4753 echo reduce.at:353 >$at_check_line_file
   4754 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4755 at_status=$?
   4756 grep '^ *+' $at_stder1 >&2
   4757 grep -v '^ *+' $at_stder1 >$at_stderr
   4758 at_failed=false
   4759 echo >>$at_stderr; echo "input.y: warning: 2 useless nonterminals and 2 useless rules
   4760 input.y:3.1-3: fatal error: start symbol exp does not derive any sentence
   4761 " | $at_diff - $at_stderr || at_failed=:
   4762 $at_diff $at_devnull $at_stdout || at_failed=:
   4763 case $at_status in
   4764    77) echo 77 > $at_status_file
   4765             exit 77;;
   4766    1) ;;
   4767    *) echo "reduce.at:353: exit code was $at_status, expected 1"
   4768       at_failed=:;;
   4769 esac
   4770 if $at_failed; then
   4771 
   4772   echo 1 > $at_status_file
   4773   exit 1
   4774 fi
   4775 
   4776 $at_traceon
   4777 
   4778 
   4779       $at_traceoff
   4780       $at_times_p && times >$at_times_file
   4781     ) 5>&1 2>&1 | eval $at_tee_pipe
   4782     at_status=`cat $at_status_file`
   4783     ;;
   4784 
   4785 
   4786   banner-5 ) # Banner 5. synclines.at:19
   4787     cat <<\_ATEOF
   4788 
   4789 User Actions.
   4790 
   4791 _ATEOF
   4792     ;;
   4793 
   4794   41 ) # 41. synclines.at:95: Prologue synch line
   4795     at_setup_line='synclines.at:95'
   4796     at_desc='Prologue synch line'
   4797     $at_quiet $ECHO_N " 41: Prologue synch line                          $ECHO_C"
   4798     at_xfail=no
   4799     (
   4800       echo "41. synclines.at:95: testing ..."
   4801       $at_traceon
   4802 
   4803 
   4804 # It seems impossible to find a generic scheme to check the location
   4805 # of an error.  Even requiring GCC is not sufficient, since for instance
   4806 # the version modified by Apple:
   4807 #
   4808 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   4809 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   4810 # | 19991024 (release) configure:2124: $? = 0
   4811 #
   4812 # instead of:
   4813 #
   4814 # | input.y:2: #error "2"
   4815 #
   4816 # it reports:
   4817 #
   4818 # | input.y:2: "2"
   4819 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   4820 
   4821 cat >syncline.c <<'_ATEOF'
   4822 #error "1"
   4823 _ATEOF
   4824 
   4825 
   4826 $at_traceoff
   4827 echo "synclines.at:95: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   4828 echo synclines.at:95 >$at_check_line_file
   4829 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   4830 at_status=$?
   4831 grep '^ *+' $at_stder1 >&2
   4832 grep -v '^ *+' $at_stder1 >$at_stderr
   4833 at_failed=false
   4834 echo stderr:; tee stderr <$at_stderr
   4835 $at_diff $at_devnull $at_stdout || at_failed=:
   4836 case $at_status in
   4837    77) echo 77 > $at_status_file
   4838             exit 77;;
   4839    *);;
   4840 esac
   4841 if $at_failed; then
   4842 
   4843   echo 1 > $at_status_file
   4844   exit 1
   4845 fi
   4846 
   4847 $at_traceon
   4848 
   4849 # In case GCC displays column information, strip it down.
   4850 #
   4851 #   input.y:4:2: #error "4"    or
   4852 #   input.y:4.2: #error "4"    or
   4853 #   input.y:4:2: error: #error "4"
   4854 # =>
   4855 #   input.y:4: #error "4"
   4856 #
   4857 $at_traceoff
   4858 echo "synclines.at:95: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   4859 echo synclines.at:95 >$at_check_line_file
   4860 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   4861 at_status=$?
   4862 grep '^ *+' $at_stder1 >&2
   4863 grep -v '^ *+' $at_stder1 >$at_stderr
   4864 at_failed=false
   4865 $at_diff $at_devnull $at_stderr || at_failed=:
   4866 echo stdout:; tee stdout <$at_stdout
   4867 case $at_status in
   4868    77) echo 77 > $at_status_file
   4869             exit 77;;
   4870    0) ;;
   4871    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   4872       at_failed=:;;
   4873 esac
   4874 if $at_failed; then
   4875 
   4876   echo 1 > $at_status_file
   4877   exit 1
   4878 fi
   4879 
   4880 $at_traceon
   4881 
   4882 
   4883 $at_traceoff
   4884 echo "synclines.at:95: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   4885 echo synclines.at:95 >$at_check_line_file
   4886 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   4887 at_status=$?
   4888 grep '^ *+' $at_stder1 >&2
   4889 grep -v '^ *+' $at_stder1 >$at_stderr
   4890 at_failed=false
   4891 $at_diff $at_devnull $at_stderr || at_failed=:
   4892 $at_diff $at_devnull $at_stdout || at_failed=:
   4893 case $at_status in
   4894    77) echo 77 > $at_status_file
   4895             exit 77;;
   4896    0) ;;
   4897    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   4898       at_failed=:;;
   4899 esac
   4900 if $at_failed; then
   4901 
   4902   echo 1 > $at_status_file
   4903   exit 1
   4904 fi
   4905 
   4906 $at_traceon
   4907 
   4908 
   4909 cat >input.y <<'_ATEOF'
   4910 %{
   4911 #error "2"
   4912 void yyerror (const char *s);
   4913 int yylex (void);
   4914 %}
   4915 %%
   4916 exp: '0';
   4917 _ATEOF
   4918 
   4919 $at_traceoff
   4920 echo "synclines.at:95: bison -o input.c input.y"
   4921 echo synclines.at:95 >$at_check_line_file
   4922 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   4923 at_status=$?
   4924 grep '^ *+' $at_stder1 >&2
   4925 grep -v '^ *+' $at_stder1 >$at_stderr
   4926 at_failed=false
   4927 $at_diff $at_devnull $at_stderr || at_failed=:
   4928 $at_diff $at_devnull $at_stdout || at_failed=:
   4929 case $at_status in
   4930    77) echo 77 > $at_status_file
   4931             exit 77;;
   4932    0) ;;
   4933    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   4934       at_failed=:;;
   4935 esac
   4936 if $at_failed; then
   4937 
   4938   echo 1 > $at_status_file
   4939   exit 1
   4940 fi
   4941 
   4942 $at_traceon
   4943 
   4944 $at_traceoff
   4945 echo "synclines.at:95: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   4946 echo synclines.at:95 >$at_check_line_file
   4947 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   4948 at_status=$?
   4949 grep '^ *+' $at_stder1 >&2
   4950 grep -v '^ *+' $at_stder1 >$at_stderr
   4951 at_failed=false
   4952 echo stderr:; tee stderr <$at_stderr
   4953 $at_diff $at_devnull $at_stdout || at_failed=:
   4954 case $at_status in
   4955    77) echo 77 > $at_status_file
   4956             exit 77;;
   4957    *);;
   4958 esac
   4959 if $at_failed; then
   4960 
   4961   echo 1 > $at_status_file
   4962   exit 1
   4963 fi
   4964 
   4965 $at_traceon
   4966 
   4967 # In case GCC displays column information, strip it down.
   4968 #
   4969 #   input.y:4:2: #error "4"    or
   4970 #   input.y:4.2: #error "4"    or
   4971 #   input.y:4:2: error: #error "4"
   4972 # =>
   4973 #   input.y:4: #error "4"
   4974 #
   4975 $at_traceoff
   4976 echo "synclines.at:95: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   4977 echo synclines.at:95 >$at_check_line_file
   4978 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   4979 at_status=$?
   4980 grep '^ *+' $at_stder1 >&2
   4981 grep -v '^ *+' $at_stder1 >$at_stderr
   4982 at_failed=false
   4983 $at_diff $at_devnull $at_stderr || at_failed=:
   4984 echo stdout:; tee stdout <$at_stdout
   4985 case $at_status in
   4986    77) echo 77 > $at_status_file
   4987             exit 77;;
   4988    0) ;;
   4989    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   4990       at_failed=:;;
   4991 esac
   4992 if $at_failed; then
   4993 
   4994   echo 1 > $at_status_file
   4995   exit 1
   4996 fi
   4997 
   4998 $at_traceon
   4999 
   5000 
   5001 $at_traceoff
   5002 echo "synclines.at:95: cat stdout"
   5003 echo synclines.at:95 >$at_check_line_file
   5004 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5005 at_status=$?
   5006 grep '^ *+' $at_stder1 >&2
   5007 grep -v '^ *+' $at_stder1 >$at_stderr
   5008 at_failed=false
   5009 $at_diff $at_devnull $at_stderr || at_failed=:
   5010 echo >>$at_stdout; echo "input.y:2: #error \"2\"
   5011 " | $at_diff - $at_stdout || at_failed=:
   5012 case $at_status in
   5013    77) echo 77 > $at_status_file
   5014             exit 77;;
   5015    0) ;;
   5016    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   5017       at_failed=:;;
   5018 esac
   5019 if $at_failed; then
   5020 
   5021   echo 1 > $at_status_file
   5022   exit 1
   5023 fi
   5024 
   5025 $at_traceon
   5026 
   5027       $at_traceoff
   5028       $at_times_p && times >$at_times_file
   5029     ) 5>&1 2>&1 | eval $at_tee_pipe
   5030     at_status=`cat $at_status_file`
   5031     ;;
   5032 
   5033   42 ) # 42. synclines.at:115: %union synch line
   5034     at_setup_line='synclines.at:115'
   5035     at_desc='%union synch line'
   5036     $at_quiet $ECHO_N " 42: %union synch line                            $ECHO_C"
   5037     at_xfail=no
   5038     (
   5039       echo "42. synclines.at:115: testing ..."
   5040       $at_traceon
   5041 
   5042 
   5043 # It seems impossible to find a generic scheme to check the location
   5044 # of an error.  Even requiring GCC is not sufficient, since for instance
   5045 # the version modified by Apple:
   5046 #
   5047 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   5048 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   5049 # | 19991024 (release) configure:2124: $? = 0
   5050 #
   5051 # instead of:
   5052 #
   5053 # | input.y:2: #error "2"
   5054 #
   5055 # it reports:
   5056 #
   5057 # | input.y:2: "2"
   5058 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   5059 
   5060 cat >syncline.c <<'_ATEOF'
   5061 #error "1"
   5062 _ATEOF
   5063 
   5064 
   5065 $at_traceoff
   5066 echo "synclines.at:115: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   5067 echo synclines.at:115 >$at_check_line_file
   5068 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   5069 at_status=$?
   5070 grep '^ *+' $at_stder1 >&2
   5071 grep -v '^ *+' $at_stder1 >$at_stderr
   5072 at_failed=false
   5073 echo stderr:; tee stderr <$at_stderr
   5074 $at_diff $at_devnull $at_stdout || at_failed=:
   5075 case $at_status in
   5076    77) echo 77 > $at_status_file
   5077             exit 77;;
   5078    *);;
   5079 esac
   5080 if $at_failed; then
   5081 
   5082   echo 1 > $at_status_file
   5083   exit 1
   5084 fi
   5085 
   5086 $at_traceon
   5087 
   5088 # In case GCC displays column information, strip it down.
   5089 #
   5090 #   input.y:4:2: #error "4"    or
   5091 #   input.y:4.2: #error "4"    or
   5092 #   input.y:4:2: error: #error "4"
   5093 # =>
   5094 #   input.y:4: #error "4"
   5095 #
   5096 $at_traceoff
   5097 echo "synclines.at:115: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5098 echo synclines.at:115 >$at_check_line_file
   5099 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5100 at_status=$?
   5101 grep '^ *+' $at_stder1 >&2
   5102 grep -v '^ *+' $at_stder1 >$at_stderr
   5103 at_failed=false
   5104 $at_diff $at_devnull $at_stderr || at_failed=:
   5105 echo stdout:; tee stdout <$at_stdout
   5106 case $at_status in
   5107    77) echo 77 > $at_status_file
   5108             exit 77;;
   5109    0) ;;
   5110    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5111       at_failed=:;;
   5112 esac
   5113 if $at_failed; then
   5114 
   5115   echo 1 > $at_status_file
   5116   exit 1
   5117 fi
   5118 
   5119 $at_traceon
   5120 
   5121 
   5122 $at_traceoff
   5123 echo "synclines.at:115: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   5124 echo synclines.at:115 >$at_check_line_file
   5125 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   5126 at_status=$?
   5127 grep '^ *+' $at_stder1 >&2
   5128 grep -v '^ *+' $at_stder1 >$at_stderr
   5129 at_failed=false
   5130 $at_diff $at_devnull $at_stderr || at_failed=:
   5131 $at_diff $at_devnull $at_stdout || at_failed=:
   5132 case $at_status in
   5133    77) echo 77 > $at_status_file
   5134             exit 77;;
   5135    0) ;;
   5136    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5137       at_failed=:;;
   5138 esac
   5139 if $at_failed; then
   5140 
   5141   echo 1 > $at_status_file
   5142   exit 1
   5143 fi
   5144 
   5145 $at_traceon
   5146 
   5147 
   5148 cat >input.y <<'_ATEOF'
   5149 %union {
   5150 #error "2"
   5151   char dummy;
   5152 }
   5153 %{
   5154 void yyerror (const char *s);
   5155 int yylex (void);
   5156 %}
   5157 %%
   5158 exp: '0';
   5159 _ATEOF
   5160 
   5161 $at_traceoff
   5162 echo "synclines.at:115: bison -o input.c input.y"
   5163 echo synclines.at:115 >$at_check_line_file
   5164 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   5165 at_status=$?
   5166 grep '^ *+' $at_stder1 >&2
   5167 grep -v '^ *+' $at_stder1 >$at_stderr
   5168 at_failed=false
   5169 $at_diff $at_devnull $at_stderr || at_failed=:
   5170 $at_diff $at_devnull $at_stdout || at_failed=:
   5171 case $at_status in
   5172    77) echo 77 > $at_status_file
   5173             exit 77;;
   5174    0) ;;
   5175    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5176       at_failed=:;;
   5177 esac
   5178 if $at_failed; then
   5179 
   5180   echo 1 > $at_status_file
   5181   exit 1
   5182 fi
   5183 
   5184 $at_traceon
   5185 
   5186 $at_traceoff
   5187 echo "synclines.at:115: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   5188 echo synclines.at:115 >$at_check_line_file
   5189 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   5190 at_status=$?
   5191 grep '^ *+' $at_stder1 >&2
   5192 grep -v '^ *+' $at_stder1 >$at_stderr
   5193 at_failed=false
   5194 echo stderr:; tee stderr <$at_stderr
   5195 $at_diff $at_devnull $at_stdout || at_failed=:
   5196 case $at_status in
   5197    77) echo 77 > $at_status_file
   5198             exit 77;;
   5199    *);;
   5200 esac
   5201 if $at_failed; then
   5202 
   5203   echo 1 > $at_status_file
   5204   exit 1
   5205 fi
   5206 
   5207 $at_traceon
   5208 
   5209 # In case GCC displays column information, strip it down.
   5210 #
   5211 #   input.y:4:2: #error "4"    or
   5212 #   input.y:4.2: #error "4"    or
   5213 #   input.y:4:2: error: #error "4"
   5214 # =>
   5215 #   input.y:4: #error "4"
   5216 #
   5217 $at_traceoff
   5218 echo "synclines.at:115: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5219 echo synclines.at:115 >$at_check_line_file
   5220 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5221 at_status=$?
   5222 grep '^ *+' $at_stder1 >&2
   5223 grep -v '^ *+' $at_stder1 >$at_stderr
   5224 at_failed=false
   5225 $at_diff $at_devnull $at_stderr || at_failed=:
   5226 echo stdout:; tee stdout <$at_stdout
   5227 case $at_status in
   5228    77) echo 77 > $at_status_file
   5229             exit 77;;
   5230    0) ;;
   5231    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5232       at_failed=:;;
   5233 esac
   5234 if $at_failed; then
   5235 
   5236   echo 1 > $at_status_file
   5237   exit 1
   5238 fi
   5239 
   5240 $at_traceon
   5241 
   5242 
   5243 $at_traceoff
   5244 echo "synclines.at:115: cat stdout"
   5245 echo synclines.at:115 >$at_check_line_file
   5246 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5247 at_status=$?
   5248 grep '^ *+' $at_stder1 >&2
   5249 grep -v '^ *+' $at_stder1 >$at_stderr
   5250 at_failed=false
   5251 $at_diff $at_devnull $at_stderr || at_failed=:
   5252 echo >>$at_stdout; echo "input.y:2: #error \"2\"
   5253 " | $at_diff - $at_stdout || at_failed=:
   5254 case $at_status in
   5255    77) echo 77 > $at_status_file
   5256             exit 77;;
   5257    0) ;;
   5258    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5259       at_failed=:;;
   5260 esac
   5261 if $at_failed; then
   5262 
   5263   echo 1 > $at_status_file
   5264   exit 1
   5265 fi
   5266 
   5267 $at_traceon
   5268 
   5269       $at_traceoff
   5270       $at_times_p && times >$at_times_file
   5271     ) 5>&1 2>&1 | eval $at_tee_pipe
   5272     at_status=`cat $at_status_file`
   5273     ;;
   5274 
   5275   43 ) # 43. synclines.at:138: Postprologue synch line
   5276     at_setup_line='synclines.at:138'
   5277     at_desc='Postprologue synch line'
   5278     $at_quiet $ECHO_N " 43: Postprologue synch line                      $ECHO_C"
   5279     at_xfail=no
   5280     (
   5281       echo "43. synclines.at:138: testing ..."
   5282       $at_traceon
   5283 
   5284 
   5285 # It seems impossible to find a generic scheme to check the location
   5286 # of an error.  Even requiring GCC is not sufficient, since for instance
   5287 # the version modified by Apple:
   5288 #
   5289 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   5290 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   5291 # | 19991024 (release) configure:2124: $? = 0
   5292 #
   5293 # instead of:
   5294 #
   5295 # | input.y:2: #error "2"
   5296 #
   5297 # it reports:
   5298 #
   5299 # | input.y:2: "2"
   5300 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   5301 
   5302 cat >syncline.c <<'_ATEOF'
   5303 #error "1"
   5304 _ATEOF
   5305 
   5306 
   5307 $at_traceoff
   5308 echo "synclines.at:138: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   5309 echo synclines.at:138 >$at_check_line_file
   5310 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   5311 at_status=$?
   5312 grep '^ *+' $at_stder1 >&2
   5313 grep -v '^ *+' $at_stder1 >$at_stderr
   5314 at_failed=false
   5315 echo stderr:; tee stderr <$at_stderr
   5316 $at_diff $at_devnull $at_stdout || at_failed=:
   5317 case $at_status in
   5318    77) echo 77 > $at_status_file
   5319             exit 77;;
   5320    *);;
   5321 esac
   5322 if $at_failed; then
   5323 
   5324   echo 1 > $at_status_file
   5325   exit 1
   5326 fi
   5327 
   5328 $at_traceon
   5329 
   5330 # In case GCC displays column information, strip it down.
   5331 #
   5332 #   input.y:4:2: #error "4"    or
   5333 #   input.y:4.2: #error "4"    or
   5334 #   input.y:4:2: error: #error "4"
   5335 # =>
   5336 #   input.y:4: #error "4"
   5337 #
   5338 $at_traceoff
   5339 echo "synclines.at:138: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5340 echo synclines.at:138 >$at_check_line_file
   5341 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5342 at_status=$?
   5343 grep '^ *+' $at_stder1 >&2
   5344 grep -v '^ *+' $at_stder1 >$at_stderr
   5345 at_failed=false
   5346 $at_diff $at_devnull $at_stderr || at_failed=:
   5347 echo stdout:; tee stdout <$at_stdout
   5348 case $at_status in
   5349    77) echo 77 > $at_status_file
   5350             exit 77;;
   5351    0) ;;
   5352    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5353       at_failed=:;;
   5354 esac
   5355 if $at_failed; then
   5356 
   5357   echo 1 > $at_status_file
   5358   exit 1
   5359 fi
   5360 
   5361 $at_traceon
   5362 
   5363 
   5364 $at_traceoff
   5365 echo "synclines.at:138: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   5366 echo synclines.at:138 >$at_check_line_file
   5367 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   5368 at_status=$?
   5369 grep '^ *+' $at_stder1 >&2
   5370 grep -v '^ *+' $at_stder1 >$at_stderr
   5371 at_failed=false
   5372 $at_diff $at_devnull $at_stderr || at_failed=:
   5373 $at_diff $at_devnull $at_stdout || at_failed=:
   5374 case $at_status in
   5375    77) echo 77 > $at_status_file
   5376             exit 77;;
   5377    0) ;;
   5378    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5379       at_failed=:;;
   5380 esac
   5381 if $at_failed; then
   5382 
   5383   echo 1 > $at_status_file
   5384   exit 1
   5385 fi
   5386 
   5387 $at_traceon
   5388 
   5389 
   5390 cat >input.y <<'_ATEOF'
   5391 %{
   5392 void yyerror (const char *s);
   5393 int yylex (void);
   5394 %}
   5395 %union
   5396 {
   5397   int ival;
   5398 }
   5399 %{
   5400 #error "10"
   5401 %}
   5402 %%
   5403 exp: '0';
   5404 _ATEOF
   5405 
   5406 $at_traceoff
   5407 echo "synclines.at:138: bison -o input.c input.y"
   5408 echo synclines.at:138 >$at_check_line_file
   5409 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   5410 at_status=$?
   5411 grep '^ *+' $at_stder1 >&2
   5412 grep -v '^ *+' $at_stder1 >$at_stderr
   5413 at_failed=false
   5414 $at_diff $at_devnull $at_stderr || at_failed=:
   5415 $at_diff $at_devnull $at_stdout || at_failed=:
   5416 case $at_status in
   5417    77) echo 77 > $at_status_file
   5418             exit 77;;
   5419    0) ;;
   5420    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5421       at_failed=:;;
   5422 esac
   5423 if $at_failed; then
   5424 
   5425   echo 1 > $at_status_file
   5426   exit 1
   5427 fi
   5428 
   5429 $at_traceon
   5430 
   5431 $at_traceoff
   5432 echo "synclines.at:138: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   5433 echo synclines.at:138 >$at_check_line_file
   5434 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   5435 at_status=$?
   5436 grep '^ *+' $at_stder1 >&2
   5437 grep -v '^ *+' $at_stder1 >$at_stderr
   5438 at_failed=false
   5439 echo stderr:; tee stderr <$at_stderr
   5440 $at_diff $at_devnull $at_stdout || at_failed=:
   5441 case $at_status in
   5442    77) echo 77 > $at_status_file
   5443             exit 77;;
   5444    *);;
   5445 esac
   5446 if $at_failed; then
   5447 
   5448   echo 1 > $at_status_file
   5449   exit 1
   5450 fi
   5451 
   5452 $at_traceon
   5453 
   5454 # In case GCC displays column information, strip it down.
   5455 #
   5456 #   input.y:4:2: #error "4"    or
   5457 #   input.y:4.2: #error "4"    or
   5458 #   input.y:4:2: error: #error "4"
   5459 # =>
   5460 #   input.y:4: #error "4"
   5461 #
   5462 $at_traceoff
   5463 echo "synclines.at:138: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5464 echo synclines.at:138 >$at_check_line_file
   5465 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5466 at_status=$?
   5467 grep '^ *+' $at_stder1 >&2
   5468 grep -v '^ *+' $at_stder1 >$at_stderr
   5469 at_failed=false
   5470 $at_diff $at_devnull $at_stderr || at_failed=:
   5471 echo stdout:; tee stdout <$at_stdout
   5472 case $at_status in
   5473    77) echo 77 > $at_status_file
   5474             exit 77;;
   5475    0) ;;
   5476    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5477       at_failed=:;;
   5478 esac
   5479 if $at_failed; then
   5480 
   5481   echo 1 > $at_status_file
   5482   exit 1
   5483 fi
   5484 
   5485 $at_traceon
   5486 
   5487 
   5488 $at_traceoff
   5489 echo "synclines.at:138: cat stdout"
   5490 echo synclines.at:138 >$at_check_line_file
   5491 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5492 at_status=$?
   5493 grep '^ *+' $at_stder1 >&2
   5494 grep -v '^ *+' $at_stder1 >$at_stderr
   5495 at_failed=false
   5496 $at_diff $at_devnull $at_stderr || at_failed=:
   5497 echo >>$at_stdout; echo "input.y:10: #error \"10\"
   5498 " | $at_diff - $at_stdout || at_failed=:
   5499 case $at_status in
   5500    77) echo 77 > $at_status_file
   5501             exit 77;;
   5502    0) ;;
   5503    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5504       at_failed=:;;
   5505 esac
   5506 if $at_failed; then
   5507 
   5508   echo 1 > $at_status_file
   5509   exit 1
   5510 fi
   5511 
   5512 $at_traceon
   5513 
   5514       $at_traceoff
   5515       $at_times_p && times >$at_times_file
   5516     ) 5>&1 2>&1 | eval $at_tee_pipe
   5517     at_status=`cat $at_status_file`
   5518     ;;
   5519 
   5520   44 ) # 44. synclines.at:157: Action synch line
   5521     at_setup_line='synclines.at:157'
   5522     at_desc='Action synch line'
   5523     $at_quiet $ECHO_N " 44: Action synch line                            $ECHO_C"
   5524     at_xfail=no
   5525     (
   5526       echo "44. synclines.at:157: testing ..."
   5527       $at_traceon
   5528 
   5529 
   5530 # It seems impossible to find a generic scheme to check the location
   5531 # of an error.  Even requiring GCC is not sufficient, since for instance
   5532 # the version modified by Apple:
   5533 #
   5534 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   5535 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   5536 # | 19991024 (release) configure:2124: $? = 0
   5537 #
   5538 # instead of:
   5539 #
   5540 # | input.y:2: #error "2"
   5541 #
   5542 # it reports:
   5543 #
   5544 # | input.y:2: "2"
   5545 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   5546 
   5547 cat >syncline.c <<'_ATEOF'
   5548 #error "1"
   5549 _ATEOF
   5550 
   5551 
   5552 $at_traceoff
   5553 echo "synclines.at:157: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   5554 echo synclines.at:157 >$at_check_line_file
   5555 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   5556 at_status=$?
   5557 grep '^ *+' $at_stder1 >&2
   5558 grep -v '^ *+' $at_stder1 >$at_stderr
   5559 at_failed=false
   5560 echo stderr:; tee stderr <$at_stderr
   5561 $at_diff $at_devnull $at_stdout || at_failed=:
   5562 case $at_status in
   5563    77) echo 77 > $at_status_file
   5564             exit 77;;
   5565    *);;
   5566 esac
   5567 if $at_failed; then
   5568 
   5569   echo 1 > $at_status_file
   5570   exit 1
   5571 fi
   5572 
   5573 $at_traceon
   5574 
   5575 # In case GCC displays column information, strip it down.
   5576 #
   5577 #   input.y:4:2: #error "4"    or
   5578 #   input.y:4.2: #error "4"    or
   5579 #   input.y:4:2: error: #error "4"
   5580 # =>
   5581 #   input.y:4: #error "4"
   5582 #
   5583 $at_traceoff
   5584 echo "synclines.at:157: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5585 echo synclines.at:157 >$at_check_line_file
   5586 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5587 at_status=$?
   5588 grep '^ *+' $at_stder1 >&2
   5589 grep -v '^ *+' $at_stder1 >$at_stderr
   5590 at_failed=false
   5591 $at_diff $at_devnull $at_stderr || at_failed=:
   5592 echo stdout:; tee stdout <$at_stdout
   5593 case $at_status in
   5594    77) echo 77 > $at_status_file
   5595             exit 77;;
   5596    0) ;;
   5597    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5598       at_failed=:;;
   5599 esac
   5600 if $at_failed; then
   5601 
   5602   echo 1 > $at_status_file
   5603   exit 1
   5604 fi
   5605 
   5606 $at_traceon
   5607 
   5608 
   5609 $at_traceoff
   5610 echo "synclines.at:157: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   5611 echo synclines.at:157 >$at_check_line_file
   5612 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   5613 at_status=$?
   5614 grep '^ *+' $at_stder1 >&2
   5615 grep -v '^ *+' $at_stder1 >$at_stderr
   5616 at_failed=false
   5617 $at_diff $at_devnull $at_stderr || at_failed=:
   5618 $at_diff $at_devnull $at_stdout || at_failed=:
   5619 case $at_status in
   5620    77) echo 77 > $at_status_file
   5621             exit 77;;
   5622    0) ;;
   5623    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5624       at_failed=:;;
   5625 esac
   5626 if $at_failed; then
   5627 
   5628   echo 1 > $at_status_file
   5629   exit 1
   5630 fi
   5631 
   5632 $at_traceon
   5633 
   5634 
   5635 cat >input.y <<'_ATEOF'
   5636 %{
   5637 void yyerror (const char *s);
   5638 int yylex (void);
   5639 %}
   5640 %%
   5641 exp:
   5642 {
   5643 #error "8"
   5644 };
   5645 _ATEOF
   5646 
   5647 $at_traceoff
   5648 echo "synclines.at:157: bison -o input.c input.y"
   5649 echo synclines.at:157 >$at_check_line_file
   5650 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   5651 at_status=$?
   5652 grep '^ *+' $at_stder1 >&2
   5653 grep -v '^ *+' $at_stder1 >$at_stderr
   5654 at_failed=false
   5655 $at_diff $at_devnull $at_stderr || at_failed=:
   5656 $at_diff $at_devnull $at_stdout || at_failed=:
   5657 case $at_status in
   5658    77) echo 77 > $at_status_file
   5659             exit 77;;
   5660    0) ;;
   5661    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5662       at_failed=:;;
   5663 esac
   5664 if $at_failed; then
   5665 
   5666   echo 1 > $at_status_file
   5667   exit 1
   5668 fi
   5669 
   5670 $at_traceon
   5671 
   5672 $at_traceoff
   5673 echo "synclines.at:157: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   5674 echo synclines.at:157 >$at_check_line_file
   5675 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   5676 at_status=$?
   5677 grep '^ *+' $at_stder1 >&2
   5678 grep -v '^ *+' $at_stder1 >$at_stderr
   5679 at_failed=false
   5680 echo stderr:; tee stderr <$at_stderr
   5681 $at_diff $at_devnull $at_stdout || at_failed=:
   5682 case $at_status in
   5683    77) echo 77 > $at_status_file
   5684             exit 77;;
   5685    *);;
   5686 esac
   5687 if $at_failed; then
   5688 
   5689   echo 1 > $at_status_file
   5690   exit 1
   5691 fi
   5692 
   5693 $at_traceon
   5694 
   5695 # In case GCC displays column information, strip it down.
   5696 #
   5697 #   input.y:4:2: #error "4"    or
   5698 #   input.y:4.2: #error "4"    or
   5699 #   input.y:4:2: error: #error "4"
   5700 # =>
   5701 #   input.y:4: #error "4"
   5702 #
   5703 $at_traceoff
   5704 echo "synclines.at:157: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5705 echo synclines.at:157 >$at_check_line_file
   5706 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5707 at_status=$?
   5708 grep '^ *+' $at_stder1 >&2
   5709 grep -v '^ *+' $at_stder1 >$at_stderr
   5710 at_failed=false
   5711 $at_diff $at_devnull $at_stderr || at_failed=:
   5712 echo stdout:; tee stdout <$at_stdout
   5713 case $at_status in
   5714    77) echo 77 > $at_status_file
   5715             exit 77;;
   5716    0) ;;
   5717    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5718       at_failed=:;;
   5719 esac
   5720 if $at_failed; then
   5721 
   5722   echo 1 > $at_status_file
   5723   exit 1
   5724 fi
   5725 
   5726 $at_traceon
   5727 
   5728 
   5729 $at_traceoff
   5730 echo "synclines.at:157: cat stdout"
   5731 echo synclines.at:157 >$at_check_line_file
   5732 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5733 at_status=$?
   5734 grep '^ *+' $at_stder1 >&2
   5735 grep -v '^ *+' $at_stder1 >$at_stderr
   5736 at_failed=false
   5737 $at_diff $at_devnull $at_stderr || at_failed=:
   5738 echo >>$at_stdout; echo "input.y:8: #error \"8\"
   5739 " | $at_diff - $at_stdout || at_failed=:
   5740 case $at_status in
   5741    77) echo 77 > $at_status_file
   5742             exit 77;;
   5743    0) ;;
   5744    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5745       at_failed=:;;
   5746 esac
   5747 if $at_failed; then
   5748 
   5749   echo 1 > $at_status_file
   5750   exit 1
   5751 fi
   5752 
   5753 $at_traceon
   5754 
   5755       $at_traceoff
   5756       $at_times_p && times >$at_times_file
   5757     ) 5>&1 2>&1 | eval $at_tee_pipe
   5758     at_status=`cat $at_status_file`
   5759     ;;
   5760 
   5761   45 ) # 45. synclines.at:175: Epilogue synch line
   5762     at_setup_line='synclines.at:175'
   5763     at_desc='Epilogue synch line'
   5764     $at_quiet $ECHO_N " 45: Epilogue synch line                          $ECHO_C"
   5765     at_xfail=no
   5766     (
   5767       echo "45. synclines.at:175: testing ..."
   5768       $at_traceon
   5769 
   5770 
   5771 # It seems impossible to find a generic scheme to check the location
   5772 # of an error.  Even requiring GCC is not sufficient, since for instance
   5773 # the version modified by Apple:
   5774 #
   5775 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   5776 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   5777 # | 19991024 (release) configure:2124: $? = 0
   5778 #
   5779 # instead of:
   5780 #
   5781 # | input.y:2: #error "2"
   5782 #
   5783 # it reports:
   5784 #
   5785 # | input.y:2: "2"
   5786 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   5787 
   5788 cat >syncline.c <<'_ATEOF'
   5789 #error "1"
   5790 _ATEOF
   5791 
   5792 
   5793 $at_traceoff
   5794 echo "synclines.at:175: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   5795 echo synclines.at:175 >$at_check_line_file
   5796 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   5797 at_status=$?
   5798 grep '^ *+' $at_stder1 >&2
   5799 grep -v '^ *+' $at_stder1 >$at_stderr
   5800 at_failed=false
   5801 echo stderr:; tee stderr <$at_stderr
   5802 $at_diff $at_devnull $at_stdout || at_failed=:
   5803 case $at_status in
   5804    77) echo 77 > $at_status_file
   5805             exit 77;;
   5806    *);;
   5807 esac
   5808 if $at_failed; then
   5809 
   5810   echo 1 > $at_status_file
   5811   exit 1
   5812 fi
   5813 
   5814 $at_traceon
   5815 
   5816 # In case GCC displays column information, strip it down.
   5817 #
   5818 #   input.y:4:2: #error "4"    or
   5819 #   input.y:4.2: #error "4"    or
   5820 #   input.y:4:2: error: #error "4"
   5821 # =>
   5822 #   input.y:4: #error "4"
   5823 #
   5824 $at_traceoff
   5825 echo "synclines.at:175: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5826 echo synclines.at:175 >$at_check_line_file
   5827 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5828 at_status=$?
   5829 grep '^ *+' $at_stder1 >&2
   5830 grep -v '^ *+' $at_stder1 >$at_stderr
   5831 at_failed=false
   5832 $at_diff $at_devnull $at_stderr || at_failed=:
   5833 echo stdout:; tee stdout <$at_stdout
   5834 case $at_status in
   5835    77) echo 77 > $at_status_file
   5836             exit 77;;
   5837    0) ;;
   5838    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5839       at_failed=:;;
   5840 esac
   5841 if $at_failed; then
   5842 
   5843   echo 1 > $at_status_file
   5844   exit 1
   5845 fi
   5846 
   5847 $at_traceon
   5848 
   5849 
   5850 $at_traceoff
   5851 echo "synclines.at:175: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   5852 echo synclines.at:175 >$at_check_line_file
   5853 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   5854 at_status=$?
   5855 grep '^ *+' $at_stder1 >&2
   5856 grep -v '^ *+' $at_stder1 >$at_stderr
   5857 at_failed=false
   5858 $at_diff $at_devnull $at_stderr || at_failed=:
   5859 $at_diff $at_devnull $at_stdout || at_failed=:
   5860 case $at_status in
   5861    77) echo 77 > $at_status_file
   5862             exit 77;;
   5863    0) ;;
   5864    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5865       at_failed=:;;
   5866 esac
   5867 if $at_failed; then
   5868 
   5869   echo 1 > $at_status_file
   5870   exit 1
   5871 fi
   5872 
   5873 $at_traceon
   5874 
   5875 
   5876 cat >input.y <<'_ATEOF'
   5877 %{
   5878 void yyerror (const char *s);
   5879 int yylex (void);
   5880 %}
   5881 %%
   5882 exp: '0';
   5883 %%
   5884 #error "8"
   5885 _ATEOF
   5886 
   5887 $at_traceoff
   5888 echo "synclines.at:175: bison -o input.c input.y"
   5889 echo synclines.at:175 >$at_check_line_file
   5890 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   5891 at_status=$?
   5892 grep '^ *+' $at_stder1 >&2
   5893 grep -v '^ *+' $at_stder1 >$at_stderr
   5894 at_failed=false
   5895 $at_diff $at_devnull $at_stderr || at_failed=:
   5896 $at_diff $at_devnull $at_stdout || at_failed=:
   5897 case $at_status in
   5898    77) echo 77 > $at_status_file
   5899             exit 77;;
   5900    0) ;;
   5901    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5902       at_failed=:;;
   5903 esac
   5904 if $at_failed; then
   5905 
   5906   echo 1 > $at_status_file
   5907   exit 1
   5908 fi
   5909 
   5910 $at_traceon
   5911 
   5912 $at_traceoff
   5913 echo "synclines.at:175: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   5914 echo synclines.at:175 >$at_check_line_file
   5915 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   5916 at_status=$?
   5917 grep '^ *+' $at_stder1 >&2
   5918 grep -v '^ *+' $at_stder1 >$at_stderr
   5919 at_failed=false
   5920 echo stderr:; tee stderr <$at_stderr
   5921 $at_diff $at_devnull $at_stdout || at_failed=:
   5922 case $at_status in
   5923    77) echo 77 > $at_status_file
   5924             exit 77;;
   5925    *);;
   5926 esac
   5927 if $at_failed; then
   5928 
   5929   echo 1 > $at_status_file
   5930   exit 1
   5931 fi
   5932 
   5933 $at_traceon
   5934 
   5935 # In case GCC displays column information, strip it down.
   5936 #
   5937 #   input.y:4:2: #error "4"    or
   5938 #   input.y:4.2: #error "4"    or
   5939 #   input.y:4:2: error: #error "4"
   5940 # =>
   5941 #   input.y:4: #error "4"
   5942 #
   5943 $at_traceoff
   5944 echo "synclines.at:175: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5945 echo synclines.at:175 >$at_check_line_file
   5946 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5947 at_status=$?
   5948 grep '^ *+' $at_stder1 >&2
   5949 grep -v '^ *+' $at_stder1 >$at_stderr
   5950 at_failed=false
   5951 $at_diff $at_devnull $at_stderr || at_failed=:
   5952 echo stdout:; tee stdout <$at_stdout
   5953 case $at_status in
   5954    77) echo 77 > $at_status_file
   5955             exit 77;;
   5956    0) ;;
   5957    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5958       at_failed=:;;
   5959 esac
   5960 if $at_failed; then
   5961 
   5962   echo 1 > $at_status_file
   5963   exit 1
   5964 fi
   5965 
   5966 $at_traceon
   5967 
   5968 
   5969 $at_traceoff
   5970 echo "synclines.at:175: cat stdout"
   5971 echo synclines.at:175 >$at_check_line_file
   5972 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5973 at_status=$?
   5974 grep '^ *+' $at_stder1 >&2
   5975 grep -v '^ *+' $at_stder1 >$at_stderr
   5976 at_failed=false
   5977 $at_diff $at_devnull $at_stderr || at_failed=:
   5978 echo >>$at_stdout; echo "input.y:8: #error \"8\"
   5979 " | $at_diff - $at_stdout || at_failed=:
   5980 case $at_status in
   5981    77) echo 77 > $at_status_file
   5982             exit 77;;
   5983    0) ;;
   5984    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5985       at_failed=:;;
   5986 esac
   5987 if $at_failed; then
   5988 
   5989   echo 1 > $at_status_file
   5990   exit 1
   5991 fi
   5992 
   5993 $at_traceon
   5994 
   5995       $at_traceoff
   5996       $at_times_p && times >$at_times_file
   5997     ) 5>&1 2>&1 | eval $at_tee_pipe
   5998     at_status=`cat $at_status_file`
   5999     ;;
   6000 
   6001 
   6002   banner-6 ) # Banner 6. headers.at:19
   6003     cat <<\_ATEOF
   6004 
   6005 Parser Headers.
   6006 
   6007 _ATEOF
   6008     ;;
   6009 
   6010   46 ) # 46. headers.at:27: %union and --defines
   6011     at_setup_line='headers.at:27'
   6012     at_desc='%union and --defines'
   6013     $at_quiet $ECHO_N " 46: %union and --defines                         $ECHO_C"
   6014     at_xfail=no
   6015     (
   6016       echo "46. headers.at:27: testing ..."
   6017       $at_traceon
   6018 
   6019 
   6020 cat >input.y <<'_ATEOF'
   6021 %union
   6022 {
   6023   int   integer;
   6024   char *string ;
   6025 }
   6026 %%
   6027 exp: {};
   6028 _ATEOF
   6029 
   6030 
   6031 $at_traceoff
   6032 echo "headers.at:39: bison --defines input.y"
   6033 echo headers.at:39 >$at_check_line_file
   6034 ( $at_traceon; bison --defines input.y ) >$at_stdout 2>$at_stder1
   6035 at_status=$?
   6036 grep '^ *+' $at_stder1 >&2
   6037 grep -v '^ *+' $at_stder1 >$at_stderr
   6038 at_failed=false
   6039 $at_diff $at_devnull $at_stderr || at_failed=:
   6040 $at_diff $at_devnull $at_stdout || at_failed=:
   6041 case $at_status in
   6042    77) echo 77 > $at_status_file
   6043             exit 77;;
   6044    0) ;;
   6045    *) echo "headers.at:39: exit code was $at_status, expected 0"
   6046       at_failed=:;;
   6047 esac
   6048 if $at_failed; then
   6049 
   6050   echo 1 > $at_status_file
   6051   exit 1
   6052 fi
   6053 
   6054 $at_traceon
   6055 
   6056 
   6057       $at_traceoff
   6058       $at_times_p && times >$at_times_file
   6059     ) 5>&1 2>&1 | eval $at_tee_pipe
   6060     at_status=`cat $at_status_file`
   6061     ;;
   6062 
   6063   47 ) # 47. headers.at:77: Invalid CPP guards: input/input
   6064     at_setup_line='headers.at:77'
   6065     at_desc='Invalid CPP guards: input/input'
   6066     $at_quiet $ECHO_N " 47: Invalid CPP guards: input/input              $ECHO_C"
   6067     at_xfail=no
   6068     (
   6069       echo "47. headers.at:77: testing ..."
   6070       $at_traceon
   6071 
   6072 
   6073 # Possibly create inner directories.
   6074 dirname=`(dirname input/input) 2>/dev/null ||
   6075 $as_expr Xinput/input : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   6076 	 Xinput/input : 'X\(//\)[^/]' \| \
   6077 	 Xinput/input : 'X\(//\)$' \| \
   6078 	 Xinput/input : 'X\(/\)' \| \
   6079 	 .     : '\(.\)' 2>/dev/null ||
   6080 echo Xinput/input |
   6081     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
   6082   	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
   6083   	  /^X\(\/\/\)$/{ s//\1/; q; }
   6084   	  /^X\(\/\).*/{ s//\1/; q; }
   6085   	  s/.*/./; q'`
   6086 { if $as_mkdir_p; then
   6087     mkdir -p $dirname
   6088   else
   6089     as_dir=$dirname
   6090     as_dirs=
   6091     while test ! -d "$as_dir"; do
   6092       as_dirs="$as_dir $as_dirs"
   6093       as_dir=`(dirname "$as_dir") 2>/dev/null ||
   6094 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   6095 	 X"$as_dir" : 'X\(//\)[^/]' \| \
   6096 	 X"$as_dir" : 'X\(//\)$' \| \
   6097 	 X"$as_dir" : 'X\(/\)' \| \
   6098 	 .     : '\(.\)' 2>/dev/null ||
   6099 echo X"$as_dir" |
   6100     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
   6101   	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
   6102   	  /^X\(\/\/\)$/{ s//\1/; q; }
   6103   	  /^X\(\/\).*/{ s//\1/; q; }
   6104   	  s/.*/./; q'`
   6105     done
   6106     test ! -n "$as_dirs" || mkdir $as_dirs
   6107   fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirname" >&5
   6108 echo "$as_me: error: cannot create directory $dirname" >&2;}
   6109    { (exit 1); exit 1; }; }; }
   6110 
   6111 
   6112 cat >input/input.y <<'_ATEOF'
   6113 %{
   6114 #ifdef HAVE_CONFIG_H
   6115 # include <config.h>
   6116   /* We don't need perfect functions for these tests. */
   6117 # undef malloc
   6118 # undef memcmp
   6119 # undef realloc
   6120 #endif
   6121 %}
   6122 
   6123 %{
   6124 #include <input/input.h>
   6125 void yyerror (const char *);
   6126 int yylex (void);
   6127 %}
   6128 %%
   6129 dummy:;
   6130 %%
   6131 #include <input/input.h>
   6132 _ATEOF
   6133 
   6134 
   6135 
   6136 $at_traceoff
   6137 echo "headers.at:77: bison --defines=input/input.h --output=y.tab.c input/input.y"
   6138 echo headers.at:77 >$at_check_line_file
   6139 ( $at_traceon; bison --defines=input/input.h --output=y.tab.c input/input.y ) >$at_stdout 2>$at_stder1
   6140 at_status=$?
   6141 grep '^ *+' $at_stder1 >&2
   6142 grep -v '^ *+' $at_stder1 >$at_stderr
   6143 at_failed=false
   6144 $at_diff $at_devnull $at_stderr || at_failed=:
   6145 $at_diff $at_devnull $at_stdout || at_failed=:
   6146 case $at_status in
   6147    77) echo 77 > $at_status_file
   6148             exit 77;;
   6149    0) ;;
   6150    *) echo "headers.at:77: exit code was $at_status, expected 0"
   6151       at_failed=:;;
   6152 esac
   6153 if $at_failed; then
   6154 
   6155   echo 1 > $at_status_file
   6156   exit 1
   6157 fi
   6158 
   6159 $at_traceon
   6160 
   6161 
   6162 $at_traceoff
   6163 echo "headers.at:77: \$CC \$CFLAGS \$CPPFLAGS -o y.tab.o -I. -c y.tab.c"
   6164 echo headers.at:77 >$at_check_line_file
   6165 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o y.tab.o -I. -c y.tab.c ) >$at_stdout 2>$at_stder1
   6166 at_status=$?
   6167 grep '^ *+' $at_stder1 >&2
   6168 grep -v '^ *+' $at_stder1 >$at_stderr
   6169 at_failed=false
   6170 echo stderr:; cat $at_stderr
   6171 echo stdout:; cat $at_stdout
   6172 case $at_status in
   6173    77) echo 77 > $at_status_file
   6174             exit 77;;
   6175    0) ;;
   6176    *) echo "headers.at:77: exit code was $at_status, expected 0"
   6177       at_failed=:;;
   6178 esac
   6179 if $at_failed; then
   6180 
   6181   echo 1 > $at_status_file
   6182   exit 1
   6183 fi
   6184 
   6185 $at_traceon
   6186 
   6187 
   6188       $at_traceoff
   6189       $at_times_p && times >$at_times_file
   6190     ) 5>&1 2>&1 | eval $at_tee_pipe
   6191     at_status=`cat $at_status_file`
   6192     ;;
   6193 
   6194   48 ) # 48. headers.at:78: Invalid CPP guards: 9foo
   6195     at_setup_line='headers.at:78'
   6196     at_desc='Invalid CPP guards: 9foo'
   6197     $at_quiet $ECHO_N " 48: Invalid CPP guards: 9foo                     $ECHO_C"
   6198     at_xfail=no
   6199     (
   6200       echo "48. headers.at:78: testing ..."
   6201       $at_traceon
   6202 
   6203 
   6204 # Possibly create inner directories.
   6205 dirname=`(dirname 9foo) 2>/dev/null ||
   6206 $as_expr X9foo : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   6207 	 X9foo : 'X\(//\)[^/]' \| \
   6208 	 X9foo : 'X\(//\)$' \| \
   6209 	 X9foo : 'X\(/\)' \| \
   6210 	 .     : '\(.\)' 2>/dev/null ||
   6211 echo X9foo |
   6212     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
   6213   	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
   6214   	  /^X\(\/\/\)$/{ s//\1/; q; }
   6215   	  /^X\(\/\).*/{ s//\1/; q; }
   6216   	  s/.*/./; q'`
   6217 { if $as_mkdir_p; then
   6218     mkdir -p $dirname
   6219   else
   6220     as_dir=$dirname
   6221     as_dirs=
   6222     while test ! -d "$as_dir"; do
   6223       as_dirs="$as_dir $as_dirs"
   6224       as_dir=`(dirname "$as_dir") 2>/dev/null ||
   6225 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   6226 	 X"$as_dir" : 'X\(//\)[^/]' \| \
   6227 	 X"$as_dir" : 'X\(//\)$' \| \
   6228 	 X"$as_dir" : 'X\(/\)' \| \
   6229 	 .     : '\(.\)' 2>/dev/null ||
   6230 echo X"$as_dir" |
   6231     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
   6232   	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
   6233   	  /^X\(\/\/\)$/{ s//\1/; q; }
   6234   	  /^X\(\/\).*/{ s//\1/; q; }
   6235   	  s/.*/./; q'`
   6236     done
   6237     test ! -n "$as_dirs" || mkdir $as_dirs
   6238   fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirname" >&5
   6239 echo "$as_me: error: cannot create directory $dirname" >&2;}
   6240    { (exit 1); exit 1; }; }; }
   6241 
   6242 
   6243 cat >9foo.y <<'_ATEOF'
   6244 %{
   6245 #ifdef HAVE_CONFIG_H
   6246 # include <config.h>
   6247   /* We don't need perfect functions for these tests. */
   6248 # undef malloc
   6249 # undef memcmp
   6250 # undef realloc
   6251 #endif
   6252 %}
   6253 
   6254 %{
   6255 #include <9foo.h>
   6256 void yyerror (const char *);
   6257 int yylex (void);
   6258 %}
   6259 %%
   6260 dummy:;
   6261 %%
   6262 #include <9foo.h>
   6263 _ATEOF
   6264 
   6265 
   6266 
   6267 $at_traceoff
   6268 echo "headers.at:78: bison --defines=9foo.h --output=y.tab.c 9foo.y"
   6269 echo headers.at:78 >$at_check_line_file
   6270 ( $at_traceon; bison --defines=9foo.h --output=y.tab.c 9foo.y ) >$at_stdout 2>$at_stder1
   6271 at_status=$?
   6272 grep '^ *+' $at_stder1 >&2
   6273 grep -v '^ *+' $at_stder1 >$at_stderr
   6274 at_failed=false
   6275 $at_diff $at_devnull $at_stderr || at_failed=:
   6276 $at_diff $at_devnull $at_stdout || at_failed=:
   6277 case $at_status in
   6278    77) echo 77 > $at_status_file
   6279             exit 77;;
   6280    0) ;;
   6281    *) echo "headers.at:78: exit code was $at_status, expected 0"
   6282       at_failed=:;;
   6283 esac
   6284 if $at_failed; then
   6285 
   6286   echo 1 > $at_status_file
   6287   exit 1
   6288 fi
   6289 
   6290 $at_traceon
   6291 
   6292 
   6293 $at_traceoff
   6294 echo "headers.at:78: \$CC \$CFLAGS \$CPPFLAGS -o y.tab.o -I. -c y.tab.c"
   6295 echo headers.at:78 >$at_check_line_file
   6296 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o y.tab.o -I. -c y.tab.c ) >$at_stdout 2>$at_stder1
   6297 at_status=$?
   6298 grep '^ *+' $at_stder1 >&2
   6299 grep -v '^ *+' $at_stder1 >$at_stderr
   6300 at_failed=false
   6301 echo stderr:; cat $at_stderr
   6302 echo stdout:; cat $at_stdout
   6303 case $at_status in
   6304    77) echo 77 > $at_status_file
   6305             exit 77;;
   6306    0) ;;
   6307    *) echo "headers.at:78: exit code was $at_status, expected 0"
   6308       at_failed=:;;
   6309 esac
   6310 if $at_failed; then
   6311 
   6312   echo 1 > $at_status_file
   6313   exit 1
   6314 fi
   6315 
   6316 $at_traceon
   6317 
   6318 
   6319       $at_traceoff
   6320       $at_times_p && times >$at_times_file
   6321     ) 5>&1 2>&1 | eval $at_tee_pipe
   6322     at_status=`cat $at_status_file`
   6323     ;;
   6324 
   6325   49 ) # 49. headers.at:87: export YYLTYPE
   6326     at_setup_line='headers.at:87'
   6327     at_desc='export YYLTYPE'
   6328     $at_quiet $ECHO_N " 49: export YYLTYPE                               $ECHO_C"
   6329     at_xfail=no
   6330     (
   6331       echo "49. headers.at:87: testing ..."
   6332       $at_traceon
   6333 
   6334 
   6335 cat >input.y <<'_ATEOF'
   6336 %{
   6337 #ifdef HAVE_CONFIG_H
   6338 # include <config.h>
   6339   /* We don't need perfect functions for these tests. */
   6340 # undef malloc
   6341 # undef memcmp
   6342 # undef realloc
   6343 #endif
   6344 %}
   6345 
   6346 %locations
   6347 
   6348 %name-prefix="my_"
   6349 %{
   6350 #include <stdio.h>
   6351 #include <stdlib.h>
   6352 
   6353 static int
   6354 my_lex (void)
   6355 {
   6356   return EOF;
   6357 }
   6358 
   6359 static void
   6360 my_error (const char *msg)
   6361 {
   6362   fprintf (stderr, "%s\n", msg);
   6363 }
   6364 
   6365 %}
   6366 %%
   6367 exp:;
   6368 _ATEOF
   6369 
   6370 
   6371 
   6372 $at_traceoff
   6373 echo "headers.at:114: bison --defines -o input.c input.y"
   6374 echo headers.at:114 >$at_check_line_file
   6375 ( $at_traceon; bison --defines -o input.c input.y ) >$at_stdout 2>$at_stder1
   6376 at_status=$?
   6377 grep '^ *+' $at_stder1 >&2
   6378 grep -v '^ *+' $at_stder1 >$at_stderr
   6379 at_failed=false
   6380 $at_diff $at_devnull $at_stderr || at_failed=:
   6381 $at_diff $at_devnull $at_stdout || at_failed=:
   6382 case $at_status in
   6383    77) echo 77 > $at_status_file
   6384             exit 77;;
   6385    0) ;;
   6386    *) echo "headers.at:114: exit code was $at_status, expected 0"
   6387       at_failed=:;;
   6388 esac
   6389 if $at_failed; then
   6390 
   6391   echo 1 > $at_status_file
   6392   exit 1
   6393 fi
   6394 
   6395 $at_traceon
   6396 
   6397 
   6398 # YYLTYPE should be defined, and MY_LLOC declared.
   6399 cat >caller.c <<'_ATEOF'
   6400 #include "input.h"
   6401 YYLTYPE *my_llocp = &my_lloc;
   6402 
   6403 int my_parse (void);
   6404 
   6405 int
   6406 main (void)
   6407 {
   6408   return my_parse ();
   6409 }
   6410 _ATEOF
   6411 
   6412 
   6413 # Link and execute, just to make sure everything is fine (and in
   6414 # particular, that MY_LLOC is indeed defined somewhere).
   6415 $at_traceoff
   6416 echo "headers.at:132: \$CC \$CFLAGS \$CPPFLAGS -o caller.o -c caller.c"
   6417 echo headers.at:132 >$at_check_line_file
   6418 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o caller.o -c caller.c ) >$at_stdout 2>$at_stder1
   6419 at_status=$?
   6420 grep '^ *+' $at_stder1 >&2
   6421 grep -v '^ *+' $at_stder1 >$at_stderr
   6422 at_failed=false
   6423 echo stderr:; cat $at_stderr
   6424 echo stdout:; cat $at_stdout
   6425 case $at_status in
   6426    77) echo 77 > $at_status_file
   6427             exit 77;;
   6428    0) ;;
   6429    *) echo "headers.at:132: exit code was $at_status, expected 0"
   6430       at_failed=:;;
   6431 esac
   6432 if $at_failed; then
   6433 
   6434   echo 1 > $at_status_file
   6435   exit 1
   6436 fi
   6437 
   6438 $at_traceon
   6439 
   6440 $at_traceoff
   6441 echo "headers.at:133: \$CC \$CFLAGS \$CPPFLAGS -o input.o -c input.c"
   6442 echo headers.at:133 >$at_check_line_file
   6443 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -c input.c ) >$at_stdout 2>$at_stder1
   6444 at_status=$?
   6445 grep '^ *+' $at_stder1 >&2
   6446 grep -v '^ *+' $at_stder1 >$at_stderr
   6447 at_failed=false
   6448 echo stderr:; cat $at_stderr
   6449 echo stdout:; cat $at_stdout
   6450 case $at_status in
   6451    77) echo 77 > $at_status_file
   6452             exit 77;;
   6453    0) ;;
   6454    *) echo "headers.at:133: exit code was $at_status, expected 0"
   6455       at_failed=:;;
   6456 esac
   6457 if $at_failed; then
   6458 
   6459   echo 1 > $at_status_file
   6460   exit 1
   6461 fi
   6462 
   6463 $at_traceon
   6464 
   6465 $at_traceoff
   6466 echo "headers.at:134: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o caller caller.o input.o \$LIBS"
   6467 echo headers.at:134 >$at_check_line_file
   6468 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o caller caller.o input.o $LIBS ) >$at_stdout 2>$at_stder1
   6469 at_status=$?
   6470 grep '^ *+' $at_stder1 >&2
   6471 grep -v '^ *+' $at_stder1 >$at_stderr
   6472 at_failed=false
   6473 echo stderr:; cat $at_stderr
   6474 echo stdout:; cat $at_stdout
   6475 case $at_status in
   6476    77) echo 77 > $at_status_file
   6477             exit 77;;
   6478    0) ;;
   6479    *) echo "headers.at:134: exit code was $at_status, expected 0"
   6480       at_failed=:;;
   6481 esac
   6482 if $at_failed; then
   6483 
   6484   echo 1 > $at_status_file
   6485   exit 1
   6486 fi
   6487 
   6488 $at_traceon
   6489 
   6490 $at_traceoff
   6491 echo "headers.at:135: \$PREPARSER ./caller"
   6492 echo headers.at:135 >$at_check_line_file
   6493 ( $at_traceon; $PREPARSER ./caller ) >$at_stdout 2>$at_stder1
   6494 at_status=$?
   6495 grep '^ *+' $at_stder1 >&2
   6496 grep -v '^ *+' $at_stder1 >$at_stderr
   6497 at_failed=false
   6498 $at_diff $at_devnull $at_stderr || at_failed=:
   6499 $at_diff $at_devnull $at_stdout || at_failed=:
   6500 case $at_status in
   6501    77) echo 77 > $at_status_file
   6502             exit 77;;
   6503    0) ;;
   6504    *) echo "headers.at:135: exit code was $at_status, expected 0"
   6505       at_failed=:;;
   6506 esac
   6507 if $at_failed; then
   6508 
   6509   echo 1 > $at_status_file
   6510   exit 1
   6511 fi
   6512 
   6513 $at_traceon
   6514 
   6515 
   6516       $at_traceoff
   6517       $at_times_p && times >$at_times_file
   6518     ) 5>&1 2>&1 | eval $at_tee_pipe
   6519     at_status=`cat $at_status_file`
   6520     ;;
   6521 
   6522 
   6523   banner-7 ) # Banner 7. actions.at:19
   6524     cat <<\_ATEOF
   6525 
   6526 User Actions.
   6527 
   6528 _ATEOF
   6529     ;;
   6530 
   6531   50 ) # 50. actions.at:25: Mid-rule actions
   6532     at_setup_line='actions.at:25'
   6533     at_desc='Mid-rule actions'
   6534     $at_quiet $ECHO_N " 50: Mid-rule actions                             $ECHO_C"
   6535     at_xfail=no
   6536     (
   6537       echo "50. actions.at:25: testing ..."
   6538       $at_traceon
   6539 
   6540 
   6541 # Bison once forgot the mid-rule actions.  It was because the action
   6542 # was attached to the host rule (the one with the mid-rule action),
   6543 # instead of being attached to the empty rule dedicated to this
   6544 # action.
   6545 
   6546 cat >input.y <<'_ATEOF'
   6547 %{
   6548 #ifdef HAVE_CONFIG_H
   6549 # include <config.h>
   6550   /* We don't need perfect functions for these tests. */
   6551 # undef malloc
   6552 # undef memcmp
   6553 # undef realloc
   6554 #endif
   6555 %}
   6556 
   6557 %error-verbose
   6558 %debug
   6559 %{
   6560 # include <stdio.h>
   6561 # include <stdlib.h>
   6562   static void yyerror (const char *msg);
   6563   static int yylex (void);
   6564 %}
   6565 %%
   6566 exp:     { putchar ('0'); }
   6567      '1' { putchar ('1'); }
   6568      '2' { putchar ('2'); }
   6569      '3' { putchar ('3'); }
   6570      '4' { putchar ('4'); }
   6571      '5' { putchar ('5'); }
   6572      '6' { putchar ('6'); }
   6573      '7' { putchar ('7'); }
   6574      '8' { putchar ('8'); }
   6575      '9' { putchar ('9'); }
   6576          { putchar ('\n'); }
   6577    ;
   6578 %%
   6579 static int
   6580 yylex (void)
   6581 {
   6582   static const char *input = "123456789";
   6583   return *input++;
   6584 }
   6585 
   6586 static void
   6587 yyerror (const char *msg)
   6588 {
   6589   fprintf (stderr, "%s\n", msg);
   6590 }
   6591 
   6592 int
   6593 main (void)
   6594 {
   6595   return yyparse ();
   6596 }
   6597 _ATEOF
   6598 
   6599 
   6600 
   6601 $at_traceoff
   6602 echo "actions.at:75: bison -d -v -o input.c input.y"
   6603 echo actions.at:75 >$at_check_line_file
   6604 ( $at_traceon; bison -d -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   6605 at_status=$?
   6606 grep '^ *+' $at_stder1 >&2
   6607 grep -v '^ *+' $at_stder1 >$at_stderr
   6608 at_failed=false
   6609 $at_diff $at_devnull $at_stderr || at_failed=:
   6610 $at_diff $at_devnull $at_stdout || at_failed=:
   6611 case $at_status in
   6612    77) echo 77 > $at_status_file
   6613             exit 77;;
   6614    0) ;;
   6615    *) echo "actions.at:75: exit code was $at_status, expected 0"
   6616       at_failed=:;;
   6617 esac
   6618 if $at_failed; then
   6619 
   6620   echo 1 > $at_status_file
   6621   exit 1
   6622 fi
   6623 
   6624 $at_traceon
   6625 
   6626 $at_traceoff
   6627 echo "actions.at:76: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   6628 echo actions.at:76 >$at_check_line_file
   6629 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   6630 at_status=$?
   6631 grep '^ *+' $at_stder1 >&2
   6632 grep -v '^ *+' $at_stder1 >$at_stderr
   6633 at_failed=false
   6634 echo stderr:; cat $at_stderr
   6635 echo stdout:; cat $at_stdout
   6636 case $at_status in
   6637    77) echo 77 > $at_status_file
   6638             exit 77;;
   6639    0) ;;
   6640    *) echo "actions.at:76: exit code was $at_status, expected 0"
   6641       at_failed=:;;
   6642 esac
   6643 if $at_failed; then
   6644 
   6645   echo 1 > $at_status_file
   6646   exit 1
   6647 fi
   6648 
   6649 $at_traceon
   6650 
   6651 $at_traceoff
   6652 echo "actions.at:79: \$PREPARSER ./input"
   6653 echo actions.at:79 >$at_check_line_file
   6654 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   6655 at_status=$?
   6656 grep '^ *+' $at_stder1 >&2
   6657 grep -v '^ *+' $at_stder1 >$at_stderr
   6658 at_failed=false
   6659 $at_diff $at_devnull $at_stderr || at_failed=:
   6660 echo >>$at_stdout; echo "0123456789
   6661 " | $at_diff - $at_stdout || at_failed=:
   6662 case $at_status in
   6663    77) echo 77 > $at_status_file
   6664             exit 77;;
   6665    0) ;;
   6666    *) echo "actions.at:79: exit code was $at_status, expected 0"
   6667       at_failed=:;;
   6668 esac
   6669 if $at_failed; then
   6670 
   6671   echo 1 > $at_status_file
   6672   exit 1
   6673 fi
   6674 
   6675 $at_traceon
   6676 
   6677 
   6678       $at_traceoff
   6679       $at_times_p && times >$at_times_file
   6680     ) 5>&1 2>&1 | eval $at_tee_pipe
   6681     at_status=`cat $at_status_file`
   6682     ;;
   6683 
   6684   51 ) # 51. actions.at:91: Exotic Dollars
   6685     at_setup_line='actions.at:91'
   6686     at_desc='Exotic Dollars'
   6687     $at_quiet $ECHO_N " 51: Exotic Dollars                               $ECHO_C"
   6688     at_xfail=no
   6689     (
   6690       echo "51. actions.at:91: testing ..."
   6691       $at_traceon
   6692 
   6693 
   6694 cat >input.y <<'_ATEOF'
   6695 %{
   6696 #ifdef HAVE_CONFIG_H
   6697 # include <config.h>
   6698   /* We don't need perfect functions for these tests. */
   6699 # undef malloc
   6700 # undef memcmp
   6701 # undef realloc
   6702 #endif
   6703 %}
   6704 
   6705 %error-verbose
   6706 %debug
   6707 %{
   6708 # include <stdio.h>
   6709 # include <stdlib.h>
   6710   static void yyerror (const char *msg);
   6711   static int yylex (void);
   6712 # define USE(Var)
   6713 %}
   6714 
   6715 %union
   6716 {
   6717   int val;
   6718 };
   6719 
   6720 %type <val> a_1 a_2 a_5
   6721             sum_of_the_five_previous_values
   6722 
   6723 %%
   6724 exp: a_1 a_2 { $<val>$ = 3; } { $<val>$ = $<val>3 + 1; } a_5
   6725      sum_of_the_five_previous_values
   6726     {
   6727        USE (($1, $2, $<foo>3, $<foo>4, $5));
   6728        printf ("%d\n", $6);
   6729     }
   6730 ;
   6731 a_1: { $$ = 1; };
   6732 a_2: { $$ = 2; };
   6733 a_5: { $$ = 5; };
   6734 
   6735 sum_of_the_five_previous_values:
   6736     {
   6737        $$ = $<val>0 + $<val>-1 + $<val>-2 + $<val>-3 + $<val>-4;
   6738     }
   6739 ;
   6740 
   6741 %%
   6742 static int
   6743 yylex (void)
   6744 {
   6745   return EOF;
   6746 }
   6747 
   6748 static void
   6749 yyerror (const char *msg)
   6750 {
   6751   fprintf (stderr, "%s\n", msg);
   6752 }
   6753 
   6754 int
   6755 main (void)
   6756 {
   6757   return yyparse ();
   6758 }
   6759 _ATEOF
   6760 
   6761 
   6762 
   6763 $at_traceoff
   6764 echo "actions.at:150: bison -d -v -o input.c input.y"
   6765 echo actions.at:150 >$at_check_line_file
   6766 ( $at_traceon; bison -d -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   6767 at_status=$?
   6768 grep '^ *+' $at_stder1 >&2
   6769 grep -v '^ *+' $at_stder1 >$at_stderr
   6770 at_failed=false
   6771 $at_diff $at_devnull $at_stderr || at_failed=:
   6772 $at_diff $at_devnull $at_stdout || at_failed=:
   6773 case $at_status in
   6774    77) echo 77 > $at_status_file
   6775             exit 77;;
   6776    0) ;;
   6777    *) echo "actions.at:150: exit code was $at_status, expected 0"
   6778       at_failed=:;;
   6779 esac
   6780 if $at_failed; then
   6781 
   6782   echo 1 > $at_status_file
   6783   exit 1
   6784 fi
   6785 
   6786 $at_traceon
   6787 
   6788 $at_traceoff
   6789 echo "actions.at:151: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   6790 echo actions.at:151 >$at_check_line_file
   6791 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   6792 at_status=$?
   6793 grep '^ *+' $at_stder1 >&2
   6794 grep -v '^ *+' $at_stder1 >$at_stderr
   6795 at_failed=false
   6796 echo stderr:; cat $at_stderr
   6797 echo stdout:; cat $at_stdout
   6798 case $at_status in
   6799    77) echo 77 > $at_status_file
   6800             exit 77;;
   6801    0) ;;
   6802    *) echo "actions.at:151: exit code was $at_status, expected 0"
   6803       at_failed=:;;
   6804 esac
   6805 if $at_failed; then
   6806 
   6807   echo 1 > $at_status_file
   6808   exit 1
   6809 fi
   6810 
   6811 $at_traceon
   6812 
   6813 $at_traceoff
   6814 echo "actions.at:154: \$PREPARSER ./input"
   6815 echo actions.at:154 >$at_check_line_file
   6816 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   6817 at_status=$?
   6818 grep '^ *+' $at_stder1 >&2
   6819 grep -v '^ *+' $at_stder1 >$at_stderr
   6820 at_failed=false
   6821 $at_diff $at_devnull $at_stderr || at_failed=:
   6822 echo >>$at_stdout; echo "15
   6823 " | $at_diff - $at_stdout || at_failed=:
   6824 case $at_status in
   6825    77) echo 77 > $at_status_file
   6826             exit 77;;
   6827    0) ;;
   6828    *) echo "actions.at:154: exit code was $at_status, expected 0"
   6829       at_failed=:;;
   6830 esac
   6831 if $at_failed; then
   6832 
   6833   echo 1 > $at_status_file
   6834   exit 1
   6835 fi
   6836 
   6837 $at_traceon
   6838 
   6839 
   6840       $at_traceoff
   6841       $at_times_p && times >$at_times_file
   6842     ) 5>&1 2>&1 | eval $at_tee_pipe
   6843     at_status=`cat $at_status_file`
   6844     ;;
   6845 
   6846   52 ) # 52. actions.at:527: Printers and Destructors :
   6847     at_setup_line='actions.at:527'
   6848     at_desc='Printers and Destructors : '
   6849     $at_quiet $ECHO_N " 52: Printers and Destructors :                   $ECHO_C"
   6850     at_xfail=no
   6851     (
   6852       echo "52. actions.at:527: testing ..."
   6853       $at_traceon
   6854 
   6855 
   6856 
   6857 # Make sure complex $n work.
   6858 
   6859 # Be sure to pass all the %directives to this macro to have correct
   6860 # helping macros.  So don't put any directly in the Bison file.
   6861 
   6862 
   6863 
   6864 
   6865 # Using yacc.c?
   6866 
   6867 
   6868 
   6869 
   6870 
   6871 
   6872 
   6873 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   6874 
   6875 # yyerror always sees the locations (when activated), except if
   6876 # yacc & pure & !param.
   6877 
   6878 
   6879 # The interface is pure: either because %pure-parser, or because we
   6880 # are using the C++ parsers.
   6881 
   6882 
   6883 
   6884 
   6885 
   6886 
   6887 
   6888 
   6889 
   6890 
   6891 
   6892 cat >input.y <<'_ATEOF'
   6893 %{
   6894 #ifdef HAVE_CONFIG_H
   6895 # include <config.h>
   6896   /* We don't need perfect functions for these tests. */
   6897 # undef malloc
   6898 # undef memcmp
   6899 # undef realloc
   6900 #endif
   6901 %}
   6902 
   6903 %{
   6904 #include <stdio.h>
   6905 #include <stdlib.h>
   6906 #include <assert.h>
   6907 
   6908 #define YYINITDEPTH 10
   6909 #define YYMAXDEPTH 10
   6910 #define RANGE(Location) (Location).first_line, (Location).last_line
   6911 %}
   6912 
   6913 %error-verbose
   6914 %debug
   6915 %verbose
   6916 %locations
   6917 
   6918 
   6919 
   6920 
   6921 %{
   6922 
   6923 static int yylex (void);
   6924 static void yyerror (const char *msg);
   6925 %}
   6926 
   6927 
   6928 
   6929 %printer
   6930   {
   6931     fprintf (yyoutput, "%d", $$);
   6932   }
   6933   input line thing 'x' 'y'
   6934 
   6935 %destructor
   6936   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   6937   input
   6938 
   6939 %destructor
   6940   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   6941   line
   6942 
   6943 %destructor
   6944   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   6945   thing
   6946 
   6947 %destructor
   6948   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   6949   'x'
   6950 
   6951 %destructor
   6952   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   6953   'y'
   6954 
   6955 %%
   6956 /*
   6957    This grammar is made to exercise error recovery.
   6958    "Lines" starting with `(' support error recovery, with
   6959    ')' as synchronizing token.  Lines starting with 'x' can never
   6960    be recovered from if in error.
   6961 */
   6962 
   6963 input:
   6964   /* Nothing. */
   6965     {
   6966       $$ = 0;
   6967       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   6968     }
   6969 | line input /* Right recursive to load the stack so that popping at
   6970 		EOF can	be exercised.  */
   6971     {
   6972       $$ = 2;
   6973       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   6974 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   6975     }
   6976 ;
   6977 
   6978 line:
   6979   thing thing thing ';'
   6980     {
   6981       $$ = $1;
   6982       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   6983               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   6984               $3, RANGE (@3), $4, RANGE (@4));
   6985     }
   6986 | '(' thing thing ')'
   6987     {
   6988       $$ = $1;
   6989       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   6990               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   6991               $3, RANGE (@3), $4, RANGE (@4));
   6992     }
   6993 | '(' thing ')'
   6994     {
   6995       $$ = $1;
   6996       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   6997               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   6998     }
   6999 | '(' error ')'
   7000     {
   7001       $$ = -1;
   7002       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   7003               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   7004     }
   7005 ;
   7006 
   7007 thing:
   7008   'x'
   7009     {
   7010       $$ = $1;
   7011       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   7012               $$, RANGE (@$), $1, RANGE (@1));
   7013     }
   7014 ;
   7015 %%
   7016 /* Alias to ARGV[1]. */
   7017 const char *source = 0;
   7018 
   7019 static int
   7020 yylex (void)
   7021 {
   7022   static unsigned int counter = 0;
   7023 
   7024   int c = (yylval) = counter++;
   7025   /* As in BASIC, line numbers go from 10 to 10.  */
   7026  (yylloc).first_line = (yylloc).first_column = 10 * c;
   7027   (yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
   7028 
   7029 
   7030   if (source[c])
   7031     printf ("sending: '%c'", source[c]);
   7032   else
   7033     printf ("sending: EOF");
   7034   printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
   7035   return source[c];
   7036 }
   7037 
   7038 static void
   7039 yyerror (const char *msg)
   7040 {
   7041   printf ("%d-%d: %s\n", RANGE (yylloc), msg);
   7042 }
   7043 
   7044 int
   7045 main (int argc, const char *argv[])
   7046 {
   7047   int status;
   7048   yydebug = !!getenv ("YYDEBUG");
   7049   assert (argc == 2);
   7050   source = argv[1];
   7051   status = yyparse ();
   7052   switch (status)
   7053     {
   7054       case 0: printf ("Successful parse.\n"); break;
   7055       case 1: printf ("Parsing FAILED.\n"); break;
   7056       default: printf ("Parsing FAILED (status %d).\n", status); break;
   7057     }
   7058   return status;
   7059 }
   7060 _ATEOF
   7061 
   7062 
   7063 
   7064 $at_traceoff
   7065 echo "actions.at:527: bison -o input.c input.y"
   7066 echo actions.at:527 >$at_check_line_file
   7067 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   7068 at_status=$?
   7069 grep '^ *+' $at_stder1 >&2
   7070 grep -v '^ *+' $at_stder1 >$at_stderr
   7071 at_failed=false
   7072 $at_diff $at_devnull $at_stderr || at_failed=:
   7073 $at_diff $at_devnull $at_stdout || at_failed=:
   7074 case $at_status in
   7075    77) echo 77 > $at_status_file
   7076             exit 77;;
   7077    0) ;;
   7078    *) echo "actions.at:527: exit code was $at_status, expected 0"
   7079       at_failed=:;;
   7080 esac
   7081 if $at_failed; then
   7082 
   7083   echo 1 > $at_status_file
   7084   exit 1
   7085 fi
   7086 
   7087 $at_traceon
   7088 
   7089    $at_traceoff
   7090 echo "actions.at:527: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   7091 echo actions.at:527 >$at_check_line_file
   7092 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   7093 at_status=$?
   7094 grep '^ *+' $at_stder1 >&2
   7095 grep -v '^ *+' $at_stder1 >$at_stderr
   7096 at_failed=false
   7097 echo stderr:; cat $at_stderr
   7098 echo stdout:; cat $at_stdout
   7099 case $at_status in
   7100    77) echo 77 > $at_status_file
   7101             exit 77;;
   7102    0) ;;
   7103    *) echo "actions.at:527: exit code was $at_status, expected 0"
   7104       at_failed=:;;
   7105 esac
   7106 if $at_failed; then
   7107 
   7108   echo 1 > $at_status_file
   7109   exit 1
   7110 fi
   7111 
   7112 $at_traceon
   7113 
   7114 
   7115 
   7116 # Check the location of "empty"
   7117 # -----------------------------
   7118 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   7119 # an empty "line" nterm.
   7120 # FIXME: This location is not satisfying.  Depend on the lookahead?
   7121 $at_traceoff
   7122 echo "actions.at:527: \$PREPARSER ./input '(x)'"
   7123 echo actions.at:527 >$at_check_line_file
   7124 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   7125 at_status=$?
   7126 grep '^ *+' $at_stder1 >&2
   7127 grep -v '^ *+' $at_stder1 >$at_stderr
   7128 at_failed=false
   7129 $at_diff $at_devnull $at_stderr || at_failed=:
   7130 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7131 sending: 'x' (1@10-19)
   7132 thing (1@10-19): 'x' (1@10-19)
   7133 sending: ')' (2@20-29)
   7134 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   7135 sending: EOF (3@30-39)
   7136 input (0@29-29): /* Nothing */
   7137 input (2@0-29): line (0@0-29) input (0@29-29)
   7138 Freeing nterm input (2@0-29)
   7139 Successful parse.
   7140 " | $at_diff - $at_stdout || at_failed=:
   7141 case $at_status in
   7142    77) echo 77 > $at_status_file
   7143             exit 77;;
   7144    0) ;;
   7145    *) echo "actions.at:527: exit code was $at_status, expected 0"
   7146       at_failed=:;;
   7147 esac
   7148 if $at_failed; then
   7149 
   7150   echo 1 > $at_status_file
   7151   exit 1
   7152 fi
   7153 
   7154 $at_traceon
   7155 
   7156 
   7157 
   7158 # Check locations in error recovery
   7159 # ---------------------------------
   7160 # '(y)' is an error, but can be recovered from.  But what's the location
   7161 # of the error itself ('y'), and of the resulting reduction ('(error)').
   7162 $at_traceoff
   7163 echo "actions.at:527: \$PREPARSER ./input '(y)'"
   7164 echo actions.at:527 >$at_check_line_file
   7165 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   7166 at_status=$?
   7167 grep '^ *+' $at_stder1 >&2
   7168 grep -v '^ *+' $at_stder1 >$at_stderr
   7169 at_failed=false
   7170 $at_diff $at_devnull $at_stderr || at_failed=:
   7171 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7172 sending: 'y' (1@10-19)
   7173 10-19: syntax error, unexpected 'y', expecting 'x'
   7174 Freeing token 'y' (1@10-19)
   7175 sending: ')' (2@20-29)
   7176 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   7177 sending: EOF (3@30-39)
   7178 input (0@29-29): /* Nothing */
   7179 input (2@0-29): line (-1@0-29) input (0@29-29)
   7180 Freeing nterm input (2@0-29)
   7181 Successful parse.
   7182 " | $at_diff - $at_stdout || at_failed=:
   7183 case $at_status in
   7184    77) echo 77 > $at_status_file
   7185             exit 77;;
   7186    0) ;;
   7187    *) echo "actions.at:527: exit code was $at_status, expected 0"
   7188       at_failed=:;;
   7189 esac
   7190 if $at_failed; then
   7191 
   7192   echo 1 > $at_status_file
   7193   exit 1
   7194 fi
   7195 
   7196 $at_traceon
   7197 
   7198 
   7199 
   7200 # Syntax errors caught by the parser
   7201 # ----------------------------------
   7202 # Exercise the discarding of stack top and input until `error'
   7203 # can be reduced.
   7204 #
   7205 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   7206 #
   7207 # Load the stack and provoke an error that cannot be caught by the
   7208 # grammar, to check that the stack is cleared.  And make sure the
   7209 # lookahead is freed.
   7210 #
   7211 #     '(', 'x', ')',
   7212 #     '(', 'x', ')',
   7213 #     'y'
   7214 $at_traceoff
   7215 echo "actions.at:527: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   7216 echo actions.at:527 >$at_check_line_file
   7217 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   7218 at_status=$?
   7219 grep '^ *+' $at_stder1 >&2
   7220 grep -v '^ *+' $at_stder1 >$at_stderr
   7221 at_failed=false
   7222 $at_diff $at_devnull $at_stderr || at_failed=:
   7223 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7224 sending: 'x' (1@10-19)
   7225 thing (1@10-19): 'x' (1@10-19)
   7226 sending: 'x' (2@20-29)
   7227 thing (2@20-29): 'x' (2@20-29)
   7228 sending: 'x' (3@30-39)
   7229 30-39: syntax error, unexpected 'x', expecting ')'
   7230 Freeing nterm thing (2@20-29)
   7231 Freeing nterm thing (1@10-19)
   7232 Freeing token 'x' (3@30-39)
   7233 sending: 'x' (4@40-49)
   7234 Freeing token 'x' (4@40-49)
   7235 sending: 'x' (5@50-59)
   7236 Freeing token 'x' (5@50-59)
   7237 sending: ')' (6@60-69)
   7238 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   7239 sending: '(' (7@70-79)
   7240 sending: 'x' (8@80-89)
   7241 thing (8@80-89): 'x' (8@80-89)
   7242 sending: ')' (9@90-99)
   7243 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   7244 sending: '(' (10@100-109)
   7245 sending: 'x' (11@110-119)
   7246 thing (11@110-119): 'x' (11@110-119)
   7247 sending: ')' (12@120-129)
   7248 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   7249 sending: 'y' (13@130-139)
   7250 input (0@129-129): /* Nothing */
   7251 input (2@100-129): line (10@100-129) input (0@129-129)
   7252 input (2@70-129): line (7@70-99) input (2@100-129)
   7253 input (2@0-129): line (-1@0-69) input (2@70-129)
   7254 130-139: syntax error, unexpected 'y', expecting \$end
   7255 Freeing nterm input (2@0-129)
   7256 Freeing token 'y' (13@130-139)
   7257 Parsing FAILED.
   7258 " | $at_diff - $at_stdout || at_failed=:
   7259 case $at_status in
   7260    77) echo 77 > $at_status_file
   7261             exit 77;;
   7262    1) ;;
   7263    *) echo "actions.at:527: exit code was $at_status, expected 1"
   7264       at_failed=:;;
   7265 esac
   7266 if $at_failed; then
   7267 
   7268   echo 1 > $at_status_file
   7269   exit 1
   7270 fi
   7271 
   7272 $at_traceon
   7273 
   7274 
   7275 # Check destruction upon stack overflow
   7276 # -------------------------------------
   7277 # Upon stack overflow, all symbols on the stack should be destroyed.
   7278 # Only check for yacc.c.
   7279 
   7280 $at_traceoff
   7281 echo "actions.at:527: \$PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)'"
   7282 echo actions.at:527 >$at_check_line_file
   7283 ( $at_traceon; $PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)' ) >$at_stdout 2>$at_stder1
   7284 at_status=$?
   7285 grep '^ *+' $at_stder1 >&2
   7286 grep -v '^ *+' $at_stder1 >$at_stderr
   7287 at_failed=false
   7288 $at_diff $at_devnull $at_stderr || at_failed=:
   7289 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7290 sending: 'x' (1@10-19)
   7291 thing (1@10-19): 'x' (1@10-19)
   7292 sending: ')' (2@20-29)
   7293 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   7294 sending: '(' (3@30-39)
   7295 sending: 'x' (4@40-49)
   7296 thing (4@40-49): 'x' (4@40-49)
   7297 sending: ')' (5@50-59)
   7298 line (3@30-59): '(' (3@30-39) thing (4@40-49) ')' (5@50-59)
   7299 sending: '(' (6@60-69)
   7300 sending: 'x' (7@70-79)
   7301 thing (7@70-79): 'x' (7@70-79)
   7302 sending: ')' (8@80-89)
   7303 line (6@60-89): '(' (6@60-69) thing (7@70-79) ')' (8@80-89)
   7304 sending: '(' (9@90-99)
   7305 sending: 'x' (10@100-109)
   7306 thing (10@100-109): 'x' (10@100-109)
   7307 sending: ')' (11@110-119)
   7308 line (9@90-119): '(' (9@90-99) thing (10@100-109) ')' (11@110-119)
   7309 sending: '(' (12@120-129)
   7310 sending: 'x' (13@130-139)
   7311 thing (13@130-139): 'x' (13@130-139)
   7312 sending: ')' (14@140-149)
   7313 line (12@120-149): '(' (12@120-129) thing (13@130-139) ')' (14@140-149)
   7314 sending: '(' (15@150-159)
   7315 sending: 'x' (16@160-169)
   7316 thing (16@160-169): 'x' (16@160-169)
   7317 sending: ')' (17@170-179)
   7318 line (15@150-179): '(' (15@150-159) thing (16@160-169) ')' (17@170-179)
   7319 sending: '(' (18@180-189)
   7320 sending: 'x' (19@190-199)
   7321 thing (19@190-199): 'x' (19@190-199)
   7322 sending: ')' (20@200-209)
   7323 200-209: memory exhausted
   7324 Freeing nterm thing (19@190-199)
   7325 Freeing nterm line (15@150-179)
   7326 Freeing nterm line (12@120-149)
   7327 Freeing nterm line (9@90-119)
   7328 Freeing nterm line (6@60-89)
   7329 Freeing nterm line (3@30-59)
   7330 Freeing nterm line (0@0-29)
   7331 Parsing FAILED (status 2).
   7332 " | $at_diff - $at_stdout || at_failed=:
   7333 case $at_status in
   7334    77) echo 77 > $at_status_file
   7335             exit 77;;
   7336    2) ;;
   7337    *) echo "actions.at:527: exit code was $at_status, expected 2"
   7338       at_failed=:;;
   7339 esac
   7340 if $at_failed; then
   7341 
   7342   echo 1 > $at_status_file
   7343   exit 1
   7344 fi
   7345 
   7346 $at_traceon
   7347 
   7348 
   7349 
   7350 
   7351 
   7352       $at_traceoff
   7353       $at_times_p && times >$at_times_file
   7354     ) 5>&1 2>&1 | eval $at_tee_pipe
   7355     at_status=`cat $at_status_file`
   7356     ;;
   7357 
   7358   53 ) # 53. actions.at:528: Printers and Destructors with union:
   7359     at_setup_line='actions.at:528'
   7360     at_desc='Printers and Destructors with union: '
   7361     $at_quiet $ECHO_N " 53: Printers and Destructors with union:         $ECHO_C"
   7362     at_xfail=no
   7363     (
   7364       echo "53. actions.at:528: testing ..."
   7365       $at_traceon
   7366 
   7367 
   7368 
   7369 # Make sure complex $n work.
   7370 
   7371 # Be sure to pass all the %directives to this macro to have correct
   7372 # helping macros.  So don't put any directly in the Bison file.
   7373 
   7374 
   7375 
   7376 
   7377 # Using yacc.c?
   7378 
   7379 
   7380 
   7381 
   7382 
   7383 
   7384 
   7385 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   7386 
   7387 # yyerror always sees the locations (when activated), except if
   7388 # yacc & pure & !param.
   7389 
   7390 
   7391 # The interface is pure: either because %pure-parser, or because we
   7392 # are using the C++ parsers.
   7393 
   7394 
   7395 
   7396 
   7397 
   7398 
   7399 
   7400 
   7401 
   7402 
   7403 
   7404 cat >input.y <<'_ATEOF'
   7405 %{
   7406 #ifdef HAVE_CONFIG_H
   7407 # include <config.h>
   7408   /* We don't need perfect functions for these tests. */
   7409 # undef malloc
   7410 # undef memcmp
   7411 # undef realloc
   7412 #endif
   7413 %}
   7414 
   7415 %{
   7416 #include <stdio.h>
   7417 #include <stdlib.h>
   7418 #include <assert.h>
   7419 
   7420 #define YYINITDEPTH 10
   7421 #define YYMAXDEPTH 10
   7422 #define RANGE(Location) (Location).first_line, (Location).last_line
   7423 %}
   7424 
   7425 %error-verbose
   7426 %debug
   7427 %verbose
   7428 %locations
   7429 
   7430 %union
   7431 {
   7432   int ival;
   7433 }
   7434 
   7435 
   7436 %{
   7437 
   7438 static int yylex (void);
   7439 static void yyerror (const char *msg);
   7440 %}
   7441 
   7442 %type <ival> '(' 'x' 'y' ')' ';' thing line input
   7443 
   7444 %printer
   7445   {
   7446     fprintf (yyoutput, "%d", $$);
   7447   }
   7448   input line thing 'x' 'y'
   7449 
   7450 %destructor
   7451   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   7452   input
   7453 
   7454 %destructor
   7455   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   7456   line
   7457 
   7458 %destructor
   7459   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   7460   thing
   7461 
   7462 %destructor
   7463   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   7464   'x'
   7465 
   7466 %destructor
   7467   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   7468   'y'
   7469 
   7470 %%
   7471 /*
   7472    This grammar is made to exercise error recovery.
   7473    "Lines" starting with `(' support error recovery, with
   7474    ')' as synchronizing token.  Lines starting with 'x' can never
   7475    be recovered from if in error.
   7476 */
   7477 
   7478 input:
   7479   /* Nothing. */
   7480     {
   7481       $$ = 0;
   7482       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   7483     }
   7484 | line input /* Right recursive to load the stack so that popping at
   7485 		EOF can	be exercised.  */
   7486     {
   7487       $$ = 2;
   7488       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   7489 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   7490     }
   7491 ;
   7492 
   7493 line:
   7494   thing thing thing ';'
   7495     {
   7496       $$ = $1;
   7497       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   7498               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   7499               $3, RANGE (@3), $4, RANGE (@4));
   7500     }
   7501 | '(' thing thing ')'
   7502     {
   7503       $$ = $1;
   7504       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   7505               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   7506               $3, RANGE (@3), $4, RANGE (@4));
   7507     }
   7508 | '(' thing ')'
   7509     {
   7510       $$ = $1;
   7511       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   7512               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   7513     }
   7514 | '(' error ')'
   7515     {
   7516       $$ = -1;
   7517       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   7518               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   7519     }
   7520 ;
   7521 
   7522 thing:
   7523   'x'
   7524     {
   7525       $$ = $1;
   7526       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   7527               $$, RANGE (@$), $1, RANGE (@1));
   7528     }
   7529 ;
   7530 %%
   7531 /* Alias to ARGV[1]. */
   7532 const char *source = 0;
   7533 
   7534 static int
   7535 yylex (void)
   7536 {
   7537   static unsigned int counter = 0;
   7538 
   7539   int c = (yylval).ival = counter++;
   7540   /* As in BASIC, line numbers go from 10 to 10.  */
   7541  (yylloc).first_line = (yylloc).first_column = 10 * c;
   7542   (yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
   7543 
   7544 
   7545   if (source[c])
   7546     printf ("sending: '%c'", source[c]);
   7547   else
   7548     printf ("sending: EOF");
   7549   printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
   7550   return source[c];
   7551 }
   7552 
   7553 static void
   7554 yyerror (const char *msg)
   7555 {
   7556   printf ("%d-%d: %s\n", RANGE (yylloc), msg);
   7557 }
   7558 
   7559 int
   7560 main (int argc, const char *argv[])
   7561 {
   7562   int status;
   7563   yydebug = !!getenv ("YYDEBUG");
   7564   assert (argc == 2);
   7565   source = argv[1];
   7566   status = yyparse ();
   7567   switch (status)
   7568     {
   7569       case 0: printf ("Successful parse.\n"); break;
   7570       case 1: printf ("Parsing FAILED.\n"); break;
   7571       default: printf ("Parsing FAILED (status %d).\n", status); break;
   7572     }
   7573   return status;
   7574 }
   7575 _ATEOF
   7576 
   7577 
   7578 
   7579 $at_traceoff
   7580 echo "actions.at:528: bison -o input.c input.y"
   7581 echo actions.at:528 >$at_check_line_file
   7582 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   7583 at_status=$?
   7584 grep '^ *+' $at_stder1 >&2
   7585 grep -v '^ *+' $at_stder1 >$at_stderr
   7586 at_failed=false
   7587 $at_diff $at_devnull $at_stderr || at_failed=:
   7588 $at_diff $at_devnull $at_stdout || at_failed=:
   7589 case $at_status in
   7590    77) echo 77 > $at_status_file
   7591             exit 77;;
   7592    0) ;;
   7593    *) echo "actions.at:528: exit code was $at_status, expected 0"
   7594       at_failed=:;;
   7595 esac
   7596 if $at_failed; then
   7597 
   7598   echo 1 > $at_status_file
   7599   exit 1
   7600 fi
   7601 
   7602 $at_traceon
   7603 
   7604    $at_traceoff
   7605 echo "actions.at:528: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   7606 echo actions.at:528 >$at_check_line_file
   7607 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   7608 at_status=$?
   7609 grep '^ *+' $at_stder1 >&2
   7610 grep -v '^ *+' $at_stder1 >$at_stderr
   7611 at_failed=false
   7612 echo stderr:; cat $at_stderr
   7613 echo stdout:; cat $at_stdout
   7614 case $at_status in
   7615    77) echo 77 > $at_status_file
   7616             exit 77;;
   7617    0) ;;
   7618    *) echo "actions.at:528: exit code was $at_status, expected 0"
   7619       at_failed=:;;
   7620 esac
   7621 if $at_failed; then
   7622 
   7623   echo 1 > $at_status_file
   7624   exit 1
   7625 fi
   7626 
   7627 $at_traceon
   7628 
   7629 
   7630 
   7631 # Check the location of "empty"
   7632 # -----------------------------
   7633 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   7634 # an empty "line" nterm.
   7635 # FIXME: This location is not satisfying.  Depend on the lookahead?
   7636 $at_traceoff
   7637 echo "actions.at:528: \$PREPARSER ./input '(x)'"
   7638 echo actions.at:528 >$at_check_line_file
   7639 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   7640 at_status=$?
   7641 grep '^ *+' $at_stder1 >&2
   7642 grep -v '^ *+' $at_stder1 >$at_stderr
   7643 at_failed=false
   7644 $at_diff $at_devnull $at_stderr || at_failed=:
   7645 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7646 sending: 'x' (1@10-19)
   7647 thing (1@10-19): 'x' (1@10-19)
   7648 sending: ')' (2@20-29)
   7649 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   7650 sending: EOF (3@30-39)
   7651 input (0@29-29): /* Nothing */
   7652 input (2@0-29): line (0@0-29) input (0@29-29)
   7653 Freeing nterm input (2@0-29)
   7654 Successful parse.
   7655 " | $at_diff - $at_stdout || at_failed=:
   7656 case $at_status in
   7657    77) echo 77 > $at_status_file
   7658             exit 77;;
   7659    0) ;;
   7660    *) echo "actions.at:528: exit code was $at_status, expected 0"
   7661       at_failed=:;;
   7662 esac
   7663 if $at_failed; then
   7664 
   7665   echo 1 > $at_status_file
   7666   exit 1
   7667 fi
   7668 
   7669 $at_traceon
   7670 
   7671 
   7672 
   7673 # Check locations in error recovery
   7674 # ---------------------------------
   7675 # '(y)' is an error, but can be recovered from.  But what's the location
   7676 # of the error itself ('y'), and of the resulting reduction ('(error)').
   7677 $at_traceoff
   7678 echo "actions.at:528: \$PREPARSER ./input '(y)'"
   7679 echo actions.at:528 >$at_check_line_file
   7680 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   7681 at_status=$?
   7682 grep '^ *+' $at_stder1 >&2
   7683 grep -v '^ *+' $at_stder1 >$at_stderr
   7684 at_failed=false
   7685 $at_diff $at_devnull $at_stderr || at_failed=:
   7686 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7687 sending: 'y' (1@10-19)
   7688 10-19: syntax error, unexpected 'y', expecting 'x'
   7689 Freeing token 'y' (1@10-19)
   7690 sending: ')' (2@20-29)
   7691 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   7692 sending: EOF (3@30-39)
   7693 input (0@29-29): /* Nothing */
   7694 input (2@0-29): line (-1@0-29) input (0@29-29)
   7695 Freeing nterm input (2@0-29)
   7696 Successful parse.
   7697 " | $at_diff - $at_stdout || at_failed=:
   7698 case $at_status in
   7699    77) echo 77 > $at_status_file
   7700             exit 77;;
   7701    0) ;;
   7702    *) echo "actions.at:528: exit code was $at_status, expected 0"
   7703       at_failed=:;;
   7704 esac
   7705 if $at_failed; then
   7706 
   7707   echo 1 > $at_status_file
   7708   exit 1
   7709 fi
   7710 
   7711 $at_traceon
   7712 
   7713 
   7714 
   7715 # Syntax errors caught by the parser
   7716 # ----------------------------------
   7717 # Exercise the discarding of stack top and input until `error'
   7718 # can be reduced.
   7719 #
   7720 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   7721 #
   7722 # Load the stack and provoke an error that cannot be caught by the
   7723 # grammar, to check that the stack is cleared.  And make sure the
   7724 # lookahead is freed.
   7725 #
   7726 #     '(', 'x', ')',
   7727 #     '(', 'x', ')',
   7728 #     'y'
   7729 $at_traceoff
   7730 echo "actions.at:528: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   7731 echo actions.at:528 >$at_check_line_file
   7732 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   7733 at_status=$?
   7734 grep '^ *+' $at_stder1 >&2
   7735 grep -v '^ *+' $at_stder1 >$at_stderr
   7736 at_failed=false
   7737 $at_diff $at_devnull $at_stderr || at_failed=:
   7738 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7739 sending: 'x' (1@10-19)
   7740 thing (1@10-19): 'x' (1@10-19)
   7741 sending: 'x' (2@20-29)
   7742 thing (2@20-29): 'x' (2@20-29)
   7743 sending: 'x' (3@30-39)
   7744 30-39: syntax error, unexpected 'x', expecting ')'
   7745 Freeing nterm thing (2@20-29)
   7746 Freeing nterm thing (1@10-19)
   7747 Freeing token 'x' (3@30-39)
   7748 sending: 'x' (4@40-49)
   7749 Freeing token 'x' (4@40-49)
   7750 sending: 'x' (5@50-59)
   7751 Freeing token 'x' (5@50-59)
   7752 sending: ')' (6@60-69)
   7753 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   7754 sending: '(' (7@70-79)
   7755 sending: 'x' (8@80-89)
   7756 thing (8@80-89): 'x' (8@80-89)
   7757 sending: ')' (9@90-99)
   7758 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   7759 sending: '(' (10@100-109)
   7760 sending: 'x' (11@110-119)
   7761 thing (11@110-119): 'x' (11@110-119)
   7762 sending: ')' (12@120-129)
   7763 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   7764 sending: 'y' (13@130-139)
   7765 input (0@129-129): /* Nothing */
   7766 input (2@100-129): line (10@100-129) input (0@129-129)
   7767 input (2@70-129): line (7@70-99) input (2@100-129)
   7768 input (2@0-129): line (-1@0-69) input (2@70-129)
   7769 130-139: syntax error, unexpected 'y', expecting \$end
   7770 Freeing nterm input (2@0-129)
   7771 Freeing token 'y' (13@130-139)
   7772 Parsing FAILED.
   7773 " | $at_diff - $at_stdout || at_failed=:
   7774 case $at_status in
   7775    77) echo 77 > $at_status_file
   7776             exit 77;;
   7777    1) ;;
   7778    *) echo "actions.at:528: exit code was $at_status, expected 1"
   7779       at_failed=:;;
   7780 esac
   7781 if $at_failed; then
   7782 
   7783   echo 1 > $at_status_file
   7784   exit 1
   7785 fi
   7786 
   7787 $at_traceon
   7788 
   7789 
   7790 # Check destruction upon stack overflow
   7791 # -------------------------------------
   7792 # Upon stack overflow, all symbols on the stack should be destroyed.
   7793 # Only check for yacc.c.
   7794 
   7795 $at_traceoff
   7796 echo "actions.at:528: \$PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)'"
   7797 echo actions.at:528 >$at_check_line_file
   7798 ( $at_traceon; $PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)' ) >$at_stdout 2>$at_stder1
   7799 at_status=$?
   7800 grep '^ *+' $at_stder1 >&2
   7801 grep -v '^ *+' $at_stder1 >$at_stderr
   7802 at_failed=false
   7803 $at_diff $at_devnull $at_stderr || at_failed=:
   7804 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7805 sending: 'x' (1@10-19)
   7806 thing (1@10-19): 'x' (1@10-19)
   7807 sending: ')' (2@20-29)
   7808 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   7809 sending: '(' (3@30-39)
   7810 sending: 'x' (4@40-49)
   7811 thing (4@40-49): 'x' (4@40-49)
   7812 sending: ')' (5@50-59)
   7813 line (3@30-59): '(' (3@30-39) thing (4@40-49) ')' (5@50-59)
   7814 sending: '(' (6@60-69)
   7815 sending: 'x' (7@70-79)
   7816 thing (7@70-79): 'x' (7@70-79)
   7817 sending: ')' (8@80-89)
   7818 line (6@60-89): '(' (6@60-69) thing (7@70-79) ')' (8@80-89)
   7819 sending: '(' (9@90-99)
   7820 sending: 'x' (10@100-109)
   7821 thing (10@100-109): 'x' (10@100-109)
   7822 sending: ')' (11@110-119)
   7823 line (9@90-119): '(' (9@90-99) thing (10@100-109) ')' (11@110-119)
   7824 sending: '(' (12@120-129)
   7825 sending: 'x' (13@130-139)
   7826 thing (13@130-139): 'x' (13@130-139)
   7827 sending: ')' (14@140-149)
   7828 line (12@120-149): '(' (12@120-129) thing (13@130-139) ')' (14@140-149)
   7829 sending: '(' (15@150-159)
   7830 sending: 'x' (16@160-169)
   7831 thing (16@160-169): 'x' (16@160-169)
   7832 sending: ')' (17@170-179)
   7833 line (15@150-179): '(' (15@150-159) thing (16@160-169) ')' (17@170-179)
   7834 sending: '(' (18@180-189)
   7835 sending: 'x' (19@190-199)
   7836 thing (19@190-199): 'x' (19@190-199)
   7837 sending: ')' (20@200-209)
   7838 200-209: memory exhausted
   7839 Freeing nterm thing (19@190-199)
   7840 Freeing nterm line (15@150-179)
   7841 Freeing nterm line (12@120-149)
   7842 Freeing nterm line (9@90-119)
   7843 Freeing nterm line (6@60-89)
   7844 Freeing nterm line (3@30-59)
   7845 Freeing nterm line (0@0-29)
   7846 Parsing FAILED (status 2).
   7847 " | $at_diff - $at_stdout || at_failed=:
   7848 case $at_status in
   7849    77) echo 77 > $at_status_file
   7850             exit 77;;
   7851    2) ;;
   7852    *) echo "actions.at:528: exit code was $at_status, expected 2"
   7853       at_failed=:;;
   7854 esac
   7855 if $at_failed; then
   7856 
   7857   echo 1 > $at_status_file
   7858   exit 1
   7859 fi
   7860 
   7861 $at_traceon
   7862 
   7863 
   7864 
   7865 
   7866 
   7867       $at_traceoff
   7868       $at_times_p && times >$at_times_file
   7869     ) 5>&1 2>&1 | eval $at_tee_pipe
   7870     at_status=`cat $at_status_file`
   7871     ;;
   7872 
   7873   54 ) # 54. actions.at:533: Printers and Destructors : %defines %skeleton "lalr1.cc"
   7874     at_setup_line='actions.at:533'
   7875     at_desc='Printers and Destructors : %defines %skeleton "lalr1.cc"'
   7876     $at_quiet $ECHO_N " 54: Printers and Destructors : %defines %skeleton "lalr1.cc"$ECHO_C"
   7877     at_xfail=no
   7878     (
   7879       echo "54. actions.at:533: testing ..."
   7880       $at_traceon
   7881 
   7882 
   7883 
   7884 # Make sure complex $n work.
   7885 
   7886 # Be sure to pass all the %directives to this macro to have correct
   7887 # helping macros.  So don't put any directly in the Bison file.
   7888 
   7889 
   7890 
   7891 
   7892 # Using yacc.c?
   7893 
   7894 
   7895 
   7896 
   7897 
   7898 
   7899 
   7900 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   7901 
   7902 # yyerror always sees the locations (when activated), except if
   7903 # yacc & pure & !param.
   7904 
   7905 
   7906 # The interface is pure: either because %pure-parser, or because we
   7907 # are using the C++ parsers.
   7908 
   7909 
   7910 
   7911 
   7912 
   7913 
   7914 
   7915 
   7916 
   7917 
   7918 
   7919 cat >input.y <<'_ATEOF'
   7920 %{
   7921 #ifdef HAVE_CONFIG_H
   7922 # include <config.h>
   7923   /* We don't need perfect functions for these tests. */
   7924 # undef malloc
   7925 # undef memcmp
   7926 # undef realloc
   7927 #endif
   7928 %}
   7929 
   7930 %{
   7931 #include <stdio.h>
   7932 #include <stdlib.h>
   7933 #include <assert.h>
   7934 
   7935 #define YYINITDEPTH 10
   7936 #define YYMAXDEPTH 10
   7937 #define RANGE(Location) (Location).begin.line, (Location).end.line
   7938 %}
   7939 
   7940 %error-verbose
   7941 %debug
   7942 %verbose
   7943 %locations
   7944 %defines %skeleton "lalr1.cc"
   7945 
   7946 %define "global_tokens_and_yystype"
   7947 
   7948 %{
   7949 typedef yy::location YYLTYPE;
   7950                 #define YYSTYPE int
   7951 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   7952 
   7953 %}
   7954 
   7955 
   7956 
   7957 %printer
   7958   {
   7959     debug_stream () << $$;;
   7960   }
   7961   input line thing 'x' 'y'
   7962 
   7963 %destructor
   7964   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   7965   input
   7966 
   7967 %destructor
   7968   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   7969   line
   7970 
   7971 %destructor
   7972   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   7973   thing
   7974 
   7975 %destructor
   7976   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   7977   'x'
   7978 
   7979 %destructor
   7980   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   7981   'y'
   7982 
   7983 %%
   7984 /*
   7985    This grammar is made to exercise error recovery.
   7986    "Lines" starting with `(' support error recovery, with
   7987    ')' as synchronizing token.  Lines starting with 'x' can never
   7988    be recovered from if in error.
   7989 */
   7990 
   7991 input:
   7992   /* Nothing. */
   7993     {
   7994       $$ = 0;
   7995       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   7996     }
   7997 | line input /* Right recursive to load the stack so that popping at
   7998 		EOF can	be exercised.  */
   7999     {
   8000       $$ = 2;
   8001       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   8002 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   8003     }
   8004 ;
   8005 
   8006 line:
   8007   thing thing thing ';'
   8008     {
   8009       $$ = $1;
   8010       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   8011               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8012               $3, RANGE (@3), $4, RANGE (@4));
   8013     }
   8014 | '(' thing thing ')'
   8015     {
   8016       $$ = $1;
   8017       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8018               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8019               $3, RANGE (@3), $4, RANGE (@4));
   8020     }
   8021 | '(' thing ')'
   8022     {
   8023       $$ = $1;
   8024       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8025               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   8026     }
   8027 | '(' error ')'
   8028     {
   8029       $$ = -1;
   8030       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   8031               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   8032     }
   8033 ;
   8034 
   8035 thing:
   8036   'x'
   8037     {
   8038       $$ = $1;
   8039       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   8040               $$, RANGE (@$), $1, RANGE (@1));
   8041     }
   8042 ;
   8043 %%
   8044 /* Alias to ARGV[1]. */
   8045 const char *source = 0;
   8046 
   8047 static int
   8048 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   8049 {
   8050   static unsigned int counter = 0;
   8051 
   8052   int c = (*lvalp) = counter++;
   8053   /* As in BASIC, line numbers go from 10 to 10.  */
   8054  (*llocp).begin.line = (*llocp).begin.column = 10 * c;
   8055   (*llocp).end.line = (*llocp).end.column = (*llocp).begin.line + 9;
   8056 
   8057 
   8058   if (source[c])
   8059     printf ("sending: '%c'", source[c]);
   8060   else
   8061     printf ("sending: EOF");
   8062   printf (" (%d@%d-%d)\n", c, RANGE ((*llocp)));
   8063   return source[c];
   8064 }
   8065 
   8066 /* A C++ error reporting function. */
   8067 void
   8068 yy::parser::error (const location& l, const std::string& m)
   8069 {
   8070   printf ("%d-%d: %s\n", RANGE (l), m.c_str());
   8071 }
   8072 
   8073 static bool yydebug;
   8074 int
   8075 yyparse ()
   8076 {
   8077   yy::parser parser;
   8078   parser.set_debug_level (yydebug);
   8079   return parser.parse ();
   8080 }
   8081 
   8082 
   8083 int
   8084 main (int argc, const char *argv[])
   8085 {
   8086   int status;
   8087   yydebug = !!getenv ("YYDEBUG");
   8088   assert (argc == 2);
   8089   source = argv[1];
   8090   status = yyparse ();
   8091   switch (status)
   8092     {
   8093       case 0: printf ("Successful parse.\n"); break;
   8094       case 1: printf ("Parsing FAILED.\n"); break;
   8095       default: printf ("Parsing FAILED (status %d).\n", status); break;
   8096     }
   8097   return status;
   8098 }
   8099 _ATEOF
   8100 
   8101 
   8102 
   8103 $at_traceoff
   8104 echo "actions.at:533: bison -o input.cc input.y"
   8105 echo actions.at:533 >$at_check_line_file
   8106 ( $at_traceon; bison -o input.cc input.y ) >$at_stdout 2>$at_stder1
   8107 at_status=$?
   8108 grep '^ *+' $at_stder1 >&2
   8109 grep -v '^ *+' $at_stder1 >$at_stderr
   8110 at_failed=false
   8111 $at_diff $at_devnull $at_stderr || at_failed=:
   8112 $at_diff $at_devnull $at_stdout || at_failed=:
   8113 case $at_status in
   8114    77) echo 77 > $at_status_file
   8115             exit 77;;
   8116    0) ;;
   8117    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8118       at_failed=:;;
   8119 esac
   8120 if $at_failed; then
   8121 
   8122   echo 1 > $at_status_file
   8123   exit 1
   8124 fi
   8125 
   8126 $at_traceon
   8127 
   8128 
   8129 $at_traceoff
   8130 echo "actions.at:533: \$BISON_CXX_WORKS"
   8131 echo actions.at:533 >$at_check_line_file
   8132 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   8133 at_status=$?
   8134 grep '^ *+' $at_stder1 >&2
   8135 grep -v '^ *+' $at_stder1 >$at_stderr
   8136 at_failed=false
   8137 echo stderr:; cat $at_stderr
   8138 echo stdout:; cat $at_stdout
   8139 case $at_status in
   8140    77) echo 77 > $at_status_file
   8141             exit 77;;
   8142    0) ;;
   8143    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8144       at_failed=:;;
   8145 esac
   8146 if $at_failed; then
   8147 
   8148   echo 1 > $at_status_file
   8149   exit 1
   8150 fi
   8151 
   8152 $at_traceon
   8153 
   8154 $at_traceoff
   8155 echo "actions.at:533: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o input input.cc \$LIBS"
   8156 echo actions.at:533 >$at_check_line_file
   8157 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o input input.cc $LIBS ) >$at_stdout 2>$at_stder1
   8158 at_status=$?
   8159 grep '^ *+' $at_stder1 >&2
   8160 grep -v '^ *+' $at_stder1 >$at_stderr
   8161 at_failed=false
   8162 echo stderr:; cat $at_stderr
   8163 echo stdout:; cat $at_stdout
   8164 case $at_status in
   8165    77) echo 77 > $at_status_file
   8166             exit 77;;
   8167    0) ;;
   8168    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8169       at_failed=:;;
   8170 esac
   8171 if $at_failed; then
   8172 
   8173   echo 1 > $at_status_file
   8174   exit 1
   8175 fi
   8176 
   8177 $at_traceon
   8178 
   8179 
   8180 
   8181 # Check the location of "empty"
   8182 # -----------------------------
   8183 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   8184 # an empty "line" nterm.
   8185 # FIXME: This location is not satisfying.  Depend on the lookahead?
   8186 $at_traceoff
   8187 echo "actions.at:533: \$PREPARSER ./input '(x)'"
   8188 echo actions.at:533 >$at_check_line_file
   8189 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   8190 at_status=$?
   8191 grep '^ *+' $at_stder1 >&2
   8192 grep -v '^ *+' $at_stder1 >$at_stderr
   8193 at_failed=false
   8194 $at_diff $at_devnull $at_stderr || at_failed=:
   8195 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8196 sending: 'x' (1@10-19)
   8197 thing (1@10-19): 'x' (1@10-19)
   8198 sending: ')' (2@20-29)
   8199 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   8200 sending: EOF (3@30-39)
   8201 input (0@29-29): /* Nothing */
   8202 input (2@0-29): line (0@0-29) input (0@29-29)
   8203 Freeing nterm input (2@0-29)
   8204 Successful parse.
   8205 " | $at_diff - $at_stdout || at_failed=:
   8206 case $at_status in
   8207    77) echo 77 > $at_status_file
   8208             exit 77;;
   8209    0) ;;
   8210    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8211       at_failed=:;;
   8212 esac
   8213 if $at_failed; then
   8214 
   8215   echo 1 > $at_status_file
   8216   exit 1
   8217 fi
   8218 
   8219 $at_traceon
   8220 
   8221 
   8222 
   8223 # Check locations in error recovery
   8224 # ---------------------------------
   8225 # '(y)' is an error, but can be recovered from.  But what's the location
   8226 # of the error itself ('y'), and of the resulting reduction ('(error)').
   8227 $at_traceoff
   8228 echo "actions.at:533: \$PREPARSER ./input '(y)'"
   8229 echo actions.at:533 >$at_check_line_file
   8230 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   8231 at_status=$?
   8232 grep '^ *+' $at_stder1 >&2
   8233 grep -v '^ *+' $at_stder1 >$at_stderr
   8234 at_failed=false
   8235 $at_diff $at_devnull $at_stderr || at_failed=:
   8236 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8237 sending: 'y' (1@10-19)
   8238 10-19: syntax error, unexpected 'y', expecting 'x'
   8239 Freeing token 'y' (1@10-19)
   8240 sending: ')' (2@20-29)
   8241 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   8242 sending: EOF (3@30-39)
   8243 input (0@29-29): /* Nothing */
   8244 input (2@0-29): line (-1@0-29) input (0@29-29)
   8245 Freeing nterm input (2@0-29)
   8246 Successful parse.
   8247 " | $at_diff - $at_stdout || at_failed=:
   8248 case $at_status in
   8249    77) echo 77 > $at_status_file
   8250             exit 77;;
   8251    0) ;;
   8252    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8253       at_failed=:;;
   8254 esac
   8255 if $at_failed; then
   8256 
   8257   echo 1 > $at_status_file
   8258   exit 1
   8259 fi
   8260 
   8261 $at_traceon
   8262 
   8263 
   8264 
   8265 # Syntax errors caught by the parser
   8266 # ----------------------------------
   8267 # Exercise the discarding of stack top and input until `error'
   8268 # can be reduced.
   8269 #
   8270 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   8271 #
   8272 # Load the stack and provoke an error that cannot be caught by the
   8273 # grammar, to check that the stack is cleared.  And make sure the
   8274 # lookahead is freed.
   8275 #
   8276 #     '(', 'x', ')',
   8277 #     '(', 'x', ')',
   8278 #     'y'
   8279 $at_traceoff
   8280 echo "actions.at:533: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   8281 echo actions.at:533 >$at_check_line_file
   8282 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   8283 at_status=$?
   8284 grep '^ *+' $at_stder1 >&2
   8285 grep -v '^ *+' $at_stder1 >$at_stderr
   8286 at_failed=false
   8287 $at_diff $at_devnull $at_stderr || at_failed=:
   8288 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8289 sending: 'x' (1@10-19)
   8290 thing (1@10-19): 'x' (1@10-19)
   8291 sending: 'x' (2@20-29)
   8292 thing (2@20-29): 'x' (2@20-29)
   8293 sending: 'x' (3@30-39)
   8294 30-39: syntax error, unexpected 'x', expecting ')'
   8295 Freeing nterm thing (2@20-29)
   8296 Freeing nterm thing (1@10-19)
   8297 Freeing token 'x' (3@30-39)
   8298 sending: 'x' (4@40-49)
   8299 Freeing token 'x' (4@40-49)
   8300 sending: 'x' (5@50-59)
   8301 Freeing token 'x' (5@50-59)
   8302 sending: ')' (6@60-69)
   8303 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   8304 sending: '(' (7@70-79)
   8305 sending: 'x' (8@80-89)
   8306 thing (8@80-89): 'x' (8@80-89)
   8307 sending: ')' (9@90-99)
   8308 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   8309 sending: '(' (10@100-109)
   8310 sending: 'x' (11@110-119)
   8311 thing (11@110-119): 'x' (11@110-119)
   8312 sending: ')' (12@120-129)
   8313 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   8314 sending: 'y' (13@130-139)
   8315 input (0@129-129): /* Nothing */
   8316 input (2@100-129): line (10@100-129) input (0@129-129)
   8317 input (2@70-129): line (7@70-99) input (2@100-129)
   8318 input (2@0-129): line (-1@0-69) input (2@70-129)
   8319 130-139: syntax error, unexpected 'y', expecting \$end
   8320 Freeing nterm input (2@0-129)
   8321 Freeing token 'y' (13@130-139)
   8322 Parsing FAILED.
   8323 " | $at_diff - $at_stdout || at_failed=:
   8324 case $at_status in
   8325    77) echo 77 > $at_status_file
   8326             exit 77;;
   8327    1) ;;
   8328    *) echo "actions.at:533: exit code was $at_status, expected 1"
   8329       at_failed=:;;
   8330 esac
   8331 if $at_failed; then
   8332 
   8333   echo 1 > $at_status_file
   8334   exit 1
   8335 fi
   8336 
   8337 $at_traceon
   8338 
   8339 
   8340 # Check destruction upon stack overflow
   8341 # -------------------------------------
   8342 # Upon stack overflow, all symbols on the stack should be destroyed.
   8343 # Only check for yacc.c.
   8344 
   8345 
   8346 
   8347 
   8348       $at_traceoff
   8349       $at_times_p && times >$at_times_file
   8350     ) 5>&1 2>&1 | eval $at_tee_pipe
   8351     at_status=`cat $at_status_file`
   8352     ;;
   8353 
   8354   55 ) # 55. actions.at:534: Printers and Destructors with union: %defines %skeleton "lalr1.cc"
   8355     at_setup_line='actions.at:534'
   8356     at_desc='Printers and Destructors with union: %defines %skeleton "lalr1.cc"'
   8357     $at_quiet $ECHO_N " 55: Printers and Destructors with union: %defines %skeleton "lalr1.cc"$ECHO_C"
   8358     at_xfail=no
   8359     (
   8360       echo "55. actions.at:534: testing ..."
   8361       $at_traceon
   8362 
   8363 
   8364 
   8365 # Make sure complex $n work.
   8366 
   8367 # Be sure to pass all the %directives to this macro to have correct
   8368 # helping macros.  So don't put any directly in the Bison file.
   8369 
   8370 
   8371 
   8372 
   8373 # Using yacc.c?
   8374 
   8375 
   8376 
   8377 
   8378 
   8379 
   8380 
   8381 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   8382 
   8383 # yyerror always sees the locations (when activated), except if
   8384 # yacc & pure & !param.
   8385 
   8386 
   8387 # The interface is pure: either because %pure-parser, or because we
   8388 # are using the C++ parsers.
   8389 
   8390 
   8391 
   8392 
   8393 
   8394 
   8395 
   8396 
   8397 
   8398 
   8399 
   8400 cat >input.y <<'_ATEOF'
   8401 %{
   8402 #ifdef HAVE_CONFIG_H
   8403 # include <config.h>
   8404   /* We don't need perfect functions for these tests. */
   8405 # undef malloc
   8406 # undef memcmp
   8407 # undef realloc
   8408 #endif
   8409 %}
   8410 
   8411 %{
   8412 #include <stdio.h>
   8413 #include <stdlib.h>
   8414 #include <assert.h>
   8415 
   8416 #define YYINITDEPTH 10
   8417 #define YYMAXDEPTH 10
   8418 #define RANGE(Location) (Location).begin.line, (Location).end.line
   8419 %}
   8420 
   8421 %error-verbose
   8422 %debug
   8423 %verbose
   8424 %locations
   8425 %defines %skeleton "lalr1.cc"
   8426 %union
   8427 {
   8428   int ival;
   8429 }
   8430 %define "global_tokens_and_yystype"
   8431 
   8432 %{
   8433 typedef yy::location YYLTYPE;
   8434 
   8435 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   8436 
   8437 %}
   8438 
   8439 %type <ival> '(' 'x' 'y' ')' ';' thing line input
   8440 
   8441 %printer
   8442   {
   8443     debug_stream () << $$;;
   8444   }
   8445   input line thing 'x' 'y'
   8446 
   8447 %destructor
   8448   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   8449   input
   8450 
   8451 %destructor
   8452   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   8453   line
   8454 
   8455 %destructor
   8456   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   8457   thing
   8458 
   8459 %destructor
   8460   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   8461   'x'
   8462 
   8463 %destructor
   8464   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   8465   'y'
   8466 
   8467 %%
   8468 /*
   8469    This grammar is made to exercise error recovery.
   8470    "Lines" starting with `(' support error recovery, with
   8471    ')' as synchronizing token.  Lines starting with 'x' can never
   8472    be recovered from if in error.
   8473 */
   8474 
   8475 input:
   8476   /* Nothing. */
   8477     {
   8478       $$ = 0;
   8479       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   8480     }
   8481 | line input /* Right recursive to load the stack so that popping at
   8482 		EOF can	be exercised.  */
   8483     {
   8484       $$ = 2;
   8485       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   8486 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   8487     }
   8488 ;
   8489 
   8490 line:
   8491   thing thing thing ';'
   8492     {
   8493       $$ = $1;
   8494       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   8495               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8496               $3, RANGE (@3), $4, RANGE (@4));
   8497     }
   8498 | '(' thing thing ')'
   8499     {
   8500       $$ = $1;
   8501       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8502               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8503               $3, RANGE (@3), $4, RANGE (@4));
   8504     }
   8505 | '(' thing ')'
   8506     {
   8507       $$ = $1;
   8508       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8509               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   8510     }
   8511 | '(' error ')'
   8512     {
   8513       $$ = -1;
   8514       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   8515               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   8516     }
   8517 ;
   8518 
   8519 thing:
   8520   'x'
   8521     {
   8522       $$ = $1;
   8523       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   8524               $$, RANGE (@$), $1, RANGE (@1));
   8525     }
   8526 ;
   8527 %%
   8528 /* Alias to ARGV[1]. */
   8529 const char *source = 0;
   8530 
   8531 static int
   8532 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   8533 {
   8534   static unsigned int counter = 0;
   8535 
   8536   int c = (*lvalp).ival = counter++;
   8537   /* As in BASIC, line numbers go from 10 to 10.  */
   8538  (*llocp).begin.line = (*llocp).begin.column = 10 * c;
   8539   (*llocp).end.line = (*llocp).end.column = (*llocp).begin.line + 9;
   8540 
   8541 
   8542   if (source[c])
   8543     printf ("sending: '%c'", source[c]);
   8544   else
   8545     printf ("sending: EOF");
   8546   printf (" (%d@%d-%d)\n", c, RANGE ((*llocp)));
   8547   return source[c];
   8548 }
   8549 
   8550 /* A C++ error reporting function. */
   8551 void
   8552 yy::parser::error (const location& l, const std::string& m)
   8553 {
   8554   printf ("%d-%d: %s\n", RANGE (l), m.c_str());
   8555 }
   8556 
   8557 static bool yydebug;
   8558 int
   8559 yyparse ()
   8560 {
   8561   yy::parser parser;
   8562   parser.set_debug_level (yydebug);
   8563   return parser.parse ();
   8564 }
   8565 
   8566 
   8567 int
   8568 main (int argc, const char *argv[])
   8569 {
   8570   int status;
   8571   yydebug = !!getenv ("YYDEBUG");
   8572   assert (argc == 2);
   8573   source = argv[1];
   8574   status = yyparse ();
   8575   switch (status)
   8576     {
   8577       case 0: printf ("Successful parse.\n"); break;
   8578       case 1: printf ("Parsing FAILED.\n"); break;
   8579       default: printf ("Parsing FAILED (status %d).\n", status); break;
   8580     }
   8581   return status;
   8582 }
   8583 _ATEOF
   8584 
   8585 
   8586 
   8587 $at_traceoff
   8588 echo "actions.at:534: bison -o input.cc input.y"
   8589 echo actions.at:534 >$at_check_line_file
   8590 ( $at_traceon; bison -o input.cc input.y ) >$at_stdout 2>$at_stder1
   8591 at_status=$?
   8592 grep '^ *+' $at_stder1 >&2
   8593 grep -v '^ *+' $at_stder1 >$at_stderr
   8594 at_failed=false
   8595 $at_diff $at_devnull $at_stderr || at_failed=:
   8596 $at_diff $at_devnull $at_stdout || at_failed=:
   8597 case $at_status in
   8598    77) echo 77 > $at_status_file
   8599             exit 77;;
   8600    0) ;;
   8601    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8602       at_failed=:;;
   8603 esac
   8604 if $at_failed; then
   8605 
   8606   echo 1 > $at_status_file
   8607   exit 1
   8608 fi
   8609 
   8610 $at_traceon
   8611 
   8612 
   8613 $at_traceoff
   8614 echo "actions.at:534: \$BISON_CXX_WORKS"
   8615 echo actions.at:534 >$at_check_line_file
   8616 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   8617 at_status=$?
   8618 grep '^ *+' $at_stder1 >&2
   8619 grep -v '^ *+' $at_stder1 >$at_stderr
   8620 at_failed=false
   8621 echo stderr:; cat $at_stderr
   8622 echo stdout:; cat $at_stdout
   8623 case $at_status in
   8624    77) echo 77 > $at_status_file
   8625             exit 77;;
   8626    0) ;;
   8627    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8628       at_failed=:;;
   8629 esac
   8630 if $at_failed; then
   8631 
   8632   echo 1 > $at_status_file
   8633   exit 1
   8634 fi
   8635 
   8636 $at_traceon
   8637 
   8638 $at_traceoff
   8639 echo "actions.at:534: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o input input.cc \$LIBS"
   8640 echo actions.at:534 >$at_check_line_file
   8641 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o input input.cc $LIBS ) >$at_stdout 2>$at_stder1
   8642 at_status=$?
   8643 grep '^ *+' $at_stder1 >&2
   8644 grep -v '^ *+' $at_stder1 >$at_stderr
   8645 at_failed=false
   8646 echo stderr:; cat $at_stderr
   8647 echo stdout:; cat $at_stdout
   8648 case $at_status in
   8649    77) echo 77 > $at_status_file
   8650             exit 77;;
   8651    0) ;;
   8652    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8653       at_failed=:;;
   8654 esac
   8655 if $at_failed; then
   8656 
   8657   echo 1 > $at_status_file
   8658   exit 1
   8659 fi
   8660 
   8661 $at_traceon
   8662 
   8663 
   8664 
   8665 # Check the location of "empty"
   8666 # -----------------------------
   8667 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   8668 # an empty "line" nterm.
   8669 # FIXME: This location is not satisfying.  Depend on the lookahead?
   8670 $at_traceoff
   8671 echo "actions.at:534: \$PREPARSER ./input '(x)'"
   8672 echo actions.at:534 >$at_check_line_file
   8673 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   8674 at_status=$?
   8675 grep '^ *+' $at_stder1 >&2
   8676 grep -v '^ *+' $at_stder1 >$at_stderr
   8677 at_failed=false
   8678 $at_diff $at_devnull $at_stderr || at_failed=:
   8679 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8680 sending: 'x' (1@10-19)
   8681 thing (1@10-19): 'x' (1@10-19)
   8682 sending: ')' (2@20-29)
   8683 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   8684 sending: EOF (3@30-39)
   8685 input (0@29-29): /* Nothing */
   8686 input (2@0-29): line (0@0-29) input (0@29-29)
   8687 Freeing nterm input (2@0-29)
   8688 Successful parse.
   8689 " | $at_diff - $at_stdout || at_failed=:
   8690 case $at_status in
   8691    77) echo 77 > $at_status_file
   8692             exit 77;;
   8693    0) ;;
   8694    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8695       at_failed=:;;
   8696 esac
   8697 if $at_failed; then
   8698 
   8699   echo 1 > $at_status_file
   8700   exit 1
   8701 fi
   8702 
   8703 $at_traceon
   8704 
   8705 
   8706 
   8707 # Check locations in error recovery
   8708 # ---------------------------------
   8709 # '(y)' is an error, but can be recovered from.  But what's the location
   8710 # of the error itself ('y'), and of the resulting reduction ('(error)').
   8711 $at_traceoff
   8712 echo "actions.at:534: \$PREPARSER ./input '(y)'"
   8713 echo actions.at:534 >$at_check_line_file
   8714 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   8715 at_status=$?
   8716 grep '^ *+' $at_stder1 >&2
   8717 grep -v '^ *+' $at_stder1 >$at_stderr
   8718 at_failed=false
   8719 $at_diff $at_devnull $at_stderr || at_failed=:
   8720 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8721 sending: 'y' (1@10-19)
   8722 10-19: syntax error, unexpected 'y', expecting 'x'
   8723 Freeing token 'y' (1@10-19)
   8724 sending: ')' (2@20-29)
   8725 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   8726 sending: EOF (3@30-39)
   8727 input (0@29-29): /* Nothing */
   8728 input (2@0-29): line (-1@0-29) input (0@29-29)
   8729 Freeing nterm input (2@0-29)
   8730 Successful parse.
   8731 " | $at_diff - $at_stdout || at_failed=:
   8732 case $at_status in
   8733    77) echo 77 > $at_status_file
   8734             exit 77;;
   8735    0) ;;
   8736    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8737       at_failed=:;;
   8738 esac
   8739 if $at_failed; then
   8740 
   8741   echo 1 > $at_status_file
   8742   exit 1
   8743 fi
   8744 
   8745 $at_traceon
   8746 
   8747 
   8748 
   8749 # Syntax errors caught by the parser
   8750 # ----------------------------------
   8751 # Exercise the discarding of stack top and input until `error'
   8752 # can be reduced.
   8753 #
   8754 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   8755 #
   8756 # Load the stack and provoke an error that cannot be caught by the
   8757 # grammar, to check that the stack is cleared.  And make sure the
   8758 # lookahead is freed.
   8759 #
   8760 #     '(', 'x', ')',
   8761 #     '(', 'x', ')',
   8762 #     'y'
   8763 $at_traceoff
   8764 echo "actions.at:534: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   8765 echo actions.at:534 >$at_check_line_file
   8766 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   8767 at_status=$?
   8768 grep '^ *+' $at_stder1 >&2
   8769 grep -v '^ *+' $at_stder1 >$at_stderr
   8770 at_failed=false
   8771 $at_diff $at_devnull $at_stderr || at_failed=:
   8772 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8773 sending: 'x' (1@10-19)
   8774 thing (1@10-19): 'x' (1@10-19)
   8775 sending: 'x' (2@20-29)
   8776 thing (2@20-29): 'x' (2@20-29)
   8777 sending: 'x' (3@30-39)
   8778 30-39: syntax error, unexpected 'x', expecting ')'
   8779 Freeing nterm thing (2@20-29)
   8780 Freeing nterm thing (1@10-19)
   8781 Freeing token 'x' (3@30-39)
   8782 sending: 'x' (4@40-49)
   8783 Freeing token 'x' (4@40-49)
   8784 sending: 'x' (5@50-59)
   8785 Freeing token 'x' (5@50-59)
   8786 sending: ')' (6@60-69)
   8787 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   8788 sending: '(' (7@70-79)
   8789 sending: 'x' (8@80-89)
   8790 thing (8@80-89): 'x' (8@80-89)
   8791 sending: ')' (9@90-99)
   8792 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   8793 sending: '(' (10@100-109)
   8794 sending: 'x' (11@110-119)
   8795 thing (11@110-119): 'x' (11@110-119)
   8796 sending: ')' (12@120-129)
   8797 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   8798 sending: 'y' (13@130-139)
   8799 input (0@129-129): /* Nothing */
   8800 input (2@100-129): line (10@100-129) input (0@129-129)
   8801 input (2@70-129): line (7@70-99) input (2@100-129)
   8802 input (2@0-129): line (-1@0-69) input (2@70-129)
   8803 130-139: syntax error, unexpected 'y', expecting \$end
   8804 Freeing nterm input (2@0-129)
   8805 Freeing token 'y' (13@130-139)
   8806 Parsing FAILED.
   8807 " | $at_diff - $at_stdout || at_failed=:
   8808 case $at_status in
   8809    77) echo 77 > $at_status_file
   8810             exit 77;;
   8811    1) ;;
   8812    *) echo "actions.at:534: exit code was $at_status, expected 1"
   8813       at_failed=:;;
   8814 esac
   8815 if $at_failed; then
   8816 
   8817   echo 1 > $at_status_file
   8818   exit 1
   8819 fi
   8820 
   8821 $at_traceon
   8822 
   8823 
   8824 # Check destruction upon stack overflow
   8825 # -------------------------------------
   8826 # Upon stack overflow, all symbols on the stack should be destroyed.
   8827 # Only check for yacc.c.
   8828 
   8829 
   8830 
   8831 
   8832       $at_traceoff
   8833       $at_times_p && times >$at_times_file
   8834     ) 5>&1 2>&1 | eval $at_tee_pipe
   8835     at_status=`cat $at_status_file`
   8836     ;;
   8837 
   8838   56 ) # 56. actions.at:536: Printers and Destructors : %glr-parser
   8839     at_setup_line='actions.at:536'
   8840     at_desc='Printers and Destructors : %glr-parser'
   8841     $at_quiet $ECHO_N " 56: Printers and Destructors : %glr-parser       $ECHO_C"
   8842     at_xfail=no
   8843     (
   8844       echo "56. actions.at:536: testing ..."
   8845       $at_traceon
   8846 
   8847 
   8848 
   8849 # Make sure complex $n work.
   8850 
   8851 # Be sure to pass all the %directives to this macro to have correct
   8852 # helping macros.  So don't put any directly in the Bison file.
   8853 
   8854 
   8855 
   8856 
   8857 # Using yacc.c?
   8858 
   8859 
   8860 
   8861 
   8862 
   8863 
   8864 
   8865 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   8866 
   8867 # yyerror always sees the locations (when activated), except if
   8868 # yacc & pure & !param.
   8869 
   8870 
   8871 # The interface is pure: either because %pure-parser, or because we
   8872 # are using the C++ parsers.
   8873 
   8874 
   8875 
   8876 
   8877 
   8878 
   8879 
   8880 
   8881 
   8882 
   8883 
   8884 cat >input.y <<'_ATEOF'
   8885 %{
   8886 #ifdef HAVE_CONFIG_H
   8887 # include <config.h>
   8888   /* We don't need perfect functions for these tests. */
   8889 # undef malloc
   8890 # undef memcmp
   8891 # undef realloc
   8892 #endif
   8893 %}
   8894 
   8895 %{
   8896 #include <stdio.h>
   8897 #include <stdlib.h>
   8898 #include <assert.h>
   8899 
   8900 #define YYINITDEPTH 10
   8901 #define YYMAXDEPTH 10
   8902 #define RANGE(Location) (Location).first_line, (Location).last_line
   8903 %}
   8904 
   8905 %error-verbose
   8906 %debug
   8907 %verbose
   8908 %locations
   8909 %glr-parser
   8910 
   8911 
   8912 
   8913 %{
   8914 
   8915 static int yylex (void);
   8916 static void yyerror (const char *msg);
   8917 %}
   8918 
   8919 
   8920 
   8921 %printer
   8922   {
   8923     fprintf (yyoutput, "%d", $$);
   8924   }
   8925   input line thing 'x' 'y'
   8926 
   8927 %destructor
   8928   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   8929   input
   8930 
   8931 %destructor
   8932   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   8933   line
   8934 
   8935 %destructor
   8936   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   8937   thing
   8938 
   8939 %destructor
   8940   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   8941   'x'
   8942 
   8943 %destructor
   8944   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   8945   'y'
   8946 
   8947 %%
   8948 /*
   8949    This grammar is made to exercise error recovery.
   8950    "Lines" starting with `(' support error recovery, with
   8951    ')' as synchronizing token.  Lines starting with 'x' can never
   8952    be recovered from if in error.
   8953 */
   8954 
   8955 input:
   8956   /* Nothing. */
   8957     {
   8958       $$ = 0;
   8959       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   8960     }
   8961 | line input /* Right recursive to load the stack so that popping at
   8962 		EOF can	be exercised.  */
   8963     {
   8964       $$ = 2;
   8965       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   8966 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   8967     }
   8968 ;
   8969 
   8970 line:
   8971   thing thing thing ';'
   8972     {
   8973       $$ = $1;
   8974       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   8975               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8976               $3, RANGE (@3), $4, RANGE (@4));
   8977     }
   8978 | '(' thing thing ')'
   8979     {
   8980       $$ = $1;
   8981       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8982               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8983               $3, RANGE (@3), $4, RANGE (@4));
   8984     }
   8985 | '(' thing ')'
   8986     {
   8987       $$ = $1;
   8988       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8989               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   8990     }
   8991 | '(' error ')'
   8992     {
   8993       $$ = -1;
   8994       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   8995               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   8996     }
   8997 ;
   8998 
   8999 thing:
   9000   'x'
   9001     {
   9002       $$ = $1;
   9003       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   9004               $$, RANGE (@$), $1, RANGE (@1));
   9005     }
   9006 ;
   9007 %%
   9008 /* Alias to ARGV[1]. */
   9009 const char *source = 0;
   9010 
   9011 static int
   9012 yylex (void)
   9013 {
   9014   static unsigned int counter = 0;
   9015 
   9016   int c = (yylval) = counter++;
   9017   /* As in BASIC, line numbers go from 10 to 10.  */
   9018  (yylloc).first_line = (yylloc).first_column = 10 * c;
   9019   (yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
   9020 
   9021 
   9022   if (source[c])
   9023     printf ("sending: '%c'", source[c]);
   9024   else
   9025     printf ("sending: EOF");
   9026   printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
   9027   return source[c];
   9028 }
   9029 
   9030 static void
   9031 yyerror (const char *msg)
   9032 {
   9033   printf ("%d-%d: %s\n", RANGE (yylloc), msg);
   9034 }
   9035 
   9036 int
   9037 main (int argc, const char *argv[])
   9038 {
   9039   int status;
   9040   yydebug = !!getenv ("YYDEBUG");
   9041   assert (argc == 2);
   9042   source = argv[1];
   9043   status = yyparse ();
   9044   switch (status)
   9045     {
   9046       case 0: printf ("Successful parse.\n"); break;
   9047       case 1: printf ("Parsing FAILED.\n"); break;
   9048       default: printf ("Parsing FAILED (status %d).\n", status); break;
   9049     }
   9050   return status;
   9051 }
   9052 _ATEOF
   9053 
   9054 
   9055 
   9056 $at_traceoff
   9057 echo "actions.at:536: bison -o input.c input.y"
   9058 echo actions.at:536 >$at_check_line_file
   9059 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   9060 at_status=$?
   9061 grep '^ *+' $at_stder1 >&2
   9062 grep -v '^ *+' $at_stder1 >$at_stderr
   9063 at_failed=false
   9064 $at_diff $at_devnull $at_stderr || at_failed=:
   9065 $at_diff $at_devnull $at_stdout || at_failed=:
   9066 case $at_status in
   9067    77) echo 77 > $at_status_file
   9068             exit 77;;
   9069    0) ;;
   9070    *) echo "actions.at:536: exit code was $at_status, expected 0"
   9071       at_failed=:;;
   9072 esac
   9073 if $at_failed; then
   9074 
   9075   echo 1 > $at_status_file
   9076   exit 1
   9077 fi
   9078 
   9079 $at_traceon
   9080 
   9081    $at_traceoff
   9082 echo "actions.at:536: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   9083 echo actions.at:536 >$at_check_line_file
   9084 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   9085 at_status=$?
   9086 grep '^ *+' $at_stder1 >&2
   9087 grep -v '^ *+' $at_stder1 >$at_stderr
   9088 at_failed=false
   9089 echo stderr:; cat $at_stderr
   9090 echo stdout:; cat $at_stdout
   9091 case $at_status in
   9092    77) echo 77 > $at_status_file
   9093             exit 77;;
   9094    0) ;;
   9095    *) echo "actions.at:536: exit code was $at_status, expected 0"
   9096       at_failed=:;;
   9097 esac
   9098 if $at_failed; then
   9099 
   9100   echo 1 > $at_status_file
   9101   exit 1
   9102 fi
   9103 
   9104 $at_traceon
   9105 
   9106 
   9107 
   9108 # Check the location of "empty"
   9109 # -----------------------------
   9110 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   9111 # an empty "line" nterm.
   9112 # FIXME: This location is not satisfying.  Depend on the lookahead?
   9113 $at_traceoff
   9114 echo "actions.at:536: \$PREPARSER ./input '(x)'"
   9115 echo actions.at:536 >$at_check_line_file
   9116 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   9117 at_status=$?
   9118 grep '^ *+' $at_stder1 >&2
   9119 grep -v '^ *+' $at_stder1 >$at_stderr
   9120 at_failed=false
   9121 $at_diff $at_devnull $at_stderr || at_failed=:
   9122 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9123 sending: 'x' (1@10-19)
   9124 thing (1@10-19): 'x' (1@10-19)
   9125 sending: ')' (2@20-29)
   9126 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   9127 sending: EOF (3@30-39)
   9128 input (0@29-29): /* Nothing */
   9129 input (2@0-29): line (0@0-29) input (0@29-29)
   9130 Freeing nterm input (2@0-29)
   9131 Successful parse.
   9132 " | $at_diff - $at_stdout || at_failed=:
   9133 case $at_status in
   9134    77) echo 77 > $at_status_file
   9135             exit 77;;
   9136    0) ;;
   9137    *) echo "actions.at:536: exit code was $at_status, expected 0"
   9138       at_failed=:;;
   9139 esac
   9140 if $at_failed; then
   9141 
   9142   echo 1 > $at_status_file
   9143   exit 1
   9144 fi
   9145 
   9146 $at_traceon
   9147 
   9148 
   9149 
   9150 # Check locations in error recovery
   9151 # ---------------------------------
   9152 # '(y)' is an error, but can be recovered from.  But what's the location
   9153 # of the error itself ('y'), and of the resulting reduction ('(error)').
   9154 $at_traceoff
   9155 echo "actions.at:536: \$PREPARSER ./input '(y)'"
   9156 echo actions.at:536 >$at_check_line_file
   9157 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   9158 at_status=$?
   9159 grep '^ *+' $at_stder1 >&2
   9160 grep -v '^ *+' $at_stder1 >$at_stderr
   9161 at_failed=false
   9162 $at_diff $at_devnull $at_stderr || at_failed=:
   9163 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9164 sending: 'y' (1@10-19)
   9165 10-19: syntax error, unexpected 'y', expecting 'x'
   9166 Freeing token 'y' (1@10-19)
   9167 sending: ')' (2@20-29)
   9168 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   9169 sending: EOF (3@30-39)
   9170 input (0@29-29): /* Nothing */
   9171 input (2@0-29): line (-1@0-29) input (0@29-29)
   9172 Freeing nterm input (2@0-29)
   9173 Successful parse.
   9174 " | $at_diff - $at_stdout || at_failed=:
   9175 case $at_status in
   9176    77) echo 77 > $at_status_file
   9177             exit 77;;
   9178    0) ;;
   9179    *) echo "actions.at:536: exit code was $at_status, expected 0"
   9180       at_failed=:;;
   9181 esac
   9182 if $at_failed; then
   9183 
   9184   echo 1 > $at_status_file
   9185   exit 1
   9186 fi
   9187 
   9188 $at_traceon
   9189 
   9190 
   9191 
   9192 # Syntax errors caught by the parser
   9193 # ----------------------------------
   9194 # Exercise the discarding of stack top and input until `error'
   9195 # can be reduced.
   9196 #
   9197 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   9198 #
   9199 # Load the stack and provoke an error that cannot be caught by the
   9200 # grammar, to check that the stack is cleared.  And make sure the
   9201 # lookahead is freed.
   9202 #
   9203 #     '(', 'x', ')',
   9204 #     '(', 'x', ')',
   9205 #     'y'
   9206 $at_traceoff
   9207 echo "actions.at:536: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   9208 echo actions.at:536 >$at_check_line_file
   9209 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   9210 at_status=$?
   9211 grep '^ *+' $at_stder1 >&2
   9212 grep -v '^ *+' $at_stder1 >$at_stderr
   9213 at_failed=false
   9214 $at_diff $at_devnull $at_stderr || at_failed=:
   9215 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9216 sending: 'x' (1@10-19)
   9217 thing (1@10-19): 'x' (1@10-19)
   9218 sending: 'x' (2@20-29)
   9219 thing (2@20-29): 'x' (2@20-29)
   9220 sending: 'x' (3@30-39)
   9221 30-39: syntax error, unexpected 'x', expecting ')'
   9222 Freeing nterm thing (2@20-29)
   9223 Freeing nterm thing (1@10-19)
   9224 Freeing token 'x' (3@30-39)
   9225 sending: 'x' (4@40-49)
   9226 Freeing token 'x' (4@40-49)
   9227 sending: 'x' (5@50-59)
   9228 Freeing token 'x' (5@50-59)
   9229 sending: ')' (6@60-69)
   9230 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   9231 sending: '(' (7@70-79)
   9232 sending: 'x' (8@80-89)
   9233 thing (8@80-89): 'x' (8@80-89)
   9234 sending: ')' (9@90-99)
   9235 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   9236 sending: '(' (10@100-109)
   9237 sending: 'x' (11@110-119)
   9238 thing (11@110-119): 'x' (11@110-119)
   9239 sending: ')' (12@120-129)
   9240 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   9241 sending: 'y' (13@130-139)
   9242 input (0@129-129): /* Nothing */
   9243 input (2@100-129): line (10@100-129) input (0@129-129)
   9244 input (2@70-129): line (7@70-99) input (2@100-129)
   9245 input (2@0-129): line (-1@0-69) input (2@70-129)
   9246 130-139: syntax error, unexpected 'y', expecting \$end
   9247 Freeing nterm input (2@0-129)
   9248 Freeing token 'y' (13@130-139)
   9249 Parsing FAILED.
   9250 " | $at_diff - $at_stdout || at_failed=:
   9251 case $at_status in
   9252    77) echo 77 > $at_status_file
   9253             exit 77;;
   9254    1) ;;
   9255    *) echo "actions.at:536: exit code was $at_status, expected 1"
   9256       at_failed=:;;
   9257 esac
   9258 if $at_failed; then
   9259 
   9260   echo 1 > $at_status_file
   9261   exit 1
   9262 fi
   9263 
   9264 $at_traceon
   9265 
   9266 
   9267 # Check destruction upon stack overflow
   9268 # -------------------------------------
   9269 # Upon stack overflow, all symbols on the stack should be destroyed.
   9270 # Only check for yacc.c.
   9271 
   9272 
   9273 
   9274 
   9275       $at_traceoff
   9276       $at_times_p && times >$at_times_file
   9277     ) 5>&1 2>&1 | eval $at_tee_pipe
   9278     at_status=`cat $at_status_file`
   9279     ;;
   9280 
   9281   57 ) # 57. actions.at:537: Printers and Destructors with union: %glr-parser
   9282     at_setup_line='actions.at:537'
   9283     at_desc='Printers and Destructors with union: %glr-parser'
   9284     $at_quiet $ECHO_N " 57: Printers and Destructors with union: %glr-parser$ECHO_C"
   9285     at_xfail=no
   9286     (
   9287       echo "57. actions.at:537: testing ..."
   9288       $at_traceon
   9289 
   9290 
   9291 
   9292 # Make sure complex $n work.
   9293 
   9294 # Be sure to pass all the %directives to this macro to have correct
   9295 # helping macros.  So don't put any directly in the Bison file.
   9296 
   9297 
   9298 
   9299 
   9300 # Using yacc.c?
   9301 
   9302 
   9303 
   9304 
   9305 
   9306 
   9307 
   9308 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   9309 
   9310 # yyerror always sees the locations (when activated), except if
   9311 # yacc & pure & !param.
   9312 
   9313 
   9314 # The interface is pure: either because %pure-parser, or because we
   9315 # are using the C++ parsers.
   9316 
   9317 
   9318 
   9319 
   9320 
   9321 
   9322 
   9323 
   9324 
   9325 
   9326 
   9327 cat >input.y <<'_ATEOF'
   9328 %{
   9329 #ifdef HAVE_CONFIG_H
   9330 # include <config.h>
   9331   /* We don't need perfect functions for these tests. */
   9332 # undef malloc
   9333 # undef memcmp
   9334 # undef realloc
   9335 #endif
   9336 %}
   9337 
   9338 %{
   9339 #include <stdio.h>
   9340 #include <stdlib.h>
   9341 #include <assert.h>
   9342 
   9343 #define YYINITDEPTH 10
   9344 #define YYMAXDEPTH 10
   9345 #define RANGE(Location) (Location).first_line, (Location).last_line
   9346 %}
   9347 
   9348 %error-verbose
   9349 %debug
   9350 %verbose
   9351 %locations
   9352 %glr-parser
   9353 %union
   9354 {
   9355   int ival;
   9356 }
   9357 
   9358 
   9359 %{
   9360 
   9361 static int yylex (void);
   9362 static void yyerror (const char *msg);
   9363 %}
   9364 
   9365 %type <ival> '(' 'x' 'y' ')' ';' thing line input
   9366 
   9367 %printer
   9368   {
   9369     fprintf (yyoutput, "%d", $$);
   9370   }
   9371   input line thing 'x' 'y'
   9372 
   9373 %destructor
   9374   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   9375   input
   9376 
   9377 %destructor
   9378   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   9379   line
   9380 
   9381 %destructor
   9382   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   9383   thing
   9384 
   9385 %destructor
   9386   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   9387   'x'
   9388 
   9389 %destructor
   9390   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   9391   'y'
   9392 
   9393 %%
   9394 /*
   9395    This grammar is made to exercise error recovery.
   9396    "Lines" starting with `(' support error recovery, with
   9397    ')' as synchronizing token.  Lines starting with 'x' can never
   9398    be recovered from if in error.
   9399 */
   9400 
   9401 input:
   9402   /* Nothing. */
   9403     {
   9404       $$ = 0;
   9405       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   9406     }
   9407 | line input /* Right recursive to load the stack so that popping at
   9408 		EOF can	be exercised.  */
   9409     {
   9410       $$ = 2;
   9411       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   9412 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   9413     }
   9414 ;
   9415 
   9416 line:
   9417   thing thing thing ';'
   9418     {
   9419       $$ = $1;
   9420       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   9421               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   9422               $3, RANGE (@3), $4, RANGE (@4));
   9423     }
   9424 | '(' thing thing ')'
   9425     {
   9426       $$ = $1;
   9427       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   9428               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   9429               $3, RANGE (@3), $4, RANGE (@4));
   9430     }
   9431 | '(' thing ')'
   9432     {
   9433       $$ = $1;
   9434       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   9435               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   9436     }
   9437 | '(' error ')'
   9438     {
   9439       $$ = -1;
   9440       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   9441               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   9442     }
   9443 ;
   9444 
   9445 thing:
   9446   'x'
   9447     {
   9448       $$ = $1;
   9449       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   9450               $$, RANGE (@$), $1, RANGE (@1));
   9451     }
   9452 ;
   9453 %%
   9454 /* Alias to ARGV[1]. */
   9455 const char *source = 0;
   9456 
   9457 static int
   9458 yylex (void)
   9459 {
   9460   static unsigned int counter = 0;
   9461 
   9462   int c = (yylval).ival = counter++;
   9463   /* As in BASIC, line numbers go from 10 to 10.  */
   9464  (yylloc).first_line = (yylloc).first_column = 10 * c;
   9465   (yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
   9466 
   9467 
   9468   if (source[c])
   9469     printf ("sending: '%c'", source[c]);
   9470   else
   9471     printf ("sending: EOF");
   9472   printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
   9473   return source[c];
   9474 }
   9475 
   9476 static void
   9477 yyerror (const char *msg)
   9478 {
   9479   printf ("%d-%d: %s\n", RANGE (yylloc), msg);
   9480 }
   9481 
   9482 int
   9483 main (int argc, const char *argv[])
   9484 {
   9485   int status;
   9486   yydebug = !!getenv ("YYDEBUG");
   9487   assert (argc == 2);
   9488   source = argv[1];
   9489   status = yyparse ();
   9490   switch (status)
   9491     {
   9492       case 0: printf ("Successful parse.\n"); break;
   9493       case 1: printf ("Parsing FAILED.\n"); break;
   9494       default: printf ("Parsing FAILED (status %d).\n", status); break;
   9495     }
   9496   return status;
   9497 }
   9498 _ATEOF
   9499 
   9500 
   9501 
   9502 $at_traceoff
   9503 echo "actions.at:537: bison -o input.c input.y"
   9504 echo actions.at:537 >$at_check_line_file
   9505 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   9506 at_status=$?
   9507 grep '^ *+' $at_stder1 >&2
   9508 grep -v '^ *+' $at_stder1 >$at_stderr
   9509 at_failed=false
   9510 $at_diff $at_devnull $at_stderr || at_failed=:
   9511 $at_diff $at_devnull $at_stdout || at_failed=:
   9512 case $at_status in
   9513    77) echo 77 > $at_status_file
   9514             exit 77;;
   9515    0) ;;
   9516    *) echo "actions.at:537: exit code was $at_status, expected 0"
   9517       at_failed=:;;
   9518 esac
   9519 if $at_failed; then
   9520 
   9521   echo 1 > $at_status_file
   9522   exit 1
   9523 fi
   9524 
   9525 $at_traceon
   9526 
   9527    $at_traceoff
   9528 echo "actions.at:537: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   9529 echo actions.at:537 >$at_check_line_file
   9530 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   9531 at_status=$?
   9532 grep '^ *+' $at_stder1 >&2
   9533 grep -v '^ *+' $at_stder1 >$at_stderr
   9534 at_failed=false
   9535 echo stderr:; cat $at_stderr
   9536 echo stdout:; cat $at_stdout
   9537 case $at_status in
   9538    77) echo 77 > $at_status_file
   9539             exit 77;;
   9540    0) ;;
   9541    *) echo "actions.at:537: exit code was $at_status, expected 0"
   9542       at_failed=:;;
   9543 esac
   9544 if $at_failed; then
   9545 
   9546   echo 1 > $at_status_file
   9547   exit 1
   9548 fi
   9549 
   9550 $at_traceon
   9551 
   9552 
   9553 
   9554 # Check the location of "empty"
   9555 # -----------------------------
   9556 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   9557 # an empty "line" nterm.
   9558 # FIXME: This location is not satisfying.  Depend on the lookahead?
   9559 $at_traceoff
   9560 echo "actions.at:537: \$PREPARSER ./input '(x)'"
   9561 echo actions.at:537 >$at_check_line_file
   9562 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   9563 at_status=$?
   9564 grep '^ *+' $at_stder1 >&2
   9565 grep -v '^ *+' $at_stder1 >$at_stderr
   9566 at_failed=false
   9567 $at_diff $at_devnull $at_stderr || at_failed=:
   9568 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9569 sending: 'x' (1@10-19)
   9570 thing (1@10-19): 'x' (1@10-19)
   9571 sending: ')' (2@20-29)
   9572 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   9573 sending: EOF (3@30-39)
   9574 input (0@29-29): /* Nothing */
   9575 input (2@0-29): line (0@0-29) input (0@29-29)
   9576 Freeing nterm input (2@0-29)
   9577 Successful parse.
   9578 " | $at_diff - $at_stdout || at_failed=:
   9579 case $at_status in
   9580    77) echo 77 > $at_status_file
   9581             exit 77;;
   9582    0) ;;
   9583    *) echo "actions.at:537: exit code was $at_status, expected 0"
   9584       at_failed=:;;
   9585 esac
   9586 if $at_failed; then
   9587 
   9588   echo 1 > $at_status_file
   9589   exit 1
   9590 fi
   9591 
   9592 $at_traceon
   9593 
   9594 
   9595 
   9596 # Check locations in error recovery
   9597 # ---------------------------------
   9598 # '(y)' is an error, but can be recovered from.  But what's the location
   9599 # of the error itself ('y'), and of the resulting reduction ('(error)').
   9600 $at_traceoff
   9601 echo "actions.at:537: \$PREPARSER ./input '(y)'"
   9602 echo actions.at:537 >$at_check_line_file
   9603 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   9604 at_status=$?
   9605 grep '^ *+' $at_stder1 >&2
   9606 grep -v '^ *+' $at_stder1 >$at_stderr
   9607 at_failed=false
   9608 $at_diff $at_devnull $at_stderr || at_failed=:
   9609 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9610 sending: 'y' (1@10-19)
   9611 10-19: syntax error, unexpected 'y', expecting 'x'
   9612 Freeing token 'y' (1@10-19)
   9613 sending: ')' (2@20-29)
   9614 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   9615 sending: EOF (3@30-39)
   9616 input (0@29-29): /* Nothing */
   9617 input (2@0-29): line (-1@0-29) input (0@29-29)
   9618 Freeing nterm input (2@0-29)
   9619 Successful parse.
   9620 " | $at_diff - $at_stdout || at_failed=:
   9621 case $at_status in
   9622    77) echo 77 > $at_status_file
   9623             exit 77;;
   9624    0) ;;
   9625    *) echo "actions.at:537: exit code was $at_status, expected 0"
   9626       at_failed=:;;
   9627 esac
   9628 if $at_failed; then
   9629 
   9630   echo 1 > $at_status_file
   9631   exit 1
   9632 fi
   9633 
   9634 $at_traceon
   9635 
   9636 
   9637 
   9638 # Syntax errors caught by the parser
   9639 # ----------------------------------
   9640 # Exercise the discarding of stack top and input until `error'
   9641 # can be reduced.
   9642 #
   9643 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   9644 #
   9645 # Load the stack and provoke an error that cannot be caught by the
   9646 # grammar, to check that the stack is cleared.  And make sure the
   9647 # lookahead is freed.
   9648 #
   9649 #     '(', 'x', ')',
   9650 #     '(', 'x', ')',
   9651 #     'y'
   9652 $at_traceoff
   9653 echo "actions.at:537: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   9654 echo actions.at:537 >$at_check_line_file
   9655 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   9656 at_status=$?
   9657 grep '^ *+' $at_stder1 >&2
   9658 grep -v '^ *+' $at_stder1 >$at_stderr
   9659 at_failed=false
   9660 $at_diff $at_devnull $at_stderr || at_failed=:
   9661 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9662 sending: 'x' (1@10-19)
   9663 thing (1@10-19): 'x' (1@10-19)
   9664 sending: 'x' (2@20-29)
   9665 thing (2@20-29): 'x' (2@20-29)
   9666 sending: 'x' (3@30-39)
   9667 30-39: syntax error, unexpected 'x', expecting ')'
   9668 Freeing nterm thing (2@20-29)
   9669 Freeing nterm thing (1@10-19)
   9670 Freeing token 'x' (3@30-39)
   9671 sending: 'x' (4@40-49)
   9672 Freeing token 'x' (4@40-49)
   9673 sending: 'x' (5@50-59)
   9674 Freeing token 'x' (5@50-59)
   9675 sending: ')' (6@60-69)
   9676 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   9677 sending: '(' (7@70-79)
   9678 sending: 'x' (8@80-89)
   9679 thing (8@80-89): 'x' (8@80-89)
   9680 sending: ')' (9@90-99)
   9681 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   9682 sending: '(' (10@100-109)
   9683 sending: 'x' (11@110-119)
   9684 thing (11@110-119): 'x' (11@110-119)
   9685 sending: ')' (12@120-129)
   9686 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   9687 sending: 'y' (13@130-139)
   9688 input (0@129-129): /* Nothing */
   9689 input (2@100-129): line (10@100-129) input (0@129-129)
   9690 input (2@70-129): line (7@70-99) input (2@100-129)
   9691 input (2@0-129): line (-1@0-69) input (2@70-129)
   9692 130-139: syntax error, unexpected 'y', expecting \$end
   9693 Freeing nterm input (2@0-129)
   9694 Freeing token 'y' (13@130-139)
   9695 Parsing FAILED.
   9696 " | $at_diff - $at_stdout || at_failed=:
   9697 case $at_status in
   9698    77) echo 77 > $at_status_file
   9699             exit 77;;
   9700    1) ;;
   9701    *) echo "actions.at:537: exit code was $at_status, expected 1"
   9702       at_failed=:;;
   9703 esac
   9704 if $at_failed; then
   9705 
   9706   echo 1 > $at_status_file
   9707   exit 1
   9708 fi
   9709 
   9710 $at_traceon
   9711 
   9712 
   9713 # Check destruction upon stack overflow
   9714 # -------------------------------------
   9715 # Upon stack overflow, all symbols on the stack should be destroyed.
   9716 # Only check for yacc.c.
   9717 
   9718 
   9719 
   9720 
   9721       $at_traceoff
   9722       $at_times_p && times >$at_times_file
   9723     ) 5>&1 2>&1 | eval $at_tee_pipe
   9724     at_status=`cat $at_status_file`
   9725     ;;
   9726 
   9727 
   9728   banner-8 ) # Banner 8. conflicts.at:20
   9729     cat <<\_ATEOF
   9730 
   9731 Conflicts.
   9732 
   9733 _ATEOF
   9734     ;;
   9735 
   9736   58 ) # 58. conflicts.at:32: S/R in initial
   9737     at_setup_line='conflicts.at:32'
   9738     at_desc='S/R in initial'
   9739     $at_quiet $ECHO_N " 58: S/R in initial                               $ECHO_C"
   9740     at_xfail=no
   9741     (
   9742       echo "58. conflicts.at:32: testing ..."
   9743       $at_traceon
   9744 
   9745 
   9746 cat >input.y <<'_ATEOF'
   9747 %expect 1
   9748 %%
   9749 exp: e 'e';
   9750 e: 'e' | /* Nothing. */;
   9751 _ATEOF
   9752 
   9753 
   9754 $at_traceoff
   9755 echo "conflicts.at:43: bison -o input.c input.y"
   9756 echo conflicts.at:43 >$at_check_line_file
   9757 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   9758 at_status=$?
   9759 grep '^ *+' $at_stder1 >&2
   9760 grep -v '^ *+' $at_stder1 >$at_stderr
   9761 at_failed=false
   9762 echo >>$at_stderr; echo "input.y:4.9: warning: rule never reduced because of conflicts: e: /* empty */
   9763 " | $at_diff - $at_stderr || at_failed=:
   9764 $at_diff $at_devnull $at_stdout || at_failed=:
   9765 case $at_status in
   9766    77) echo 77 > $at_status_file
   9767             exit 77;;
   9768    0) ;;
   9769    *) echo "conflicts.at:43: exit code was $at_status, expected 0"
   9770       at_failed=:;;
   9771 esac
   9772 if $at_failed; then
   9773 
   9774   echo 1 > $at_status_file
   9775   exit 1
   9776 fi
   9777 
   9778 $at_traceon
   9779 
   9780 
   9781       $at_traceoff
   9782       $at_times_p && times >$at_times_file
   9783     ) 5>&1 2>&1 | eval $at_tee_pipe
   9784     at_status=`cat $at_status_file`
   9785     ;;
   9786 
   9787   59 ) # 59. conflicts.at:52: %nonassoc and eof
   9788     at_setup_line='conflicts.at:52'
   9789     at_desc='%nonassoc and eof'
   9790     $at_quiet $ECHO_N " 59: %nonassoc and eof                            $ECHO_C"
   9791     at_xfail=no
   9792     (
   9793       echo "59. conflicts.at:52: testing ..."
   9794       $at_traceon
   9795 
   9796 
   9797 cat >input.y <<'_ATEOF'
   9798 %{
   9799 #ifdef HAVE_CONFIG_H
   9800 # include <config.h>
   9801   /* We don't need perfect functions for these tests. */
   9802 # undef malloc
   9803 # undef memcmp
   9804 # undef realloc
   9805 #endif
   9806 %}
   9807 
   9808 
   9809 %{
   9810 #include <stdio.h>
   9811 #include <stdlib.h>
   9812 
   9813 #define YYERROR_VERBOSE 1
   9814 static void
   9815 yyerror (const char *msg)
   9816 {
   9817   fprintf (stderr, "%s\n", msg);
   9818 }
   9819 
   9820 /* The current argument. */
   9821 static const char *input = NULL;
   9822 
   9823 static int
   9824 yylex (void)
   9825 {
   9826   /* No token stands for end of file. */
   9827   if (input && *input)
   9828     return *input++;
   9829   else
   9830     return 0;
   9831 }
   9832 
   9833 %}
   9834 
   9835 %nonassoc '<' '>'
   9836 
   9837 %%
   9838 expr: expr '<' expr
   9839     | expr '>' expr
   9840     | '0'
   9841     ;
   9842 %%
   9843 int
   9844 main (int argc, const char *argv[])
   9845 {
   9846   if (argc > 1)
   9847     input = argv[1];
   9848   return yyparse ();
   9849 }
   9850 _ATEOF
   9851 
   9852 
   9853 
   9854 # Specify the output files to avoid problems on different file systems.
   9855 $at_traceoff
   9856 echo "conflicts.at:100: bison -o input.c input.y"
   9857 echo conflicts.at:100 >$at_check_line_file
   9858 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   9859 at_status=$?
   9860 grep '^ *+' $at_stder1 >&2
   9861 grep -v '^ *+' $at_stder1 >$at_stderr
   9862 at_failed=false
   9863 $at_diff $at_devnull $at_stderr || at_failed=:
   9864 $at_diff $at_devnull $at_stdout || at_failed=:
   9865 case $at_status in
   9866    77) echo 77 > $at_status_file
   9867             exit 77;;
   9868    0) ;;
   9869    *) echo "conflicts.at:100: exit code was $at_status, expected 0"
   9870       at_failed=:;;
   9871 esac
   9872 if $at_failed; then
   9873 
   9874   echo 1 > $at_status_file
   9875   exit 1
   9876 fi
   9877 
   9878 $at_traceon
   9879 
   9880 $at_traceoff
   9881 echo "conflicts.at:101: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   9882 echo conflicts.at:101 >$at_check_line_file
   9883 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   9884 at_status=$?
   9885 grep '^ *+' $at_stder1 >&2
   9886 grep -v '^ *+' $at_stder1 >$at_stderr
   9887 at_failed=false
   9888 echo stderr:; cat $at_stderr
   9889 echo stdout:; cat $at_stdout
   9890 case $at_status in
   9891    77) echo 77 > $at_status_file
   9892             exit 77;;
   9893    0) ;;
   9894    *) echo "conflicts.at:101: exit code was $at_status, expected 0"
   9895       at_failed=:;;
   9896 esac
   9897 if $at_failed; then
   9898 
   9899   echo 1 > $at_status_file
   9900   exit 1
   9901 fi
   9902 
   9903 $at_traceon
   9904 
   9905 
   9906 $at_traceoff
   9907 echo "conflicts.at:103: \$PREPARSER ./input '0<0'"
   9908 echo conflicts.at:103 >$at_check_line_file
   9909 ( $at_traceon; $PREPARSER ./input '0<0' ) >$at_stdout 2>$at_stder1
   9910 at_status=$?
   9911 grep '^ *+' $at_stder1 >&2
   9912 grep -v '^ *+' $at_stder1 >$at_stderr
   9913 at_failed=false
   9914 $at_diff $at_devnull $at_stderr || at_failed=:
   9915 $at_diff $at_devnull $at_stdout || at_failed=:
   9916 case $at_status in
   9917    77) echo 77 > $at_status_file
   9918             exit 77;;
   9919    0) ;;
   9920    *) echo "conflicts.at:103: exit code was $at_status, expected 0"
   9921       at_failed=:;;
   9922 esac
   9923 if $at_failed; then
   9924 
   9925   echo 1 > $at_status_file
   9926   exit 1
   9927 fi
   9928 
   9929 $at_traceon
   9930 
   9931 # FIXME: This is an actual bug, but a new one, in the sense that
   9932 # no one has ever spotted it!  The messages are *wrong*: there should
   9933 # be nothing there, it should be expected eof.
   9934 $at_traceoff
   9935 echo "conflicts.at:109: \$PREPARSER ./input '0<0<0'"
   9936 echo conflicts.at:109 >$at_check_line_file
   9937 ( $at_traceon; $PREPARSER ./input '0<0<0' ) >$at_stdout 2>$at_stder1
   9938 at_status=$?
   9939 grep '^ *+' $at_stder1 >&2
   9940 grep -v '^ *+' $at_stder1 >$at_stderr
   9941 at_failed=false
   9942 echo >>$at_stderr; echo "syntax error, unexpected '<', expecting '<' or '>'
   9943 " | $at_diff - $at_stderr || at_failed=:
   9944 $at_diff $at_devnull $at_stdout || at_failed=:
   9945 case $at_status in
   9946    77) echo 77 > $at_status_file
   9947             exit 77;;
   9948    1) ;;
   9949    *) echo "conflicts.at:109: exit code was $at_status, expected 1"
   9950       at_failed=:;;
   9951 esac
   9952 if $at_failed; then
   9953 
   9954   echo 1 > $at_status_file
   9955   exit 1
   9956 fi
   9957 
   9958 $at_traceon
   9959 
   9960 
   9961 $at_traceoff
   9962 echo "conflicts.at:111: \$PREPARSER ./input '0>0'"
   9963 echo conflicts.at:111 >$at_check_line_file
   9964 ( $at_traceon; $PREPARSER ./input '0>0' ) >$at_stdout 2>$at_stder1
   9965 at_status=$?
   9966 grep '^ *+' $at_stder1 >&2
   9967 grep -v '^ *+' $at_stder1 >$at_stderr
   9968 at_failed=false
   9969 $at_diff $at_devnull $at_stderr || at_failed=:
   9970 $at_diff $at_devnull $at_stdout || at_failed=:
   9971 case $at_status in
   9972    77) echo 77 > $at_status_file
   9973             exit 77;;
   9974    0) ;;
   9975    *) echo "conflicts.at:111: exit code was $at_status, expected 0"
   9976       at_failed=:;;
   9977 esac
   9978 if $at_failed; then
   9979 
   9980   echo 1 > $at_status_file
   9981   exit 1
   9982 fi
   9983 
   9984 $at_traceon
   9985 
   9986 $at_traceoff
   9987 echo "conflicts.at:114: \$PREPARSER ./input '0>0>0'"
   9988 echo conflicts.at:114 >$at_check_line_file
   9989 ( $at_traceon; $PREPARSER ./input '0>0>0' ) >$at_stdout 2>$at_stder1
   9990 at_status=$?
   9991 grep '^ *+' $at_stder1 >&2
   9992 grep -v '^ *+' $at_stder1 >$at_stderr
   9993 at_failed=false
   9994 echo >>$at_stderr; echo "syntax error, unexpected '>', expecting '<' or '>'
   9995 " | $at_diff - $at_stderr || at_failed=:
   9996 $at_diff $at_devnull $at_stdout || at_failed=:
   9997 case $at_status in
   9998    77) echo 77 > $at_status_file
   9999             exit 77;;
   10000    1) ;;
   10001    *) echo "conflicts.at:114: exit code was $at_status, expected 1"
   10002       at_failed=:;;
   10003 esac
   10004 if $at_failed; then
   10005 
   10006   echo 1 > $at_status_file
   10007   exit 1
   10008 fi
   10009 
   10010 $at_traceon
   10011 
   10012 
   10013 $at_traceoff
   10014 echo "conflicts.at:118: \$PREPARSER ./input '0<0>0'"
   10015 echo conflicts.at:118 >$at_check_line_file
   10016 ( $at_traceon; $PREPARSER ./input '0<0>0' ) >$at_stdout 2>$at_stder1
   10017 at_status=$?
   10018 grep '^ *+' $at_stder1 >&2
   10019 grep -v '^ *+' $at_stder1 >$at_stderr
   10020 at_failed=false
   10021 echo >>$at_stderr; echo "syntax error, unexpected '>', expecting '<' or '>'
   10022 " | $at_diff - $at_stderr || at_failed=:
   10023 $at_diff $at_devnull $at_stdout || at_failed=:
   10024 case $at_status in
   10025    77) echo 77 > $at_status_file
   10026             exit 77;;
   10027    1) ;;
   10028    *) echo "conflicts.at:118: exit code was $at_status, expected 1"
   10029       at_failed=:;;
   10030 esac
   10031 if $at_failed; then
   10032 
   10033   echo 1 > $at_status_file
   10034   exit 1
   10035 fi
   10036 
   10037 $at_traceon
   10038 
   10039 
   10040       $at_traceoff
   10041       $at_times_p && times >$at_times_file
   10042     ) 5>&1 2>&1 | eval $at_tee_pipe
   10043     at_status=`cat $at_status_file`
   10044     ;;
   10045 
   10046   60 ) # 60. conflicts.at:128: Unresolved SR Conflicts
   10047     at_setup_line='conflicts.at:128'
   10048     at_desc='Unresolved SR Conflicts'
   10049     $at_quiet $ECHO_N " 60: Unresolved SR Conflicts                      $ECHO_C"
   10050     at_xfail=no
   10051     (
   10052       echo "60. conflicts.at:128: testing ..."
   10053       $at_traceon
   10054 
   10055 
   10056 
   10057 
   10058 cat >input.y <<'_ATEOF'
   10059 %token NUM OP
   10060 %%
   10061 exp: exp OP exp | NUM;
   10062 _ATEOF
   10063 
   10064 
   10065 $at_traceoff
   10066 echo "conflicts.at:140: bison -o input.c --report=all input.y"
   10067 echo conflicts.at:140 >$at_check_line_file
   10068 ( $at_traceon; bison -o input.c --report=all input.y ) >$at_stdout 2>$at_stder1
   10069 at_status=$?
   10070 grep '^ *+' $at_stder1 >&2
   10071 grep -v '^ *+' $at_stder1 >$at_stderr
   10072 at_failed=false
   10073 echo >>$at_stderr; echo "input.y: conflicts: 1 shift/reduce
   10074 " | $at_diff - $at_stderr || at_failed=:
   10075 $at_diff $at_devnull $at_stdout || at_failed=:
   10076 case $at_status in
   10077    77) echo 77 > $at_status_file
   10078             exit 77;;
   10079    0) ;;
   10080    *) echo "conflicts.at:140: exit code was $at_status, expected 0"
   10081       at_failed=:;;
   10082 esac
   10083 if $at_failed; then
   10084 
   10085   echo 1 > $at_status_file
   10086   exit 1
   10087 fi
   10088 
   10089 $at_traceon
   10090 
   10091 
   10092 # Check the contents of the report.
   10093 $at_traceoff
   10094 echo "conflicts.at:225: cat input.output"
   10095 echo conflicts.at:225 >$at_check_line_file
   10096 ( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
   10097 at_status=$?
   10098 grep '^ *+' $at_stder1 >&2
   10099 grep -v '^ *+' $at_stder1 >$at_stderr
   10100 at_failed=false
   10101 $at_diff $at_devnull $at_stderr || at_failed=:
   10102 echo >>$at_stdout; echo "State 5 conflicts: 1 shift/reduce
   10103 
   10104 
   10105 Grammar
   10106 
   10107     0 \$accept: exp \$end
   10108 
   10109     1 exp: exp OP exp
   10110     2    | NUM
   10111 
   10112 
   10113 Terminals, with rules where they appear
   10114 
   10115 \$end (0) 0
   10116 error (256)
   10117 NUM (258) 2
   10118 OP (259) 1
   10119 
   10120 
   10121 Nonterminals, with rules where they appear
   10122 
   10123 \$accept (5)
   10124     on left: 0
   10125 exp (6)
   10126     on left: 1 2, on right: 0 1
   10127 
   10128 
   10129 state 0
   10130 
   10131     0 \$accept: . exp \$end
   10132     1 exp: . exp OP exp
   10133     2    | . NUM
   10134 
   10135     NUM  shift, and go to state 1
   10136 
   10137     exp  go to state 2
   10138 
   10139 
   10140 state 1
   10141 
   10142     2 exp: NUM .
   10143 
   10144     \$default  reduce using rule 2 (exp)
   10145 
   10146 
   10147 state 2
   10148 
   10149     0 \$accept: exp . \$end
   10150     1 exp: exp . OP exp
   10151 
   10152     \$end  shift, and go to state 3
   10153     OP    shift, and go to state 4
   10154 
   10155 
   10156 state 3
   10157 
   10158     0 \$accept: exp \$end .
   10159 
   10160     \$default  accept
   10161 
   10162 
   10163 state 4
   10164 
   10165     1 exp: . exp OP exp
   10166     1    | exp OP . exp
   10167     2    | . NUM
   10168 
   10169     NUM  shift, and go to state 1
   10170 
   10171     exp  go to state 5
   10172 
   10173 
   10174 state 5
   10175 
   10176     1 exp: exp . OP exp  [\$end, OP]
   10177     1    | exp OP exp .  [\$end, OP]
   10178 
   10179     OP  shift, and go to state 4
   10180 
   10181     OP        [reduce using rule 1 (exp)]
   10182     \$default  reduce using rule 1 (exp)
   10183 " | $at_diff - $at_stdout || at_failed=:
   10184 case $at_status in
   10185    77) echo 77 > $at_status_file
   10186             exit 77;;
   10187    0) ;;
   10188    *) echo "conflicts.at:225: exit code was $at_status, expected 0"
   10189       at_failed=:;;
   10190 esac
   10191 if $at_failed; then
   10192 
   10193   echo 1 > $at_status_file
   10194   exit 1
   10195 fi
   10196 
   10197 $at_traceon
   10198 
   10199 
   10200       $at_traceoff
   10201       $at_times_p && times >$at_times_file
   10202     ) 5>&1 2>&1 | eval $at_tee_pipe
   10203     at_status=`cat $at_status_file`
   10204     ;;
   10205 
   10206   61 ) # 61. conflicts.at:235: Resolved SR Conflicts
   10207     at_setup_line='conflicts.at:235'
   10208     at_desc='Resolved SR Conflicts'
   10209     $at_quiet $ECHO_N " 61: Resolved SR Conflicts                        $ECHO_C"
   10210     at_xfail=no
   10211     (
   10212       echo "61. conflicts.at:235: testing ..."
   10213       $at_traceon
   10214 
   10215 
   10216 
   10217 
   10218 cat >input.y <<'_ATEOF'
   10219 %token NUM OP
   10220 %left OP
   10221 %%
   10222 exp: exp OP exp | NUM;
   10223 _ATEOF
   10224 
   10225 
   10226 $at_traceoff
   10227 echo "conflicts.at:246: bison -o input.c --report=all input.y"
   10228 echo conflicts.at:246 >$at_check_line_file
   10229 ( $at_traceon; bison -o input.c --report=all input.y ) >$at_stdout 2>$at_stder1
   10230 at_status=$?
   10231 grep '^ *+' $at_stder1 >&2
   10232 grep -v '^ *+' $at_stder1 >$at_stderr
   10233 at_failed=false
   10234 $at_diff $at_devnull $at_stderr || at_failed=:
   10235 $at_diff $at_devnull $at_stdout || at_failed=:
   10236 case $at_status in
   10237    77) echo 77 > $at_status_file
   10238             exit 77;;
   10239    0) ;;
   10240    *) echo "conflicts.at:246: exit code was $at_status, expected 0"
   10241       at_failed=:;;
   10242 esac
   10243 if $at_failed; then
   10244 
   10245   echo 1 > $at_status_file
   10246   exit 1
   10247 fi
   10248 
   10249 $at_traceon
   10250 
   10251 
   10252 # Check the contents of the report.
   10253 $at_traceoff
   10254 echo "conflicts.at:327: cat input.output"
   10255 echo conflicts.at:327 >$at_check_line_file
   10256 ( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
   10257 at_status=$?
   10258 grep '^ *+' $at_stder1 >&2
   10259 grep -v '^ *+' $at_stder1 >$at_stderr
   10260 at_failed=false
   10261 $at_diff $at_devnull $at_stderr || at_failed=:
   10262 echo >>$at_stdout; echo "Grammar
   10263 
   10264     0 \$accept: exp \$end
   10265 
   10266     1 exp: exp OP exp
   10267     2    | NUM
   10268 
   10269 
   10270 Terminals, with rules where they appear
   10271 
   10272 \$end (0) 0
   10273 error (256)
   10274 NUM (258) 2
   10275 OP (259) 1
   10276 
   10277 
   10278 Nonterminals, with rules where they appear
   10279 
   10280 \$accept (5)
   10281     on left: 0
   10282 exp (6)
   10283     on left: 1 2, on right: 0 1
   10284 
   10285 
   10286 state 0
   10287 
   10288     0 \$accept: . exp \$end
   10289     1 exp: . exp OP exp
   10290     2    | . NUM
   10291 
   10292     NUM  shift, and go to state 1
   10293 
   10294     exp  go to state 2
   10295 
   10296 
   10297 state 1
   10298 
   10299     2 exp: NUM .
   10300 
   10301     \$default  reduce using rule 2 (exp)
   10302 
   10303 
   10304 state 2
   10305 
   10306     0 \$accept: exp . \$end
   10307     1 exp: exp . OP exp
   10308 
   10309     \$end  shift, and go to state 3
   10310     OP    shift, and go to state 4
   10311 
   10312 
   10313 state 3
   10314 
   10315     0 \$accept: exp \$end .
   10316 
   10317     \$default  accept
   10318 
   10319 
   10320 state 4
   10321 
   10322     1 exp: . exp OP exp
   10323     1    | exp OP . exp
   10324     2    | . NUM
   10325 
   10326     NUM  shift, and go to state 1
   10327 
   10328     exp  go to state 5
   10329 
   10330 
   10331 state 5
   10332 
   10333     1 exp: exp . OP exp  [\$end, OP]
   10334     1    | exp OP exp .  [\$end, OP]
   10335 
   10336     \$default  reduce using rule 1 (exp)
   10337 
   10338     Conflict between rule 1 and token OP resolved as reduce (%left OP).
   10339 " | $at_diff - $at_stdout || at_failed=:
   10340 case $at_status in
   10341    77) echo 77 > $at_status_file
   10342             exit 77;;
   10343    0) ;;
   10344    *) echo "conflicts.at:327: exit code was $at_status, expected 0"
   10345       at_failed=:;;
   10346 esac
   10347 if $at_failed; then
   10348 
   10349   echo 1 > $at_status_file
   10350   exit 1
   10351 fi
   10352 
   10353 $at_traceon
   10354 
   10355 
   10356       $at_traceoff
   10357       $at_times_p && times >$at_times_file
   10358     ) 5>&1 2>&1 | eval $at_tee_pipe
   10359     at_status=`cat $at_status_file`
   10360     ;;
   10361 
   10362   62 ) # 62. conflicts.at:357: Defaulted Conflicted Reduction
   10363     at_setup_line='conflicts.at:357'
   10364     at_desc='Defaulted Conflicted Reduction'
   10365     $at_quiet $ECHO_N " 62: Defaulted Conflicted Reduction               $ECHO_C"
   10366     at_xfail=no
   10367     (
   10368       echo "62. conflicts.at:357: testing ..."
   10369       $at_traceon
   10370 
   10371 
   10372 
   10373 cat >input.y <<'_ATEOF'
   10374 %%
   10375 exp: num | id;
   10376 num: '0';
   10377 id : '0';
   10378 %%
   10379 _ATEOF
   10380 
   10381 
   10382 $at_traceoff
   10383 echo "conflicts.at:371: bison -o input.c --report=all input.y"
   10384 echo conflicts.at:371 >$at_check_line_file
   10385 ( $at_traceon; bison -o input.c --report=all input.y ) >$at_stdout 2>$at_stder1
   10386 at_status=$?
   10387 grep '^ *+' $at_stder1 >&2
   10388 grep -v '^ *+' $at_stder1 >$at_stderr
   10389 at_failed=false
   10390 echo >>$at_stderr; echo "input.y: conflicts: 1 reduce/reduce
   10391 input.y:4.6-8: warning: rule never reduced because of conflicts: id: '0'
   10392 " | $at_diff - $at_stderr || at_failed=:
   10393 $at_diff $at_devnull $at_stdout || at_failed=:
   10394 case $at_status in
   10395    77) echo 77 > $at_status_file
   10396             exit 77;;
   10397    0) ;;
   10398    *) echo "conflicts.at:371: exit code was $at_status, expected 0"
   10399       at_failed=:;;
   10400 esac
   10401 if $at_failed; then
   10402 
   10403   echo 1 > $at_status_file
   10404   exit 1
   10405 fi
   10406 
   10407 $at_traceon
   10408 
   10409 
   10410 # Check the contents of the report.
   10411 $at_traceoff
   10412 echo "conflicts.at:465: cat input.output"
   10413 echo conflicts.at:465 >$at_check_line_file
   10414 ( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
   10415 at_status=$?
   10416 grep '^ *+' $at_stder1 >&2
   10417 grep -v '^ *+' $at_stder1 >$at_stderr
   10418 at_failed=false
   10419 $at_diff $at_devnull $at_stderr || at_failed=:
   10420 echo >>$at_stdout; echo "Rules never reduced
   10421 
   10422     4 id: '0'
   10423 
   10424 
   10425 State 1 conflicts: 1 reduce/reduce
   10426 
   10427 
   10428 Grammar
   10429 
   10430     0 \$accept: exp \$end
   10431 
   10432     1 exp: num
   10433     2    | id
   10434 
   10435     3 num: '0'
   10436 
   10437     4 id: '0'
   10438 
   10439 
   10440 Terminals, with rules where they appear
   10441 
   10442 \$end (0) 0
   10443 '0' (48) 3 4
   10444 error (256)
   10445 
   10446 
   10447 Nonterminals, with rules where they appear
   10448 
   10449 \$accept (4)
   10450     on left: 0
   10451 exp (5)
   10452     on left: 1 2, on right: 0
   10453 num (6)
   10454     on left: 3, on right: 1
   10455 id (7)
   10456     on left: 4, on right: 2
   10457 
   10458 
   10459 state 0
   10460 
   10461     0 \$accept: . exp \$end
   10462     1 exp: . num
   10463     2    | . id
   10464     3 num: . '0'
   10465     4 id: . '0'
   10466 
   10467     '0'  shift, and go to state 1
   10468 
   10469     exp  go to state 2
   10470     num  go to state 3
   10471     id   go to state 4
   10472 
   10473 
   10474 state 1
   10475 
   10476     3 num: '0' .  [\$end]
   10477     4 id: '0' .  [\$end]
   10478 
   10479     \$end      reduce using rule 3 (num)
   10480     \$end      [reduce using rule 4 (id)]
   10481     \$default  reduce using rule 3 (num)
   10482 
   10483 
   10484 state 2
   10485 
   10486     0 \$accept: exp . \$end
   10487 
   10488     \$end  shift, and go to state 5
   10489 
   10490 
   10491 state 3
   10492 
   10493     1 exp: num .
   10494 
   10495     \$default  reduce using rule 1 (exp)
   10496 
   10497 
   10498 state 4
   10499 
   10500     2 exp: id .
   10501 
   10502     \$default  reduce using rule 2 (exp)
   10503 
   10504 
   10505 state 5
   10506 
   10507     0 \$accept: exp \$end .
   10508 
   10509     \$default  accept
   10510 " | $at_diff - $at_stdout || at_failed=:
   10511 case $at_status in
   10512    77) echo 77 > $at_status_file
   10513             exit 77;;
   10514    0) ;;
   10515    *) echo "conflicts.at:465: exit code was $at_status, expected 0"
   10516       at_failed=:;;
   10517 esac
   10518 if $at_failed; then
   10519 
   10520   echo 1 > $at_status_file
   10521   exit 1
   10522 fi
   10523 
   10524 $at_traceon
   10525 
   10526 
   10527       $at_traceoff
   10528       $at_times_p && times >$at_times_file
   10529     ) 5>&1 2>&1 | eval $at_tee_pipe
   10530     at_status=`cat $at_status_file`
   10531     ;;
   10532 
   10533   63 ) # 63. conflicts.at:476: %expect not enough
   10534     at_setup_line='conflicts.at:476'
   10535     at_desc='%expect not enough'
   10536     $at_quiet $ECHO_N " 63: %expect not enough                           $ECHO_C"
   10537     at_xfail=no
   10538     (
   10539       echo "63. conflicts.at:476: testing ..."
   10540       $at_traceon
   10541 
   10542 
   10543 cat >input.y <<'_ATEOF'
   10544 %token NUM OP
   10545 %expect 0
   10546 %%
   10547 exp: exp OP exp | NUM;
   10548 _ATEOF
   10549 
   10550 
   10551 $at_traceoff
   10552 echo "conflicts.at:488: bison -o input.c input.y"
   10553 echo conflicts.at:488 >$at_check_line_file
   10554 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10555 at_status=$?
   10556 grep '^ *+' $at_stder1 >&2
   10557 grep -v '^ *+' $at_stder1 >$at_stderr
   10558 at_failed=false
   10559 echo >>$at_stderr; echo "input.y: conflicts: 1 shift/reduce
   10560 input.y: expected 0 shift/reduce conflicts
   10561 " | $at_diff - $at_stderr || at_failed=:
   10562 $at_diff $at_devnull $at_stdout || at_failed=:
   10563 case $at_status in
   10564    77) echo 77 > $at_status_file
   10565             exit 77;;
   10566    1) ;;
   10567    *) echo "conflicts.at:488: exit code was $at_status, expected 1"
   10568       at_failed=:;;
   10569 esac
   10570 if $at_failed; then
   10571 
   10572   echo 1 > $at_status_file
   10573   exit 1
   10574 fi
   10575 
   10576 $at_traceon
   10577 
   10578       $at_traceoff
   10579       $at_times_p && times >$at_times_file
   10580     ) 5>&1 2>&1 | eval $at_tee_pipe
   10581     at_status=`cat $at_status_file`
   10582     ;;
   10583 
   10584   64 ) # 64. conflicts.at:496: %expect right
   10585     at_setup_line='conflicts.at:496'
   10586     at_desc='%expect right'
   10587     $at_quiet $ECHO_N " 64: %expect right                                $ECHO_C"
   10588     at_xfail=no
   10589     (
   10590       echo "64. conflicts.at:496: testing ..."
   10591       $at_traceon
   10592 
   10593 
   10594 cat >input.y <<'_ATEOF'
   10595 %token NUM OP
   10596 %expect 1
   10597 %%
   10598 exp: exp OP exp | NUM;
   10599 _ATEOF
   10600 
   10601 
   10602 $at_traceoff
   10603 echo "conflicts.at:505: bison -o input.c input.y"
   10604 echo conflicts.at:505 >$at_check_line_file
   10605 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10606 at_status=$?
   10607 grep '^ *+' $at_stder1 >&2
   10608 grep -v '^ *+' $at_stder1 >$at_stderr
   10609 at_failed=false
   10610 $at_diff $at_devnull $at_stderr || at_failed=:
   10611 $at_diff $at_devnull $at_stdout || at_failed=:
   10612 case $at_status in
   10613    77) echo 77 > $at_status_file
   10614             exit 77;;
   10615    0) ;;
   10616    *) echo "conflicts.at:505: exit code was $at_status, expected 0"
   10617       at_failed=:;;
   10618 esac
   10619 if $at_failed; then
   10620 
   10621   echo 1 > $at_status_file
   10622   exit 1
   10623 fi
   10624 
   10625 $at_traceon
   10626 
   10627       $at_traceoff
   10628       $at_times_p && times >$at_times_file
   10629     ) 5>&1 2>&1 | eval $at_tee_pipe
   10630     at_status=`cat $at_status_file`
   10631     ;;
   10632 
   10633   65 ) # 65. conflicts.at:513: %expect too much
   10634     at_setup_line='conflicts.at:513'
   10635     at_desc='%expect too much'
   10636     $at_quiet $ECHO_N " 65: %expect too much                             $ECHO_C"
   10637     at_xfail=no
   10638     (
   10639       echo "65. conflicts.at:513: testing ..."
   10640       $at_traceon
   10641 
   10642 
   10643 cat >input.y <<'_ATEOF'
   10644 %token NUM OP
   10645 %expect 2
   10646 %%
   10647 exp: exp OP exp | NUM;
   10648 _ATEOF
   10649 
   10650 
   10651 $at_traceoff
   10652 echo "conflicts.at:525: bison -o input.c input.y"
   10653 echo conflicts.at:525 >$at_check_line_file
   10654 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10655 at_status=$?
   10656 grep '^ *+' $at_stder1 >&2
   10657 grep -v '^ *+' $at_stder1 >$at_stderr
   10658 at_failed=false
   10659 echo >>$at_stderr; echo "input.y: conflicts: 1 shift/reduce
   10660 input.y: expected 2 shift/reduce conflicts
   10661 " | $at_diff - $at_stderr || at_failed=:
   10662 $at_diff $at_devnull $at_stdout || at_failed=:
   10663 case $at_status in
   10664    77) echo 77 > $at_status_file
   10665             exit 77;;
   10666    1) ;;
   10667    *) echo "conflicts.at:525: exit code was $at_status, expected 1"
   10668       at_failed=:;;
   10669 esac
   10670 if $at_failed; then
   10671 
   10672   echo 1 > $at_status_file
   10673   exit 1
   10674 fi
   10675 
   10676 $at_traceon
   10677 
   10678       $at_traceoff
   10679       $at_times_p && times >$at_times_file
   10680     ) 5>&1 2>&1 | eval $at_tee_pipe
   10681     at_status=`cat $at_status_file`
   10682     ;;
   10683 
   10684   66 ) # 66. conflicts.at:533: %expect with reduce conflicts
   10685     at_setup_line='conflicts.at:533'
   10686     at_desc='%expect with reduce conflicts'
   10687     $at_quiet $ECHO_N " 66: %expect with reduce conflicts                $ECHO_C"
   10688     at_xfail=no
   10689     (
   10690       echo "66. conflicts.at:533: testing ..."
   10691       $at_traceon
   10692 
   10693 
   10694 cat >input.y <<'_ATEOF'
   10695 %expect 0
   10696 %%
   10697 program: a 'a' | a a;
   10698 a: 'a';
   10699 _ATEOF
   10700 
   10701 
   10702 $at_traceoff
   10703 echo "conflicts.at:545: bison -o input.c input.y"
   10704 echo conflicts.at:545 >$at_check_line_file
   10705 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10706 at_status=$?
   10707 grep '^ *+' $at_stder1 >&2
   10708 grep -v '^ *+' $at_stder1 >$at_stderr
   10709 at_failed=false
   10710 echo >>$at_stderr; echo "input.y: conflicts: 1 reduce/reduce
   10711 input.y: expected 0 reduce/reduce conflicts
   10712 " | $at_diff - $at_stderr || at_failed=:
   10713 $at_diff $at_devnull $at_stdout || at_failed=:
   10714 case $at_status in
   10715    77) echo 77 > $at_status_file
   10716             exit 77;;
   10717    1) ;;
   10718    *) echo "conflicts.at:545: exit code was $at_status, expected 1"
   10719       at_failed=:;;
   10720 esac
   10721 if $at_failed; then
   10722 
   10723   echo 1 > $at_status_file
   10724   exit 1
   10725 fi
   10726 
   10727 $at_traceon
   10728 
   10729       $at_traceoff
   10730       $at_times_p && times >$at_times_file
   10731     ) 5>&1 2>&1 | eval $at_tee_pipe
   10732     at_status=`cat $at_status_file`
   10733     ;;
   10734 
   10735   67 ) # 67. conflicts.at:553: %no-default-prec without %prec
   10736     at_setup_line='conflicts.at:553'
   10737     at_desc='%no-default-prec without %prec'
   10738     $at_quiet $ECHO_N " 67: %no-default-prec without %prec               $ECHO_C"
   10739     at_xfail=no
   10740     (
   10741       echo "67. conflicts.at:553: testing ..."
   10742       $at_traceon
   10743 
   10744 
   10745 cat >input.y <<'_ATEOF'
   10746 %left '+'
   10747 %left '*'
   10748 
   10749 %%
   10750 
   10751 %no-default-prec;
   10752 
   10753 e:   e '+' e
   10754    | e '*' e
   10755    | '0'
   10756    ;
   10757 _ATEOF
   10758 
   10759 
   10760 $at_traceoff
   10761 echo "conflicts.at:571: bison -o input.c input.y"
   10762 echo conflicts.at:571 >$at_check_line_file
   10763 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10764 at_status=$?
   10765 grep '^ *+' $at_stder1 >&2
   10766 grep -v '^ *+' $at_stder1 >$at_stderr
   10767 at_failed=false
   10768 echo >>$at_stderr; echo "input.y: conflicts: 4 shift/reduce
   10769 " | $at_diff - $at_stderr || at_failed=:
   10770 $at_diff $at_devnull $at_stdout || at_failed=:
   10771 case $at_status in
   10772    77) echo 77 > $at_status_file
   10773             exit 77;;
   10774    0) ;;
   10775    *) echo "conflicts.at:571: exit code was $at_status, expected 0"
   10776       at_failed=:;;
   10777 esac
   10778 if $at_failed; then
   10779 
   10780   echo 1 > $at_status_file
   10781   exit 1
   10782 fi
   10783 
   10784 $at_traceon
   10785 
   10786       $at_traceoff
   10787       $at_times_p && times >$at_times_file
   10788     ) 5>&1 2>&1 | eval $at_tee_pipe
   10789     at_status=`cat $at_status_file`
   10790     ;;
   10791 
   10792   68 ) # 68. conflicts.at:579: %no-default-prec with %prec
   10793     at_setup_line='conflicts.at:579'
   10794     at_desc='%no-default-prec with %prec'
   10795     $at_quiet $ECHO_N " 68: %no-default-prec with %prec                  $ECHO_C"
   10796     at_xfail=no
   10797     (
   10798       echo "68. conflicts.at:579: testing ..."
   10799       $at_traceon
   10800 
   10801 
   10802 cat >input.y <<'_ATEOF'
   10803 %left '+'
   10804 %left '*'
   10805 
   10806 %%
   10807 
   10808 %no-default-prec;
   10809 
   10810 e:   e '+' e %prec '+'
   10811    | e '*' e %prec '*'
   10812    | '0'
   10813    ;
   10814 _ATEOF
   10815 
   10816 
   10817 $at_traceoff
   10818 echo "conflicts.at:595: bison -o input.c input.y"
   10819 echo conflicts.at:595 >$at_check_line_file
   10820 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10821 at_status=$?
   10822 grep '^ *+' $at_stder1 >&2
   10823 grep -v '^ *+' $at_stder1 >$at_stderr
   10824 at_failed=false
   10825 $at_diff $at_devnull $at_stderr || at_failed=:
   10826 $at_diff $at_devnull $at_stdout || at_failed=:
   10827 case $at_status in
   10828    77) echo 77 > $at_status_file
   10829             exit 77;;
   10830    0) ;;
   10831    *) echo "conflicts.at:595: exit code was $at_status, expected 0"
   10832       at_failed=:;;
   10833 esac
   10834 if $at_failed; then
   10835 
   10836   echo 1 > $at_status_file
   10837   exit 1
   10838 fi
   10839 
   10840 $at_traceon
   10841 
   10842       $at_traceoff
   10843       $at_times_p && times >$at_times_file
   10844     ) 5>&1 2>&1 | eval $at_tee_pipe
   10845     at_status=`cat $at_status_file`
   10846     ;;
   10847 
   10848   69 ) # 69. conflicts.at:603: %default-prec
   10849     at_setup_line='conflicts.at:603'
   10850     at_desc='%default-prec'
   10851     $at_quiet $ECHO_N " 69: %default-prec                                $ECHO_C"
   10852     at_xfail=no
   10853     (
   10854       echo "69. conflicts.at:603: testing ..."
   10855       $at_traceon
   10856 
   10857 
   10858 cat >input.y <<'_ATEOF'
   10859 %left '+'
   10860 %left '*'
   10861 
   10862 %%
   10863 
   10864 %default-prec;
   10865 
   10866 e:   e '+' e
   10867    | e '*' e
   10868    | '0'
   10869    ;
   10870 _ATEOF
   10871 
   10872 
   10873 $at_traceoff
   10874 echo "conflicts.at:619: bison -o input.c input.y"
   10875 echo conflicts.at:619 >$at_check_line_file
   10876 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10877 at_status=$?
   10878 grep '^ *+' $at_stder1 >&2
   10879 grep -v '^ *+' $at_stder1 >$at_stderr
   10880 at_failed=false
   10881 $at_diff $at_devnull $at_stderr || at_failed=:
   10882 $at_diff $at_devnull $at_stdout || at_failed=:
   10883 case $at_status in
   10884    77) echo 77 > $at_status_file
   10885             exit 77;;
   10886    0) ;;
   10887    *) echo "conflicts.at:619: exit code was $at_status, expected 0"
   10888       at_failed=:;;
   10889 esac
   10890 if $at_failed; then
   10891 
   10892   echo 1 > $at_status_file
   10893   exit 1
   10894 fi
   10895 
   10896 $at_traceon
   10897 
   10898       $at_traceoff
   10899       $at_times_p && times >$at_times_file
   10900     ) 5>&1 2>&1 | eval $at_tee_pipe
   10901     at_status=`cat $at_status_file`
   10902     ;;
   10903 
   10904 
   10905   banner-9 ) # Banner 9. calc.at:541
   10906     cat <<\_ATEOF
   10907 
   10908 Simple LALR(1) Calculator.
   10909 
   10910 _ATEOF
   10911     ;;
   10912 
   10913   70 ) # 70. calc.at:550: Calculator
   10914     at_setup_line='calc.at:550'
   10915     at_desc='Calculator '
   10916     $at_quiet $ECHO_N " 70: Calculator                                   $ECHO_C"
   10917     at_xfail=no
   10918     (
   10919       echo "70. calc.at:550: testing ..."
   10920       $at_traceon
   10921 
   10922 
   10923 
   10924 
   10925 
   10926 
   10927 
   10928 
   10929 # Using yacc.c?
   10930 
   10931 
   10932 
   10933 
   10934 
   10935 
   10936 
   10937 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   10938 
   10939 # yyerror always sees the locations (when activated), except if
   10940 # yacc & pure & !param.
   10941 
   10942 
   10943 # The interface is pure: either because %pure-parser, or because we
   10944 # are using the C++ parsers.
   10945 
   10946 
   10947 
   10948 
   10949 
   10950 
   10951 
   10952 
   10953 
   10954 
   10955 
   10956 
   10957 cat >calc.y <<'_ATEOF'
   10958 %{
   10959 #ifdef HAVE_CONFIG_H
   10960 # include <config.h>
   10961   /* We don't need perfect functions for these tests. */
   10962 # undef malloc
   10963 # undef memcmp
   10964 # undef realloc
   10965 #endif
   10966 %}
   10967 
   10968 /* Infix notation calculator--calc */
   10969 
   10970 
   10971 %{
   10972 #include <stdio.h>
   10973 
   10974 #include <stdlib.h>
   10975 #include <string.h>
   10976 #if HAVE_UNISTD_H
   10977 # include <unistd.h>
   10978 #else
   10979 # undef alarm
   10980 # define alarm(seconds) /* empty */
   10981 #endif
   10982 #include <ctype.h>
   10983 #define USE(Var)
   10984 
   10985 /* Exercise pre-prologue dependency to %union.  */
   10986 typedef int semantic_value;
   10987 
   10988 static semantic_value global_result = 0;
   10989 static int global_count = 0;
   10990 %}
   10991 
   10992 /* Exercise %union. */
   10993 %union
   10994 {
   10995   semantic_value ival;
   10996 };
   10997 
   10998 %{
   10999 static int power (int base, int exponent);
   11000 /* yyerror receives the location if:
   11001    - %location & %pure & %glr
   11002    - %location & %pure & %yacc & %parse-param. */
   11003 static void yyerror (
   11004 
   11005                      const char *s
   11006                      );
   11007 static int yylex (void);
   11008 static int get_char (void);
   11009 static void unget_char ( int c);
   11010 %}
   11011 
   11012 
   11013 
   11014 /* Bison Declarations */
   11015 %token CALC_EOF 0 "end of input"
   11016 %token <ival> NUM "number"
   11017 %type  <ival> exp
   11018 
   11019 %nonassoc '=' /* comparison	       */
   11020 %left '-' '+'
   11021 %left '*' '/'
   11022 %left NEG     /* negation--unary minus */
   11023 %right '^'    /* exponentiation        */
   11024 
   11025 /* Grammar follows */
   11026 %%
   11027 input:
   11028   line
   11029 | input line         {  }
   11030 ;
   11031 
   11032 line:
   11033   '\n'
   11034 | exp '\n'           { USE ($1); }
   11035 ;
   11036 
   11037 exp:
   11038   NUM                { $$ = $1;             }
   11039 | exp '=' exp
   11040   {
   11041     if ($1 != $3)
   11042       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   11043     $$ = $1;
   11044   }
   11045 | exp '+' exp        { $$ = $1 + $3;        }
   11046 | exp '-' exp        { $$ = $1 - $3;        }
   11047 | exp '*' exp        { $$ = $1 * $3;        }
   11048 | exp '/' exp        { $$ = $1 / $3;        }
   11049 | '-' exp  %prec NEG { $$ = -$2;            }
   11050 | exp '^' exp        { $$ = power ($1, $3); }
   11051 | '(' exp ')'        { $$ = $2;             }
   11052 | '(' error ')'      { $$ = 1111;           }
   11053 | '!'                { $$ = 0; YYERROR;     }
   11054 | '-' error          { $$ = 0; YYERROR;     }
   11055 ;
   11056 %%
   11057 /* The input.  */
   11058 static FILE *input;
   11059 
   11060 static void
   11061 yyerror (
   11062 
   11063          const char *s)
   11064 {
   11065 
   11066 
   11067   fprintf (stderr, "%s\n", s);
   11068 }
   11069 
   11070 
   11071 
   11072 static int
   11073 get_char (void)
   11074 {
   11075   int res = getc (input);
   11076   ;
   11077 
   11078   return res;
   11079 }
   11080 
   11081 
   11082 static void
   11083 unget_char ( int c)
   11084 {
   11085   ;
   11086 
   11087   ungetc (c, input);
   11088 }
   11089 
   11090 static int
   11091 read_signed_integer (void)
   11092 {
   11093   int c = get_char ();
   11094   int sign = 1;
   11095   int n = 0;
   11096 
   11097   ;
   11098   if (c == '-')
   11099     {
   11100       c = get_char ();
   11101       sign = -1;
   11102     }
   11103 
   11104   while (isdigit (c))
   11105     {
   11106       n = 10 * n + (c - '0');
   11107       c = get_char ();
   11108     }
   11109 
   11110   unget_char ( c);
   11111 
   11112   return sign * n;
   11113 }
   11114 
   11115 
   11116 
   11117 /*---------------------------------------------------------------.
   11118 | Lexical analyzer returns an integer on the stack and the token |
   11119 | NUM, or the ASCII character read if not a number.  Skips all   |
   11120 | blanks and tabs, returns 0 for EOF.                            |
   11121 `---------------------------------------------------------------*/
   11122 
   11123 static int
   11124 yylex (void)
   11125 {
   11126   static int init = 1;
   11127   int c;
   11128 
   11129   if (init)
   11130     {
   11131       init = 0;
   11132 
   11133     }
   11134 
   11135 
   11136 
   11137   /* Skip white space.  */
   11138   while ((c = get_char ()) == ' ' || c == '\t')
   11139     {
   11140 
   11141     }
   11142 
   11143   /* process numbers   */
   11144   if (c == '.' || isdigit (c))
   11145     {
   11146       unget_char ( c);
   11147       (yylval).ival = read_signed_integer ();
   11148       return NUM;
   11149     }
   11150 
   11151   /* Return end-of-file.  */
   11152   if (c == EOF)
   11153     return CALC_EOF;
   11154 
   11155   /* Return single chars. */
   11156   return c;
   11157 }
   11158 
   11159 static int
   11160 power (int base, int exponent)
   11161 {
   11162   int res = 1;
   11163   if (exponent < 0)
   11164     exit (3);
   11165   for (/* Niente */; exponent; --exponent)
   11166     res *= base;
   11167   return res;
   11168 }
   11169 
   11170 
   11171 int
   11172 main (int argc, const char **argv)
   11173 {
   11174   semantic_value result = 0;
   11175   int count = 0;
   11176   int status;
   11177 
   11178   /* This used to be alarm (10), but that isn't enough time for
   11179      a July 1995 vintage DEC Alphastation 200 4/100 system,
   11180      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   11181   alarm (100);
   11182 
   11183   if (argc == 2)
   11184     input = fopen (argv[1], "r");
   11185   else
   11186     input = stdin;
   11187 
   11188   if (!input)
   11189     {
   11190       perror (argv[1]);
   11191       return 3;
   11192     }
   11193 
   11194 
   11195   status = yyparse ();
   11196   if (global_result != result)
   11197     abort ();
   11198   if (global_count != count)
   11199     abort ();
   11200   return status;
   11201 }
   11202 _ATEOF
   11203 
   11204 
   11205 
   11206 
   11207 
   11208 $at_traceoff
   11209 echo "calc.at:550: bison -o calc.c calc.y"
   11210 echo calc.at:550 >$at_check_line_file
   11211 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   11212 at_status=$?
   11213 grep '^ *+' $at_stder1 >&2
   11214 grep -v '^ *+' $at_stder1 >$at_stderr
   11215 at_failed=false
   11216 $at_diff $at_devnull $at_stderr || at_failed=:
   11217 $at_diff $at_devnull $at_stdout || at_failed=:
   11218 case $at_status in
   11219    77) echo 77 > $at_status_file
   11220             exit 77;;
   11221    0) ;;
   11222    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11223       at_failed=:;;
   11224 esac
   11225 if $at_failed; then
   11226 
   11227   echo 1 > $at_status_file
   11228   exit 1
   11229 fi
   11230 
   11231 $at_traceon
   11232 
   11233    $at_traceoff
   11234 echo "calc.at:550: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   11235 echo calc.at:550 >$at_check_line_file
   11236 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   11237 at_status=$?
   11238 grep '^ *+' $at_stder1 >&2
   11239 grep -v '^ *+' $at_stder1 >$at_stderr
   11240 at_failed=false
   11241 echo stderr:; cat $at_stderr
   11242 echo stdout:; cat $at_stdout
   11243 case $at_status in
   11244    77) echo 77 > $at_status_file
   11245             exit 77;;
   11246    0) ;;
   11247    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11248       at_failed=:;;
   11249 esac
   11250 if $at_failed; then
   11251 
   11252   echo 1 > $at_status_file
   11253   exit 1
   11254 fi
   11255 
   11256 $at_traceon
   11257 
   11258 
   11259 # Test the priorities.
   11260 cat >input <<'_ATEOF'
   11261 1 + 2 * 3 = 7
   11262 1 + 2 * -3 = -5
   11263 
   11264 -1^2 = -1
   11265 (-1)^2 = 1
   11266 
   11267 ---1 = -1
   11268 
   11269 1 - 2 - 3 = -4
   11270 1 - (2 - 3) = 2
   11271 
   11272 2^2^3 = 256
   11273 (2^2)^3 = 64
   11274 _ATEOF
   11275 
   11276 $at_traceoff
   11277 echo "calc.at:550: \$PREPARSER ./calc input"
   11278 echo calc.at:550 >$at_check_line_file
   11279 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11280 at_status=$?
   11281 grep '^ *+' $at_stder1 >&2
   11282 grep -v '^ *+' $at_stder1 >$at_stderr
   11283 at_failed=false
   11284 echo stderr:; tee stderr <$at_stderr
   11285 $at_diff $at_devnull $at_stdout || at_failed=:
   11286 case $at_status in
   11287    77) echo 77 > $at_status_file
   11288             exit 77;;
   11289    0) ;;
   11290    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11291       at_failed=:;;
   11292 esac
   11293 if $at_failed; then
   11294 
   11295   echo 1 > $at_status_file
   11296   exit 1
   11297 fi
   11298 
   11299 $at_traceon
   11300 
   11301 
   11302 
   11303 # Some syntax errors.
   11304 cat >input <<'_ATEOF'
   11305 0 0
   11306 _ATEOF
   11307 
   11308 $at_traceoff
   11309 echo "calc.at:550: \$PREPARSER ./calc input"
   11310 echo calc.at:550 >$at_check_line_file
   11311 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11312 at_status=$?
   11313 grep '^ *+' $at_stder1 >&2
   11314 grep -v '^ *+' $at_stder1 >$at_stderr
   11315 at_failed=false
   11316 echo stderr:; tee stderr <$at_stderr
   11317 $at_diff $at_devnull $at_stdout || at_failed=:
   11318 case $at_status in
   11319    77) echo 77 > $at_status_file
   11320             exit 77;;
   11321    1) ;;
   11322    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11323       at_failed=:;;
   11324 esac
   11325 if $at_failed; then
   11326 
   11327   echo 1 > $at_status_file
   11328   exit 1
   11329 fi
   11330 
   11331 $at_traceon
   11332 
   11333 
   11334 # Normalize the observed and expected error messages, depending upon the
   11335 # options.
   11336 # 1. Remove the traces from observed.
   11337 sed '/^Starting/d
   11338 /^Entering/d
   11339 /^Stack/d
   11340 /^Reading/d
   11341 /^Reducing/d
   11342 /^Shifting/d
   11343 /^state/d
   11344 /^Cleanup:/d
   11345 /^Error:/d
   11346 /^Next/d
   11347 /^Discarding/d
   11348 / \$[0-9$]* = /d
   11349 /^yydestructor:/d' stderr >at-stderr
   11350 mv at-stderr stderr
   11351 # 2. Create the reference error message.
   11352 cat >expout <<'_ATEOF'
   11353 1.2: syntax error, unexpected number
   11354 _ATEOF
   11355 
   11356 # 3. If locations are not used, remove them.
   11357 sed 's/^[-0-9.]*: //' expout >at-expout
   11358 mv at-expout expout
   11359 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11360 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11361 mv at-expout expout
   11362 # 5. Check
   11363 $at_traceoff
   11364 echo "calc.at:550: cat stderr"
   11365 echo calc.at:550 >$at_check_line_file
   11366 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11367 at_status=$?
   11368 grep '^ *+' $at_stder1 >&2
   11369 grep -v '^ *+' $at_stder1 >$at_stderr
   11370 at_failed=false
   11371 $at_diff $at_devnull $at_stderr || at_failed=:
   11372 $at_diff expout $at_stdout || at_failed=:
   11373 case $at_status in
   11374    77) echo 77 > $at_status_file
   11375             exit 77;;
   11376    0) ;;
   11377    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11378       at_failed=:;;
   11379 esac
   11380 if $at_failed; then
   11381 
   11382   echo 1 > $at_status_file
   11383   exit 1
   11384 fi
   11385 
   11386 $at_traceon
   11387 
   11388 
   11389 cat >input <<'_ATEOF'
   11390 1//2
   11391 _ATEOF
   11392 
   11393 $at_traceoff
   11394 echo "calc.at:550: \$PREPARSER ./calc input"
   11395 echo calc.at:550 >$at_check_line_file
   11396 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11397 at_status=$?
   11398 grep '^ *+' $at_stder1 >&2
   11399 grep -v '^ *+' $at_stder1 >$at_stderr
   11400 at_failed=false
   11401 echo stderr:; tee stderr <$at_stderr
   11402 $at_diff $at_devnull $at_stdout || at_failed=:
   11403 case $at_status in
   11404    77) echo 77 > $at_status_file
   11405             exit 77;;
   11406    1) ;;
   11407    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11408       at_failed=:;;
   11409 esac
   11410 if $at_failed; then
   11411 
   11412   echo 1 > $at_status_file
   11413   exit 1
   11414 fi
   11415 
   11416 $at_traceon
   11417 
   11418 
   11419 # Normalize the observed and expected error messages, depending upon the
   11420 # options.
   11421 # 1. Remove the traces from observed.
   11422 sed '/^Starting/d
   11423 /^Entering/d
   11424 /^Stack/d
   11425 /^Reading/d
   11426 /^Reducing/d
   11427 /^Shifting/d
   11428 /^state/d
   11429 /^Cleanup:/d
   11430 /^Error:/d
   11431 /^Next/d
   11432 /^Discarding/d
   11433 / \$[0-9$]* = /d
   11434 /^yydestructor:/d' stderr >at-stderr
   11435 mv at-stderr stderr
   11436 # 2. Create the reference error message.
   11437 cat >expout <<'_ATEOF'
   11438 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   11439 _ATEOF
   11440 
   11441 # 3. If locations are not used, remove them.
   11442 sed 's/^[-0-9.]*: //' expout >at-expout
   11443 mv at-expout expout
   11444 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11445 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11446 mv at-expout expout
   11447 # 5. Check
   11448 $at_traceoff
   11449 echo "calc.at:550: cat stderr"
   11450 echo calc.at:550 >$at_check_line_file
   11451 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11452 at_status=$?
   11453 grep '^ *+' $at_stder1 >&2
   11454 grep -v '^ *+' $at_stder1 >$at_stderr
   11455 at_failed=false
   11456 $at_diff $at_devnull $at_stderr || at_failed=:
   11457 $at_diff expout $at_stdout || at_failed=:
   11458 case $at_status in
   11459    77) echo 77 > $at_status_file
   11460             exit 77;;
   11461    0) ;;
   11462    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11463       at_failed=:;;
   11464 esac
   11465 if $at_failed; then
   11466 
   11467   echo 1 > $at_status_file
   11468   exit 1
   11469 fi
   11470 
   11471 $at_traceon
   11472 
   11473 
   11474 cat >input <<'_ATEOF'
   11475 error
   11476 _ATEOF
   11477 
   11478 $at_traceoff
   11479 echo "calc.at:550: \$PREPARSER ./calc input"
   11480 echo calc.at:550 >$at_check_line_file
   11481 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11482 at_status=$?
   11483 grep '^ *+' $at_stder1 >&2
   11484 grep -v '^ *+' $at_stder1 >$at_stderr
   11485 at_failed=false
   11486 echo stderr:; tee stderr <$at_stderr
   11487 $at_diff $at_devnull $at_stdout || at_failed=:
   11488 case $at_status in
   11489    77) echo 77 > $at_status_file
   11490             exit 77;;
   11491    1) ;;
   11492    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11493       at_failed=:;;
   11494 esac
   11495 if $at_failed; then
   11496 
   11497   echo 1 > $at_status_file
   11498   exit 1
   11499 fi
   11500 
   11501 $at_traceon
   11502 
   11503 
   11504 # Normalize the observed and expected error messages, depending upon the
   11505 # options.
   11506 # 1. Remove the traces from observed.
   11507 sed '/^Starting/d
   11508 /^Entering/d
   11509 /^Stack/d
   11510 /^Reading/d
   11511 /^Reducing/d
   11512 /^Shifting/d
   11513 /^state/d
   11514 /^Cleanup:/d
   11515 /^Error:/d
   11516 /^Next/d
   11517 /^Discarding/d
   11518 / \$[0-9$]* = /d
   11519 /^yydestructor:/d' stderr >at-stderr
   11520 mv at-stderr stderr
   11521 # 2. Create the reference error message.
   11522 cat >expout <<'_ATEOF'
   11523 1.0: syntax error, unexpected $undefined
   11524 _ATEOF
   11525 
   11526 # 3. If locations are not used, remove them.
   11527 sed 's/^[-0-9.]*: //' expout >at-expout
   11528 mv at-expout expout
   11529 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11530 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11531 mv at-expout expout
   11532 # 5. Check
   11533 $at_traceoff
   11534 echo "calc.at:550: cat stderr"
   11535 echo calc.at:550 >$at_check_line_file
   11536 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11537 at_status=$?
   11538 grep '^ *+' $at_stder1 >&2
   11539 grep -v '^ *+' $at_stder1 >$at_stderr
   11540 at_failed=false
   11541 $at_diff $at_devnull $at_stderr || at_failed=:
   11542 $at_diff expout $at_stdout || at_failed=:
   11543 case $at_status in
   11544    77) echo 77 > $at_status_file
   11545             exit 77;;
   11546    0) ;;
   11547    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11548       at_failed=:;;
   11549 esac
   11550 if $at_failed; then
   11551 
   11552   echo 1 > $at_status_file
   11553   exit 1
   11554 fi
   11555 
   11556 $at_traceon
   11557 
   11558 
   11559 cat >input <<'_ATEOF'
   11560 1 = 2 = 3
   11561 _ATEOF
   11562 
   11563 $at_traceoff
   11564 echo "calc.at:550: \$PREPARSER ./calc input"
   11565 echo calc.at:550 >$at_check_line_file
   11566 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11567 at_status=$?
   11568 grep '^ *+' $at_stder1 >&2
   11569 grep -v '^ *+' $at_stder1 >$at_stderr
   11570 at_failed=false
   11571 echo stderr:; tee stderr <$at_stderr
   11572 $at_diff $at_devnull $at_stdout || at_failed=:
   11573 case $at_status in
   11574    77) echo 77 > $at_status_file
   11575             exit 77;;
   11576    1) ;;
   11577    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11578       at_failed=:;;
   11579 esac
   11580 if $at_failed; then
   11581 
   11582   echo 1 > $at_status_file
   11583   exit 1
   11584 fi
   11585 
   11586 $at_traceon
   11587 
   11588 
   11589 # Normalize the observed and expected error messages, depending upon the
   11590 # options.
   11591 # 1. Remove the traces from observed.
   11592 sed '/^Starting/d
   11593 /^Entering/d
   11594 /^Stack/d
   11595 /^Reading/d
   11596 /^Reducing/d
   11597 /^Shifting/d
   11598 /^state/d
   11599 /^Cleanup:/d
   11600 /^Error:/d
   11601 /^Next/d
   11602 /^Discarding/d
   11603 / \$[0-9$]* = /d
   11604 /^yydestructor:/d' stderr >at-stderr
   11605 mv at-stderr stderr
   11606 # 2. Create the reference error message.
   11607 cat >expout <<'_ATEOF'
   11608 1.6: syntax error, unexpected '='
   11609 _ATEOF
   11610 
   11611 # 3. If locations are not used, remove them.
   11612 sed 's/^[-0-9.]*: //' expout >at-expout
   11613 mv at-expout expout
   11614 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11615 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11616 mv at-expout expout
   11617 # 5. Check
   11618 $at_traceoff
   11619 echo "calc.at:550: cat stderr"
   11620 echo calc.at:550 >$at_check_line_file
   11621 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11622 at_status=$?
   11623 grep '^ *+' $at_stder1 >&2
   11624 grep -v '^ *+' $at_stder1 >$at_stderr
   11625 at_failed=false
   11626 $at_diff $at_devnull $at_stderr || at_failed=:
   11627 $at_diff expout $at_stdout || at_failed=:
   11628 case $at_status in
   11629    77) echo 77 > $at_status_file
   11630             exit 77;;
   11631    0) ;;
   11632    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11633       at_failed=:;;
   11634 esac
   11635 if $at_failed; then
   11636 
   11637   echo 1 > $at_status_file
   11638   exit 1
   11639 fi
   11640 
   11641 $at_traceon
   11642 
   11643 
   11644 cat >input <<'_ATEOF'
   11645 
   11646 +1
   11647 _ATEOF
   11648 
   11649 $at_traceoff
   11650 echo "calc.at:550: \$PREPARSER ./calc input"
   11651 echo calc.at:550 >$at_check_line_file
   11652 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11653 at_status=$?
   11654 grep '^ *+' $at_stder1 >&2
   11655 grep -v '^ *+' $at_stder1 >$at_stderr
   11656 at_failed=false
   11657 echo stderr:; tee stderr <$at_stderr
   11658 $at_diff $at_devnull $at_stdout || at_failed=:
   11659 case $at_status in
   11660    77) echo 77 > $at_status_file
   11661             exit 77;;
   11662    1) ;;
   11663    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11664       at_failed=:;;
   11665 esac
   11666 if $at_failed; then
   11667 
   11668   echo 1 > $at_status_file
   11669   exit 1
   11670 fi
   11671 
   11672 $at_traceon
   11673 
   11674 
   11675 # Normalize the observed and expected error messages, depending upon the
   11676 # options.
   11677 # 1. Remove the traces from observed.
   11678 sed '/^Starting/d
   11679 /^Entering/d
   11680 /^Stack/d
   11681 /^Reading/d
   11682 /^Reducing/d
   11683 /^Shifting/d
   11684 /^state/d
   11685 /^Cleanup:/d
   11686 /^Error:/d
   11687 /^Next/d
   11688 /^Discarding/d
   11689 / \$[0-9$]* = /d
   11690 /^yydestructor:/d' stderr >at-stderr
   11691 mv at-stderr stderr
   11692 # 2. Create the reference error message.
   11693 cat >expout <<'_ATEOF'
   11694 2.0: syntax error, unexpected '+'
   11695 _ATEOF
   11696 
   11697 # 3. If locations are not used, remove them.
   11698 sed 's/^[-0-9.]*: //' expout >at-expout
   11699 mv at-expout expout
   11700 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11701 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11702 mv at-expout expout
   11703 # 5. Check
   11704 $at_traceoff
   11705 echo "calc.at:550: cat stderr"
   11706 echo calc.at:550 >$at_check_line_file
   11707 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11708 at_status=$?
   11709 grep '^ *+' $at_stder1 >&2
   11710 grep -v '^ *+' $at_stder1 >$at_stderr
   11711 at_failed=false
   11712 $at_diff $at_devnull $at_stderr || at_failed=:
   11713 $at_diff expout $at_stdout || at_failed=:
   11714 case $at_status in
   11715    77) echo 77 > $at_status_file
   11716             exit 77;;
   11717    0) ;;
   11718    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11719       at_failed=:;;
   11720 esac
   11721 if $at_failed; then
   11722 
   11723   echo 1 > $at_status_file
   11724   exit 1
   11725 fi
   11726 
   11727 $at_traceon
   11728 
   11729 
   11730 # Exercise error messages with EOF: work on an empty file.
   11731 $at_traceoff
   11732 echo "calc.at:550: \$PREPARSER ./calc /dev/null"
   11733 echo calc.at:550 >$at_check_line_file
   11734 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   11735 at_status=$?
   11736 grep '^ *+' $at_stder1 >&2
   11737 grep -v '^ *+' $at_stder1 >$at_stderr
   11738 at_failed=false
   11739 echo stderr:; tee stderr <$at_stderr
   11740 $at_diff $at_devnull $at_stdout || at_failed=:
   11741 case $at_status in
   11742    77) echo 77 > $at_status_file
   11743             exit 77;;
   11744    1) ;;
   11745    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11746       at_failed=:;;
   11747 esac
   11748 if $at_failed; then
   11749 
   11750   echo 1 > $at_status_file
   11751   exit 1
   11752 fi
   11753 
   11754 $at_traceon
   11755 
   11756 
   11757 # Normalize the observed and expected error messages, depending upon the
   11758 # options.
   11759 # 1. Remove the traces from observed.
   11760 sed '/^Starting/d
   11761 /^Entering/d
   11762 /^Stack/d
   11763 /^Reading/d
   11764 /^Reducing/d
   11765 /^Shifting/d
   11766 /^state/d
   11767 /^Cleanup:/d
   11768 /^Error:/d
   11769 /^Next/d
   11770 /^Discarding/d
   11771 / \$[0-9$]* = /d
   11772 /^yydestructor:/d' stderr >at-stderr
   11773 mv at-stderr stderr
   11774 # 2. Create the reference error message.
   11775 cat >expout <<'_ATEOF'
   11776 1.0: syntax error, unexpected end of input
   11777 _ATEOF
   11778 
   11779 # 3. If locations are not used, remove them.
   11780 sed 's/^[-0-9.]*: //' expout >at-expout
   11781 mv at-expout expout
   11782 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11783 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11784 mv at-expout expout
   11785 # 5. Check
   11786 $at_traceoff
   11787 echo "calc.at:550: cat stderr"
   11788 echo calc.at:550 >$at_check_line_file
   11789 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11790 at_status=$?
   11791 grep '^ *+' $at_stder1 >&2
   11792 grep -v '^ *+' $at_stder1 >$at_stderr
   11793 at_failed=false
   11794 $at_diff $at_devnull $at_stderr || at_failed=:
   11795 $at_diff expout $at_stdout || at_failed=:
   11796 case $at_status in
   11797    77) echo 77 > $at_status_file
   11798             exit 77;;
   11799    0) ;;
   11800    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11801       at_failed=:;;
   11802 esac
   11803 if $at_failed; then
   11804 
   11805   echo 1 > $at_status_file
   11806   exit 1
   11807 fi
   11808 
   11809 $at_traceon
   11810 
   11811 
   11812 
   11813 # Exercise the error token: without it, we die at the first error,
   11814 # hence be sure to
   11815 #
   11816 # - have several errors which exercise different shift/discardings
   11817 #   - (): nothing to pop, nothing to discard
   11818 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   11819 #   - (* * *): nothing to pop, a lot to discard
   11820 #   - (1 + 2 * *): some to pop and discard
   11821 #
   11822 # - test the action associated to `error'
   11823 #
   11824 # - check the look-ahead that triggers an error is not discarded
   11825 #   when we enter error recovery.  Below, the look-ahead causing the
   11826 #   first error is ")", which is needed to recover from the error and
   11827 #   produce the "0" that triggers the "0 != 1" error.
   11828 #
   11829 cat >input <<'_ATEOF'
   11830 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   11831 _ATEOF
   11832 
   11833 $at_traceoff
   11834 echo "calc.at:550: \$PREPARSER ./calc input"
   11835 echo calc.at:550 >$at_check_line_file
   11836 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11837 at_status=$?
   11838 grep '^ *+' $at_stder1 >&2
   11839 grep -v '^ *+' $at_stder1 >$at_stderr
   11840 at_failed=false
   11841 echo stderr:; tee stderr <$at_stderr
   11842 $at_diff $at_devnull $at_stdout || at_failed=:
   11843 case $at_status in
   11844    77) echo 77 > $at_status_file
   11845             exit 77;;
   11846    0) ;;
   11847    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11848       at_failed=:;;
   11849 esac
   11850 if $at_failed; then
   11851 
   11852   echo 1 > $at_status_file
   11853   exit 1
   11854 fi
   11855 
   11856 $at_traceon
   11857 
   11858 
   11859 # Normalize the observed and expected error messages, depending upon the
   11860 # options.
   11861 # 1. Remove the traces from observed.
   11862 sed '/^Starting/d
   11863 /^Entering/d
   11864 /^Stack/d
   11865 /^Reading/d
   11866 /^Reducing/d
   11867 /^Shifting/d
   11868 /^state/d
   11869 /^Cleanup:/d
   11870 /^Error:/d
   11871 /^Next/d
   11872 /^Discarding/d
   11873 / \$[0-9$]* = /d
   11874 /^yydestructor:/d' stderr >at-stderr
   11875 mv at-stderr stderr
   11876 # 2. Create the reference error message.
   11877 cat >expout <<'_ATEOF'
   11878 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   11879 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   11880 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   11881 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   11882 calc: error: 4444 != 1
   11883 _ATEOF
   11884 
   11885 # 3. If locations are not used, remove them.
   11886 sed 's/^[-0-9.]*: //' expout >at-expout
   11887 mv at-expout expout
   11888 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11889 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11890 mv at-expout expout
   11891 # 5. Check
   11892 $at_traceoff
   11893 echo "calc.at:550: cat stderr"
   11894 echo calc.at:550 >$at_check_line_file
   11895 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11896 at_status=$?
   11897 grep '^ *+' $at_stder1 >&2
   11898 grep -v '^ *+' $at_stder1 >$at_stderr
   11899 at_failed=false
   11900 $at_diff $at_devnull $at_stderr || at_failed=:
   11901 $at_diff expout $at_stdout || at_failed=:
   11902 case $at_status in
   11903    77) echo 77 > $at_status_file
   11904             exit 77;;
   11905    0) ;;
   11906    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11907       at_failed=:;;
   11908 esac
   11909 if $at_failed; then
   11910 
   11911   echo 1 > $at_status_file
   11912   exit 1
   11913 fi
   11914 
   11915 $at_traceon
   11916 
   11917 
   11918 
   11919 # The same, but this time exercising explicitly triggered syntax errors.
   11920 # POSIX says the look-ahead causing the error should not be discarded.
   11921 cat >input <<'_ATEOF'
   11922 (!) + (0 0) = 1
   11923 _ATEOF
   11924 
   11925 $at_traceoff
   11926 echo "calc.at:550: \$PREPARSER ./calc input"
   11927 echo calc.at:550 >$at_check_line_file
   11928 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11929 at_status=$?
   11930 grep '^ *+' $at_stder1 >&2
   11931 grep -v '^ *+' $at_stder1 >$at_stderr
   11932 at_failed=false
   11933 echo stderr:; tee stderr <$at_stderr
   11934 $at_diff $at_devnull $at_stdout || at_failed=:
   11935 case $at_status in
   11936    77) echo 77 > $at_status_file
   11937             exit 77;;
   11938    0) ;;
   11939    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11940       at_failed=:;;
   11941 esac
   11942 if $at_failed; then
   11943 
   11944   echo 1 > $at_status_file
   11945   exit 1
   11946 fi
   11947 
   11948 $at_traceon
   11949 
   11950 
   11951 # Normalize the observed and expected error messages, depending upon the
   11952 # options.
   11953 # 1. Remove the traces from observed.
   11954 sed '/^Starting/d
   11955 /^Entering/d
   11956 /^Stack/d
   11957 /^Reading/d
   11958 /^Reducing/d
   11959 /^Shifting/d
   11960 /^state/d
   11961 /^Cleanup:/d
   11962 /^Error:/d
   11963 /^Next/d
   11964 /^Discarding/d
   11965 / \$[0-9$]* = /d
   11966 /^yydestructor:/d' stderr >at-stderr
   11967 mv at-stderr stderr
   11968 # 2. Create the reference error message.
   11969 cat >expout <<'_ATEOF'
   11970 1.9: syntax error, unexpected number
   11971 calc: error: 2222 != 1
   11972 _ATEOF
   11973 
   11974 # 3. If locations are not used, remove them.
   11975 sed 's/^[-0-9.]*: //' expout >at-expout
   11976 mv at-expout expout
   11977 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11978 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11979 mv at-expout expout
   11980 # 5. Check
   11981 $at_traceoff
   11982 echo "calc.at:550: cat stderr"
   11983 echo calc.at:550 >$at_check_line_file
   11984 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11985 at_status=$?
   11986 grep '^ *+' $at_stder1 >&2
   11987 grep -v '^ *+' $at_stder1 >$at_stderr
   11988 at_failed=false
   11989 $at_diff $at_devnull $at_stderr || at_failed=:
   11990 $at_diff expout $at_stdout || at_failed=:
   11991 case $at_status in
   11992    77) echo 77 > $at_status_file
   11993             exit 77;;
   11994    0) ;;
   11995    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11996       at_failed=:;;
   11997 esac
   11998 if $at_failed; then
   11999 
   12000   echo 1 > $at_status_file
   12001   exit 1
   12002 fi
   12003 
   12004 $at_traceon
   12005 
   12006 
   12007 cat >input <<'_ATEOF'
   12008 (- *) + (0 0) = 1
   12009 _ATEOF
   12010 
   12011 $at_traceoff
   12012 echo "calc.at:550: \$PREPARSER ./calc input"
   12013 echo calc.at:550 >$at_check_line_file
   12014 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12015 at_status=$?
   12016 grep '^ *+' $at_stder1 >&2
   12017 grep -v '^ *+' $at_stder1 >$at_stderr
   12018 at_failed=false
   12019 echo stderr:; tee stderr <$at_stderr
   12020 $at_diff $at_devnull $at_stdout || at_failed=:
   12021 case $at_status in
   12022    77) echo 77 > $at_status_file
   12023             exit 77;;
   12024    0) ;;
   12025    *) echo "calc.at:550: exit code was $at_status, expected 0"
   12026       at_failed=:;;
   12027 esac
   12028 if $at_failed; then
   12029 
   12030   echo 1 > $at_status_file
   12031   exit 1
   12032 fi
   12033 
   12034 $at_traceon
   12035 
   12036 
   12037 # Normalize the observed and expected error messages, depending upon the
   12038 # options.
   12039 # 1. Remove the traces from observed.
   12040 sed '/^Starting/d
   12041 /^Entering/d
   12042 /^Stack/d
   12043 /^Reading/d
   12044 /^Reducing/d
   12045 /^Shifting/d
   12046 /^state/d
   12047 /^Cleanup:/d
   12048 /^Error:/d
   12049 /^Next/d
   12050 /^Discarding/d
   12051 / \$[0-9$]* = /d
   12052 /^yydestructor:/d' stderr >at-stderr
   12053 mv at-stderr stderr
   12054 # 2. Create the reference error message.
   12055 cat >expout <<'_ATEOF'
   12056 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   12057 1.11: syntax error, unexpected number
   12058 calc: error: 2222 != 1
   12059 _ATEOF
   12060 
   12061 # 3. If locations are not used, remove them.
   12062 sed 's/^[-0-9.]*: //' expout >at-expout
   12063 mv at-expout expout
   12064 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12065 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12066 mv at-expout expout
   12067 # 5. Check
   12068 $at_traceoff
   12069 echo "calc.at:550: cat stderr"
   12070 echo calc.at:550 >$at_check_line_file
   12071 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12072 at_status=$?
   12073 grep '^ *+' $at_stder1 >&2
   12074 grep -v '^ *+' $at_stder1 >$at_stderr
   12075 at_failed=false
   12076 $at_diff $at_devnull $at_stderr || at_failed=:
   12077 $at_diff expout $at_stdout || at_failed=:
   12078 case $at_status in
   12079    77) echo 77 > $at_status_file
   12080             exit 77;;
   12081    0) ;;
   12082    *) echo "calc.at:550: exit code was $at_status, expected 0"
   12083       at_failed=:;;
   12084 esac
   12085 if $at_failed; then
   12086 
   12087   echo 1 > $at_status_file
   12088   exit 1
   12089 fi
   12090 
   12091 $at_traceon
   12092 
   12093 
   12094 
   12095 
   12096 
   12097 
   12098 
   12099 
   12100 
   12101 
   12102 
   12103 
   12104 
   12105 
   12106 
   12107 
   12108 
   12109 
   12110 
   12111 
   12112 
   12113 
   12114 
   12115 
   12116       $at_traceoff
   12117       $at_times_p && times >$at_times_file
   12118     ) 5>&1 2>&1 | eval $at_tee_pipe
   12119     at_status=`cat $at_status_file`
   12120     ;;
   12121 
   12122   71 ) # 71. calc.at:552: Calculator %defines
   12123     at_setup_line='calc.at:552'
   12124     at_desc='Calculator %defines'
   12125     $at_quiet $ECHO_N " 71: Calculator %defines                          $ECHO_C"
   12126     at_xfail=no
   12127     (
   12128       echo "71. calc.at:552: testing ..."
   12129       $at_traceon
   12130 
   12131 
   12132 
   12133 
   12134 
   12135 
   12136 
   12137 
   12138 # Using yacc.c?
   12139 
   12140 
   12141 
   12142 
   12143 
   12144 
   12145 
   12146 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   12147 
   12148 # yyerror always sees the locations (when activated), except if
   12149 # yacc & pure & !param.
   12150 
   12151 
   12152 # The interface is pure: either because %pure-parser, or because we
   12153 # are using the C++ parsers.
   12154 
   12155 
   12156 
   12157 
   12158 
   12159 
   12160 
   12161 
   12162 
   12163 
   12164 
   12165 
   12166 cat >calc.y <<'_ATEOF'
   12167 %{
   12168 #ifdef HAVE_CONFIG_H
   12169 # include <config.h>
   12170   /* We don't need perfect functions for these tests. */
   12171 # undef malloc
   12172 # undef memcmp
   12173 # undef realloc
   12174 #endif
   12175 %}
   12176 
   12177 /* Infix notation calculator--calc */
   12178 %defines
   12179 
   12180 %{
   12181 #include <stdio.h>
   12182 
   12183 #include <stdlib.h>
   12184 #include <string.h>
   12185 #if HAVE_UNISTD_H
   12186 # include <unistd.h>
   12187 #else
   12188 # undef alarm
   12189 # define alarm(seconds) /* empty */
   12190 #endif
   12191 #include <ctype.h>
   12192 #define USE(Var)
   12193 
   12194 /* Exercise pre-prologue dependency to %union.  */
   12195 typedef int semantic_value;
   12196 
   12197 static semantic_value global_result = 0;
   12198 static int global_count = 0;
   12199 %}
   12200 
   12201 /* Exercise %union. */
   12202 %union
   12203 {
   12204   semantic_value ival;
   12205 };
   12206 
   12207 %{
   12208 static int power (int base, int exponent);
   12209 /* yyerror receives the location if:
   12210    - %location & %pure & %glr
   12211    - %location & %pure & %yacc & %parse-param. */
   12212 static void yyerror (
   12213 
   12214                      const char *s
   12215                      );
   12216 static int yylex (void);
   12217 static int get_char (void);
   12218 static void unget_char ( int c);
   12219 %}
   12220 
   12221 
   12222 
   12223 /* Bison Declarations */
   12224 %token CALC_EOF 0 "end of input"
   12225 %token <ival> NUM "number"
   12226 %type  <ival> exp
   12227 
   12228 %nonassoc '=' /* comparison	       */
   12229 %left '-' '+'
   12230 %left '*' '/'
   12231 %left NEG     /* negation--unary minus */
   12232 %right '^'    /* exponentiation        */
   12233 
   12234 /* Grammar follows */
   12235 %%
   12236 input:
   12237   line
   12238 | input line         {  }
   12239 ;
   12240 
   12241 line:
   12242   '\n'
   12243 | exp '\n'           { USE ($1); }
   12244 ;
   12245 
   12246 exp:
   12247   NUM                { $$ = $1;             }
   12248 | exp '=' exp
   12249   {
   12250     if ($1 != $3)
   12251       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   12252     $$ = $1;
   12253   }
   12254 | exp '+' exp        { $$ = $1 + $3;        }
   12255 | exp '-' exp        { $$ = $1 - $3;        }
   12256 | exp '*' exp        { $$ = $1 * $3;        }
   12257 | exp '/' exp        { $$ = $1 / $3;        }
   12258 | '-' exp  %prec NEG { $$ = -$2;            }
   12259 | exp '^' exp        { $$ = power ($1, $3); }
   12260 | '(' exp ')'        { $$ = $2;             }
   12261 | '(' error ')'      { $$ = 1111;           }
   12262 | '!'                { $$ = 0; YYERROR;     }
   12263 | '-' error          { $$ = 0; YYERROR;     }
   12264 ;
   12265 %%
   12266 /* The input.  */
   12267 static FILE *input;
   12268 
   12269 static void
   12270 yyerror (
   12271 
   12272          const char *s)
   12273 {
   12274 
   12275 
   12276   fprintf (stderr, "%s\n", s);
   12277 }
   12278 
   12279 
   12280 
   12281 static int
   12282 get_char (void)
   12283 {
   12284   int res = getc (input);
   12285   ;
   12286 
   12287   return res;
   12288 }
   12289 
   12290 
   12291 static void
   12292 unget_char ( int c)
   12293 {
   12294   ;
   12295 
   12296   ungetc (c, input);
   12297 }
   12298 
   12299 static int
   12300 read_signed_integer (void)
   12301 {
   12302   int c = get_char ();
   12303   int sign = 1;
   12304   int n = 0;
   12305 
   12306   ;
   12307   if (c == '-')
   12308     {
   12309       c = get_char ();
   12310       sign = -1;
   12311     }
   12312 
   12313   while (isdigit (c))
   12314     {
   12315       n = 10 * n + (c - '0');
   12316       c = get_char ();
   12317     }
   12318 
   12319   unget_char ( c);
   12320 
   12321   return sign * n;
   12322 }
   12323 
   12324 
   12325 
   12326 /*---------------------------------------------------------------.
   12327 | Lexical analyzer returns an integer on the stack and the token |
   12328 | NUM, or the ASCII character read if not a number.  Skips all   |
   12329 | blanks and tabs, returns 0 for EOF.                            |
   12330 `---------------------------------------------------------------*/
   12331 
   12332 static int
   12333 yylex (void)
   12334 {
   12335   static int init = 1;
   12336   int c;
   12337 
   12338   if (init)
   12339     {
   12340       init = 0;
   12341 
   12342     }
   12343 
   12344 
   12345 
   12346   /* Skip white space.  */
   12347   while ((c = get_char ()) == ' ' || c == '\t')
   12348     {
   12349 
   12350     }
   12351 
   12352   /* process numbers   */
   12353   if (c == '.' || isdigit (c))
   12354     {
   12355       unget_char ( c);
   12356       (yylval).ival = read_signed_integer ();
   12357       return NUM;
   12358     }
   12359 
   12360   /* Return end-of-file.  */
   12361   if (c == EOF)
   12362     return CALC_EOF;
   12363 
   12364   /* Return single chars. */
   12365   return c;
   12366 }
   12367 
   12368 static int
   12369 power (int base, int exponent)
   12370 {
   12371   int res = 1;
   12372   if (exponent < 0)
   12373     exit (3);
   12374   for (/* Niente */; exponent; --exponent)
   12375     res *= base;
   12376   return res;
   12377 }
   12378 
   12379 
   12380 int
   12381 main (int argc, const char **argv)
   12382 {
   12383   semantic_value result = 0;
   12384   int count = 0;
   12385   int status;
   12386 
   12387   /* This used to be alarm (10), but that isn't enough time for
   12388      a July 1995 vintage DEC Alphastation 200 4/100 system,
   12389      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   12390   alarm (100);
   12391 
   12392   if (argc == 2)
   12393     input = fopen (argv[1], "r");
   12394   else
   12395     input = stdin;
   12396 
   12397   if (!input)
   12398     {
   12399       perror (argv[1]);
   12400       return 3;
   12401     }
   12402 
   12403 
   12404   status = yyparse ();
   12405   if (global_result != result)
   12406     abort ();
   12407   if (global_count != count)
   12408     abort ();
   12409   return status;
   12410 }
   12411 _ATEOF
   12412 
   12413 
   12414 
   12415 
   12416 
   12417 $at_traceoff
   12418 echo "calc.at:552: bison -o calc.c calc.y"
   12419 echo calc.at:552 >$at_check_line_file
   12420 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   12421 at_status=$?
   12422 grep '^ *+' $at_stder1 >&2
   12423 grep -v '^ *+' $at_stder1 >$at_stderr
   12424 at_failed=false
   12425 $at_diff $at_devnull $at_stderr || at_failed=:
   12426 $at_diff $at_devnull $at_stdout || at_failed=:
   12427 case $at_status in
   12428    77) echo 77 > $at_status_file
   12429             exit 77;;
   12430    0) ;;
   12431    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12432       at_failed=:;;
   12433 esac
   12434 if $at_failed; then
   12435 
   12436   echo 1 > $at_status_file
   12437   exit 1
   12438 fi
   12439 
   12440 $at_traceon
   12441 
   12442    $at_traceoff
   12443 echo "calc.at:552: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   12444 echo calc.at:552 >$at_check_line_file
   12445 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   12446 at_status=$?
   12447 grep '^ *+' $at_stder1 >&2
   12448 grep -v '^ *+' $at_stder1 >$at_stderr
   12449 at_failed=false
   12450 echo stderr:; cat $at_stderr
   12451 echo stdout:; cat $at_stdout
   12452 case $at_status in
   12453    77) echo 77 > $at_status_file
   12454             exit 77;;
   12455    0) ;;
   12456    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12457       at_failed=:;;
   12458 esac
   12459 if $at_failed; then
   12460 
   12461   echo 1 > $at_status_file
   12462   exit 1
   12463 fi
   12464 
   12465 $at_traceon
   12466 
   12467 
   12468 # Test the priorities.
   12469 cat >input <<'_ATEOF'
   12470 1 + 2 * 3 = 7
   12471 1 + 2 * -3 = -5
   12472 
   12473 -1^2 = -1
   12474 (-1)^2 = 1
   12475 
   12476 ---1 = -1
   12477 
   12478 1 - 2 - 3 = -4
   12479 1 - (2 - 3) = 2
   12480 
   12481 2^2^3 = 256
   12482 (2^2)^3 = 64
   12483 _ATEOF
   12484 
   12485 $at_traceoff
   12486 echo "calc.at:552: \$PREPARSER ./calc input"
   12487 echo calc.at:552 >$at_check_line_file
   12488 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12489 at_status=$?
   12490 grep '^ *+' $at_stder1 >&2
   12491 grep -v '^ *+' $at_stder1 >$at_stderr
   12492 at_failed=false
   12493 echo stderr:; tee stderr <$at_stderr
   12494 $at_diff $at_devnull $at_stdout || at_failed=:
   12495 case $at_status in
   12496    77) echo 77 > $at_status_file
   12497             exit 77;;
   12498    0) ;;
   12499    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12500       at_failed=:;;
   12501 esac
   12502 if $at_failed; then
   12503 
   12504   echo 1 > $at_status_file
   12505   exit 1
   12506 fi
   12507 
   12508 $at_traceon
   12509 
   12510 
   12511 
   12512 # Some syntax errors.
   12513 cat >input <<'_ATEOF'
   12514 0 0
   12515 _ATEOF
   12516 
   12517 $at_traceoff
   12518 echo "calc.at:552: \$PREPARSER ./calc input"
   12519 echo calc.at:552 >$at_check_line_file
   12520 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12521 at_status=$?
   12522 grep '^ *+' $at_stder1 >&2
   12523 grep -v '^ *+' $at_stder1 >$at_stderr
   12524 at_failed=false
   12525 echo stderr:; tee stderr <$at_stderr
   12526 $at_diff $at_devnull $at_stdout || at_failed=:
   12527 case $at_status in
   12528    77) echo 77 > $at_status_file
   12529             exit 77;;
   12530    1) ;;
   12531    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12532       at_failed=:;;
   12533 esac
   12534 if $at_failed; then
   12535 
   12536   echo 1 > $at_status_file
   12537   exit 1
   12538 fi
   12539 
   12540 $at_traceon
   12541 
   12542 
   12543 # Normalize the observed and expected error messages, depending upon the
   12544 # options.
   12545 # 1. Remove the traces from observed.
   12546 sed '/^Starting/d
   12547 /^Entering/d
   12548 /^Stack/d
   12549 /^Reading/d
   12550 /^Reducing/d
   12551 /^Shifting/d
   12552 /^state/d
   12553 /^Cleanup:/d
   12554 /^Error:/d
   12555 /^Next/d
   12556 /^Discarding/d
   12557 / \$[0-9$]* = /d
   12558 /^yydestructor:/d' stderr >at-stderr
   12559 mv at-stderr stderr
   12560 # 2. Create the reference error message.
   12561 cat >expout <<'_ATEOF'
   12562 1.2: syntax error, unexpected number
   12563 _ATEOF
   12564 
   12565 # 3. If locations are not used, remove them.
   12566 sed 's/^[-0-9.]*: //' expout >at-expout
   12567 mv at-expout expout
   12568 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12569 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12570 mv at-expout expout
   12571 # 5. Check
   12572 $at_traceoff
   12573 echo "calc.at:552: cat stderr"
   12574 echo calc.at:552 >$at_check_line_file
   12575 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12576 at_status=$?
   12577 grep '^ *+' $at_stder1 >&2
   12578 grep -v '^ *+' $at_stder1 >$at_stderr
   12579 at_failed=false
   12580 $at_diff $at_devnull $at_stderr || at_failed=:
   12581 $at_diff expout $at_stdout || at_failed=:
   12582 case $at_status in
   12583    77) echo 77 > $at_status_file
   12584             exit 77;;
   12585    0) ;;
   12586    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12587       at_failed=:;;
   12588 esac
   12589 if $at_failed; then
   12590 
   12591   echo 1 > $at_status_file
   12592   exit 1
   12593 fi
   12594 
   12595 $at_traceon
   12596 
   12597 
   12598 cat >input <<'_ATEOF'
   12599 1//2
   12600 _ATEOF
   12601 
   12602 $at_traceoff
   12603 echo "calc.at:552: \$PREPARSER ./calc input"
   12604 echo calc.at:552 >$at_check_line_file
   12605 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12606 at_status=$?
   12607 grep '^ *+' $at_stder1 >&2
   12608 grep -v '^ *+' $at_stder1 >$at_stderr
   12609 at_failed=false
   12610 echo stderr:; tee stderr <$at_stderr
   12611 $at_diff $at_devnull $at_stdout || at_failed=:
   12612 case $at_status in
   12613    77) echo 77 > $at_status_file
   12614             exit 77;;
   12615    1) ;;
   12616    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12617       at_failed=:;;
   12618 esac
   12619 if $at_failed; then
   12620 
   12621   echo 1 > $at_status_file
   12622   exit 1
   12623 fi
   12624 
   12625 $at_traceon
   12626 
   12627 
   12628 # Normalize the observed and expected error messages, depending upon the
   12629 # options.
   12630 # 1. Remove the traces from observed.
   12631 sed '/^Starting/d
   12632 /^Entering/d
   12633 /^Stack/d
   12634 /^Reading/d
   12635 /^Reducing/d
   12636 /^Shifting/d
   12637 /^state/d
   12638 /^Cleanup:/d
   12639 /^Error:/d
   12640 /^Next/d
   12641 /^Discarding/d
   12642 / \$[0-9$]* = /d
   12643 /^yydestructor:/d' stderr >at-stderr
   12644 mv at-stderr stderr
   12645 # 2. Create the reference error message.
   12646 cat >expout <<'_ATEOF'
   12647 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   12648 _ATEOF
   12649 
   12650 # 3. If locations are not used, remove them.
   12651 sed 's/^[-0-9.]*: //' expout >at-expout
   12652 mv at-expout expout
   12653 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12654 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12655 mv at-expout expout
   12656 # 5. Check
   12657 $at_traceoff
   12658 echo "calc.at:552: cat stderr"
   12659 echo calc.at:552 >$at_check_line_file
   12660 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12661 at_status=$?
   12662 grep '^ *+' $at_stder1 >&2
   12663 grep -v '^ *+' $at_stder1 >$at_stderr
   12664 at_failed=false
   12665 $at_diff $at_devnull $at_stderr || at_failed=:
   12666 $at_diff expout $at_stdout || at_failed=:
   12667 case $at_status in
   12668    77) echo 77 > $at_status_file
   12669             exit 77;;
   12670    0) ;;
   12671    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12672       at_failed=:;;
   12673 esac
   12674 if $at_failed; then
   12675 
   12676   echo 1 > $at_status_file
   12677   exit 1
   12678 fi
   12679 
   12680 $at_traceon
   12681 
   12682 
   12683 cat >input <<'_ATEOF'
   12684 error
   12685 _ATEOF
   12686 
   12687 $at_traceoff
   12688 echo "calc.at:552: \$PREPARSER ./calc input"
   12689 echo calc.at:552 >$at_check_line_file
   12690 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12691 at_status=$?
   12692 grep '^ *+' $at_stder1 >&2
   12693 grep -v '^ *+' $at_stder1 >$at_stderr
   12694 at_failed=false
   12695 echo stderr:; tee stderr <$at_stderr
   12696 $at_diff $at_devnull $at_stdout || at_failed=:
   12697 case $at_status in
   12698    77) echo 77 > $at_status_file
   12699             exit 77;;
   12700    1) ;;
   12701    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12702       at_failed=:;;
   12703 esac
   12704 if $at_failed; then
   12705 
   12706   echo 1 > $at_status_file
   12707   exit 1
   12708 fi
   12709 
   12710 $at_traceon
   12711 
   12712 
   12713 # Normalize the observed and expected error messages, depending upon the
   12714 # options.
   12715 # 1. Remove the traces from observed.
   12716 sed '/^Starting/d
   12717 /^Entering/d
   12718 /^Stack/d
   12719 /^Reading/d
   12720 /^Reducing/d
   12721 /^Shifting/d
   12722 /^state/d
   12723 /^Cleanup:/d
   12724 /^Error:/d
   12725 /^Next/d
   12726 /^Discarding/d
   12727 / \$[0-9$]* = /d
   12728 /^yydestructor:/d' stderr >at-stderr
   12729 mv at-stderr stderr
   12730 # 2. Create the reference error message.
   12731 cat >expout <<'_ATEOF'
   12732 1.0: syntax error, unexpected $undefined
   12733 _ATEOF
   12734 
   12735 # 3. If locations are not used, remove them.
   12736 sed 's/^[-0-9.]*: //' expout >at-expout
   12737 mv at-expout expout
   12738 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12739 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12740 mv at-expout expout
   12741 # 5. Check
   12742 $at_traceoff
   12743 echo "calc.at:552: cat stderr"
   12744 echo calc.at:552 >$at_check_line_file
   12745 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12746 at_status=$?
   12747 grep '^ *+' $at_stder1 >&2
   12748 grep -v '^ *+' $at_stder1 >$at_stderr
   12749 at_failed=false
   12750 $at_diff $at_devnull $at_stderr || at_failed=:
   12751 $at_diff expout $at_stdout || at_failed=:
   12752 case $at_status in
   12753    77) echo 77 > $at_status_file
   12754             exit 77;;
   12755    0) ;;
   12756    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12757       at_failed=:;;
   12758 esac
   12759 if $at_failed; then
   12760 
   12761   echo 1 > $at_status_file
   12762   exit 1
   12763 fi
   12764 
   12765 $at_traceon
   12766 
   12767 
   12768 cat >input <<'_ATEOF'
   12769 1 = 2 = 3
   12770 _ATEOF
   12771 
   12772 $at_traceoff
   12773 echo "calc.at:552: \$PREPARSER ./calc input"
   12774 echo calc.at:552 >$at_check_line_file
   12775 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12776 at_status=$?
   12777 grep '^ *+' $at_stder1 >&2
   12778 grep -v '^ *+' $at_stder1 >$at_stderr
   12779 at_failed=false
   12780 echo stderr:; tee stderr <$at_stderr
   12781 $at_diff $at_devnull $at_stdout || at_failed=:
   12782 case $at_status in
   12783    77) echo 77 > $at_status_file
   12784             exit 77;;
   12785    1) ;;
   12786    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12787       at_failed=:;;
   12788 esac
   12789 if $at_failed; then
   12790 
   12791   echo 1 > $at_status_file
   12792   exit 1
   12793 fi
   12794 
   12795 $at_traceon
   12796 
   12797 
   12798 # Normalize the observed and expected error messages, depending upon the
   12799 # options.
   12800 # 1. Remove the traces from observed.
   12801 sed '/^Starting/d
   12802 /^Entering/d
   12803 /^Stack/d
   12804 /^Reading/d
   12805 /^Reducing/d
   12806 /^Shifting/d
   12807 /^state/d
   12808 /^Cleanup:/d
   12809 /^Error:/d
   12810 /^Next/d
   12811 /^Discarding/d
   12812 / \$[0-9$]* = /d
   12813 /^yydestructor:/d' stderr >at-stderr
   12814 mv at-stderr stderr
   12815 # 2. Create the reference error message.
   12816 cat >expout <<'_ATEOF'
   12817 1.6: syntax error, unexpected '='
   12818 _ATEOF
   12819 
   12820 # 3. If locations are not used, remove them.
   12821 sed 's/^[-0-9.]*: //' expout >at-expout
   12822 mv at-expout expout
   12823 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12824 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12825 mv at-expout expout
   12826 # 5. Check
   12827 $at_traceoff
   12828 echo "calc.at:552: cat stderr"
   12829 echo calc.at:552 >$at_check_line_file
   12830 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12831 at_status=$?
   12832 grep '^ *+' $at_stder1 >&2
   12833 grep -v '^ *+' $at_stder1 >$at_stderr
   12834 at_failed=false
   12835 $at_diff $at_devnull $at_stderr || at_failed=:
   12836 $at_diff expout $at_stdout || at_failed=:
   12837 case $at_status in
   12838    77) echo 77 > $at_status_file
   12839             exit 77;;
   12840    0) ;;
   12841    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12842       at_failed=:;;
   12843 esac
   12844 if $at_failed; then
   12845 
   12846   echo 1 > $at_status_file
   12847   exit 1
   12848 fi
   12849 
   12850 $at_traceon
   12851 
   12852 
   12853 cat >input <<'_ATEOF'
   12854 
   12855 +1
   12856 _ATEOF
   12857 
   12858 $at_traceoff
   12859 echo "calc.at:552: \$PREPARSER ./calc input"
   12860 echo calc.at:552 >$at_check_line_file
   12861 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12862 at_status=$?
   12863 grep '^ *+' $at_stder1 >&2
   12864 grep -v '^ *+' $at_stder1 >$at_stderr
   12865 at_failed=false
   12866 echo stderr:; tee stderr <$at_stderr
   12867 $at_diff $at_devnull $at_stdout || at_failed=:
   12868 case $at_status in
   12869    77) echo 77 > $at_status_file
   12870             exit 77;;
   12871    1) ;;
   12872    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12873       at_failed=:;;
   12874 esac
   12875 if $at_failed; then
   12876 
   12877   echo 1 > $at_status_file
   12878   exit 1
   12879 fi
   12880 
   12881 $at_traceon
   12882 
   12883 
   12884 # Normalize the observed and expected error messages, depending upon the
   12885 # options.
   12886 # 1. Remove the traces from observed.
   12887 sed '/^Starting/d
   12888 /^Entering/d
   12889 /^Stack/d
   12890 /^Reading/d
   12891 /^Reducing/d
   12892 /^Shifting/d
   12893 /^state/d
   12894 /^Cleanup:/d
   12895 /^Error:/d
   12896 /^Next/d
   12897 /^Discarding/d
   12898 / \$[0-9$]* = /d
   12899 /^yydestructor:/d' stderr >at-stderr
   12900 mv at-stderr stderr
   12901 # 2. Create the reference error message.
   12902 cat >expout <<'_ATEOF'
   12903 2.0: syntax error, unexpected '+'
   12904 _ATEOF
   12905 
   12906 # 3. If locations are not used, remove them.
   12907 sed 's/^[-0-9.]*: //' expout >at-expout
   12908 mv at-expout expout
   12909 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12910 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12911 mv at-expout expout
   12912 # 5. Check
   12913 $at_traceoff
   12914 echo "calc.at:552: cat stderr"
   12915 echo calc.at:552 >$at_check_line_file
   12916 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12917 at_status=$?
   12918 grep '^ *+' $at_stder1 >&2
   12919 grep -v '^ *+' $at_stder1 >$at_stderr
   12920 at_failed=false
   12921 $at_diff $at_devnull $at_stderr || at_failed=:
   12922 $at_diff expout $at_stdout || at_failed=:
   12923 case $at_status in
   12924    77) echo 77 > $at_status_file
   12925             exit 77;;
   12926    0) ;;
   12927    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12928       at_failed=:;;
   12929 esac
   12930 if $at_failed; then
   12931 
   12932   echo 1 > $at_status_file
   12933   exit 1
   12934 fi
   12935 
   12936 $at_traceon
   12937 
   12938 
   12939 # Exercise error messages with EOF: work on an empty file.
   12940 $at_traceoff
   12941 echo "calc.at:552: \$PREPARSER ./calc /dev/null"
   12942 echo calc.at:552 >$at_check_line_file
   12943 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   12944 at_status=$?
   12945 grep '^ *+' $at_stder1 >&2
   12946 grep -v '^ *+' $at_stder1 >$at_stderr
   12947 at_failed=false
   12948 echo stderr:; tee stderr <$at_stderr
   12949 $at_diff $at_devnull $at_stdout || at_failed=:
   12950 case $at_status in
   12951    77) echo 77 > $at_status_file
   12952             exit 77;;
   12953    1) ;;
   12954    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12955       at_failed=:;;
   12956 esac
   12957 if $at_failed; then
   12958 
   12959   echo 1 > $at_status_file
   12960   exit 1
   12961 fi
   12962 
   12963 $at_traceon
   12964 
   12965 
   12966 # Normalize the observed and expected error messages, depending upon the
   12967 # options.
   12968 # 1. Remove the traces from observed.
   12969 sed '/^Starting/d
   12970 /^Entering/d
   12971 /^Stack/d
   12972 /^Reading/d
   12973 /^Reducing/d
   12974 /^Shifting/d
   12975 /^state/d
   12976 /^Cleanup:/d
   12977 /^Error:/d
   12978 /^Next/d
   12979 /^Discarding/d
   12980 / \$[0-9$]* = /d
   12981 /^yydestructor:/d' stderr >at-stderr
   12982 mv at-stderr stderr
   12983 # 2. Create the reference error message.
   12984 cat >expout <<'_ATEOF'
   12985 1.0: syntax error, unexpected end of input
   12986 _ATEOF
   12987 
   12988 # 3. If locations are not used, remove them.
   12989 sed 's/^[-0-9.]*: //' expout >at-expout
   12990 mv at-expout expout
   12991 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12992 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12993 mv at-expout expout
   12994 # 5. Check
   12995 $at_traceoff
   12996 echo "calc.at:552: cat stderr"
   12997 echo calc.at:552 >$at_check_line_file
   12998 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12999 at_status=$?
   13000 grep '^ *+' $at_stder1 >&2
   13001 grep -v '^ *+' $at_stder1 >$at_stderr
   13002 at_failed=false
   13003 $at_diff $at_devnull $at_stderr || at_failed=:
   13004 $at_diff expout $at_stdout || at_failed=:
   13005 case $at_status in
   13006    77) echo 77 > $at_status_file
   13007             exit 77;;
   13008    0) ;;
   13009    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13010       at_failed=:;;
   13011 esac
   13012 if $at_failed; then
   13013 
   13014   echo 1 > $at_status_file
   13015   exit 1
   13016 fi
   13017 
   13018 $at_traceon
   13019 
   13020 
   13021 
   13022 # Exercise the error token: without it, we die at the first error,
   13023 # hence be sure to
   13024 #
   13025 # - have several errors which exercise different shift/discardings
   13026 #   - (): nothing to pop, nothing to discard
   13027 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   13028 #   - (* * *): nothing to pop, a lot to discard
   13029 #   - (1 + 2 * *): some to pop and discard
   13030 #
   13031 # - test the action associated to `error'
   13032 #
   13033 # - check the look-ahead that triggers an error is not discarded
   13034 #   when we enter error recovery.  Below, the look-ahead causing the
   13035 #   first error is ")", which is needed to recover from the error and
   13036 #   produce the "0" that triggers the "0 != 1" error.
   13037 #
   13038 cat >input <<'_ATEOF'
   13039 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   13040 _ATEOF
   13041 
   13042 $at_traceoff
   13043 echo "calc.at:552: \$PREPARSER ./calc input"
   13044 echo calc.at:552 >$at_check_line_file
   13045 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13046 at_status=$?
   13047 grep '^ *+' $at_stder1 >&2
   13048 grep -v '^ *+' $at_stder1 >$at_stderr
   13049 at_failed=false
   13050 echo stderr:; tee stderr <$at_stderr
   13051 $at_diff $at_devnull $at_stdout || at_failed=:
   13052 case $at_status in
   13053    77) echo 77 > $at_status_file
   13054             exit 77;;
   13055    0) ;;
   13056    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13057       at_failed=:;;
   13058 esac
   13059 if $at_failed; then
   13060 
   13061   echo 1 > $at_status_file
   13062   exit 1
   13063 fi
   13064 
   13065 $at_traceon
   13066 
   13067 
   13068 # Normalize the observed and expected error messages, depending upon the
   13069 # options.
   13070 # 1. Remove the traces from observed.
   13071 sed '/^Starting/d
   13072 /^Entering/d
   13073 /^Stack/d
   13074 /^Reading/d
   13075 /^Reducing/d
   13076 /^Shifting/d
   13077 /^state/d
   13078 /^Cleanup:/d
   13079 /^Error:/d
   13080 /^Next/d
   13081 /^Discarding/d
   13082 / \$[0-9$]* = /d
   13083 /^yydestructor:/d' stderr >at-stderr
   13084 mv at-stderr stderr
   13085 # 2. Create the reference error message.
   13086 cat >expout <<'_ATEOF'
   13087 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   13088 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   13089 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   13090 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   13091 calc: error: 4444 != 1
   13092 _ATEOF
   13093 
   13094 # 3. If locations are not used, remove them.
   13095 sed 's/^[-0-9.]*: //' expout >at-expout
   13096 mv at-expout expout
   13097 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13098 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13099 mv at-expout expout
   13100 # 5. Check
   13101 $at_traceoff
   13102 echo "calc.at:552: cat stderr"
   13103 echo calc.at:552 >$at_check_line_file
   13104 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13105 at_status=$?
   13106 grep '^ *+' $at_stder1 >&2
   13107 grep -v '^ *+' $at_stder1 >$at_stderr
   13108 at_failed=false
   13109 $at_diff $at_devnull $at_stderr || at_failed=:
   13110 $at_diff expout $at_stdout || at_failed=:
   13111 case $at_status in
   13112    77) echo 77 > $at_status_file
   13113             exit 77;;
   13114    0) ;;
   13115    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13116       at_failed=:;;
   13117 esac
   13118 if $at_failed; then
   13119 
   13120   echo 1 > $at_status_file
   13121   exit 1
   13122 fi
   13123 
   13124 $at_traceon
   13125 
   13126 
   13127 
   13128 # The same, but this time exercising explicitly triggered syntax errors.
   13129 # POSIX says the look-ahead causing the error should not be discarded.
   13130 cat >input <<'_ATEOF'
   13131 (!) + (0 0) = 1
   13132 _ATEOF
   13133 
   13134 $at_traceoff
   13135 echo "calc.at:552: \$PREPARSER ./calc input"
   13136 echo calc.at:552 >$at_check_line_file
   13137 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13138 at_status=$?
   13139 grep '^ *+' $at_stder1 >&2
   13140 grep -v '^ *+' $at_stder1 >$at_stderr
   13141 at_failed=false
   13142 echo stderr:; tee stderr <$at_stderr
   13143 $at_diff $at_devnull $at_stdout || at_failed=:
   13144 case $at_status in
   13145    77) echo 77 > $at_status_file
   13146             exit 77;;
   13147    0) ;;
   13148    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13149       at_failed=:;;
   13150 esac
   13151 if $at_failed; then
   13152 
   13153   echo 1 > $at_status_file
   13154   exit 1
   13155 fi
   13156 
   13157 $at_traceon
   13158 
   13159 
   13160 # Normalize the observed and expected error messages, depending upon the
   13161 # options.
   13162 # 1. Remove the traces from observed.
   13163 sed '/^Starting/d
   13164 /^Entering/d
   13165 /^Stack/d
   13166 /^Reading/d
   13167 /^Reducing/d
   13168 /^Shifting/d
   13169 /^state/d
   13170 /^Cleanup:/d
   13171 /^Error:/d
   13172 /^Next/d
   13173 /^Discarding/d
   13174 / \$[0-9$]* = /d
   13175 /^yydestructor:/d' stderr >at-stderr
   13176 mv at-stderr stderr
   13177 # 2. Create the reference error message.
   13178 cat >expout <<'_ATEOF'
   13179 1.9: syntax error, unexpected number
   13180 calc: error: 2222 != 1
   13181 _ATEOF
   13182 
   13183 # 3. If locations are not used, remove them.
   13184 sed 's/^[-0-9.]*: //' expout >at-expout
   13185 mv at-expout expout
   13186 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13187 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13188 mv at-expout expout
   13189 # 5. Check
   13190 $at_traceoff
   13191 echo "calc.at:552: cat stderr"
   13192 echo calc.at:552 >$at_check_line_file
   13193 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13194 at_status=$?
   13195 grep '^ *+' $at_stder1 >&2
   13196 grep -v '^ *+' $at_stder1 >$at_stderr
   13197 at_failed=false
   13198 $at_diff $at_devnull $at_stderr || at_failed=:
   13199 $at_diff expout $at_stdout || at_failed=:
   13200 case $at_status in
   13201    77) echo 77 > $at_status_file
   13202             exit 77;;
   13203    0) ;;
   13204    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13205       at_failed=:;;
   13206 esac
   13207 if $at_failed; then
   13208 
   13209   echo 1 > $at_status_file
   13210   exit 1
   13211 fi
   13212 
   13213 $at_traceon
   13214 
   13215 
   13216 cat >input <<'_ATEOF'
   13217 (- *) + (0 0) = 1
   13218 _ATEOF
   13219 
   13220 $at_traceoff
   13221 echo "calc.at:552: \$PREPARSER ./calc input"
   13222 echo calc.at:552 >$at_check_line_file
   13223 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13224 at_status=$?
   13225 grep '^ *+' $at_stder1 >&2
   13226 grep -v '^ *+' $at_stder1 >$at_stderr
   13227 at_failed=false
   13228 echo stderr:; tee stderr <$at_stderr
   13229 $at_diff $at_devnull $at_stdout || at_failed=:
   13230 case $at_status in
   13231    77) echo 77 > $at_status_file
   13232             exit 77;;
   13233    0) ;;
   13234    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13235       at_failed=:;;
   13236 esac
   13237 if $at_failed; then
   13238 
   13239   echo 1 > $at_status_file
   13240   exit 1
   13241 fi
   13242 
   13243 $at_traceon
   13244 
   13245 
   13246 # Normalize the observed and expected error messages, depending upon the
   13247 # options.
   13248 # 1. Remove the traces from observed.
   13249 sed '/^Starting/d
   13250 /^Entering/d
   13251 /^Stack/d
   13252 /^Reading/d
   13253 /^Reducing/d
   13254 /^Shifting/d
   13255 /^state/d
   13256 /^Cleanup:/d
   13257 /^Error:/d
   13258 /^Next/d
   13259 /^Discarding/d
   13260 / \$[0-9$]* = /d
   13261 /^yydestructor:/d' stderr >at-stderr
   13262 mv at-stderr stderr
   13263 # 2. Create the reference error message.
   13264 cat >expout <<'_ATEOF'
   13265 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   13266 1.11: syntax error, unexpected number
   13267 calc: error: 2222 != 1
   13268 _ATEOF
   13269 
   13270 # 3. If locations are not used, remove them.
   13271 sed 's/^[-0-9.]*: //' expout >at-expout
   13272 mv at-expout expout
   13273 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13274 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13275 mv at-expout expout
   13276 # 5. Check
   13277 $at_traceoff
   13278 echo "calc.at:552: cat stderr"
   13279 echo calc.at:552 >$at_check_line_file
   13280 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13281 at_status=$?
   13282 grep '^ *+' $at_stder1 >&2
   13283 grep -v '^ *+' $at_stder1 >$at_stderr
   13284 at_failed=false
   13285 $at_diff $at_devnull $at_stderr || at_failed=:
   13286 $at_diff expout $at_stdout || at_failed=:
   13287 case $at_status in
   13288    77) echo 77 > $at_status_file
   13289             exit 77;;
   13290    0) ;;
   13291    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13292       at_failed=:;;
   13293 esac
   13294 if $at_failed; then
   13295 
   13296   echo 1 > $at_status_file
   13297   exit 1
   13298 fi
   13299 
   13300 $at_traceon
   13301 
   13302 
   13303 
   13304 
   13305 
   13306 
   13307 
   13308 
   13309 
   13310 
   13311 
   13312 
   13313 
   13314 
   13315 
   13316 
   13317 
   13318 
   13319 
   13320 
   13321 
   13322 
   13323 
   13324 
   13325       $at_traceoff
   13326       $at_times_p && times >$at_times_file
   13327     ) 5>&1 2>&1 | eval $at_tee_pipe
   13328     at_status=`cat $at_status_file`
   13329     ;;
   13330 
   13331   72 ) # 72. calc.at:553: Calculator %locations
   13332     at_setup_line='calc.at:553'
   13333     at_desc='Calculator %locations'
   13334     $at_quiet $ECHO_N " 72: Calculator %locations                        $ECHO_C"
   13335     at_xfail=no
   13336     (
   13337       echo "72. calc.at:553: testing ..."
   13338       $at_traceon
   13339 
   13340 
   13341 
   13342 
   13343 
   13344 
   13345 
   13346 
   13347 # Using yacc.c?
   13348 
   13349 
   13350 
   13351 
   13352 
   13353 
   13354 
   13355 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   13356 
   13357 # yyerror always sees the locations (when activated), except if
   13358 # yacc & pure & !param.
   13359 
   13360 
   13361 # The interface is pure: either because %pure-parser, or because we
   13362 # are using the C++ parsers.
   13363 
   13364 
   13365 
   13366 
   13367 
   13368 
   13369 
   13370 
   13371 
   13372 
   13373 
   13374 
   13375 cat >calc.y <<'_ATEOF'
   13376 %{
   13377 #ifdef HAVE_CONFIG_H
   13378 # include <config.h>
   13379   /* We don't need perfect functions for these tests. */
   13380 # undef malloc
   13381 # undef memcmp
   13382 # undef realloc
   13383 #endif
   13384 %}
   13385 
   13386 /* Infix notation calculator--calc */
   13387 %locations
   13388 
   13389 %{
   13390 #include <stdio.h>
   13391 
   13392 #include <stdlib.h>
   13393 #include <string.h>
   13394 #if HAVE_UNISTD_H
   13395 # include <unistd.h>
   13396 #else
   13397 # undef alarm
   13398 # define alarm(seconds) /* empty */
   13399 #endif
   13400 #include <ctype.h>
   13401 #define USE(Var)
   13402 
   13403 /* Exercise pre-prologue dependency to %union.  */
   13404 typedef int semantic_value;
   13405 
   13406 static semantic_value global_result = 0;
   13407 static int global_count = 0;
   13408 %}
   13409 
   13410 /* Exercise %union. */
   13411 %union
   13412 {
   13413   semantic_value ival;
   13414 };
   13415 
   13416 %{
   13417 static int power (int base, int exponent);
   13418 /* yyerror receives the location if:
   13419    - %location & %pure & %glr
   13420    - %location & %pure & %yacc & %parse-param. */
   13421 static void yyerror (
   13422 
   13423                      const char *s
   13424                      );
   13425 static int yylex (void);
   13426 static int get_char (void);
   13427 static void unget_char ( int c);
   13428 %}
   13429 
   13430 
   13431 
   13432 /* Bison Declarations */
   13433 %token CALC_EOF 0 "end of input"
   13434 %token <ival> NUM "number"
   13435 %type  <ival> exp
   13436 
   13437 %nonassoc '=' /* comparison	       */
   13438 %left '-' '+'
   13439 %left '*' '/'
   13440 %left NEG     /* negation--unary minus */
   13441 %right '^'    /* exponentiation        */
   13442 
   13443 /* Grammar follows */
   13444 %%
   13445 input:
   13446   line
   13447 | input line         {  }
   13448 ;
   13449 
   13450 line:
   13451   '\n'
   13452 | exp '\n'           { USE ($1); }
   13453 ;
   13454 
   13455 exp:
   13456   NUM                { $$ = $1;             }
   13457 | exp '=' exp
   13458   {
   13459     if ($1 != $3)
   13460       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   13461     $$ = $1;
   13462   }
   13463 | exp '+' exp        { $$ = $1 + $3;        }
   13464 | exp '-' exp        { $$ = $1 - $3;        }
   13465 | exp '*' exp        { $$ = $1 * $3;        }
   13466 | exp '/' exp        { $$ = $1 / $3;        }
   13467 | '-' exp  %prec NEG { $$ = -$2;            }
   13468 | exp '^' exp        { $$ = power ($1, $3); }
   13469 | '(' exp ')'        { $$ = $2;             }
   13470 | '(' error ')'      { $$ = 1111;           }
   13471 | '!'                { $$ = 0; YYERROR;     }
   13472 | '-' error          { $$ = 0; YYERROR;     }
   13473 ;
   13474 %%
   13475 /* The input.  */
   13476 static FILE *input;
   13477 
   13478 static void
   13479 yyerror (
   13480 
   13481          const char *s)
   13482 {
   13483 
   13484 
   13485   fprintf (stderr, "%d.%d",
   13486            (yylloc).first_line, (yylloc).first_column);
   13487   if ((yylloc).first_line != (yylloc).last_line)
   13488     fprintf (stderr, "-%d.%d",
   13489 	     (yylloc).last_line,  (yylloc).last_column - 1);
   13490   else if ((yylloc).first_column != (yylloc).last_column - 1)
   13491     fprintf (stderr, "-%d",
   13492 	     (yylloc).last_column - 1);
   13493   fprintf (stderr, ": ");
   13494   fprintf (stderr, "%s\n", s);
   13495 }
   13496 
   13497 
   13498 
   13499 static YYLTYPE last_yylloc;
   13500 
   13501 static int
   13502 get_char (void)
   13503 {
   13504   int res = getc (input);
   13505   ;
   13506 
   13507   last_yylloc = (yylloc);
   13508   if (res == '\n')
   13509     {
   13510       (yylloc).last_line++;
   13511       (yylloc).last_column = 0;
   13512     }
   13513   else
   13514     (yylloc).last_column++;
   13515 
   13516   return res;
   13517 }
   13518 
   13519 
   13520 static void
   13521 unget_char ( int c)
   13522 {
   13523   ;
   13524 
   13525   /* Wrong when C == `\n'. */
   13526   (yylloc) = last_yylloc;
   13527 
   13528   ungetc (c, input);
   13529 }
   13530 
   13531 static int
   13532 read_signed_integer (void)
   13533 {
   13534   int c = get_char ();
   13535   int sign = 1;
   13536   int n = 0;
   13537 
   13538   ;
   13539   if (c == '-')
   13540     {
   13541       c = get_char ();
   13542       sign = -1;
   13543     }
   13544 
   13545   while (isdigit (c))
   13546     {
   13547       n = 10 * n + (c - '0');
   13548       c = get_char ();
   13549     }
   13550 
   13551   unget_char ( c);
   13552 
   13553   return sign * n;
   13554 }
   13555 
   13556 
   13557 
   13558 /*---------------------------------------------------------------.
   13559 | Lexical analyzer returns an integer on the stack and the token |
   13560 | NUM, or the ASCII character read if not a number.  Skips all   |
   13561 | blanks and tabs, returns 0 for EOF.                            |
   13562 `---------------------------------------------------------------*/
   13563 
   13564 static int
   13565 yylex (void)
   13566 {
   13567   static int init = 1;
   13568   int c;
   13569 
   13570   if (init)
   13571     {
   13572       init = 0;
   13573 
   13574       (yylloc).last_column = 0;
   13575       (yylloc).last_line = 1;
   13576 
   13577     }
   13578 
   13579 
   13580  (yylloc).first_column = (yylloc).last_column;
   13581   (yylloc).first_line   = (yylloc).last_line;
   13582 
   13583 
   13584   /* Skip white space.  */
   13585   while ((c = get_char ()) == ' ' || c == '\t')
   13586     {
   13587      (yylloc).first_column = (yylloc).last_column;
   13588       (yylloc).first_line   = (yylloc).last_line;
   13589 
   13590     }
   13591 
   13592   /* process numbers   */
   13593   if (c == '.' || isdigit (c))
   13594     {
   13595       unget_char ( c);
   13596       (yylval).ival = read_signed_integer ();
   13597       return NUM;
   13598     }
   13599 
   13600   /* Return end-of-file.  */
   13601   if (c == EOF)
   13602     return CALC_EOF;
   13603 
   13604   /* Return single chars. */
   13605   return c;
   13606 }
   13607 
   13608 static int
   13609 power (int base, int exponent)
   13610 {
   13611   int res = 1;
   13612   if (exponent < 0)
   13613     exit (3);
   13614   for (/* Niente */; exponent; --exponent)
   13615     res *= base;
   13616   return res;
   13617 }
   13618 
   13619 
   13620 int
   13621 main (int argc, const char **argv)
   13622 {
   13623   semantic_value result = 0;
   13624   int count = 0;
   13625   int status;
   13626 
   13627   /* This used to be alarm (10), but that isn't enough time for
   13628      a July 1995 vintage DEC Alphastation 200 4/100 system,
   13629      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   13630   alarm (100);
   13631 
   13632   if (argc == 2)
   13633     input = fopen (argv[1], "r");
   13634   else
   13635     input = stdin;
   13636 
   13637   if (!input)
   13638     {
   13639       perror (argv[1]);
   13640       return 3;
   13641     }
   13642 
   13643 
   13644   status = yyparse ();
   13645   if (global_result != result)
   13646     abort ();
   13647   if (global_count != count)
   13648     abort ();
   13649   return status;
   13650 }
   13651 _ATEOF
   13652 
   13653 
   13654 
   13655 
   13656 
   13657 $at_traceoff
   13658 echo "calc.at:553: bison -o calc.c calc.y"
   13659 echo calc.at:553 >$at_check_line_file
   13660 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   13661 at_status=$?
   13662 grep '^ *+' $at_stder1 >&2
   13663 grep -v '^ *+' $at_stder1 >$at_stderr
   13664 at_failed=false
   13665 $at_diff $at_devnull $at_stderr || at_failed=:
   13666 $at_diff $at_devnull $at_stdout || at_failed=:
   13667 case $at_status in
   13668    77) echo 77 > $at_status_file
   13669             exit 77;;
   13670    0) ;;
   13671    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13672       at_failed=:;;
   13673 esac
   13674 if $at_failed; then
   13675 
   13676   echo 1 > $at_status_file
   13677   exit 1
   13678 fi
   13679 
   13680 $at_traceon
   13681 
   13682    $at_traceoff
   13683 echo "calc.at:553: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   13684 echo calc.at:553 >$at_check_line_file
   13685 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   13686 at_status=$?
   13687 grep '^ *+' $at_stder1 >&2
   13688 grep -v '^ *+' $at_stder1 >$at_stderr
   13689 at_failed=false
   13690 echo stderr:; cat $at_stderr
   13691 echo stdout:; cat $at_stdout
   13692 case $at_status in
   13693    77) echo 77 > $at_status_file
   13694             exit 77;;
   13695    0) ;;
   13696    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13697       at_failed=:;;
   13698 esac
   13699 if $at_failed; then
   13700 
   13701   echo 1 > $at_status_file
   13702   exit 1
   13703 fi
   13704 
   13705 $at_traceon
   13706 
   13707 
   13708 # Test the priorities.
   13709 cat >input <<'_ATEOF'
   13710 1 + 2 * 3 = 7
   13711 1 + 2 * -3 = -5
   13712 
   13713 -1^2 = -1
   13714 (-1)^2 = 1
   13715 
   13716 ---1 = -1
   13717 
   13718 1 - 2 - 3 = -4
   13719 1 - (2 - 3) = 2
   13720 
   13721 2^2^3 = 256
   13722 (2^2)^3 = 64
   13723 _ATEOF
   13724 
   13725 $at_traceoff
   13726 echo "calc.at:553: \$PREPARSER ./calc input"
   13727 echo calc.at:553 >$at_check_line_file
   13728 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13729 at_status=$?
   13730 grep '^ *+' $at_stder1 >&2
   13731 grep -v '^ *+' $at_stder1 >$at_stderr
   13732 at_failed=false
   13733 echo stderr:; tee stderr <$at_stderr
   13734 $at_diff $at_devnull $at_stdout || at_failed=:
   13735 case $at_status in
   13736    77) echo 77 > $at_status_file
   13737             exit 77;;
   13738    0) ;;
   13739    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13740       at_failed=:;;
   13741 esac
   13742 if $at_failed; then
   13743 
   13744   echo 1 > $at_status_file
   13745   exit 1
   13746 fi
   13747 
   13748 $at_traceon
   13749 
   13750 
   13751 
   13752 # Some syntax errors.
   13753 cat >input <<'_ATEOF'
   13754 0 0
   13755 _ATEOF
   13756 
   13757 $at_traceoff
   13758 echo "calc.at:553: \$PREPARSER ./calc input"
   13759 echo calc.at:553 >$at_check_line_file
   13760 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13761 at_status=$?
   13762 grep '^ *+' $at_stder1 >&2
   13763 grep -v '^ *+' $at_stder1 >$at_stderr
   13764 at_failed=false
   13765 echo stderr:; tee stderr <$at_stderr
   13766 $at_diff $at_devnull $at_stdout || at_failed=:
   13767 case $at_status in
   13768    77) echo 77 > $at_status_file
   13769             exit 77;;
   13770    1) ;;
   13771    *) echo "calc.at:553: exit code was $at_status, expected 1"
   13772       at_failed=:;;
   13773 esac
   13774 if $at_failed; then
   13775 
   13776   echo 1 > $at_status_file
   13777   exit 1
   13778 fi
   13779 
   13780 $at_traceon
   13781 
   13782 
   13783 # Normalize the observed and expected error messages, depending upon the
   13784 # options.
   13785 # 1. Remove the traces from observed.
   13786 sed '/^Starting/d
   13787 /^Entering/d
   13788 /^Stack/d
   13789 /^Reading/d
   13790 /^Reducing/d
   13791 /^Shifting/d
   13792 /^state/d
   13793 /^Cleanup:/d
   13794 /^Error:/d
   13795 /^Next/d
   13796 /^Discarding/d
   13797 / \$[0-9$]* = /d
   13798 /^yydestructor:/d' stderr >at-stderr
   13799 mv at-stderr stderr
   13800 # 2. Create the reference error message.
   13801 cat >expout <<'_ATEOF'
   13802 1.2: syntax error, unexpected number
   13803 _ATEOF
   13804 
   13805 # 3. If locations are not used, remove them.
   13806 
   13807 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13808 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13809 mv at-expout expout
   13810 # 5. Check
   13811 $at_traceoff
   13812 echo "calc.at:553: cat stderr"
   13813 echo calc.at:553 >$at_check_line_file
   13814 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13815 at_status=$?
   13816 grep '^ *+' $at_stder1 >&2
   13817 grep -v '^ *+' $at_stder1 >$at_stderr
   13818 at_failed=false
   13819 $at_diff $at_devnull $at_stderr || at_failed=:
   13820 $at_diff expout $at_stdout || at_failed=:
   13821 case $at_status in
   13822    77) echo 77 > $at_status_file
   13823             exit 77;;
   13824    0) ;;
   13825    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13826       at_failed=:;;
   13827 esac
   13828 if $at_failed; then
   13829 
   13830   echo 1 > $at_status_file
   13831   exit 1
   13832 fi
   13833 
   13834 $at_traceon
   13835 
   13836 
   13837 cat >input <<'_ATEOF'
   13838 1//2
   13839 _ATEOF
   13840 
   13841 $at_traceoff
   13842 echo "calc.at:553: \$PREPARSER ./calc input"
   13843 echo calc.at:553 >$at_check_line_file
   13844 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13845 at_status=$?
   13846 grep '^ *+' $at_stder1 >&2
   13847 grep -v '^ *+' $at_stder1 >$at_stderr
   13848 at_failed=false
   13849 echo stderr:; tee stderr <$at_stderr
   13850 $at_diff $at_devnull $at_stdout || at_failed=:
   13851 case $at_status in
   13852    77) echo 77 > $at_status_file
   13853             exit 77;;
   13854    1) ;;
   13855    *) echo "calc.at:553: exit code was $at_status, expected 1"
   13856       at_failed=:;;
   13857 esac
   13858 if $at_failed; then
   13859 
   13860   echo 1 > $at_status_file
   13861   exit 1
   13862 fi
   13863 
   13864 $at_traceon
   13865 
   13866 
   13867 # Normalize the observed and expected error messages, depending upon the
   13868 # options.
   13869 # 1. Remove the traces from observed.
   13870 sed '/^Starting/d
   13871 /^Entering/d
   13872 /^Stack/d
   13873 /^Reading/d
   13874 /^Reducing/d
   13875 /^Shifting/d
   13876 /^state/d
   13877 /^Cleanup:/d
   13878 /^Error:/d
   13879 /^Next/d
   13880 /^Discarding/d
   13881 / \$[0-9$]* = /d
   13882 /^yydestructor:/d' stderr >at-stderr
   13883 mv at-stderr stderr
   13884 # 2. Create the reference error message.
   13885 cat >expout <<'_ATEOF'
   13886 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   13887 _ATEOF
   13888 
   13889 # 3. If locations are not used, remove them.
   13890 
   13891 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13892 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13893 mv at-expout expout
   13894 # 5. Check
   13895 $at_traceoff
   13896 echo "calc.at:553: cat stderr"
   13897 echo calc.at:553 >$at_check_line_file
   13898 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13899 at_status=$?
   13900 grep '^ *+' $at_stder1 >&2
   13901 grep -v '^ *+' $at_stder1 >$at_stderr
   13902 at_failed=false
   13903 $at_diff $at_devnull $at_stderr || at_failed=:
   13904 $at_diff expout $at_stdout || at_failed=:
   13905 case $at_status in
   13906    77) echo 77 > $at_status_file
   13907             exit 77;;
   13908    0) ;;
   13909    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13910       at_failed=:;;
   13911 esac
   13912 if $at_failed; then
   13913 
   13914   echo 1 > $at_status_file
   13915   exit 1
   13916 fi
   13917 
   13918 $at_traceon
   13919 
   13920 
   13921 cat >input <<'_ATEOF'
   13922 error
   13923 _ATEOF
   13924 
   13925 $at_traceoff
   13926 echo "calc.at:553: \$PREPARSER ./calc input"
   13927 echo calc.at:553 >$at_check_line_file
   13928 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13929 at_status=$?
   13930 grep '^ *+' $at_stder1 >&2
   13931 grep -v '^ *+' $at_stder1 >$at_stderr
   13932 at_failed=false
   13933 echo stderr:; tee stderr <$at_stderr
   13934 $at_diff $at_devnull $at_stdout || at_failed=:
   13935 case $at_status in
   13936    77) echo 77 > $at_status_file
   13937             exit 77;;
   13938    1) ;;
   13939    *) echo "calc.at:553: exit code was $at_status, expected 1"
   13940       at_failed=:;;
   13941 esac
   13942 if $at_failed; then
   13943 
   13944   echo 1 > $at_status_file
   13945   exit 1
   13946 fi
   13947 
   13948 $at_traceon
   13949 
   13950 
   13951 # Normalize the observed and expected error messages, depending upon the
   13952 # options.
   13953 # 1. Remove the traces from observed.
   13954 sed '/^Starting/d
   13955 /^Entering/d
   13956 /^Stack/d
   13957 /^Reading/d
   13958 /^Reducing/d
   13959 /^Shifting/d
   13960 /^state/d
   13961 /^Cleanup:/d
   13962 /^Error:/d
   13963 /^Next/d
   13964 /^Discarding/d
   13965 / \$[0-9$]* = /d
   13966 /^yydestructor:/d' stderr >at-stderr
   13967 mv at-stderr stderr
   13968 # 2. Create the reference error message.
   13969 cat >expout <<'_ATEOF'
   13970 1.0: syntax error, unexpected $undefined
   13971 _ATEOF
   13972 
   13973 # 3. If locations are not used, remove them.
   13974 
   13975 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13976 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13977 mv at-expout expout
   13978 # 5. Check
   13979 $at_traceoff
   13980 echo "calc.at:553: cat stderr"
   13981 echo calc.at:553 >$at_check_line_file
   13982 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13983 at_status=$?
   13984 grep '^ *+' $at_stder1 >&2
   13985 grep -v '^ *+' $at_stder1 >$at_stderr
   13986 at_failed=false
   13987 $at_diff $at_devnull $at_stderr || at_failed=:
   13988 $at_diff expout $at_stdout || at_failed=:
   13989 case $at_status in
   13990    77) echo 77 > $at_status_file
   13991             exit 77;;
   13992    0) ;;
   13993    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13994       at_failed=:;;
   13995 esac
   13996 if $at_failed; then
   13997 
   13998   echo 1 > $at_status_file
   13999   exit 1
   14000 fi
   14001 
   14002 $at_traceon
   14003 
   14004 
   14005 cat >input <<'_ATEOF'
   14006 1 = 2 = 3
   14007 _ATEOF
   14008 
   14009 $at_traceoff
   14010 echo "calc.at:553: \$PREPARSER ./calc input"
   14011 echo calc.at:553 >$at_check_line_file
   14012 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14013 at_status=$?
   14014 grep '^ *+' $at_stder1 >&2
   14015 grep -v '^ *+' $at_stder1 >$at_stderr
   14016 at_failed=false
   14017 echo stderr:; tee stderr <$at_stderr
   14018 $at_diff $at_devnull $at_stdout || at_failed=:
   14019 case $at_status in
   14020    77) echo 77 > $at_status_file
   14021             exit 77;;
   14022    1) ;;
   14023    *) echo "calc.at:553: exit code was $at_status, expected 1"
   14024       at_failed=:;;
   14025 esac
   14026 if $at_failed; then
   14027 
   14028   echo 1 > $at_status_file
   14029   exit 1
   14030 fi
   14031 
   14032 $at_traceon
   14033 
   14034 
   14035 # Normalize the observed and expected error messages, depending upon the
   14036 # options.
   14037 # 1. Remove the traces from observed.
   14038 sed '/^Starting/d
   14039 /^Entering/d
   14040 /^Stack/d
   14041 /^Reading/d
   14042 /^Reducing/d
   14043 /^Shifting/d
   14044 /^state/d
   14045 /^Cleanup:/d
   14046 /^Error:/d
   14047 /^Next/d
   14048 /^Discarding/d
   14049 / \$[0-9$]* = /d
   14050 /^yydestructor:/d' stderr >at-stderr
   14051 mv at-stderr stderr
   14052 # 2. Create the reference error message.
   14053 cat >expout <<'_ATEOF'
   14054 1.6: syntax error, unexpected '='
   14055 _ATEOF
   14056 
   14057 # 3. If locations are not used, remove them.
   14058 
   14059 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14060 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14061 mv at-expout expout
   14062 # 5. Check
   14063 $at_traceoff
   14064 echo "calc.at:553: cat stderr"
   14065 echo calc.at:553 >$at_check_line_file
   14066 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14067 at_status=$?
   14068 grep '^ *+' $at_stder1 >&2
   14069 grep -v '^ *+' $at_stder1 >$at_stderr
   14070 at_failed=false
   14071 $at_diff $at_devnull $at_stderr || at_failed=:
   14072 $at_diff expout $at_stdout || at_failed=:
   14073 case $at_status in
   14074    77) echo 77 > $at_status_file
   14075             exit 77;;
   14076    0) ;;
   14077    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14078       at_failed=:;;
   14079 esac
   14080 if $at_failed; then
   14081 
   14082   echo 1 > $at_status_file
   14083   exit 1
   14084 fi
   14085 
   14086 $at_traceon
   14087 
   14088 
   14089 cat >input <<'_ATEOF'
   14090 
   14091 +1
   14092 _ATEOF
   14093 
   14094 $at_traceoff
   14095 echo "calc.at:553: \$PREPARSER ./calc input"
   14096 echo calc.at:553 >$at_check_line_file
   14097 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14098 at_status=$?
   14099 grep '^ *+' $at_stder1 >&2
   14100 grep -v '^ *+' $at_stder1 >$at_stderr
   14101 at_failed=false
   14102 echo stderr:; tee stderr <$at_stderr
   14103 $at_diff $at_devnull $at_stdout || at_failed=:
   14104 case $at_status in
   14105    77) echo 77 > $at_status_file
   14106             exit 77;;
   14107    1) ;;
   14108    *) echo "calc.at:553: exit code was $at_status, expected 1"
   14109       at_failed=:;;
   14110 esac
   14111 if $at_failed; then
   14112 
   14113   echo 1 > $at_status_file
   14114   exit 1
   14115 fi
   14116 
   14117 $at_traceon
   14118 
   14119 
   14120 # Normalize the observed and expected error messages, depending upon the
   14121 # options.
   14122 # 1. Remove the traces from observed.
   14123 sed '/^Starting/d
   14124 /^Entering/d
   14125 /^Stack/d
   14126 /^Reading/d
   14127 /^Reducing/d
   14128 /^Shifting/d
   14129 /^state/d
   14130 /^Cleanup:/d
   14131 /^Error:/d
   14132 /^Next/d
   14133 /^Discarding/d
   14134 / \$[0-9$]* = /d
   14135 /^yydestructor:/d' stderr >at-stderr
   14136 mv at-stderr stderr
   14137 # 2. Create the reference error message.
   14138 cat >expout <<'_ATEOF'
   14139 2.0: syntax error, unexpected '+'
   14140 _ATEOF
   14141 
   14142 # 3. If locations are not used, remove them.
   14143 
   14144 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14145 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14146 mv at-expout expout
   14147 # 5. Check
   14148 $at_traceoff
   14149 echo "calc.at:553: cat stderr"
   14150 echo calc.at:553 >$at_check_line_file
   14151 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14152 at_status=$?
   14153 grep '^ *+' $at_stder1 >&2
   14154 grep -v '^ *+' $at_stder1 >$at_stderr
   14155 at_failed=false
   14156 $at_diff $at_devnull $at_stderr || at_failed=:
   14157 $at_diff expout $at_stdout || at_failed=:
   14158 case $at_status in
   14159    77) echo 77 > $at_status_file
   14160             exit 77;;
   14161    0) ;;
   14162    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14163       at_failed=:;;
   14164 esac
   14165 if $at_failed; then
   14166 
   14167   echo 1 > $at_status_file
   14168   exit 1
   14169 fi
   14170 
   14171 $at_traceon
   14172 
   14173 
   14174 # Exercise error messages with EOF: work on an empty file.
   14175 $at_traceoff
   14176 echo "calc.at:553: \$PREPARSER ./calc /dev/null"
   14177 echo calc.at:553 >$at_check_line_file
   14178 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   14179 at_status=$?
   14180 grep '^ *+' $at_stder1 >&2
   14181 grep -v '^ *+' $at_stder1 >$at_stderr
   14182 at_failed=false
   14183 echo stderr:; tee stderr <$at_stderr
   14184 $at_diff $at_devnull $at_stdout || at_failed=:
   14185 case $at_status in
   14186    77) echo 77 > $at_status_file
   14187             exit 77;;
   14188    1) ;;
   14189    *) echo "calc.at:553: exit code was $at_status, expected 1"
   14190       at_failed=:;;
   14191 esac
   14192 if $at_failed; then
   14193 
   14194   echo 1 > $at_status_file
   14195   exit 1
   14196 fi
   14197 
   14198 $at_traceon
   14199 
   14200 
   14201 # Normalize the observed and expected error messages, depending upon the
   14202 # options.
   14203 # 1. Remove the traces from observed.
   14204 sed '/^Starting/d
   14205 /^Entering/d
   14206 /^Stack/d
   14207 /^Reading/d
   14208 /^Reducing/d
   14209 /^Shifting/d
   14210 /^state/d
   14211 /^Cleanup:/d
   14212 /^Error:/d
   14213 /^Next/d
   14214 /^Discarding/d
   14215 / \$[0-9$]* = /d
   14216 /^yydestructor:/d' stderr >at-stderr
   14217 mv at-stderr stderr
   14218 # 2. Create the reference error message.
   14219 cat >expout <<'_ATEOF'
   14220 1.0: syntax error, unexpected end of input
   14221 _ATEOF
   14222 
   14223 # 3. If locations are not used, remove them.
   14224 
   14225 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14226 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14227 mv at-expout expout
   14228 # 5. Check
   14229 $at_traceoff
   14230 echo "calc.at:553: cat stderr"
   14231 echo calc.at:553 >$at_check_line_file
   14232 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14233 at_status=$?
   14234 grep '^ *+' $at_stder1 >&2
   14235 grep -v '^ *+' $at_stder1 >$at_stderr
   14236 at_failed=false
   14237 $at_diff $at_devnull $at_stderr || at_failed=:
   14238 $at_diff expout $at_stdout || at_failed=:
   14239 case $at_status in
   14240    77) echo 77 > $at_status_file
   14241             exit 77;;
   14242    0) ;;
   14243    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14244       at_failed=:;;
   14245 esac
   14246 if $at_failed; then
   14247 
   14248   echo 1 > $at_status_file
   14249   exit 1
   14250 fi
   14251 
   14252 $at_traceon
   14253 
   14254 
   14255 
   14256 # Exercise the error token: without it, we die at the first error,
   14257 # hence be sure to
   14258 #
   14259 # - have several errors which exercise different shift/discardings
   14260 #   - (): nothing to pop, nothing to discard
   14261 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   14262 #   - (* * *): nothing to pop, a lot to discard
   14263 #   - (1 + 2 * *): some to pop and discard
   14264 #
   14265 # - test the action associated to `error'
   14266 #
   14267 # - check the look-ahead that triggers an error is not discarded
   14268 #   when we enter error recovery.  Below, the look-ahead causing the
   14269 #   first error is ")", which is needed to recover from the error and
   14270 #   produce the "0" that triggers the "0 != 1" error.
   14271 #
   14272 cat >input <<'_ATEOF'
   14273 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   14274 _ATEOF
   14275 
   14276 $at_traceoff
   14277 echo "calc.at:553: \$PREPARSER ./calc input"
   14278 echo calc.at:553 >$at_check_line_file
   14279 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14280 at_status=$?
   14281 grep '^ *+' $at_stder1 >&2
   14282 grep -v '^ *+' $at_stder1 >$at_stderr
   14283 at_failed=false
   14284 echo stderr:; tee stderr <$at_stderr
   14285 $at_diff $at_devnull $at_stdout || at_failed=:
   14286 case $at_status in
   14287    77) echo 77 > $at_status_file
   14288             exit 77;;
   14289    0) ;;
   14290    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14291       at_failed=:;;
   14292 esac
   14293 if $at_failed; then
   14294 
   14295   echo 1 > $at_status_file
   14296   exit 1
   14297 fi
   14298 
   14299 $at_traceon
   14300 
   14301 
   14302 # Normalize the observed and expected error messages, depending upon the
   14303 # options.
   14304 # 1. Remove the traces from observed.
   14305 sed '/^Starting/d
   14306 /^Entering/d
   14307 /^Stack/d
   14308 /^Reading/d
   14309 /^Reducing/d
   14310 /^Shifting/d
   14311 /^state/d
   14312 /^Cleanup:/d
   14313 /^Error:/d
   14314 /^Next/d
   14315 /^Discarding/d
   14316 / \$[0-9$]* = /d
   14317 /^yydestructor:/d' stderr >at-stderr
   14318 mv at-stderr stderr
   14319 # 2. Create the reference error message.
   14320 cat >expout <<'_ATEOF'
   14321 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   14322 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   14323 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   14324 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   14325 calc: error: 4444 != 1
   14326 _ATEOF
   14327 
   14328 # 3. If locations are not used, remove them.
   14329 
   14330 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14331 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14332 mv at-expout expout
   14333 # 5. Check
   14334 $at_traceoff
   14335 echo "calc.at:553: cat stderr"
   14336 echo calc.at:553 >$at_check_line_file
   14337 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14338 at_status=$?
   14339 grep '^ *+' $at_stder1 >&2
   14340 grep -v '^ *+' $at_stder1 >$at_stderr
   14341 at_failed=false
   14342 $at_diff $at_devnull $at_stderr || at_failed=:
   14343 $at_diff expout $at_stdout || at_failed=:
   14344 case $at_status in
   14345    77) echo 77 > $at_status_file
   14346             exit 77;;
   14347    0) ;;
   14348    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14349       at_failed=:;;
   14350 esac
   14351 if $at_failed; then
   14352 
   14353   echo 1 > $at_status_file
   14354   exit 1
   14355 fi
   14356 
   14357 $at_traceon
   14358 
   14359 
   14360 
   14361 # The same, but this time exercising explicitly triggered syntax errors.
   14362 # POSIX says the look-ahead causing the error should not be discarded.
   14363 cat >input <<'_ATEOF'
   14364 (!) + (0 0) = 1
   14365 _ATEOF
   14366 
   14367 $at_traceoff
   14368 echo "calc.at:553: \$PREPARSER ./calc input"
   14369 echo calc.at:553 >$at_check_line_file
   14370 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14371 at_status=$?
   14372 grep '^ *+' $at_stder1 >&2
   14373 grep -v '^ *+' $at_stder1 >$at_stderr
   14374 at_failed=false
   14375 echo stderr:; tee stderr <$at_stderr
   14376 $at_diff $at_devnull $at_stdout || at_failed=:
   14377 case $at_status in
   14378    77) echo 77 > $at_status_file
   14379             exit 77;;
   14380    0) ;;
   14381    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14382       at_failed=:;;
   14383 esac
   14384 if $at_failed; then
   14385 
   14386   echo 1 > $at_status_file
   14387   exit 1
   14388 fi
   14389 
   14390 $at_traceon
   14391 
   14392 
   14393 # Normalize the observed and expected error messages, depending upon the
   14394 # options.
   14395 # 1. Remove the traces from observed.
   14396 sed '/^Starting/d
   14397 /^Entering/d
   14398 /^Stack/d
   14399 /^Reading/d
   14400 /^Reducing/d
   14401 /^Shifting/d
   14402 /^state/d
   14403 /^Cleanup:/d
   14404 /^Error:/d
   14405 /^Next/d
   14406 /^Discarding/d
   14407 / \$[0-9$]* = /d
   14408 /^yydestructor:/d' stderr >at-stderr
   14409 mv at-stderr stderr
   14410 # 2. Create the reference error message.
   14411 cat >expout <<'_ATEOF'
   14412 1.9: syntax error, unexpected number
   14413 calc: error: 2222 != 1
   14414 _ATEOF
   14415 
   14416 # 3. If locations are not used, remove them.
   14417 
   14418 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14419 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14420 mv at-expout expout
   14421 # 5. Check
   14422 $at_traceoff
   14423 echo "calc.at:553: cat stderr"
   14424 echo calc.at:553 >$at_check_line_file
   14425 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14426 at_status=$?
   14427 grep '^ *+' $at_stder1 >&2
   14428 grep -v '^ *+' $at_stder1 >$at_stderr
   14429 at_failed=false
   14430 $at_diff $at_devnull $at_stderr || at_failed=:
   14431 $at_diff expout $at_stdout || at_failed=:
   14432 case $at_status in
   14433    77) echo 77 > $at_status_file
   14434             exit 77;;
   14435    0) ;;
   14436    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14437       at_failed=:;;
   14438 esac
   14439 if $at_failed; then
   14440 
   14441   echo 1 > $at_status_file
   14442   exit 1
   14443 fi
   14444 
   14445 $at_traceon
   14446 
   14447 
   14448 cat >input <<'_ATEOF'
   14449 (- *) + (0 0) = 1
   14450 _ATEOF
   14451 
   14452 $at_traceoff
   14453 echo "calc.at:553: \$PREPARSER ./calc input"
   14454 echo calc.at:553 >$at_check_line_file
   14455 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14456 at_status=$?
   14457 grep '^ *+' $at_stder1 >&2
   14458 grep -v '^ *+' $at_stder1 >$at_stderr
   14459 at_failed=false
   14460 echo stderr:; tee stderr <$at_stderr
   14461 $at_diff $at_devnull $at_stdout || at_failed=:
   14462 case $at_status in
   14463    77) echo 77 > $at_status_file
   14464             exit 77;;
   14465    0) ;;
   14466    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14467       at_failed=:;;
   14468 esac
   14469 if $at_failed; then
   14470 
   14471   echo 1 > $at_status_file
   14472   exit 1
   14473 fi
   14474 
   14475 $at_traceon
   14476 
   14477 
   14478 # Normalize the observed and expected error messages, depending upon the
   14479 # options.
   14480 # 1. Remove the traces from observed.
   14481 sed '/^Starting/d
   14482 /^Entering/d
   14483 /^Stack/d
   14484 /^Reading/d
   14485 /^Reducing/d
   14486 /^Shifting/d
   14487 /^state/d
   14488 /^Cleanup:/d
   14489 /^Error:/d
   14490 /^Next/d
   14491 /^Discarding/d
   14492 / \$[0-9$]* = /d
   14493 /^yydestructor:/d' stderr >at-stderr
   14494 mv at-stderr stderr
   14495 # 2. Create the reference error message.
   14496 cat >expout <<'_ATEOF'
   14497 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   14498 1.11: syntax error, unexpected number
   14499 calc: error: 2222 != 1
   14500 _ATEOF
   14501 
   14502 # 3. If locations are not used, remove them.
   14503 
   14504 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14505 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14506 mv at-expout expout
   14507 # 5. Check
   14508 $at_traceoff
   14509 echo "calc.at:553: cat stderr"
   14510 echo calc.at:553 >$at_check_line_file
   14511 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14512 at_status=$?
   14513 grep '^ *+' $at_stder1 >&2
   14514 grep -v '^ *+' $at_stder1 >$at_stderr
   14515 at_failed=false
   14516 $at_diff $at_devnull $at_stderr || at_failed=:
   14517 $at_diff expout $at_stdout || at_failed=:
   14518 case $at_status in
   14519    77) echo 77 > $at_status_file
   14520             exit 77;;
   14521    0) ;;
   14522    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14523       at_failed=:;;
   14524 esac
   14525 if $at_failed; then
   14526 
   14527   echo 1 > $at_status_file
   14528   exit 1
   14529 fi
   14530 
   14531 $at_traceon
   14532 
   14533 
   14534 
   14535 
   14536 
   14537 
   14538 
   14539 
   14540 
   14541 
   14542 
   14543 
   14544 
   14545 
   14546 
   14547 
   14548 
   14549 
   14550 
   14551 
   14552 
   14553 
   14554 
   14555 
   14556       $at_traceoff
   14557       $at_times_p && times >$at_times_file
   14558     ) 5>&1 2>&1 | eval $at_tee_pipe
   14559     at_status=`cat $at_status_file`
   14560     ;;
   14561 
   14562   73 ) # 73. calc.at:554: Calculator %name-prefix="calc"
   14563     at_setup_line='calc.at:554'
   14564     at_desc='Calculator %name-prefix="calc"'
   14565     $at_quiet $ECHO_N " 73: Calculator %name-prefix="calc"               $ECHO_C"
   14566     at_xfail=no
   14567     (
   14568       echo "73. calc.at:554: testing ..."
   14569       $at_traceon
   14570 
   14571 
   14572 
   14573 
   14574 
   14575 
   14576 
   14577 
   14578 # Using yacc.c?
   14579 
   14580 
   14581 
   14582 
   14583 
   14584 
   14585 
   14586 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   14587 
   14588 # yyerror always sees the locations (when activated), except if
   14589 # yacc & pure & !param.
   14590 
   14591 
   14592 # The interface is pure: either because %pure-parser, or because we
   14593 # are using the C++ parsers.
   14594 
   14595 
   14596 
   14597 
   14598 
   14599 
   14600 
   14601 
   14602 
   14603 
   14604 
   14605 
   14606 cat >calc.y <<'_ATEOF'
   14607 %{
   14608 #ifdef HAVE_CONFIG_H
   14609 # include <config.h>
   14610   /* We don't need perfect functions for these tests. */
   14611 # undef malloc
   14612 # undef memcmp
   14613 # undef realloc
   14614 #endif
   14615 %}
   14616 
   14617 /* Infix notation calculator--calc */
   14618 %name-prefix="calc"
   14619 
   14620 %{
   14621 #include <stdio.h>
   14622 
   14623 #include <stdlib.h>
   14624 #include <string.h>
   14625 #if HAVE_UNISTD_H
   14626 # include <unistd.h>
   14627 #else
   14628 # undef alarm
   14629 # define alarm(seconds) /* empty */
   14630 #endif
   14631 #include <ctype.h>
   14632 #define USE(Var)
   14633 
   14634 /* Exercise pre-prologue dependency to %union.  */
   14635 typedef int semantic_value;
   14636 
   14637 static semantic_value global_result = 0;
   14638 static int global_count = 0;
   14639 %}
   14640 
   14641 /* Exercise %union. */
   14642 %union
   14643 {
   14644   semantic_value ival;
   14645 };
   14646 
   14647 %{
   14648 static int power (int base, int exponent);
   14649 /* yyerror receives the location if:
   14650    - %location & %pure & %glr
   14651    - %location & %pure & %yacc & %parse-param. */
   14652 static void yyerror (
   14653 
   14654                      const char *s
   14655                      );
   14656 static int yylex (void);
   14657 static int get_char (void);
   14658 static void unget_char ( int c);
   14659 %}
   14660 
   14661 
   14662 
   14663 /* Bison Declarations */
   14664 %token CALC_EOF 0 "end of input"
   14665 %token <ival> NUM "number"
   14666 %type  <ival> exp
   14667 
   14668 %nonassoc '=' /* comparison	       */
   14669 %left '-' '+'
   14670 %left '*' '/'
   14671 %left NEG     /* negation--unary minus */
   14672 %right '^'    /* exponentiation        */
   14673 
   14674 /* Grammar follows */
   14675 %%
   14676 input:
   14677   line
   14678 | input line         {  }
   14679 ;
   14680 
   14681 line:
   14682   '\n'
   14683 | exp '\n'           { USE ($1); }
   14684 ;
   14685 
   14686 exp:
   14687   NUM                { $$ = $1;             }
   14688 | exp '=' exp
   14689   {
   14690     if ($1 != $3)
   14691       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   14692     $$ = $1;
   14693   }
   14694 | exp '+' exp        { $$ = $1 + $3;        }
   14695 | exp '-' exp        { $$ = $1 - $3;        }
   14696 | exp '*' exp        { $$ = $1 * $3;        }
   14697 | exp '/' exp        { $$ = $1 / $3;        }
   14698 | '-' exp  %prec NEG { $$ = -$2;            }
   14699 | exp '^' exp        { $$ = power ($1, $3); }
   14700 | '(' exp ')'        { $$ = $2;             }
   14701 | '(' error ')'      { $$ = 1111;           }
   14702 | '!'                { $$ = 0; YYERROR;     }
   14703 | '-' error          { $$ = 0; YYERROR;     }
   14704 ;
   14705 %%
   14706 /* The input.  */
   14707 static FILE *input;
   14708 
   14709 static void
   14710 yyerror (
   14711 
   14712          const char *s)
   14713 {
   14714 
   14715 
   14716   fprintf (stderr, "%s\n", s);
   14717 }
   14718 
   14719 
   14720 
   14721 static int
   14722 get_char (void)
   14723 {
   14724   int res = getc (input);
   14725   ;
   14726 
   14727   return res;
   14728 }
   14729 
   14730 
   14731 static void
   14732 unget_char ( int c)
   14733 {
   14734   ;
   14735 
   14736   ungetc (c, input);
   14737 }
   14738 
   14739 static int
   14740 read_signed_integer (void)
   14741 {
   14742   int c = get_char ();
   14743   int sign = 1;
   14744   int n = 0;
   14745 
   14746   ;
   14747   if (c == '-')
   14748     {
   14749       c = get_char ();
   14750       sign = -1;
   14751     }
   14752 
   14753   while (isdigit (c))
   14754     {
   14755       n = 10 * n + (c - '0');
   14756       c = get_char ();
   14757     }
   14758 
   14759   unget_char ( c);
   14760 
   14761   return sign * n;
   14762 }
   14763 
   14764 
   14765 
   14766 /*---------------------------------------------------------------.
   14767 | Lexical analyzer returns an integer on the stack and the token |
   14768 | NUM, or the ASCII character read if not a number.  Skips all   |
   14769 | blanks and tabs, returns 0 for EOF.                            |
   14770 `---------------------------------------------------------------*/
   14771 
   14772 static int
   14773 yylex (void)
   14774 {
   14775   static int init = 1;
   14776   int c;
   14777 
   14778   if (init)
   14779     {
   14780       init = 0;
   14781 
   14782     }
   14783 
   14784 
   14785 
   14786   /* Skip white space.  */
   14787   while ((c = get_char ()) == ' ' || c == '\t')
   14788     {
   14789 
   14790     }
   14791 
   14792   /* process numbers   */
   14793   if (c == '.' || isdigit (c))
   14794     {
   14795       unget_char ( c);
   14796       (yylval).ival = read_signed_integer ();
   14797       return NUM;
   14798     }
   14799 
   14800   /* Return end-of-file.  */
   14801   if (c == EOF)
   14802     return CALC_EOF;
   14803 
   14804   /* Return single chars. */
   14805   return c;
   14806 }
   14807 
   14808 static int
   14809 power (int base, int exponent)
   14810 {
   14811   int res = 1;
   14812   if (exponent < 0)
   14813     exit (3);
   14814   for (/* Niente */; exponent; --exponent)
   14815     res *= base;
   14816   return res;
   14817 }
   14818 
   14819 
   14820 int
   14821 main (int argc, const char **argv)
   14822 {
   14823   semantic_value result = 0;
   14824   int count = 0;
   14825   int status;
   14826 
   14827   /* This used to be alarm (10), but that isn't enough time for
   14828      a July 1995 vintage DEC Alphastation 200 4/100 system,
   14829      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   14830   alarm (100);
   14831 
   14832   if (argc == 2)
   14833     input = fopen (argv[1], "r");
   14834   else
   14835     input = stdin;
   14836 
   14837   if (!input)
   14838     {
   14839       perror (argv[1]);
   14840       return 3;
   14841     }
   14842 
   14843 
   14844   status = yyparse ();
   14845   if (global_result != result)
   14846     abort ();
   14847   if (global_count != count)
   14848     abort ();
   14849   return status;
   14850 }
   14851 _ATEOF
   14852 
   14853 
   14854 
   14855 
   14856 
   14857 $at_traceoff
   14858 echo "calc.at:554: bison -o calc.c calc.y"
   14859 echo calc.at:554 >$at_check_line_file
   14860 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   14861 at_status=$?
   14862 grep '^ *+' $at_stder1 >&2
   14863 grep -v '^ *+' $at_stder1 >$at_stderr
   14864 at_failed=false
   14865 $at_diff $at_devnull $at_stderr || at_failed=:
   14866 $at_diff $at_devnull $at_stdout || at_failed=:
   14867 case $at_status in
   14868    77) echo 77 > $at_status_file
   14869             exit 77;;
   14870    0) ;;
   14871    *) echo "calc.at:554: exit code was $at_status, expected 0"
   14872       at_failed=:;;
   14873 esac
   14874 if $at_failed; then
   14875 
   14876   echo 1 > $at_status_file
   14877   exit 1
   14878 fi
   14879 
   14880 $at_traceon
   14881 
   14882    $at_traceoff
   14883 echo "calc.at:554: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   14884 echo calc.at:554 >$at_check_line_file
   14885 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   14886 at_status=$?
   14887 grep '^ *+' $at_stder1 >&2
   14888 grep -v '^ *+' $at_stder1 >$at_stderr
   14889 at_failed=false
   14890 echo stderr:; cat $at_stderr
   14891 echo stdout:; cat $at_stdout
   14892 case $at_status in
   14893    77) echo 77 > $at_status_file
   14894             exit 77;;
   14895    0) ;;
   14896    *) echo "calc.at:554: exit code was $at_status, expected 0"
   14897       at_failed=:;;
   14898 esac
   14899 if $at_failed; then
   14900 
   14901   echo 1 > $at_status_file
   14902   exit 1
   14903 fi
   14904 
   14905 $at_traceon
   14906 
   14907 
   14908 # Test the priorities.
   14909 cat >input <<'_ATEOF'
   14910 1 + 2 * 3 = 7
   14911 1 + 2 * -3 = -5
   14912 
   14913 -1^2 = -1
   14914 (-1)^2 = 1
   14915 
   14916 ---1 = -1
   14917 
   14918 1 - 2 - 3 = -4
   14919 1 - (2 - 3) = 2
   14920 
   14921 2^2^3 = 256
   14922 (2^2)^3 = 64
   14923 _ATEOF
   14924 
   14925 $at_traceoff
   14926 echo "calc.at:554: \$PREPARSER ./calc input"
   14927 echo calc.at:554 >$at_check_line_file
   14928 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14929 at_status=$?
   14930 grep '^ *+' $at_stder1 >&2
   14931 grep -v '^ *+' $at_stder1 >$at_stderr
   14932 at_failed=false
   14933 echo stderr:; tee stderr <$at_stderr
   14934 $at_diff $at_devnull $at_stdout || at_failed=:
   14935 case $at_status in
   14936    77) echo 77 > $at_status_file
   14937             exit 77;;
   14938    0) ;;
   14939    *) echo "calc.at:554: exit code was $at_status, expected 0"
   14940       at_failed=:;;
   14941 esac
   14942 if $at_failed; then
   14943 
   14944   echo 1 > $at_status_file
   14945   exit 1
   14946 fi
   14947 
   14948 $at_traceon
   14949 
   14950 
   14951 
   14952 # Some syntax errors.
   14953 cat >input <<'_ATEOF'
   14954 0 0
   14955 _ATEOF
   14956 
   14957 $at_traceoff
   14958 echo "calc.at:554: \$PREPARSER ./calc input"
   14959 echo calc.at:554 >$at_check_line_file
   14960 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14961 at_status=$?
   14962 grep '^ *+' $at_stder1 >&2
   14963 grep -v '^ *+' $at_stder1 >$at_stderr
   14964 at_failed=false
   14965 echo stderr:; tee stderr <$at_stderr
   14966 $at_diff $at_devnull $at_stdout || at_failed=:
   14967 case $at_status in
   14968    77) echo 77 > $at_status_file
   14969             exit 77;;
   14970    1) ;;
   14971    *) echo "calc.at:554: exit code was $at_status, expected 1"
   14972       at_failed=:;;
   14973 esac
   14974 if $at_failed; then
   14975 
   14976   echo 1 > $at_status_file
   14977   exit 1
   14978 fi
   14979 
   14980 $at_traceon
   14981 
   14982 
   14983 # Normalize the observed and expected error messages, depending upon the
   14984 # options.
   14985 # 1. Remove the traces from observed.
   14986 sed '/^Starting/d
   14987 /^Entering/d
   14988 /^Stack/d
   14989 /^Reading/d
   14990 /^Reducing/d
   14991 /^Shifting/d
   14992 /^state/d
   14993 /^Cleanup:/d
   14994 /^Error:/d
   14995 /^Next/d
   14996 /^Discarding/d
   14997 / \$[0-9$]* = /d
   14998 /^yydestructor:/d' stderr >at-stderr
   14999 mv at-stderr stderr
   15000 # 2. Create the reference error message.
   15001 cat >expout <<'_ATEOF'
   15002 1.2: syntax error, unexpected number
   15003 _ATEOF
   15004 
   15005 # 3. If locations are not used, remove them.
   15006 sed 's/^[-0-9.]*: //' expout >at-expout
   15007 mv at-expout expout
   15008 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15009 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15010 mv at-expout expout
   15011 # 5. Check
   15012 $at_traceoff
   15013 echo "calc.at:554: cat stderr"
   15014 echo calc.at:554 >$at_check_line_file
   15015 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15016 at_status=$?
   15017 grep '^ *+' $at_stder1 >&2
   15018 grep -v '^ *+' $at_stder1 >$at_stderr
   15019 at_failed=false
   15020 $at_diff $at_devnull $at_stderr || at_failed=:
   15021 $at_diff expout $at_stdout || at_failed=:
   15022 case $at_status in
   15023    77) echo 77 > $at_status_file
   15024             exit 77;;
   15025    0) ;;
   15026    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15027       at_failed=:;;
   15028 esac
   15029 if $at_failed; then
   15030 
   15031   echo 1 > $at_status_file
   15032   exit 1
   15033 fi
   15034 
   15035 $at_traceon
   15036 
   15037 
   15038 cat >input <<'_ATEOF'
   15039 1//2
   15040 _ATEOF
   15041 
   15042 $at_traceoff
   15043 echo "calc.at:554: \$PREPARSER ./calc input"
   15044 echo calc.at:554 >$at_check_line_file
   15045 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15046 at_status=$?
   15047 grep '^ *+' $at_stder1 >&2
   15048 grep -v '^ *+' $at_stder1 >$at_stderr
   15049 at_failed=false
   15050 echo stderr:; tee stderr <$at_stderr
   15051 $at_diff $at_devnull $at_stdout || at_failed=:
   15052 case $at_status in
   15053    77) echo 77 > $at_status_file
   15054             exit 77;;
   15055    1) ;;
   15056    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15057       at_failed=:;;
   15058 esac
   15059 if $at_failed; then
   15060 
   15061   echo 1 > $at_status_file
   15062   exit 1
   15063 fi
   15064 
   15065 $at_traceon
   15066 
   15067 
   15068 # Normalize the observed and expected error messages, depending upon the
   15069 # options.
   15070 # 1. Remove the traces from observed.
   15071 sed '/^Starting/d
   15072 /^Entering/d
   15073 /^Stack/d
   15074 /^Reading/d
   15075 /^Reducing/d
   15076 /^Shifting/d
   15077 /^state/d
   15078 /^Cleanup:/d
   15079 /^Error:/d
   15080 /^Next/d
   15081 /^Discarding/d
   15082 / \$[0-9$]* = /d
   15083 /^yydestructor:/d' stderr >at-stderr
   15084 mv at-stderr stderr
   15085 # 2. Create the reference error message.
   15086 cat >expout <<'_ATEOF'
   15087 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   15088 _ATEOF
   15089 
   15090 # 3. If locations are not used, remove them.
   15091 sed 's/^[-0-9.]*: //' expout >at-expout
   15092 mv at-expout expout
   15093 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15094 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15095 mv at-expout expout
   15096 # 5. Check
   15097 $at_traceoff
   15098 echo "calc.at:554: cat stderr"
   15099 echo calc.at:554 >$at_check_line_file
   15100 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15101 at_status=$?
   15102 grep '^ *+' $at_stder1 >&2
   15103 grep -v '^ *+' $at_stder1 >$at_stderr
   15104 at_failed=false
   15105 $at_diff $at_devnull $at_stderr || at_failed=:
   15106 $at_diff expout $at_stdout || at_failed=:
   15107 case $at_status in
   15108    77) echo 77 > $at_status_file
   15109             exit 77;;
   15110    0) ;;
   15111    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15112       at_failed=:;;
   15113 esac
   15114 if $at_failed; then
   15115 
   15116   echo 1 > $at_status_file
   15117   exit 1
   15118 fi
   15119 
   15120 $at_traceon
   15121 
   15122 
   15123 cat >input <<'_ATEOF'
   15124 error
   15125 _ATEOF
   15126 
   15127 $at_traceoff
   15128 echo "calc.at:554: \$PREPARSER ./calc input"
   15129 echo calc.at:554 >$at_check_line_file
   15130 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15131 at_status=$?
   15132 grep '^ *+' $at_stder1 >&2
   15133 grep -v '^ *+' $at_stder1 >$at_stderr
   15134 at_failed=false
   15135 echo stderr:; tee stderr <$at_stderr
   15136 $at_diff $at_devnull $at_stdout || at_failed=:
   15137 case $at_status in
   15138    77) echo 77 > $at_status_file
   15139             exit 77;;
   15140    1) ;;
   15141    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15142       at_failed=:;;
   15143 esac
   15144 if $at_failed; then
   15145 
   15146   echo 1 > $at_status_file
   15147   exit 1
   15148 fi
   15149 
   15150 $at_traceon
   15151 
   15152 
   15153 # Normalize the observed and expected error messages, depending upon the
   15154 # options.
   15155 # 1. Remove the traces from observed.
   15156 sed '/^Starting/d
   15157 /^Entering/d
   15158 /^Stack/d
   15159 /^Reading/d
   15160 /^Reducing/d
   15161 /^Shifting/d
   15162 /^state/d
   15163 /^Cleanup:/d
   15164 /^Error:/d
   15165 /^Next/d
   15166 /^Discarding/d
   15167 / \$[0-9$]* = /d
   15168 /^yydestructor:/d' stderr >at-stderr
   15169 mv at-stderr stderr
   15170 # 2. Create the reference error message.
   15171 cat >expout <<'_ATEOF'
   15172 1.0: syntax error, unexpected $undefined
   15173 _ATEOF
   15174 
   15175 # 3. If locations are not used, remove them.
   15176 sed 's/^[-0-9.]*: //' expout >at-expout
   15177 mv at-expout expout
   15178 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15179 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15180 mv at-expout expout
   15181 # 5. Check
   15182 $at_traceoff
   15183 echo "calc.at:554: cat stderr"
   15184 echo calc.at:554 >$at_check_line_file
   15185 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15186 at_status=$?
   15187 grep '^ *+' $at_stder1 >&2
   15188 grep -v '^ *+' $at_stder1 >$at_stderr
   15189 at_failed=false
   15190 $at_diff $at_devnull $at_stderr || at_failed=:
   15191 $at_diff expout $at_stdout || at_failed=:
   15192 case $at_status in
   15193    77) echo 77 > $at_status_file
   15194             exit 77;;
   15195    0) ;;
   15196    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15197       at_failed=:;;
   15198 esac
   15199 if $at_failed; then
   15200 
   15201   echo 1 > $at_status_file
   15202   exit 1
   15203 fi
   15204 
   15205 $at_traceon
   15206 
   15207 
   15208 cat >input <<'_ATEOF'
   15209 1 = 2 = 3
   15210 _ATEOF
   15211 
   15212 $at_traceoff
   15213 echo "calc.at:554: \$PREPARSER ./calc input"
   15214 echo calc.at:554 >$at_check_line_file
   15215 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15216 at_status=$?
   15217 grep '^ *+' $at_stder1 >&2
   15218 grep -v '^ *+' $at_stder1 >$at_stderr
   15219 at_failed=false
   15220 echo stderr:; tee stderr <$at_stderr
   15221 $at_diff $at_devnull $at_stdout || at_failed=:
   15222 case $at_status in
   15223    77) echo 77 > $at_status_file
   15224             exit 77;;
   15225    1) ;;
   15226    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15227       at_failed=:;;
   15228 esac
   15229 if $at_failed; then
   15230 
   15231   echo 1 > $at_status_file
   15232   exit 1
   15233 fi
   15234 
   15235 $at_traceon
   15236 
   15237 
   15238 # Normalize the observed and expected error messages, depending upon the
   15239 # options.
   15240 # 1. Remove the traces from observed.
   15241 sed '/^Starting/d
   15242 /^Entering/d
   15243 /^Stack/d
   15244 /^Reading/d
   15245 /^Reducing/d
   15246 /^Shifting/d
   15247 /^state/d
   15248 /^Cleanup:/d
   15249 /^Error:/d
   15250 /^Next/d
   15251 /^Discarding/d
   15252 / \$[0-9$]* = /d
   15253 /^yydestructor:/d' stderr >at-stderr
   15254 mv at-stderr stderr
   15255 # 2. Create the reference error message.
   15256 cat >expout <<'_ATEOF'
   15257 1.6: syntax error, unexpected '='
   15258 _ATEOF
   15259 
   15260 # 3. If locations are not used, remove them.
   15261 sed 's/^[-0-9.]*: //' expout >at-expout
   15262 mv at-expout expout
   15263 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15264 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15265 mv at-expout expout
   15266 # 5. Check
   15267 $at_traceoff
   15268 echo "calc.at:554: cat stderr"
   15269 echo calc.at:554 >$at_check_line_file
   15270 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15271 at_status=$?
   15272 grep '^ *+' $at_stder1 >&2
   15273 grep -v '^ *+' $at_stder1 >$at_stderr
   15274 at_failed=false
   15275 $at_diff $at_devnull $at_stderr || at_failed=:
   15276 $at_diff expout $at_stdout || at_failed=:
   15277 case $at_status in
   15278    77) echo 77 > $at_status_file
   15279             exit 77;;
   15280    0) ;;
   15281    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15282       at_failed=:;;
   15283 esac
   15284 if $at_failed; then
   15285 
   15286   echo 1 > $at_status_file
   15287   exit 1
   15288 fi
   15289 
   15290 $at_traceon
   15291 
   15292 
   15293 cat >input <<'_ATEOF'
   15294 
   15295 +1
   15296 _ATEOF
   15297 
   15298 $at_traceoff
   15299 echo "calc.at:554: \$PREPARSER ./calc input"
   15300 echo calc.at:554 >$at_check_line_file
   15301 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15302 at_status=$?
   15303 grep '^ *+' $at_stder1 >&2
   15304 grep -v '^ *+' $at_stder1 >$at_stderr
   15305 at_failed=false
   15306 echo stderr:; tee stderr <$at_stderr
   15307 $at_diff $at_devnull $at_stdout || at_failed=:
   15308 case $at_status in
   15309    77) echo 77 > $at_status_file
   15310             exit 77;;
   15311    1) ;;
   15312    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15313       at_failed=:;;
   15314 esac
   15315 if $at_failed; then
   15316 
   15317   echo 1 > $at_status_file
   15318   exit 1
   15319 fi
   15320 
   15321 $at_traceon
   15322 
   15323 
   15324 # Normalize the observed and expected error messages, depending upon the
   15325 # options.
   15326 # 1. Remove the traces from observed.
   15327 sed '/^Starting/d
   15328 /^Entering/d
   15329 /^Stack/d
   15330 /^Reading/d
   15331 /^Reducing/d
   15332 /^Shifting/d
   15333 /^state/d
   15334 /^Cleanup:/d
   15335 /^Error:/d
   15336 /^Next/d
   15337 /^Discarding/d
   15338 / \$[0-9$]* = /d
   15339 /^yydestructor:/d' stderr >at-stderr
   15340 mv at-stderr stderr
   15341 # 2. Create the reference error message.
   15342 cat >expout <<'_ATEOF'
   15343 2.0: syntax error, unexpected '+'
   15344 _ATEOF
   15345 
   15346 # 3. If locations are not used, remove them.
   15347 sed 's/^[-0-9.]*: //' expout >at-expout
   15348 mv at-expout expout
   15349 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15350 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15351 mv at-expout expout
   15352 # 5. Check
   15353 $at_traceoff
   15354 echo "calc.at:554: cat stderr"
   15355 echo calc.at:554 >$at_check_line_file
   15356 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15357 at_status=$?
   15358 grep '^ *+' $at_stder1 >&2
   15359 grep -v '^ *+' $at_stder1 >$at_stderr
   15360 at_failed=false
   15361 $at_diff $at_devnull $at_stderr || at_failed=:
   15362 $at_diff expout $at_stdout || at_failed=:
   15363 case $at_status in
   15364    77) echo 77 > $at_status_file
   15365             exit 77;;
   15366    0) ;;
   15367    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15368       at_failed=:;;
   15369 esac
   15370 if $at_failed; then
   15371 
   15372   echo 1 > $at_status_file
   15373   exit 1
   15374 fi
   15375 
   15376 $at_traceon
   15377 
   15378 
   15379 # Exercise error messages with EOF: work on an empty file.
   15380 $at_traceoff
   15381 echo "calc.at:554: \$PREPARSER ./calc /dev/null"
   15382 echo calc.at:554 >$at_check_line_file
   15383 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   15384 at_status=$?
   15385 grep '^ *+' $at_stder1 >&2
   15386 grep -v '^ *+' $at_stder1 >$at_stderr
   15387 at_failed=false
   15388 echo stderr:; tee stderr <$at_stderr
   15389 $at_diff $at_devnull $at_stdout || at_failed=:
   15390 case $at_status in
   15391    77) echo 77 > $at_status_file
   15392             exit 77;;
   15393    1) ;;
   15394    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15395       at_failed=:;;
   15396 esac
   15397 if $at_failed; then
   15398 
   15399   echo 1 > $at_status_file
   15400   exit 1
   15401 fi
   15402 
   15403 $at_traceon
   15404 
   15405 
   15406 # Normalize the observed and expected error messages, depending upon the
   15407 # options.
   15408 # 1. Remove the traces from observed.
   15409 sed '/^Starting/d
   15410 /^Entering/d
   15411 /^Stack/d
   15412 /^Reading/d
   15413 /^Reducing/d
   15414 /^Shifting/d
   15415 /^state/d
   15416 /^Cleanup:/d
   15417 /^Error:/d
   15418 /^Next/d
   15419 /^Discarding/d
   15420 / \$[0-9$]* = /d
   15421 /^yydestructor:/d' stderr >at-stderr
   15422 mv at-stderr stderr
   15423 # 2. Create the reference error message.
   15424 cat >expout <<'_ATEOF'
   15425 1.0: syntax error, unexpected end of input
   15426 _ATEOF
   15427 
   15428 # 3. If locations are not used, remove them.
   15429 sed 's/^[-0-9.]*: //' expout >at-expout
   15430 mv at-expout expout
   15431 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15432 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15433 mv at-expout expout
   15434 # 5. Check
   15435 $at_traceoff
   15436 echo "calc.at:554: cat stderr"
   15437 echo calc.at:554 >$at_check_line_file
   15438 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15439 at_status=$?
   15440 grep '^ *+' $at_stder1 >&2
   15441 grep -v '^ *+' $at_stder1 >$at_stderr
   15442 at_failed=false
   15443 $at_diff $at_devnull $at_stderr || at_failed=:
   15444 $at_diff expout $at_stdout || at_failed=:
   15445 case $at_status in
   15446    77) echo 77 > $at_status_file
   15447             exit 77;;
   15448    0) ;;
   15449    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15450       at_failed=:;;
   15451 esac
   15452 if $at_failed; then
   15453 
   15454   echo 1 > $at_status_file
   15455   exit 1
   15456 fi
   15457 
   15458 $at_traceon
   15459 
   15460 
   15461 
   15462 # Exercise the error token: without it, we die at the first error,
   15463 # hence be sure to
   15464 #
   15465 # - have several errors which exercise different shift/discardings
   15466 #   - (): nothing to pop, nothing to discard
   15467 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   15468 #   - (* * *): nothing to pop, a lot to discard
   15469 #   - (1 + 2 * *): some to pop and discard
   15470 #
   15471 # - test the action associated to `error'
   15472 #
   15473 # - check the look-ahead that triggers an error is not discarded
   15474 #   when we enter error recovery.  Below, the look-ahead causing the
   15475 #   first error is ")", which is needed to recover from the error and
   15476 #   produce the "0" that triggers the "0 != 1" error.
   15477 #
   15478 cat >input <<'_ATEOF'
   15479 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   15480 _ATEOF
   15481 
   15482 $at_traceoff
   15483 echo "calc.at:554: \$PREPARSER ./calc input"
   15484 echo calc.at:554 >$at_check_line_file
   15485 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15486 at_status=$?
   15487 grep '^ *+' $at_stder1 >&2
   15488 grep -v '^ *+' $at_stder1 >$at_stderr
   15489 at_failed=false
   15490 echo stderr:; tee stderr <$at_stderr
   15491 $at_diff $at_devnull $at_stdout || at_failed=:
   15492 case $at_status in
   15493    77) echo 77 > $at_status_file
   15494             exit 77;;
   15495    0) ;;
   15496    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15497       at_failed=:;;
   15498 esac
   15499 if $at_failed; then
   15500 
   15501   echo 1 > $at_status_file
   15502   exit 1
   15503 fi
   15504 
   15505 $at_traceon
   15506 
   15507 
   15508 # Normalize the observed and expected error messages, depending upon the
   15509 # options.
   15510 # 1. Remove the traces from observed.
   15511 sed '/^Starting/d
   15512 /^Entering/d
   15513 /^Stack/d
   15514 /^Reading/d
   15515 /^Reducing/d
   15516 /^Shifting/d
   15517 /^state/d
   15518 /^Cleanup:/d
   15519 /^Error:/d
   15520 /^Next/d
   15521 /^Discarding/d
   15522 / \$[0-9$]* = /d
   15523 /^yydestructor:/d' stderr >at-stderr
   15524 mv at-stderr stderr
   15525 # 2. Create the reference error message.
   15526 cat >expout <<'_ATEOF'
   15527 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   15528 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   15529 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   15530 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   15531 calc: error: 4444 != 1
   15532 _ATEOF
   15533 
   15534 # 3. If locations are not used, remove them.
   15535 sed 's/^[-0-9.]*: //' expout >at-expout
   15536 mv at-expout expout
   15537 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15538 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15539 mv at-expout expout
   15540 # 5. Check
   15541 $at_traceoff
   15542 echo "calc.at:554: cat stderr"
   15543 echo calc.at:554 >$at_check_line_file
   15544 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15545 at_status=$?
   15546 grep '^ *+' $at_stder1 >&2
   15547 grep -v '^ *+' $at_stder1 >$at_stderr
   15548 at_failed=false
   15549 $at_diff $at_devnull $at_stderr || at_failed=:
   15550 $at_diff expout $at_stdout || at_failed=:
   15551 case $at_status in
   15552    77) echo 77 > $at_status_file
   15553             exit 77;;
   15554    0) ;;
   15555    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15556       at_failed=:;;
   15557 esac
   15558 if $at_failed; then
   15559 
   15560   echo 1 > $at_status_file
   15561   exit 1
   15562 fi
   15563 
   15564 $at_traceon
   15565 
   15566 
   15567 
   15568 # The same, but this time exercising explicitly triggered syntax errors.
   15569 # POSIX says the look-ahead causing the error should not be discarded.
   15570 cat >input <<'_ATEOF'
   15571 (!) + (0 0) = 1
   15572 _ATEOF
   15573 
   15574 $at_traceoff
   15575 echo "calc.at:554: \$PREPARSER ./calc input"
   15576 echo calc.at:554 >$at_check_line_file
   15577 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15578 at_status=$?
   15579 grep '^ *+' $at_stder1 >&2
   15580 grep -v '^ *+' $at_stder1 >$at_stderr
   15581 at_failed=false
   15582 echo stderr:; tee stderr <$at_stderr
   15583 $at_diff $at_devnull $at_stdout || at_failed=:
   15584 case $at_status in
   15585    77) echo 77 > $at_status_file
   15586             exit 77;;
   15587    0) ;;
   15588    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15589       at_failed=:;;
   15590 esac
   15591 if $at_failed; then
   15592 
   15593   echo 1 > $at_status_file
   15594   exit 1
   15595 fi
   15596 
   15597 $at_traceon
   15598 
   15599 
   15600 # Normalize the observed and expected error messages, depending upon the
   15601 # options.
   15602 # 1. Remove the traces from observed.
   15603 sed '/^Starting/d
   15604 /^Entering/d
   15605 /^Stack/d
   15606 /^Reading/d
   15607 /^Reducing/d
   15608 /^Shifting/d
   15609 /^state/d
   15610 /^Cleanup:/d
   15611 /^Error:/d
   15612 /^Next/d
   15613 /^Discarding/d
   15614 / \$[0-9$]* = /d
   15615 /^yydestructor:/d' stderr >at-stderr
   15616 mv at-stderr stderr
   15617 # 2. Create the reference error message.
   15618 cat >expout <<'_ATEOF'
   15619 1.9: syntax error, unexpected number
   15620 calc: error: 2222 != 1
   15621 _ATEOF
   15622 
   15623 # 3. If locations are not used, remove them.
   15624 sed 's/^[-0-9.]*: //' expout >at-expout
   15625 mv at-expout expout
   15626 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15627 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15628 mv at-expout expout
   15629 # 5. Check
   15630 $at_traceoff
   15631 echo "calc.at:554: cat stderr"
   15632 echo calc.at:554 >$at_check_line_file
   15633 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15634 at_status=$?
   15635 grep '^ *+' $at_stder1 >&2
   15636 grep -v '^ *+' $at_stder1 >$at_stderr
   15637 at_failed=false
   15638 $at_diff $at_devnull $at_stderr || at_failed=:
   15639 $at_diff expout $at_stdout || at_failed=:
   15640 case $at_status in
   15641    77) echo 77 > $at_status_file
   15642             exit 77;;
   15643    0) ;;
   15644    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15645       at_failed=:;;
   15646 esac
   15647 if $at_failed; then
   15648 
   15649   echo 1 > $at_status_file
   15650   exit 1
   15651 fi
   15652 
   15653 $at_traceon
   15654 
   15655 
   15656 cat >input <<'_ATEOF'
   15657 (- *) + (0 0) = 1
   15658 _ATEOF
   15659 
   15660 $at_traceoff
   15661 echo "calc.at:554: \$PREPARSER ./calc input"
   15662 echo calc.at:554 >$at_check_line_file
   15663 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15664 at_status=$?
   15665 grep '^ *+' $at_stder1 >&2
   15666 grep -v '^ *+' $at_stder1 >$at_stderr
   15667 at_failed=false
   15668 echo stderr:; tee stderr <$at_stderr
   15669 $at_diff $at_devnull $at_stdout || at_failed=:
   15670 case $at_status in
   15671    77) echo 77 > $at_status_file
   15672             exit 77;;
   15673    0) ;;
   15674    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15675       at_failed=:;;
   15676 esac
   15677 if $at_failed; then
   15678 
   15679   echo 1 > $at_status_file
   15680   exit 1
   15681 fi
   15682 
   15683 $at_traceon
   15684 
   15685 
   15686 # Normalize the observed and expected error messages, depending upon the
   15687 # options.
   15688 # 1. Remove the traces from observed.
   15689 sed '/^Starting/d
   15690 /^Entering/d
   15691 /^Stack/d
   15692 /^Reading/d
   15693 /^Reducing/d
   15694 /^Shifting/d
   15695 /^state/d
   15696 /^Cleanup:/d
   15697 /^Error:/d
   15698 /^Next/d
   15699 /^Discarding/d
   15700 / \$[0-9$]* = /d
   15701 /^yydestructor:/d' stderr >at-stderr
   15702 mv at-stderr stderr
   15703 # 2. Create the reference error message.
   15704 cat >expout <<'_ATEOF'
   15705 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   15706 1.11: syntax error, unexpected number
   15707 calc: error: 2222 != 1
   15708 _ATEOF
   15709 
   15710 # 3. If locations are not used, remove them.
   15711 sed 's/^[-0-9.]*: //' expout >at-expout
   15712 mv at-expout expout
   15713 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15714 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15715 mv at-expout expout
   15716 # 5. Check
   15717 $at_traceoff
   15718 echo "calc.at:554: cat stderr"
   15719 echo calc.at:554 >$at_check_line_file
   15720 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15721 at_status=$?
   15722 grep '^ *+' $at_stder1 >&2
   15723 grep -v '^ *+' $at_stder1 >$at_stderr
   15724 at_failed=false
   15725 $at_diff $at_devnull $at_stderr || at_failed=:
   15726 $at_diff expout $at_stdout || at_failed=:
   15727 case $at_status in
   15728    77) echo 77 > $at_status_file
   15729             exit 77;;
   15730    0) ;;
   15731    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15732       at_failed=:;;
   15733 esac
   15734 if $at_failed; then
   15735 
   15736   echo 1 > $at_status_file
   15737   exit 1
   15738 fi
   15739 
   15740 $at_traceon
   15741 
   15742 
   15743 
   15744 
   15745 
   15746 
   15747 
   15748 
   15749 
   15750 
   15751 
   15752 
   15753 
   15754 
   15755 
   15756 
   15757 
   15758 
   15759 
   15760 
   15761 
   15762 
   15763 
   15764 
   15765       $at_traceoff
   15766       $at_times_p && times >$at_times_file
   15767     ) 5>&1 2>&1 | eval $at_tee_pipe
   15768     at_status=`cat $at_status_file`
   15769     ;;
   15770 
   15771   74 ) # 74. calc.at:555: Calculator %verbose
   15772     at_setup_line='calc.at:555'
   15773     at_desc='Calculator %verbose'
   15774     $at_quiet $ECHO_N " 74: Calculator %verbose                          $ECHO_C"
   15775     at_xfail=no
   15776     (
   15777       echo "74. calc.at:555: testing ..."
   15778       $at_traceon
   15779 
   15780 
   15781 
   15782 
   15783 
   15784 
   15785 
   15786 
   15787 # Using yacc.c?
   15788 
   15789 
   15790 
   15791 
   15792 
   15793 
   15794 
   15795 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   15796 
   15797 # yyerror always sees the locations (when activated), except if
   15798 # yacc & pure & !param.
   15799 
   15800 
   15801 # The interface is pure: either because %pure-parser, or because we
   15802 # are using the C++ parsers.
   15803 
   15804 
   15805 
   15806 
   15807 
   15808 
   15809 
   15810 
   15811 
   15812 
   15813 
   15814 
   15815 cat >calc.y <<'_ATEOF'
   15816 %{
   15817 #ifdef HAVE_CONFIG_H
   15818 # include <config.h>
   15819   /* We don't need perfect functions for these tests. */
   15820 # undef malloc
   15821 # undef memcmp
   15822 # undef realloc
   15823 #endif
   15824 %}
   15825 
   15826 /* Infix notation calculator--calc */
   15827 %verbose
   15828 
   15829 %{
   15830 #include <stdio.h>
   15831 
   15832 #include <stdlib.h>
   15833 #include <string.h>
   15834 #if HAVE_UNISTD_H
   15835 # include <unistd.h>
   15836 #else
   15837 # undef alarm
   15838 # define alarm(seconds) /* empty */
   15839 #endif
   15840 #include <ctype.h>
   15841 #define USE(Var)
   15842 
   15843 /* Exercise pre-prologue dependency to %union.  */
   15844 typedef int semantic_value;
   15845 
   15846 static semantic_value global_result = 0;
   15847 static int global_count = 0;
   15848 %}
   15849 
   15850 /* Exercise %union. */
   15851 %union
   15852 {
   15853   semantic_value ival;
   15854 };
   15855 
   15856 %{
   15857 static int power (int base, int exponent);
   15858 /* yyerror receives the location if:
   15859    - %location & %pure & %glr
   15860    - %location & %pure & %yacc & %parse-param. */
   15861 static void yyerror (
   15862 
   15863                      const char *s
   15864                      );
   15865 static int yylex (void);
   15866 static int get_char (void);
   15867 static void unget_char ( int c);
   15868 %}
   15869 
   15870 
   15871 
   15872 /* Bison Declarations */
   15873 %token CALC_EOF 0 "end of input"
   15874 %token <ival> NUM "number"
   15875 %type  <ival> exp
   15876 
   15877 %nonassoc '=' /* comparison	       */
   15878 %left '-' '+'
   15879 %left '*' '/'
   15880 %left NEG     /* negation--unary minus */
   15881 %right '^'    /* exponentiation        */
   15882 
   15883 /* Grammar follows */
   15884 %%
   15885 input:
   15886   line
   15887 | input line         {  }
   15888 ;
   15889 
   15890 line:
   15891   '\n'
   15892 | exp '\n'           { USE ($1); }
   15893 ;
   15894 
   15895 exp:
   15896   NUM                { $$ = $1;             }
   15897 | exp '=' exp
   15898   {
   15899     if ($1 != $3)
   15900       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   15901     $$ = $1;
   15902   }
   15903 | exp '+' exp        { $$ = $1 + $3;        }
   15904 | exp '-' exp        { $$ = $1 - $3;        }
   15905 | exp '*' exp        { $$ = $1 * $3;        }
   15906 | exp '/' exp        { $$ = $1 / $3;        }
   15907 | '-' exp  %prec NEG { $$ = -$2;            }
   15908 | exp '^' exp        { $$ = power ($1, $3); }
   15909 | '(' exp ')'        { $$ = $2;             }
   15910 | '(' error ')'      { $$ = 1111;           }
   15911 | '!'                { $$ = 0; YYERROR;     }
   15912 | '-' error          { $$ = 0; YYERROR;     }
   15913 ;
   15914 %%
   15915 /* The input.  */
   15916 static FILE *input;
   15917 
   15918 static void
   15919 yyerror (
   15920 
   15921          const char *s)
   15922 {
   15923 
   15924 
   15925   fprintf (stderr, "%s\n", s);
   15926 }
   15927 
   15928 
   15929 
   15930 static int
   15931 get_char (void)
   15932 {
   15933   int res = getc (input);
   15934   ;
   15935 
   15936   return res;
   15937 }
   15938 
   15939 
   15940 static void
   15941 unget_char ( int c)
   15942 {
   15943   ;
   15944 
   15945   ungetc (c, input);
   15946 }
   15947 
   15948 static int
   15949 read_signed_integer (void)
   15950 {
   15951   int c = get_char ();
   15952   int sign = 1;
   15953   int n = 0;
   15954 
   15955   ;
   15956   if (c == '-')
   15957     {
   15958       c = get_char ();
   15959       sign = -1;
   15960     }
   15961 
   15962   while (isdigit (c))
   15963     {
   15964       n = 10 * n + (c - '0');
   15965       c = get_char ();
   15966     }
   15967 
   15968   unget_char ( c);
   15969 
   15970   return sign * n;
   15971 }
   15972 
   15973 
   15974 
   15975 /*---------------------------------------------------------------.
   15976 | Lexical analyzer returns an integer on the stack and the token |
   15977 | NUM, or the ASCII character read if not a number.  Skips all   |
   15978 | blanks and tabs, returns 0 for EOF.                            |
   15979 `---------------------------------------------------------------*/
   15980 
   15981 static int
   15982 yylex (void)
   15983 {
   15984   static int init = 1;
   15985   int c;
   15986 
   15987   if (init)
   15988     {
   15989       init = 0;
   15990 
   15991     }
   15992 
   15993 
   15994 
   15995   /* Skip white space.  */
   15996   while ((c = get_char ()) == ' ' || c == '\t')
   15997     {
   15998 
   15999     }
   16000 
   16001   /* process numbers   */
   16002   if (c == '.' || isdigit (c))
   16003     {
   16004       unget_char ( c);
   16005       (yylval).ival = read_signed_integer ();
   16006       return NUM;
   16007     }
   16008 
   16009   /* Return end-of-file.  */
   16010   if (c == EOF)
   16011     return CALC_EOF;
   16012 
   16013   /* Return single chars. */
   16014   return c;
   16015 }
   16016 
   16017 static int
   16018 power (int base, int exponent)
   16019 {
   16020   int res = 1;
   16021   if (exponent < 0)
   16022     exit (3);
   16023   for (/* Niente */; exponent; --exponent)
   16024     res *= base;
   16025   return res;
   16026 }
   16027 
   16028 
   16029 int
   16030 main (int argc, const char **argv)
   16031 {
   16032   semantic_value result = 0;
   16033   int count = 0;
   16034   int status;
   16035 
   16036   /* This used to be alarm (10), but that isn't enough time for
   16037      a July 1995 vintage DEC Alphastation 200 4/100 system,
   16038      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   16039   alarm (100);
   16040 
   16041   if (argc == 2)
   16042     input = fopen (argv[1], "r");
   16043   else
   16044     input = stdin;
   16045 
   16046   if (!input)
   16047     {
   16048       perror (argv[1]);
   16049       return 3;
   16050     }
   16051 
   16052 
   16053   status = yyparse ();
   16054   if (global_result != result)
   16055     abort ();
   16056   if (global_count != count)
   16057     abort ();
   16058   return status;
   16059 }
   16060 _ATEOF
   16061 
   16062 
   16063 
   16064 
   16065 
   16066 $at_traceoff
   16067 echo "calc.at:555: bison -o calc.c calc.y"
   16068 echo calc.at:555 >$at_check_line_file
   16069 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   16070 at_status=$?
   16071 grep '^ *+' $at_stder1 >&2
   16072 grep -v '^ *+' $at_stder1 >$at_stderr
   16073 at_failed=false
   16074 $at_diff $at_devnull $at_stderr || at_failed=:
   16075 $at_diff $at_devnull $at_stdout || at_failed=:
   16076 case $at_status in
   16077    77) echo 77 > $at_status_file
   16078             exit 77;;
   16079    0) ;;
   16080    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16081       at_failed=:;;
   16082 esac
   16083 if $at_failed; then
   16084 
   16085   echo 1 > $at_status_file
   16086   exit 1
   16087 fi
   16088 
   16089 $at_traceon
   16090 
   16091    $at_traceoff
   16092 echo "calc.at:555: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   16093 echo calc.at:555 >$at_check_line_file
   16094 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   16095 at_status=$?
   16096 grep '^ *+' $at_stder1 >&2
   16097 grep -v '^ *+' $at_stder1 >$at_stderr
   16098 at_failed=false
   16099 echo stderr:; cat $at_stderr
   16100 echo stdout:; cat $at_stdout
   16101 case $at_status in
   16102    77) echo 77 > $at_status_file
   16103             exit 77;;
   16104    0) ;;
   16105    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16106       at_failed=:;;
   16107 esac
   16108 if $at_failed; then
   16109 
   16110   echo 1 > $at_status_file
   16111   exit 1
   16112 fi
   16113 
   16114 $at_traceon
   16115 
   16116 
   16117 # Test the priorities.
   16118 cat >input <<'_ATEOF'
   16119 1 + 2 * 3 = 7
   16120 1 + 2 * -3 = -5
   16121 
   16122 -1^2 = -1
   16123 (-1)^2 = 1
   16124 
   16125 ---1 = -1
   16126 
   16127 1 - 2 - 3 = -4
   16128 1 - (2 - 3) = 2
   16129 
   16130 2^2^3 = 256
   16131 (2^2)^3 = 64
   16132 _ATEOF
   16133 
   16134 $at_traceoff
   16135 echo "calc.at:555: \$PREPARSER ./calc input"
   16136 echo calc.at:555 >$at_check_line_file
   16137 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16138 at_status=$?
   16139 grep '^ *+' $at_stder1 >&2
   16140 grep -v '^ *+' $at_stder1 >$at_stderr
   16141 at_failed=false
   16142 echo stderr:; tee stderr <$at_stderr
   16143 $at_diff $at_devnull $at_stdout || at_failed=:
   16144 case $at_status in
   16145    77) echo 77 > $at_status_file
   16146             exit 77;;
   16147    0) ;;
   16148    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16149       at_failed=:;;
   16150 esac
   16151 if $at_failed; then
   16152 
   16153   echo 1 > $at_status_file
   16154   exit 1
   16155 fi
   16156 
   16157 $at_traceon
   16158 
   16159 
   16160 
   16161 # Some syntax errors.
   16162 cat >input <<'_ATEOF'
   16163 0 0
   16164 _ATEOF
   16165 
   16166 $at_traceoff
   16167 echo "calc.at:555: \$PREPARSER ./calc input"
   16168 echo calc.at:555 >$at_check_line_file
   16169 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16170 at_status=$?
   16171 grep '^ *+' $at_stder1 >&2
   16172 grep -v '^ *+' $at_stder1 >$at_stderr
   16173 at_failed=false
   16174 echo stderr:; tee stderr <$at_stderr
   16175 $at_diff $at_devnull $at_stdout || at_failed=:
   16176 case $at_status in
   16177    77) echo 77 > $at_status_file
   16178             exit 77;;
   16179    1) ;;
   16180    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16181       at_failed=:;;
   16182 esac
   16183 if $at_failed; then
   16184 
   16185   echo 1 > $at_status_file
   16186   exit 1
   16187 fi
   16188 
   16189 $at_traceon
   16190 
   16191 
   16192 # Normalize the observed and expected error messages, depending upon the
   16193 # options.
   16194 # 1. Remove the traces from observed.
   16195 sed '/^Starting/d
   16196 /^Entering/d
   16197 /^Stack/d
   16198 /^Reading/d
   16199 /^Reducing/d
   16200 /^Shifting/d
   16201 /^state/d
   16202 /^Cleanup:/d
   16203 /^Error:/d
   16204 /^Next/d
   16205 /^Discarding/d
   16206 / \$[0-9$]* = /d
   16207 /^yydestructor:/d' stderr >at-stderr
   16208 mv at-stderr stderr
   16209 # 2. Create the reference error message.
   16210 cat >expout <<'_ATEOF'
   16211 1.2: syntax error, unexpected number
   16212 _ATEOF
   16213 
   16214 # 3. If locations are not used, remove them.
   16215 sed 's/^[-0-9.]*: //' expout >at-expout
   16216 mv at-expout expout
   16217 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16218 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16219 mv at-expout expout
   16220 # 5. Check
   16221 $at_traceoff
   16222 echo "calc.at:555: cat stderr"
   16223 echo calc.at:555 >$at_check_line_file
   16224 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16225 at_status=$?
   16226 grep '^ *+' $at_stder1 >&2
   16227 grep -v '^ *+' $at_stder1 >$at_stderr
   16228 at_failed=false
   16229 $at_diff $at_devnull $at_stderr || at_failed=:
   16230 $at_diff expout $at_stdout || at_failed=:
   16231 case $at_status in
   16232    77) echo 77 > $at_status_file
   16233             exit 77;;
   16234    0) ;;
   16235    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16236       at_failed=:;;
   16237 esac
   16238 if $at_failed; then
   16239 
   16240   echo 1 > $at_status_file
   16241   exit 1
   16242 fi
   16243 
   16244 $at_traceon
   16245 
   16246 
   16247 cat >input <<'_ATEOF'
   16248 1//2
   16249 _ATEOF
   16250 
   16251 $at_traceoff
   16252 echo "calc.at:555: \$PREPARSER ./calc input"
   16253 echo calc.at:555 >$at_check_line_file
   16254 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16255 at_status=$?
   16256 grep '^ *+' $at_stder1 >&2
   16257 grep -v '^ *+' $at_stder1 >$at_stderr
   16258 at_failed=false
   16259 echo stderr:; tee stderr <$at_stderr
   16260 $at_diff $at_devnull $at_stdout || at_failed=:
   16261 case $at_status in
   16262    77) echo 77 > $at_status_file
   16263             exit 77;;
   16264    1) ;;
   16265    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16266       at_failed=:;;
   16267 esac
   16268 if $at_failed; then
   16269 
   16270   echo 1 > $at_status_file
   16271   exit 1
   16272 fi
   16273 
   16274 $at_traceon
   16275 
   16276 
   16277 # Normalize the observed and expected error messages, depending upon the
   16278 # options.
   16279 # 1. Remove the traces from observed.
   16280 sed '/^Starting/d
   16281 /^Entering/d
   16282 /^Stack/d
   16283 /^Reading/d
   16284 /^Reducing/d
   16285 /^Shifting/d
   16286 /^state/d
   16287 /^Cleanup:/d
   16288 /^Error:/d
   16289 /^Next/d
   16290 /^Discarding/d
   16291 / \$[0-9$]* = /d
   16292 /^yydestructor:/d' stderr >at-stderr
   16293 mv at-stderr stderr
   16294 # 2. Create the reference error message.
   16295 cat >expout <<'_ATEOF'
   16296 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   16297 _ATEOF
   16298 
   16299 # 3. If locations are not used, remove them.
   16300 sed 's/^[-0-9.]*: //' expout >at-expout
   16301 mv at-expout expout
   16302 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16303 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16304 mv at-expout expout
   16305 # 5. Check
   16306 $at_traceoff
   16307 echo "calc.at:555: cat stderr"
   16308 echo calc.at:555 >$at_check_line_file
   16309 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16310 at_status=$?
   16311 grep '^ *+' $at_stder1 >&2
   16312 grep -v '^ *+' $at_stder1 >$at_stderr
   16313 at_failed=false
   16314 $at_diff $at_devnull $at_stderr || at_failed=:
   16315 $at_diff expout $at_stdout || at_failed=:
   16316 case $at_status in
   16317    77) echo 77 > $at_status_file
   16318             exit 77;;
   16319    0) ;;
   16320    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16321       at_failed=:;;
   16322 esac
   16323 if $at_failed; then
   16324 
   16325   echo 1 > $at_status_file
   16326   exit 1
   16327 fi
   16328 
   16329 $at_traceon
   16330 
   16331 
   16332 cat >input <<'_ATEOF'
   16333 error
   16334 _ATEOF
   16335 
   16336 $at_traceoff
   16337 echo "calc.at:555: \$PREPARSER ./calc input"
   16338 echo calc.at:555 >$at_check_line_file
   16339 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16340 at_status=$?
   16341 grep '^ *+' $at_stder1 >&2
   16342 grep -v '^ *+' $at_stder1 >$at_stderr
   16343 at_failed=false
   16344 echo stderr:; tee stderr <$at_stderr
   16345 $at_diff $at_devnull $at_stdout || at_failed=:
   16346 case $at_status in
   16347    77) echo 77 > $at_status_file
   16348             exit 77;;
   16349    1) ;;
   16350    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16351       at_failed=:;;
   16352 esac
   16353 if $at_failed; then
   16354 
   16355   echo 1 > $at_status_file
   16356   exit 1
   16357 fi
   16358 
   16359 $at_traceon
   16360 
   16361 
   16362 # Normalize the observed and expected error messages, depending upon the
   16363 # options.
   16364 # 1. Remove the traces from observed.
   16365 sed '/^Starting/d
   16366 /^Entering/d
   16367 /^Stack/d
   16368 /^Reading/d
   16369 /^Reducing/d
   16370 /^Shifting/d
   16371 /^state/d
   16372 /^Cleanup:/d
   16373 /^Error:/d
   16374 /^Next/d
   16375 /^Discarding/d
   16376 / \$[0-9$]* = /d
   16377 /^yydestructor:/d' stderr >at-stderr
   16378 mv at-stderr stderr
   16379 # 2. Create the reference error message.
   16380 cat >expout <<'_ATEOF'
   16381 1.0: syntax error, unexpected $undefined
   16382 _ATEOF
   16383 
   16384 # 3. If locations are not used, remove them.
   16385 sed 's/^[-0-9.]*: //' expout >at-expout
   16386 mv at-expout expout
   16387 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16388 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16389 mv at-expout expout
   16390 # 5. Check
   16391 $at_traceoff
   16392 echo "calc.at:555: cat stderr"
   16393 echo calc.at:555 >$at_check_line_file
   16394 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16395 at_status=$?
   16396 grep '^ *+' $at_stder1 >&2
   16397 grep -v '^ *+' $at_stder1 >$at_stderr
   16398 at_failed=false
   16399 $at_diff $at_devnull $at_stderr || at_failed=:
   16400 $at_diff expout $at_stdout || at_failed=:
   16401 case $at_status in
   16402    77) echo 77 > $at_status_file
   16403             exit 77;;
   16404    0) ;;
   16405    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16406       at_failed=:;;
   16407 esac
   16408 if $at_failed; then
   16409 
   16410   echo 1 > $at_status_file
   16411   exit 1
   16412 fi
   16413 
   16414 $at_traceon
   16415 
   16416 
   16417 cat >input <<'_ATEOF'
   16418 1 = 2 = 3
   16419 _ATEOF
   16420 
   16421 $at_traceoff
   16422 echo "calc.at:555: \$PREPARSER ./calc input"
   16423 echo calc.at:555 >$at_check_line_file
   16424 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16425 at_status=$?
   16426 grep '^ *+' $at_stder1 >&2
   16427 grep -v '^ *+' $at_stder1 >$at_stderr
   16428 at_failed=false
   16429 echo stderr:; tee stderr <$at_stderr
   16430 $at_diff $at_devnull $at_stdout || at_failed=:
   16431 case $at_status in
   16432    77) echo 77 > $at_status_file
   16433             exit 77;;
   16434    1) ;;
   16435    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16436       at_failed=:;;
   16437 esac
   16438 if $at_failed; then
   16439 
   16440   echo 1 > $at_status_file
   16441   exit 1
   16442 fi
   16443 
   16444 $at_traceon
   16445 
   16446 
   16447 # Normalize the observed and expected error messages, depending upon the
   16448 # options.
   16449 # 1. Remove the traces from observed.
   16450 sed '/^Starting/d
   16451 /^Entering/d
   16452 /^Stack/d
   16453 /^Reading/d
   16454 /^Reducing/d
   16455 /^Shifting/d
   16456 /^state/d
   16457 /^Cleanup:/d
   16458 /^Error:/d
   16459 /^Next/d
   16460 /^Discarding/d
   16461 / \$[0-9$]* = /d
   16462 /^yydestructor:/d' stderr >at-stderr
   16463 mv at-stderr stderr
   16464 # 2. Create the reference error message.
   16465 cat >expout <<'_ATEOF'
   16466 1.6: syntax error, unexpected '='
   16467 _ATEOF
   16468 
   16469 # 3. If locations are not used, remove them.
   16470 sed 's/^[-0-9.]*: //' expout >at-expout
   16471 mv at-expout expout
   16472 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16473 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16474 mv at-expout expout
   16475 # 5. Check
   16476 $at_traceoff
   16477 echo "calc.at:555: cat stderr"
   16478 echo calc.at:555 >$at_check_line_file
   16479 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16480 at_status=$?
   16481 grep '^ *+' $at_stder1 >&2
   16482 grep -v '^ *+' $at_stder1 >$at_stderr
   16483 at_failed=false
   16484 $at_diff $at_devnull $at_stderr || at_failed=:
   16485 $at_diff expout $at_stdout || at_failed=:
   16486 case $at_status in
   16487    77) echo 77 > $at_status_file
   16488             exit 77;;
   16489    0) ;;
   16490    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16491       at_failed=:;;
   16492 esac
   16493 if $at_failed; then
   16494 
   16495   echo 1 > $at_status_file
   16496   exit 1
   16497 fi
   16498 
   16499 $at_traceon
   16500 
   16501 
   16502 cat >input <<'_ATEOF'
   16503 
   16504 +1
   16505 _ATEOF
   16506 
   16507 $at_traceoff
   16508 echo "calc.at:555: \$PREPARSER ./calc input"
   16509 echo calc.at:555 >$at_check_line_file
   16510 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16511 at_status=$?
   16512 grep '^ *+' $at_stder1 >&2
   16513 grep -v '^ *+' $at_stder1 >$at_stderr
   16514 at_failed=false
   16515 echo stderr:; tee stderr <$at_stderr
   16516 $at_diff $at_devnull $at_stdout || at_failed=:
   16517 case $at_status in
   16518    77) echo 77 > $at_status_file
   16519             exit 77;;
   16520    1) ;;
   16521    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16522       at_failed=:;;
   16523 esac
   16524 if $at_failed; then
   16525 
   16526   echo 1 > $at_status_file
   16527   exit 1
   16528 fi
   16529 
   16530 $at_traceon
   16531 
   16532 
   16533 # Normalize the observed and expected error messages, depending upon the
   16534 # options.
   16535 # 1. Remove the traces from observed.
   16536 sed '/^Starting/d
   16537 /^Entering/d
   16538 /^Stack/d
   16539 /^Reading/d
   16540 /^Reducing/d
   16541 /^Shifting/d
   16542 /^state/d
   16543 /^Cleanup:/d
   16544 /^Error:/d
   16545 /^Next/d
   16546 /^Discarding/d
   16547 / \$[0-9$]* = /d
   16548 /^yydestructor:/d' stderr >at-stderr
   16549 mv at-stderr stderr
   16550 # 2. Create the reference error message.
   16551 cat >expout <<'_ATEOF'
   16552 2.0: syntax error, unexpected '+'
   16553 _ATEOF
   16554 
   16555 # 3. If locations are not used, remove them.
   16556 sed 's/^[-0-9.]*: //' expout >at-expout
   16557 mv at-expout expout
   16558 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16559 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16560 mv at-expout expout
   16561 # 5. Check
   16562 $at_traceoff
   16563 echo "calc.at:555: cat stderr"
   16564 echo calc.at:555 >$at_check_line_file
   16565 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16566 at_status=$?
   16567 grep '^ *+' $at_stder1 >&2
   16568 grep -v '^ *+' $at_stder1 >$at_stderr
   16569 at_failed=false
   16570 $at_diff $at_devnull $at_stderr || at_failed=:
   16571 $at_diff expout $at_stdout || at_failed=:
   16572 case $at_status in
   16573    77) echo 77 > $at_status_file
   16574             exit 77;;
   16575    0) ;;
   16576    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16577       at_failed=:;;
   16578 esac
   16579 if $at_failed; then
   16580 
   16581   echo 1 > $at_status_file
   16582   exit 1
   16583 fi
   16584 
   16585 $at_traceon
   16586 
   16587 
   16588 # Exercise error messages with EOF: work on an empty file.
   16589 $at_traceoff
   16590 echo "calc.at:555: \$PREPARSER ./calc /dev/null"
   16591 echo calc.at:555 >$at_check_line_file
   16592 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   16593 at_status=$?
   16594 grep '^ *+' $at_stder1 >&2
   16595 grep -v '^ *+' $at_stder1 >$at_stderr
   16596 at_failed=false
   16597 echo stderr:; tee stderr <$at_stderr
   16598 $at_diff $at_devnull $at_stdout || at_failed=:
   16599 case $at_status in
   16600    77) echo 77 > $at_status_file
   16601             exit 77;;
   16602    1) ;;
   16603    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16604       at_failed=:;;
   16605 esac
   16606 if $at_failed; then
   16607 
   16608   echo 1 > $at_status_file
   16609   exit 1
   16610 fi
   16611 
   16612 $at_traceon
   16613 
   16614 
   16615 # Normalize the observed and expected error messages, depending upon the
   16616 # options.
   16617 # 1. Remove the traces from observed.
   16618 sed '/^Starting/d
   16619 /^Entering/d
   16620 /^Stack/d
   16621 /^Reading/d
   16622 /^Reducing/d
   16623 /^Shifting/d
   16624 /^state/d
   16625 /^Cleanup:/d
   16626 /^Error:/d
   16627 /^Next/d
   16628 /^Discarding/d
   16629 / \$[0-9$]* = /d
   16630 /^yydestructor:/d' stderr >at-stderr
   16631 mv at-stderr stderr
   16632 # 2. Create the reference error message.
   16633 cat >expout <<'_ATEOF'
   16634 1.0: syntax error, unexpected end of input
   16635 _ATEOF
   16636 
   16637 # 3. If locations are not used, remove them.
   16638 sed 's/^[-0-9.]*: //' expout >at-expout
   16639 mv at-expout expout
   16640 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16641 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16642 mv at-expout expout
   16643 # 5. Check
   16644 $at_traceoff
   16645 echo "calc.at:555: cat stderr"
   16646 echo calc.at:555 >$at_check_line_file
   16647 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16648 at_status=$?
   16649 grep '^ *+' $at_stder1 >&2
   16650 grep -v '^ *+' $at_stder1 >$at_stderr
   16651 at_failed=false
   16652 $at_diff $at_devnull $at_stderr || at_failed=:
   16653 $at_diff expout $at_stdout || at_failed=:
   16654 case $at_status in
   16655    77) echo 77 > $at_status_file
   16656             exit 77;;
   16657    0) ;;
   16658    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16659       at_failed=:;;
   16660 esac
   16661 if $at_failed; then
   16662 
   16663   echo 1 > $at_status_file
   16664   exit 1
   16665 fi
   16666 
   16667 $at_traceon
   16668 
   16669 
   16670 
   16671 # Exercise the error token: without it, we die at the first error,
   16672 # hence be sure to
   16673 #
   16674 # - have several errors which exercise different shift/discardings
   16675 #   - (): nothing to pop, nothing to discard
   16676 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   16677 #   - (* * *): nothing to pop, a lot to discard
   16678 #   - (1 + 2 * *): some to pop and discard
   16679 #
   16680 # - test the action associated to `error'
   16681 #
   16682 # - check the look-ahead that triggers an error is not discarded
   16683 #   when we enter error recovery.  Below, the look-ahead causing the
   16684 #   first error is ")", which is needed to recover from the error and
   16685 #   produce the "0" that triggers the "0 != 1" error.
   16686 #
   16687 cat >input <<'_ATEOF'
   16688 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   16689 _ATEOF
   16690 
   16691 $at_traceoff
   16692 echo "calc.at:555: \$PREPARSER ./calc input"
   16693 echo calc.at:555 >$at_check_line_file
   16694 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16695 at_status=$?
   16696 grep '^ *+' $at_stder1 >&2
   16697 grep -v '^ *+' $at_stder1 >$at_stderr
   16698 at_failed=false
   16699 echo stderr:; tee stderr <$at_stderr
   16700 $at_diff $at_devnull $at_stdout || at_failed=:
   16701 case $at_status in
   16702    77) echo 77 > $at_status_file
   16703             exit 77;;
   16704    0) ;;
   16705    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16706       at_failed=:;;
   16707 esac
   16708 if $at_failed; then
   16709 
   16710   echo 1 > $at_status_file
   16711   exit 1
   16712 fi
   16713 
   16714 $at_traceon
   16715 
   16716 
   16717 # Normalize the observed and expected error messages, depending upon the
   16718 # options.
   16719 # 1. Remove the traces from observed.
   16720 sed '/^Starting/d
   16721 /^Entering/d
   16722 /^Stack/d
   16723 /^Reading/d
   16724 /^Reducing/d
   16725 /^Shifting/d
   16726 /^state/d
   16727 /^Cleanup:/d
   16728 /^Error:/d
   16729 /^Next/d
   16730 /^Discarding/d
   16731 / \$[0-9$]* = /d
   16732 /^yydestructor:/d' stderr >at-stderr
   16733 mv at-stderr stderr
   16734 # 2. Create the reference error message.
   16735 cat >expout <<'_ATEOF'
   16736 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   16737 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   16738 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   16739 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   16740 calc: error: 4444 != 1
   16741 _ATEOF
   16742 
   16743 # 3. If locations are not used, remove them.
   16744 sed 's/^[-0-9.]*: //' expout >at-expout
   16745 mv at-expout expout
   16746 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16747 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16748 mv at-expout expout
   16749 # 5. Check
   16750 $at_traceoff
   16751 echo "calc.at:555: cat stderr"
   16752 echo calc.at:555 >$at_check_line_file
   16753 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16754 at_status=$?
   16755 grep '^ *+' $at_stder1 >&2
   16756 grep -v '^ *+' $at_stder1 >$at_stderr
   16757 at_failed=false
   16758 $at_diff $at_devnull $at_stderr || at_failed=:
   16759 $at_diff expout $at_stdout || at_failed=:
   16760 case $at_status in
   16761    77) echo 77 > $at_status_file
   16762             exit 77;;
   16763    0) ;;
   16764    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16765       at_failed=:;;
   16766 esac
   16767 if $at_failed; then
   16768 
   16769   echo 1 > $at_status_file
   16770   exit 1
   16771 fi
   16772 
   16773 $at_traceon
   16774 
   16775 
   16776 
   16777 # The same, but this time exercising explicitly triggered syntax errors.
   16778 # POSIX says the look-ahead causing the error should not be discarded.
   16779 cat >input <<'_ATEOF'
   16780 (!) + (0 0) = 1
   16781 _ATEOF
   16782 
   16783 $at_traceoff
   16784 echo "calc.at:555: \$PREPARSER ./calc input"
   16785 echo calc.at:555 >$at_check_line_file
   16786 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16787 at_status=$?
   16788 grep '^ *+' $at_stder1 >&2
   16789 grep -v '^ *+' $at_stder1 >$at_stderr
   16790 at_failed=false
   16791 echo stderr:; tee stderr <$at_stderr
   16792 $at_diff $at_devnull $at_stdout || at_failed=:
   16793 case $at_status in
   16794    77) echo 77 > $at_status_file
   16795             exit 77;;
   16796    0) ;;
   16797    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16798       at_failed=:;;
   16799 esac
   16800 if $at_failed; then
   16801 
   16802   echo 1 > $at_status_file
   16803   exit 1
   16804 fi
   16805 
   16806 $at_traceon
   16807 
   16808 
   16809 # Normalize the observed and expected error messages, depending upon the
   16810 # options.
   16811 # 1. Remove the traces from observed.
   16812 sed '/^Starting/d
   16813 /^Entering/d
   16814 /^Stack/d
   16815 /^Reading/d
   16816 /^Reducing/d
   16817 /^Shifting/d
   16818 /^state/d
   16819 /^Cleanup:/d
   16820 /^Error:/d
   16821 /^Next/d
   16822 /^Discarding/d
   16823 / \$[0-9$]* = /d
   16824 /^yydestructor:/d' stderr >at-stderr
   16825 mv at-stderr stderr
   16826 # 2. Create the reference error message.
   16827 cat >expout <<'_ATEOF'
   16828 1.9: syntax error, unexpected number
   16829 calc: error: 2222 != 1
   16830 _ATEOF
   16831 
   16832 # 3. If locations are not used, remove them.
   16833 sed 's/^[-0-9.]*: //' expout >at-expout
   16834 mv at-expout expout
   16835 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16836 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16837 mv at-expout expout
   16838 # 5. Check
   16839 $at_traceoff
   16840 echo "calc.at:555: cat stderr"
   16841 echo calc.at:555 >$at_check_line_file
   16842 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16843 at_status=$?
   16844 grep '^ *+' $at_stder1 >&2
   16845 grep -v '^ *+' $at_stder1 >$at_stderr
   16846 at_failed=false
   16847 $at_diff $at_devnull $at_stderr || at_failed=:
   16848 $at_diff expout $at_stdout || at_failed=:
   16849 case $at_status in
   16850    77) echo 77 > $at_status_file
   16851             exit 77;;
   16852    0) ;;
   16853    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16854       at_failed=:;;
   16855 esac
   16856 if $at_failed; then
   16857 
   16858   echo 1 > $at_status_file
   16859   exit 1
   16860 fi
   16861 
   16862 $at_traceon
   16863 
   16864 
   16865 cat >input <<'_ATEOF'
   16866 (- *) + (0 0) = 1
   16867 _ATEOF
   16868 
   16869 $at_traceoff
   16870 echo "calc.at:555: \$PREPARSER ./calc input"
   16871 echo calc.at:555 >$at_check_line_file
   16872 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16873 at_status=$?
   16874 grep '^ *+' $at_stder1 >&2
   16875 grep -v '^ *+' $at_stder1 >$at_stderr
   16876 at_failed=false
   16877 echo stderr:; tee stderr <$at_stderr
   16878 $at_diff $at_devnull $at_stdout || at_failed=:
   16879 case $at_status in
   16880    77) echo 77 > $at_status_file
   16881             exit 77;;
   16882    0) ;;
   16883    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16884       at_failed=:;;
   16885 esac
   16886 if $at_failed; then
   16887 
   16888   echo 1 > $at_status_file
   16889   exit 1
   16890 fi
   16891 
   16892 $at_traceon
   16893 
   16894 
   16895 # Normalize the observed and expected error messages, depending upon the
   16896 # options.
   16897 # 1. Remove the traces from observed.
   16898 sed '/^Starting/d
   16899 /^Entering/d
   16900 /^Stack/d
   16901 /^Reading/d
   16902 /^Reducing/d
   16903 /^Shifting/d
   16904 /^state/d
   16905 /^Cleanup:/d
   16906 /^Error:/d
   16907 /^Next/d
   16908 /^Discarding/d
   16909 / \$[0-9$]* = /d
   16910 /^yydestructor:/d' stderr >at-stderr
   16911 mv at-stderr stderr
   16912 # 2. Create the reference error message.
   16913 cat >expout <<'_ATEOF'
   16914 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   16915 1.11: syntax error, unexpected number
   16916 calc: error: 2222 != 1
   16917 _ATEOF
   16918 
   16919 # 3. If locations are not used, remove them.
   16920 sed 's/^[-0-9.]*: //' expout >at-expout
   16921 mv at-expout expout
   16922 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16923 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16924 mv at-expout expout
   16925 # 5. Check
   16926 $at_traceoff
   16927 echo "calc.at:555: cat stderr"
   16928 echo calc.at:555 >$at_check_line_file
   16929 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16930 at_status=$?
   16931 grep '^ *+' $at_stder1 >&2
   16932 grep -v '^ *+' $at_stder1 >$at_stderr
   16933 at_failed=false
   16934 $at_diff $at_devnull $at_stderr || at_failed=:
   16935 $at_diff expout $at_stdout || at_failed=:
   16936 case $at_status in
   16937    77) echo 77 > $at_status_file
   16938             exit 77;;
   16939    0) ;;
   16940    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16941       at_failed=:;;
   16942 esac
   16943 if $at_failed; then
   16944 
   16945   echo 1 > $at_status_file
   16946   exit 1
   16947 fi
   16948 
   16949 $at_traceon
   16950 
   16951 
   16952 
   16953 
   16954 
   16955 
   16956 
   16957 
   16958 
   16959 
   16960 
   16961 
   16962 
   16963 
   16964 
   16965 
   16966 
   16967 
   16968 
   16969 
   16970 
   16971 
   16972 
   16973 
   16974       $at_traceoff
   16975       $at_times_p && times >$at_times_file
   16976     ) 5>&1 2>&1 | eval $at_tee_pipe
   16977     at_status=`cat $at_status_file`
   16978     ;;
   16979 
   16980   75 ) # 75. calc.at:556: Calculator %yacc
   16981     at_setup_line='calc.at:556'
   16982     at_desc='Calculator %yacc'
   16983     $at_quiet $ECHO_N " 75: Calculator %yacc                             $ECHO_C"
   16984     at_xfail=no
   16985     (
   16986       echo "75. calc.at:556: testing ..."
   16987       $at_traceon
   16988 
   16989 
   16990 
   16991 
   16992 
   16993 
   16994 
   16995 
   16996 # Using yacc.c?
   16997 
   16998 
   16999 
   17000 
   17001 
   17002 
   17003 
   17004 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   17005 
   17006 # yyerror always sees the locations (when activated), except if
   17007 # yacc & pure & !param.
   17008 
   17009 
   17010 # The interface is pure: either because %pure-parser, or because we
   17011 # are using the C++ parsers.
   17012 
   17013 
   17014 
   17015 
   17016 
   17017 
   17018 
   17019 
   17020 
   17021 
   17022 
   17023 
   17024 cat >calc.y <<'_ATEOF'
   17025 %{
   17026 #ifdef HAVE_CONFIG_H
   17027 # include <config.h>
   17028   /* We don't need perfect functions for these tests. */
   17029 # undef malloc
   17030 # undef memcmp
   17031 # undef realloc
   17032 #endif
   17033 %}
   17034 
   17035 /* Infix notation calculator--calc */
   17036 %yacc
   17037 
   17038 %{
   17039 #include <stdio.h>
   17040 
   17041 #include <stdlib.h>
   17042 #include <string.h>
   17043 #if HAVE_UNISTD_H
   17044 # include <unistd.h>
   17045 #else
   17046 # undef alarm
   17047 # define alarm(seconds) /* empty */
   17048 #endif
   17049 #include <ctype.h>
   17050 #define USE(Var)
   17051 
   17052 /* Exercise pre-prologue dependency to %union.  */
   17053 typedef int semantic_value;
   17054 
   17055 static semantic_value global_result = 0;
   17056 static int global_count = 0;
   17057 %}
   17058 
   17059 /* Exercise %union. */
   17060 %union
   17061 {
   17062   semantic_value ival;
   17063 };
   17064 
   17065 %{
   17066 static int power (int base, int exponent);
   17067 /* yyerror receives the location if:
   17068    - %location & %pure & %glr
   17069    - %location & %pure & %yacc & %parse-param. */
   17070 static void yyerror (
   17071 
   17072                      const char *s
   17073                      );
   17074 static int yylex (void);
   17075 static int get_char (void);
   17076 static void unget_char ( int c);
   17077 %}
   17078 
   17079 
   17080 
   17081 /* Bison Declarations */
   17082 %token CALC_EOF 0 "end of input"
   17083 %token <ival> NUM "number"
   17084 %type  <ival> exp
   17085 
   17086 %nonassoc '=' /* comparison	       */
   17087 %left '-' '+'
   17088 %left '*' '/'
   17089 %left NEG     /* negation--unary minus */
   17090 %right '^'    /* exponentiation        */
   17091 
   17092 /* Grammar follows */
   17093 %%
   17094 input:
   17095   line
   17096 | input line         {  }
   17097 ;
   17098 
   17099 line:
   17100   '\n'
   17101 | exp '\n'           { USE ($1); }
   17102 ;
   17103 
   17104 exp:
   17105   NUM                { $$ = $1;             }
   17106 | exp '=' exp
   17107   {
   17108     if ($1 != $3)
   17109       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   17110     $$ = $1;
   17111   }
   17112 | exp '+' exp        { $$ = $1 + $3;        }
   17113 | exp '-' exp        { $$ = $1 - $3;        }
   17114 | exp '*' exp        { $$ = $1 * $3;        }
   17115 | exp '/' exp        { $$ = $1 / $3;        }
   17116 | '-' exp  %prec NEG { $$ = -$2;            }
   17117 | exp '^' exp        { $$ = power ($1, $3); }
   17118 | '(' exp ')'        { $$ = $2;             }
   17119 | '(' error ')'      { $$ = 1111;           }
   17120 | '!'                { $$ = 0; YYERROR;     }
   17121 | '-' error          { $$ = 0; YYERROR;     }
   17122 ;
   17123 %%
   17124 /* The input.  */
   17125 static FILE *input;
   17126 
   17127 static void
   17128 yyerror (
   17129 
   17130          const char *s)
   17131 {
   17132 
   17133 
   17134   fprintf (stderr, "%s\n", s);
   17135 }
   17136 
   17137 
   17138 
   17139 static int
   17140 get_char (void)
   17141 {
   17142   int res = getc (input);
   17143   ;
   17144 
   17145   return res;
   17146 }
   17147 
   17148 
   17149 static void
   17150 unget_char ( int c)
   17151 {
   17152   ;
   17153 
   17154   ungetc (c, input);
   17155 }
   17156 
   17157 static int
   17158 read_signed_integer (void)
   17159 {
   17160   int c = get_char ();
   17161   int sign = 1;
   17162   int n = 0;
   17163 
   17164   ;
   17165   if (c == '-')
   17166     {
   17167       c = get_char ();
   17168       sign = -1;
   17169     }
   17170 
   17171   while (isdigit (c))
   17172     {
   17173       n = 10 * n + (c - '0');
   17174       c = get_char ();
   17175     }
   17176 
   17177   unget_char ( c);
   17178 
   17179   return sign * n;
   17180 }
   17181 
   17182 
   17183 
   17184 /*---------------------------------------------------------------.
   17185 | Lexical analyzer returns an integer on the stack and the token |
   17186 | NUM, or the ASCII character read if not a number.  Skips all   |
   17187 | blanks and tabs, returns 0 for EOF.                            |
   17188 `---------------------------------------------------------------*/
   17189 
   17190 static int
   17191 yylex (void)
   17192 {
   17193   static int init = 1;
   17194   int c;
   17195 
   17196   if (init)
   17197     {
   17198       init = 0;
   17199 
   17200     }
   17201 
   17202 
   17203 
   17204   /* Skip white space.  */
   17205   while ((c = get_char ()) == ' ' || c == '\t')
   17206     {
   17207 
   17208     }
   17209 
   17210   /* process numbers   */
   17211   if (c == '.' || isdigit (c))
   17212     {
   17213       unget_char ( c);
   17214       (yylval).ival = read_signed_integer ();
   17215       return NUM;
   17216     }
   17217 
   17218   /* Return end-of-file.  */
   17219   if (c == EOF)
   17220     return CALC_EOF;
   17221 
   17222   /* Return single chars. */
   17223   return c;
   17224 }
   17225 
   17226 static int
   17227 power (int base, int exponent)
   17228 {
   17229   int res = 1;
   17230   if (exponent < 0)
   17231     exit (3);
   17232   for (/* Niente */; exponent; --exponent)
   17233     res *= base;
   17234   return res;
   17235 }
   17236 
   17237 
   17238 int
   17239 main (int argc, const char **argv)
   17240 {
   17241   semantic_value result = 0;
   17242   int count = 0;
   17243   int status;
   17244 
   17245   /* This used to be alarm (10), but that isn't enough time for
   17246      a July 1995 vintage DEC Alphastation 200 4/100 system,
   17247      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   17248   alarm (100);
   17249 
   17250   if (argc == 2)
   17251     input = fopen (argv[1], "r");
   17252   else
   17253     input = stdin;
   17254 
   17255   if (!input)
   17256     {
   17257       perror (argv[1]);
   17258       return 3;
   17259     }
   17260 
   17261 
   17262   status = yyparse ();
   17263   if (global_result != result)
   17264     abort ();
   17265   if (global_count != count)
   17266     abort ();
   17267   return status;
   17268 }
   17269 _ATEOF
   17270 
   17271 
   17272 
   17273 
   17274 
   17275 $at_traceoff
   17276 echo "calc.at:556: bison -o calc.c calc.y"
   17277 echo calc.at:556 >$at_check_line_file
   17278 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   17279 at_status=$?
   17280 grep '^ *+' $at_stder1 >&2
   17281 grep -v '^ *+' $at_stder1 >$at_stderr
   17282 at_failed=false
   17283 $at_diff $at_devnull $at_stderr || at_failed=:
   17284 $at_diff $at_devnull $at_stdout || at_failed=:
   17285 case $at_status in
   17286    77) echo 77 > $at_status_file
   17287             exit 77;;
   17288    0) ;;
   17289    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17290       at_failed=:;;
   17291 esac
   17292 if $at_failed; then
   17293 
   17294   echo 1 > $at_status_file
   17295   exit 1
   17296 fi
   17297 
   17298 $at_traceon
   17299 
   17300    $at_traceoff
   17301 echo "calc.at:556: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   17302 echo calc.at:556 >$at_check_line_file
   17303 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   17304 at_status=$?
   17305 grep '^ *+' $at_stder1 >&2
   17306 grep -v '^ *+' $at_stder1 >$at_stderr
   17307 at_failed=false
   17308 echo stderr:; cat $at_stderr
   17309 echo stdout:; cat $at_stdout
   17310 case $at_status in
   17311    77) echo 77 > $at_status_file
   17312             exit 77;;
   17313    0) ;;
   17314    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17315       at_failed=:;;
   17316 esac
   17317 if $at_failed; then
   17318 
   17319   echo 1 > $at_status_file
   17320   exit 1
   17321 fi
   17322 
   17323 $at_traceon
   17324 
   17325 
   17326 # Test the priorities.
   17327 cat >input <<'_ATEOF'
   17328 1 + 2 * 3 = 7
   17329 1 + 2 * -3 = -5
   17330 
   17331 -1^2 = -1
   17332 (-1)^2 = 1
   17333 
   17334 ---1 = -1
   17335 
   17336 1 - 2 - 3 = -4
   17337 1 - (2 - 3) = 2
   17338 
   17339 2^2^3 = 256
   17340 (2^2)^3 = 64
   17341 _ATEOF
   17342 
   17343 $at_traceoff
   17344 echo "calc.at:556: \$PREPARSER ./calc input"
   17345 echo calc.at:556 >$at_check_line_file
   17346 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17347 at_status=$?
   17348 grep '^ *+' $at_stder1 >&2
   17349 grep -v '^ *+' $at_stder1 >$at_stderr
   17350 at_failed=false
   17351 echo stderr:; tee stderr <$at_stderr
   17352 $at_diff $at_devnull $at_stdout || at_failed=:
   17353 case $at_status in
   17354    77) echo 77 > $at_status_file
   17355             exit 77;;
   17356    0) ;;
   17357    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17358       at_failed=:;;
   17359 esac
   17360 if $at_failed; then
   17361 
   17362   echo 1 > $at_status_file
   17363   exit 1
   17364 fi
   17365 
   17366 $at_traceon
   17367 
   17368 
   17369 
   17370 # Some syntax errors.
   17371 cat >input <<'_ATEOF'
   17372 0 0
   17373 _ATEOF
   17374 
   17375 $at_traceoff
   17376 echo "calc.at:556: \$PREPARSER ./calc input"
   17377 echo calc.at:556 >$at_check_line_file
   17378 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17379 at_status=$?
   17380 grep '^ *+' $at_stder1 >&2
   17381 grep -v '^ *+' $at_stder1 >$at_stderr
   17382 at_failed=false
   17383 echo stderr:; tee stderr <$at_stderr
   17384 $at_diff $at_devnull $at_stdout || at_failed=:
   17385 case $at_status in
   17386    77) echo 77 > $at_status_file
   17387             exit 77;;
   17388    1) ;;
   17389    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17390       at_failed=:;;
   17391 esac
   17392 if $at_failed; then
   17393 
   17394   echo 1 > $at_status_file
   17395   exit 1
   17396 fi
   17397 
   17398 $at_traceon
   17399 
   17400 
   17401 # Normalize the observed and expected error messages, depending upon the
   17402 # options.
   17403 # 1. Remove the traces from observed.
   17404 sed '/^Starting/d
   17405 /^Entering/d
   17406 /^Stack/d
   17407 /^Reading/d
   17408 /^Reducing/d
   17409 /^Shifting/d
   17410 /^state/d
   17411 /^Cleanup:/d
   17412 /^Error:/d
   17413 /^Next/d
   17414 /^Discarding/d
   17415 / \$[0-9$]* = /d
   17416 /^yydestructor:/d' stderr >at-stderr
   17417 mv at-stderr stderr
   17418 # 2. Create the reference error message.
   17419 cat >expout <<'_ATEOF'
   17420 1.2: syntax error, unexpected number
   17421 _ATEOF
   17422 
   17423 # 3. If locations are not used, remove them.
   17424 sed 's/^[-0-9.]*: //' expout >at-expout
   17425 mv at-expout expout
   17426 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17427 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17428 mv at-expout expout
   17429 # 5. Check
   17430 $at_traceoff
   17431 echo "calc.at:556: cat stderr"
   17432 echo calc.at:556 >$at_check_line_file
   17433 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17434 at_status=$?
   17435 grep '^ *+' $at_stder1 >&2
   17436 grep -v '^ *+' $at_stder1 >$at_stderr
   17437 at_failed=false
   17438 $at_diff $at_devnull $at_stderr || at_failed=:
   17439 $at_diff expout $at_stdout || at_failed=:
   17440 case $at_status in
   17441    77) echo 77 > $at_status_file
   17442             exit 77;;
   17443    0) ;;
   17444    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17445       at_failed=:;;
   17446 esac
   17447 if $at_failed; then
   17448 
   17449   echo 1 > $at_status_file
   17450   exit 1
   17451 fi
   17452 
   17453 $at_traceon
   17454 
   17455 
   17456 cat >input <<'_ATEOF'
   17457 1//2
   17458 _ATEOF
   17459 
   17460 $at_traceoff
   17461 echo "calc.at:556: \$PREPARSER ./calc input"
   17462 echo calc.at:556 >$at_check_line_file
   17463 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17464 at_status=$?
   17465 grep '^ *+' $at_stder1 >&2
   17466 grep -v '^ *+' $at_stder1 >$at_stderr
   17467 at_failed=false
   17468 echo stderr:; tee stderr <$at_stderr
   17469 $at_diff $at_devnull $at_stdout || at_failed=:
   17470 case $at_status in
   17471    77) echo 77 > $at_status_file
   17472             exit 77;;
   17473    1) ;;
   17474    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17475       at_failed=:;;
   17476 esac
   17477 if $at_failed; then
   17478 
   17479   echo 1 > $at_status_file
   17480   exit 1
   17481 fi
   17482 
   17483 $at_traceon
   17484 
   17485 
   17486 # Normalize the observed and expected error messages, depending upon the
   17487 # options.
   17488 # 1. Remove the traces from observed.
   17489 sed '/^Starting/d
   17490 /^Entering/d
   17491 /^Stack/d
   17492 /^Reading/d
   17493 /^Reducing/d
   17494 /^Shifting/d
   17495 /^state/d
   17496 /^Cleanup:/d
   17497 /^Error:/d
   17498 /^Next/d
   17499 /^Discarding/d
   17500 / \$[0-9$]* = /d
   17501 /^yydestructor:/d' stderr >at-stderr
   17502 mv at-stderr stderr
   17503 # 2. Create the reference error message.
   17504 cat >expout <<'_ATEOF'
   17505 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   17506 _ATEOF
   17507 
   17508 # 3. If locations are not used, remove them.
   17509 sed 's/^[-0-9.]*: //' expout >at-expout
   17510 mv at-expout expout
   17511 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17512 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17513 mv at-expout expout
   17514 # 5. Check
   17515 $at_traceoff
   17516 echo "calc.at:556: cat stderr"
   17517 echo calc.at:556 >$at_check_line_file
   17518 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17519 at_status=$?
   17520 grep '^ *+' $at_stder1 >&2
   17521 grep -v '^ *+' $at_stder1 >$at_stderr
   17522 at_failed=false
   17523 $at_diff $at_devnull $at_stderr || at_failed=:
   17524 $at_diff expout $at_stdout || at_failed=:
   17525 case $at_status in
   17526    77) echo 77 > $at_status_file
   17527             exit 77;;
   17528    0) ;;
   17529    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17530       at_failed=:;;
   17531 esac
   17532 if $at_failed; then
   17533 
   17534   echo 1 > $at_status_file
   17535   exit 1
   17536 fi
   17537 
   17538 $at_traceon
   17539 
   17540 
   17541 cat >input <<'_ATEOF'
   17542 error
   17543 _ATEOF
   17544 
   17545 $at_traceoff
   17546 echo "calc.at:556: \$PREPARSER ./calc input"
   17547 echo calc.at:556 >$at_check_line_file
   17548 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17549 at_status=$?
   17550 grep '^ *+' $at_stder1 >&2
   17551 grep -v '^ *+' $at_stder1 >$at_stderr
   17552 at_failed=false
   17553 echo stderr:; tee stderr <$at_stderr
   17554 $at_diff $at_devnull $at_stdout || at_failed=:
   17555 case $at_status in
   17556    77) echo 77 > $at_status_file
   17557             exit 77;;
   17558    1) ;;
   17559    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17560       at_failed=:;;
   17561 esac
   17562 if $at_failed; then
   17563 
   17564   echo 1 > $at_status_file
   17565   exit 1
   17566 fi
   17567 
   17568 $at_traceon
   17569 
   17570 
   17571 # Normalize the observed and expected error messages, depending upon the
   17572 # options.
   17573 # 1. Remove the traces from observed.
   17574 sed '/^Starting/d
   17575 /^Entering/d
   17576 /^Stack/d
   17577 /^Reading/d
   17578 /^Reducing/d
   17579 /^Shifting/d
   17580 /^state/d
   17581 /^Cleanup:/d
   17582 /^Error:/d
   17583 /^Next/d
   17584 /^Discarding/d
   17585 / \$[0-9$]* = /d
   17586 /^yydestructor:/d' stderr >at-stderr
   17587 mv at-stderr stderr
   17588 # 2. Create the reference error message.
   17589 cat >expout <<'_ATEOF'
   17590 1.0: syntax error, unexpected $undefined
   17591 _ATEOF
   17592 
   17593 # 3. If locations are not used, remove them.
   17594 sed 's/^[-0-9.]*: //' expout >at-expout
   17595 mv at-expout expout
   17596 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17597 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17598 mv at-expout expout
   17599 # 5. Check
   17600 $at_traceoff
   17601 echo "calc.at:556: cat stderr"
   17602 echo calc.at:556 >$at_check_line_file
   17603 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17604 at_status=$?
   17605 grep '^ *+' $at_stder1 >&2
   17606 grep -v '^ *+' $at_stder1 >$at_stderr
   17607 at_failed=false
   17608 $at_diff $at_devnull $at_stderr || at_failed=:
   17609 $at_diff expout $at_stdout || at_failed=:
   17610 case $at_status in
   17611    77) echo 77 > $at_status_file
   17612             exit 77;;
   17613    0) ;;
   17614    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17615       at_failed=:;;
   17616 esac
   17617 if $at_failed; then
   17618 
   17619   echo 1 > $at_status_file
   17620   exit 1
   17621 fi
   17622 
   17623 $at_traceon
   17624 
   17625 
   17626 cat >input <<'_ATEOF'
   17627 1 = 2 = 3
   17628 _ATEOF
   17629 
   17630 $at_traceoff
   17631 echo "calc.at:556: \$PREPARSER ./calc input"
   17632 echo calc.at:556 >$at_check_line_file
   17633 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17634 at_status=$?
   17635 grep '^ *+' $at_stder1 >&2
   17636 grep -v '^ *+' $at_stder1 >$at_stderr
   17637 at_failed=false
   17638 echo stderr:; tee stderr <$at_stderr
   17639 $at_diff $at_devnull $at_stdout || at_failed=:
   17640 case $at_status in
   17641    77) echo 77 > $at_status_file
   17642             exit 77;;
   17643    1) ;;
   17644    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17645       at_failed=:;;
   17646 esac
   17647 if $at_failed; then
   17648 
   17649   echo 1 > $at_status_file
   17650   exit 1
   17651 fi
   17652 
   17653 $at_traceon
   17654 
   17655 
   17656 # Normalize the observed and expected error messages, depending upon the
   17657 # options.
   17658 # 1. Remove the traces from observed.
   17659 sed '/^Starting/d
   17660 /^Entering/d
   17661 /^Stack/d
   17662 /^Reading/d
   17663 /^Reducing/d
   17664 /^Shifting/d
   17665 /^state/d
   17666 /^Cleanup:/d
   17667 /^Error:/d
   17668 /^Next/d
   17669 /^Discarding/d
   17670 / \$[0-9$]* = /d
   17671 /^yydestructor:/d' stderr >at-stderr
   17672 mv at-stderr stderr
   17673 # 2. Create the reference error message.
   17674 cat >expout <<'_ATEOF'
   17675 1.6: syntax error, unexpected '='
   17676 _ATEOF
   17677 
   17678 # 3. If locations are not used, remove them.
   17679 sed 's/^[-0-9.]*: //' expout >at-expout
   17680 mv at-expout expout
   17681 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17682 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17683 mv at-expout expout
   17684 # 5. Check
   17685 $at_traceoff
   17686 echo "calc.at:556: cat stderr"
   17687 echo calc.at:556 >$at_check_line_file
   17688 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17689 at_status=$?
   17690 grep '^ *+' $at_stder1 >&2
   17691 grep -v '^ *+' $at_stder1 >$at_stderr
   17692 at_failed=false
   17693 $at_diff $at_devnull $at_stderr || at_failed=:
   17694 $at_diff expout $at_stdout || at_failed=:
   17695 case $at_status in
   17696    77) echo 77 > $at_status_file
   17697             exit 77;;
   17698    0) ;;
   17699    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17700       at_failed=:;;
   17701 esac
   17702 if $at_failed; then
   17703 
   17704   echo 1 > $at_status_file
   17705   exit 1
   17706 fi
   17707 
   17708 $at_traceon
   17709 
   17710 
   17711 cat >input <<'_ATEOF'
   17712 
   17713 +1
   17714 _ATEOF
   17715 
   17716 $at_traceoff
   17717 echo "calc.at:556: \$PREPARSER ./calc input"
   17718 echo calc.at:556 >$at_check_line_file
   17719 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17720 at_status=$?
   17721 grep '^ *+' $at_stder1 >&2
   17722 grep -v '^ *+' $at_stder1 >$at_stderr
   17723 at_failed=false
   17724 echo stderr:; tee stderr <$at_stderr
   17725 $at_diff $at_devnull $at_stdout || at_failed=:
   17726 case $at_status in
   17727    77) echo 77 > $at_status_file
   17728             exit 77;;
   17729    1) ;;
   17730    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17731       at_failed=:;;
   17732 esac
   17733 if $at_failed; then
   17734 
   17735   echo 1 > $at_status_file
   17736   exit 1
   17737 fi
   17738 
   17739 $at_traceon
   17740 
   17741 
   17742 # Normalize the observed and expected error messages, depending upon the
   17743 # options.
   17744 # 1. Remove the traces from observed.
   17745 sed '/^Starting/d
   17746 /^Entering/d
   17747 /^Stack/d
   17748 /^Reading/d
   17749 /^Reducing/d
   17750 /^Shifting/d
   17751 /^state/d
   17752 /^Cleanup:/d
   17753 /^Error:/d
   17754 /^Next/d
   17755 /^Discarding/d
   17756 / \$[0-9$]* = /d
   17757 /^yydestructor:/d' stderr >at-stderr
   17758 mv at-stderr stderr
   17759 # 2. Create the reference error message.
   17760 cat >expout <<'_ATEOF'
   17761 2.0: syntax error, unexpected '+'
   17762 _ATEOF
   17763 
   17764 # 3. If locations are not used, remove them.
   17765 sed 's/^[-0-9.]*: //' expout >at-expout
   17766 mv at-expout expout
   17767 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17768 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17769 mv at-expout expout
   17770 # 5. Check
   17771 $at_traceoff
   17772 echo "calc.at:556: cat stderr"
   17773 echo calc.at:556 >$at_check_line_file
   17774 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17775 at_status=$?
   17776 grep '^ *+' $at_stder1 >&2
   17777 grep -v '^ *+' $at_stder1 >$at_stderr
   17778 at_failed=false
   17779 $at_diff $at_devnull $at_stderr || at_failed=:
   17780 $at_diff expout $at_stdout || at_failed=:
   17781 case $at_status in
   17782    77) echo 77 > $at_status_file
   17783             exit 77;;
   17784    0) ;;
   17785    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17786       at_failed=:;;
   17787 esac
   17788 if $at_failed; then
   17789 
   17790   echo 1 > $at_status_file
   17791   exit 1
   17792 fi
   17793 
   17794 $at_traceon
   17795 
   17796 
   17797 # Exercise error messages with EOF: work on an empty file.
   17798 $at_traceoff
   17799 echo "calc.at:556: \$PREPARSER ./calc /dev/null"
   17800 echo calc.at:556 >$at_check_line_file
   17801 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   17802 at_status=$?
   17803 grep '^ *+' $at_stder1 >&2
   17804 grep -v '^ *+' $at_stder1 >$at_stderr
   17805 at_failed=false
   17806 echo stderr:; tee stderr <$at_stderr
   17807 $at_diff $at_devnull $at_stdout || at_failed=:
   17808 case $at_status in
   17809    77) echo 77 > $at_status_file
   17810             exit 77;;
   17811    1) ;;
   17812    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17813       at_failed=:;;
   17814 esac
   17815 if $at_failed; then
   17816 
   17817   echo 1 > $at_status_file
   17818   exit 1
   17819 fi
   17820 
   17821 $at_traceon
   17822 
   17823 
   17824 # Normalize the observed and expected error messages, depending upon the
   17825 # options.
   17826 # 1. Remove the traces from observed.
   17827 sed '/^Starting/d
   17828 /^Entering/d
   17829 /^Stack/d
   17830 /^Reading/d
   17831 /^Reducing/d
   17832 /^Shifting/d
   17833 /^state/d
   17834 /^Cleanup:/d
   17835 /^Error:/d
   17836 /^Next/d
   17837 /^Discarding/d
   17838 / \$[0-9$]* = /d
   17839 /^yydestructor:/d' stderr >at-stderr
   17840 mv at-stderr stderr
   17841 # 2. Create the reference error message.
   17842 cat >expout <<'_ATEOF'
   17843 1.0: syntax error, unexpected end of input
   17844 _ATEOF
   17845 
   17846 # 3. If locations are not used, remove them.
   17847 sed 's/^[-0-9.]*: //' expout >at-expout
   17848 mv at-expout expout
   17849 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17850 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17851 mv at-expout expout
   17852 # 5. Check
   17853 $at_traceoff
   17854 echo "calc.at:556: cat stderr"
   17855 echo calc.at:556 >$at_check_line_file
   17856 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17857 at_status=$?
   17858 grep '^ *+' $at_stder1 >&2
   17859 grep -v '^ *+' $at_stder1 >$at_stderr
   17860 at_failed=false
   17861 $at_diff $at_devnull $at_stderr || at_failed=:
   17862 $at_diff expout $at_stdout || at_failed=:
   17863 case $at_status in
   17864    77) echo 77 > $at_status_file
   17865             exit 77;;
   17866    0) ;;
   17867    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17868       at_failed=:;;
   17869 esac
   17870 if $at_failed; then
   17871 
   17872   echo 1 > $at_status_file
   17873   exit 1
   17874 fi
   17875 
   17876 $at_traceon
   17877 
   17878 
   17879 
   17880 # Exercise the error token: without it, we die at the first error,
   17881 # hence be sure to
   17882 #
   17883 # - have several errors which exercise different shift/discardings
   17884 #   - (): nothing to pop, nothing to discard
   17885 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   17886 #   - (* * *): nothing to pop, a lot to discard
   17887 #   - (1 + 2 * *): some to pop and discard
   17888 #
   17889 # - test the action associated to `error'
   17890 #
   17891 # - check the look-ahead that triggers an error is not discarded
   17892 #   when we enter error recovery.  Below, the look-ahead causing the
   17893 #   first error is ")", which is needed to recover from the error and
   17894 #   produce the "0" that triggers the "0 != 1" error.
   17895 #
   17896 cat >input <<'_ATEOF'
   17897 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   17898 _ATEOF
   17899 
   17900 $at_traceoff
   17901 echo "calc.at:556: \$PREPARSER ./calc input"
   17902 echo calc.at:556 >$at_check_line_file
   17903 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17904 at_status=$?
   17905 grep '^ *+' $at_stder1 >&2
   17906 grep -v '^ *+' $at_stder1 >$at_stderr
   17907 at_failed=false
   17908 echo stderr:; tee stderr <$at_stderr
   17909 $at_diff $at_devnull $at_stdout || at_failed=:
   17910 case $at_status in
   17911    77) echo 77 > $at_status_file
   17912             exit 77;;
   17913    0) ;;
   17914    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17915       at_failed=:;;
   17916 esac
   17917 if $at_failed; then
   17918 
   17919   echo 1 > $at_status_file
   17920   exit 1
   17921 fi
   17922 
   17923 $at_traceon
   17924 
   17925 
   17926 # Normalize the observed and expected error messages, depending upon the
   17927 # options.
   17928 # 1. Remove the traces from observed.
   17929 sed '/^Starting/d
   17930 /^Entering/d
   17931 /^Stack/d
   17932 /^Reading/d
   17933 /^Reducing/d
   17934 /^Shifting/d
   17935 /^state/d
   17936 /^Cleanup:/d
   17937 /^Error:/d
   17938 /^Next/d
   17939 /^Discarding/d
   17940 / \$[0-9$]* = /d
   17941 /^yydestructor:/d' stderr >at-stderr
   17942 mv at-stderr stderr
   17943 # 2. Create the reference error message.
   17944 cat >expout <<'_ATEOF'
   17945 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   17946 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   17947 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   17948 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   17949 calc: error: 4444 != 1
   17950 _ATEOF
   17951 
   17952 # 3. If locations are not used, remove them.
   17953 sed 's/^[-0-9.]*: //' expout >at-expout
   17954 mv at-expout expout
   17955 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17956 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17957 mv at-expout expout
   17958 # 5. Check
   17959 $at_traceoff
   17960 echo "calc.at:556: cat stderr"
   17961 echo calc.at:556 >$at_check_line_file
   17962 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17963 at_status=$?
   17964 grep '^ *+' $at_stder1 >&2
   17965 grep -v '^ *+' $at_stder1 >$at_stderr
   17966 at_failed=false
   17967 $at_diff $at_devnull $at_stderr || at_failed=:
   17968 $at_diff expout $at_stdout || at_failed=:
   17969 case $at_status in
   17970    77) echo 77 > $at_status_file
   17971             exit 77;;
   17972    0) ;;
   17973    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17974       at_failed=:;;
   17975 esac
   17976 if $at_failed; then
   17977 
   17978   echo 1 > $at_status_file
   17979   exit 1
   17980 fi
   17981 
   17982 $at_traceon
   17983 
   17984 
   17985 
   17986 # The same, but this time exercising explicitly triggered syntax errors.
   17987 # POSIX says the look-ahead causing the error should not be discarded.
   17988 cat >input <<'_ATEOF'
   17989 (!) + (0 0) = 1
   17990 _ATEOF
   17991 
   17992 $at_traceoff
   17993 echo "calc.at:556: \$PREPARSER ./calc input"
   17994 echo calc.at:556 >$at_check_line_file
   17995 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17996 at_status=$?
   17997 grep '^ *+' $at_stder1 >&2
   17998 grep -v '^ *+' $at_stder1 >$at_stderr
   17999 at_failed=false
   18000 echo stderr:; tee stderr <$at_stderr
   18001 $at_diff $at_devnull $at_stdout || at_failed=:
   18002 case $at_status in
   18003    77) echo 77 > $at_status_file
   18004             exit 77;;
   18005    0) ;;
   18006    *) echo "calc.at:556: exit code was $at_status, expected 0"
   18007       at_failed=:;;
   18008 esac
   18009 if $at_failed; then
   18010 
   18011   echo 1 > $at_status_file
   18012   exit 1
   18013 fi
   18014 
   18015 $at_traceon
   18016 
   18017 
   18018 # Normalize the observed and expected error messages, depending upon the
   18019 # options.
   18020 # 1. Remove the traces from observed.
   18021 sed '/^Starting/d
   18022 /^Entering/d
   18023 /^Stack/d
   18024 /^Reading/d
   18025 /^Reducing/d
   18026 /^Shifting/d
   18027 /^state/d
   18028 /^Cleanup:/d
   18029 /^Error:/d
   18030 /^Next/d
   18031 /^Discarding/d
   18032 / \$[0-9$]* = /d
   18033 /^yydestructor:/d' stderr >at-stderr
   18034 mv at-stderr stderr
   18035 # 2. Create the reference error message.
   18036 cat >expout <<'_ATEOF'
   18037 1.9: syntax error, unexpected number
   18038 calc: error: 2222 != 1
   18039 _ATEOF
   18040 
   18041 # 3. If locations are not used, remove them.
   18042 sed 's/^[-0-9.]*: //' expout >at-expout
   18043 mv at-expout expout
   18044 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18045 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   18046 mv at-expout expout
   18047 # 5. Check
   18048 $at_traceoff
   18049 echo "calc.at:556: cat stderr"
   18050 echo calc.at:556 >$at_check_line_file
   18051 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18052 at_status=$?
   18053 grep '^ *+' $at_stder1 >&2
   18054 grep -v '^ *+' $at_stder1 >$at_stderr
   18055 at_failed=false
   18056 $at_diff $at_devnull $at_stderr || at_failed=:
   18057 $at_diff expout $at_stdout || at_failed=:
   18058 case $at_status in
   18059    77) echo 77 > $at_status_file
   18060             exit 77;;
   18061    0) ;;
   18062    *) echo "calc.at:556: exit code was $at_status, expected 0"
   18063       at_failed=:;;
   18064 esac
   18065 if $at_failed; then
   18066 
   18067   echo 1 > $at_status_file
   18068   exit 1
   18069 fi
   18070 
   18071 $at_traceon
   18072 
   18073 
   18074 cat >input <<'_ATEOF'
   18075 (- *) + (0 0) = 1
   18076 _ATEOF
   18077 
   18078 $at_traceoff
   18079 echo "calc.at:556: \$PREPARSER ./calc input"
   18080 echo calc.at:556 >$at_check_line_file
   18081 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18082 at_status=$?
   18083 grep '^ *+' $at_stder1 >&2
   18084 grep -v '^ *+' $at_stder1 >$at_stderr
   18085 at_failed=false
   18086 echo stderr:; tee stderr <$at_stderr
   18087 $at_diff $at_devnull $at_stdout || at_failed=:
   18088 case $at_status in
   18089    77) echo 77 > $at_status_file
   18090             exit 77;;
   18091    0) ;;
   18092    *) echo "calc.at:556: exit code was $at_status, expected 0"
   18093       at_failed=:;;
   18094 esac
   18095 if $at_failed; then
   18096 
   18097   echo 1 > $at_status_file
   18098   exit 1
   18099 fi
   18100 
   18101 $at_traceon
   18102 
   18103 
   18104 # Normalize the observed and expected error messages, depending upon the
   18105 # options.
   18106 # 1. Remove the traces from observed.
   18107 sed '/^Starting/d
   18108 /^Entering/d
   18109 /^Stack/d
   18110 /^Reading/d
   18111 /^Reducing/d
   18112 /^Shifting/d
   18113 /^state/d
   18114 /^Cleanup:/d
   18115 /^Error:/d
   18116 /^Next/d
   18117 /^Discarding/d
   18118 / \$[0-9$]* = /d
   18119 /^yydestructor:/d' stderr >at-stderr
   18120 mv at-stderr stderr
   18121 # 2. Create the reference error message.
   18122 cat >expout <<'_ATEOF'
   18123 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   18124 1.11: syntax error, unexpected number
   18125 calc: error: 2222 != 1
   18126 _ATEOF
   18127 
   18128 # 3. If locations are not used, remove them.
   18129 sed 's/^[-0-9.]*: //' expout >at-expout
   18130 mv at-expout expout
   18131 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18132 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   18133 mv at-expout expout
   18134 # 5. Check
   18135 $at_traceoff
   18136 echo "calc.at:556: cat stderr"
   18137 echo calc.at:556 >$at_check_line_file
   18138 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18139 at_status=$?
   18140 grep '^ *+' $at_stder1 >&2
   18141 grep -v '^ *+' $at_stder1 >$at_stderr
   18142 at_failed=false
   18143 $at_diff $at_devnull $at_stderr || at_failed=:
   18144 $at_diff expout $at_stdout || at_failed=:
   18145 case $at_status in
   18146    77) echo 77 > $at_status_file
   18147             exit 77;;
   18148    0) ;;
   18149    *) echo "calc.at:556: exit code was $at_status, expected 0"
   18150       at_failed=:;;
   18151 esac
   18152 if $at_failed; then
   18153 
   18154   echo 1 > $at_status_file
   18155   exit 1
   18156 fi
   18157 
   18158 $at_traceon
   18159 
   18160 
   18161 
   18162 
   18163 
   18164 
   18165 
   18166 
   18167 
   18168 
   18169 
   18170 
   18171 
   18172 
   18173 
   18174 
   18175 
   18176 
   18177 
   18178 
   18179 
   18180 
   18181 
   18182 
   18183       $at_traceoff
   18184       $at_times_p && times >$at_times_file
   18185     ) 5>&1 2>&1 | eval $at_tee_pipe
   18186     at_status=`cat $at_status_file`
   18187     ;;
   18188 
   18189   76 ) # 76. calc.at:557: Calculator %error-verbose
   18190     at_setup_line='calc.at:557'
   18191     at_desc='Calculator %error-verbose'
   18192     $at_quiet $ECHO_N " 76: Calculator %error-verbose                    $ECHO_C"
   18193     at_xfail=no
   18194     (
   18195       echo "76. calc.at:557: testing ..."
   18196       $at_traceon
   18197 
   18198 
   18199 
   18200 
   18201 
   18202 
   18203 
   18204 
   18205 # Using yacc.c?
   18206 
   18207 
   18208 
   18209 
   18210 
   18211 
   18212 
   18213 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   18214 
   18215 # yyerror always sees the locations (when activated), except if
   18216 # yacc & pure & !param.
   18217 
   18218 
   18219 # The interface is pure: either because %pure-parser, or because we
   18220 # are using the C++ parsers.
   18221 
   18222 
   18223 
   18224 
   18225 
   18226 
   18227 
   18228 
   18229 
   18230 
   18231 
   18232 
   18233 cat >calc.y <<'_ATEOF'
   18234 %{
   18235 #ifdef HAVE_CONFIG_H
   18236 # include <config.h>
   18237   /* We don't need perfect functions for these tests. */
   18238 # undef malloc
   18239 # undef memcmp
   18240 # undef realloc
   18241 #endif
   18242 %}
   18243 
   18244 /* Infix notation calculator--calc */
   18245 %error-verbose
   18246 
   18247 %{
   18248 #include <stdio.h>
   18249 
   18250 #include <stdlib.h>
   18251 #include <string.h>
   18252 #if HAVE_UNISTD_H
   18253 # include <unistd.h>
   18254 #else
   18255 # undef alarm
   18256 # define alarm(seconds) /* empty */
   18257 #endif
   18258 #include <ctype.h>
   18259 #define USE(Var)
   18260 
   18261 /* Exercise pre-prologue dependency to %union.  */
   18262 typedef int semantic_value;
   18263 
   18264 static semantic_value global_result = 0;
   18265 static int global_count = 0;
   18266 %}
   18267 
   18268 /* Exercise %union. */
   18269 %union
   18270 {
   18271   semantic_value ival;
   18272 };
   18273 
   18274 %{
   18275 static int power (int base, int exponent);
   18276 /* yyerror receives the location if:
   18277    - %location & %pure & %glr
   18278    - %location & %pure & %yacc & %parse-param. */
   18279 static void yyerror (
   18280 
   18281                      const char *s
   18282                      );
   18283 static int yylex (void);
   18284 static int get_char (void);
   18285 static void unget_char ( int c);
   18286 %}
   18287 
   18288 
   18289 
   18290 /* Bison Declarations */
   18291 %token CALC_EOF 0 "end of input"
   18292 %token <ival> NUM "number"
   18293 %type  <ival> exp
   18294 
   18295 %nonassoc '=' /* comparison	       */
   18296 %left '-' '+'
   18297 %left '*' '/'
   18298 %left NEG     /* negation--unary minus */
   18299 %right '^'    /* exponentiation        */
   18300 
   18301 /* Grammar follows */
   18302 %%
   18303 input:
   18304   line
   18305 | input line         {  }
   18306 ;
   18307 
   18308 line:
   18309   '\n'
   18310 | exp '\n'           { USE ($1); }
   18311 ;
   18312 
   18313 exp:
   18314   NUM                { $$ = $1;             }
   18315 | exp '=' exp
   18316   {
   18317     if ($1 != $3)
   18318       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   18319     $$ = $1;
   18320   }
   18321 | exp '+' exp        { $$ = $1 + $3;        }
   18322 | exp '-' exp        { $$ = $1 - $3;        }
   18323 | exp '*' exp        { $$ = $1 * $3;        }
   18324 | exp '/' exp        { $$ = $1 / $3;        }
   18325 | '-' exp  %prec NEG { $$ = -$2;            }
   18326 | exp '^' exp        { $$ = power ($1, $3); }
   18327 | '(' exp ')'        { $$ = $2;             }
   18328 | '(' error ')'      { $$ = 1111;           }
   18329 | '!'                { $$ = 0; YYERROR;     }
   18330 | '-' error          { $$ = 0; YYERROR;     }
   18331 ;
   18332 %%
   18333 /* The input.  */
   18334 static FILE *input;
   18335 
   18336 static void
   18337 yyerror (
   18338 
   18339          const char *s)
   18340 {
   18341 
   18342 
   18343   fprintf (stderr, "%s\n", s);
   18344 }
   18345 
   18346 
   18347 
   18348 static int
   18349 get_char (void)
   18350 {
   18351   int res = getc (input);
   18352   ;
   18353 
   18354   return res;
   18355 }
   18356 
   18357 
   18358 static void
   18359 unget_char ( int c)
   18360 {
   18361   ;
   18362 
   18363   ungetc (c, input);
   18364 }
   18365 
   18366 static int
   18367 read_signed_integer (void)
   18368 {
   18369   int c = get_char ();
   18370   int sign = 1;
   18371   int n = 0;
   18372 
   18373   ;
   18374   if (c == '-')
   18375     {
   18376       c = get_char ();
   18377       sign = -1;
   18378     }
   18379 
   18380   while (isdigit (c))
   18381     {
   18382       n = 10 * n + (c - '0');
   18383       c = get_char ();
   18384     }
   18385 
   18386   unget_char ( c);
   18387 
   18388   return sign * n;
   18389 }
   18390 
   18391 
   18392 
   18393 /*---------------------------------------------------------------.
   18394 | Lexical analyzer returns an integer on the stack and the token |
   18395 | NUM, or the ASCII character read if not a number.  Skips all   |
   18396 | blanks and tabs, returns 0 for EOF.                            |
   18397 `---------------------------------------------------------------*/
   18398 
   18399 static int
   18400 yylex (void)
   18401 {
   18402   static int init = 1;
   18403   int c;
   18404 
   18405   if (init)
   18406     {
   18407       init = 0;
   18408 
   18409     }
   18410 
   18411 
   18412 
   18413   /* Skip white space.  */
   18414   while ((c = get_char ()) == ' ' || c == '\t')
   18415     {
   18416 
   18417     }
   18418 
   18419   /* process numbers   */
   18420   if (c == '.' || isdigit (c))
   18421     {
   18422       unget_char ( c);
   18423       (yylval).ival = read_signed_integer ();
   18424       return NUM;
   18425     }
   18426 
   18427   /* Return end-of-file.  */
   18428   if (c == EOF)
   18429     return CALC_EOF;
   18430 
   18431   /* Return single chars. */
   18432   return c;
   18433 }
   18434 
   18435 static int
   18436 power (int base, int exponent)
   18437 {
   18438   int res = 1;
   18439   if (exponent < 0)
   18440     exit (3);
   18441   for (/* Niente */; exponent; --exponent)
   18442     res *= base;
   18443   return res;
   18444 }
   18445 
   18446 
   18447 int
   18448 main (int argc, const char **argv)
   18449 {
   18450   semantic_value result = 0;
   18451   int count = 0;
   18452   int status;
   18453 
   18454   /* This used to be alarm (10), but that isn't enough time for
   18455      a July 1995 vintage DEC Alphastation 200 4/100 system,
   18456      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   18457   alarm (100);
   18458 
   18459   if (argc == 2)
   18460     input = fopen (argv[1], "r");
   18461   else
   18462     input = stdin;
   18463 
   18464   if (!input)
   18465     {
   18466       perror (argv[1]);
   18467       return 3;
   18468     }
   18469 
   18470 
   18471   status = yyparse ();
   18472   if (global_result != result)
   18473     abort ();
   18474   if (global_count != count)
   18475     abort ();
   18476   return status;
   18477 }
   18478 _ATEOF
   18479 
   18480 
   18481 
   18482 
   18483 
   18484 $at_traceoff
   18485 echo "calc.at:557: bison -o calc.c calc.y"
   18486 echo calc.at:557 >$at_check_line_file
   18487 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   18488 at_status=$?
   18489 grep '^ *+' $at_stder1 >&2
   18490 grep -v '^ *+' $at_stder1 >$at_stderr
   18491 at_failed=false
   18492 $at_diff $at_devnull $at_stderr || at_failed=:
   18493 $at_diff $at_devnull $at_stdout || at_failed=:
   18494 case $at_status in
   18495    77) echo 77 > $at_status_file
   18496             exit 77;;
   18497    0) ;;
   18498    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18499       at_failed=:;;
   18500 esac
   18501 if $at_failed; then
   18502 
   18503   echo 1 > $at_status_file
   18504   exit 1
   18505 fi
   18506 
   18507 $at_traceon
   18508 
   18509    $at_traceoff
   18510 echo "calc.at:557: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   18511 echo calc.at:557 >$at_check_line_file
   18512 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   18513 at_status=$?
   18514 grep '^ *+' $at_stder1 >&2
   18515 grep -v '^ *+' $at_stder1 >$at_stderr
   18516 at_failed=false
   18517 echo stderr:; cat $at_stderr
   18518 echo stdout:; cat $at_stdout
   18519 case $at_status in
   18520    77) echo 77 > $at_status_file
   18521             exit 77;;
   18522    0) ;;
   18523    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18524       at_failed=:;;
   18525 esac
   18526 if $at_failed; then
   18527 
   18528   echo 1 > $at_status_file
   18529   exit 1
   18530 fi
   18531 
   18532 $at_traceon
   18533 
   18534 
   18535 # Test the priorities.
   18536 cat >input <<'_ATEOF'
   18537 1 + 2 * 3 = 7
   18538 1 + 2 * -3 = -5
   18539 
   18540 -1^2 = -1
   18541 (-1)^2 = 1
   18542 
   18543 ---1 = -1
   18544 
   18545 1 - 2 - 3 = -4
   18546 1 - (2 - 3) = 2
   18547 
   18548 2^2^3 = 256
   18549 (2^2)^3 = 64
   18550 _ATEOF
   18551 
   18552 $at_traceoff
   18553 echo "calc.at:557: \$PREPARSER ./calc input"
   18554 echo calc.at:557 >$at_check_line_file
   18555 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18556 at_status=$?
   18557 grep '^ *+' $at_stder1 >&2
   18558 grep -v '^ *+' $at_stder1 >$at_stderr
   18559 at_failed=false
   18560 echo stderr:; tee stderr <$at_stderr
   18561 $at_diff $at_devnull $at_stdout || at_failed=:
   18562 case $at_status in
   18563    77) echo 77 > $at_status_file
   18564             exit 77;;
   18565    0) ;;
   18566    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18567       at_failed=:;;
   18568 esac
   18569 if $at_failed; then
   18570 
   18571   echo 1 > $at_status_file
   18572   exit 1
   18573 fi
   18574 
   18575 $at_traceon
   18576 
   18577 
   18578 
   18579 # Some syntax errors.
   18580 cat >input <<'_ATEOF'
   18581 0 0
   18582 _ATEOF
   18583 
   18584 $at_traceoff
   18585 echo "calc.at:557: \$PREPARSER ./calc input"
   18586 echo calc.at:557 >$at_check_line_file
   18587 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18588 at_status=$?
   18589 grep '^ *+' $at_stder1 >&2
   18590 grep -v '^ *+' $at_stder1 >$at_stderr
   18591 at_failed=false
   18592 echo stderr:; tee stderr <$at_stderr
   18593 $at_diff $at_devnull $at_stdout || at_failed=:
   18594 case $at_status in
   18595    77) echo 77 > $at_status_file
   18596             exit 77;;
   18597    1) ;;
   18598    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18599       at_failed=:;;
   18600 esac
   18601 if $at_failed; then
   18602 
   18603   echo 1 > $at_status_file
   18604   exit 1
   18605 fi
   18606 
   18607 $at_traceon
   18608 
   18609 
   18610 # Normalize the observed and expected error messages, depending upon the
   18611 # options.
   18612 # 1. Remove the traces from observed.
   18613 sed '/^Starting/d
   18614 /^Entering/d
   18615 /^Stack/d
   18616 /^Reading/d
   18617 /^Reducing/d
   18618 /^Shifting/d
   18619 /^state/d
   18620 /^Cleanup:/d
   18621 /^Error:/d
   18622 /^Next/d
   18623 /^Discarding/d
   18624 / \$[0-9$]* = /d
   18625 /^yydestructor:/d' stderr >at-stderr
   18626 mv at-stderr stderr
   18627 # 2. Create the reference error message.
   18628 cat >expout <<'_ATEOF'
   18629 1.2: syntax error, unexpected number
   18630 _ATEOF
   18631 
   18632 # 3. If locations are not used, remove them.
   18633 sed 's/^[-0-9.]*: //' expout >at-expout
   18634 mv at-expout expout
   18635 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18636 
   18637 # 5. Check
   18638 $at_traceoff
   18639 echo "calc.at:557: cat stderr"
   18640 echo calc.at:557 >$at_check_line_file
   18641 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18642 at_status=$?
   18643 grep '^ *+' $at_stder1 >&2
   18644 grep -v '^ *+' $at_stder1 >$at_stderr
   18645 at_failed=false
   18646 $at_diff $at_devnull $at_stderr || at_failed=:
   18647 $at_diff expout $at_stdout || at_failed=:
   18648 case $at_status in
   18649    77) echo 77 > $at_status_file
   18650             exit 77;;
   18651    0) ;;
   18652    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18653       at_failed=:;;
   18654 esac
   18655 if $at_failed; then
   18656 
   18657   echo 1 > $at_status_file
   18658   exit 1
   18659 fi
   18660 
   18661 $at_traceon
   18662 
   18663 
   18664 cat >input <<'_ATEOF'
   18665 1//2
   18666 _ATEOF
   18667 
   18668 $at_traceoff
   18669 echo "calc.at:557: \$PREPARSER ./calc input"
   18670 echo calc.at:557 >$at_check_line_file
   18671 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18672 at_status=$?
   18673 grep '^ *+' $at_stder1 >&2
   18674 grep -v '^ *+' $at_stder1 >$at_stderr
   18675 at_failed=false
   18676 echo stderr:; tee stderr <$at_stderr
   18677 $at_diff $at_devnull $at_stdout || at_failed=:
   18678 case $at_status in
   18679    77) echo 77 > $at_status_file
   18680             exit 77;;
   18681    1) ;;
   18682    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18683       at_failed=:;;
   18684 esac
   18685 if $at_failed; then
   18686 
   18687   echo 1 > $at_status_file
   18688   exit 1
   18689 fi
   18690 
   18691 $at_traceon
   18692 
   18693 
   18694 # Normalize the observed and expected error messages, depending upon the
   18695 # options.
   18696 # 1. Remove the traces from observed.
   18697 sed '/^Starting/d
   18698 /^Entering/d
   18699 /^Stack/d
   18700 /^Reading/d
   18701 /^Reducing/d
   18702 /^Shifting/d
   18703 /^state/d
   18704 /^Cleanup:/d
   18705 /^Error:/d
   18706 /^Next/d
   18707 /^Discarding/d
   18708 / \$[0-9$]* = /d
   18709 /^yydestructor:/d' stderr >at-stderr
   18710 mv at-stderr stderr
   18711 # 2. Create the reference error message.
   18712 cat >expout <<'_ATEOF'
   18713 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   18714 _ATEOF
   18715 
   18716 # 3. If locations are not used, remove them.
   18717 sed 's/^[-0-9.]*: //' expout >at-expout
   18718 mv at-expout expout
   18719 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18720 
   18721 # 5. Check
   18722 $at_traceoff
   18723 echo "calc.at:557: cat stderr"
   18724 echo calc.at:557 >$at_check_line_file
   18725 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18726 at_status=$?
   18727 grep '^ *+' $at_stder1 >&2
   18728 grep -v '^ *+' $at_stder1 >$at_stderr
   18729 at_failed=false
   18730 $at_diff $at_devnull $at_stderr || at_failed=:
   18731 $at_diff expout $at_stdout || at_failed=:
   18732 case $at_status in
   18733    77) echo 77 > $at_status_file
   18734             exit 77;;
   18735    0) ;;
   18736    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18737       at_failed=:;;
   18738 esac
   18739 if $at_failed; then
   18740 
   18741   echo 1 > $at_status_file
   18742   exit 1
   18743 fi
   18744 
   18745 $at_traceon
   18746 
   18747 
   18748 cat >input <<'_ATEOF'
   18749 error
   18750 _ATEOF
   18751 
   18752 $at_traceoff
   18753 echo "calc.at:557: \$PREPARSER ./calc input"
   18754 echo calc.at:557 >$at_check_line_file
   18755 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18756 at_status=$?
   18757 grep '^ *+' $at_stder1 >&2
   18758 grep -v '^ *+' $at_stder1 >$at_stderr
   18759 at_failed=false
   18760 echo stderr:; tee stderr <$at_stderr
   18761 $at_diff $at_devnull $at_stdout || at_failed=:
   18762 case $at_status in
   18763    77) echo 77 > $at_status_file
   18764             exit 77;;
   18765    1) ;;
   18766    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18767       at_failed=:;;
   18768 esac
   18769 if $at_failed; then
   18770 
   18771   echo 1 > $at_status_file
   18772   exit 1
   18773 fi
   18774 
   18775 $at_traceon
   18776 
   18777 
   18778 # Normalize the observed and expected error messages, depending upon the
   18779 # options.
   18780 # 1. Remove the traces from observed.
   18781 sed '/^Starting/d
   18782 /^Entering/d
   18783 /^Stack/d
   18784 /^Reading/d
   18785 /^Reducing/d
   18786 /^Shifting/d
   18787 /^state/d
   18788 /^Cleanup:/d
   18789 /^Error:/d
   18790 /^Next/d
   18791 /^Discarding/d
   18792 / \$[0-9$]* = /d
   18793 /^yydestructor:/d' stderr >at-stderr
   18794 mv at-stderr stderr
   18795 # 2. Create the reference error message.
   18796 cat >expout <<'_ATEOF'
   18797 1.0: syntax error, unexpected $undefined
   18798 _ATEOF
   18799 
   18800 # 3. If locations are not used, remove them.
   18801 sed 's/^[-0-9.]*: //' expout >at-expout
   18802 mv at-expout expout
   18803 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18804 
   18805 # 5. Check
   18806 $at_traceoff
   18807 echo "calc.at:557: cat stderr"
   18808 echo calc.at:557 >$at_check_line_file
   18809 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18810 at_status=$?
   18811 grep '^ *+' $at_stder1 >&2
   18812 grep -v '^ *+' $at_stder1 >$at_stderr
   18813 at_failed=false
   18814 $at_diff $at_devnull $at_stderr || at_failed=:
   18815 $at_diff expout $at_stdout || at_failed=:
   18816 case $at_status in
   18817    77) echo 77 > $at_status_file
   18818             exit 77;;
   18819    0) ;;
   18820    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18821       at_failed=:;;
   18822 esac
   18823 if $at_failed; then
   18824 
   18825   echo 1 > $at_status_file
   18826   exit 1
   18827 fi
   18828 
   18829 $at_traceon
   18830 
   18831 
   18832 cat >input <<'_ATEOF'
   18833 1 = 2 = 3
   18834 _ATEOF
   18835 
   18836 $at_traceoff
   18837 echo "calc.at:557: \$PREPARSER ./calc input"
   18838 echo calc.at:557 >$at_check_line_file
   18839 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18840 at_status=$?
   18841 grep '^ *+' $at_stder1 >&2
   18842 grep -v '^ *+' $at_stder1 >$at_stderr
   18843 at_failed=false
   18844 echo stderr:; tee stderr <$at_stderr
   18845 $at_diff $at_devnull $at_stdout || at_failed=:
   18846 case $at_status in
   18847    77) echo 77 > $at_status_file
   18848             exit 77;;
   18849    1) ;;
   18850    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18851       at_failed=:;;
   18852 esac
   18853 if $at_failed; then
   18854 
   18855   echo 1 > $at_status_file
   18856   exit 1
   18857 fi
   18858 
   18859 $at_traceon
   18860 
   18861 
   18862 # Normalize the observed and expected error messages, depending upon the
   18863 # options.
   18864 # 1. Remove the traces from observed.
   18865 sed '/^Starting/d
   18866 /^Entering/d
   18867 /^Stack/d
   18868 /^Reading/d
   18869 /^Reducing/d
   18870 /^Shifting/d
   18871 /^state/d
   18872 /^Cleanup:/d
   18873 /^Error:/d
   18874 /^Next/d
   18875 /^Discarding/d
   18876 / \$[0-9$]* = /d
   18877 /^yydestructor:/d' stderr >at-stderr
   18878 mv at-stderr stderr
   18879 # 2. Create the reference error message.
   18880 cat >expout <<'_ATEOF'
   18881 1.6: syntax error, unexpected '='
   18882 _ATEOF
   18883 
   18884 # 3. If locations are not used, remove them.
   18885 sed 's/^[-0-9.]*: //' expout >at-expout
   18886 mv at-expout expout
   18887 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18888 
   18889 # 5. Check
   18890 $at_traceoff
   18891 echo "calc.at:557: cat stderr"
   18892 echo calc.at:557 >$at_check_line_file
   18893 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18894 at_status=$?
   18895 grep '^ *+' $at_stder1 >&2
   18896 grep -v '^ *+' $at_stder1 >$at_stderr
   18897 at_failed=false
   18898 $at_diff $at_devnull $at_stderr || at_failed=:
   18899 $at_diff expout $at_stdout || at_failed=:
   18900 case $at_status in
   18901    77) echo 77 > $at_status_file
   18902             exit 77;;
   18903    0) ;;
   18904    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18905       at_failed=:;;
   18906 esac
   18907 if $at_failed; then
   18908 
   18909   echo 1 > $at_status_file
   18910   exit 1
   18911 fi
   18912 
   18913 $at_traceon
   18914 
   18915 
   18916 cat >input <<'_ATEOF'
   18917 
   18918 +1
   18919 _ATEOF
   18920 
   18921 $at_traceoff
   18922 echo "calc.at:557: \$PREPARSER ./calc input"
   18923 echo calc.at:557 >$at_check_line_file
   18924 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18925 at_status=$?
   18926 grep '^ *+' $at_stder1 >&2
   18927 grep -v '^ *+' $at_stder1 >$at_stderr
   18928 at_failed=false
   18929 echo stderr:; tee stderr <$at_stderr
   18930 $at_diff $at_devnull $at_stdout || at_failed=:
   18931 case $at_status in
   18932    77) echo 77 > $at_status_file
   18933             exit 77;;
   18934    1) ;;
   18935    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18936       at_failed=:;;
   18937 esac
   18938 if $at_failed; then
   18939 
   18940   echo 1 > $at_status_file
   18941   exit 1
   18942 fi
   18943 
   18944 $at_traceon
   18945 
   18946 
   18947 # Normalize the observed and expected error messages, depending upon the
   18948 # options.
   18949 # 1. Remove the traces from observed.
   18950 sed '/^Starting/d
   18951 /^Entering/d
   18952 /^Stack/d
   18953 /^Reading/d
   18954 /^Reducing/d
   18955 /^Shifting/d
   18956 /^state/d
   18957 /^Cleanup:/d
   18958 /^Error:/d
   18959 /^Next/d
   18960 /^Discarding/d
   18961 / \$[0-9$]* = /d
   18962 /^yydestructor:/d' stderr >at-stderr
   18963 mv at-stderr stderr
   18964 # 2. Create the reference error message.
   18965 cat >expout <<'_ATEOF'
   18966 2.0: syntax error, unexpected '+'
   18967 _ATEOF
   18968 
   18969 # 3. If locations are not used, remove them.
   18970 sed 's/^[-0-9.]*: //' expout >at-expout
   18971 mv at-expout expout
   18972 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18973 
   18974 # 5. Check
   18975 $at_traceoff
   18976 echo "calc.at:557: cat stderr"
   18977 echo calc.at:557 >$at_check_line_file
   18978 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18979 at_status=$?
   18980 grep '^ *+' $at_stder1 >&2
   18981 grep -v '^ *+' $at_stder1 >$at_stderr
   18982 at_failed=false
   18983 $at_diff $at_devnull $at_stderr || at_failed=:
   18984 $at_diff expout $at_stdout || at_failed=:
   18985 case $at_status in
   18986    77) echo 77 > $at_status_file
   18987             exit 77;;
   18988    0) ;;
   18989    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18990       at_failed=:;;
   18991 esac
   18992 if $at_failed; then
   18993 
   18994   echo 1 > $at_status_file
   18995   exit 1
   18996 fi
   18997 
   18998 $at_traceon
   18999 
   19000 
   19001 # Exercise error messages with EOF: work on an empty file.
   19002 $at_traceoff
   19003 echo "calc.at:557: \$PREPARSER ./calc /dev/null"
   19004 echo calc.at:557 >$at_check_line_file
   19005 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   19006 at_status=$?
   19007 grep '^ *+' $at_stder1 >&2
   19008 grep -v '^ *+' $at_stder1 >$at_stderr
   19009 at_failed=false
   19010 echo stderr:; tee stderr <$at_stderr
   19011 $at_diff $at_devnull $at_stdout || at_failed=:
   19012 case $at_status in
   19013    77) echo 77 > $at_status_file
   19014             exit 77;;
   19015    1) ;;
   19016    *) echo "calc.at:557: exit code was $at_status, expected 1"
   19017       at_failed=:;;
   19018 esac
   19019 if $at_failed; then
   19020 
   19021   echo 1 > $at_status_file
   19022   exit 1
   19023 fi
   19024 
   19025 $at_traceon
   19026 
   19027 
   19028 # Normalize the observed and expected error messages, depending upon the
   19029 # options.
   19030 # 1. Remove the traces from observed.
   19031 sed '/^Starting/d
   19032 /^Entering/d
   19033 /^Stack/d
   19034 /^Reading/d
   19035 /^Reducing/d
   19036 /^Shifting/d
   19037 /^state/d
   19038 /^Cleanup:/d
   19039 /^Error:/d
   19040 /^Next/d
   19041 /^Discarding/d
   19042 / \$[0-9$]* = /d
   19043 /^yydestructor:/d' stderr >at-stderr
   19044 mv at-stderr stderr
   19045 # 2. Create the reference error message.
   19046 cat >expout <<'_ATEOF'
   19047 1.0: syntax error, unexpected end of input
   19048 _ATEOF
   19049 
   19050 # 3. If locations are not used, remove them.
   19051 sed 's/^[-0-9.]*: //' expout >at-expout
   19052 mv at-expout expout
   19053 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   19054 
   19055 # 5. Check
   19056 $at_traceoff
   19057 echo "calc.at:557: cat stderr"
   19058 echo calc.at:557 >$at_check_line_file
   19059 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   19060 at_status=$?
   19061 grep '^ *+' $at_stder1 >&2
   19062 grep -v '^ *+' $at_stder1 >$at_stderr
   19063 at_failed=false
   19064 $at_diff $at_devnull $at_stderr || at_failed=:
   19065 $at_diff expout $at_stdout || at_failed=:
   19066 case $at_status in
   19067    77) echo 77 > $at_status_file
   19068             exit 77;;
   19069    0) ;;
   19070    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19071       at_failed=:;;
   19072 esac
   19073 if $at_failed; then
   19074 
   19075   echo 1 > $at_status_file
   19076   exit 1
   19077 fi
   19078 
   19079 $at_traceon
   19080 
   19081 
   19082 
   19083 # Exercise the error token: without it, we die at the first error,
   19084 # hence be sure to
   19085 #
   19086 # - have several errors which exercise different shift/discardings
   19087 #   - (): nothing to pop, nothing to discard
   19088 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   19089 #   - (* * *): nothing to pop, a lot to discard
   19090 #   - (1 + 2 * *): some to pop and discard
   19091 #
   19092 # - test the action associated to `error'
   19093 #
   19094 # - check the look-ahead that triggers an error is not discarded
   19095 #   when we enter error recovery.  Below, the look-ahead causing the
   19096 #   first error is ")", which is needed to recover from the error and
   19097 #   produce the "0" that triggers the "0 != 1" error.
   19098 #
   19099 cat >input <<'_ATEOF'
   19100 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   19101 _ATEOF
   19102 
   19103 $at_traceoff
   19104 echo "calc.at:557: \$PREPARSER ./calc input"
   19105 echo calc.at:557 >$at_check_line_file
   19106 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19107 at_status=$?
   19108 grep '^ *+' $at_stder1 >&2
   19109 grep -v '^ *+' $at_stder1 >$at_stderr
   19110 at_failed=false
   19111 echo stderr:; tee stderr <$at_stderr
   19112 $at_diff $at_devnull $at_stdout || at_failed=:
   19113 case $at_status in
   19114    77) echo 77 > $at_status_file
   19115             exit 77;;
   19116    0) ;;
   19117    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19118       at_failed=:;;
   19119 esac
   19120 if $at_failed; then
   19121 
   19122   echo 1 > $at_status_file
   19123   exit 1
   19124 fi
   19125 
   19126 $at_traceon
   19127 
   19128 
   19129 # Normalize the observed and expected error messages, depending upon the
   19130 # options.
   19131 # 1. Remove the traces from observed.
   19132 sed '/^Starting/d
   19133 /^Entering/d
   19134 /^Stack/d
   19135 /^Reading/d
   19136 /^Reducing/d
   19137 /^Shifting/d
   19138 /^state/d
   19139 /^Cleanup:/d
   19140 /^Error:/d
   19141 /^Next/d
   19142 /^Discarding/d
   19143 / \$[0-9$]* = /d
   19144 /^yydestructor:/d' stderr >at-stderr
   19145 mv at-stderr stderr
   19146 # 2. Create the reference error message.
   19147 cat >expout <<'_ATEOF'
   19148 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   19149 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   19150 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   19151 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   19152 calc: error: 4444 != 1
   19153 _ATEOF
   19154 
   19155 # 3. If locations are not used, remove them.
   19156 sed 's/^[-0-9.]*: //' expout >at-expout
   19157 mv at-expout expout
   19158 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   19159 
   19160 # 5. Check
   19161 $at_traceoff
   19162 echo "calc.at:557: cat stderr"
   19163 echo calc.at:557 >$at_check_line_file
   19164 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   19165 at_status=$?
   19166 grep '^ *+' $at_stder1 >&2
   19167 grep -v '^ *+' $at_stder1 >$at_stderr
   19168 at_failed=false
   19169 $at_diff $at_devnull $at_stderr || at_failed=:
   19170 $at_diff expout $at_stdout || at_failed=:
   19171 case $at_status in
   19172    77) echo 77 > $at_status_file
   19173             exit 77;;
   19174    0) ;;
   19175    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19176       at_failed=:;;
   19177 esac
   19178 if $at_failed; then
   19179 
   19180   echo 1 > $at_status_file
   19181   exit 1
   19182 fi
   19183 
   19184 $at_traceon
   19185 
   19186 
   19187 
   19188 # The same, but this time exercising explicitly triggered syntax errors.
   19189 # POSIX says the look-ahead causing the error should not be discarded.
   19190 cat >input <<'_ATEOF'
   19191 (!) + (0 0) = 1
   19192 _ATEOF
   19193 
   19194 $at_traceoff
   19195 echo "calc.at:557: \$PREPARSER ./calc input"
   19196 echo calc.at:557 >$at_check_line_file
   19197 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19198 at_status=$?
   19199 grep '^ *+' $at_stder1 >&2
   19200 grep -v '^ *+' $at_stder1 >$at_stderr
   19201 at_failed=false
   19202 echo stderr:; tee stderr <$at_stderr
   19203 $at_diff $at_devnull $at_stdout || at_failed=:
   19204 case $at_status in
   19205    77) echo 77 > $at_status_file
   19206             exit 77;;
   19207    0) ;;
   19208    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19209       at_failed=:;;
   19210 esac
   19211 if $at_failed; then
   19212 
   19213   echo 1 > $at_status_file
   19214   exit 1
   19215 fi
   19216 
   19217 $at_traceon
   19218 
   19219 
   19220 # Normalize the observed and expected error messages, depending upon the
   19221 # options.
   19222 # 1. Remove the traces from observed.
   19223 sed '/^Starting/d
   19224 /^Entering/d
   19225 /^Stack/d
   19226 /^Reading/d
   19227 /^Reducing/d
   19228 /^Shifting/d
   19229 /^state/d
   19230 /^Cleanup:/d
   19231 /^Error:/d
   19232 /^Next/d
   19233 /^Discarding/d
   19234 / \$[0-9$]* = /d
   19235 /^yydestructor:/d' stderr >at-stderr
   19236 mv at-stderr stderr
   19237 # 2. Create the reference error message.
   19238 cat >expout <<'_ATEOF'
   19239 1.9: syntax error, unexpected number
   19240 calc: error: 2222 != 1
   19241 _ATEOF
   19242 
   19243 # 3. If locations are not used, remove them.
   19244 sed 's/^[-0-9.]*: //' expout >at-expout
   19245 mv at-expout expout
   19246 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   19247 
   19248 # 5. Check
   19249 $at_traceoff
   19250 echo "calc.at:557: cat stderr"
   19251 echo calc.at:557 >$at_check_line_file
   19252 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   19253 at_status=$?
   19254 grep '^ *+' $at_stder1 >&2
   19255 grep -v '^ *+' $at_stder1 >$at_stderr
   19256 at_failed=false
   19257 $at_diff $at_devnull $at_stderr || at_failed=:
   19258 $at_diff expout $at_stdout || at_failed=:
   19259 case $at_status in
   19260    77) echo 77 > $at_status_file
   19261             exit 77;;
   19262    0) ;;
   19263    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19264       at_failed=:;;
   19265 esac
   19266 if $at_failed; then
   19267 
   19268   echo 1 > $at_status_file
   19269   exit 1
   19270 fi
   19271 
   19272 $at_traceon
   19273 
   19274 
   19275 cat >input <<'_ATEOF'
   19276 (- *) + (0 0) = 1
   19277 _ATEOF
   19278 
   19279 $at_traceoff
   19280 echo "calc.at:557: \$PREPARSER ./calc input"
   19281 echo calc.at:557 >$at_check_line_file
   19282 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19283 at_status=$?
   19284 grep '^ *+' $at_stder1 >&2
   19285 grep -v '^ *+' $at_stder1 >$at_stderr
   19286 at_failed=false
   19287 echo stderr:; tee stderr <$at_stderr
   19288 $at_diff $at_devnull $at_stdout || at_failed=:
   19289 case $at_status in
   19290    77) echo 77 > $at_status_file
   19291             exit 77;;
   19292    0) ;;
   19293    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19294       at_failed=:;;
   19295 esac
   19296 if $at_failed; then
   19297 
   19298   echo 1 > $at_status_file
   19299   exit 1
   19300 fi
   19301 
   19302 $at_traceon
   19303 
   19304 
   19305 # Normalize the observed and expected error messages, depending upon the
   19306 # options.
   19307 # 1. Remove the traces from observed.
   19308 sed '/^Starting/d
   19309 /^Entering/d
   19310 /^Stack/d
   19311 /^Reading/d
   19312 /^Reducing/d
   19313 /^Shifting/d
   19314 /^state/d
   19315 /^Cleanup:/d
   19316 /^Error:/d
   19317 /^Next/d
   19318 /^Discarding/d
   19319 / \$[0-9$]* = /d
   19320 /^yydestructor:/d' stderr >at-stderr
   19321 mv at-stderr stderr
   19322 # 2. Create the reference error message.
   19323 cat >expout <<'_ATEOF'
   19324 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   19325 1.11: syntax error, unexpected number
   19326 calc: error: 2222 != 1
   19327 _ATEOF
   19328 
   19329 # 3. If locations are not used, remove them.
   19330 sed 's/^[-0-9.]*: //' expout >at-expout
   19331 mv at-expout expout
   19332 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   19333 
   19334 # 5. Check
   19335 $at_traceoff
   19336 echo "calc.at:557: cat stderr"
   19337 echo calc.at:557 >$at_check_line_file
   19338 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   19339 at_status=$?
   19340 grep '^ *+' $at_stder1 >&2
   19341 grep -v '^ *+' $at_stder1 >$at_stderr
   19342 at_failed=false
   19343 $at_diff $at_devnull $at_stderr || at_failed=:
   19344 $at_diff expout $at_stdout || at_failed=:
   19345 case $at_status in
   19346    77) echo 77 > $at_status_file
   19347             exit 77;;
   19348    0) ;;
   19349    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19350       at_failed=:;;
   19351 esac
   19352 if $at_failed; then
   19353 
   19354   echo 1 > $at_status_file
   19355   exit 1
   19356 fi
   19357 
   19358 $at_traceon
   19359 
   19360 
   19361 
   19362 
   19363 
   19364 
   19365 
   19366 
   19367 
   19368 
   19369 
   19370 
   19371 
   19372 
   19373 
   19374 
   19375 
   19376 
   19377 
   19378 
   19379 
   19380 
   19381 
   19382 
   19383       $at_traceoff
   19384       $at_times_p && times >$at_times_file
   19385     ) 5>&1 2>&1 | eval $at_tee_pipe
   19386     at_status=`cat $at_status_file`
   19387     ;;
   19388 
   19389   77 ) # 77. calc.at:559: Calculator %pure-parser %locations
   19390     at_setup_line='calc.at:559'
   19391     at_desc='Calculator %pure-parser %locations'
   19392     $at_quiet $ECHO_N " 77: Calculator %pure-parser %locations           $ECHO_C"
   19393     at_xfail=no
   19394     (
   19395       echo "77. calc.at:559: testing ..."
   19396       $at_traceon
   19397 
   19398 
   19399 
   19400 
   19401 
   19402 
   19403 
   19404 
   19405 # Using yacc.c?
   19406 
   19407 
   19408 
   19409 
   19410 
   19411 
   19412 
   19413 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   19414 
   19415 # yyerror always sees the locations (when activated), except if
   19416 # yacc & pure & !param.
   19417 
   19418 
   19419 # The interface is pure: either because %pure-parser, or because we
   19420 # are using the C++ parsers.
   19421 
   19422 
   19423 
   19424 
   19425 
   19426 
   19427 
   19428 
   19429 
   19430 
   19431 
   19432 
   19433 cat >calc.y <<'_ATEOF'
   19434 %{
   19435 #ifdef HAVE_CONFIG_H
   19436 # include <config.h>
   19437   /* We don't need perfect functions for these tests. */
   19438 # undef malloc
   19439 # undef memcmp
   19440 # undef realloc
   19441 #endif
   19442 %}
   19443 
   19444 /* Infix notation calculator--calc */
   19445 %pure-parser %locations
   19446 
   19447 %{
   19448 #include <stdio.h>
   19449 
   19450 #include <stdlib.h>
   19451 #include <string.h>
   19452 #if HAVE_UNISTD_H
   19453 # include <unistd.h>
   19454 #else
   19455 # undef alarm
   19456 # define alarm(seconds) /* empty */
   19457 #endif
   19458 #include <ctype.h>
   19459 #define USE(Var)
   19460 
   19461 /* Exercise pre-prologue dependency to %union.  */
   19462 typedef int semantic_value;
   19463 
   19464 static semantic_value global_result = 0;
   19465 static int global_count = 0;
   19466 %}
   19467 
   19468 /* Exercise %union. */
   19469 %union
   19470 {
   19471   semantic_value ival;
   19472 };
   19473 
   19474 %{
   19475 static int power (int base, int exponent);
   19476 /* yyerror receives the location if:
   19477    - %location & %pure & %glr
   19478    - %location & %pure & %yacc & %parse-param. */
   19479 static void yyerror (
   19480 
   19481                      const char *s
   19482                      );
   19483 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   19484 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   19485 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   19486 %}
   19487 
   19488 
   19489 
   19490 /* Bison Declarations */
   19491 %token CALC_EOF 0 "end of input"
   19492 %token <ival> NUM "number"
   19493 %type  <ival> exp
   19494 
   19495 %nonassoc '=' /* comparison	       */
   19496 %left '-' '+'
   19497 %left '*' '/'
   19498 %left NEG     /* negation--unary minus */
   19499 %right '^'    /* exponentiation        */
   19500 
   19501 /* Grammar follows */
   19502 %%
   19503 input:
   19504   line
   19505 | input line         {  }
   19506 ;
   19507 
   19508 line:
   19509   '\n'
   19510 | exp '\n'           { USE ($1); }
   19511 ;
   19512 
   19513 exp:
   19514   NUM                { $$ = $1;             }
   19515 | exp '=' exp
   19516   {
   19517     if ($1 != $3)
   19518       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   19519     $$ = $1;
   19520   }
   19521 | exp '+' exp        { $$ = $1 + $3;        }
   19522 | exp '-' exp        { $$ = $1 - $3;        }
   19523 | exp '*' exp        { $$ = $1 * $3;        }
   19524 | exp '/' exp        { $$ = $1 / $3;        }
   19525 | '-' exp  %prec NEG { $$ = -$2;            }
   19526 | exp '^' exp        { $$ = power ($1, $3); }
   19527 | '(' exp ')'        { $$ = $2;             }
   19528 | '(' error ')'      { $$ = 1111;           }
   19529 | '!'                { $$ = 0; YYERROR;     }
   19530 | '-' error          { $$ = 0; YYERROR;     }
   19531 ;
   19532 %%
   19533 /* The input.  */
   19534 static FILE *input;
   19535 
   19536 static void
   19537 yyerror (
   19538 
   19539          const char *s)
   19540 {
   19541 
   19542 
   19543   fprintf (stderr, "%s\n", s);
   19544 }
   19545 
   19546 
   19547 
   19548 static YYLTYPE last_yylloc;
   19549 
   19550 static int
   19551 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   19552 {
   19553   int res = getc (input);
   19554   (void) lvalp;(void) llocp;
   19555 
   19556   last_yylloc = (*llocp);
   19557   if (res == '\n')
   19558     {
   19559       (*llocp).last_line++;
   19560       (*llocp).last_column = 0;
   19561     }
   19562   else
   19563     (*llocp).last_column++;
   19564 
   19565   return res;
   19566 }
   19567 
   19568 
   19569 static void
   19570 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   19571 {
   19572   (void) lvalp;(void) llocp;
   19573 
   19574   /* Wrong when C == `\n'. */
   19575   (*llocp) = last_yylloc;
   19576 
   19577   ungetc (c, input);
   19578 }
   19579 
   19580 static int
   19581 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   19582 {
   19583   int c = get_char (lvalp, llocp);
   19584   int sign = 1;
   19585   int n = 0;
   19586 
   19587   (void) lvalp;(void) llocp;
   19588   if (c == '-')
   19589     {
   19590       c = get_char (lvalp, llocp);
   19591       sign = -1;
   19592     }
   19593 
   19594   while (isdigit (c))
   19595     {
   19596       n = 10 * n + (c - '0');
   19597       c = get_char (lvalp, llocp);
   19598     }
   19599 
   19600   unget_char (lvalp, llocp,  c);
   19601 
   19602   return sign * n;
   19603 }
   19604 
   19605 
   19606 
   19607 /*---------------------------------------------------------------.
   19608 | Lexical analyzer returns an integer on the stack and the token |
   19609 | NUM, or the ASCII character read if not a number.  Skips all   |
   19610 | blanks and tabs, returns 0 for EOF.                            |
   19611 `---------------------------------------------------------------*/
   19612 
   19613 static int
   19614 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   19615 {
   19616   static int init = 1;
   19617   int c;
   19618 
   19619   if (init)
   19620     {
   19621       init = 0;
   19622 
   19623       (*llocp).last_column = 0;
   19624       (*llocp).last_line = 1;
   19625 
   19626     }
   19627 
   19628 
   19629  (*llocp).first_column = (*llocp).last_column;
   19630   (*llocp).first_line   = (*llocp).last_line;
   19631 
   19632 
   19633   /* Skip white space.  */
   19634   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   19635     {
   19636      (*llocp).first_column = (*llocp).last_column;
   19637       (*llocp).first_line   = (*llocp).last_line;
   19638 
   19639     }
   19640 
   19641   /* process numbers   */
   19642   if (c == '.' || isdigit (c))
   19643     {
   19644       unget_char (lvalp, llocp,  c);
   19645       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   19646       return NUM;
   19647     }
   19648 
   19649   /* Return end-of-file.  */
   19650   if (c == EOF)
   19651     return CALC_EOF;
   19652 
   19653   /* Return single chars. */
   19654   return c;
   19655 }
   19656 
   19657 static int
   19658 power (int base, int exponent)
   19659 {
   19660   int res = 1;
   19661   if (exponent < 0)
   19662     exit (3);
   19663   for (/* Niente */; exponent; --exponent)
   19664     res *= base;
   19665   return res;
   19666 }
   19667 
   19668 
   19669 int
   19670 main (int argc, const char **argv)
   19671 {
   19672   semantic_value result = 0;
   19673   int count = 0;
   19674   int status;
   19675 
   19676   /* This used to be alarm (10), but that isn't enough time for
   19677      a July 1995 vintage DEC Alphastation 200 4/100 system,
   19678      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   19679   alarm (100);
   19680 
   19681   if (argc == 2)
   19682     input = fopen (argv[1], "r");
   19683   else
   19684     input = stdin;
   19685 
   19686   if (!input)
   19687     {
   19688       perror (argv[1]);
   19689       return 3;
   19690     }
   19691 
   19692 
   19693   status = yyparse ();
   19694   if (global_result != result)
   19695     abort ();
   19696   if (global_count != count)
   19697     abort ();
   19698   return status;
   19699 }
   19700 _ATEOF
   19701 
   19702 
   19703 
   19704 
   19705 
   19706 $at_traceoff
   19707 echo "calc.at:559: bison -o calc.c calc.y"
   19708 echo calc.at:559 >$at_check_line_file
   19709 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   19710 at_status=$?
   19711 grep '^ *+' $at_stder1 >&2
   19712 grep -v '^ *+' $at_stder1 >$at_stderr
   19713 at_failed=false
   19714 $at_diff $at_devnull $at_stderr || at_failed=:
   19715 $at_diff $at_devnull $at_stdout || at_failed=:
   19716 case $at_status in
   19717    77) echo 77 > $at_status_file
   19718             exit 77;;
   19719    0) ;;
   19720    *) echo "calc.at:559: exit code was $at_status, expected 0"
   19721       at_failed=:;;
   19722 esac
   19723 if $at_failed; then
   19724 
   19725   echo 1 > $at_status_file
   19726   exit 1
   19727 fi
   19728 
   19729 $at_traceon
   19730 
   19731    $at_traceoff
   19732 echo "calc.at:559: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   19733 echo calc.at:559 >$at_check_line_file
   19734 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   19735 at_status=$?
   19736 grep '^ *+' $at_stder1 >&2
   19737 grep -v '^ *+' $at_stder1 >$at_stderr
   19738 at_failed=false
   19739 echo stderr:; cat $at_stderr
   19740 echo stdout:; cat $at_stdout
   19741 case $at_status in
   19742    77) echo 77 > $at_status_file
   19743             exit 77;;
   19744    0) ;;
   19745    *) echo "calc.at:559: exit code was $at_status, expected 0"
   19746       at_failed=:;;
   19747 esac
   19748 if $at_failed; then
   19749 
   19750   echo 1 > $at_status_file
   19751   exit 1
   19752 fi
   19753 
   19754 $at_traceon
   19755 
   19756 
   19757 # Test the priorities.
   19758 cat >input <<'_ATEOF'
   19759 1 + 2 * 3 = 7
   19760 1 + 2 * -3 = -5
   19761 
   19762 -1^2 = -1
   19763 (-1)^2 = 1
   19764 
   19765 ---1 = -1
   19766 
   19767 1 - 2 - 3 = -4
   19768 1 - (2 - 3) = 2
   19769 
   19770 2^2^3 = 256
   19771 (2^2)^3 = 64
   19772 _ATEOF
   19773 
   19774 $at_traceoff
   19775 echo "calc.at:559: \$PREPARSER ./calc input"
   19776 echo calc.at:559 >$at_check_line_file
   19777 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19778 at_status=$?
   19779 grep '^ *+' $at_stder1 >&2
   19780 grep -v '^ *+' $at_stder1 >$at_stderr
   19781 at_failed=false
   19782 echo stderr:; tee stderr <$at_stderr
   19783 $at_diff $at_devnull $at_stdout || at_failed=:
   19784 case $at_status in
   19785    77) echo 77 > $at_status_file
   19786             exit 77;;
   19787    0) ;;
   19788    *) echo "calc.at:559: exit code was $at_status, expected 0"
   19789       at_failed=:;;
   19790 esac
   19791 if $at_failed; then
   19792 
   19793   echo 1 > $at_status_file
   19794   exit 1
   19795 fi
   19796 
   19797 $at_traceon
   19798 
   19799 
   19800 
   19801 # Some syntax errors.
   19802 cat >input <<'_ATEOF'
   19803 0 0
   19804 _ATEOF
   19805 
   19806 $at_traceoff
   19807 echo "calc.at:559: \$PREPARSER ./calc input"
   19808 echo calc.at:559 >$at_check_line_file
   19809 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19810 at_status=$?
   19811 grep '^ *+' $at_stder1 >&2
   19812 grep -v '^ *+' $at_stder1 >$at_stderr
   19813 at_failed=false
   19814 echo stderr:; tee stderr <$at_stderr
   19815 $at_diff $at_devnull $at_stdout || at_failed=:
   19816 case $at_status in
   19817    77) echo 77 > $at_status_file
   19818             exit 77;;
   19819    1) ;;
   19820    *) echo "calc.at:559: exit code was $at_status, expected 1"
   19821       at_failed=:;;
   19822 esac
   19823 if $at_failed; then
   19824 
   19825   echo 1 > $at_status_file
   19826   exit 1
   19827 fi
   19828 
   19829 $at_traceon
   19830 
   19831 
   19832 # Normalize the observed and expected error messages, depending upon the
   19833 # options.
   19834 # 1. Remove the traces from observed.
   19835 sed '/^Starting/d
   19836 /^Entering/d
   19837 /^Stack/d
   19838 /^Reading/d
   19839 /^Reducing/d
   19840 /^Shifting/d
   19841 /^state/d
   19842 /^Cleanup:/d
   19843 /^Error:/d
   19844 /^Next/d
   19845 /^Discarding/d
   19846 / \$[0-9$]* = /d
   19847 /^yydestructor:/d' stderr >at-stderr
   19848 mv at-stderr stderr
   19849 # 2. Create the reference error message.
   19850 cat >expout <<'_ATEOF'
   19851 1.2: syntax error, unexpected number
   19852 _ATEOF
   19853 
   19854 # 3. If locations are not used, remove them.
   19855 sed 's/^[-0-9.]*: //' expout >at-expout
   19856 mv at-expout expout
   19857 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   19858 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   19859 mv at-expout expout
   19860 # 5. Check
   19861 $at_traceoff
   19862 echo "calc.at:559: cat stderr"
   19863 echo calc.at:559 >$at_check_line_file
   19864 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   19865 at_status=$?
   19866 grep '^ *+' $at_stder1 >&2
   19867 grep -v '^ *+' $at_stder1 >$at_stderr
   19868 at_failed=false
   19869 $at_diff $at_devnull $at_stderr || at_failed=:
   19870 $at_diff expout $at_stdout || at_failed=:
   19871 case $at_status in
   19872    77) echo 77 > $at_status_file
   19873             exit 77;;
   19874    0) ;;
   19875    *) echo "calc.at:559: exit code was $at_status, expected 0"
   19876       at_failed=:;;
   19877 esac
   19878 if $at_failed; then
   19879 
   19880   echo 1 > $at_status_file
   19881   exit 1
   19882 fi
   19883 
   19884 $at_traceon
   19885 
   19886 
   19887 cat >input <<'_ATEOF'
   19888 1//2
   19889 _ATEOF
   19890 
   19891 $at_traceoff
   19892 echo "calc.at:559: \$PREPARSER ./calc input"
   19893 echo calc.at:559 >$at_check_line_file
   19894 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19895 at_status=$?
   19896 grep '^ *+' $at_stder1 >&2
   19897 grep -v '^ *+' $at_stder1 >$at_stderr
   19898 at_failed=false
   19899 echo stderr:; tee stderr <$at_stderr
   19900 $at_diff $at_devnull $at_stdout || at_failed=:
   19901 case $at_status in
   19902    77) echo 77 > $at_status_file
   19903             exit 77;;
   19904    1) ;;
   19905    *) echo "calc.at:559: exit code was $at_status, expected 1"
   19906       at_failed=:;;
   19907 esac
   19908 if $at_failed; then
   19909 
   19910   echo 1 > $at_status_file
   19911   exit 1
   19912 fi
   19913 
   19914 $at_traceon
   19915 
   19916 
   19917 # Normalize the observed and expected error messages, depending upon the
   19918 # options.
   19919 # 1. Remove the traces from observed.
   19920 sed '/^Starting/d
   19921 /^Entering/d
   19922 /^Stack/d
   19923 /^Reading/d
   19924 /^Reducing/d
   19925 /^Shifting/d
   19926 /^state/d
   19927 /^Cleanup:/d
   19928 /^Error:/d
   19929 /^Next/d
   19930 /^Discarding/d
   19931 / \$[0-9$]* = /d
   19932 /^yydestructor:/d' stderr >at-stderr
   19933 mv at-stderr stderr
   19934 # 2. Create the reference error message.
   19935 cat >expout <<'_ATEOF'
   19936 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   19937 _ATEOF
   19938 
   19939 # 3. If locations are not used, remove them.
   19940 sed 's/^[-0-9.]*: //' expout >at-expout
   19941 mv at-expout expout
   19942 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   19943 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   19944 mv at-expout expout
   19945 # 5. Check
   19946 $at_traceoff
   19947 echo "calc.at:559: cat stderr"
   19948 echo calc.at:559 >$at_check_line_file
   19949 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   19950 at_status=$?
   19951 grep '^ *+' $at_stder1 >&2
   19952 grep -v '^ *+' $at_stder1 >$at_stderr
   19953 at_failed=false
   19954 $at_diff $at_devnull $at_stderr || at_failed=:
   19955 $at_diff expout $at_stdout || at_failed=:
   19956 case $at_status in
   19957    77) echo 77 > $at_status_file
   19958             exit 77;;
   19959    0) ;;
   19960    *) echo "calc.at:559: exit code was $at_status, expected 0"
   19961       at_failed=:;;
   19962 esac
   19963 if $at_failed; then
   19964 
   19965   echo 1 > $at_status_file
   19966   exit 1
   19967 fi
   19968 
   19969 $at_traceon
   19970 
   19971 
   19972 cat >input <<'_ATEOF'
   19973 error
   19974 _ATEOF
   19975 
   19976 $at_traceoff
   19977 echo "calc.at:559: \$PREPARSER ./calc input"
   19978 echo calc.at:559 >$at_check_line_file
   19979 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19980 at_status=$?
   19981 grep '^ *+' $at_stder1 >&2
   19982 grep -v '^ *+' $at_stder1 >$at_stderr
   19983 at_failed=false
   19984 echo stderr:; tee stderr <$at_stderr
   19985 $at_diff $at_devnull $at_stdout || at_failed=:
   19986 case $at_status in
   19987    77) echo 77 > $at_status_file
   19988             exit 77;;
   19989    1) ;;
   19990    *) echo "calc.at:559: exit code was $at_status, expected 1"
   19991       at_failed=:;;
   19992 esac
   19993 if $at_failed; then
   19994 
   19995   echo 1 > $at_status_file
   19996   exit 1
   19997 fi
   19998 
   19999 $at_traceon
   20000 
   20001 
   20002 # Normalize the observed and expected error messages, depending upon the
   20003 # options.
   20004 # 1. Remove the traces from observed.
   20005 sed '/^Starting/d
   20006 /^Entering/d
   20007 /^Stack/d
   20008 /^Reading/d
   20009 /^Reducing/d
   20010 /^Shifting/d
   20011 /^state/d
   20012 /^Cleanup:/d
   20013 /^Error:/d
   20014 /^Next/d
   20015 /^Discarding/d
   20016 / \$[0-9$]* = /d
   20017 /^yydestructor:/d' stderr >at-stderr
   20018 mv at-stderr stderr
   20019 # 2. Create the reference error message.
   20020 cat >expout <<'_ATEOF'
   20021 1.0: syntax error, unexpected $undefined
   20022 _ATEOF
   20023 
   20024 # 3. If locations are not used, remove them.
   20025 sed 's/^[-0-9.]*: //' expout >at-expout
   20026 mv at-expout expout
   20027 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   20028 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   20029 mv at-expout expout
   20030 # 5. Check
   20031 $at_traceoff
   20032 echo "calc.at:559: cat stderr"
   20033 echo calc.at:559 >$at_check_line_file
   20034 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   20035 at_status=$?
   20036 grep '^ *+' $at_stder1 >&2
   20037 grep -v '^ *+' $at_stder1 >$at_stderr
   20038 at_failed=false
   20039 $at_diff $at_devnull $at_stderr || at_failed=:
   20040 $at_diff expout $at_stdout || at_failed=:
   20041 case $at_status in
   20042    77) echo 77 > $at_status_file
   20043             exit 77;;
   20044    0) ;;
   20045    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20046       at_failed=:;;
   20047 esac
   20048 if $at_failed; then
   20049 
   20050   echo 1 > $at_status_file
   20051   exit 1
   20052 fi
   20053 
   20054 $at_traceon
   20055 
   20056 
   20057 cat >input <<'_ATEOF'
   20058 1 = 2 = 3
   20059 _ATEOF
   20060 
   20061 $at_traceoff
   20062 echo "calc.at:559: \$PREPARSER ./calc input"
   20063 echo calc.at:559 >$at_check_line_file
   20064 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   20065 at_status=$?
   20066 grep '^ *+' $at_stder1 >&2
   20067 grep -v '^ *+' $at_stder1 >$at_stderr
   20068 at_failed=false
   20069 echo stderr:; tee stderr <$at_stderr
   20070 $at_diff $at_devnull $at_stdout || at_failed=:
   20071 case $at_status in
   20072    77) echo 77 > $at_status_file
   20073             exit 77;;
   20074    1) ;;
   20075    *) echo "calc.at:559: exit code was $at_status, expected 1"
   20076       at_failed=:;;
   20077 esac
   20078 if $at_failed; then
   20079 
   20080   echo 1 > $at_status_file
   20081   exit 1
   20082 fi
   20083 
   20084 $at_traceon
   20085 
   20086 
   20087 # Normalize the observed and expected error messages, depending upon the
   20088 # options.
   20089 # 1. Remove the traces from observed.
   20090 sed '/^Starting/d
   20091 /^Entering/d
   20092 /^Stack/d
   20093 /^Reading/d
   20094 /^Reducing/d
   20095 /^Shifting/d
   20096 /^state/d
   20097 /^Cleanup:/d
   20098 /^Error:/d
   20099 /^Next/d
   20100 /^Discarding/d
   20101 / \$[0-9$]* = /d
   20102 /^yydestructor:/d' stderr >at-stderr
   20103 mv at-stderr stderr
   20104 # 2. Create the reference error message.
   20105 cat >expout <<'_ATEOF'
   20106 1.6: syntax error, unexpected '='
   20107 _ATEOF
   20108 
   20109 # 3. If locations are not used, remove them.
   20110 sed 's/^[-0-9.]*: //' expout >at-expout
   20111 mv at-expout expout
   20112 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   20113 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   20114 mv at-expout expout
   20115 # 5. Check
   20116 $at_traceoff
   20117 echo "calc.at:559: cat stderr"
   20118 echo calc.at:559 >$at_check_line_file
   20119 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   20120 at_status=$?
   20121 grep '^ *+' $at_stder1 >&2
   20122 grep -v '^ *+' $at_stder1 >$at_stderr
   20123 at_failed=false
   20124 $at_diff $at_devnull $at_stderr || at_failed=:
   20125 $at_diff expout $at_stdout || at_failed=:
   20126 case $at_status in
   20127    77) echo 77 > $at_status_file
   20128             exit 77;;
   20129    0) ;;
   20130    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20131       at_failed=:;;
   20132 esac
   20133 if $at_failed; then
   20134 
   20135   echo 1 > $at_status_file
   20136   exit 1
   20137 fi
   20138 
   20139 $at_traceon
   20140 
   20141 
   20142 cat >input <<'_ATEOF'
   20143 
   20144 +1
   20145 _ATEOF
   20146 
   20147 $at_traceoff
   20148 echo "calc.at:559: \$PREPARSER ./calc input"
   20149 echo calc.at:559 >$at_check_line_file
   20150 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   20151 at_status=$?
   20152 grep '^ *+' $at_stder1 >&2
   20153 grep -v '^ *+' $at_stder1 >$at_stderr
   20154 at_failed=false
   20155 echo stderr:; tee stderr <$at_stderr
   20156 $at_diff $at_devnull $at_stdout || at_failed=:
   20157 case $at_status in
   20158    77) echo 77 > $at_status_file
   20159             exit 77;;
   20160    1) ;;
   20161    *) echo "calc.at:559: exit code was $at_status, expected 1"
   20162       at_failed=:;;
   20163 esac
   20164 if $at_failed; then
   20165 
   20166   echo 1 > $at_status_file
   20167   exit 1
   20168 fi
   20169 
   20170 $at_traceon
   20171 
   20172 
   20173 # Normalize the observed and expected error messages, depending upon the
   20174 # options.
   20175 # 1. Remove the traces from observed.
   20176 sed '/^Starting/d
   20177 /^Entering/d
   20178 /^Stack/d
   20179 /^Reading/d
   20180 /^Reducing/d
   20181 /^Shifting/d
   20182 /^state/d
   20183 /^Cleanup:/d
   20184 /^Error:/d
   20185 /^Next/d
   20186 /^Discarding/d
   20187 / \$[0-9$]* = /d
   20188 /^yydestructor:/d' stderr >at-stderr
   20189 mv at-stderr stderr
   20190 # 2. Create the reference error message.
   20191 cat >expout <<'_ATEOF'
   20192 2.0: syntax error, unexpected '+'
   20193 _ATEOF
   20194 
   20195 # 3. If locations are not used, remove them.
   20196 sed 's/^[-0-9.]*: //' expout >at-expout
   20197 mv at-expout expout
   20198 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   20199 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   20200 mv at-expout expout
   20201 # 5. Check
   20202 $at_traceoff
   20203 echo "calc.at:559: cat stderr"
   20204 echo calc.at:559 >$at_check_line_file
   20205 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   20206 at_status=$?
   20207 grep '^ *+' $at_stder1 >&2
   20208 grep -v '^ *+' $at_stder1 >$at_stderr
   20209 at_failed=false
   20210 $at_diff $at_devnull $at_stderr || at_failed=:
   20211 $at_diff expout $at_stdout || at_failed=:
   20212 case $at_status in
   20213    77) echo 77 > $at_status_file
   20214             exit 77;;
   20215    0) ;;
   20216    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20217       at_failed=:;;
   20218 esac
   20219 if $at_failed; then
   20220 
   20221   echo 1 > $at_status_file
   20222   exit 1
   20223 fi
   20224 
   20225 $at_traceon
   20226 
   20227 
   20228 # Exercise error messages with EOF: work on an empty file.
   20229 $at_traceoff
   20230 echo "calc.at:559: \$PREPARSER ./calc /dev/null"
   20231 echo calc.at:559 >$at_check_line_file
   20232 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   20233 at_status=$?
   20234 grep '^ *+' $at_stder1 >&2
   20235 grep -v '^ *+' $at_stder1 >$at_stderr
   20236 at_failed=false
   20237 echo stderr:; tee stderr <$at_stderr
   20238 $at_diff $at_devnull $at_stdout || at_failed=:
   20239 case $at_status in
   20240    77) echo 77 > $at_status_file
   20241             exit 77;;
   20242    1) ;;
   20243    *) echo "calc.at:559: exit code was $at_status, expected 1"
   20244       at_failed=:;;
   20245 esac
   20246 if $at_failed; then
   20247 
   20248   echo 1 > $at_status_file
   20249   exit 1
   20250 fi
   20251 
   20252 $at_traceon
   20253 
   20254 
   20255 # Normalize the observed and expected error messages, depending upon the
   20256 # options.
   20257 # 1. Remove the traces from observed.
   20258 sed '/^Starting/d
   20259 /^Entering/d
   20260 /^Stack/d
   20261 /^Reading/d
   20262 /^Reducing/d
   20263 /^Shifting/d
   20264 /^state/d
   20265 /^Cleanup:/d
   20266 /^Error:/d
   20267 /^Next/d
   20268 /^Discarding/d
   20269 / \$[0-9$]* = /d
   20270 /^yydestructor:/d' stderr >at-stderr
   20271 mv at-stderr stderr
   20272 # 2. Create the reference error message.
   20273 cat >expout <<'_ATEOF'
   20274 1.0: syntax error, unexpected end of input
   20275 _ATEOF
   20276 
   20277 # 3. If locations are not used, remove them.
   20278 sed 's/^[-0-9.]*: //' expout >at-expout
   20279 mv at-expout expout
   20280 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   20281 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   20282 mv at-expout expout
   20283 # 5. Check
   20284 $at_traceoff
   20285 echo "calc.at:559: cat stderr"
   20286 echo calc.at:559 >$at_check_line_file
   20287 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   20288 at_status=$?
   20289 grep '^ *+' $at_stder1 >&2
   20290 grep -v '^ *+' $at_stder1 >$at_stderr
   20291 at_failed=false
   20292 $at_diff $at_devnull $at_stderr || at_failed=:
   20293 $at_diff expout $at_stdout || at_failed=:
   20294 case $at_status in
   20295    77) echo 77 > $at_status_file
   20296             exit 77;;
   20297    0) ;;
   20298    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20299       at_failed=:;;
   20300 esac
   20301 if $at_failed; then
   20302 
   20303   echo 1 > $at_status_file
   20304   exit 1
   20305 fi
   20306 
   20307 $at_traceon
   20308 
   20309 
   20310 
   20311 # Exercise the error token: without it, we die at the first error,
   20312 # hence be sure to
   20313 #
   20314 # - have several errors which exercise different shift/discardings
   20315 #   - (): nothing to pop, nothing to discard
   20316 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   20317 #   - (* * *): nothing to pop, a lot to discard
   20318 #   - (1 + 2 * *): some to pop and discard
   20319 #
   20320 # - test the action associated to `error'
   20321 #
   20322 # - check the look-ahead that triggers an error is not discarded
   20323 #   when we enter error recovery.  Below, the look-ahead causing the
   20324 #   first error is ")", which is needed to recover from the error and
   20325 #   produce the "0" that triggers the "0 != 1" error.
   20326 #
   20327 cat >input <<'_ATEOF'
   20328 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   20329 _ATEOF
   20330 
   20331 $at_traceoff
   20332 echo "calc.at:559: \$PREPARSER ./calc input"
   20333 echo calc.at:559 >$at_check_line_file
   20334 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   20335 at_status=$?
   20336 grep '^ *+' $at_stder1 >&2
   20337 grep -v '^ *+' $at_stder1 >$at_stderr
   20338 at_failed=false
   20339 echo stderr:; tee stderr <$at_stderr
   20340 $at_diff $at_devnull $at_stdout || at_failed=:
   20341 case $at_status in
   20342    77) echo 77 > $at_status_file
   20343             exit 77;;
   20344    0) ;;
   20345    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20346       at_failed=:;;
   20347 esac
   20348 if $at_failed; then
   20349 
   20350   echo 1 > $at_status_file
   20351   exit 1
   20352 fi
   20353 
   20354 $at_traceon
   20355 
   20356 
   20357 # Normalize the observed and expected error messages, depending upon the
   20358 # options.
   20359 # 1. Remove the traces from observed.
   20360 sed '/^Starting/d
   20361 /^Entering/d
   20362 /^Stack/d
   20363 /^Reading/d
   20364 /^Reducing/d
   20365 /^Shifting/d
   20366 /^state/d
   20367 /^Cleanup:/d
   20368 /^Error:/d
   20369 /^Next/d
   20370 /^Discarding/d
   20371 / \$[0-9$]* = /d
   20372 /^yydestructor:/d' stderr >at-stderr
   20373 mv at-stderr stderr
   20374 # 2. Create the reference error message.
   20375 cat >expout <<'_ATEOF'
   20376 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   20377 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   20378 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   20379 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   20380 calc: error: 4444 != 1
   20381 _ATEOF
   20382 
   20383 # 3. If locations are not used, remove them.
   20384 sed 's/^[-0-9.]*: //' expout >at-expout
   20385 mv at-expout expout
   20386 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   20387 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   20388 mv at-expout expout
   20389 # 5. Check
   20390 $at_traceoff
   20391 echo "calc.at:559: cat stderr"
   20392 echo calc.at:559 >$at_check_line_file
   20393 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   20394 at_status=$?
   20395 grep '^ *+' $at_stder1 >&2
   20396 grep -v '^ *+' $at_stder1 >$at_stderr
   20397 at_failed=false
   20398 $at_diff $at_devnull $at_stderr || at_failed=:
   20399 $at_diff expout $at_stdout || at_failed=:
   20400 case $at_status in
   20401    77) echo 77 > $at_status_file
   20402             exit 77;;
   20403    0) ;;
   20404    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20405       at_failed=:;;
   20406 esac
   20407 if $at_failed; then
   20408 
   20409   echo 1 > $at_status_file
   20410   exit 1
   20411 fi
   20412 
   20413 $at_traceon
   20414 
   20415 
   20416 
   20417 # The same, but this time exercising explicitly triggered syntax errors.
   20418 # POSIX says the look-ahead causing the error should not be discarded.
   20419 cat >input <<'_ATEOF'
   20420 (!) + (0 0) = 1
   20421 _ATEOF
   20422 
   20423 $at_traceoff
   20424 echo "calc.at:559: \$PREPARSER ./calc input"
   20425 echo calc.at:559 >$at_check_line_file
   20426 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   20427 at_status=$?
   20428 grep '^ *+' $at_stder1 >&2
   20429 grep -v '^ *+' $at_stder1 >$at_stderr
   20430 at_failed=false
   20431 echo stderr:; tee stderr <$at_stderr
   20432 $at_diff $at_devnull $at_stdout || at_failed=:
   20433 case $at_status in
   20434    77) echo 77 > $at_status_file
   20435             exit 77;;
   20436    0) ;;
   20437    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20438       at_failed=:;;
   20439 esac
   20440 if $at_failed; then
   20441 
   20442   echo 1 > $at_status_file
   20443   exit 1
   20444 fi
   20445 
   20446 $at_traceon
   20447 
   20448 
   20449 # Normalize the observed and expected error messages, depending upon the
   20450 # options.
   20451 # 1. Remove the traces from observed.
   20452 sed '/^Starting/d
   20453 /^Entering/d
   20454 /^Stack/d
   20455 /^Reading/d
   20456 /^Reducing/d
   20457 /^Shifting/d
   20458 /^state/d
   20459 /^Cleanup:/d
   20460 /^Error:/d
   20461 /^Next/d
   20462 /^Discarding/d
   20463 / \$[0-9$]* = /d
   20464 /^yydestructor:/d' stderr >at-stderr
   20465 mv at-stderr stderr
   20466 # 2. Create the reference error message.
   20467 cat >expout <<'_ATEOF'
   20468 1.9: syntax error, unexpected number
   20469 calc: error: 2222 != 1
   20470 _ATEOF
   20471 
   20472 # 3. If locations are not used, remove them.
   20473 sed 's/^[-0-9.]*: //' expout >at-expout
   20474 mv at-expout expout
   20475 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   20476 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   20477 mv at-expout expout
   20478 # 5. Check
   20479 $at_traceoff
   20480 echo "calc.at:559: cat stderr"
   20481 echo calc.at:559 >$at_check_line_file
   20482 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   20483 at_status=$?
   20484 grep '^ *+' $at_stder1 >&2
   20485 grep -v '^ *+' $at_stder1 >$at_stderr
   20486 at_failed=false
   20487 $at_diff $at_devnull $at_stderr || at_failed=:
   20488 $at_diff expout $at_stdout || at_failed=:
   20489 case $at_status in
   20490    77) echo 77 > $at_status_file
   20491             exit 77;;
   20492    0) ;;
   20493    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20494       at_failed=:;;
   20495 esac
   20496 if $at_failed; then
   20497 
   20498   echo 1 > $at_status_file
   20499   exit 1
   20500 fi
   20501 
   20502 $at_traceon
   20503 
   20504 
   20505 cat >input <<'_ATEOF'
   20506 (- *) + (0 0) = 1
   20507 _ATEOF
   20508 
   20509 $at_traceoff
   20510 echo "calc.at:559: \$PREPARSER ./calc input"
   20511 echo calc.at:559 >$at_check_line_file
   20512 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   20513 at_status=$?
   20514 grep '^ *+' $at_stder1 >&2
   20515 grep -v '^ *+' $at_stder1 >$at_stderr
   20516 at_failed=false
   20517 echo stderr:; tee stderr <$at_stderr
   20518 $at_diff $at_devnull $at_stdout || at_failed=:
   20519 case $at_status in
   20520    77) echo 77 > $at_status_file
   20521             exit 77;;
   20522    0) ;;
   20523    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20524       at_failed=:;;
   20525 esac
   20526 if $at_failed; then
   20527 
   20528   echo 1 > $at_status_file
   20529   exit 1
   20530 fi
   20531 
   20532 $at_traceon
   20533 
   20534 
   20535 # Normalize the observed and expected error messages, depending upon the
   20536 # options.
   20537 # 1. Remove the traces from observed.
   20538 sed '/^Starting/d
   20539 /^Entering/d
   20540 /^Stack/d
   20541 /^Reading/d
   20542 /^Reducing/d
   20543 /^Shifting/d
   20544 /^state/d
   20545 /^Cleanup:/d
   20546 /^Error:/d
   20547 /^Next/d
   20548 /^Discarding/d
   20549 / \$[0-9$]* = /d
   20550 /^yydestructor:/d' stderr >at-stderr
   20551 mv at-stderr stderr
   20552 # 2. Create the reference error message.
   20553 cat >expout <<'_ATEOF'
   20554 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   20555 1.11: syntax error, unexpected number
   20556 calc: error: 2222 != 1
   20557 _ATEOF
   20558 
   20559 # 3. If locations are not used, remove them.
   20560 sed 's/^[-0-9.]*: //' expout >at-expout
   20561 mv at-expout expout
   20562 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   20563 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   20564 mv at-expout expout
   20565 # 5. Check
   20566 $at_traceoff
   20567 echo "calc.at:559: cat stderr"
   20568 echo calc.at:559 >$at_check_line_file
   20569 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   20570 at_status=$?
   20571 grep '^ *+' $at_stder1 >&2
   20572 grep -v '^ *+' $at_stder1 >$at_stderr
   20573 at_failed=false
   20574 $at_diff $at_devnull $at_stderr || at_failed=:
   20575 $at_diff expout $at_stdout || at_failed=:
   20576 case $at_status in
   20577    77) echo 77 > $at_status_file
   20578             exit 77;;
   20579    0) ;;
   20580    *) echo "calc.at:559: exit code was $at_status, expected 0"
   20581       at_failed=:;;
   20582 esac
   20583 if $at_failed; then
   20584 
   20585   echo 1 > $at_status_file
   20586   exit 1
   20587 fi
   20588 
   20589 $at_traceon
   20590 
   20591 
   20592 
   20593 
   20594 
   20595 
   20596 
   20597 
   20598 
   20599 
   20600 
   20601 
   20602 
   20603 
   20604 
   20605 
   20606 
   20607 
   20608 
   20609 
   20610 
   20611 
   20612 
   20613 
   20614       $at_traceoff
   20615       $at_times_p && times >$at_times_file
   20616     ) 5>&1 2>&1 | eval $at_tee_pipe
   20617     at_status=`cat $at_status_file`
   20618     ;;
   20619 
   20620   78 ) # 78. calc.at:560: Calculator %error-verbose %locations
   20621     at_setup_line='calc.at:560'
   20622     at_desc='Calculator %error-verbose %locations'
   20623     $at_quiet $ECHO_N " 78: Calculator %error-verbose %locations         $ECHO_C"
   20624     at_xfail=no
   20625     (
   20626       echo "78. calc.at:560: testing ..."
   20627       $at_traceon
   20628 
   20629 
   20630 
   20631 
   20632 
   20633 
   20634 
   20635 
   20636 # Using yacc.c?
   20637 
   20638 
   20639 
   20640 
   20641 
   20642 
   20643 
   20644 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   20645 
   20646 # yyerror always sees the locations (when activated), except if
   20647 # yacc & pure & !param.
   20648 
   20649 
   20650 # The interface is pure: either because %pure-parser, or because we
   20651 # are using the C++ parsers.
   20652 
   20653 
   20654 
   20655 
   20656 
   20657 
   20658 
   20659 
   20660 
   20661 
   20662 
   20663 
   20664 cat >calc.y <<'_ATEOF'
   20665 %{
   20666 #ifdef HAVE_CONFIG_H
   20667 # include <config.h>
   20668   /* We don't need perfect functions for these tests. */
   20669 # undef malloc
   20670 # undef memcmp
   20671 # undef realloc
   20672 #endif
   20673 %}
   20674 
   20675 /* Infix notation calculator--calc */
   20676 %error-verbose %locations
   20677 
   20678 %{
   20679 #include <stdio.h>
   20680 
   20681 #include <stdlib.h>
   20682 #include <string.h>
   20683 #if HAVE_UNISTD_H
   20684 # include <unistd.h>
   20685 #else
   20686 # undef alarm
   20687 # define alarm(seconds) /* empty */
   20688 #endif
   20689 #include <ctype.h>
   20690 #define USE(Var)
   20691 
   20692 /* Exercise pre-prologue dependency to %union.  */
   20693 typedef int semantic_value;
   20694 
   20695 static semantic_value global_result = 0;
   20696 static int global_count = 0;
   20697 %}
   20698 
   20699 /* Exercise %union. */
   20700 %union
   20701 {
   20702   semantic_value ival;
   20703 };
   20704 
   20705 %{
   20706 static int power (int base, int exponent);
   20707 /* yyerror receives the location if:
   20708    - %location & %pure & %glr
   20709    - %location & %pure & %yacc & %parse-param. */
   20710 static void yyerror (
   20711 
   20712                      const char *s
   20713                      );
   20714 static int yylex (void);
   20715 static int get_char (void);
   20716 static void unget_char ( int c);
   20717 %}
   20718 
   20719 
   20720 
   20721 /* Bison Declarations */
   20722 %token CALC_EOF 0 "end of input"
   20723 %token <ival> NUM "number"
   20724 %type  <ival> exp
   20725 
   20726 %nonassoc '=' /* comparison	       */
   20727 %left '-' '+'
   20728 %left '*' '/'
   20729 %left NEG     /* negation--unary minus */
   20730 %right '^'    /* exponentiation        */
   20731 
   20732 /* Grammar follows */
   20733 %%
   20734 input:
   20735   line
   20736 | input line         {  }
   20737 ;
   20738 
   20739 line:
   20740   '\n'
   20741 | exp '\n'           { USE ($1); }
   20742 ;
   20743 
   20744 exp:
   20745   NUM                { $$ = $1;             }
   20746 | exp '=' exp
   20747   {
   20748     if ($1 != $3)
   20749       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   20750     $$ = $1;
   20751   }
   20752 | exp '+' exp        { $$ = $1 + $3;        }
   20753 | exp '-' exp        { $$ = $1 - $3;        }
   20754 | exp '*' exp        { $$ = $1 * $3;        }
   20755 | exp '/' exp        { $$ = $1 / $3;        }
   20756 | '-' exp  %prec NEG { $$ = -$2;            }
   20757 | exp '^' exp        { $$ = power ($1, $3); }
   20758 | '(' exp ')'        { $$ = $2;             }
   20759 | '(' error ')'      { $$ = 1111;           }
   20760 | '!'                { $$ = 0; YYERROR;     }
   20761 | '-' error          { $$ = 0; YYERROR;     }
   20762 ;
   20763 %%
   20764 /* The input.  */
   20765 static FILE *input;
   20766 
   20767 static void
   20768 yyerror (
   20769 
   20770          const char *s)
   20771 {
   20772 
   20773 
   20774   fprintf (stderr, "%d.%d",
   20775            (yylloc).first_line, (yylloc).first_column);
   20776   if ((yylloc).first_line != (yylloc).last_line)
   20777     fprintf (stderr, "-%d.%d",
   20778 	     (yylloc).last_line,  (yylloc).last_column - 1);
   20779   else if ((yylloc).first_column != (yylloc).last_column - 1)
   20780     fprintf (stderr, "-%d",
   20781 	     (yylloc).last_column - 1);
   20782   fprintf (stderr, ": ");
   20783   fprintf (stderr, "%s\n", s);
   20784 }
   20785 
   20786 
   20787 
   20788 static YYLTYPE last_yylloc;
   20789 
   20790 static int
   20791 get_char (void)
   20792 {
   20793   int res = getc (input);
   20794   ;
   20795 
   20796   last_yylloc = (yylloc);
   20797   if (res == '\n')
   20798     {
   20799       (yylloc).last_line++;
   20800       (yylloc).last_column = 0;
   20801     }
   20802   else
   20803     (yylloc).last_column++;
   20804 
   20805   return res;
   20806 }
   20807 
   20808 
   20809 static void
   20810 unget_char ( int c)
   20811 {
   20812   ;
   20813 
   20814   /* Wrong when C == `\n'. */
   20815   (yylloc) = last_yylloc;
   20816 
   20817   ungetc (c, input);
   20818 }
   20819 
   20820 static int
   20821 read_signed_integer (void)
   20822 {
   20823   int c = get_char ();
   20824   int sign = 1;
   20825   int n = 0;
   20826 
   20827   ;
   20828   if (c == '-')
   20829     {
   20830       c = get_char ();
   20831       sign = -1;
   20832     }
   20833 
   20834   while (isdigit (c))
   20835     {
   20836       n = 10 * n + (c - '0');
   20837       c = get_char ();
   20838     }
   20839 
   20840   unget_char ( c);
   20841 
   20842   return sign * n;
   20843 }
   20844 
   20845 
   20846 
   20847 /*---------------------------------------------------------------.
   20848 | Lexical analyzer returns an integer on the stack and the token |
   20849 | NUM, or the ASCII character read if not a number.  Skips all   |
   20850 | blanks and tabs, returns 0 for EOF.                            |
   20851 `---------------------------------------------------------------*/
   20852 
   20853 static int
   20854 yylex (void)
   20855 {
   20856   static int init = 1;
   20857   int c;
   20858 
   20859   if (init)
   20860     {
   20861       init = 0;
   20862 
   20863       (yylloc).last_column = 0;
   20864       (yylloc).last_line = 1;
   20865 
   20866     }
   20867 
   20868 
   20869  (yylloc).first_column = (yylloc).last_column;
   20870   (yylloc).first_line   = (yylloc).last_line;
   20871 
   20872 
   20873   /* Skip white space.  */
   20874   while ((c = get_char ()) == ' ' || c == '\t')
   20875     {
   20876      (yylloc).first_column = (yylloc).last_column;
   20877       (yylloc).first_line   = (yylloc).last_line;
   20878 
   20879     }
   20880 
   20881   /* process numbers   */
   20882   if (c == '.' || isdigit (c))
   20883     {
   20884       unget_char ( c);
   20885       (yylval).ival = read_signed_integer ();
   20886       return NUM;
   20887     }
   20888 
   20889   /* Return end-of-file.  */
   20890   if (c == EOF)
   20891     return CALC_EOF;
   20892 
   20893   /* Return single chars. */
   20894   return c;
   20895 }
   20896 
   20897 static int
   20898 power (int base, int exponent)
   20899 {
   20900   int res = 1;
   20901   if (exponent < 0)
   20902     exit (3);
   20903   for (/* Niente */; exponent; --exponent)
   20904     res *= base;
   20905   return res;
   20906 }
   20907 
   20908 
   20909 int
   20910 main (int argc, const char **argv)
   20911 {
   20912   semantic_value result = 0;
   20913   int count = 0;
   20914   int status;
   20915 
   20916   /* This used to be alarm (10), but that isn't enough time for
   20917      a July 1995 vintage DEC Alphastation 200 4/100 system,
   20918      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   20919   alarm (100);
   20920 
   20921   if (argc == 2)
   20922     input = fopen (argv[1], "r");
   20923   else
   20924     input = stdin;
   20925 
   20926   if (!input)
   20927     {
   20928       perror (argv[1]);
   20929       return 3;
   20930     }
   20931 
   20932 
   20933   status = yyparse ();
   20934   if (global_result != result)
   20935     abort ();
   20936   if (global_count != count)
   20937     abort ();
   20938   return status;
   20939 }
   20940 _ATEOF
   20941 
   20942 
   20943 
   20944 
   20945 
   20946 $at_traceoff
   20947 echo "calc.at:560: bison -o calc.c calc.y"
   20948 echo calc.at:560 >$at_check_line_file
   20949 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   20950 at_status=$?
   20951 grep '^ *+' $at_stder1 >&2
   20952 grep -v '^ *+' $at_stder1 >$at_stderr
   20953 at_failed=false
   20954 $at_diff $at_devnull $at_stderr || at_failed=:
   20955 $at_diff $at_devnull $at_stdout || at_failed=:
   20956 case $at_status in
   20957    77) echo 77 > $at_status_file
   20958             exit 77;;
   20959    0) ;;
   20960    *) echo "calc.at:560: exit code was $at_status, expected 0"
   20961       at_failed=:;;
   20962 esac
   20963 if $at_failed; then
   20964 
   20965   echo 1 > $at_status_file
   20966   exit 1
   20967 fi
   20968 
   20969 $at_traceon
   20970 
   20971    $at_traceoff
   20972 echo "calc.at:560: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   20973 echo calc.at:560 >$at_check_line_file
   20974 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   20975 at_status=$?
   20976 grep '^ *+' $at_stder1 >&2
   20977 grep -v '^ *+' $at_stder1 >$at_stderr
   20978 at_failed=false
   20979 echo stderr:; cat $at_stderr
   20980 echo stdout:; cat $at_stdout
   20981 case $at_status in
   20982    77) echo 77 > $at_status_file
   20983             exit 77;;
   20984    0) ;;
   20985    *) echo "calc.at:560: exit code was $at_status, expected 0"
   20986       at_failed=:;;
   20987 esac
   20988 if $at_failed; then
   20989 
   20990   echo 1 > $at_status_file
   20991   exit 1
   20992 fi
   20993 
   20994 $at_traceon
   20995 
   20996 
   20997 # Test the priorities.
   20998 cat >input <<'_ATEOF'
   20999 1 + 2 * 3 = 7
   21000 1 + 2 * -3 = -5
   21001 
   21002 -1^2 = -1
   21003 (-1)^2 = 1
   21004 
   21005 ---1 = -1
   21006 
   21007 1 - 2 - 3 = -4
   21008 1 - (2 - 3) = 2
   21009 
   21010 2^2^3 = 256
   21011 (2^2)^3 = 64
   21012 _ATEOF
   21013 
   21014 $at_traceoff
   21015 echo "calc.at:560: \$PREPARSER ./calc input"
   21016 echo calc.at:560 >$at_check_line_file
   21017 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   21018 at_status=$?
   21019 grep '^ *+' $at_stder1 >&2
   21020 grep -v '^ *+' $at_stder1 >$at_stderr
   21021 at_failed=false
   21022 echo stderr:; tee stderr <$at_stderr
   21023 $at_diff $at_devnull $at_stdout || at_failed=:
   21024 case $at_status in
   21025    77) echo 77 > $at_status_file
   21026             exit 77;;
   21027    0) ;;
   21028    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21029       at_failed=:;;
   21030 esac
   21031 if $at_failed; then
   21032 
   21033   echo 1 > $at_status_file
   21034   exit 1
   21035 fi
   21036 
   21037 $at_traceon
   21038 
   21039 
   21040 
   21041 # Some syntax errors.
   21042 cat >input <<'_ATEOF'
   21043 0 0
   21044 _ATEOF
   21045 
   21046 $at_traceoff
   21047 echo "calc.at:560: \$PREPARSER ./calc input"
   21048 echo calc.at:560 >$at_check_line_file
   21049 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   21050 at_status=$?
   21051 grep '^ *+' $at_stder1 >&2
   21052 grep -v '^ *+' $at_stder1 >$at_stderr
   21053 at_failed=false
   21054 echo stderr:; tee stderr <$at_stderr
   21055 $at_diff $at_devnull $at_stdout || at_failed=:
   21056 case $at_status in
   21057    77) echo 77 > $at_status_file
   21058             exit 77;;
   21059    1) ;;
   21060    *) echo "calc.at:560: exit code was $at_status, expected 1"
   21061       at_failed=:;;
   21062 esac
   21063 if $at_failed; then
   21064 
   21065   echo 1 > $at_status_file
   21066   exit 1
   21067 fi
   21068 
   21069 $at_traceon
   21070 
   21071 
   21072 # Normalize the observed and expected error messages, depending upon the
   21073 # options.
   21074 # 1. Remove the traces from observed.
   21075 sed '/^Starting/d
   21076 /^Entering/d
   21077 /^Stack/d
   21078 /^Reading/d
   21079 /^Reducing/d
   21080 /^Shifting/d
   21081 /^state/d
   21082 /^Cleanup:/d
   21083 /^Error:/d
   21084 /^Next/d
   21085 /^Discarding/d
   21086 / \$[0-9$]* = /d
   21087 /^yydestructor:/d' stderr >at-stderr
   21088 mv at-stderr stderr
   21089 # 2. Create the reference error message.
   21090 cat >expout <<'_ATEOF'
   21091 1.2: syntax error, unexpected number
   21092 _ATEOF
   21093 
   21094 # 3. If locations are not used, remove them.
   21095 
   21096 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   21097 
   21098 # 5. Check
   21099 $at_traceoff
   21100 echo "calc.at:560: cat stderr"
   21101 echo calc.at:560 >$at_check_line_file
   21102 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   21103 at_status=$?
   21104 grep '^ *+' $at_stder1 >&2
   21105 grep -v '^ *+' $at_stder1 >$at_stderr
   21106 at_failed=false
   21107 $at_diff $at_devnull $at_stderr || at_failed=:
   21108 $at_diff expout $at_stdout || at_failed=:
   21109 case $at_status in
   21110    77) echo 77 > $at_status_file
   21111             exit 77;;
   21112    0) ;;
   21113    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21114       at_failed=:;;
   21115 esac
   21116 if $at_failed; then
   21117 
   21118   echo 1 > $at_status_file
   21119   exit 1
   21120 fi
   21121 
   21122 $at_traceon
   21123 
   21124 
   21125 cat >input <<'_ATEOF'
   21126 1//2
   21127 _ATEOF
   21128 
   21129 $at_traceoff
   21130 echo "calc.at:560: \$PREPARSER ./calc input"
   21131 echo calc.at:560 >$at_check_line_file
   21132 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   21133 at_status=$?
   21134 grep '^ *+' $at_stder1 >&2
   21135 grep -v '^ *+' $at_stder1 >$at_stderr
   21136 at_failed=false
   21137 echo stderr:; tee stderr <$at_stderr
   21138 $at_diff $at_devnull $at_stdout || at_failed=:
   21139 case $at_status in
   21140    77) echo 77 > $at_status_file
   21141             exit 77;;
   21142    1) ;;
   21143    *) echo "calc.at:560: exit code was $at_status, expected 1"
   21144       at_failed=:;;
   21145 esac
   21146 if $at_failed; then
   21147 
   21148   echo 1 > $at_status_file
   21149   exit 1
   21150 fi
   21151 
   21152 $at_traceon
   21153 
   21154 
   21155 # Normalize the observed and expected error messages, depending upon the
   21156 # options.
   21157 # 1. Remove the traces from observed.
   21158 sed '/^Starting/d
   21159 /^Entering/d
   21160 /^Stack/d
   21161 /^Reading/d
   21162 /^Reducing/d
   21163 /^Shifting/d
   21164 /^state/d
   21165 /^Cleanup:/d
   21166 /^Error:/d
   21167 /^Next/d
   21168 /^Discarding/d
   21169 / \$[0-9$]* = /d
   21170 /^yydestructor:/d' stderr >at-stderr
   21171 mv at-stderr stderr
   21172 # 2. Create the reference error message.
   21173 cat >expout <<'_ATEOF'
   21174 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   21175 _ATEOF
   21176 
   21177 # 3. If locations are not used, remove them.
   21178 
   21179 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   21180 
   21181 # 5. Check
   21182 $at_traceoff
   21183 echo "calc.at:560: cat stderr"
   21184 echo calc.at:560 >$at_check_line_file
   21185 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   21186 at_status=$?
   21187 grep '^ *+' $at_stder1 >&2
   21188 grep -v '^ *+' $at_stder1 >$at_stderr
   21189 at_failed=false
   21190 $at_diff $at_devnull $at_stderr || at_failed=:
   21191 $at_diff expout $at_stdout || at_failed=:
   21192 case $at_status in
   21193    77) echo 77 > $at_status_file
   21194             exit 77;;
   21195    0) ;;
   21196    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21197       at_failed=:;;
   21198 esac
   21199 if $at_failed; then
   21200 
   21201   echo 1 > $at_status_file
   21202   exit 1
   21203 fi
   21204 
   21205 $at_traceon
   21206 
   21207 
   21208 cat >input <<'_ATEOF'
   21209 error
   21210 _ATEOF
   21211 
   21212 $at_traceoff
   21213 echo "calc.at:560: \$PREPARSER ./calc input"
   21214 echo calc.at:560 >$at_check_line_file
   21215 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   21216 at_status=$?
   21217 grep '^ *+' $at_stder1 >&2
   21218 grep -v '^ *+' $at_stder1 >$at_stderr
   21219 at_failed=false
   21220 echo stderr:; tee stderr <$at_stderr
   21221 $at_diff $at_devnull $at_stdout || at_failed=:
   21222 case $at_status in
   21223    77) echo 77 > $at_status_file
   21224             exit 77;;
   21225    1) ;;
   21226    *) echo "calc.at:560: exit code was $at_status, expected 1"
   21227       at_failed=:;;
   21228 esac
   21229 if $at_failed; then
   21230 
   21231   echo 1 > $at_status_file
   21232   exit 1
   21233 fi
   21234 
   21235 $at_traceon
   21236 
   21237 
   21238 # Normalize the observed and expected error messages, depending upon the
   21239 # options.
   21240 # 1. Remove the traces from observed.
   21241 sed '/^Starting/d
   21242 /^Entering/d
   21243 /^Stack/d
   21244 /^Reading/d
   21245 /^Reducing/d
   21246 /^Shifting/d
   21247 /^state/d
   21248 /^Cleanup:/d
   21249 /^Error:/d
   21250 /^Next/d
   21251 /^Discarding/d
   21252 / \$[0-9$]* = /d
   21253 /^yydestructor:/d' stderr >at-stderr
   21254 mv at-stderr stderr
   21255 # 2. Create the reference error message.
   21256 cat >expout <<'_ATEOF'
   21257 1.0: syntax error, unexpected $undefined
   21258 _ATEOF
   21259 
   21260 # 3. If locations are not used, remove them.
   21261 
   21262 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   21263 
   21264 # 5. Check
   21265 $at_traceoff
   21266 echo "calc.at:560: cat stderr"
   21267 echo calc.at:560 >$at_check_line_file
   21268 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   21269 at_status=$?
   21270 grep '^ *+' $at_stder1 >&2
   21271 grep -v '^ *+' $at_stder1 >$at_stderr
   21272 at_failed=false
   21273 $at_diff $at_devnull $at_stderr || at_failed=:
   21274 $at_diff expout $at_stdout || at_failed=:
   21275 case $at_status in
   21276    77) echo 77 > $at_status_file
   21277             exit 77;;
   21278    0) ;;
   21279    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21280       at_failed=:;;
   21281 esac
   21282 if $at_failed; then
   21283 
   21284   echo 1 > $at_status_file
   21285   exit 1
   21286 fi
   21287 
   21288 $at_traceon
   21289 
   21290 
   21291 cat >input <<'_ATEOF'
   21292 1 = 2 = 3
   21293 _ATEOF
   21294 
   21295 $at_traceoff
   21296 echo "calc.at:560: \$PREPARSER ./calc input"
   21297 echo calc.at:560 >$at_check_line_file
   21298 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   21299 at_status=$?
   21300 grep '^ *+' $at_stder1 >&2
   21301 grep -v '^ *+' $at_stder1 >$at_stderr
   21302 at_failed=false
   21303 echo stderr:; tee stderr <$at_stderr
   21304 $at_diff $at_devnull $at_stdout || at_failed=:
   21305 case $at_status in
   21306    77) echo 77 > $at_status_file
   21307             exit 77;;
   21308    1) ;;
   21309    *) echo "calc.at:560: exit code was $at_status, expected 1"
   21310       at_failed=:;;
   21311 esac
   21312 if $at_failed; then
   21313 
   21314   echo 1 > $at_status_file
   21315   exit 1
   21316 fi
   21317 
   21318 $at_traceon
   21319 
   21320 
   21321 # Normalize the observed and expected error messages, depending upon the
   21322 # options.
   21323 # 1. Remove the traces from observed.
   21324 sed '/^Starting/d
   21325 /^Entering/d
   21326 /^Stack/d
   21327 /^Reading/d
   21328 /^Reducing/d
   21329 /^Shifting/d
   21330 /^state/d
   21331 /^Cleanup:/d
   21332 /^Error:/d
   21333 /^Next/d
   21334 /^Discarding/d
   21335 / \$[0-9$]* = /d
   21336 /^yydestructor:/d' stderr >at-stderr
   21337 mv at-stderr stderr
   21338 # 2. Create the reference error message.
   21339 cat >expout <<'_ATEOF'
   21340 1.6: syntax error, unexpected '='
   21341 _ATEOF
   21342 
   21343 # 3. If locations are not used, remove them.
   21344 
   21345 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   21346 
   21347 # 5. Check
   21348 $at_traceoff
   21349 echo "calc.at:560: cat stderr"
   21350 echo calc.at:560 >$at_check_line_file
   21351 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   21352 at_status=$?
   21353 grep '^ *+' $at_stder1 >&2
   21354 grep -v '^ *+' $at_stder1 >$at_stderr
   21355 at_failed=false
   21356 $at_diff $at_devnull $at_stderr || at_failed=:
   21357 $at_diff expout $at_stdout || at_failed=:
   21358 case $at_status in
   21359    77) echo 77 > $at_status_file
   21360             exit 77;;
   21361    0) ;;
   21362    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21363       at_failed=:;;
   21364 esac
   21365 if $at_failed; then
   21366 
   21367   echo 1 > $at_status_file
   21368   exit 1
   21369 fi
   21370 
   21371 $at_traceon
   21372 
   21373 
   21374 cat >input <<'_ATEOF'
   21375 
   21376 +1
   21377 _ATEOF
   21378 
   21379 $at_traceoff
   21380 echo "calc.at:560: \$PREPARSER ./calc input"
   21381 echo calc.at:560 >$at_check_line_file
   21382 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   21383 at_status=$?
   21384 grep '^ *+' $at_stder1 >&2
   21385 grep -v '^ *+' $at_stder1 >$at_stderr
   21386 at_failed=false
   21387 echo stderr:; tee stderr <$at_stderr
   21388 $at_diff $at_devnull $at_stdout || at_failed=:
   21389 case $at_status in
   21390    77) echo 77 > $at_status_file
   21391             exit 77;;
   21392    1) ;;
   21393    *) echo "calc.at:560: exit code was $at_status, expected 1"
   21394       at_failed=:;;
   21395 esac
   21396 if $at_failed; then
   21397 
   21398   echo 1 > $at_status_file
   21399   exit 1
   21400 fi
   21401 
   21402 $at_traceon
   21403 
   21404 
   21405 # Normalize the observed and expected error messages, depending upon the
   21406 # options.
   21407 # 1. Remove the traces from observed.
   21408 sed '/^Starting/d
   21409 /^Entering/d
   21410 /^Stack/d
   21411 /^Reading/d
   21412 /^Reducing/d
   21413 /^Shifting/d
   21414 /^state/d
   21415 /^Cleanup:/d
   21416 /^Error:/d
   21417 /^Next/d
   21418 /^Discarding/d
   21419 / \$[0-9$]* = /d
   21420 /^yydestructor:/d' stderr >at-stderr
   21421 mv at-stderr stderr
   21422 # 2. Create the reference error message.
   21423 cat >expout <<'_ATEOF'
   21424 2.0: syntax error, unexpected '+'
   21425 _ATEOF
   21426 
   21427 # 3. If locations are not used, remove them.
   21428 
   21429 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   21430 
   21431 # 5. Check
   21432 $at_traceoff
   21433 echo "calc.at:560: cat stderr"
   21434 echo calc.at:560 >$at_check_line_file
   21435 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   21436 at_status=$?
   21437 grep '^ *+' $at_stder1 >&2
   21438 grep -v '^ *+' $at_stder1 >$at_stderr
   21439 at_failed=false
   21440 $at_diff $at_devnull $at_stderr || at_failed=:
   21441 $at_diff expout $at_stdout || at_failed=:
   21442 case $at_status in
   21443    77) echo 77 > $at_status_file
   21444             exit 77;;
   21445    0) ;;
   21446    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21447       at_failed=:;;
   21448 esac
   21449 if $at_failed; then
   21450 
   21451   echo 1 > $at_status_file
   21452   exit 1
   21453 fi
   21454 
   21455 $at_traceon
   21456 
   21457 
   21458 # Exercise error messages with EOF: work on an empty file.
   21459 $at_traceoff
   21460 echo "calc.at:560: \$PREPARSER ./calc /dev/null"
   21461 echo calc.at:560 >$at_check_line_file
   21462 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   21463 at_status=$?
   21464 grep '^ *+' $at_stder1 >&2
   21465 grep -v '^ *+' $at_stder1 >$at_stderr
   21466 at_failed=false
   21467 echo stderr:; tee stderr <$at_stderr
   21468 $at_diff $at_devnull $at_stdout || at_failed=:
   21469 case $at_status in
   21470    77) echo 77 > $at_status_file
   21471             exit 77;;
   21472    1) ;;
   21473    *) echo "calc.at:560: exit code was $at_status, expected 1"
   21474       at_failed=:;;
   21475 esac
   21476 if $at_failed; then
   21477 
   21478   echo 1 > $at_status_file
   21479   exit 1
   21480 fi
   21481 
   21482 $at_traceon
   21483 
   21484 
   21485 # Normalize the observed and expected error messages, depending upon the
   21486 # options.
   21487 # 1. Remove the traces from observed.
   21488 sed '/^Starting/d
   21489 /^Entering/d
   21490 /^Stack/d
   21491 /^Reading/d
   21492 /^Reducing/d
   21493 /^Shifting/d
   21494 /^state/d
   21495 /^Cleanup:/d
   21496 /^Error:/d
   21497 /^Next/d
   21498 /^Discarding/d
   21499 / \$[0-9$]* = /d
   21500 /^yydestructor:/d' stderr >at-stderr
   21501 mv at-stderr stderr
   21502 # 2. Create the reference error message.
   21503 cat >expout <<'_ATEOF'
   21504 1.0: syntax error, unexpected end of input
   21505 _ATEOF
   21506 
   21507 # 3. If locations are not used, remove them.
   21508 
   21509 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   21510 
   21511 # 5. Check
   21512 $at_traceoff
   21513 echo "calc.at:560: cat stderr"
   21514 echo calc.at:560 >$at_check_line_file
   21515 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   21516 at_status=$?
   21517 grep '^ *+' $at_stder1 >&2
   21518 grep -v '^ *+' $at_stder1 >$at_stderr
   21519 at_failed=false
   21520 $at_diff $at_devnull $at_stderr || at_failed=:
   21521 $at_diff expout $at_stdout || at_failed=:
   21522 case $at_status in
   21523    77) echo 77 > $at_status_file
   21524             exit 77;;
   21525    0) ;;
   21526    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21527       at_failed=:;;
   21528 esac
   21529 if $at_failed; then
   21530 
   21531   echo 1 > $at_status_file
   21532   exit 1
   21533 fi
   21534 
   21535 $at_traceon
   21536 
   21537 
   21538 
   21539 # Exercise the error token: without it, we die at the first error,
   21540 # hence be sure to
   21541 #
   21542 # - have several errors which exercise different shift/discardings
   21543 #   - (): nothing to pop, nothing to discard
   21544 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   21545 #   - (* * *): nothing to pop, a lot to discard
   21546 #   - (1 + 2 * *): some to pop and discard
   21547 #
   21548 # - test the action associated to `error'
   21549 #
   21550 # - check the look-ahead that triggers an error is not discarded
   21551 #   when we enter error recovery.  Below, the look-ahead causing the
   21552 #   first error is ")", which is needed to recover from the error and
   21553 #   produce the "0" that triggers the "0 != 1" error.
   21554 #
   21555 cat >input <<'_ATEOF'
   21556 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   21557 _ATEOF
   21558 
   21559 $at_traceoff
   21560 echo "calc.at:560: \$PREPARSER ./calc input"
   21561 echo calc.at:560 >$at_check_line_file
   21562 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   21563 at_status=$?
   21564 grep '^ *+' $at_stder1 >&2
   21565 grep -v '^ *+' $at_stder1 >$at_stderr
   21566 at_failed=false
   21567 echo stderr:; tee stderr <$at_stderr
   21568 $at_diff $at_devnull $at_stdout || at_failed=:
   21569 case $at_status in
   21570    77) echo 77 > $at_status_file
   21571             exit 77;;
   21572    0) ;;
   21573    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21574       at_failed=:;;
   21575 esac
   21576 if $at_failed; then
   21577 
   21578   echo 1 > $at_status_file
   21579   exit 1
   21580 fi
   21581 
   21582 $at_traceon
   21583 
   21584 
   21585 # Normalize the observed and expected error messages, depending upon the
   21586 # options.
   21587 # 1. Remove the traces from observed.
   21588 sed '/^Starting/d
   21589 /^Entering/d
   21590 /^Stack/d
   21591 /^Reading/d
   21592 /^Reducing/d
   21593 /^Shifting/d
   21594 /^state/d
   21595 /^Cleanup:/d
   21596 /^Error:/d
   21597 /^Next/d
   21598 /^Discarding/d
   21599 / \$[0-9$]* = /d
   21600 /^yydestructor:/d' stderr >at-stderr
   21601 mv at-stderr stderr
   21602 # 2. Create the reference error message.
   21603 cat >expout <<'_ATEOF'
   21604 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   21605 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   21606 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   21607 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   21608 calc: error: 4444 != 1
   21609 _ATEOF
   21610 
   21611 # 3. If locations are not used, remove them.
   21612 
   21613 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   21614 
   21615 # 5. Check
   21616 $at_traceoff
   21617 echo "calc.at:560: cat stderr"
   21618 echo calc.at:560 >$at_check_line_file
   21619 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   21620 at_status=$?
   21621 grep '^ *+' $at_stder1 >&2
   21622 grep -v '^ *+' $at_stder1 >$at_stderr
   21623 at_failed=false
   21624 $at_diff $at_devnull $at_stderr || at_failed=:
   21625 $at_diff expout $at_stdout || at_failed=:
   21626 case $at_status in
   21627    77) echo 77 > $at_status_file
   21628             exit 77;;
   21629    0) ;;
   21630    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21631       at_failed=:;;
   21632 esac
   21633 if $at_failed; then
   21634 
   21635   echo 1 > $at_status_file
   21636   exit 1
   21637 fi
   21638 
   21639 $at_traceon
   21640 
   21641 
   21642 
   21643 # The same, but this time exercising explicitly triggered syntax errors.
   21644 # POSIX says the look-ahead causing the error should not be discarded.
   21645 cat >input <<'_ATEOF'
   21646 (!) + (0 0) = 1
   21647 _ATEOF
   21648 
   21649 $at_traceoff
   21650 echo "calc.at:560: \$PREPARSER ./calc input"
   21651 echo calc.at:560 >$at_check_line_file
   21652 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   21653 at_status=$?
   21654 grep '^ *+' $at_stder1 >&2
   21655 grep -v '^ *+' $at_stder1 >$at_stderr
   21656 at_failed=false
   21657 echo stderr:; tee stderr <$at_stderr
   21658 $at_diff $at_devnull $at_stdout || at_failed=:
   21659 case $at_status in
   21660    77) echo 77 > $at_status_file
   21661             exit 77;;
   21662    0) ;;
   21663    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21664       at_failed=:;;
   21665 esac
   21666 if $at_failed; then
   21667 
   21668   echo 1 > $at_status_file
   21669   exit 1
   21670 fi
   21671 
   21672 $at_traceon
   21673 
   21674 
   21675 # Normalize the observed and expected error messages, depending upon the
   21676 # options.
   21677 # 1. Remove the traces from observed.
   21678 sed '/^Starting/d
   21679 /^Entering/d
   21680 /^Stack/d
   21681 /^Reading/d
   21682 /^Reducing/d
   21683 /^Shifting/d
   21684 /^state/d
   21685 /^Cleanup:/d
   21686 /^Error:/d
   21687 /^Next/d
   21688 /^Discarding/d
   21689 / \$[0-9$]* = /d
   21690 /^yydestructor:/d' stderr >at-stderr
   21691 mv at-stderr stderr
   21692 # 2. Create the reference error message.
   21693 cat >expout <<'_ATEOF'
   21694 1.9: syntax error, unexpected number
   21695 calc: error: 2222 != 1
   21696 _ATEOF
   21697 
   21698 # 3. If locations are not used, remove them.
   21699 
   21700 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   21701 
   21702 # 5. Check
   21703 $at_traceoff
   21704 echo "calc.at:560: cat stderr"
   21705 echo calc.at:560 >$at_check_line_file
   21706 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   21707 at_status=$?
   21708 grep '^ *+' $at_stder1 >&2
   21709 grep -v '^ *+' $at_stder1 >$at_stderr
   21710 at_failed=false
   21711 $at_diff $at_devnull $at_stderr || at_failed=:
   21712 $at_diff expout $at_stdout || at_failed=:
   21713 case $at_status in
   21714    77) echo 77 > $at_status_file
   21715             exit 77;;
   21716    0) ;;
   21717    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21718       at_failed=:;;
   21719 esac
   21720 if $at_failed; then
   21721 
   21722   echo 1 > $at_status_file
   21723   exit 1
   21724 fi
   21725 
   21726 $at_traceon
   21727 
   21728 
   21729 cat >input <<'_ATEOF'
   21730 (- *) + (0 0) = 1
   21731 _ATEOF
   21732 
   21733 $at_traceoff
   21734 echo "calc.at:560: \$PREPARSER ./calc input"
   21735 echo calc.at:560 >$at_check_line_file
   21736 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   21737 at_status=$?
   21738 grep '^ *+' $at_stder1 >&2
   21739 grep -v '^ *+' $at_stder1 >$at_stderr
   21740 at_failed=false
   21741 echo stderr:; tee stderr <$at_stderr
   21742 $at_diff $at_devnull $at_stdout || at_failed=:
   21743 case $at_status in
   21744    77) echo 77 > $at_status_file
   21745             exit 77;;
   21746    0) ;;
   21747    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21748       at_failed=:;;
   21749 esac
   21750 if $at_failed; then
   21751 
   21752   echo 1 > $at_status_file
   21753   exit 1
   21754 fi
   21755 
   21756 $at_traceon
   21757 
   21758 
   21759 # Normalize the observed and expected error messages, depending upon the
   21760 # options.
   21761 # 1. Remove the traces from observed.
   21762 sed '/^Starting/d
   21763 /^Entering/d
   21764 /^Stack/d
   21765 /^Reading/d
   21766 /^Reducing/d
   21767 /^Shifting/d
   21768 /^state/d
   21769 /^Cleanup:/d
   21770 /^Error:/d
   21771 /^Next/d
   21772 /^Discarding/d
   21773 / \$[0-9$]* = /d
   21774 /^yydestructor:/d' stderr >at-stderr
   21775 mv at-stderr stderr
   21776 # 2. Create the reference error message.
   21777 cat >expout <<'_ATEOF'
   21778 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   21779 1.11: syntax error, unexpected number
   21780 calc: error: 2222 != 1
   21781 _ATEOF
   21782 
   21783 # 3. If locations are not used, remove them.
   21784 
   21785 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   21786 
   21787 # 5. Check
   21788 $at_traceoff
   21789 echo "calc.at:560: cat stderr"
   21790 echo calc.at:560 >$at_check_line_file
   21791 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   21792 at_status=$?
   21793 grep '^ *+' $at_stder1 >&2
   21794 grep -v '^ *+' $at_stder1 >$at_stderr
   21795 at_failed=false
   21796 $at_diff $at_devnull $at_stderr || at_failed=:
   21797 $at_diff expout $at_stdout || at_failed=:
   21798 case $at_status in
   21799    77) echo 77 > $at_status_file
   21800             exit 77;;
   21801    0) ;;
   21802    *) echo "calc.at:560: exit code was $at_status, expected 0"
   21803       at_failed=:;;
   21804 esac
   21805 if $at_failed; then
   21806 
   21807   echo 1 > $at_status_file
   21808   exit 1
   21809 fi
   21810 
   21811 $at_traceon
   21812 
   21813 
   21814 
   21815 
   21816 
   21817 
   21818 
   21819 
   21820 
   21821 
   21822 
   21823 
   21824 
   21825 
   21826 
   21827 
   21828 
   21829 
   21830 
   21831 
   21832 
   21833 
   21834 
   21835 
   21836       $at_traceoff
   21837       $at_times_p && times >$at_times_file
   21838     ) 5>&1 2>&1 | eval $at_tee_pipe
   21839     at_status=`cat $at_status_file`
   21840     ;;
   21841 
   21842   79 ) # 79. calc.at:562: Calculator %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc
   21843     at_setup_line='calc.at:562'
   21844     at_desc='Calculator %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc'
   21845     $at_quiet $ECHO_N " 79: Calculator %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc$ECHO_C"
   21846     at_xfail=no
   21847     (
   21848       echo "79. calc.at:562: testing ..."
   21849       $at_traceon
   21850 
   21851 
   21852 
   21853 
   21854 
   21855 
   21856 
   21857 
   21858 # Using yacc.c?
   21859 
   21860 
   21861 
   21862 
   21863 
   21864 
   21865 
   21866 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   21867 
   21868 # yyerror always sees the locations (when activated), except if
   21869 # yacc & pure & !param.
   21870 
   21871 
   21872 # The interface is pure: either because %pure-parser, or because we
   21873 # are using the C++ parsers.
   21874 
   21875 
   21876 
   21877 
   21878 
   21879 
   21880 
   21881 
   21882 
   21883 
   21884 
   21885 
   21886 cat >calc.y <<'_ATEOF'
   21887 %{
   21888 #ifdef HAVE_CONFIG_H
   21889 # include <config.h>
   21890   /* We don't need perfect functions for these tests. */
   21891 # undef malloc
   21892 # undef memcmp
   21893 # undef realloc
   21894 #endif
   21895 %}
   21896 
   21897 /* Infix notation calculator--calc */
   21898 %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc
   21899 
   21900 %{
   21901 #include <stdio.h>
   21902 
   21903 #include <stdlib.h>
   21904 #include <string.h>
   21905 #if HAVE_UNISTD_H
   21906 # include <unistd.h>
   21907 #else
   21908 # undef alarm
   21909 # define alarm(seconds) /* empty */
   21910 #endif
   21911 #include <ctype.h>
   21912 #define USE(Var)
   21913 
   21914 /* Exercise pre-prologue dependency to %union.  */
   21915 typedef int semantic_value;
   21916 
   21917 static semantic_value global_result = 0;
   21918 static int global_count = 0;
   21919 %}
   21920 
   21921 /* Exercise %union. */
   21922 %union
   21923 {
   21924   semantic_value ival;
   21925 };
   21926 
   21927 %{
   21928 static int power (int base, int exponent);
   21929 /* yyerror receives the location if:
   21930    - %location & %pure & %glr
   21931    - %location & %pure & %yacc & %parse-param. */
   21932 static void yyerror (
   21933 
   21934                      const char *s
   21935                      );
   21936 static int yylex (void);
   21937 static int get_char (void);
   21938 static void unget_char ( int c);
   21939 %}
   21940 
   21941 
   21942 
   21943 /* Bison Declarations */
   21944 %token CALC_EOF 0 "end of input"
   21945 %token <ival> NUM "number"
   21946 %type  <ival> exp
   21947 
   21948 %nonassoc '=' /* comparison	       */
   21949 %left '-' '+'
   21950 %left '*' '/'
   21951 %left NEG     /* negation--unary minus */
   21952 %right '^'    /* exponentiation        */
   21953 
   21954 /* Grammar follows */
   21955 %%
   21956 input:
   21957   line
   21958 | input line         {  }
   21959 ;
   21960 
   21961 line:
   21962   '\n'
   21963 | exp '\n'           { USE ($1); }
   21964 ;
   21965 
   21966 exp:
   21967   NUM                { $$ = $1;             }
   21968 | exp '=' exp
   21969   {
   21970     if ($1 != $3)
   21971       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   21972     $$ = $1;
   21973   }
   21974 | exp '+' exp        { $$ = $1 + $3;        }
   21975 | exp '-' exp        { $$ = $1 - $3;        }
   21976 | exp '*' exp        { $$ = $1 * $3;        }
   21977 | exp '/' exp        { $$ = $1 / $3;        }
   21978 | '-' exp  %prec NEG { $$ = -$2;            }
   21979 | exp '^' exp        { $$ = power ($1, $3); }
   21980 | '(' exp ')'        { $$ = $2;             }
   21981 | '(' error ')'      { $$ = 1111;           }
   21982 | '!'                { $$ = 0; YYERROR;     }
   21983 | '-' error          { $$ = 0; YYERROR;     }
   21984 ;
   21985 %%
   21986 /* The input.  */
   21987 static FILE *input;
   21988 
   21989 static void
   21990 yyerror (
   21991 
   21992          const char *s)
   21993 {
   21994 
   21995 
   21996   fprintf (stderr, "%d.%d",
   21997            (yylloc).first_line, (yylloc).first_column);
   21998   if ((yylloc).first_line != (yylloc).last_line)
   21999     fprintf (stderr, "-%d.%d",
   22000 	     (yylloc).last_line,  (yylloc).last_column - 1);
   22001   else if ((yylloc).first_column != (yylloc).last_column - 1)
   22002     fprintf (stderr, "-%d",
   22003 	     (yylloc).last_column - 1);
   22004   fprintf (stderr, ": ");
   22005   fprintf (stderr, "%s\n", s);
   22006 }
   22007 
   22008 
   22009 
   22010 static YYLTYPE last_yylloc;
   22011 
   22012 static int
   22013 get_char (void)
   22014 {
   22015   int res = getc (input);
   22016   ;
   22017 
   22018   last_yylloc = (yylloc);
   22019   if (res == '\n')
   22020     {
   22021       (yylloc).last_line++;
   22022       (yylloc).last_column = 0;
   22023     }
   22024   else
   22025     (yylloc).last_column++;
   22026 
   22027   return res;
   22028 }
   22029 
   22030 
   22031 static void
   22032 unget_char ( int c)
   22033 {
   22034   ;
   22035 
   22036   /* Wrong when C == `\n'. */
   22037   (yylloc) = last_yylloc;
   22038 
   22039   ungetc (c, input);
   22040 }
   22041 
   22042 static int
   22043 read_signed_integer (void)
   22044 {
   22045   int c = get_char ();
   22046   int sign = 1;
   22047   int n = 0;
   22048 
   22049   ;
   22050   if (c == '-')
   22051     {
   22052       c = get_char ();
   22053       sign = -1;
   22054     }
   22055 
   22056   while (isdigit (c))
   22057     {
   22058       n = 10 * n + (c - '0');
   22059       c = get_char ();
   22060     }
   22061 
   22062   unget_char ( c);
   22063 
   22064   return sign * n;
   22065 }
   22066 
   22067 
   22068 
   22069 /*---------------------------------------------------------------.
   22070 | Lexical analyzer returns an integer on the stack and the token |
   22071 | NUM, or the ASCII character read if not a number.  Skips all   |
   22072 | blanks and tabs, returns 0 for EOF.                            |
   22073 `---------------------------------------------------------------*/
   22074 
   22075 static int
   22076 yylex (void)
   22077 {
   22078   static int init = 1;
   22079   int c;
   22080 
   22081   if (init)
   22082     {
   22083       init = 0;
   22084 
   22085       (yylloc).last_column = 0;
   22086       (yylloc).last_line = 1;
   22087 
   22088     }
   22089 
   22090 
   22091  (yylloc).first_column = (yylloc).last_column;
   22092   (yylloc).first_line   = (yylloc).last_line;
   22093 
   22094 
   22095   /* Skip white space.  */
   22096   while ((c = get_char ()) == ' ' || c == '\t')
   22097     {
   22098      (yylloc).first_column = (yylloc).last_column;
   22099       (yylloc).first_line   = (yylloc).last_line;
   22100 
   22101     }
   22102 
   22103   /* process numbers   */
   22104   if (c == '.' || isdigit (c))
   22105     {
   22106       unget_char ( c);
   22107       (yylval).ival = read_signed_integer ();
   22108       return NUM;
   22109     }
   22110 
   22111   /* Return end-of-file.  */
   22112   if (c == EOF)
   22113     return CALC_EOF;
   22114 
   22115   /* Return single chars. */
   22116   return c;
   22117 }
   22118 
   22119 static int
   22120 power (int base, int exponent)
   22121 {
   22122   int res = 1;
   22123   if (exponent < 0)
   22124     exit (3);
   22125   for (/* Niente */; exponent; --exponent)
   22126     res *= base;
   22127   return res;
   22128 }
   22129 
   22130 
   22131 int
   22132 main (int argc, const char **argv)
   22133 {
   22134   semantic_value result = 0;
   22135   int count = 0;
   22136   int status;
   22137 
   22138   /* This used to be alarm (10), but that isn't enough time for
   22139      a July 1995 vintage DEC Alphastation 200 4/100 system,
   22140      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   22141   alarm (100);
   22142 
   22143   if (argc == 2)
   22144     input = fopen (argv[1], "r");
   22145   else
   22146     input = stdin;
   22147 
   22148   if (!input)
   22149     {
   22150       perror (argv[1]);
   22151       return 3;
   22152     }
   22153 
   22154 
   22155   status = yyparse ();
   22156   if (global_result != result)
   22157     abort ();
   22158   if (global_count != count)
   22159     abort ();
   22160   return status;
   22161 }
   22162 _ATEOF
   22163 
   22164 
   22165 
   22166 
   22167 
   22168 $at_traceoff
   22169 echo "calc.at:562: bison -o calc.c calc.y"
   22170 echo calc.at:562 >$at_check_line_file
   22171 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   22172 at_status=$?
   22173 grep '^ *+' $at_stder1 >&2
   22174 grep -v '^ *+' $at_stder1 >$at_stderr
   22175 at_failed=false
   22176 $at_diff $at_devnull $at_stderr || at_failed=:
   22177 $at_diff $at_devnull $at_stdout || at_failed=:
   22178 case $at_status in
   22179    77) echo 77 > $at_status_file
   22180             exit 77;;
   22181    0) ;;
   22182    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22183       at_failed=:;;
   22184 esac
   22185 if $at_failed; then
   22186 
   22187   echo 1 > $at_status_file
   22188   exit 1
   22189 fi
   22190 
   22191 $at_traceon
   22192 
   22193    $at_traceoff
   22194 echo "calc.at:562: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   22195 echo calc.at:562 >$at_check_line_file
   22196 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   22197 at_status=$?
   22198 grep '^ *+' $at_stder1 >&2
   22199 grep -v '^ *+' $at_stder1 >$at_stderr
   22200 at_failed=false
   22201 echo stderr:; cat $at_stderr
   22202 echo stdout:; cat $at_stdout
   22203 case $at_status in
   22204    77) echo 77 > $at_status_file
   22205             exit 77;;
   22206    0) ;;
   22207    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22208       at_failed=:;;
   22209 esac
   22210 if $at_failed; then
   22211 
   22212   echo 1 > $at_status_file
   22213   exit 1
   22214 fi
   22215 
   22216 $at_traceon
   22217 
   22218 
   22219 # Test the priorities.
   22220 cat >input <<'_ATEOF'
   22221 1 + 2 * 3 = 7
   22222 1 + 2 * -3 = -5
   22223 
   22224 -1^2 = -1
   22225 (-1)^2 = 1
   22226 
   22227 ---1 = -1
   22228 
   22229 1 - 2 - 3 = -4
   22230 1 - (2 - 3) = 2
   22231 
   22232 2^2^3 = 256
   22233 (2^2)^3 = 64
   22234 _ATEOF
   22235 
   22236 $at_traceoff
   22237 echo "calc.at:562: \$PREPARSER ./calc input"
   22238 echo calc.at:562 >$at_check_line_file
   22239 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   22240 at_status=$?
   22241 grep '^ *+' $at_stder1 >&2
   22242 grep -v '^ *+' $at_stder1 >$at_stderr
   22243 at_failed=false
   22244 echo stderr:; tee stderr <$at_stderr
   22245 $at_diff $at_devnull $at_stdout || at_failed=:
   22246 case $at_status in
   22247    77) echo 77 > $at_status_file
   22248             exit 77;;
   22249    0) ;;
   22250    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22251       at_failed=:;;
   22252 esac
   22253 if $at_failed; then
   22254 
   22255   echo 1 > $at_status_file
   22256   exit 1
   22257 fi
   22258 
   22259 $at_traceon
   22260 
   22261 
   22262 
   22263 # Some syntax errors.
   22264 cat >input <<'_ATEOF'
   22265 0 0
   22266 _ATEOF
   22267 
   22268 $at_traceoff
   22269 echo "calc.at:562: \$PREPARSER ./calc input"
   22270 echo calc.at:562 >$at_check_line_file
   22271 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   22272 at_status=$?
   22273 grep '^ *+' $at_stder1 >&2
   22274 grep -v '^ *+' $at_stder1 >$at_stderr
   22275 at_failed=false
   22276 echo stderr:; tee stderr <$at_stderr
   22277 $at_diff $at_devnull $at_stdout || at_failed=:
   22278 case $at_status in
   22279    77) echo 77 > $at_status_file
   22280             exit 77;;
   22281    1) ;;
   22282    *) echo "calc.at:562: exit code was $at_status, expected 1"
   22283       at_failed=:;;
   22284 esac
   22285 if $at_failed; then
   22286 
   22287   echo 1 > $at_status_file
   22288   exit 1
   22289 fi
   22290 
   22291 $at_traceon
   22292 
   22293 
   22294 # Normalize the observed and expected error messages, depending upon the
   22295 # options.
   22296 # 1. Remove the traces from observed.
   22297 sed '/^Starting/d
   22298 /^Entering/d
   22299 /^Stack/d
   22300 /^Reading/d
   22301 /^Reducing/d
   22302 /^Shifting/d
   22303 /^state/d
   22304 /^Cleanup:/d
   22305 /^Error:/d
   22306 /^Next/d
   22307 /^Discarding/d
   22308 / \$[0-9$]* = /d
   22309 /^yydestructor:/d' stderr >at-stderr
   22310 mv at-stderr stderr
   22311 # 2. Create the reference error message.
   22312 cat >expout <<'_ATEOF'
   22313 1.2: syntax error, unexpected number
   22314 _ATEOF
   22315 
   22316 # 3. If locations are not used, remove them.
   22317 
   22318 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   22319 
   22320 # 5. Check
   22321 $at_traceoff
   22322 echo "calc.at:562: cat stderr"
   22323 echo calc.at:562 >$at_check_line_file
   22324 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   22325 at_status=$?
   22326 grep '^ *+' $at_stder1 >&2
   22327 grep -v '^ *+' $at_stder1 >$at_stderr
   22328 at_failed=false
   22329 $at_diff $at_devnull $at_stderr || at_failed=:
   22330 $at_diff expout $at_stdout || at_failed=:
   22331 case $at_status in
   22332    77) echo 77 > $at_status_file
   22333             exit 77;;
   22334    0) ;;
   22335    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22336       at_failed=:;;
   22337 esac
   22338 if $at_failed; then
   22339 
   22340   echo 1 > $at_status_file
   22341   exit 1
   22342 fi
   22343 
   22344 $at_traceon
   22345 
   22346 
   22347 cat >input <<'_ATEOF'
   22348 1//2
   22349 _ATEOF
   22350 
   22351 $at_traceoff
   22352 echo "calc.at:562: \$PREPARSER ./calc input"
   22353 echo calc.at:562 >$at_check_line_file
   22354 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   22355 at_status=$?
   22356 grep '^ *+' $at_stder1 >&2
   22357 grep -v '^ *+' $at_stder1 >$at_stderr
   22358 at_failed=false
   22359 echo stderr:; tee stderr <$at_stderr
   22360 $at_diff $at_devnull $at_stdout || at_failed=:
   22361 case $at_status in
   22362    77) echo 77 > $at_status_file
   22363             exit 77;;
   22364    1) ;;
   22365    *) echo "calc.at:562: exit code was $at_status, expected 1"
   22366       at_failed=:;;
   22367 esac
   22368 if $at_failed; then
   22369 
   22370   echo 1 > $at_status_file
   22371   exit 1
   22372 fi
   22373 
   22374 $at_traceon
   22375 
   22376 
   22377 # Normalize the observed and expected error messages, depending upon the
   22378 # options.
   22379 # 1. Remove the traces from observed.
   22380 sed '/^Starting/d
   22381 /^Entering/d
   22382 /^Stack/d
   22383 /^Reading/d
   22384 /^Reducing/d
   22385 /^Shifting/d
   22386 /^state/d
   22387 /^Cleanup:/d
   22388 /^Error:/d
   22389 /^Next/d
   22390 /^Discarding/d
   22391 / \$[0-9$]* = /d
   22392 /^yydestructor:/d' stderr >at-stderr
   22393 mv at-stderr stderr
   22394 # 2. Create the reference error message.
   22395 cat >expout <<'_ATEOF'
   22396 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   22397 _ATEOF
   22398 
   22399 # 3. If locations are not used, remove them.
   22400 
   22401 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   22402 
   22403 # 5. Check
   22404 $at_traceoff
   22405 echo "calc.at:562: cat stderr"
   22406 echo calc.at:562 >$at_check_line_file
   22407 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   22408 at_status=$?
   22409 grep '^ *+' $at_stder1 >&2
   22410 grep -v '^ *+' $at_stder1 >$at_stderr
   22411 at_failed=false
   22412 $at_diff $at_devnull $at_stderr || at_failed=:
   22413 $at_diff expout $at_stdout || at_failed=:
   22414 case $at_status in
   22415    77) echo 77 > $at_status_file
   22416             exit 77;;
   22417    0) ;;
   22418    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22419       at_failed=:;;
   22420 esac
   22421 if $at_failed; then
   22422 
   22423   echo 1 > $at_status_file
   22424   exit 1
   22425 fi
   22426 
   22427 $at_traceon
   22428 
   22429 
   22430 cat >input <<'_ATEOF'
   22431 error
   22432 _ATEOF
   22433 
   22434 $at_traceoff
   22435 echo "calc.at:562: \$PREPARSER ./calc input"
   22436 echo calc.at:562 >$at_check_line_file
   22437 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   22438 at_status=$?
   22439 grep '^ *+' $at_stder1 >&2
   22440 grep -v '^ *+' $at_stder1 >$at_stderr
   22441 at_failed=false
   22442 echo stderr:; tee stderr <$at_stderr
   22443 $at_diff $at_devnull $at_stdout || at_failed=:
   22444 case $at_status in
   22445    77) echo 77 > $at_status_file
   22446             exit 77;;
   22447    1) ;;
   22448    *) echo "calc.at:562: exit code was $at_status, expected 1"
   22449       at_failed=:;;
   22450 esac
   22451 if $at_failed; then
   22452 
   22453   echo 1 > $at_status_file
   22454   exit 1
   22455 fi
   22456 
   22457 $at_traceon
   22458 
   22459 
   22460 # Normalize the observed and expected error messages, depending upon the
   22461 # options.
   22462 # 1. Remove the traces from observed.
   22463 sed '/^Starting/d
   22464 /^Entering/d
   22465 /^Stack/d
   22466 /^Reading/d
   22467 /^Reducing/d
   22468 /^Shifting/d
   22469 /^state/d
   22470 /^Cleanup:/d
   22471 /^Error:/d
   22472 /^Next/d
   22473 /^Discarding/d
   22474 / \$[0-9$]* = /d
   22475 /^yydestructor:/d' stderr >at-stderr
   22476 mv at-stderr stderr
   22477 # 2. Create the reference error message.
   22478 cat >expout <<'_ATEOF'
   22479 1.0: syntax error, unexpected $undefined
   22480 _ATEOF
   22481 
   22482 # 3. If locations are not used, remove them.
   22483 
   22484 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   22485 
   22486 # 5. Check
   22487 $at_traceoff
   22488 echo "calc.at:562: cat stderr"
   22489 echo calc.at:562 >$at_check_line_file
   22490 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   22491 at_status=$?
   22492 grep '^ *+' $at_stder1 >&2
   22493 grep -v '^ *+' $at_stder1 >$at_stderr
   22494 at_failed=false
   22495 $at_diff $at_devnull $at_stderr || at_failed=:
   22496 $at_diff expout $at_stdout || at_failed=:
   22497 case $at_status in
   22498    77) echo 77 > $at_status_file
   22499             exit 77;;
   22500    0) ;;
   22501    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22502       at_failed=:;;
   22503 esac
   22504 if $at_failed; then
   22505 
   22506   echo 1 > $at_status_file
   22507   exit 1
   22508 fi
   22509 
   22510 $at_traceon
   22511 
   22512 
   22513 cat >input <<'_ATEOF'
   22514 1 = 2 = 3
   22515 _ATEOF
   22516 
   22517 $at_traceoff
   22518 echo "calc.at:562: \$PREPARSER ./calc input"
   22519 echo calc.at:562 >$at_check_line_file
   22520 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   22521 at_status=$?
   22522 grep '^ *+' $at_stder1 >&2
   22523 grep -v '^ *+' $at_stder1 >$at_stderr
   22524 at_failed=false
   22525 echo stderr:; tee stderr <$at_stderr
   22526 $at_diff $at_devnull $at_stdout || at_failed=:
   22527 case $at_status in
   22528    77) echo 77 > $at_status_file
   22529             exit 77;;
   22530    1) ;;
   22531    *) echo "calc.at:562: exit code was $at_status, expected 1"
   22532       at_failed=:;;
   22533 esac
   22534 if $at_failed; then
   22535 
   22536   echo 1 > $at_status_file
   22537   exit 1
   22538 fi
   22539 
   22540 $at_traceon
   22541 
   22542 
   22543 # Normalize the observed and expected error messages, depending upon the
   22544 # options.
   22545 # 1. Remove the traces from observed.
   22546 sed '/^Starting/d
   22547 /^Entering/d
   22548 /^Stack/d
   22549 /^Reading/d
   22550 /^Reducing/d
   22551 /^Shifting/d
   22552 /^state/d
   22553 /^Cleanup:/d
   22554 /^Error:/d
   22555 /^Next/d
   22556 /^Discarding/d
   22557 / \$[0-9$]* = /d
   22558 /^yydestructor:/d' stderr >at-stderr
   22559 mv at-stderr stderr
   22560 # 2. Create the reference error message.
   22561 cat >expout <<'_ATEOF'
   22562 1.6: syntax error, unexpected '='
   22563 _ATEOF
   22564 
   22565 # 3. If locations are not used, remove them.
   22566 
   22567 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   22568 
   22569 # 5. Check
   22570 $at_traceoff
   22571 echo "calc.at:562: cat stderr"
   22572 echo calc.at:562 >$at_check_line_file
   22573 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   22574 at_status=$?
   22575 grep '^ *+' $at_stder1 >&2
   22576 grep -v '^ *+' $at_stder1 >$at_stderr
   22577 at_failed=false
   22578 $at_diff $at_devnull $at_stderr || at_failed=:
   22579 $at_diff expout $at_stdout || at_failed=:
   22580 case $at_status in
   22581    77) echo 77 > $at_status_file
   22582             exit 77;;
   22583    0) ;;
   22584    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22585       at_failed=:;;
   22586 esac
   22587 if $at_failed; then
   22588 
   22589   echo 1 > $at_status_file
   22590   exit 1
   22591 fi
   22592 
   22593 $at_traceon
   22594 
   22595 
   22596 cat >input <<'_ATEOF'
   22597 
   22598 +1
   22599 _ATEOF
   22600 
   22601 $at_traceoff
   22602 echo "calc.at:562: \$PREPARSER ./calc input"
   22603 echo calc.at:562 >$at_check_line_file
   22604 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   22605 at_status=$?
   22606 grep '^ *+' $at_stder1 >&2
   22607 grep -v '^ *+' $at_stder1 >$at_stderr
   22608 at_failed=false
   22609 echo stderr:; tee stderr <$at_stderr
   22610 $at_diff $at_devnull $at_stdout || at_failed=:
   22611 case $at_status in
   22612    77) echo 77 > $at_status_file
   22613             exit 77;;
   22614    1) ;;
   22615    *) echo "calc.at:562: exit code was $at_status, expected 1"
   22616       at_failed=:;;
   22617 esac
   22618 if $at_failed; then
   22619 
   22620   echo 1 > $at_status_file
   22621   exit 1
   22622 fi
   22623 
   22624 $at_traceon
   22625 
   22626 
   22627 # Normalize the observed and expected error messages, depending upon the
   22628 # options.
   22629 # 1. Remove the traces from observed.
   22630 sed '/^Starting/d
   22631 /^Entering/d
   22632 /^Stack/d
   22633 /^Reading/d
   22634 /^Reducing/d
   22635 /^Shifting/d
   22636 /^state/d
   22637 /^Cleanup:/d
   22638 /^Error:/d
   22639 /^Next/d
   22640 /^Discarding/d
   22641 / \$[0-9$]* = /d
   22642 /^yydestructor:/d' stderr >at-stderr
   22643 mv at-stderr stderr
   22644 # 2. Create the reference error message.
   22645 cat >expout <<'_ATEOF'
   22646 2.0: syntax error, unexpected '+'
   22647 _ATEOF
   22648 
   22649 # 3. If locations are not used, remove them.
   22650 
   22651 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   22652 
   22653 # 5. Check
   22654 $at_traceoff
   22655 echo "calc.at:562: cat stderr"
   22656 echo calc.at:562 >$at_check_line_file
   22657 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   22658 at_status=$?
   22659 grep '^ *+' $at_stder1 >&2
   22660 grep -v '^ *+' $at_stder1 >$at_stderr
   22661 at_failed=false
   22662 $at_diff $at_devnull $at_stderr || at_failed=:
   22663 $at_diff expout $at_stdout || at_failed=:
   22664 case $at_status in
   22665    77) echo 77 > $at_status_file
   22666             exit 77;;
   22667    0) ;;
   22668    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22669       at_failed=:;;
   22670 esac
   22671 if $at_failed; then
   22672 
   22673   echo 1 > $at_status_file
   22674   exit 1
   22675 fi
   22676 
   22677 $at_traceon
   22678 
   22679 
   22680 # Exercise error messages with EOF: work on an empty file.
   22681 $at_traceoff
   22682 echo "calc.at:562: \$PREPARSER ./calc /dev/null"
   22683 echo calc.at:562 >$at_check_line_file
   22684 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   22685 at_status=$?
   22686 grep '^ *+' $at_stder1 >&2
   22687 grep -v '^ *+' $at_stder1 >$at_stderr
   22688 at_failed=false
   22689 echo stderr:; tee stderr <$at_stderr
   22690 $at_diff $at_devnull $at_stdout || at_failed=:
   22691 case $at_status in
   22692    77) echo 77 > $at_status_file
   22693             exit 77;;
   22694    1) ;;
   22695    *) echo "calc.at:562: exit code was $at_status, expected 1"
   22696       at_failed=:;;
   22697 esac
   22698 if $at_failed; then
   22699 
   22700   echo 1 > $at_status_file
   22701   exit 1
   22702 fi
   22703 
   22704 $at_traceon
   22705 
   22706 
   22707 # Normalize the observed and expected error messages, depending upon the
   22708 # options.
   22709 # 1. Remove the traces from observed.
   22710 sed '/^Starting/d
   22711 /^Entering/d
   22712 /^Stack/d
   22713 /^Reading/d
   22714 /^Reducing/d
   22715 /^Shifting/d
   22716 /^state/d
   22717 /^Cleanup:/d
   22718 /^Error:/d
   22719 /^Next/d
   22720 /^Discarding/d
   22721 / \$[0-9$]* = /d
   22722 /^yydestructor:/d' stderr >at-stderr
   22723 mv at-stderr stderr
   22724 # 2. Create the reference error message.
   22725 cat >expout <<'_ATEOF'
   22726 1.0: syntax error, unexpected end of input
   22727 _ATEOF
   22728 
   22729 # 3. If locations are not used, remove them.
   22730 
   22731 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   22732 
   22733 # 5. Check
   22734 $at_traceoff
   22735 echo "calc.at:562: cat stderr"
   22736 echo calc.at:562 >$at_check_line_file
   22737 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   22738 at_status=$?
   22739 grep '^ *+' $at_stder1 >&2
   22740 grep -v '^ *+' $at_stder1 >$at_stderr
   22741 at_failed=false
   22742 $at_diff $at_devnull $at_stderr || at_failed=:
   22743 $at_diff expout $at_stdout || at_failed=:
   22744 case $at_status in
   22745    77) echo 77 > $at_status_file
   22746             exit 77;;
   22747    0) ;;
   22748    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22749       at_failed=:;;
   22750 esac
   22751 if $at_failed; then
   22752 
   22753   echo 1 > $at_status_file
   22754   exit 1
   22755 fi
   22756 
   22757 $at_traceon
   22758 
   22759 
   22760 
   22761 # Exercise the error token: without it, we die at the first error,
   22762 # hence be sure to
   22763 #
   22764 # - have several errors which exercise different shift/discardings
   22765 #   - (): nothing to pop, nothing to discard
   22766 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   22767 #   - (* * *): nothing to pop, a lot to discard
   22768 #   - (1 + 2 * *): some to pop and discard
   22769 #
   22770 # - test the action associated to `error'
   22771 #
   22772 # - check the look-ahead that triggers an error is not discarded
   22773 #   when we enter error recovery.  Below, the look-ahead causing the
   22774 #   first error is ")", which is needed to recover from the error and
   22775 #   produce the "0" that triggers the "0 != 1" error.
   22776 #
   22777 cat >input <<'_ATEOF'
   22778 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   22779 _ATEOF
   22780 
   22781 $at_traceoff
   22782 echo "calc.at:562: \$PREPARSER ./calc input"
   22783 echo calc.at:562 >$at_check_line_file
   22784 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   22785 at_status=$?
   22786 grep '^ *+' $at_stder1 >&2
   22787 grep -v '^ *+' $at_stder1 >$at_stderr
   22788 at_failed=false
   22789 echo stderr:; tee stderr <$at_stderr
   22790 $at_diff $at_devnull $at_stdout || at_failed=:
   22791 case $at_status in
   22792    77) echo 77 > $at_status_file
   22793             exit 77;;
   22794    0) ;;
   22795    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22796       at_failed=:;;
   22797 esac
   22798 if $at_failed; then
   22799 
   22800   echo 1 > $at_status_file
   22801   exit 1
   22802 fi
   22803 
   22804 $at_traceon
   22805 
   22806 
   22807 # Normalize the observed and expected error messages, depending upon the
   22808 # options.
   22809 # 1. Remove the traces from observed.
   22810 sed '/^Starting/d
   22811 /^Entering/d
   22812 /^Stack/d
   22813 /^Reading/d
   22814 /^Reducing/d
   22815 /^Shifting/d
   22816 /^state/d
   22817 /^Cleanup:/d
   22818 /^Error:/d
   22819 /^Next/d
   22820 /^Discarding/d
   22821 / \$[0-9$]* = /d
   22822 /^yydestructor:/d' stderr >at-stderr
   22823 mv at-stderr stderr
   22824 # 2. Create the reference error message.
   22825 cat >expout <<'_ATEOF'
   22826 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   22827 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   22828 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   22829 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   22830 calc: error: 4444 != 1
   22831 _ATEOF
   22832 
   22833 # 3. If locations are not used, remove them.
   22834 
   22835 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   22836 
   22837 # 5. Check
   22838 $at_traceoff
   22839 echo "calc.at:562: cat stderr"
   22840 echo calc.at:562 >$at_check_line_file
   22841 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   22842 at_status=$?
   22843 grep '^ *+' $at_stder1 >&2
   22844 grep -v '^ *+' $at_stder1 >$at_stderr
   22845 at_failed=false
   22846 $at_diff $at_devnull $at_stderr || at_failed=:
   22847 $at_diff expout $at_stdout || at_failed=:
   22848 case $at_status in
   22849    77) echo 77 > $at_status_file
   22850             exit 77;;
   22851    0) ;;
   22852    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22853       at_failed=:;;
   22854 esac
   22855 if $at_failed; then
   22856 
   22857   echo 1 > $at_status_file
   22858   exit 1
   22859 fi
   22860 
   22861 $at_traceon
   22862 
   22863 
   22864 
   22865 # The same, but this time exercising explicitly triggered syntax errors.
   22866 # POSIX says the look-ahead causing the error should not be discarded.
   22867 cat >input <<'_ATEOF'
   22868 (!) + (0 0) = 1
   22869 _ATEOF
   22870 
   22871 $at_traceoff
   22872 echo "calc.at:562: \$PREPARSER ./calc input"
   22873 echo calc.at:562 >$at_check_line_file
   22874 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   22875 at_status=$?
   22876 grep '^ *+' $at_stder1 >&2
   22877 grep -v '^ *+' $at_stder1 >$at_stderr
   22878 at_failed=false
   22879 echo stderr:; tee stderr <$at_stderr
   22880 $at_diff $at_devnull $at_stdout || at_failed=:
   22881 case $at_status in
   22882    77) echo 77 > $at_status_file
   22883             exit 77;;
   22884    0) ;;
   22885    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22886       at_failed=:;;
   22887 esac
   22888 if $at_failed; then
   22889 
   22890   echo 1 > $at_status_file
   22891   exit 1
   22892 fi
   22893 
   22894 $at_traceon
   22895 
   22896 
   22897 # Normalize the observed and expected error messages, depending upon the
   22898 # options.
   22899 # 1. Remove the traces from observed.
   22900 sed '/^Starting/d
   22901 /^Entering/d
   22902 /^Stack/d
   22903 /^Reading/d
   22904 /^Reducing/d
   22905 /^Shifting/d
   22906 /^state/d
   22907 /^Cleanup:/d
   22908 /^Error:/d
   22909 /^Next/d
   22910 /^Discarding/d
   22911 / \$[0-9$]* = /d
   22912 /^yydestructor:/d' stderr >at-stderr
   22913 mv at-stderr stderr
   22914 # 2. Create the reference error message.
   22915 cat >expout <<'_ATEOF'
   22916 1.9: syntax error, unexpected number
   22917 calc: error: 2222 != 1
   22918 _ATEOF
   22919 
   22920 # 3. If locations are not used, remove them.
   22921 
   22922 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   22923 
   22924 # 5. Check
   22925 $at_traceoff
   22926 echo "calc.at:562: cat stderr"
   22927 echo calc.at:562 >$at_check_line_file
   22928 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   22929 at_status=$?
   22930 grep '^ *+' $at_stder1 >&2
   22931 grep -v '^ *+' $at_stder1 >$at_stderr
   22932 at_failed=false
   22933 $at_diff $at_devnull $at_stderr || at_failed=:
   22934 $at_diff expout $at_stdout || at_failed=:
   22935 case $at_status in
   22936    77) echo 77 > $at_status_file
   22937             exit 77;;
   22938    0) ;;
   22939    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22940       at_failed=:;;
   22941 esac
   22942 if $at_failed; then
   22943 
   22944   echo 1 > $at_status_file
   22945   exit 1
   22946 fi
   22947 
   22948 $at_traceon
   22949 
   22950 
   22951 cat >input <<'_ATEOF'
   22952 (- *) + (0 0) = 1
   22953 _ATEOF
   22954 
   22955 $at_traceoff
   22956 echo "calc.at:562: \$PREPARSER ./calc input"
   22957 echo calc.at:562 >$at_check_line_file
   22958 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   22959 at_status=$?
   22960 grep '^ *+' $at_stder1 >&2
   22961 grep -v '^ *+' $at_stder1 >$at_stderr
   22962 at_failed=false
   22963 echo stderr:; tee stderr <$at_stderr
   22964 $at_diff $at_devnull $at_stdout || at_failed=:
   22965 case $at_status in
   22966    77) echo 77 > $at_status_file
   22967             exit 77;;
   22968    0) ;;
   22969    *) echo "calc.at:562: exit code was $at_status, expected 0"
   22970       at_failed=:;;
   22971 esac
   22972 if $at_failed; then
   22973 
   22974   echo 1 > $at_status_file
   22975   exit 1
   22976 fi
   22977 
   22978 $at_traceon
   22979 
   22980 
   22981 # Normalize the observed and expected error messages, depending upon the
   22982 # options.
   22983 # 1. Remove the traces from observed.
   22984 sed '/^Starting/d
   22985 /^Entering/d
   22986 /^Stack/d
   22987 /^Reading/d
   22988 /^Reducing/d
   22989 /^Shifting/d
   22990 /^state/d
   22991 /^Cleanup:/d
   22992 /^Error:/d
   22993 /^Next/d
   22994 /^Discarding/d
   22995 / \$[0-9$]* = /d
   22996 /^yydestructor:/d' stderr >at-stderr
   22997 mv at-stderr stderr
   22998 # 2. Create the reference error message.
   22999 cat >expout <<'_ATEOF'
   23000 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   23001 1.11: syntax error, unexpected number
   23002 calc: error: 2222 != 1
   23003 _ATEOF
   23004 
   23005 # 3. If locations are not used, remove them.
   23006 
   23007 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   23008 
   23009 # 5. Check
   23010 $at_traceoff
   23011 echo "calc.at:562: cat stderr"
   23012 echo calc.at:562 >$at_check_line_file
   23013 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   23014 at_status=$?
   23015 grep '^ *+' $at_stder1 >&2
   23016 grep -v '^ *+' $at_stder1 >$at_stderr
   23017 at_failed=false
   23018 $at_diff $at_devnull $at_stderr || at_failed=:
   23019 $at_diff expout $at_stdout || at_failed=:
   23020 case $at_status in
   23021    77) echo 77 > $at_status_file
   23022             exit 77;;
   23023    0) ;;
   23024    *) echo "calc.at:562: exit code was $at_status, expected 0"
   23025       at_failed=:;;
   23026 esac
   23027 if $at_failed; then
   23028 
   23029   echo 1 > $at_status_file
   23030   exit 1
   23031 fi
   23032 
   23033 $at_traceon
   23034 
   23035 
   23036 
   23037 
   23038 
   23039 
   23040 
   23041 
   23042 
   23043 
   23044 
   23045 
   23046 
   23047 
   23048 
   23049 
   23050 
   23051 
   23052 
   23053 
   23054 
   23055 
   23056 
   23057 
   23058       $at_traceoff
   23059       $at_times_p && times >$at_times_file
   23060     ) 5>&1 2>&1 | eval $at_tee_pipe
   23061     at_status=`cat $at_status_file`
   23062     ;;
   23063 
   23064   80 ) # 80. calc.at:564: Calculator %debug
   23065     at_setup_line='calc.at:564'
   23066     at_desc='Calculator %debug'
   23067     $at_quiet $ECHO_N " 80: Calculator %debug                            $ECHO_C"
   23068     at_xfail=no
   23069     (
   23070       echo "80. calc.at:564: testing ..."
   23071       $at_traceon
   23072 
   23073 
   23074 
   23075 
   23076 
   23077 
   23078 
   23079 
   23080 # Using yacc.c?
   23081 
   23082 
   23083 
   23084 
   23085 
   23086 
   23087 
   23088 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   23089 
   23090 # yyerror always sees the locations (when activated), except if
   23091 # yacc & pure & !param.
   23092 
   23093 
   23094 # The interface is pure: either because %pure-parser, or because we
   23095 # are using the C++ parsers.
   23096 
   23097 
   23098 
   23099 
   23100 
   23101 
   23102 
   23103 
   23104 
   23105 
   23106 
   23107 
   23108 cat >calc.y <<'_ATEOF'
   23109 %{
   23110 #ifdef HAVE_CONFIG_H
   23111 # include <config.h>
   23112   /* We don't need perfect functions for these tests. */
   23113 # undef malloc
   23114 # undef memcmp
   23115 # undef realloc
   23116 #endif
   23117 %}
   23118 
   23119 /* Infix notation calculator--calc */
   23120 %debug
   23121 
   23122 %{
   23123 #include <stdio.h>
   23124 
   23125 #include <stdlib.h>
   23126 #include <string.h>
   23127 #if HAVE_UNISTD_H
   23128 # include <unistd.h>
   23129 #else
   23130 # undef alarm
   23131 # define alarm(seconds) /* empty */
   23132 #endif
   23133 #include <ctype.h>
   23134 #define USE(Var)
   23135 
   23136 /* Exercise pre-prologue dependency to %union.  */
   23137 typedef int semantic_value;
   23138 
   23139 static semantic_value global_result = 0;
   23140 static int global_count = 0;
   23141 %}
   23142 
   23143 /* Exercise %union. */
   23144 %union
   23145 {
   23146   semantic_value ival;
   23147 };
   23148 
   23149 %{
   23150 static int power (int base, int exponent);
   23151 /* yyerror receives the location if:
   23152    - %location & %pure & %glr
   23153    - %location & %pure & %yacc & %parse-param. */
   23154 static void yyerror (
   23155 
   23156                      const char *s
   23157                      );
   23158 static int yylex (void);
   23159 static int get_char (void);
   23160 static void unget_char ( int c);
   23161 %}
   23162 
   23163 
   23164 
   23165 /* Bison Declarations */
   23166 %token CALC_EOF 0 "end of input"
   23167 %token <ival> NUM "number"
   23168 %type  <ival> exp
   23169 
   23170 %nonassoc '=' /* comparison	       */
   23171 %left '-' '+'
   23172 %left '*' '/'
   23173 %left NEG     /* negation--unary minus */
   23174 %right '^'    /* exponentiation        */
   23175 
   23176 /* Grammar follows */
   23177 %%
   23178 input:
   23179   line
   23180 | input line         {  }
   23181 ;
   23182 
   23183 line:
   23184   '\n'
   23185 | exp '\n'           { USE ($1); }
   23186 ;
   23187 
   23188 exp:
   23189   NUM                { $$ = $1;             }
   23190 | exp '=' exp
   23191   {
   23192     if ($1 != $3)
   23193       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   23194     $$ = $1;
   23195   }
   23196 | exp '+' exp        { $$ = $1 + $3;        }
   23197 | exp '-' exp        { $$ = $1 - $3;        }
   23198 | exp '*' exp        { $$ = $1 * $3;        }
   23199 | exp '/' exp        { $$ = $1 / $3;        }
   23200 | '-' exp  %prec NEG { $$ = -$2;            }
   23201 | exp '^' exp        { $$ = power ($1, $3); }
   23202 | '(' exp ')'        { $$ = $2;             }
   23203 | '(' error ')'      { $$ = 1111;           }
   23204 | '!'                { $$ = 0; YYERROR;     }
   23205 | '-' error          { $$ = 0; YYERROR;     }
   23206 ;
   23207 %%
   23208 /* The input.  */
   23209 static FILE *input;
   23210 
   23211 static void
   23212 yyerror (
   23213 
   23214          const char *s)
   23215 {
   23216 
   23217 
   23218   fprintf (stderr, "%s\n", s);
   23219 }
   23220 
   23221 
   23222 
   23223 static int
   23224 get_char (void)
   23225 {
   23226   int res = getc (input);
   23227   ;
   23228 
   23229   return res;
   23230 }
   23231 
   23232 
   23233 static void
   23234 unget_char ( int c)
   23235 {
   23236   ;
   23237 
   23238   ungetc (c, input);
   23239 }
   23240 
   23241 static int
   23242 read_signed_integer (void)
   23243 {
   23244   int c = get_char ();
   23245   int sign = 1;
   23246   int n = 0;
   23247 
   23248   ;
   23249   if (c == '-')
   23250     {
   23251       c = get_char ();
   23252       sign = -1;
   23253     }
   23254 
   23255   while (isdigit (c))
   23256     {
   23257       n = 10 * n + (c - '0');
   23258       c = get_char ();
   23259     }
   23260 
   23261   unget_char ( c);
   23262 
   23263   return sign * n;
   23264 }
   23265 
   23266 
   23267 
   23268 /*---------------------------------------------------------------.
   23269 | Lexical analyzer returns an integer on the stack and the token |
   23270 | NUM, or the ASCII character read if not a number.  Skips all   |
   23271 | blanks and tabs, returns 0 for EOF.                            |
   23272 `---------------------------------------------------------------*/
   23273 
   23274 static int
   23275 yylex (void)
   23276 {
   23277   static int init = 1;
   23278   int c;
   23279 
   23280   if (init)
   23281     {
   23282       init = 0;
   23283 
   23284     }
   23285 
   23286 
   23287 
   23288   /* Skip white space.  */
   23289   while ((c = get_char ()) == ' ' || c == '\t')
   23290     {
   23291 
   23292     }
   23293 
   23294   /* process numbers   */
   23295   if (c == '.' || isdigit (c))
   23296     {
   23297       unget_char ( c);
   23298       (yylval).ival = read_signed_integer ();
   23299       return NUM;
   23300     }
   23301 
   23302   /* Return end-of-file.  */
   23303   if (c == EOF)
   23304     return CALC_EOF;
   23305 
   23306   /* Return single chars. */
   23307   return c;
   23308 }
   23309 
   23310 static int
   23311 power (int base, int exponent)
   23312 {
   23313   int res = 1;
   23314   if (exponent < 0)
   23315     exit (3);
   23316   for (/* Niente */; exponent; --exponent)
   23317     res *= base;
   23318   return res;
   23319 }
   23320 
   23321 
   23322 int
   23323 main (int argc, const char **argv)
   23324 {
   23325   semantic_value result = 0;
   23326   int count = 0;
   23327   int status;
   23328 
   23329   /* This used to be alarm (10), but that isn't enough time for
   23330      a July 1995 vintage DEC Alphastation 200 4/100 system,
   23331      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   23332   alarm (100);
   23333 
   23334   if (argc == 2)
   23335     input = fopen (argv[1], "r");
   23336   else
   23337     input = stdin;
   23338 
   23339   if (!input)
   23340     {
   23341       perror (argv[1]);
   23342       return 3;
   23343     }
   23344 
   23345   yydebug = 1;
   23346   status = yyparse ();
   23347   if (global_result != result)
   23348     abort ();
   23349   if (global_count != count)
   23350     abort ();
   23351   return status;
   23352 }
   23353 _ATEOF
   23354 
   23355 
   23356 
   23357 
   23358 
   23359 $at_traceoff
   23360 echo "calc.at:564: bison -o calc.c calc.y"
   23361 echo calc.at:564 >$at_check_line_file
   23362 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   23363 at_status=$?
   23364 grep '^ *+' $at_stder1 >&2
   23365 grep -v '^ *+' $at_stder1 >$at_stderr
   23366 at_failed=false
   23367 $at_diff $at_devnull $at_stderr || at_failed=:
   23368 $at_diff $at_devnull $at_stdout || at_failed=:
   23369 case $at_status in
   23370    77) echo 77 > $at_status_file
   23371             exit 77;;
   23372    0) ;;
   23373    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23374       at_failed=:;;
   23375 esac
   23376 if $at_failed; then
   23377 
   23378   echo 1 > $at_status_file
   23379   exit 1
   23380 fi
   23381 
   23382 $at_traceon
   23383 
   23384    $at_traceoff
   23385 echo "calc.at:564: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   23386 echo calc.at:564 >$at_check_line_file
   23387 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   23388 at_status=$?
   23389 grep '^ *+' $at_stder1 >&2
   23390 grep -v '^ *+' $at_stder1 >$at_stderr
   23391 at_failed=false
   23392 echo stderr:; cat $at_stderr
   23393 echo stdout:; cat $at_stdout
   23394 case $at_status in
   23395    77) echo 77 > $at_status_file
   23396             exit 77;;
   23397    0) ;;
   23398    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23399       at_failed=:;;
   23400 esac
   23401 if $at_failed; then
   23402 
   23403   echo 1 > $at_status_file
   23404   exit 1
   23405 fi
   23406 
   23407 $at_traceon
   23408 
   23409 
   23410 # Test the priorities.
   23411 cat >input <<'_ATEOF'
   23412 1 + 2 * 3 = 7
   23413 1 + 2 * -3 = -5
   23414 
   23415 -1^2 = -1
   23416 (-1)^2 = 1
   23417 
   23418 ---1 = -1
   23419 
   23420 1 - 2 - 3 = -4
   23421 1 - (2 - 3) = 2
   23422 
   23423 2^2^3 = 256
   23424 (2^2)^3 = 64
   23425 _ATEOF
   23426 
   23427 $at_traceoff
   23428 echo "calc.at:564: \$PREPARSER ./calc input"
   23429 echo calc.at:564 >$at_check_line_file
   23430 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   23431 at_status=$?
   23432 grep '^ *+' $at_stder1 >&2
   23433 grep -v '^ *+' $at_stder1 >$at_stderr
   23434 at_failed=false
   23435 echo stderr:; tee stderr <$at_stderr
   23436 $at_diff $at_devnull $at_stdout || at_failed=:
   23437 case $at_status in
   23438    77) echo 77 > $at_status_file
   23439             exit 77;;
   23440    0) ;;
   23441    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23442       at_failed=:;;
   23443 esac
   23444 if $at_failed; then
   23445 
   23446   echo 1 > $at_status_file
   23447   exit 1
   23448 fi
   23449 
   23450 $at_traceon
   23451 
   23452 
   23453 
   23454 # Some syntax errors.
   23455 cat >input <<'_ATEOF'
   23456 0 0
   23457 _ATEOF
   23458 
   23459 $at_traceoff
   23460 echo "calc.at:564: \$PREPARSER ./calc input"
   23461 echo calc.at:564 >$at_check_line_file
   23462 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   23463 at_status=$?
   23464 grep '^ *+' $at_stder1 >&2
   23465 grep -v '^ *+' $at_stder1 >$at_stderr
   23466 at_failed=false
   23467 echo stderr:; tee stderr <$at_stderr
   23468 $at_diff $at_devnull $at_stdout || at_failed=:
   23469 case $at_status in
   23470    77) echo 77 > $at_status_file
   23471             exit 77;;
   23472    1) ;;
   23473    *) echo "calc.at:564: exit code was $at_status, expected 1"
   23474       at_failed=:;;
   23475 esac
   23476 if $at_failed; then
   23477 
   23478   echo 1 > $at_status_file
   23479   exit 1
   23480 fi
   23481 
   23482 $at_traceon
   23483 
   23484 
   23485 # Normalize the observed and expected error messages, depending upon the
   23486 # options.
   23487 # 1. Remove the traces from observed.
   23488 sed '/^Starting/d
   23489 /^Entering/d
   23490 /^Stack/d
   23491 /^Reading/d
   23492 /^Reducing/d
   23493 /^Shifting/d
   23494 /^state/d
   23495 /^Cleanup:/d
   23496 /^Error:/d
   23497 /^Next/d
   23498 /^Discarding/d
   23499 / \$[0-9$]* = /d
   23500 /^yydestructor:/d' stderr >at-stderr
   23501 mv at-stderr stderr
   23502 # 2. Create the reference error message.
   23503 cat >expout <<'_ATEOF'
   23504 1.2: syntax error, unexpected number
   23505 _ATEOF
   23506 
   23507 # 3. If locations are not used, remove them.
   23508 sed 's/^[-0-9.]*: //' expout >at-expout
   23509 mv at-expout expout
   23510 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   23511 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   23512 mv at-expout expout
   23513 # 5. Check
   23514 $at_traceoff
   23515 echo "calc.at:564: cat stderr"
   23516 echo calc.at:564 >$at_check_line_file
   23517 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   23518 at_status=$?
   23519 grep '^ *+' $at_stder1 >&2
   23520 grep -v '^ *+' $at_stder1 >$at_stderr
   23521 at_failed=false
   23522 $at_diff $at_devnull $at_stderr || at_failed=:
   23523 $at_diff expout $at_stdout || at_failed=:
   23524 case $at_status in
   23525    77) echo 77 > $at_status_file
   23526             exit 77;;
   23527    0) ;;
   23528    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23529       at_failed=:;;
   23530 esac
   23531 if $at_failed; then
   23532 
   23533   echo 1 > $at_status_file
   23534   exit 1
   23535 fi
   23536 
   23537 $at_traceon
   23538 
   23539 
   23540 cat >input <<'_ATEOF'
   23541 1//2
   23542 _ATEOF
   23543 
   23544 $at_traceoff
   23545 echo "calc.at:564: \$PREPARSER ./calc input"
   23546 echo calc.at:564 >$at_check_line_file
   23547 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   23548 at_status=$?
   23549 grep '^ *+' $at_stder1 >&2
   23550 grep -v '^ *+' $at_stder1 >$at_stderr
   23551 at_failed=false
   23552 echo stderr:; tee stderr <$at_stderr
   23553 $at_diff $at_devnull $at_stdout || at_failed=:
   23554 case $at_status in
   23555    77) echo 77 > $at_status_file
   23556             exit 77;;
   23557    1) ;;
   23558    *) echo "calc.at:564: exit code was $at_status, expected 1"
   23559       at_failed=:;;
   23560 esac
   23561 if $at_failed; then
   23562 
   23563   echo 1 > $at_status_file
   23564   exit 1
   23565 fi
   23566 
   23567 $at_traceon
   23568 
   23569 
   23570 # Normalize the observed and expected error messages, depending upon the
   23571 # options.
   23572 # 1. Remove the traces from observed.
   23573 sed '/^Starting/d
   23574 /^Entering/d
   23575 /^Stack/d
   23576 /^Reading/d
   23577 /^Reducing/d
   23578 /^Shifting/d
   23579 /^state/d
   23580 /^Cleanup:/d
   23581 /^Error:/d
   23582 /^Next/d
   23583 /^Discarding/d
   23584 / \$[0-9$]* = /d
   23585 /^yydestructor:/d' stderr >at-stderr
   23586 mv at-stderr stderr
   23587 # 2. Create the reference error message.
   23588 cat >expout <<'_ATEOF'
   23589 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   23590 _ATEOF
   23591 
   23592 # 3. If locations are not used, remove them.
   23593 sed 's/^[-0-9.]*: //' expout >at-expout
   23594 mv at-expout expout
   23595 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   23596 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   23597 mv at-expout expout
   23598 # 5. Check
   23599 $at_traceoff
   23600 echo "calc.at:564: cat stderr"
   23601 echo calc.at:564 >$at_check_line_file
   23602 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   23603 at_status=$?
   23604 grep '^ *+' $at_stder1 >&2
   23605 grep -v '^ *+' $at_stder1 >$at_stderr
   23606 at_failed=false
   23607 $at_diff $at_devnull $at_stderr || at_failed=:
   23608 $at_diff expout $at_stdout || at_failed=:
   23609 case $at_status in
   23610    77) echo 77 > $at_status_file
   23611             exit 77;;
   23612    0) ;;
   23613    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23614       at_failed=:;;
   23615 esac
   23616 if $at_failed; then
   23617 
   23618   echo 1 > $at_status_file
   23619   exit 1
   23620 fi
   23621 
   23622 $at_traceon
   23623 
   23624 
   23625 cat >input <<'_ATEOF'
   23626 error
   23627 _ATEOF
   23628 
   23629 $at_traceoff
   23630 echo "calc.at:564: \$PREPARSER ./calc input"
   23631 echo calc.at:564 >$at_check_line_file
   23632 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   23633 at_status=$?
   23634 grep '^ *+' $at_stder1 >&2
   23635 grep -v '^ *+' $at_stder1 >$at_stderr
   23636 at_failed=false
   23637 echo stderr:; tee stderr <$at_stderr
   23638 $at_diff $at_devnull $at_stdout || at_failed=:
   23639 case $at_status in
   23640    77) echo 77 > $at_status_file
   23641             exit 77;;
   23642    1) ;;
   23643    *) echo "calc.at:564: exit code was $at_status, expected 1"
   23644       at_failed=:;;
   23645 esac
   23646 if $at_failed; then
   23647 
   23648   echo 1 > $at_status_file
   23649   exit 1
   23650 fi
   23651 
   23652 $at_traceon
   23653 
   23654 
   23655 # Normalize the observed and expected error messages, depending upon the
   23656 # options.
   23657 # 1. Remove the traces from observed.
   23658 sed '/^Starting/d
   23659 /^Entering/d
   23660 /^Stack/d
   23661 /^Reading/d
   23662 /^Reducing/d
   23663 /^Shifting/d
   23664 /^state/d
   23665 /^Cleanup:/d
   23666 /^Error:/d
   23667 /^Next/d
   23668 /^Discarding/d
   23669 / \$[0-9$]* = /d
   23670 /^yydestructor:/d' stderr >at-stderr
   23671 mv at-stderr stderr
   23672 # 2. Create the reference error message.
   23673 cat >expout <<'_ATEOF'
   23674 1.0: syntax error, unexpected $undefined
   23675 _ATEOF
   23676 
   23677 # 3. If locations are not used, remove them.
   23678 sed 's/^[-0-9.]*: //' expout >at-expout
   23679 mv at-expout expout
   23680 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   23681 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   23682 mv at-expout expout
   23683 # 5. Check
   23684 $at_traceoff
   23685 echo "calc.at:564: cat stderr"
   23686 echo calc.at:564 >$at_check_line_file
   23687 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   23688 at_status=$?
   23689 grep '^ *+' $at_stder1 >&2
   23690 grep -v '^ *+' $at_stder1 >$at_stderr
   23691 at_failed=false
   23692 $at_diff $at_devnull $at_stderr || at_failed=:
   23693 $at_diff expout $at_stdout || at_failed=:
   23694 case $at_status in
   23695    77) echo 77 > $at_status_file
   23696             exit 77;;
   23697    0) ;;
   23698    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23699       at_failed=:;;
   23700 esac
   23701 if $at_failed; then
   23702 
   23703   echo 1 > $at_status_file
   23704   exit 1
   23705 fi
   23706 
   23707 $at_traceon
   23708 
   23709 
   23710 cat >input <<'_ATEOF'
   23711 1 = 2 = 3
   23712 _ATEOF
   23713 
   23714 $at_traceoff
   23715 echo "calc.at:564: \$PREPARSER ./calc input"
   23716 echo calc.at:564 >$at_check_line_file
   23717 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   23718 at_status=$?
   23719 grep '^ *+' $at_stder1 >&2
   23720 grep -v '^ *+' $at_stder1 >$at_stderr
   23721 at_failed=false
   23722 echo stderr:; tee stderr <$at_stderr
   23723 $at_diff $at_devnull $at_stdout || at_failed=:
   23724 case $at_status in
   23725    77) echo 77 > $at_status_file
   23726             exit 77;;
   23727    1) ;;
   23728    *) echo "calc.at:564: exit code was $at_status, expected 1"
   23729       at_failed=:;;
   23730 esac
   23731 if $at_failed; then
   23732 
   23733   echo 1 > $at_status_file
   23734   exit 1
   23735 fi
   23736 
   23737 $at_traceon
   23738 
   23739 
   23740 # Normalize the observed and expected error messages, depending upon the
   23741 # options.
   23742 # 1. Remove the traces from observed.
   23743 sed '/^Starting/d
   23744 /^Entering/d
   23745 /^Stack/d
   23746 /^Reading/d
   23747 /^Reducing/d
   23748 /^Shifting/d
   23749 /^state/d
   23750 /^Cleanup:/d
   23751 /^Error:/d
   23752 /^Next/d
   23753 /^Discarding/d
   23754 / \$[0-9$]* = /d
   23755 /^yydestructor:/d' stderr >at-stderr
   23756 mv at-stderr stderr
   23757 # 2. Create the reference error message.
   23758 cat >expout <<'_ATEOF'
   23759 1.6: syntax error, unexpected '='
   23760 _ATEOF
   23761 
   23762 # 3. If locations are not used, remove them.
   23763 sed 's/^[-0-9.]*: //' expout >at-expout
   23764 mv at-expout expout
   23765 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   23766 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   23767 mv at-expout expout
   23768 # 5. Check
   23769 $at_traceoff
   23770 echo "calc.at:564: cat stderr"
   23771 echo calc.at:564 >$at_check_line_file
   23772 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   23773 at_status=$?
   23774 grep '^ *+' $at_stder1 >&2
   23775 grep -v '^ *+' $at_stder1 >$at_stderr
   23776 at_failed=false
   23777 $at_diff $at_devnull $at_stderr || at_failed=:
   23778 $at_diff expout $at_stdout || at_failed=:
   23779 case $at_status in
   23780    77) echo 77 > $at_status_file
   23781             exit 77;;
   23782    0) ;;
   23783    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23784       at_failed=:;;
   23785 esac
   23786 if $at_failed; then
   23787 
   23788   echo 1 > $at_status_file
   23789   exit 1
   23790 fi
   23791 
   23792 $at_traceon
   23793 
   23794 
   23795 cat >input <<'_ATEOF'
   23796 
   23797 +1
   23798 _ATEOF
   23799 
   23800 $at_traceoff
   23801 echo "calc.at:564: \$PREPARSER ./calc input"
   23802 echo calc.at:564 >$at_check_line_file
   23803 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   23804 at_status=$?
   23805 grep '^ *+' $at_stder1 >&2
   23806 grep -v '^ *+' $at_stder1 >$at_stderr
   23807 at_failed=false
   23808 echo stderr:; tee stderr <$at_stderr
   23809 $at_diff $at_devnull $at_stdout || at_failed=:
   23810 case $at_status in
   23811    77) echo 77 > $at_status_file
   23812             exit 77;;
   23813    1) ;;
   23814    *) echo "calc.at:564: exit code was $at_status, expected 1"
   23815       at_failed=:;;
   23816 esac
   23817 if $at_failed; then
   23818 
   23819   echo 1 > $at_status_file
   23820   exit 1
   23821 fi
   23822 
   23823 $at_traceon
   23824 
   23825 
   23826 # Normalize the observed and expected error messages, depending upon the
   23827 # options.
   23828 # 1. Remove the traces from observed.
   23829 sed '/^Starting/d
   23830 /^Entering/d
   23831 /^Stack/d
   23832 /^Reading/d
   23833 /^Reducing/d
   23834 /^Shifting/d
   23835 /^state/d
   23836 /^Cleanup:/d
   23837 /^Error:/d
   23838 /^Next/d
   23839 /^Discarding/d
   23840 / \$[0-9$]* = /d
   23841 /^yydestructor:/d' stderr >at-stderr
   23842 mv at-stderr stderr
   23843 # 2. Create the reference error message.
   23844 cat >expout <<'_ATEOF'
   23845 2.0: syntax error, unexpected '+'
   23846 _ATEOF
   23847 
   23848 # 3. If locations are not used, remove them.
   23849 sed 's/^[-0-9.]*: //' expout >at-expout
   23850 mv at-expout expout
   23851 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   23852 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   23853 mv at-expout expout
   23854 # 5. Check
   23855 $at_traceoff
   23856 echo "calc.at:564: cat stderr"
   23857 echo calc.at:564 >$at_check_line_file
   23858 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   23859 at_status=$?
   23860 grep '^ *+' $at_stder1 >&2
   23861 grep -v '^ *+' $at_stder1 >$at_stderr
   23862 at_failed=false
   23863 $at_diff $at_devnull $at_stderr || at_failed=:
   23864 $at_diff expout $at_stdout || at_failed=:
   23865 case $at_status in
   23866    77) echo 77 > $at_status_file
   23867             exit 77;;
   23868    0) ;;
   23869    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23870       at_failed=:;;
   23871 esac
   23872 if $at_failed; then
   23873 
   23874   echo 1 > $at_status_file
   23875   exit 1
   23876 fi
   23877 
   23878 $at_traceon
   23879 
   23880 
   23881 # Exercise error messages with EOF: work on an empty file.
   23882 $at_traceoff
   23883 echo "calc.at:564: \$PREPARSER ./calc /dev/null"
   23884 echo calc.at:564 >$at_check_line_file
   23885 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   23886 at_status=$?
   23887 grep '^ *+' $at_stder1 >&2
   23888 grep -v '^ *+' $at_stder1 >$at_stderr
   23889 at_failed=false
   23890 echo stderr:; tee stderr <$at_stderr
   23891 $at_diff $at_devnull $at_stdout || at_failed=:
   23892 case $at_status in
   23893    77) echo 77 > $at_status_file
   23894             exit 77;;
   23895    1) ;;
   23896    *) echo "calc.at:564: exit code was $at_status, expected 1"
   23897       at_failed=:;;
   23898 esac
   23899 if $at_failed; then
   23900 
   23901   echo 1 > $at_status_file
   23902   exit 1
   23903 fi
   23904 
   23905 $at_traceon
   23906 
   23907 
   23908 # Normalize the observed and expected error messages, depending upon the
   23909 # options.
   23910 # 1. Remove the traces from observed.
   23911 sed '/^Starting/d
   23912 /^Entering/d
   23913 /^Stack/d
   23914 /^Reading/d
   23915 /^Reducing/d
   23916 /^Shifting/d
   23917 /^state/d
   23918 /^Cleanup:/d
   23919 /^Error:/d
   23920 /^Next/d
   23921 /^Discarding/d
   23922 / \$[0-9$]* = /d
   23923 /^yydestructor:/d' stderr >at-stderr
   23924 mv at-stderr stderr
   23925 # 2. Create the reference error message.
   23926 cat >expout <<'_ATEOF'
   23927 1.0: syntax error, unexpected end of input
   23928 _ATEOF
   23929 
   23930 # 3. If locations are not used, remove them.
   23931 sed 's/^[-0-9.]*: //' expout >at-expout
   23932 mv at-expout expout
   23933 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   23934 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   23935 mv at-expout expout
   23936 # 5. Check
   23937 $at_traceoff
   23938 echo "calc.at:564: cat stderr"
   23939 echo calc.at:564 >$at_check_line_file
   23940 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   23941 at_status=$?
   23942 grep '^ *+' $at_stder1 >&2
   23943 grep -v '^ *+' $at_stder1 >$at_stderr
   23944 at_failed=false
   23945 $at_diff $at_devnull $at_stderr || at_failed=:
   23946 $at_diff expout $at_stdout || at_failed=:
   23947 case $at_status in
   23948    77) echo 77 > $at_status_file
   23949             exit 77;;
   23950    0) ;;
   23951    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23952       at_failed=:;;
   23953 esac
   23954 if $at_failed; then
   23955 
   23956   echo 1 > $at_status_file
   23957   exit 1
   23958 fi
   23959 
   23960 $at_traceon
   23961 
   23962 
   23963 
   23964 # Exercise the error token: without it, we die at the first error,
   23965 # hence be sure to
   23966 #
   23967 # - have several errors which exercise different shift/discardings
   23968 #   - (): nothing to pop, nothing to discard
   23969 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   23970 #   - (* * *): nothing to pop, a lot to discard
   23971 #   - (1 + 2 * *): some to pop and discard
   23972 #
   23973 # - test the action associated to `error'
   23974 #
   23975 # - check the look-ahead that triggers an error is not discarded
   23976 #   when we enter error recovery.  Below, the look-ahead causing the
   23977 #   first error is ")", which is needed to recover from the error and
   23978 #   produce the "0" that triggers the "0 != 1" error.
   23979 #
   23980 cat >input <<'_ATEOF'
   23981 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   23982 _ATEOF
   23983 
   23984 $at_traceoff
   23985 echo "calc.at:564: \$PREPARSER ./calc input"
   23986 echo calc.at:564 >$at_check_line_file
   23987 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   23988 at_status=$?
   23989 grep '^ *+' $at_stder1 >&2
   23990 grep -v '^ *+' $at_stder1 >$at_stderr
   23991 at_failed=false
   23992 echo stderr:; tee stderr <$at_stderr
   23993 $at_diff $at_devnull $at_stdout || at_failed=:
   23994 case $at_status in
   23995    77) echo 77 > $at_status_file
   23996             exit 77;;
   23997    0) ;;
   23998    *) echo "calc.at:564: exit code was $at_status, expected 0"
   23999       at_failed=:;;
   24000 esac
   24001 if $at_failed; then
   24002 
   24003   echo 1 > $at_status_file
   24004   exit 1
   24005 fi
   24006 
   24007 $at_traceon
   24008 
   24009 
   24010 # Normalize the observed and expected error messages, depending upon the
   24011 # options.
   24012 # 1. Remove the traces from observed.
   24013 sed '/^Starting/d
   24014 /^Entering/d
   24015 /^Stack/d
   24016 /^Reading/d
   24017 /^Reducing/d
   24018 /^Shifting/d
   24019 /^state/d
   24020 /^Cleanup:/d
   24021 /^Error:/d
   24022 /^Next/d
   24023 /^Discarding/d
   24024 / \$[0-9$]* = /d
   24025 /^yydestructor:/d' stderr >at-stderr
   24026 mv at-stderr stderr
   24027 # 2. Create the reference error message.
   24028 cat >expout <<'_ATEOF'
   24029 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   24030 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   24031 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   24032 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   24033 calc: error: 4444 != 1
   24034 _ATEOF
   24035 
   24036 # 3. If locations are not used, remove them.
   24037 sed 's/^[-0-9.]*: //' expout >at-expout
   24038 mv at-expout expout
   24039 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   24040 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   24041 mv at-expout expout
   24042 # 5. Check
   24043 $at_traceoff
   24044 echo "calc.at:564: cat stderr"
   24045 echo calc.at:564 >$at_check_line_file
   24046 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   24047 at_status=$?
   24048 grep '^ *+' $at_stder1 >&2
   24049 grep -v '^ *+' $at_stder1 >$at_stderr
   24050 at_failed=false
   24051 $at_diff $at_devnull $at_stderr || at_failed=:
   24052 $at_diff expout $at_stdout || at_failed=:
   24053 case $at_status in
   24054    77) echo 77 > $at_status_file
   24055             exit 77;;
   24056    0) ;;
   24057    *) echo "calc.at:564: exit code was $at_status, expected 0"
   24058       at_failed=:;;
   24059 esac
   24060 if $at_failed; then
   24061 
   24062   echo 1 > $at_status_file
   24063   exit 1
   24064 fi
   24065 
   24066 $at_traceon
   24067 
   24068 
   24069 
   24070 # The same, but this time exercising explicitly triggered syntax errors.
   24071 # POSIX says the look-ahead causing the error should not be discarded.
   24072 cat >input <<'_ATEOF'
   24073 (!) + (0 0) = 1
   24074 _ATEOF
   24075 
   24076 $at_traceoff
   24077 echo "calc.at:564: \$PREPARSER ./calc input"
   24078 echo calc.at:564 >$at_check_line_file
   24079 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   24080 at_status=$?
   24081 grep '^ *+' $at_stder1 >&2
   24082 grep -v '^ *+' $at_stder1 >$at_stderr
   24083 at_failed=false
   24084 echo stderr:; tee stderr <$at_stderr
   24085 $at_diff $at_devnull $at_stdout || at_failed=:
   24086 case $at_status in
   24087    77) echo 77 > $at_status_file
   24088             exit 77;;
   24089    0) ;;
   24090    *) echo "calc.at:564: exit code was $at_status, expected 0"
   24091       at_failed=:;;
   24092 esac
   24093 if $at_failed; then
   24094 
   24095   echo 1 > $at_status_file
   24096   exit 1
   24097 fi
   24098 
   24099 $at_traceon
   24100 
   24101 
   24102 # Normalize the observed and expected error messages, depending upon the
   24103 # options.
   24104 # 1. Remove the traces from observed.
   24105 sed '/^Starting/d
   24106 /^Entering/d
   24107 /^Stack/d
   24108 /^Reading/d
   24109 /^Reducing/d
   24110 /^Shifting/d
   24111 /^state/d
   24112 /^Cleanup:/d
   24113 /^Error:/d
   24114 /^Next/d
   24115 /^Discarding/d
   24116 / \$[0-9$]* = /d
   24117 /^yydestructor:/d' stderr >at-stderr
   24118 mv at-stderr stderr
   24119 # 2. Create the reference error message.
   24120 cat >expout <<'_ATEOF'
   24121 1.9: syntax error, unexpected number
   24122 calc: error: 2222 != 1
   24123 _ATEOF
   24124 
   24125 # 3. If locations are not used, remove them.
   24126 sed 's/^[-0-9.]*: //' expout >at-expout
   24127 mv at-expout expout
   24128 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   24129 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   24130 mv at-expout expout
   24131 # 5. Check
   24132 $at_traceoff
   24133 echo "calc.at:564: cat stderr"
   24134 echo calc.at:564 >$at_check_line_file
   24135 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   24136 at_status=$?
   24137 grep '^ *+' $at_stder1 >&2
   24138 grep -v '^ *+' $at_stder1 >$at_stderr
   24139 at_failed=false
   24140 $at_diff $at_devnull $at_stderr || at_failed=:
   24141 $at_diff expout $at_stdout || at_failed=:
   24142 case $at_status in
   24143    77) echo 77 > $at_status_file
   24144             exit 77;;
   24145    0) ;;
   24146    *) echo "calc.at:564: exit code was $at_status, expected 0"
   24147       at_failed=:;;
   24148 esac
   24149 if $at_failed; then
   24150 
   24151   echo 1 > $at_status_file
   24152   exit 1
   24153 fi
   24154 
   24155 $at_traceon
   24156 
   24157 
   24158 cat >input <<'_ATEOF'
   24159 (- *) + (0 0) = 1
   24160 _ATEOF
   24161 
   24162 $at_traceoff
   24163 echo "calc.at:564: \$PREPARSER ./calc input"
   24164 echo calc.at:564 >$at_check_line_file
   24165 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   24166 at_status=$?
   24167 grep '^ *+' $at_stder1 >&2
   24168 grep -v '^ *+' $at_stder1 >$at_stderr
   24169 at_failed=false
   24170 echo stderr:; tee stderr <$at_stderr
   24171 $at_diff $at_devnull $at_stdout || at_failed=:
   24172 case $at_status in
   24173    77) echo 77 > $at_status_file
   24174             exit 77;;
   24175    0) ;;
   24176    *) echo "calc.at:564: exit code was $at_status, expected 0"
   24177       at_failed=:;;
   24178 esac
   24179 if $at_failed; then
   24180 
   24181   echo 1 > $at_status_file
   24182   exit 1
   24183 fi
   24184 
   24185 $at_traceon
   24186 
   24187 
   24188 # Normalize the observed and expected error messages, depending upon the
   24189 # options.
   24190 # 1. Remove the traces from observed.
   24191 sed '/^Starting/d
   24192 /^Entering/d
   24193 /^Stack/d
   24194 /^Reading/d
   24195 /^Reducing/d
   24196 /^Shifting/d
   24197 /^state/d
   24198 /^Cleanup:/d
   24199 /^Error:/d
   24200 /^Next/d
   24201 /^Discarding/d
   24202 / \$[0-9$]* = /d
   24203 /^yydestructor:/d' stderr >at-stderr
   24204 mv at-stderr stderr
   24205 # 2. Create the reference error message.
   24206 cat >expout <<'_ATEOF'
   24207 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   24208 1.11: syntax error, unexpected number
   24209 calc: error: 2222 != 1
   24210 _ATEOF
   24211 
   24212 # 3. If locations are not used, remove them.
   24213 sed 's/^[-0-9.]*: //' expout >at-expout
   24214 mv at-expout expout
   24215 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   24216 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   24217 mv at-expout expout
   24218 # 5. Check
   24219 $at_traceoff
   24220 echo "calc.at:564: cat stderr"
   24221 echo calc.at:564 >$at_check_line_file
   24222 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   24223 at_status=$?
   24224 grep '^ *+' $at_stder1 >&2
   24225 grep -v '^ *+' $at_stder1 >$at_stderr
   24226 at_failed=false
   24227 $at_diff $at_devnull $at_stderr || at_failed=:
   24228 $at_diff expout $at_stdout || at_failed=:
   24229 case $at_status in
   24230    77) echo 77 > $at_status_file
   24231             exit 77;;
   24232    0) ;;
   24233    *) echo "calc.at:564: exit code was $at_status, expected 0"
   24234       at_failed=:;;
   24235 esac
   24236 if $at_failed; then
   24237 
   24238   echo 1 > $at_status_file
   24239   exit 1
   24240 fi
   24241 
   24242 $at_traceon
   24243 
   24244 
   24245 
   24246 
   24247 
   24248 
   24249 
   24250 
   24251 
   24252 
   24253 
   24254 
   24255 
   24256 
   24257 
   24258 
   24259 
   24260 
   24261 
   24262 
   24263 
   24264 
   24265 
   24266 
   24267       $at_traceoff
   24268       $at_times_p && times >$at_times_file
   24269     ) 5>&1 2>&1 | eval $at_tee_pipe
   24270     at_status=`cat $at_status_file`
   24271     ;;
   24272 
   24273   81 ) # 81. calc.at:565: Calculator %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
   24274     at_setup_line='calc.at:565'
   24275     at_desc='Calculator %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc'
   24276     $at_quiet $ECHO_N " 81: Calculator %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc$ECHO_C"
   24277     at_xfail=no
   24278     (
   24279       echo "81. calc.at:565: testing ..."
   24280       $at_traceon
   24281 
   24282 
   24283 
   24284 
   24285 
   24286 
   24287 
   24288 
   24289 # Using yacc.c?
   24290 
   24291 
   24292 
   24293 
   24294 
   24295 
   24296 
   24297 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   24298 
   24299 # yyerror always sees the locations (when activated), except if
   24300 # yacc & pure & !param.
   24301 
   24302 
   24303 # The interface is pure: either because %pure-parser, or because we
   24304 # are using the C++ parsers.
   24305 
   24306 
   24307 
   24308 
   24309 
   24310 
   24311 
   24312 
   24313 
   24314 
   24315 
   24316 
   24317 cat >calc.y <<'_ATEOF'
   24318 %{
   24319 #ifdef HAVE_CONFIG_H
   24320 # include <config.h>
   24321   /* We don't need perfect functions for these tests. */
   24322 # undef malloc
   24323 # undef memcmp
   24324 # undef realloc
   24325 #endif
   24326 %}
   24327 
   24328 /* Infix notation calculator--calc */
   24329 %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
   24330 
   24331 %{
   24332 #include <stdio.h>
   24333 
   24334 #include <stdlib.h>
   24335 #include <string.h>
   24336 #if HAVE_UNISTD_H
   24337 # include <unistd.h>
   24338 #else
   24339 # undef alarm
   24340 # define alarm(seconds) /* empty */
   24341 #endif
   24342 #include <ctype.h>
   24343 #define USE(Var)
   24344 
   24345 /* Exercise pre-prologue dependency to %union.  */
   24346 typedef int semantic_value;
   24347 
   24348 static semantic_value global_result = 0;
   24349 static int global_count = 0;
   24350 %}
   24351 
   24352 /* Exercise %union. */
   24353 %union
   24354 {
   24355   semantic_value ival;
   24356 };
   24357 
   24358 %{
   24359 static int power (int base, int exponent);
   24360 /* yyerror receives the location if:
   24361    - %location & %pure & %glr
   24362    - %location & %pure & %yacc & %parse-param. */
   24363 static void yyerror (
   24364 
   24365                      const char *s
   24366                      );
   24367 static int yylex (void);
   24368 static int get_char (void);
   24369 static void unget_char ( int c);
   24370 %}
   24371 
   24372 
   24373 
   24374 /* Bison Declarations */
   24375 %token CALC_EOF 0 "end of input"
   24376 %token <ival> NUM "number"
   24377 %type  <ival> exp
   24378 
   24379 %nonassoc '=' /* comparison	       */
   24380 %left '-' '+'
   24381 %left '*' '/'
   24382 %left NEG     /* negation--unary minus */
   24383 %right '^'    /* exponentiation        */
   24384 
   24385 /* Grammar follows */
   24386 %%
   24387 input:
   24388   line
   24389 | input line         {  }
   24390 ;
   24391 
   24392 line:
   24393   '\n'
   24394 | exp '\n'           { USE ($1); }
   24395 ;
   24396 
   24397 exp:
   24398   NUM                { $$ = $1;             }
   24399 | exp '=' exp
   24400   {
   24401     if ($1 != $3)
   24402       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   24403     $$ = $1;
   24404   }
   24405 | exp '+' exp        { $$ = $1 + $3;        }
   24406 | exp '-' exp        { $$ = $1 - $3;        }
   24407 | exp '*' exp        { $$ = $1 * $3;        }
   24408 | exp '/' exp        { $$ = $1 / $3;        }
   24409 | '-' exp  %prec NEG { $$ = -$2;            }
   24410 | exp '^' exp        { $$ = power ($1, $3); }
   24411 | '(' exp ')'        { $$ = $2;             }
   24412 | '(' error ')'      { $$ = 1111;           }
   24413 | '!'                { $$ = 0; YYERROR;     }
   24414 | '-' error          { $$ = 0; YYERROR;     }
   24415 ;
   24416 %%
   24417 /* The input.  */
   24418 static FILE *input;
   24419 
   24420 static void
   24421 yyerror (
   24422 
   24423          const char *s)
   24424 {
   24425 
   24426 
   24427   fprintf (stderr, "%d.%d",
   24428            (yylloc).first_line, (yylloc).first_column);
   24429   if ((yylloc).first_line != (yylloc).last_line)
   24430     fprintf (stderr, "-%d.%d",
   24431 	     (yylloc).last_line,  (yylloc).last_column - 1);
   24432   else if ((yylloc).first_column != (yylloc).last_column - 1)
   24433     fprintf (stderr, "-%d",
   24434 	     (yylloc).last_column - 1);
   24435   fprintf (stderr, ": ");
   24436   fprintf (stderr, "%s\n", s);
   24437 }
   24438 
   24439 
   24440 
   24441 static YYLTYPE last_yylloc;
   24442 
   24443 static int
   24444 get_char (void)
   24445 {
   24446   int res = getc (input);
   24447   ;
   24448 
   24449   last_yylloc = (yylloc);
   24450   if (res == '\n')
   24451     {
   24452       (yylloc).last_line++;
   24453       (yylloc).last_column = 0;
   24454     }
   24455   else
   24456     (yylloc).last_column++;
   24457 
   24458   return res;
   24459 }
   24460 
   24461 
   24462 static void
   24463 unget_char ( int c)
   24464 {
   24465   ;
   24466 
   24467   /* Wrong when C == `\n'. */
   24468   (yylloc) = last_yylloc;
   24469 
   24470   ungetc (c, input);
   24471 }
   24472 
   24473 static int
   24474 read_signed_integer (void)
   24475 {
   24476   int c = get_char ();
   24477   int sign = 1;
   24478   int n = 0;
   24479 
   24480   ;
   24481   if (c == '-')
   24482     {
   24483       c = get_char ();
   24484       sign = -1;
   24485     }
   24486 
   24487   while (isdigit (c))
   24488     {
   24489       n = 10 * n + (c - '0');
   24490       c = get_char ();
   24491     }
   24492 
   24493   unget_char ( c);
   24494 
   24495   return sign * n;
   24496 }
   24497 
   24498 
   24499 
   24500 /*---------------------------------------------------------------.
   24501 | Lexical analyzer returns an integer on the stack and the token |
   24502 | NUM, or the ASCII character read if not a number.  Skips all   |
   24503 | blanks and tabs, returns 0 for EOF.                            |
   24504 `---------------------------------------------------------------*/
   24505 
   24506 static int
   24507 yylex (void)
   24508 {
   24509   static int init = 1;
   24510   int c;
   24511 
   24512   if (init)
   24513     {
   24514       init = 0;
   24515 
   24516       (yylloc).last_column = 0;
   24517       (yylloc).last_line = 1;
   24518 
   24519     }
   24520 
   24521 
   24522  (yylloc).first_column = (yylloc).last_column;
   24523   (yylloc).first_line   = (yylloc).last_line;
   24524 
   24525 
   24526   /* Skip white space.  */
   24527   while ((c = get_char ()) == ' ' || c == '\t')
   24528     {
   24529      (yylloc).first_column = (yylloc).last_column;
   24530       (yylloc).first_line   = (yylloc).last_line;
   24531 
   24532     }
   24533 
   24534   /* process numbers   */
   24535   if (c == '.' || isdigit (c))
   24536     {
   24537       unget_char ( c);
   24538       (yylval).ival = read_signed_integer ();
   24539       return NUM;
   24540     }
   24541 
   24542   /* Return end-of-file.  */
   24543   if (c == EOF)
   24544     return CALC_EOF;
   24545 
   24546   /* Return single chars. */
   24547   return c;
   24548 }
   24549 
   24550 static int
   24551 power (int base, int exponent)
   24552 {
   24553   int res = 1;
   24554   if (exponent < 0)
   24555     exit (3);
   24556   for (/* Niente */; exponent; --exponent)
   24557     res *= base;
   24558   return res;
   24559 }
   24560 
   24561 
   24562 int
   24563 main (int argc, const char **argv)
   24564 {
   24565   semantic_value result = 0;
   24566   int count = 0;
   24567   int status;
   24568 
   24569   /* This used to be alarm (10), but that isn't enough time for
   24570      a July 1995 vintage DEC Alphastation 200 4/100 system,
   24571      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   24572   alarm (100);
   24573 
   24574   if (argc == 2)
   24575     input = fopen (argv[1], "r");
   24576   else
   24577     input = stdin;
   24578 
   24579   if (!input)
   24580     {
   24581       perror (argv[1]);
   24582       return 3;
   24583     }
   24584 
   24585   yydebug = 1;
   24586   status = yyparse ();
   24587   if (global_result != result)
   24588     abort ();
   24589   if (global_count != count)
   24590     abort ();
   24591   return status;
   24592 }
   24593 _ATEOF
   24594 
   24595 
   24596 
   24597 
   24598 
   24599 $at_traceoff
   24600 echo "calc.at:565: bison -o calc.c calc.y"
   24601 echo calc.at:565 >$at_check_line_file
   24602 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   24603 at_status=$?
   24604 grep '^ *+' $at_stder1 >&2
   24605 grep -v '^ *+' $at_stder1 >$at_stderr
   24606 at_failed=false
   24607 $at_diff $at_devnull $at_stderr || at_failed=:
   24608 $at_diff $at_devnull $at_stdout || at_failed=:
   24609 case $at_status in
   24610    77) echo 77 > $at_status_file
   24611             exit 77;;
   24612    0) ;;
   24613    *) echo "calc.at:565: exit code was $at_status, expected 0"
   24614       at_failed=:;;
   24615 esac
   24616 if $at_failed; then
   24617 
   24618   echo 1 > $at_status_file
   24619   exit 1
   24620 fi
   24621 
   24622 $at_traceon
   24623 
   24624    $at_traceoff
   24625 echo "calc.at:565: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   24626 echo calc.at:565 >$at_check_line_file
   24627 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   24628 at_status=$?
   24629 grep '^ *+' $at_stder1 >&2
   24630 grep -v '^ *+' $at_stder1 >$at_stderr
   24631 at_failed=false
   24632 echo stderr:; cat $at_stderr
   24633 echo stdout:; cat $at_stdout
   24634 case $at_status in
   24635    77) echo 77 > $at_status_file
   24636             exit 77;;
   24637    0) ;;
   24638    *) echo "calc.at:565: exit code was $at_status, expected 0"
   24639       at_failed=:;;
   24640 esac
   24641 if $at_failed; then
   24642 
   24643   echo 1 > $at_status_file
   24644   exit 1
   24645 fi
   24646 
   24647 $at_traceon
   24648 
   24649 
   24650 # Test the priorities.
   24651 cat >input <<'_ATEOF'
   24652 1 + 2 * 3 = 7
   24653 1 + 2 * -3 = -5
   24654 
   24655 -1^2 = -1
   24656 (-1)^2 = 1
   24657 
   24658 ---1 = -1
   24659 
   24660 1 - 2 - 3 = -4
   24661 1 - (2 - 3) = 2
   24662 
   24663 2^2^3 = 256
   24664 (2^2)^3 = 64
   24665 _ATEOF
   24666 
   24667 $at_traceoff
   24668 echo "calc.at:565: \$PREPARSER ./calc input"
   24669 echo calc.at:565 >$at_check_line_file
   24670 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   24671 at_status=$?
   24672 grep '^ *+' $at_stder1 >&2
   24673 grep -v '^ *+' $at_stder1 >$at_stderr
   24674 at_failed=false
   24675 echo stderr:; tee stderr <$at_stderr
   24676 $at_diff $at_devnull $at_stdout || at_failed=:
   24677 case $at_status in
   24678    77) echo 77 > $at_status_file
   24679             exit 77;;
   24680    0) ;;
   24681    *) echo "calc.at:565: exit code was $at_status, expected 0"
   24682       at_failed=:;;
   24683 esac
   24684 if $at_failed; then
   24685 
   24686   echo 1 > $at_status_file
   24687   exit 1
   24688 fi
   24689 
   24690 $at_traceon
   24691 
   24692 
   24693 
   24694 # Some syntax errors.
   24695 cat >input <<'_ATEOF'
   24696 0 0
   24697 _ATEOF
   24698 
   24699 $at_traceoff
   24700 echo "calc.at:565: \$PREPARSER ./calc input"
   24701 echo calc.at:565 >$at_check_line_file
   24702 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   24703 at_status=$?
   24704 grep '^ *+' $at_stder1 >&2
   24705 grep -v '^ *+' $at_stder1 >$at_stderr
   24706 at_failed=false
   24707 echo stderr:; tee stderr <$at_stderr
   24708 $at_diff $at_devnull $at_stdout || at_failed=:
   24709 case $at_status in
   24710    77) echo 77 > $at_status_file
   24711             exit 77;;
   24712    1) ;;
   24713    *) echo "calc.at:565: exit code was $at_status, expected 1"
   24714       at_failed=:;;
   24715 esac
   24716 if $at_failed; then
   24717 
   24718   echo 1 > $at_status_file
   24719   exit 1
   24720 fi
   24721 
   24722 $at_traceon
   24723 
   24724 
   24725 # Normalize the observed and expected error messages, depending upon the
   24726 # options.
   24727 # 1. Remove the traces from observed.
   24728 sed '/^Starting/d
   24729 /^Entering/d
   24730 /^Stack/d
   24731 /^Reading/d
   24732 /^Reducing/d
   24733 /^Shifting/d
   24734 /^state/d
   24735 /^Cleanup:/d
   24736 /^Error:/d
   24737 /^Next/d
   24738 /^Discarding/d
   24739 / \$[0-9$]* = /d
   24740 /^yydestructor:/d' stderr >at-stderr
   24741 mv at-stderr stderr
   24742 # 2. Create the reference error message.
   24743 cat >expout <<'_ATEOF'
   24744 1.2: syntax error, unexpected number
   24745 _ATEOF
   24746 
   24747 # 3. If locations are not used, remove them.
   24748 
   24749 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   24750 
   24751 # 5. Check
   24752 $at_traceoff
   24753 echo "calc.at:565: cat stderr"
   24754 echo calc.at:565 >$at_check_line_file
   24755 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   24756 at_status=$?
   24757 grep '^ *+' $at_stder1 >&2
   24758 grep -v '^ *+' $at_stder1 >$at_stderr
   24759 at_failed=false
   24760 $at_diff $at_devnull $at_stderr || at_failed=:
   24761 $at_diff expout $at_stdout || at_failed=:
   24762 case $at_status in
   24763    77) echo 77 > $at_status_file
   24764             exit 77;;
   24765    0) ;;
   24766    *) echo "calc.at:565: exit code was $at_status, expected 0"
   24767       at_failed=:;;
   24768 esac
   24769 if $at_failed; then
   24770 
   24771   echo 1 > $at_status_file
   24772   exit 1
   24773 fi
   24774 
   24775 $at_traceon
   24776 
   24777 
   24778 cat >input <<'_ATEOF'
   24779 1//2
   24780 _ATEOF
   24781 
   24782 $at_traceoff
   24783 echo "calc.at:565: \$PREPARSER ./calc input"
   24784 echo calc.at:565 >$at_check_line_file
   24785 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   24786 at_status=$?
   24787 grep '^ *+' $at_stder1 >&2
   24788 grep -v '^ *+' $at_stder1 >$at_stderr
   24789 at_failed=false
   24790 echo stderr:; tee stderr <$at_stderr
   24791 $at_diff $at_devnull $at_stdout || at_failed=:
   24792 case $at_status in
   24793    77) echo 77 > $at_status_file
   24794             exit 77;;
   24795    1) ;;
   24796    *) echo "calc.at:565: exit code was $at_status, expected 1"
   24797       at_failed=:;;
   24798 esac
   24799 if $at_failed; then
   24800 
   24801   echo 1 > $at_status_file
   24802   exit 1
   24803 fi
   24804 
   24805 $at_traceon
   24806 
   24807 
   24808 # Normalize the observed and expected error messages, depending upon the
   24809 # options.
   24810 # 1. Remove the traces from observed.
   24811 sed '/^Starting/d
   24812 /^Entering/d
   24813 /^Stack/d
   24814 /^Reading/d
   24815 /^Reducing/d
   24816 /^Shifting/d
   24817 /^state/d
   24818 /^Cleanup:/d
   24819 /^Error:/d
   24820 /^Next/d
   24821 /^Discarding/d
   24822 / \$[0-9$]* = /d
   24823 /^yydestructor:/d' stderr >at-stderr
   24824 mv at-stderr stderr
   24825 # 2. Create the reference error message.
   24826 cat >expout <<'_ATEOF'
   24827 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   24828 _ATEOF
   24829 
   24830 # 3. If locations are not used, remove them.
   24831 
   24832 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   24833 
   24834 # 5. Check
   24835 $at_traceoff
   24836 echo "calc.at:565: cat stderr"
   24837 echo calc.at:565 >$at_check_line_file
   24838 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   24839 at_status=$?
   24840 grep '^ *+' $at_stder1 >&2
   24841 grep -v '^ *+' $at_stder1 >$at_stderr
   24842 at_failed=false
   24843 $at_diff $at_devnull $at_stderr || at_failed=:
   24844 $at_diff expout $at_stdout || at_failed=:
   24845 case $at_status in
   24846    77) echo 77 > $at_status_file
   24847             exit 77;;
   24848    0) ;;
   24849    *) echo "calc.at:565: exit code was $at_status, expected 0"
   24850       at_failed=:;;
   24851 esac
   24852 if $at_failed; then
   24853 
   24854   echo 1 > $at_status_file
   24855   exit 1
   24856 fi
   24857 
   24858 $at_traceon
   24859 
   24860 
   24861 cat >input <<'_ATEOF'
   24862 error
   24863 _ATEOF
   24864 
   24865 $at_traceoff
   24866 echo "calc.at:565: \$PREPARSER ./calc input"
   24867 echo calc.at:565 >$at_check_line_file
   24868 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   24869 at_status=$?
   24870 grep '^ *+' $at_stder1 >&2
   24871 grep -v '^ *+' $at_stder1 >$at_stderr
   24872 at_failed=false
   24873 echo stderr:; tee stderr <$at_stderr
   24874 $at_diff $at_devnull $at_stdout || at_failed=:
   24875 case $at_status in
   24876    77) echo 77 > $at_status_file
   24877             exit 77;;
   24878    1) ;;
   24879    *) echo "calc.at:565: exit code was $at_status, expected 1"
   24880       at_failed=:;;
   24881 esac
   24882 if $at_failed; then
   24883 
   24884   echo 1 > $at_status_file
   24885   exit 1
   24886 fi
   24887 
   24888 $at_traceon
   24889 
   24890 
   24891 # Normalize the observed and expected error messages, depending upon the
   24892 # options.
   24893 # 1. Remove the traces from observed.
   24894 sed '/^Starting/d
   24895 /^Entering/d
   24896 /^Stack/d
   24897 /^Reading/d
   24898 /^Reducing/d
   24899 /^Shifting/d
   24900 /^state/d
   24901 /^Cleanup:/d
   24902 /^Error:/d
   24903 /^Next/d
   24904 /^Discarding/d
   24905 / \$[0-9$]* = /d
   24906 /^yydestructor:/d' stderr >at-stderr
   24907 mv at-stderr stderr
   24908 # 2. Create the reference error message.
   24909 cat >expout <<'_ATEOF'
   24910 1.0: syntax error, unexpected $undefined
   24911 _ATEOF
   24912 
   24913 # 3. If locations are not used, remove them.
   24914 
   24915 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   24916 
   24917 # 5. Check
   24918 $at_traceoff
   24919 echo "calc.at:565: cat stderr"
   24920 echo calc.at:565 >$at_check_line_file
   24921 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   24922 at_status=$?
   24923 grep '^ *+' $at_stder1 >&2
   24924 grep -v '^ *+' $at_stder1 >$at_stderr
   24925 at_failed=false
   24926 $at_diff $at_devnull $at_stderr || at_failed=:
   24927 $at_diff expout $at_stdout || at_failed=:
   24928 case $at_status in
   24929    77) echo 77 > $at_status_file
   24930             exit 77;;
   24931    0) ;;
   24932    *) echo "calc.at:565: exit code was $at_status, expected 0"
   24933       at_failed=:;;
   24934 esac
   24935 if $at_failed; then
   24936 
   24937   echo 1 > $at_status_file
   24938   exit 1
   24939 fi
   24940 
   24941 $at_traceon
   24942 
   24943 
   24944 cat >input <<'_ATEOF'
   24945 1 = 2 = 3
   24946 _ATEOF
   24947 
   24948 $at_traceoff
   24949 echo "calc.at:565: \$PREPARSER ./calc input"
   24950 echo calc.at:565 >$at_check_line_file
   24951 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   24952 at_status=$?
   24953 grep '^ *+' $at_stder1 >&2
   24954 grep -v '^ *+' $at_stder1 >$at_stderr
   24955 at_failed=false
   24956 echo stderr:; tee stderr <$at_stderr
   24957 $at_diff $at_devnull $at_stdout || at_failed=:
   24958 case $at_status in
   24959    77) echo 77 > $at_status_file
   24960             exit 77;;
   24961    1) ;;
   24962    *) echo "calc.at:565: exit code was $at_status, expected 1"
   24963       at_failed=:;;
   24964 esac
   24965 if $at_failed; then
   24966 
   24967   echo 1 > $at_status_file
   24968   exit 1
   24969 fi
   24970 
   24971 $at_traceon
   24972 
   24973 
   24974 # Normalize the observed and expected error messages, depending upon the
   24975 # options.
   24976 # 1. Remove the traces from observed.
   24977 sed '/^Starting/d
   24978 /^Entering/d
   24979 /^Stack/d
   24980 /^Reading/d
   24981 /^Reducing/d
   24982 /^Shifting/d
   24983 /^state/d
   24984 /^Cleanup:/d
   24985 /^Error:/d
   24986 /^Next/d
   24987 /^Discarding/d
   24988 / \$[0-9$]* = /d
   24989 /^yydestructor:/d' stderr >at-stderr
   24990 mv at-stderr stderr
   24991 # 2. Create the reference error message.
   24992 cat >expout <<'_ATEOF'
   24993 1.6: syntax error, unexpected '='
   24994 _ATEOF
   24995 
   24996 # 3. If locations are not used, remove them.
   24997 
   24998 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   24999 
   25000 # 5. Check
   25001 $at_traceoff
   25002 echo "calc.at:565: cat stderr"
   25003 echo calc.at:565 >$at_check_line_file
   25004 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   25005 at_status=$?
   25006 grep '^ *+' $at_stder1 >&2
   25007 grep -v '^ *+' $at_stder1 >$at_stderr
   25008 at_failed=false
   25009 $at_diff $at_devnull $at_stderr || at_failed=:
   25010 $at_diff expout $at_stdout || at_failed=:
   25011 case $at_status in
   25012    77) echo 77 > $at_status_file
   25013             exit 77;;
   25014    0) ;;
   25015    *) echo "calc.at:565: exit code was $at_status, expected 0"
   25016       at_failed=:;;
   25017 esac
   25018 if $at_failed; then
   25019 
   25020   echo 1 > $at_status_file
   25021   exit 1
   25022 fi
   25023 
   25024 $at_traceon
   25025 
   25026 
   25027 cat >input <<'_ATEOF'
   25028 
   25029 +1
   25030 _ATEOF
   25031 
   25032 $at_traceoff
   25033 echo "calc.at:565: \$PREPARSER ./calc input"
   25034 echo calc.at:565 >$at_check_line_file
   25035 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   25036 at_status=$?
   25037 grep '^ *+' $at_stder1 >&2
   25038 grep -v '^ *+' $at_stder1 >$at_stderr
   25039 at_failed=false
   25040 echo stderr:; tee stderr <$at_stderr
   25041 $at_diff $at_devnull $at_stdout || at_failed=:
   25042 case $at_status in
   25043    77) echo 77 > $at_status_file
   25044             exit 77;;
   25045    1) ;;
   25046    *) echo "calc.at:565: exit code was $at_status, expected 1"
   25047       at_failed=:;;
   25048 esac
   25049 if $at_failed; then
   25050 
   25051   echo 1 > $at_status_file
   25052   exit 1
   25053 fi
   25054 
   25055 $at_traceon
   25056 
   25057 
   25058 # Normalize the observed and expected error messages, depending upon the
   25059 # options.
   25060 # 1. Remove the traces from observed.
   25061 sed '/^Starting/d
   25062 /^Entering/d
   25063 /^Stack/d
   25064 /^Reading/d
   25065 /^Reducing/d
   25066 /^Shifting/d
   25067 /^state/d
   25068 /^Cleanup:/d
   25069 /^Error:/d
   25070 /^Next/d
   25071 /^Discarding/d
   25072 / \$[0-9$]* = /d
   25073 /^yydestructor:/d' stderr >at-stderr
   25074 mv at-stderr stderr
   25075 # 2. Create the reference error message.
   25076 cat >expout <<'_ATEOF'
   25077 2.0: syntax error, unexpected '+'
   25078 _ATEOF
   25079 
   25080 # 3. If locations are not used, remove them.
   25081 
   25082 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   25083 
   25084 # 5. Check
   25085 $at_traceoff
   25086 echo "calc.at:565: cat stderr"
   25087 echo calc.at:565 >$at_check_line_file
   25088 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   25089 at_status=$?
   25090 grep '^ *+' $at_stder1 >&2
   25091 grep -v '^ *+' $at_stder1 >$at_stderr
   25092 at_failed=false
   25093 $at_diff $at_devnull $at_stderr || at_failed=:
   25094 $at_diff expout $at_stdout || at_failed=:
   25095 case $at_status in
   25096    77) echo 77 > $at_status_file
   25097             exit 77;;
   25098    0) ;;
   25099    *) echo "calc.at:565: exit code was $at_status, expected 0"
   25100       at_failed=:;;
   25101 esac
   25102 if $at_failed; then
   25103 
   25104   echo 1 > $at_status_file
   25105   exit 1
   25106 fi
   25107 
   25108 $at_traceon
   25109 
   25110 
   25111 # Exercise error messages with EOF: work on an empty file.
   25112 $at_traceoff
   25113 echo "calc.at:565: \$PREPARSER ./calc /dev/null"
   25114 echo calc.at:565 >$at_check_line_file
   25115 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   25116 at_status=$?
   25117 grep '^ *+' $at_stder1 >&2
   25118 grep -v '^ *+' $at_stder1 >$at_stderr
   25119 at_failed=false
   25120 echo stderr:; tee stderr <$at_stderr
   25121 $at_diff $at_devnull $at_stdout || at_failed=:
   25122 case $at_status in
   25123    77) echo 77 > $at_status_file
   25124             exit 77;;
   25125    1) ;;
   25126    *) echo "calc.at:565: exit code was $at_status, expected 1"
   25127       at_failed=:;;
   25128 esac
   25129 if $at_failed; then
   25130 
   25131   echo 1 > $at_status_file
   25132   exit 1
   25133 fi
   25134 
   25135 $at_traceon
   25136 
   25137 
   25138 # Normalize the observed and expected error messages, depending upon the
   25139 # options.
   25140 # 1. Remove the traces from observed.
   25141 sed '/^Starting/d
   25142 /^Entering/d
   25143 /^Stack/d
   25144 /^Reading/d
   25145 /^Reducing/d
   25146 /^Shifting/d
   25147 /^state/d
   25148 /^Cleanup:/d
   25149 /^Error:/d
   25150 /^Next/d
   25151 /^Discarding/d
   25152 / \$[0-9$]* = /d
   25153 /^yydestructor:/d' stderr >at-stderr
   25154 mv at-stderr stderr
   25155 # 2. Create the reference error message.
   25156 cat >expout <<'_ATEOF'
   25157 1.0: syntax error, unexpected end of input
   25158 _ATEOF
   25159 
   25160 # 3. If locations are not used, remove them.
   25161 
   25162 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   25163 
   25164 # 5. Check
   25165 $at_traceoff
   25166 echo "calc.at:565: cat stderr"
   25167 echo calc.at:565 >$at_check_line_file
   25168 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   25169 at_status=$?
   25170 grep '^ *+' $at_stder1 >&2
   25171 grep -v '^ *+' $at_stder1 >$at_stderr
   25172 at_failed=false
   25173 $at_diff $at_devnull $at_stderr || at_failed=:
   25174 $at_diff expout $at_stdout || at_failed=:
   25175 case $at_status in
   25176    77) echo 77 > $at_status_file
   25177             exit 77;;
   25178    0) ;;
   25179    *) echo "calc.at:565: exit code was $at_status, expected 0"
   25180       at_failed=:;;
   25181 esac
   25182 if $at_failed; then
   25183 
   25184   echo 1 > $at_status_file
   25185   exit 1
   25186 fi
   25187 
   25188 $at_traceon
   25189 
   25190 
   25191 
   25192 # Exercise the error token: without it, we die at the first error,
   25193 # hence be sure to
   25194 #
   25195 # - have several errors which exercise different shift/discardings
   25196 #   - (): nothing to pop, nothing to discard
   25197 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   25198 #   - (* * *): nothing to pop, a lot to discard
   25199 #   - (1 + 2 * *): some to pop and discard
   25200 #
   25201 # - test the action associated to `error'
   25202 #
   25203 # - check the look-ahead that triggers an error is not discarded
   25204 #   when we enter error recovery.  Below, the look-ahead causing the
   25205 #   first error is ")", which is needed to recover from the error and
   25206 #   produce the "0" that triggers the "0 != 1" error.
   25207 #
   25208 cat >input <<'_ATEOF'
   25209 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   25210 _ATEOF
   25211 
   25212 $at_traceoff
   25213 echo "calc.at:565: \$PREPARSER ./calc input"
   25214 echo calc.at:565 >$at_check_line_file
   25215 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   25216 at_status=$?
   25217 grep '^ *+' $at_stder1 >&2
   25218 grep -v '^ *+' $at_stder1 >$at_stderr
   25219 at_failed=false
   25220 echo stderr:; tee stderr <$at_stderr
   25221 $at_diff $at_devnull $at_stdout || at_failed=:
   25222 case $at_status in
   25223    77) echo 77 > $at_status_file
   25224             exit 77;;
   25225    0) ;;
   25226    *) echo "calc.at:565: exit code was $at_status, expected 0"
   25227       at_failed=:;;
   25228 esac
   25229 if $at_failed; then
   25230 
   25231   echo 1 > $at_status_file
   25232   exit 1
   25233 fi
   25234 
   25235 $at_traceon
   25236 
   25237 
   25238 # Normalize the observed and expected error messages, depending upon the
   25239 # options.
   25240 # 1. Remove the traces from observed.
   25241 sed '/^Starting/d
   25242 /^Entering/d
   25243 /^Stack/d
   25244 /^Reading/d
   25245 /^Reducing/d
   25246 /^Shifting/d
   25247 /^state/d
   25248 /^Cleanup:/d
   25249 /^Error:/d
   25250 /^Next/d
   25251 /^Discarding/d
   25252 / \$[0-9$]* = /d
   25253 /^yydestructor:/d' stderr >at-stderr
   25254 mv at-stderr stderr
   25255 # 2. Create the reference error message.
   25256 cat >expout <<'_ATEOF'
   25257 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   25258 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   25259 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   25260 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   25261 calc: error: 4444 != 1
   25262 _ATEOF
   25263 
   25264 # 3. If locations are not used, remove them.
   25265 
   25266 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   25267 
   25268 # 5. Check
   25269 $at_traceoff
   25270 echo "calc.at:565: cat stderr"
   25271 echo calc.at:565 >$at_check_line_file
   25272 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   25273 at_status=$?
   25274 grep '^ *+' $at_stder1 >&2
   25275 grep -v '^ *+' $at_stder1 >$at_stderr
   25276 at_failed=false
   25277 $at_diff $at_devnull $at_stderr || at_failed=:
   25278 $at_diff expout $at_stdout || at_failed=:
   25279 case $at_status in
   25280    77) echo 77 > $at_status_file
   25281             exit 77;;
   25282    0) ;;
   25283    *) echo "calc.at:565: exit code was $at_status, expected 0"
   25284       at_failed=:;;
   25285 esac
   25286 if $at_failed; then
   25287 
   25288   echo 1 > $at_status_file
   25289   exit 1
   25290 fi
   25291 
   25292 $at_traceon
   25293 
   25294 
   25295 
   25296 # The same, but this time exercising explicitly triggered syntax errors.
   25297 # POSIX says the look-ahead causing the error should not be discarded.
   25298 cat >input <<'_ATEOF'
   25299 (!) + (0 0) = 1
   25300 _ATEOF
   25301 
   25302 $at_traceoff
   25303 echo "calc.at:565: \$PREPARSER ./calc input"
   25304 echo calc.at:565 >$at_check_line_file
   25305 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   25306 at_status=$?
   25307 grep '^ *+' $at_stder1 >&2
   25308 grep -v '^ *+' $at_stder1 >$at_stderr
   25309 at_failed=false
   25310 echo stderr:; tee stderr <$at_stderr
   25311 $at_diff $at_devnull $at_stdout || at_failed=:
   25312 case $at_status in
   25313    77) echo 77 > $at_status_file
   25314             exit 77;;
   25315    0) ;;
   25316    *) echo "calc.at:565: exit code was $at_status, expected 0"
   25317       at_failed=:;;
   25318 esac
   25319 if $at_failed; then
   25320 
   25321   echo 1 > $at_status_file
   25322   exit 1
   25323 fi
   25324 
   25325 $at_traceon
   25326 
   25327 
   25328 # Normalize the observed and expected error messages, depending upon the
   25329 # options.
   25330 # 1. Remove the traces from observed.
   25331 sed '/^Starting/d
   25332 /^Entering/d
   25333 /^Stack/d
   25334 /^Reading/d
   25335 /^Reducing/d
   25336 /^Shifting/d
   25337 /^state/d
   25338 /^Cleanup:/d
   25339 /^Error:/d
   25340 /^Next/d
   25341 /^Discarding/d
   25342 / \$[0-9$]* = /d
   25343 /^yydestructor:/d' stderr >at-stderr
   25344 mv at-stderr stderr
   25345 # 2. Create the reference error message.
   25346 cat >expout <<'_ATEOF'
   25347 1.9: syntax error, unexpected number
   25348 calc: error: 2222 != 1
   25349 _ATEOF
   25350 
   25351 # 3. If locations are not used, remove them.
   25352 
   25353 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   25354 
   25355 # 5. Check
   25356 $at_traceoff
   25357 echo "calc.at:565: cat stderr"
   25358 echo calc.at:565 >$at_check_line_file
   25359 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   25360 at_status=$?
   25361 grep '^ *+' $at_stder1 >&2
   25362 grep -v '^ *+' $at_stder1 >$at_stderr
   25363 at_failed=false
   25364 $at_diff $at_devnull $at_stderr || at_failed=:
   25365 $at_diff expout $at_stdout || at_failed=:
   25366 case $at_status in
   25367    77) echo 77 > $at_status_file
   25368             exit 77;;
   25369    0) ;;
   25370    *) echo "calc.at:565: exit code was $at_status, expected 0"
   25371       at_failed=:;;
   25372 esac
   25373 if $at_failed; then
   25374 
   25375   echo 1 > $at_status_file
   25376   exit 1
   25377 fi
   25378 
   25379 $at_traceon
   25380 
   25381 
   25382 cat >input <<'_ATEOF'
   25383 (- *) + (0 0) = 1
   25384 _ATEOF
   25385 
   25386 $at_traceoff
   25387 echo "calc.at:565: \$PREPARSER ./calc input"
   25388 echo calc.at:565 >$at_check_line_file
   25389 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   25390 at_status=$?
   25391 grep '^ *+' $at_stder1 >&2
   25392 grep -v '^ *+' $at_stder1 >$at_stderr
   25393 at_failed=false
   25394 echo stderr:; tee stderr <$at_stderr
   25395 $at_diff $at_devnull $at_stdout || at_failed=:
   25396 case $at_status in
   25397    77) echo 77 > $at_status_file
   25398             exit 77;;
   25399    0) ;;
   25400    *) echo "calc.at:565: exit code was $at_status, expected 0"
   25401       at_failed=:;;
   25402 esac
   25403 if $at_failed; then
   25404 
   25405   echo 1 > $at_status_file
   25406   exit 1
   25407 fi
   25408 
   25409 $at_traceon
   25410 
   25411 
   25412 # Normalize the observed and expected error messages, depending upon the
   25413 # options.
   25414 # 1. Remove the traces from observed.
   25415 sed '/^Starting/d
   25416 /^Entering/d
   25417 /^Stack/d
   25418 /^Reading/d
   25419 /^Reducing/d
   25420 /^Shifting/d
   25421 /^state/d
   25422 /^Cleanup:/d
   25423 /^Error:/d
   25424 /^Next/d
   25425 /^Discarding/d
   25426 / \$[0-9$]* = /d
   25427 /^yydestructor:/d' stderr >at-stderr
   25428 mv at-stderr stderr
   25429 # 2. Create the reference error message.
   25430 cat >expout <<'_ATEOF'
   25431 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   25432 1.11: syntax error, unexpected number
   25433 calc: error: 2222 != 1
   25434 _ATEOF
   25435 
   25436 # 3. If locations are not used, remove them.
   25437 
   25438 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   25439 
   25440 # 5. Check
   25441 $at_traceoff
   25442 echo "calc.at:565: cat stderr"
   25443 echo calc.at:565 >$at_check_line_file
   25444 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   25445 at_status=$?
   25446 grep '^ *+' $at_stder1 >&2
   25447 grep -v '^ *+' $at_stder1 >$at_stderr
   25448 at_failed=false
   25449 $at_diff $at_devnull $at_stderr || at_failed=:
   25450 $at_diff expout $at_stdout || at_failed=:
   25451 case $at_status in
   25452    77) echo 77 > $at_status_file
   25453             exit 77;;
   25454    0) ;;
   25455    *) echo "calc.at:565: exit code was $at_status, expected 0"
   25456       at_failed=:;;
   25457 esac
   25458 if $at_failed; then
   25459 
   25460   echo 1 > $at_status_file
   25461   exit 1
   25462 fi
   25463 
   25464 $at_traceon
   25465 
   25466 
   25467 
   25468 
   25469 
   25470 
   25471 
   25472 
   25473 
   25474 
   25475 
   25476 
   25477 
   25478 
   25479 
   25480 
   25481 
   25482 
   25483 
   25484 
   25485 
   25486 
   25487 
   25488 
   25489       $at_traceoff
   25490       $at_times_p && times >$at_times_file
   25491     ) 5>&1 2>&1 | eval $at_tee_pipe
   25492     at_status=`cat $at_status_file`
   25493     ;;
   25494 
   25495   82 ) # 82. calc.at:567: Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
   25496     at_setup_line='calc.at:567'
   25497     at_desc='Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc'
   25498     $at_quiet $ECHO_N " 82: Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc$ECHO_C"
   25499     at_xfail=no
   25500     (
   25501       echo "82. calc.at:567: testing ..."
   25502       $at_traceon
   25503 
   25504 
   25505 
   25506 
   25507 
   25508 
   25509 
   25510 
   25511 # Using yacc.c?
   25512 
   25513 
   25514 
   25515 
   25516 
   25517 
   25518 
   25519 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   25520 
   25521 # yyerror always sees the locations (when activated), except if
   25522 # yacc & pure & !param.
   25523 
   25524 
   25525 # The interface is pure: either because %pure-parser, or because we
   25526 # are using the C++ parsers.
   25527 
   25528 
   25529 
   25530 
   25531 
   25532 
   25533 
   25534 
   25535 
   25536 
   25537 
   25538 
   25539 cat >calc.y <<'_ATEOF'
   25540 %{
   25541 #ifdef HAVE_CONFIG_H
   25542 # include <config.h>
   25543   /* We don't need perfect functions for these tests. */
   25544 # undef malloc
   25545 # undef memcmp
   25546 # undef realloc
   25547 #endif
   25548 %}
   25549 
   25550 /* Infix notation calculator--calc */
   25551 %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
   25552 
   25553 %{
   25554 #include <stdio.h>
   25555 
   25556 #include <stdlib.h>
   25557 #include <string.h>
   25558 #if HAVE_UNISTD_H
   25559 # include <unistd.h>
   25560 #else
   25561 # undef alarm
   25562 # define alarm(seconds) /* empty */
   25563 #endif
   25564 #include <ctype.h>
   25565 #define USE(Var)
   25566 
   25567 /* Exercise pre-prologue dependency to %union.  */
   25568 typedef int semantic_value;
   25569 
   25570 static semantic_value global_result = 0;
   25571 static int global_count = 0;
   25572 %}
   25573 
   25574 /* Exercise %union. */
   25575 %union
   25576 {
   25577   semantic_value ival;
   25578 };
   25579 
   25580 %{
   25581 static int power (int base, int exponent);
   25582 /* yyerror receives the location if:
   25583    - %location & %pure & %glr
   25584    - %location & %pure & %yacc & %parse-param. */
   25585 static void yyerror (
   25586 
   25587                      const char *s
   25588                      );
   25589 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   25590 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   25591 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   25592 %}
   25593 
   25594 
   25595 
   25596 /* Bison Declarations */
   25597 %token CALC_EOF 0 "end of input"
   25598 %token <ival> NUM "number"
   25599 %type  <ival> exp
   25600 
   25601 %nonassoc '=' /* comparison	       */
   25602 %left '-' '+'
   25603 %left '*' '/'
   25604 %left NEG     /* negation--unary minus */
   25605 %right '^'    /* exponentiation        */
   25606 
   25607 /* Grammar follows */
   25608 %%
   25609 input:
   25610   line
   25611 | input line         {  }
   25612 ;
   25613 
   25614 line:
   25615   '\n'
   25616 | exp '\n'           { USE ($1); }
   25617 ;
   25618 
   25619 exp:
   25620   NUM                { $$ = $1;             }
   25621 | exp '=' exp
   25622   {
   25623     if ($1 != $3)
   25624       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   25625     $$ = $1;
   25626   }
   25627 | exp '+' exp        { $$ = $1 + $3;        }
   25628 | exp '-' exp        { $$ = $1 - $3;        }
   25629 | exp '*' exp        { $$ = $1 * $3;        }
   25630 | exp '/' exp        { $$ = $1 / $3;        }
   25631 | '-' exp  %prec NEG { $$ = -$2;            }
   25632 | exp '^' exp        { $$ = power ($1, $3); }
   25633 | '(' exp ')'        { $$ = $2;             }
   25634 | '(' error ')'      { $$ = 1111;           }
   25635 | '!'                { $$ = 0; YYERROR;     }
   25636 | '-' error          { $$ = 0; YYERROR;     }
   25637 ;
   25638 %%
   25639 /* The input.  */
   25640 static FILE *input;
   25641 
   25642 static void
   25643 yyerror (
   25644 
   25645          const char *s)
   25646 {
   25647 
   25648 
   25649   fprintf (stderr, "%s\n", s);
   25650 }
   25651 
   25652 
   25653 
   25654 static YYLTYPE last_yylloc;
   25655 
   25656 static int
   25657 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   25658 {
   25659   int res = getc (input);
   25660   (void) lvalp;(void) llocp;
   25661 
   25662   last_yylloc = (*llocp);
   25663   if (res == '\n')
   25664     {
   25665       (*llocp).last_line++;
   25666       (*llocp).last_column = 0;
   25667     }
   25668   else
   25669     (*llocp).last_column++;
   25670 
   25671   return res;
   25672 }
   25673 
   25674 
   25675 static void
   25676 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   25677 {
   25678   (void) lvalp;(void) llocp;
   25679 
   25680   /* Wrong when C == `\n'. */
   25681   (*llocp) = last_yylloc;
   25682 
   25683   ungetc (c, input);
   25684 }
   25685 
   25686 static int
   25687 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   25688 {
   25689   int c = get_char (lvalp, llocp);
   25690   int sign = 1;
   25691   int n = 0;
   25692 
   25693   (void) lvalp;(void) llocp;
   25694   if (c == '-')
   25695     {
   25696       c = get_char (lvalp, llocp);
   25697       sign = -1;
   25698     }
   25699 
   25700   while (isdigit (c))
   25701     {
   25702       n = 10 * n + (c - '0');
   25703       c = get_char (lvalp, llocp);
   25704     }
   25705 
   25706   unget_char (lvalp, llocp,  c);
   25707 
   25708   return sign * n;
   25709 }
   25710 
   25711 
   25712 
   25713 /*---------------------------------------------------------------.
   25714 | Lexical analyzer returns an integer on the stack and the token |
   25715 | NUM, or the ASCII character read if not a number.  Skips all   |
   25716 | blanks and tabs, returns 0 for EOF.                            |
   25717 `---------------------------------------------------------------*/
   25718 
   25719 static int
   25720 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   25721 {
   25722   static int init = 1;
   25723   int c;
   25724 
   25725   if (init)
   25726     {
   25727       init = 0;
   25728 
   25729       (*llocp).last_column = 0;
   25730       (*llocp).last_line = 1;
   25731 
   25732     }
   25733 
   25734 
   25735  (*llocp).first_column = (*llocp).last_column;
   25736   (*llocp).first_line   = (*llocp).last_line;
   25737 
   25738 
   25739   /* Skip white space.  */
   25740   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   25741     {
   25742      (*llocp).first_column = (*llocp).last_column;
   25743       (*llocp).first_line   = (*llocp).last_line;
   25744 
   25745     }
   25746 
   25747   /* process numbers   */
   25748   if (c == '.' || isdigit (c))
   25749     {
   25750       unget_char (lvalp, llocp,  c);
   25751       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   25752       return NUM;
   25753     }
   25754 
   25755   /* Return end-of-file.  */
   25756   if (c == EOF)
   25757     return CALC_EOF;
   25758 
   25759   /* Return single chars. */
   25760   return c;
   25761 }
   25762 
   25763 static int
   25764 power (int base, int exponent)
   25765 {
   25766   int res = 1;
   25767   if (exponent < 0)
   25768     exit (3);
   25769   for (/* Niente */; exponent; --exponent)
   25770     res *= base;
   25771   return res;
   25772 }
   25773 
   25774 
   25775 int
   25776 main (int argc, const char **argv)
   25777 {
   25778   semantic_value result = 0;
   25779   int count = 0;
   25780   int status;
   25781 
   25782   /* This used to be alarm (10), but that isn't enough time for
   25783      a July 1995 vintage DEC Alphastation 200 4/100 system,
   25784      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   25785   alarm (100);
   25786 
   25787   if (argc == 2)
   25788     input = fopen (argv[1], "r");
   25789   else
   25790     input = stdin;
   25791 
   25792   if (!input)
   25793     {
   25794       perror (argv[1]);
   25795       return 3;
   25796     }
   25797 
   25798   yydebug = 1;
   25799   status = yyparse ();
   25800   if (global_result != result)
   25801     abort ();
   25802   if (global_count != count)
   25803     abort ();
   25804   return status;
   25805 }
   25806 _ATEOF
   25807 
   25808 
   25809 
   25810 
   25811 
   25812 $at_traceoff
   25813 echo "calc.at:567: bison -o calc.c calc.y"
   25814 echo calc.at:567 >$at_check_line_file
   25815 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   25816 at_status=$?
   25817 grep '^ *+' $at_stder1 >&2
   25818 grep -v '^ *+' $at_stder1 >$at_stderr
   25819 at_failed=false
   25820 $at_diff $at_devnull $at_stderr || at_failed=:
   25821 $at_diff $at_devnull $at_stdout || at_failed=:
   25822 case $at_status in
   25823    77) echo 77 > $at_status_file
   25824             exit 77;;
   25825    0) ;;
   25826    *) echo "calc.at:567: exit code was $at_status, expected 0"
   25827       at_failed=:;;
   25828 esac
   25829 if $at_failed; then
   25830 
   25831   echo 1 > $at_status_file
   25832   exit 1
   25833 fi
   25834 
   25835 $at_traceon
   25836 
   25837    $at_traceoff
   25838 echo "calc.at:567: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   25839 echo calc.at:567 >$at_check_line_file
   25840 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   25841 at_status=$?
   25842 grep '^ *+' $at_stder1 >&2
   25843 grep -v '^ *+' $at_stder1 >$at_stderr
   25844 at_failed=false
   25845 echo stderr:; cat $at_stderr
   25846 echo stdout:; cat $at_stdout
   25847 case $at_status in
   25848    77) echo 77 > $at_status_file
   25849             exit 77;;
   25850    0) ;;
   25851    *) echo "calc.at:567: exit code was $at_status, expected 0"
   25852       at_failed=:;;
   25853 esac
   25854 if $at_failed; then
   25855 
   25856   echo 1 > $at_status_file
   25857   exit 1
   25858 fi
   25859 
   25860 $at_traceon
   25861 
   25862 
   25863 # Test the priorities.
   25864 cat >input <<'_ATEOF'
   25865 1 + 2 * 3 = 7
   25866 1 + 2 * -3 = -5
   25867 
   25868 -1^2 = -1
   25869 (-1)^2 = 1
   25870 
   25871 ---1 = -1
   25872 
   25873 1 - 2 - 3 = -4
   25874 1 - (2 - 3) = 2
   25875 
   25876 2^2^3 = 256
   25877 (2^2)^3 = 64
   25878 _ATEOF
   25879 
   25880 $at_traceoff
   25881 echo "calc.at:567: \$PREPARSER ./calc input"
   25882 echo calc.at:567 >$at_check_line_file
   25883 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   25884 at_status=$?
   25885 grep '^ *+' $at_stder1 >&2
   25886 grep -v '^ *+' $at_stder1 >$at_stderr
   25887 at_failed=false
   25888 echo stderr:; tee stderr <$at_stderr
   25889 $at_diff $at_devnull $at_stdout || at_failed=:
   25890 case $at_status in
   25891    77) echo 77 > $at_status_file
   25892             exit 77;;
   25893    0) ;;
   25894    *) echo "calc.at:567: exit code was $at_status, expected 0"
   25895       at_failed=:;;
   25896 esac
   25897 if $at_failed; then
   25898 
   25899   echo 1 > $at_status_file
   25900   exit 1
   25901 fi
   25902 
   25903 $at_traceon
   25904 
   25905 
   25906 
   25907 # Some syntax errors.
   25908 cat >input <<'_ATEOF'
   25909 0 0
   25910 _ATEOF
   25911 
   25912 $at_traceoff
   25913 echo "calc.at:567: \$PREPARSER ./calc input"
   25914 echo calc.at:567 >$at_check_line_file
   25915 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   25916 at_status=$?
   25917 grep '^ *+' $at_stder1 >&2
   25918 grep -v '^ *+' $at_stder1 >$at_stderr
   25919 at_failed=false
   25920 echo stderr:; tee stderr <$at_stderr
   25921 $at_diff $at_devnull $at_stdout || at_failed=:
   25922 case $at_status in
   25923    77) echo 77 > $at_status_file
   25924             exit 77;;
   25925    1) ;;
   25926    *) echo "calc.at:567: exit code was $at_status, expected 1"
   25927       at_failed=:;;
   25928 esac
   25929 if $at_failed; then
   25930 
   25931   echo 1 > $at_status_file
   25932   exit 1
   25933 fi
   25934 
   25935 $at_traceon
   25936 
   25937 
   25938 # Normalize the observed and expected error messages, depending upon the
   25939 # options.
   25940 # 1. Remove the traces from observed.
   25941 sed '/^Starting/d
   25942 /^Entering/d
   25943 /^Stack/d
   25944 /^Reading/d
   25945 /^Reducing/d
   25946 /^Shifting/d
   25947 /^state/d
   25948 /^Cleanup:/d
   25949 /^Error:/d
   25950 /^Next/d
   25951 /^Discarding/d
   25952 / \$[0-9$]* = /d
   25953 /^yydestructor:/d' stderr >at-stderr
   25954 mv at-stderr stderr
   25955 # 2. Create the reference error message.
   25956 cat >expout <<'_ATEOF'
   25957 1.2: syntax error, unexpected number
   25958 _ATEOF
   25959 
   25960 # 3. If locations are not used, remove them.
   25961 sed 's/^[-0-9.]*: //' expout >at-expout
   25962 mv at-expout expout
   25963 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   25964 
   25965 # 5. Check
   25966 $at_traceoff
   25967 echo "calc.at:567: cat stderr"
   25968 echo calc.at:567 >$at_check_line_file
   25969 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   25970 at_status=$?
   25971 grep '^ *+' $at_stder1 >&2
   25972 grep -v '^ *+' $at_stder1 >$at_stderr
   25973 at_failed=false
   25974 $at_diff $at_devnull $at_stderr || at_failed=:
   25975 $at_diff expout $at_stdout || at_failed=:
   25976 case $at_status in
   25977    77) echo 77 > $at_status_file
   25978             exit 77;;
   25979    0) ;;
   25980    *) echo "calc.at:567: exit code was $at_status, expected 0"
   25981       at_failed=:;;
   25982 esac
   25983 if $at_failed; then
   25984 
   25985   echo 1 > $at_status_file
   25986   exit 1
   25987 fi
   25988 
   25989 $at_traceon
   25990 
   25991 
   25992 cat >input <<'_ATEOF'
   25993 1//2
   25994 _ATEOF
   25995 
   25996 $at_traceoff
   25997 echo "calc.at:567: \$PREPARSER ./calc input"
   25998 echo calc.at:567 >$at_check_line_file
   25999 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   26000 at_status=$?
   26001 grep '^ *+' $at_stder1 >&2
   26002 grep -v '^ *+' $at_stder1 >$at_stderr
   26003 at_failed=false
   26004 echo stderr:; tee stderr <$at_stderr
   26005 $at_diff $at_devnull $at_stdout || at_failed=:
   26006 case $at_status in
   26007    77) echo 77 > $at_status_file
   26008             exit 77;;
   26009    1) ;;
   26010    *) echo "calc.at:567: exit code was $at_status, expected 1"
   26011       at_failed=:;;
   26012 esac
   26013 if $at_failed; then
   26014 
   26015   echo 1 > $at_status_file
   26016   exit 1
   26017 fi
   26018 
   26019 $at_traceon
   26020 
   26021 
   26022 # Normalize the observed and expected error messages, depending upon the
   26023 # options.
   26024 # 1. Remove the traces from observed.
   26025 sed '/^Starting/d
   26026 /^Entering/d
   26027 /^Stack/d
   26028 /^Reading/d
   26029 /^Reducing/d
   26030 /^Shifting/d
   26031 /^state/d
   26032 /^Cleanup:/d
   26033 /^Error:/d
   26034 /^Next/d
   26035 /^Discarding/d
   26036 / \$[0-9$]* = /d
   26037 /^yydestructor:/d' stderr >at-stderr
   26038 mv at-stderr stderr
   26039 # 2. Create the reference error message.
   26040 cat >expout <<'_ATEOF'
   26041 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   26042 _ATEOF
   26043 
   26044 # 3. If locations are not used, remove them.
   26045 sed 's/^[-0-9.]*: //' expout >at-expout
   26046 mv at-expout expout
   26047 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   26048 
   26049 # 5. Check
   26050 $at_traceoff
   26051 echo "calc.at:567: cat stderr"
   26052 echo calc.at:567 >$at_check_line_file
   26053 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   26054 at_status=$?
   26055 grep '^ *+' $at_stder1 >&2
   26056 grep -v '^ *+' $at_stder1 >$at_stderr
   26057 at_failed=false
   26058 $at_diff $at_devnull $at_stderr || at_failed=:
   26059 $at_diff expout $at_stdout || at_failed=:
   26060 case $at_status in
   26061    77) echo 77 > $at_status_file
   26062             exit 77;;
   26063    0) ;;
   26064    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26065       at_failed=:;;
   26066 esac
   26067 if $at_failed; then
   26068 
   26069   echo 1 > $at_status_file
   26070   exit 1
   26071 fi
   26072 
   26073 $at_traceon
   26074 
   26075 
   26076 cat >input <<'_ATEOF'
   26077 error
   26078 _ATEOF
   26079 
   26080 $at_traceoff
   26081 echo "calc.at:567: \$PREPARSER ./calc input"
   26082 echo calc.at:567 >$at_check_line_file
   26083 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   26084 at_status=$?
   26085 grep '^ *+' $at_stder1 >&2
   26086 grep -v '^ *+' $at_stder1 >$at_stderr
   26087 at_failed=false
   26088 echo stderr:; tee stderr <$at_stderr
   26089 $at_diff $at_devnull $at_stdout || at_failed=:
   26090 case $at_status in
   26091    77) echo 77 > $at_status_file
   26092             exit 77;;
   26093    1) ;;
   26094    *) echo "calc.at:567: exit code was $at_status, expected 1"
   26095       at_failed=:;;
   26096 esac
   26097 if $at_failed; then
   26098 
   26099   echo 1 > $at_status_file
   26100   exit 1
   26101 fi
   26102 
   26103 $at_traceon
   26104 
   26105 
   26106 # Normalize the observed and expected error messages, depending upon the
   26107 # options.
   26108 # 1. Remove the traces from observed.
   26109 sed '/^Starting/d
   26110 /^Entering/d
   26111 /^Stack/d
   26112 /^Reading/d
   26113 /^Reducing/d
   26114 /^Shifting/d
   26115 /^state/d
   26116 /^Cleanup:/d
   26117 /^Error:/d
   26118 /^Next/d
   26119 /^Discarding/d
   26120 / \$[0-9$]* = /d
   26121 /^yydestructor:/d' stderr >at-stderr
   26122 mv at-stderr stderr
   26123 # 2. Create the reference error message.
   26124 cat >expout <<'_ATEOF'
   26125 1.0: syntax error, unexpected $undefined
   26126 _ATEOF
   26127 
   26128 # 3. If locations are not used, remove them.
   26129 sed 's/^[-0-9.]*: //' expout >at-expout
   26130 mv at-expout expout
   26131 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   26132 
   26133 # 5. Check
   26134 $at_traceoff
   26135 echo "calc.at:567: cat stderr"
   26136 echo calc.at:567 >$at_check_line_file
   26137 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   26138 at_status=$?
   26139 grep '^ *+' $at_stder1 >&2
   26140 grep -v '^ *+' $at_stder1 >$at_stderr
   26141 at_failed=false
   26142 $at_diff $at_devnull $at_stderr || at_failed=:
   26143 $at_diff expout $at_stdout || at_failed=:
   26144 case $at_status in
   26145    77) echo 77 > $at_status_file
   26146             exit 77;;
   26147    0) ;;
   26148    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26149       at_failed=:;;
   26150 esac
   26151 if $at_failed; then
   26152 
   26153   echo 1 > $at_status_file
   26154   exit 1
   26155 fi
   26156 
   26157 $at_traceon
   26158 
   26159 
   26160 cat >input <<'_ATEOF'
   26161 1 = 2 = 3
   26162 _ATEOF
   26163 
   26164 $at_traceoff
   26165 echo "calc.at:567: \$PREPARSER ./calc input"
   26166 echo calc.at:567 >$at_check_line_file
   26167 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   26168 at_status=$?
   26169 grep '^ *+' $at_stder1 >&2
   26170 grep -v '^ *+' $at_stder1 >$at_stderr
   26171 at_failed=false
   26172 echo stderr:; tee stderr <$at_stderr
   26173 $at_diff $at_devnull $at_stdout || at_failed=:
   26174 case $at_status in
   26175    77) echo 77 > $at_status_file
   26176             exit 77;;
   26177    1) ;;
   26178    *) echo "calc.at:567: exit code was $at_status, expected 1"
   26179       at_failed=:;;
   26180 esac
   26181 if $at_failed; then
   26182 
   26183   echo 1 > $at_status_file
   26184   exit 1
   26185 fi
   26186 
   26187 $at_traceon
   26188 
   26189 
   26190 # Normalize the observed and expected error messages, depending upon the
   26191 # options.
   26192 # 1. Remove the traces from observed.
   26193 sed '/^Starting/d
   26194 /^Entering/d
   26195 /^Stack/d
   26196 /^Reading/d
   26197 /^Reducing/d
   26198 /^Shifting/d
   26199 /^state/d
   26200 /^Cleanup:/d
   26201 /^Error:/d
   26202 /^Next/d
   26203 /^Discarding/d
   26204 / \$[0-9$]* = /d
   26205 /^yydestructor:/d' stderr >at-stderr
   26206 mv at-stderr stderr
   26207 # 2. Create the reference error message.
   26208 cat >expout <<'_ATEOF'
   26209 1.6: syntax error, unexpected '='
   26210 _ATEOF
   26211 
   26212 # 3. If locations are not used, remove them.
   26213 sed 's/^[-0-9.]*: //' expout >at-expout
   26214 mv at-expout expout
   26215 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   26216 
   26217 # 5. Check
   26218 $at_traceoff
   26219 echo "calc.at:567: cat stderr"
   26220 echo calc.at:567 >$at_check_line_file
   26221 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   26222 at_status=$?
   26223 grep '^ *+' $at_stder1 >&2
   26224 grep -v '^ *+' $at_stder1 >$at_stderr
   26225 at_failed=false
   26226 $at_diff $at_devnull $at_stderr || at_failed=:
   26227 $at_diff expout $at_stdout || at_failed=:
   26228 case $at_status in
   26229    77) echo 77 > $at_status_file
   26230             exit 77;;
   26231    0) ;;
   26232    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26233       at_failed=:;;
   26234 esac
   26235 if $at_failed; then
   26236 
   26237   echo 1 > $at_status_file
   26238   exit 1
   26239 fi
   26240 
   26241 $at_traceon
   26242 
   26243 
   26244 cat >input <<'_ATEOF'
   26245 
   26246 +1
   26247 _ATEOF
   26248 
   26249 $at_traceoff
   26250 echo "calc.at:567: \$PREPARSER ./calc input"
   26251 echo calc.at:567 >$at_check_line_file
   26252 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   26253 at_status=$?
   26254 grep '^ *+' $at_stder1 >&2
   26255 grep -v '^ *+' $at_stder1 >$at_stderr
   26256 at_failed=false
   26257 echo stderr:; tee stderr <$at_stderr
   26258 $at_diff $at_devnull $at_stdout || at_failed=:
   26259 case $at_status in
   26260    77) echo 77 > $at_status_file
   26261             exit 77;;
   26262    1) ;;
   26263    *) echo "calc.at:567: exit code was $at_status, expected 1"
   26264       at_failed=:;;
   26265 esac
   26266 if $at_failed; then
   26267 
   26268   echo 1 > $at_status_file
   26269   exit 1
   26270 fi
   26271 
   26272 $at_traceon
   26273 
   26274 
   26275 # Normalize the observed and expected error messages, depending upon the
   26276 # options.
   26277 # 1. Remove the traces from observed.
   26278 sed '/^Starting/d
   26279 /^Entering/d
   26280 /^Stack/d
   26281 /^Reading/d
   26282 /^Reducing/d
   26283 /^Shifting/d
   26284 /^state/d
   26285 /^Cleanup:/d
   26286 /^Error:/d
   26287 /^Next/d
   26288 /^Discarding/d
   26289 / \$[0-9$]* = /d
   26290 /^yydestructor:/d' stderr >at-stderr
   26291 mv at-stderr stderr
   26292 # 2. Create the reference error message.
   26293 cat >expout <<'_ATEOF'
   26294 2.0: syntax error, unexpected '+'
   26295 _ATEOF
   26296 
   26297 # 3. If locations are not used, remove them.
   26298 sed 's/^[-0-9.]*: //' expout >at-expout
   26299 mv at-expout expout
   26300 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   26301 
   26302 # 5. Check
   26303 $at_traceoff
   26304 echo "calc.at:567: cat stderr"
   26305 echo calc.at:567 >$at_check_line_file
   26306 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   26307 at_status=$?
   26308 grep '^ *+' $at_stder1 >&2
   26309 grep -v '^ *+' $at_stder1 >$at_stderr
   26310 at_failed=false
   26311 $at_diff $at_devnull $at_stderr || at_failed=:
   26312 $at_diff expout $at_stdout || at_failed=:
   26313 case $at_status in
   26314    77) echo 77 > $at_status_file
   26315             exit 77;;
   26316    0) ;;
   26317    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26318       at_failed=:;;
   26319 esac
   26320 if $at_failed; then
   26321 
   26322   echo 1 > $at_status_file
   26323   exit 1
   26324 fi
   26325 
   26326 $at_traceon
   26327 
   26328 
   26329 # Exercise error messages with EOF: work on an empty file.
   26330 $at_traceoff
   26331 echo "calc.at:567: \$PREPARSER ./calc /dev/null"
   26332 echo calc.at:567 >$at_check_line_file
   26333 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   26334 at_status=$?
   26335 grep '^ *+' $at_stder1 >&2
   26336 grep -v '^ *+' $at_stder1 >$at_stderr
   26337 at_failed=false
   26338 echo stderr:; tee stderr <$at_stderr
   26339 $at_diff $at_devnull $at_stdout || at_failed=:
   26340 case $at_status in
   26341    77) echo 77 > $at_status_file
   26342             exit 77;;
   26343    1) ;;
   26344    *) echo "calc.at:567: exit code was $at_status, expected 1"
   26345       at_failed=:;;
   26346 esac
   26347 if $at_failed; then
   26348 
   26349   echo 1 > $at_status_file
   26350   exit 1
   26351 fi
   26352 
   26353 $at_traceon
   26354 
   26355 
   26356 # Normalize the observed and expected error messages, depending upon the
   26357 # options.
   26358 # 1. Remove the traces from observed.
   26359 sed '/^Starting/d
   26360 /^Entering/d
   26361 /^Stack/d
   26362 /^Reading/d
   26363 /^Reducing/d
   26364 /^Shifting/d
   26365 /^state/d
   26366 /^Cleanup:/d
   26367 /^Error:/d
   26368 /^Next/d
   26369 /^Discarding/d
   26370 / \$[0-9$]* = /d
   26371 /^yydestructor:/d' stderr >at-stderr
   26372 mv at-stderr stderr
   26373 # 2. Create the reference error message.
   26374 cat >expout <<'_ATEOF'
   26375 1.0: syntax error, unexpected end of input
   26376 _ATEOF
   26377 
   26378 # 3. If locations are not used, remove them.
   26379 sed 's/^[-0-9.]*: //' expout >at-expout
   26380 mv at-expout expout
   26381 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   26382 
   26383 # 5. Check
   26384 $at_traceoff
   26385 echo "calc.at:567: cat stderr"
   26386 echo calc.at:567 >$at_check_line_file
   26387 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   26388 at_status=$?
   26389 grep '^ *+' $at_stder1 >&2
   26390 grep -v '^ *+' $at_stder1 >$at_stderr
   26391 at_failed=false
   26392 $at_diff $at_devnull $at_stderr || at_failed=:
   26393 $at_diff expout $at_stdout || at_failed=:
   26394 case $at_status in
   26395    77) echo 77 > $at_status_file
   26396             exit 77;;
   26397    0) ;;
   26398    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26399       at_failed=:;;
   26400 esac
   26401 if $at_failed; then
   26402 
   26403   echo 1 > $at_status_file
   26404   exit 1
   26405 fi
   26406 
   26407 $at_traceon
   26408 
   26409 
   26410 
   26411 # Exercise the error token: without it, we die at the first error,
   26412 # hence be sure to
   26413 #
   26414 # - have several errors which exercise different shift/discardings
   26415 #   - (): nothing to pop, nothing to discard
   26416 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   26417 #   - (* * *): nothing to pop, a lot to discard
   26418 #   - (1 + 2 * *): some to pop and discard
   26419 #
   26420 # - test the action associated to `error'
   26421 #
   26422 # - check the look-ahead that triggers an error is not discarded
   26423 #   when we enter error recovery.  Below, the look-ahead causing the
   26424 #   first error is ")", which is needed to recover from the error and
   26425 #   produce the "0" that triggers the "0 != 1" error.
   26426 #
   26427 cat >input <<'_ATEOF'
   26428 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   26429 _ATEOF
   26430 
   26431 $at_traceoff
   26432 echo "calc.at:567: \$PREPARSER ./calc input"
   26433 echo calc.at:567 >$at_check_line_file
   26434 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   26435 at_status=$?
   26436 grep '^ *+' $at_stder1 >&2
   26437 grep -v '^ *+' $at_stder1 >$at_stderr
   26438 at_failed=false
   26439 echo stderr:; tee stderr <$at_stderr
   26440 $at_diff $at_devnull $at_stdout || at_failed=:
   26441 case $at_status in
   26442    77) echo 77 > $at_status_file
   26443             exit 77;;
   26444    0) ;;
   26445    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26446       at_failed=:;;
   26447 esac
   26448 if $at_failed; then
   26449 
   26450   echo 1 > $at_status_file
   26451   exit 1
   26452 fi
   26453 
   26454 $at_traceon
   26455 
   26456 
   26457 # Normalize the observed and expected error messages, depending upon the
   26458 # options.
   26459 # 1. Remove the traces from observed.
   26460 sed '/^Starting/d
   26461 /^Entering/d
   26462 /^Stack/d
   26463 /^Reading/d
   26464 /^Reducing/d
   26465 /^Shifting/d
   26466 /^state/d
   26467 /^Cleanup:/d
   26468 /^Error:/d
   26469 /^Next/d
   26470 /^Discarding/d
   26471 / \$[0-9$]* = /d
   26472 /^yydestructor:/d' stderr >at-stderr
   26473 mv at-stderr stderr
   26474 # 2. Create the reference error message.
   26475 cat >expout <<'_ATEOF'
   26476 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   26477 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   26478 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   26479 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   26480 calc: error: 4444 != 1
   26481 _ATEOF
   26482 
   26483 # 3. If locations are not used, remove them.
   26484 sed 's/^[-0-9.]*: //' expout >at-expout
   26485 mv at-expout expout
   26486 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   26487 
   26488 # 5. Check
   26489 $at_traceoff
   26490 echo "calc.at:567: cat stderr"
   26491 echo calc.at:567 >$at_check_line_file
   26492 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   26493 at_status=$?
   26494 grep '^ *+' $at_stder1 >&2
   26495 grep -v '^ *+' $at_stder1 >$at_stderr
   26496 at_failed=false
   26497 $at_diff $at_devnull $at_stderr || at_failed=:
   26498 $at_diff expout $at_stdout || at_failed=:
   26499 case $at_status in
   26500    77) echo 77 > $at_status_file
   26501             exit 77;;
   26502    0) ;;
   26503    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26504       at_failed=:;;
   26505 esac
   26506 if $at_failed; then
   26507 
   26508   echo 1 > $at_status_file
   26509   exit 1
   26510 fi
   26511 
   26512 $at_traceon
   26513 
   26514 
   26515 
   26516 # The same, but this time exercising explicitly triggered syntax errors.
   26517 # POSIX says the look-ahead causing the error should not be discarded.
   26518 cat >input <<'_ATEOF'
   26519 (!) + (0 0) = 1
   26520 _ATEOF
   26521 
   26522 $at_traceoff
   26523 echo "calc.at:567: \$PREPARSER ./calc input"
   26524 echo calc.at:567 >$at_check_line_file
   26525 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   26526 at_status=$?
   26527 grep '^ *+' $at_stder1 >&2
   26528 grep -v '^ *+' $at_stder1 >$at_stderr
   26529 at_failed=false
   26530 echo stderr:; tee stderr <$at_stderr
   26531 $at_diff $at_devnull $at_stdout || at_failed=:
   26532 case $at_status in
   26533    77) echo 77 > $at_status_file
   26534             exit 77;;
   26535    0) ;;
   26536    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26537       at_failed=:;;
   26538 esac
   26539 if $at_failed; then
   26540 
   26541   echo 1 > $at_status_file
   26542   exit 1
   26543 fi
   26544 
   26545 $at_traceon
   26546 
   26547 
   26548 # Normalize the observed and expected error messages, depending upon the
   26549 # options.
   26550 # 1. Remove the traces from observed.
   26551 sed '/^Starting/d
   26552 /^Entering/d
   26553 /^Stack/d
   26554 /^Reading/d
   26555 /^Reducing/d
   26556 /^Shifting/d
   26557 /^state/d
   26558 /^Cleanup:/d
   26559 /^Error:/d
   26560 /^Next/d
   26561 /^Discarding/d
   26562 / \$[0-9$]* = /d
   26563 /^yydestructor:/d' stderr >at-stderr
   26564 mv at-stderr stderr
   26565 # 2. Create the reference error message.
   26566 cat >expout <<'_ATEOF'
   26567 1.9: syntax error, unexpected number
   26568 calc: error: 2222 != 1
   26569 _ATEOF
   26570 
   26571 # 3. If locations are not used, remove them.
   26572 sed 's/^[-0-9.]*: //' expout >at-expout
   26573 mv at-expout expout
   26574 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   26575 
   26576 # 5. Check
   26577 $at_traceoff
   26578 echo "calc.at:567: cat stderr"
   26579 echo calc.at:567 >$at_check_line_file
   26580 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   26581 at_status=$?
   26582 grep '^ *+' $at_stder1 >&2
   26583 grep -v '^ *+' $at_stder1 >$at_stderr
   26584 at_failed=false
   26585 $at_diff $at_devnull $at_stderr || at_failed=:
   26586 $at_diff expout $at_stdout || at_failed=:
   26587 case $at_status in
   26588    77) echo 77 > $at_status_file
   26589             exit 77;;
   26590    0) ;;
   26591    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26592       at_failed=:;;
   26593 esac
   26594 if $at_failed; then
   26595 
   26596   echo 1 > $at_status_file
   26597   exit 1
   26598 fi
   26599 
   26600 $at_traceon
   26601 
   26602 
   26603 cat >input <<'_ATEOF'
   26604 (- *) + (0 0) = 1
   26605 _ATEOF
   26606 
   26607 $at_traceoff
   26608 echo "calc.at:567: \$PREPARSER ./calc input"
   26609 echo calc.at:567 >$at_check_line_file
   26610 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   26611 at_status=$?
   26612 grep '^ *+' $at_stder1 >&2
   26613 grep -v '^ *+' $at_stder1 >$at_stderr
   26614 at_failed=false
   26615 echo stderr:; tee stderr <$at_stderr
   26616 $at_diff $at_devnull $at_stdout || at_failed=:
   26617 case $at_status in
   26618    77) echo 77 > $at_status_file
   26619             exit 77;;
   26620    0) ;;
   26621    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26622       at_failed=:;;
   26623 esac
   26624 if $at_failed; then
   26625 
   26626   echo 1 > $at_status_file
   26627   exit 1
   26628 fi
   26629 
   26630 $at_traceon
   26631 
   26632 
   26633 # Normalize the observed and expected error messages, depending upon the
   26634 # options.
   26635 # 1. Remove the traces from observed.
   26636 sed '/^Starting/d
   26637 /^Entering/d
   26638 /^Stack/d
   26639 /^Reading/d
   26640 /^Reducing/d
   26641 /^Shifting/d
   26642 /^state/d
   26643 /^Cleanup:/d
   26644 /^Error:/d
   26645 /^Next/d
   26646 /^Discarding/d
   26647 / \$[0-9$]* = /d
   26648 /^yydestructor:/d' stderr >at-stderr
   26649 mv at-stderr stderr
   26650 # 2. Create the reference error message.
   26651 cat >expout <<'_ATEOF'
   26652 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   26653 1.11: syntax error, unexpected number
   26654 calc: error: 2222 != 1
   26655 _ATEOF
   26656 
   26657 # 3. If locations are not used, remove them.
   26658 sed 's/^[-0-9.]*: //' expout >at-expout
   26659 mv at-expout expout
   26660 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   26661 
   26662 # 5. Check
   26663 $at_traceoff
   26664 echo "calc.at:567: cat stderr"
   26665 echo calc.at:567 >$at_check_line_file
   26666 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   26667 at_status=$?
   26668 grep '^ *+' $at_stder1 >&2
   26669 grep -v '^ *+' $at_stder1 >$at_stderr
   26670 at_failed=false
   26671 $at_diff $at_devnull $at_stderr || at_failed=:
   26672 $at_diff expout $at_stdout || at_failed=:
   26673 case $at_status in
   26674    77) echo 77 > $at_status_file
   26675             exit 77;;
   26676    0) ;;
   26677    *) echo "calc.at:567: exit code was $at_status, expected 0"
   26678       at_failed=:;;
   26679 esac
   26680 if $at_failed; then
   26681 
   26682   echo 1 > $at_status_file
   26683   exit 1
   26684 fi
   26685 
   26686 $at_traceon
   26687 
   26688 
   26689 
   26690 
   26691 
   26692 
   26693 
   26694 
   26695 
   26696 
   26697 
   26698 
   26699 
   26700 
   26701 
   26702 
   26703 
   26704 
   26705 
   26706 
   26707 
   26708 
   26709 
   26710 
   26711       $at_traceoff
   26712       $at_times_p && times >$at_times_file
   26713     ) 5>&1 2>&1 | eval $at_tee_pipe
   26714     at_status=`cat $at_status_file`
   26715     ;;
   26716 
   26717   83 ) # 83. calc.at:569: Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}
   26718     at_setup_line='calc.at:569'
   26719     at_desc='Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}'
   26720     $at_quiet $ECHO_N " 83: Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}$ECHO_C"
   26721     at_xfail=no
   26722     (
   26723       echo "83. calc.at:569: testing ..."
   26724       $at_traceon
   26725 
   26726 
   26727 
   26728 
   26729 
   26730 
   26731 
   26732 
   26733 # Using yacc.c?
   26734 
   26735 
   26736 
   26737 
   26738 
   26739 
   26740 
   26741 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   26742 
   26743 # yyerror always sees the locations (when activated), except if
   26744 # yacc & pure & !param.
   26745 
   26746 
   26747 # The interface is pure: either because %pure-parser, or because we
   26748 # are using the C++ parsers.
   26749 
   26750 
   26751 
   26752 
   26753 
   26754 
   26755 
   26756 
   26757 
   26758 
   26759 
   26760 
   26761 cat >calc.y <<'_ATEOF'
   26762 %{
   26763 #ifdef HAVE_CONFIG_H
   26764 # include <config.h>
   26765   /* We don't need perfect functions for these tests. */
   26766 # undef malloc
   26767 # undef memcmp
   26768 # undef realloc
   26769 #endif
   26770 %}
   26771 
   26772 /* Infix notation calculator--calc */
   26773 %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}
   26774 
   26775 %{
   26776 #include <stdio.h>
   26777 
   26778 #include <stdlib.h>
   26779 #include <string.h>
   26780 #if HAVE_UNISTD_H
   26781 # include <unistd.h>
   26782 #else
   26783 # undef alarm
   26784 # define alarm(seconds) /* empty */
   26785 #endif
   26786 #include <ctype.h>
   26787 #define USE(Var)
   26788 
   26789 /* Exercise pre-prologue dependency to %union.  */
   26790 typedef int semantic_value;
   26791 
   26792 static semantic_value global_result = 0;
   26793 static int global_count = 0;
   26794 %}
   26795 
   26796 /* Exercise %union. */
   26797 %union
   26798 {
   26799   semantic_value ival;
   26800 };
   26801 
   26802 %{
   26803 static int power (int base, int exponent);
   26804 /* yyerror receives the location if:
   26805    - %location & %pure & %glr
   26806    - %location & %pure & %yacc & %parse-param. */
   26807 static void yyerror (YYLTYPE *llocp,
   26808                      semantic_value *result, int *count,
   26809                      const char *s
   26810                      );
   26811 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   26812 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   26813 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   26814 %}
   26815 
   26816 
   26817 
   26818 /* Bison Declarations */
   26819 %token CALC_EOF 0 "end of input"
   26820 %token <ival> NUM "number"
   26821 %type  <ival> exp
   26822 
   26823 %nonassoc '=' /* comparison	       */
   26824 %left '-' '+'
   26825 %left '*' '/'
   26826 %left NEG     /* negation--unary minus */
   26827 %right '^'    /* exponentiation        */
   26828 
   26829 /* Grammar follows */
   26830 %%
   26831 input:
   26832   line
   26833 | input line         { ++*count; ++global_count; }
   26834 ;
   26835 
   26836 line:
   26837   '\n'
   26838 | exp '\n'           { *result = global_result = $1; }
   26839 ;
   26840 
   26841 exp:
   26842   NUM                { $$ = $1;             }
   26843 | exp '=' exp
   26844   {
   26845     if ($1 != $3)
   26846       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   26847     $$ = $1;
   26848   }
   26849 | exp '+' exp        { $$ = $1 + $3;        }
   26850 | exp '-' exp        { $$ = $1 - $3;        }
   26851 | exp '*' exp        { $$ = $1 * $3;        }
   26852 | exp '/' exp        { $$ = $1 / $3;        }
   26853 | '-' exp  %prec NEG { $$ = -$2;            }
   26854 | exp '^' exp        { $$ = power ($1, $3); }
   26855 | '(' exp ')'        { $$ = $2;             }
   26856 | '(' error ')'      { $$ = 1111;           }
   26857 | '!'                { $$ = 0; YYERROR;     }
   26858 | '-' error          { $$ = 0; YYERROR;     }
   26859 ;
   26860 %%
   26861 /* The input.  */
   26862 static FILE *input;
   26863 
   26864 static void
   26865 yyerror (YYLTYPE *llocp,
   26866          semantic_value *result, int *count,
   26867          const char *s)
   26868 {
   26869 (void) result; (void) count;
   26870 
   26871   fprintf (stderr, "%d.%d",
   26872            (*llocp).first_line, (*llocp).first_column);
   26873   if ((*llocp).first_line != (*llocp).last_line)
   26874     fprintf (stderr, "-%d.%d",
   26875 	     (*llocp).last_line,  (*llocp).last_column - 1);
   26876   else if ((*llocp).first_column != (*llocp).last_column - 1)
   26877     fprintf (stderr, "-%d",
   26878 	     (*llocp).last_column - 1);
   26879   fprintf (stderr, ": ");
   26880   fprintf (stderr, "%s\n", s);
   26881 }
   26882 
   26883 
   26884 
   26885 static YYLTYPE last_yylloc;
   26886 
   26887 static int
   26888 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   26889 {
   26890   int res = getc (input);
   26891   (void) lvalp;(void) llocp;
   26892 
   26893   last_yylloc = (*llocp);
   26894   if (res == '\n')
   26895     {
   26896       (*llocp).last_line++;
   26897       (*llocp).last_column = 0;
   26898     }
   26899   else
   26900     (*llocp).last_column++;
   26901 
   26902   return res;
   26903 }
   26904 
   26905 
   26906 static void
   26907 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   26908 {
   26909   (void) lvalp;(void) llocp;
   26910 
   26911   /* Wrong when C == `\n'. */
   26912   (*llocp) = last_yylloc;
   26913 
   26914   ungetc (c, input);
   26915 }
   26916 
   26917 static int
   26918 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   26919 {
   26920   int c = get_char (lvalp, llocp);
   26921   int sign = 1;
   26922   int n = 0;
   26923 
   26924   (void) lvalp;(void) llocp;
   26925   if (c == '-')
   26926     {
   26927       c = get_char (lvalp, llocp);
   26928       sign = -1;
   26929     }
   26930 
   26931   while (isdigit (c))
   26932     {
   26933       n = 10 * n + (c - '0');
   26934       c = get_char (lvalp, llocp);
   26935     }
   26936 
   26937   unget_char (lvalp, llocp,  c);
   26938 
   26939   return sign * n;
   26940 }
   26941 
   26942 
   26943 
   26944 /*---------------------------------------------------------------.
   26945 | Lexical analyzer returns an integer on the stack and the token |
   26946 | NUM, or the ASCII character read if not a number.  Skips all   |
   26947 | blanks and tabs, returns 0 for EOF.                            |
   26948 `---------------------------------------------------------------*/
   26949 
   26950 static int
   26951 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   26952 {
   26953   static int init = 1;
   26954   int c;
   26955 
   26956   if (init)
   26957     {
   26958       init = 0;
   26959 
   26960       (*llocp).last_column = 0;
   26961       (*llocp).last_line = 1;
   26962 
   26963     }
   26964 
   26965 
   26966  (*llocp).first_column = (*llocp).last_column;
   26967   (*llocp).first_line   = (*llocp).last_line;
   26968 
   26969 
   26970   /* Skip white space.  */
   26971   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   26972     {
   26973      (*llocp).first_column = (*llocp).last_column;
   26974       (*llocp).first_line   = (*llocp).last_line;
   26975 
   26976     }
   26977 
   26978   /* process numbers   */
   26979   if (c == '.' || isdigit (c))
   26980     {
   26981       unget_char (lvalp, llocp,  c);
   26982       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   26983       return NUM;
   26984     }
   26985 
   26986   /* Return end-of-file.  */
   26987   if (c == EOF)
   26988     return CALC_EOF;
   26989 
   26990   /* Return single chars. */
   26991   return c;
   26992 }
   26993 
   26994 static int
   26995 power (int base, int exponent)
   26996 {
   26997   int res = 1;
   26998   if (exponent < 0)
   26999     exit (3);
   27000   for (/* Niente */; exponent; --exponent)
   27001     res *= base;
   27002   return res;
   27003 }
   27004 
   27005 
   27006 int
   27007 main (int argc, const char **argv)
   27008 {
   27009   semantic_value result = 0;
   27010   int count = 0;
   27011   int status;
   27012 
   27013   /* This used to be alarm (10), but that isn't enough time for
   27014      a July 1995 vintage DEC Alphastation 200 4/100 system,
   27015      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   27016   alarm (100);
   27017 
   27018   if (argc == 2)
   27019     input = fopen (argv[1], "r");
   27020   else
   27021     input = stdin;
   27022 
   27023   if (!input)
   27024     {
   27025       perror (argv[1]);
   27026       return 3;
   27027     }
   27028 
   27029   yydebug = 1;
   27030   status = yyparse (&result, &count);
   27031   if (global_result != result)
   27032     abort ();
   27033   if (global_count != count)
   27034     abort ();
   27035   return status;
   27036 }
   27037 _ATEOF
   27038 
   27039 
   27040 
   27041 
   27042 
   27043 $at_traceoff
   27044 echo "calc.at:569: bison -o calc.c calc.y"
   27045 echo calc.at:569 >$at_check_line_file
   27046 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   27047 at_status=$?
   27048 grep '^ *+' $at_stder1 >&2
   27049 grep -v '^ *+' $at_stder1 >$at_stderr
   27050 at_failed=false
   27051 $at_diff $at_devnull $at_stderr || at_failed=:
   27052 $at_diff $at_devnull $at_stdout || at_failed=:
   27053 case $at_status in
   27054    77) echo 77 > $at_status_file
   27055             exit 77;;
   27056    0) ;;
   27057    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27058       at_failed=:;;
   27059 esac
   27060 if $at_failed; then
   27061 
   27062   echo 1 > $at_status_file
   27063   exit 1
   27064 fi
   27065 
   27066 $at_traceon
   27067 
   27068    $at_traceoff
   27069 echo "calc.at:569: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   27070 echo calc.at:569 >$at_check_line_file
   27071 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   27072 at_status=$?
   27073 grep '^ *+' $at_stder1 >&2
   27074 grep -v '^ *+' $at_stder1 >$at_stderr
   27075 at_failed=false
   27076 echo stderr:; cat $at_stderr
   27077 echo stdout:; cat $at_stdout
   27078 case $at_status in
   27079    77) echo 77 > $at_status_file
   27080             exit 77;;
   27081    0) ;;
   27082    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27083       at_failed=:;;
   27084 esac
   27085 if $at_failed; then
   27086 
   27087   echo 1 > $at_status_file
   27088   exit 1
   27089 fi
   27090 
   27091 $at_traceon
   27092 
   27093 
   27094 # Test the priorities.
   27095 cat >input <<'_ATEOF'
   27096 1 + 2 * 3 = 7
   27097 1 + 2 * -3 = -5
   27098 
   27099 -1^2 = -1
   27100 (-1)^2 = 1
   27101 
   27102 ---1 = -1
   27103 
   27104 1 - 2 - 3 = -4
   27105 1 - (2 - 3) = 2
   27106 
   27107 2^2^3 = 256
   27108 (2^2)^3 = 64
   27109 _ATEOF
   27110 
   27111 $at_traceoff
   27112 echo "calc.at:569: \$PREPARSER ./calc input"
   27113 echo calc.at:569 >$at_check_line_file
   27114 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   27115 at_status=$?
   27116 grep '^ *+' $at_stder1 >&2
   27117 grep -v '^ *+' $at_stder1 >$at_stderr
   27118 at_failed=false
   27119 echo stderr:; tee stderr <$at_stderr
   27120 $at_diff $at_devnull $at_stdout || at_failed=:
   27121 case $at_status in
   27122    77) echo 77 > $at_status_file
   27123             exit 77;;
   27124    0) ;;
   27125    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27126       at_failed=:;;
   27127 esac
   27128 if $at_failed; then
   27129 
   27130   echo 1 > $at_status_file
   27131   exit 1
   27132 fi
   27133 
   27134 $at_traceon
   27135 
   27136 
   27137 
   27138 # Some syntax errors.
   27139 cat >input <<'_ATEOF'
   27140 0 0
   27141 _ATEOF
   27142 
   27143 $at_traceoff
   27144 echo "calc.at:569: \$PREPARSER ./calc input"
   27145 echo calc.at:569 >$at_check_line_file
   27146 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   27147 at_status=$?
   27148 grep '^ *+' $at_stder1 >&2
   27149 grep -v '^ *+' $at_stder1 >$at_stderr
   27150 at_failed=false
   27151 echo stderr:; tee stderr <$at_stderr
   27152 $at_diff $at_devnull $at_stdout || at_failed=:
   27153 case $at_status in
   27154    77) echo 77 > $at_status_file
   27155             exit 77;;
   27156    1) ;;
   27157    *) echo "calc.at:569: exit code was $at_status, expected 1"
   27158       at_failed=:;;
   27159 esac
   27160 if $at_failed; then
   27161 
   27162   echo 1 > $at_status_file
   27163   exit 1
   27164 fi
   27165 
   27166 $at_traceon
   27167 
   27168 
   27169 # Normalize the observed and expected error messages, depending upon the
   27170 # options.
   27171 # 1. Remove the traces from observed.
   27172 sed '/^Starting/d
   27173 /^Entering/d
   27174 /^Stack/d
   27175 /^Reading/d
   27176 /^Reducing/d
   27177 /^Shifting/d
   27178 /^state/d
   27179 /^Cleanup:/d
   27180 /^Error:/d
   27181 /^Next/d
   27182 /^Discarding/d
   27183 / \$[0-9$]* = /d
   27184 /^yydestructor:/d' stderr >at-stderr
   27185 mv at-stderr stderr
   27186 # 2. Create the reference error message.
   27187 cat >expout <<'_ATEOF'
   27188 1.2: syntax error, unexpected number
   27189 _ATEOF
   27190 
   27191 # 3. If locations are not used, remove them.
   27192 
   27193 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   27194 
   27195 # 5. Check
   27196 $at_traceoff
   27197 echo "calc.at:569: cat stderr"
   27198 echo calc.at:569 >$at_check_line_file
   27199 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   27200 at_status=$?
   27201 grep '^ *+' $at_stder1 >&2
   27202 grep -v '^ *+' $at_stder1 >$at_stderr
   27203 at_failed=false
   27204 $at_diff $at_devnull $at_stderr || at_failed=:
   27205 $at_diff expout $at_stdout || at_failed=:
   27206 case $at_status in
   27207    77) echo 77 > $at_status_file
   27208             exit 77;;
   27209    0) ;;
   27210    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27211       at_failed=:;;
   27212 esac
   27213 if $at_failed; then
   27214 
   27215   echo 1 > $at_status_file
   27216   exit 1
   27217 fi
   27218 
   27219 $at_traceon
   27220 
   27221 
   27222 cat >input <<'_ATEOF'
   27223 1//2
   27224 _ATEOF
   27225 
   27226 $at_traceoff
   27227 echo "calc.at:569: \$PREPARSER ./calc input"
   27228 echo calc.at:569 >$at_check_line_file
   27229 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   27230 at_status=$?
   27231 grep '^ *+' $at_stder1 >&2
   27232 grep -v '^ *+' $at_stder1 >$at_stderr
   27233 at_failed=false
   27234 echo stderr:; tee stderr <$at_stderr
   27235 $at_diff $at_devnull $at_stdout || at_failed=:
   27236 case $at_status in
   27237    77) echo 77 > $at_status_file
   27238             exit 77;;
   27239    1) ;;
   27240    *) echo "calc.at:569: exit code was $at_status, expected 1"
   27241       at_failed=:;;
   27242 esac
   27243 if $at_failed; then
   27244 
   27245   echo 1 > $at_status_file
   27246   exit 1
   27247 fi
   27248 
   27249 $at_traceon
   27250 
   27251 
   27252 # Normalize the observed and expected error messages, depending upon the
   27253 # options.
   27254 # 1. Remove the traces from observed.
   27255 sed '/^Starting/d
   27256 /^Entering/d
   27257 /^Stack/d
   27258 /^Reading/d
   27259 /^Reducing/d
   27260 /^Shifting/d
   27261 /^state/d
   27262 /^Cleanup:/d
   27263 /^Error:/d
   27264 /^Next/d
   27265 /^Discarding/d
   27266 / \$[0-9$]* = /d
   27267 /^yydestructor:/d' stderr >at-stderr
   27268 mv at-stderr stderr
   27269 # 2. Create the reference error message.
   27270 cat >expout <<'_ATEOF'
   27271 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   27272 _ATEOF
   27273 
   27274 # 3. If locations are not used, remove them.
   27275 
   27276 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   27277 
   27278 # 5. Check
   27279 $at_traceoff
   27280 echo "calc.at:569: cat stderr"
   27281 echo calc.at:569 >$at_check_line_file
   27282 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   27283 at_status=$?
   27284 grep '^ *+' $at_stder1 >&2
   27285 grep -v '^ *+' $at_stder1 >$at_stderr
   27286 at_failed=false
   27287 $at_diff $at_devnull $at_stderr || at_failed=:
   27288 $at_diff expout $at_stdout || at_failed=:
   27289 case $at_status in
   27290    77) echo 77 > $at_status_file
   27291             exit 77;;
   27292    0) ;;
   27293    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27294       at_failed=:;;
   27295 esac
   27296 if $at_failed; then
   27297 
   27298   echo 1 > $at_status_file
   27299   exit 1
   27300 fi
   27301 
   27302 $at_traceon
   27303 
   27304 
   27305 cat >input <<'_ATEOF'
   27306 error
   27307 _ATEOF
   27308 
   27309 $at_traceoff
   27310 echo "calc.at:569: \$PREPARSER ./calc input"
   27311 echo calc.at:569 >$at_check_line_file
   27312 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   27313 at_status=$?
   27314 grep '^ *+' $at_stder1 >&2
   27315 grep -v '^ *+' $at_stder1 >$at_stderr
   27316 at_failed=false
   27317 echo stderr:; tee stderr <$at_stderr
   27318 $at_diff $at_devnull $at_stdout || at_failed=:
   27319 case $at_status in
   27320    77) echo 77 > $at_status_file
   27321             exit 77;;
   27322    1) ;;
   27323    *) echo "calc.at:569: exit code was $at_status, expected 1"
   27324       at_failed=:;;
   27325 esac
   27326 if $at_failed; then
   27327 
   27328   echo 1 > $at_status_file
   27329   exit 1
   27330 fi
   27331 
   27332 $at_traceon
   27333 
   27334 
   27335 # Normalize the observed and expected error messages, depending upon the
   27336 # options.
   27337 # 1. Remove the traces from observed.
   27338 sed '/^Starting/d
   27339 /^Entering/d
   27340 /^Stack/d
   27341 /^Reading/d
   27342 /^Reducing/d
   27343 /^Shifting/d
   27344 /^state/d
   27345 /^Cleanup:/d
   27346 /^Error:/d
   27347 /^Next/d
   27348 /^Discarding/d
   27349 / \$[0-9$]* = /d
   27350 /^yydestructor:/d' stderr >at-stderr
   27351 mv at-stderr stderr
   27352 # 2. Create the reference error message.
   27353 cat >expout <<'_ATEOF'
   27354 1.0: syntax error, unexpected $undefined
   27355 _ATEOF
   27356 
   27357 # 3. If locations are not used, remove them.
   27358 
   27359 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   27360 
   27361 # 5. Check
   27362 $at_traceoff
   27363 echo "calc.at:569: cat stderr"
   27364 echo calc.at:569 >$at_check_line_file
   27365 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   27366 at_status=$?
   27367 grep '^ *+' $at_stder1 >&2
   27368 grep -v '^ *+' $at_stder1 >$at_stderr
   27369 at_failed=false
   27370 $at_diff $at_devnull $at_stderr || at_failed=:
   27371 $at_diff expout $at_stdout || at_failed=:
   27372 case $at_status in
   27373    77) echo 77 > $at_status_file
   27374             exit 77;;
   27375    0) ;;
   27376    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27377       at_failed=:;;
   27378 esac
   27379 if $at_failed; then
   27380 
   27381   echo 1 > $at_status_file
   27382   exit 1
   27383 fi
   27384 
   27385 $at_traceon
   27386 
   27387 
   27388 cat >input <<'_ATEOF'
   27389 1 = 2 = 3
   27390 _ATEOF
   27391 
   27392 $at_traceoff
   27393 echo "calc.at:569: \$PREPARSER ./calc input"
   27394 echo calc.at:569 >$at_check_line_file
   27395 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   27396 at_status=$?
   27397 grep '^ *+' $at_stder1 >&2
   27398 grep -v '^ *+' $at_stder1 >$at_stderr
   27399 at_failed=false
   27400 echo stderr:; tee stderr <$at_stderr
   27401 $at_diff $at_devnull $at_stdout || at_failed=:
   27402 case $at_status in
   27403    77) echo 77 > $at_status_file
   27404             exit 77;;
   27405    1) ;;
   27406    *) echo "calc.at:569: exit code was $at_status, expected 1"
   27407       at_failed=:;;
   27408 esac
   27409 if $at_failed; then
   27410 
   27411   echo 1 > $at_status_file
   27412   exit 1
   27413 fi
   27414 
   27415 $at_traceon
   27416 
   27417 
   27418 # Normalize the observed and expected error messages, depending upon the
   27419 # options.
   27420 # 1. Remove the traces from observed.
   27421 sed '/^Starting/d
   27422 /^Entering/d
   27423 /^Stack/d
   27424 /^Reading/d
   27425 /^Reducing/d
   27426 /^Shifting/d
   27427 /^state/d
   27428 /^Cleanup:/d
   27429 /^Error:/d
   27430 /^Next/d
   27431 /^Discarding/d
   27432 / \$[0-9$]* = /d
   27433 /^yydestructor:/d' stderr >at-stderr
   27434 mv at-stderr stderr
   27435 # 2. Create the reference error message.
   27436 cat >expout <<'_ATEOF'
   27437 1.6: syntax error, unexpected '='
   27438 _ATEOF
   27439 
   27440 # 3. If locations are not used, remove them.
   27441 
   27442 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   27443 
   27444 # 5. Check
   27445 $at_traceoff
   27446 echo "calc.at:569: cat stderr"
   27447 echo calc.at:569 >$at_check_line_file
   27448 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   27449 at_status=$?
   27450 grep '^ *+' $at_stder1 >&2
   27451 grep -v '^ *+' $at_stder1 >$at_stderr
   27452 at_failed=false
   27453 $at_diff $at_devnull $at_stderr || at_failed=:
   27454 $at_diff expout $at_stdout || at_failed=:
   27455 case $at_status in
   27456    77) echo 77 > $at_status_file
   27457             exit 77;;
   27458    0) ;;
   27459    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27460       at_failed=:;;
   27461 esac
   27462 if $at_failed; then
   27463 
   27464   echo 1 > $at_status_file
   27465   exit 1
   27466 fi
   27467 
   27468 $at_traceon
   27469 
   27470 
   27471 cat >input <<'_ATEOF'
   27472 
   27473 +1
   27474 _ATEOF
   27475 
   27476 $at_traceoff
   27477 echo "calc.at:569: \$PREPARSER ./calc input"
   27478 echo calc.at:569 >$at_check_line_file
   27479 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   27480 at_status=$?
   27481 grep '^ *+' $at_stder1 >&2
   27482 grep -v '^ *+' $at_stder1 >$at_stderr
   27483 at_failed=false
   27484 echo stderr:; tee stderr <$at_stderr
   27485 $at_diff $at_devnull $at_stdout || at_failed=:
   27486 case $at_status in
   27487    77) echo 77 > $at_status_file
   27488             exit 77;;
   27489    1) ;;
   27490    *) echo "calc.at:569: exit code was $at_status, expected 1"
   27491       at_failed=:;;
   27492 esac
   27493 if $at_failed; then
   27494 
   27495   echo 1 > $at_status_file
   27496   exit 1
   27497 fi
   27498 
   27499 $at_traceon
   27500 
   27501 
   27502 # Normalize the observed and expected error messages, depending upon the
   27503 # options.
   27504 # 1. Remove the traces from observed.
   27505 sed '/^Starting/d
   27506 /^Entering/d
   27507 /^Stack/d
   27508 /^Reading/d
   27509 /^Reducing/d
   27510 /^Shifting/d
   27511 /^state/d
   27512 /^Cleanup:/d
   27513 /^Error:/d
   27514 /^Next/d
   27515 /^Discarding/d
   27516 / \$[0-9$]* = /d
   27517 /^yydestructor:/d' stderr >at-stderr
   27518 mv at-stderr stderr
   27519 # 2. Create the reference error message.
   27520 cat >expout <<'_ATEOF'
   27521 2.0: syntax error, unexpected '+'
   27522 _ATEOF
   27523 
   27524 # 3. If locations are not used, remove them.
   27525 
   27526 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   27527 
   27528 # 5. Check
   27529 $at_traceoff
   27530 echo "calc.at:569: cat stderr"
   27531 echo calc.at:569 >$at_check_line_file
   27532 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   27533 at_status=$?
   27534 grep '^ *+' $at_stder1 >&2
   27535 grep -v '^ *+' $at_stder1 >$at_stderr
   27536 at_failed=false
   27537 $at_diff $at_devnull $at_stderr || at_failed=:
   27538 $at_diff expout $at_stdout || at_failed=:
   27539 case $at_status in
   27540    77) echo 77 > $at_status_file
   27541             exit 77;;
   27542    0) ;;
   27543    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27544       at_failed=:;;
   27545 esac
   27546 if $at_failed; then
   27547 
   27548   echo 1 > $at_status_file
   27549   exit 1
   27550 fi
   27551 
   27552 $at_traceon
   27553 
   27554 
   27555 # Exercise error messages with EOF: work on an empty file.
   27556 $at_traceoff
   27557 echo "calc.at:569: \$PREPARSER ./calc /dev/null"
   27558 echo calc.at:569 >$at_check_line_file
   27559 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   27560 at_status=$?
   27561 grep '^ *+' $at_stder1 >&2
   27562 grep -v '^ *+' $at_stder1 >$at_stderr
   27563 at_failed=false
   27564 echo stderr:; tee stderr <$at_stderr
   27565 $at_diff $at_devnull $at_stdout || at_failed=:
   27566 case $at_status in
   27567    77) echo 77 > $at_status_file
   27568             exit 77;;
   27569    1) ;;
   27570    *) echo "calc.at:569: exit code was $at_status, expected 1"
   27571       at_failed=:;;
   27572 esac
   27573 if $at_failed; then
   27574 
   27575   echo 1 > $at_status_file
   27576   exit 1
   27577 fi
   27578 
   27579 $at_traceon
   27580 
   27581 
   27582 # Normalize the observed and expected error messages, depending upon the
   27583 # options.
   27584 # 1. Remove the traces from observed.
   27585 sed '/^Starting/d
   27586 /^Entering/d
   27587 /^Stack/d
   27588 /^Reading/d
   27589 /^Reducing/d
   27590 /^Shifting/d
   27591 /^state/d
   27592 /^Cleanup:/d
   27593 /^Error:/d
   27594 /^Next/d
   27595 /^Discarding/d
   27596 / \$[0-9$]* = /d
   27597 /^yydestructor:/d' stderr >at-stderr
   27598 mv at-stderr stderr
   27599 # 2. Create the reference error message.
   27600 cat >expout <<'_ATEOF'
   27601 1.0: syntax error, unexpected end of input
   27602 _ATEOF
   27603 
   27604 # 3. If locations are not used, remove them.
   27605 
   27606 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   27607 
   27608 # 5. Check
   27609 $at_traceoff
   27610 echo "calc.at:569: cat stderr"
   27611 echo calc.at:569 >$at_check_line_file
   27612 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   27613 at_status=$?
   27614 grep '^ *+' $at_stder1 >&2
   27615 grep -v '^ *+' $at_stder1 >$at_stderr
   27616 at_failed=false
   27617 $at_diff $at_devnull $at_stderr || at_failed=:
   27618 $at_diff expout $at_stdout || at_failed=:
   27619 case $at_status in
   27620    77) echo 77 > $at_status_file
   27621             exit 77;;
   27622    0) ;;
   27623    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27624       at_failed=:;;
   27625 esac
   27626 if $at_failed; then
   27627 
   27628   echo 1 > $at_status_file
   27629   exit 1
   27630 fi
   27631 
   27632 $at_traceon
   27633 
   27634 
   27635 
   27636 # Exercise the error token: without it, we die at the first error,
   27637 # hence be sure to
   27638 #
   27639 # - have several errors which exercise different shift/discardings
   27640 #   - (): nothing to pop, nothing to discard
   27641 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   27642 #   - (* * *): nothing to pop, a lot to discard
   27643 #   - (1 + 2 * *): some to pop and discard
   27644 #
   27645 # - test the action associated to `error'
   27646 #
   27647 # - check the look-ahead that triggers an error is not discarded
   27648 #   when we enter error recovery.  Below, the look-ahead causing the
   27649 #   first error is ")", which is needed to recover from the error and
   27650 #   produce the "0" that triggers the "0 != 1" error.
   27651 #
   27652 cat >input <<'_ATEOF'
   27653 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   27654 _ATEOF
   27655 
   27656 $at_traceoff
   27657 echo "calc.at:569: \$PREPARSER ./calc input"
   27658 echo calc.at:569 >$at_check_line_file
   27659 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   27660 at_status=$?
   27661 grep '^ *+' $at_stder1 >&2
   27662 grep -v '^ *+' $at_stder1 >$at_stderr
   27663 at_failed=false
   27664 echo stderr:; tee stderr <$at_stderr
   27665 $at_diff $at_devnull $at_stdout || at_failed=:
   27666 case $at_status in
   27667    77) echo 77 > $at_status_file
   27668             exit 77;;
   27669    0) ;;
   27670    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27671       at_failed=:;;
   27672 esac
   27673 if $at_failed; then
   27674 
   27675   echo 1 > $at_status_file
   27676   exit 1
   27677 fi
   27678 
   27679 $at_traceon
   27680 
   27681 
   27682 # Normalize the observed and expected error messages, depending upon the
   27683 # options.
   27684 # 1. Remove the traces from observed.
   27685 sed '/^Starting/d
   27686 /^Entering/d
   27687 /^Stack/d
   27688 /^Reading/d
   27689 /^Reducing/d
   27690 /^Shifting/d
   27691 /^state/d
   27692 /^Cleanup:/d
   27693 /^Error:/d
   27694 /^Next/d
   27695 /^Discarding/d
   27696 / \$[0-9$]* = /d
   27697 /^yydestructor:/d' stderr >at-stderr
   27698 mv at-stderr stderr
   27699 # 2. Create the reference error message.
   27700 cat >expout <<'_ATEOF'
   27701 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   27702 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   27703 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   27704 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   27705 calc: error: 4444 != 1
   27706 _ATEOF
   27707 
   27708 # 3. If locations are not used, remove them.
   27709 
   27710 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   27711 
   27712 # 5. Check
   27713 $at_traceoff
   27714 echo "calc.at:569: cat stderr"
   27715 echo calc.at:569 >$at_check_line_file
   27716 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   27717 at_status=$?
   27718 grep '^ *+' $at_stder1 >&2
   27719 grep -v '^ *+' $at_stder1 >$at_stderr
   27720 at_failed=false
   27721 $at_diff $at_devnull $at_stderr || at_failed=:
   27722 $at_diff expout $at_stdout || at_failed=:
   27723 case $at_status in
   27724    77) echo 77 > $at_status_file
   27725             exit 77;;
   27726    0) ;;
   27727    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27728       at_failed=:;;
   27729 esac
   27730 if $at_failed; then
   27731 
   27732   echo 1 > $at_status_file
   27733   exit 1
   27734 fi
   27735 
   27736 $at_traceon
   27737 
   27738 
   27739 
   27740 # The same, but this time exercising explicitly triggered syntax errors.
   27741 # POSIX says the look-ahead causing the error should not be discarded.
   27742 cat >input <<'_ATEOF'
   27743 (!) + (0 0) = 1
   27744 _ATEOF
   27745 
   27746 $at_traceoff
   27747 echo "calc.at:569: \$PREPARSER ./calc input"
   27748 echo calc.at:569 >$at_check_line_file
   27749 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   27750 at_status=$?
   27751 grep '^ *+' $at_stder1 >&2
   27752 grep -v '^ *+' $at_stder1 >$at_stderr
   27753 at_failed=false
   27754 echo stderr:; tee stderr <$at_stderr
   27755 $at_diff $at_devnull $at_stdout || at_failed=:
   27756 case $at_status in
   27757    77) echo 77 > $at_status_file
   27758             exit 77;;
   27759    0) ;;
   27760    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27761       at_failed=:;;
   27762 esac
   27763 if $at_failed; then
   27764 
   27765   echo 1 > $at_status_file
   27766   exit 1
   27767 fi
   27768 
   27769 $at_traceon
   27770 
   27771 
   27772 # Normalize the observed and expected error messages, depending upon the
   27773 # options.
   27774 # 1. Remove the traces from observed.
   27775 sed '/^Starting/d
   27776 /^Entering/d
   27777 /^Stack/d
   27778 /^Reading/d
   27779 /^Reducing/d
   27780 /^Shifting/d
   27781 /^state/d
   27782 /^Cleanup:/d
   27783 /^Error:/d
   27784 /^Next/d
   27785 /^Discarding/d
   27786 / \$[0-9$]* = /d
   27787 /^yydestructor:/d' stderr >at-stderr
   27788 mv at-stderr stderr
   27789 # 2. Create the reference error message.
   27790 cat >expout <<'_ATEOF'
   27791 1.9: syntax error, unexpected number
   27792 calc: error: 2222 != 1
   27793 _ATEOF
   27794 
   27795 # 3. If locations are not used, remove them.
   27796 
   27797 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   27798 
   27799 # 5. Check
   27800 $at_traceoff
   27801 echo "calc.at:569: cat stderr"
   27802 echo calc.at:569 >$at_check_line_file
   27803 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   27804 at_status=$?
   27805 grep '^ *+' $at_stder1 >&2
   27806 grep -v '^ *+' $at_stder1 >$at_stderr
   27807 at_failed=false
   27808 $at_diff $at_devnull $at_stderr || at_failed=:
   27809 $at_diff expout $at_stdout || at_failed=:
   27810 case $at_status in
   27811    77) echo 77 > $at_status_file
   27812             exit 77;;
   27813    0) ;;
   27814    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27815       at_failed=:;;
   27816 esac
   27817 if $at_failed; then
   27818 
   27819   echo 1 > $at_status_file
   27820   exit 1
   27821 fi
   27822 
   27823 $at_traceon
   27824 
   27825 
   27826 cat >input <<'_ATEOF'
   27827 (- *) + (0 0) = 1
   27828 _ATEOF
   27829 
   27830 $at_traceoff
   27831 echo "calc.at:569: \$PREPARSER ./calc input"
   27832 echo calc.at:569 >$at_check_line_file
   27833 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   27834 at_status=$?
   27835 grep '^ *+' $at_stder1 >&2
   27836 grep -v '^ *+' $at_stder1 >$at_stderr
   27837 at_failed=false
   27838 echo stderr:; tee stderr <$at_stderr
   27839 $at_diff $at_devnull $at_stdout || at_failed=:
   27840 case $at_status in
   27841    77) echo 77 > $at_status_file
   27842             exit 77;;
   27843    0) ;;
   27844    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27845       at_failed=:;;
   27846 esac
   27847 if $at_failed; then
   27848 
   27849   echo 1 > $at_status_file
   27850   exit 1
   27851 fi
   27852 
   27853 $at_traceon
   27854 
   27855 
   27856 # Normalize the observed and expected error messages, depending upon the
   27857 # options.
   27858 # 1. Remove the traces from observed.
   27859 sed '/^Starting/d
   27860 /^Entering/d
   27861 /^Stack/d
   27862 /^Reading/d
   27863 /^Reducing/d
   27864 /^Shifting/d
   27865 /^state/d
   27866 /^Cleanup:/d
   27867 /^Error:/d
   27868 /^Next/d
   27869 /^Discarding/d
   27870 / \$[0-9$]* = /d
   27871 /^yydestructor:/d' stderr >at-stderr
   27872 mv at-stderr stderr
   27873 # 2. Create the reference error message.
   27874 cat >expout <<'_ATEOF'
   27875 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   27876 1.11: syntax error, unexpected number
   27877 calc: error: 2222 != 1
   27878 _ATEOF
   27879 
   27880 # 3. If locations are not used, remove them.
   27881 
   27882 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   27883 
   27884 # 5. Check
   27885 $at_traceoff
   27886 echo "calc.at:569: cat stderr"
   27887 echo calc.at:569 >$at_check_line_file
   27888 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   27889 at_status=$?
   27890 grep '^ *+' $at_stder1 >&2
   27891 grep -v '^ *+' $at_stder1 >$at_stderr
   27892 at_failed=false
   27893 $at_diff $at_devnull $at_stderr || at_failed=:
   27894 $at_diff expout $at_stdout || at_failed=:
   27895 case $at_status in
   27896    77) echo 77 > $at_status_file
   27897             exit 77;;
   27898    0) ;;
   27899    *) echo "calc.at:569: exit code was $at_status, expected 0"
   27900       at_failed=:;;
   27901 esac
   27902 if $at_failed; then
   27903 
   27904   echo 1 > $at_status_file
   27905   exit 1
   27906 fi
   27907 
   27908 $at_traceon
   27909 
   27910 
   27911 
   27912 
   27913 
   27914 
   27915 
   27916 
   27917 
   27918 
   27919 
   27920 
   27921 
   27922 
   27923 
   27924 
   27925 
   27926 
   27927 
   27928 
   27929 
   27930 
   27931 
   27932 
   27933       $at_traceoff
   27934       $at_times_p && times >$at_times_file
   27935     ) 5>&1 2>&1 | eval $at_tee_pipe
   27936     at_status=`cat $at_status_file`
   27937     ;;
   27938 
   27939 
   27940   banner-10 ) # Banner 10. calc.at:576
   27941     cat <<\_ATEOF
   27942 
   27943 Simple GLR Calculator.
   27944 
   27945 _ATEOF
   27946     ;;
   27947 
   27948   84 ) # 84. calc.at:586: Calculator %glr-parser
   27949     at_setup_line='calc.at:586'
   27950     at_desc='Calculator %glr-parser '
   27951     $at_quiet $ECHO_N " 84: Calculator %glr-parser                       $ECHO_C"
   27952     at_xfail=no
   27953     (
   27954       echo "84. calc.at:586: testing ..."
   27955       $at_traceon
   27956 
   27957 
   27958 
   27959 
   27960 
   27961 
   27962 
   27963 
   27964 # Using yacc.c?
   27965 
   27966 
   27967 
   27968 
   27969 
   27970 
   27971 
   27972 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   27973 
   27974 # yyerror always sees the locations (when activated), except if
   27975 # yacc & pure & !param.
   27976 
   27977 
   27978 # The interface is pure: either because %pure-parser, or because we
   27979 # are using the C++ parsers.
   27980 
   27981 
   27982 
   27983 
   27984 
   27985 
   27986 
   27987 
   27988 
   27989 
   27990 
   27991 
   27992 cat >calc.y <<'_ATEOF'
   27993 %{
   27994 #ifdef HAVE_CONFIG_H
   27995 # include <config.h>
   27996   /* We don't need perfect functions for these tests. */
   27997 # undef malloc
   27998 # undef memcmp
   27999 # undef realloc
   28000 #endif
   28001 %}
   28002 
   28003 /* Infix notation calculator--calc */
   28004 %glr-parser
   28005 
   28006 %{
   28007 #include <stdio.h>
   28008 
   28009 #include <stdlib.h>
   28010 #include <string.h>
   28011 #if HAVE_UNISTD_H
   28012 # include <unistd.h>
   28013 #else
   28014 # undef alarm
   28015 # define alarm(seconds) /* empty */
   28016 #endif
   28017 #include <ctype.h>
   28018 #define USE(Var)
   28019 
   28020 /* Exercise pre-prologue dependency to %union.  */
   28021 typedef int semantic_value;
   28022 
   28023 static semantic_value global_result = 0;
   28024 static int global_count = 0;
   28025 %}
   28026 
   28027 /* Exercise %union. */
   28028 %union
   28029 {
   28030   semantic_value ival;
   28031 };
   28032 
   28033 %{
   28034 static int power (int base, int exponent);
   28035 /* yyerror receives the location if:
   28036    - %location & %pure & %glr
   28037    - %location & %pure & %yacc & %parse-param. */
   28038 static void yyerror (
   28039 
   28040                      const char *s
   28041                      );
   28042 static int yylex (void);
   28043 static int get_char (void);
   28044 static void unget_char ( int c);
   28045 %}
   28046 
   28047 
   28048 
   28049 /* Bison Declarations */
   28050 %token CALC_EOF 0 "end of input"
   28051 %token <ival> NUM "number"
   28052 %type  <ival> exp
   28053 
   28054 %nonassoc '=' /* comparison	       */
   28055 %left '-' '+'
   28056 %left '*' '/'
   28057 %left NEG     /* negation--unary minus */
   28058 %right '^'    /* exponentiation        */
   28059 
   28060 /* Grammar follows */
   28061 %%
   28062 input:
   28063   line
   28064 | input line         {  }
   28065 ;
   28066 
   28067 line:
   28068   '\n'
   28069 | exp '\n'           { USE ($1); }
   28070 ;
   28071 
   28072 exp:
   28073   NUM                { $$ = $1;             }
   28074 | exp '=' exp
   28075   {
   28076     if ($1 != $3)
   28077       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   28078     $$ = $1;
   28079   }
   28080 | exp '+' exp        { $$ = $1 + $3;        }
   28081 | exp '-' exp        { $$ = $1 - $3;        }
   28082 | exp '*' exp        { $$ = $1 * $3;        }
   28083 | exp '/' exp        { $$ = $1 / $3;        }
   28084 | '-' exp  %prec NEG { $$ = -$2;            }
   28085 | exp '^' exp        { $$ = power ($1, $3); }
   28086 | '(' exp ')'        { $$ = $2;             }
   28087 | '(' error ')'      { $$ = 1111;           }
   28088 | '!'                { $$ = 0; YYERROR;     }
   28089 | '-' error          { $$ = 0; YYERROR;     }
   28090 ;
   28091 %%
   28092 /* The input.  */
   28093 static FILE *input;
   28094 
   28095 static void
   28096 yyerror (
   28097 
   28098          const char *s)
   28099 {
   28100 
   28101 
   28102   fprintf (stderr, "%s\n", s);
   28103 }
   28104 
   28105 
   28106 
   28107 static int
   28108 get_char (void)
   28109 {
   28110   int res = getc (input);
   28111   ;
   28112 
   28113   return res;
   28114 }
   28115 
   28116 
   28117 static void
   28118 unget_char ( int c)
   28119 {
   28120   ;
   28121 
   28122   ungetc (c, input);
   28123 }
   28124 
   28125 static int
   28126 read_signed_integer (void)
   28127 {
   28128   int c = get_char ();
   28129   int sign = 1;
   28130   int n = 0;
   28131 
   28132   ;
   28133   if (c == '-')
   28134     {
   28135       c = get_char ();
   28136       sign = -1;
   28137     }
   28138 
   28139   while (isdigit (c))
   28140     {
   28141       n = 10 * n + (c - '0');
   28142       c = get_char ();
   28143     }
   28144 
   28145   unget_char ( c);
   28146 
   28147   return sign * n;
   28148 }
   28149 
   28150 
   28151 
   28152 /*---------------------------------------------------------------.
   28153 | Lexical analyzer returns an integer on the stack and the token |
   28154 | NUM, or the ASCII character read if not a number.  Skips all   |
   28155 | blanks and tabs, returns 0 for EOF.                            |
   28156 `---------------------------------------------------------------*/
   28157 
   28158 static int
   28159 yylex (void)
   28160 {
   28161   static int init = 1;
   28162   int c;
   28163 
   28164   if (init)
   28165     {
   28166       init = 0;
   28167 
   28168     }
   28169 
   28170 
   28171 
   28172   /* Skip white space.  */
   28173   while ((c = get_char ()) == ' ' || c == '\t')
   28174     {
   28175 
   28176     }
   28177 
   28178   /* process numbers   */
   28179   if (c == '.' || isdigit (c))
   28180     {
   28181       unget_char ( c);
   28182       (yylval).ival = read_signed_integer ();
   28183       return NUM;
   28184     }
   28185 
   28186   /* Return end-of-file.  */
   28187   if (c == EOF)
   28188     return CALC_EOF;
   28189 
   28190   /* Return single chars. */
   28191   return c;
   28192 }
   28193 
   28194 static int
   28195 power (int base, int exponent)
   28196 {
   28197   int res = 1;
   28198   if (exponent < 0)
   28199     exit (3);
   28200   for (/* Niente */; exponent; --exponent)
   28201     res *= base;
   28202   return res;
   28203 }
   28204 
   28205 
   28206 int
   28207 main (int argc, const char **argv)
   28208 {
   28209   semantic_value result = 0;
   28210   int count = 0;
   28211   int status;
   28212 
   28213   /* This used to be alarm (10), but that isn't enough time for
   28214      a July 1995 vintage DEC Alphastation 200 4/100 system,
   28215      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   28216   alarm (100);
   28217 
   28218   if (argc == 2)
   28219     input = fopen (argv[1], "r");
   28220   else
   28221     input = stdin;
   28222 
   28223   if (!input)
   28224     {
   28225       perror (argv[1]);
   28226       return 3;
   28227     }
   28228 
   28229 
   28230   status = yyparse ();
   28231   if (global_result != result)
   28232     abort ();
   28233   if (global_count != count)
   28234     abort ();
   28235   return status;
   28236 }
   28237 _ATEOF
   28238 
   28239 
   28240 
   28241 
   28242 
   28243 $at_traceoff
   28244 echo "calc.at:586: bison -o calc.c calc.y"
   28245 echo calc.at:586 >$at_check_line_file
   28246 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   28247 at_status=$?
   28248 grep '^ *+' $at_stder1 >&2
   28249 grep -v '^ *+' $at_stder1 >$at_stderr
   28250 at_failed=false
   28251 $at_diff $at_devnull $at_stderr || at_failed=:
   28252 $at_diff $at_devnull $at_stdout || at_failed=:
   28253 case $at_status in
   28254    77) echo 77 > $at_status_file
   28255             exit 77;;
   28256    0) ;;
   28257    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28258       at_failed=:;;
   28259 esac
   28260 if $at_failed; then
   28261 
   28262   echo 1 > $at_status_file
   28263   exit 1
   28264 fi
   28265 
   28266 $at_traceon
   28267 
   28268    $at_traceoff
   28269 echo "calc.at:586: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   28270 echo calc.at:586 >$at_check_line_file
   28271 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   28272 at_status=$?
   28273 grep '^ *+' $at_stder1 >&2
   28274 grep -v '^ *+' $at_stder1 >$at_stderr
   28275 at_failed=false
   28276 echo stderr:; cat $at_stderr
   28277 echo stdout:; cat $at_stdout
   28278 case $at_status in
   28279    77) echo 77 > $at_status_file
   28280             exit 77;;
   28281    0) ;;
   28282    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28283       at_failed=:;;
   28284 esac
   28285 if $at_failed; then
   28286 
   28287   echo 1 > $at_status_file
   28288   exit 1
   28289 fi
   28290 
   28291 $at_traceon
   28292 
   28293 
   28294 # Test the priorities.
   28295 cat >input <<'_ATEOF'
   28296 1 + 2 * 3 = 7
   28297 1 + 2 * -3 = -5
   28298 
   28299 -1^2 = -1
   28300 (-1)^2 = 1
   28301 
   28302 ---1 = -1
   28303 
   28304 1 - 2 - 3 = -4
   28305 1 - (2 - 3) = 2
   28306 
   28307 2^2^3 = 256
   28308 (2^2)^3 = 64
   28309 _ATEOF
   28310 
   28311 $at_traceoff
   28312 echo "calc.at:586: \$PREPARSER ./calc input"
   28313 echo calc.at:586 >$at_check_line_file
   28314 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   28315 at_status=$?
   28316 grep '^ *+' $at_stder1 >&2
   28317 grep -v '^ *+' $at_stder1 >$at_stderr
   28318 at_failed=false
   28319 echo stderr:; tee stderr <$at_stderr
   28320 $at_diff $at_devnull $at_stdout || at_failed=:
   28321 case $at_status in
   28322    77) echo 77 > $at_status_file
   28323             exit 77;;
   28324    0) ;;
   28325    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28326       at_failed=:;;
   28327 esac
   28328 if $at_failed; then
   28329 
   28330   echo 1 > $at_status_file
   28331   exit 1
   28332 fi
   28333 
   28334 $at_traceon
   28335 
   28336 
   28337 
   28338 # Some syntax errors.
   28339 cat >input <<'_ATEOF'
   28340 0 0
   28341 _ATEOF
   28342 
   28343 $at_traceoff
   28344 echo "calc.at:586: \$PREPARSER ./calc input"
   28345 echo calc.at:586 >$at_check_line_file
   28346 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   28347 at_status=$?
   28348 grep '^ *+' $at_stder1 >&2
   28349 grep -v '^ *+' $at_stder1 >$at_stderr
   28350 at_failed=false
   28351 echo stderr:; tee stderr <$at_stderr
   28352 $at_diff $at_devnull $at_stdout || at_failed=:
   28353 case $at_status in
   28354    77) echo 77 > $at_status_file
   28355             exit 77;;
   28356    1) ;;
   28357    *) echo "calc.at:586: exit code was $at_status, expected 1"
   28358       at_failed=:;;
   28359 esac
   28360 if $at_failed; then
   28361 
   28362   echo 1 > $at_status_file
   28363   exit 1
   28364 fi
   28365 
   28366 $at_traceon
   28367 
   28368 
   28369 # Normalize the observed and expected error messages, depending upon the
   28370 # options.
   28371 # 1. Remove the traces from observed.
   28372 sed '/^Starting/d
   28373 /^Entering/d
   28374 /^Stack/d
   28375 /^Reading/d
   28376 /^Reducing/d
   28377 /^Shifting/d
   28378 /^state/d
   28379 /^Cleanup:/d
   28380 /^Error:/d
   28381 /^Next/d
   28382 /^Discarding/d
   28383 / \$[0-9$]* = /d
   28384 /^yydestructor:/d' stderr >at-stderr
   28385 mv at-stderr stderr
   28386 # 2. Create the reference error message.
   28387 cat >expout <<'_ATEOF'
   28388 1.2: syntax error, unexpected number
   28389 _ATEOF
   28390 
   28391 # 3. If locations are not used, remove them.
   28392 sed 's/^[-0-9.]*: //' expout >at-expout
   28393 mv at-expout expout
   28394 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   28395 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   28396 mv at-expout expout
   28397 # 5. Check
   28398 $at_traceoff
   28399 echo "calc.at:586: cat stderr"
   28400 echo calc.at:586 >$at_check_line_file
   28401 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   28402 at_status=$?
   28403 grep '^ *+' $at_stder1 >&2
   28404 grep -v '^ *+' $at_stder1 >$at_stderr
   28405 at_failed=false
   28406 $at_diff $at_devnull $at_stderr || at_failed=:
   28407 $at_diff expout $at_stdout || at_failed=:
   28408 case $at_status in
   28409    77) echo 77 > $at_status_file
   28410             exit 77;;
   28411    0) ;;
   28412    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28413       at_failed=:;;
   28414 esac
   28415 if $at_failed; then
   28416 
   28417   echo 1 > $at_status_file
   28418   exit 1
   28419 fi
   28420 
   28421 $at_traceon
   28422 
   28423 
   28424 cat >input <<'_ATEOF'
   28425 1//2
   28426 _ATEOF
   28427 
   28428 $at_traceoff
   28429 echo "calc.at:586: \$PREPARSER ./calc input"
   28430 echo calc.at:586 >$at_check_line_file
   28431 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   28432 at_status=$?
   28433 grep '^ *+' $at_stder1 >&2
   28434 grep -v '^ *+' $at_stder1 >$at_stderr
   28435 at_failed=false
   28436 echo stderr:; tee stderr <$at_stderr
   28437 $at_diff $at_devnull $at_stdout || at_failed=:
   28438 case $at_status in
   28439    77) echo 77 > $at_status_file
   28440             exit 77;;
   28441    1) ;;
   28442    *) echo "calc.at:586: exit code was $at_status, expected 1"
   28443       at_failed=:;;
   28444 esac
   28445 if $at_failed; then
   28446 
   28447   echo 1 > $at_status_file
   28448   exit 1
   28449 fi
   28450 
   28451 $at_traceon
   28452 
   28453 
   28454 # Normalize the observed and expected error messages, depending upon the
   28455 # options.
   28456 # 1. Remove the traces from observed.
   28457 sed '/^Starting/d
   28458 /^Entering/d
   28459 /^Stack/d
   28460 /^Reading/d
   28461 /^Reducing/d
   28462 /^Shifting/d
   28463 /^state/d
   28464 /^Cleanup:/d
   28465 /^Error:/d
   28466 /^Next/d
   28467 /^Discarding/d
   28468 / \$[0-9$]* = /d
   28469 /^yydestructor:/d' stderr >at-stderr
   28470 mv at-stderr stderr
   28471 # 2. Create the reference error message.
   28472 cat >expout <<'_ATEOF'
   28473 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   28474 _ATEOF
   28475 
   28476 # 3. If locations are not used, remove them.
   28477 sed 's/^[-0-9.]*: //' expout >at-expout
   28478 mv at-expout expout
   28479 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   28480 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   28481 mv at-expout expout
   28482 # 5. Check
   28483 $at_traceoff
   28484 echo "calc.at:586: cat stderr"
   28485 echo calc.at:586 >$at_check_line_file
   28486 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   28487 at_status=$?
   28488 grep '^ *+' $at_stder1 >&2
   28489 grep -v '^ *+' $at_stder1 >$at_stderr
   28490 at_failed=false
   28491 $at_diff $at_devnull $at_stderr || at_failed=:
   28492 $at_diff expout $at_stdout || at_failed=:
   28493 case $at_status in
   28494    77) echo 77 > $at_status_file
   28495             exit 77;;
   28496    0) ;;
   28497    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28498       at_failed=:;;
   28499 esac
   28500 if $at_failed; then
   28501 
   28502   echo 1 > $at_status_file
   28503   exit 1
   28504 fi
   28505 
   28506 $at_traceon
   28507 
   28508 
   28509 cat >input <<'_ATEOF'
   28510 error
   28511 _ATEOF
   28512 
   28513 $at_traceoff
   28514 echo "calc.at:586: \$PREPARSER ./calc input"
   28515 echo calc.at:586 >$at_check_line_file
   28516 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   28517 at_status=$?
   28518 grep '^ *+' $at_stder1 >&2
   28519 grep -v '^ *+' $at_stder1 >$at_stderr
   28520 at_failed=false
   28521 echo stderr:; tee stderr <$at_stderr
   28522 $at_diff $at_devnull $at_stdout || at_failed=:
   28523 case $at_status in
   28524    77) echo 77 > $at_status_file
   28525             exit 77;;
   28526    1) ;;
   28527    *) echo "calc.at:586: exit code was $at_status, expected 1"
   28528       at_failed=:;;
   28529 esac
   28530 if $at_failed; then
   28531 
   28532   echo 1 > $at_status_file
   28533   exit 1
   28534 fi
   28535 
   28536 $at_traceon
   28537 
   28538 
   28539 # Normalize the observed and expected error messages, depending upon the
   28540 # options.
   28541 # 1. Remove the traces from observed.
   28542 sed '/^Starting/d
   28543 /^Entering/d
   28544 /^Stack/d
   28545 /^Reading/d
   28546 /^Reducing/d
   28547 /^Shifting/d
   28548 /^state/d
   28549 /^Cleanup:/d
   28550 /^Error:/d
   28551 /^Next/d
   28552 /^Discarding/d
   28553 / \$[0-9$]* = /d
   28554 /^yydestructor:/d' stderr >at-stderr
   28555 mv at-stderr stderr
   28556 # 2. Create the reference error message.
   28557 cat >expout <<'_ATEOF'
   28558 1.0: syntax error, unexpected $undefined
   28559 _ATEOF
   28560 
   28561 # 3. If locations are not used, remove them.
   28562 sed 's/^[-0-9.]*: //' expout >at-expout
   28563 mv at-expout expout
   28564 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   28565 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   28566 mv at-expout expout
   28567 # 5. Check
   28568 $at_traceoff
   28569 echo "calc.at:586: cat stderr"
   28570 echo calc.at:586 >$at_check_line_file
   28571 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   28572 at_status=$?
   28573 grep '^ *+' $at_stder1 >&2
   28574 grep -v '^ *+' $at_stder1 >$at_stderr
   28575 at_failed=false
   28576 $at_diff $at_devnull $at_stderr || at_failed=:
   28577 $at_diff expout $at_stdout || at_failed=:
   28578 case $at_status in
   28579    77) echo 77 > $at_status_file
   28580             exit 77;;
   28581    0) ;;
   28582    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28583       at_failed=:;;
   28584 esac
   28585 if $at_failed; then
   28586 
   28587   echo 1 > $at_status_file
   28588   exit 1
   28589 fi
   28590 
   28591 $at_traceon
   28592 
   28593 
   28594 cat >input <<'_ATEOF'
   28595 1 = 2 = 3
   28596 _ATEOF
   28597 
   28598 $at_traceoff
   28599 echo "calc.at:586: \$PREPARSER ./calc input"
   28600 echo calc.at:586 >$at_check_line_file
   28601 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   28602 at_status=$?
   28603 grep '^ *+' $at_stder1 >&2
   28604 grep -v '^ *+' $at_stder1 >$at_stderr
   28605 at_failed=false
   28606 echo stderr:; tee stderr <$at_stderr
   28607 $at_diff $at_devnull $at_stdout || at_failed=:
   28608 case $at_status in
   28609    77) echo 77 > $at_status_file
   28610             exit 77;;
   28611    1) ;;
   28612    *) echo "calc.at:586: exit code was $at_status, expected 1"
   28613       at_failed=:;;
   28614 esac
   28615 if $at_failed; then
   28616 
   28617   echo 1 > $at_status_file
   28618   exit 1
   28619 fi
   28620 
   28621 $at_traceon
   28622 
   28623 
   28624 # Normalize the observed and expected error messages, depending upon the
   28625 # options.
   28626 # 1. Remove the traces from observed.
   28627 sed '/^Starting/d
   28628 /^Entering/d
   28629 /^Stack/d
   28630 /^Reading/d
   28631 /^Reducing/d
   28632 /^Shifting/d
   28633 /^state/d
   28634 /^Cleanup:/d
   28635 /^Error:/d
   28636 /^Next/d
   28637 /^Discarding/d
   28638 / \$[0-9$]* = /d
   28639 /^yydestructor:/d' stderr >at-stderr
   28640 mv at-stderr stderr
   28641 # 2. Create the reference error message.
   28642 cat >expout <<'_ATEOF'
   28643 1.6: syntax error, unexpected '='
   28644 _ATEOF
   28645 
   28646 # 3. If locations are not used, remove them.
   28647 sed 's/^[-0-9.]*: //' expout >at-expout
   28648 mv at-expout expout
   28649 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   28650 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   28651 mv at-expout expout
   28652 # 5. Check
   28653 $at_traceoff
   28654 echo "calc.at:586: cat stderr"
   28655 echo calc.at:586 >$at_check_line_file
   28656 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   28657 at_status=$?
   28658 grep '^ *+' $at_stder1 >&2
   28659 grep -v '^ *+' $at_stder1 >$at_stderr
   28660 at_failed=false
   28661 $at_diff $at_devnull $at_stderr || at_failed=:
   28662 $at_diff expout $at_stdout || at_failed=:
   28663 case $at_status in
   28664    77) echo 77 > $at_status_file
   28665             exit 77;;
   28666    0) ;;
   28667    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28668       at_failed=:;;
   28669 esac
   28670 if $at_failed; then
   28671 
   28672   echo 1 > $at_status_file
   28673   exit 1
   28674 fi
   28675 
   28676 $at_traceon
   28677 
   28678 
   28679 cat >input <<'_ATEOF'
   28680 
   28681 +1
   28682 _ATEOF
   28683 
   28684 $at_traceoff
   28685 echo "calc.at:586: \$PREPARSER ./calc input"
   28686 echo calc.at:586 >$at_check_line_file
   28687 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   28688 at_status=$?
   28689 grep '^ *+' $at_stder1 >&2
   28690 grep -v '^ *+' $at_stder1 >$at_stderr
   28691 at_failed=false
   28692 echo stderr:; tee stderr <$at_stderr
   28693 $at_diff $at_devnull $at_stdout || at_failed=:
   28694 case $at_status in
   28695    77) echo 77 > $at_status_file
   28696             exit 77;;
   28697    1) ;;
   28698    *) echo "calc.at:586: exit code was $at_status, expected 1"
   28699       at_failed=:;;
   28700 esac
   28701 if $at_failed; then
   28702 
   28703   echo 1 > $at_status_file
   28704   exit 1
   28705 fi
   28706 
   28707 $at_traceon
   28708 
   28709 
   28710 # Normalize the observed and expected error messages, depending upon the
   28711 # options.
   28712 # 1. Remove the traces from observed.
   28713 sed '/^Starting/d
   28714 /^Entering/d
   28715 /^Stack/d
   28716 /^Reading/d
   28717 /^Reducing/d
   28718 /^Shifting/d
   28719 /^state/d
   28720 /^Cleanup:/d
   28721 /^Error:/d
   28722 /^Next/d
   28723 /^Discarding/d
   28724 / \$[0-9$]* = /d
   28725 /^yydestructor:/d' stderr >at-stderr
   28726 mv at-stderr stderr
   28727 # 2. Create the reference error message.
   28728 cat >expout <<'_ATEOF'
   28729 2.0: syntax error, unexpected '+'
   28730 _ATEOF
   28731 
   28732 # 3. If locations are not used, remove them.
   28733 sed 's/^[-0-9.]*: //' expout >at-expout
   28734 mv at-expout expout
   28735 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   28736 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   28737 mv at-expout expout
   28738 # 5. Check
   28739 $at_traceoff
   28740 echo "calc.at:586: cat stderr"
   28741 echo calc.at:586 >$at_check_line_file
   28742 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   28743 at_status=$?
   28744 grep '^ *+' $at_stder1 >&2
   28745 grep -v '^ *+' $at_stder1 >$at_stderr
   28746 at_failed=false
   28747 $at_diff $at_devnull $at_stderr || at_failed=:
   28748 $at_diff expout $at_stdout || at_failed=:
   28749 case $at_status in
   28750    77) echo 77 > $at_status_file
   28751             exit 77;;
   28752    0) ;;
   28753    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28754       at_failed=:;;
   28755 esac
   28756 if $at_failed; then
   28757 
   28758   echo 1 > $at_status_file
   28759   exit 1
   28760 fi
   28761 
   28762 $at_traceon
   28763 
   28764 
   28765 # Exercise error messages with EOF: work on an empty file.
   28766 $at_traceoff
   28767 echo "calc.at:586: \$PREPARSER ./calc /dev/null"
   28768 echo calc.at:586 >$at_check_line_file
   28769 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   28770 at_status=$?
   28771 grep '^ *+' $at_stder1 >&2
   28772 grep -v '^ *+' $at_stder1 >$at_stderr
   28773 at_failed=false
   28774 echo stderr:; tee stderr <$at_stderr
   28775 $at_diff $at_devnull $at_stdout || at_failed=:
   28776 case $at_status in
   28777    77) echo 77 > $at_status_file
   28778             exit 77;;
   28779    1) ;;
   28780    *) echo "calc.at:586: exit code was $at_status, expected 1"
   28781       at_failed=:;;
   28782 esac
   28783 if $at_failed; then
   28784 
   28785   echo 1 > $at_status_file
   28786   exit 1
   28787 fi
   28788 
   28789 $at_traceon
   28790 
   28791 
   28792 # Normalize the observed and expected error messages, depending upon the
   28793 # options.
   28794 # 1. Remove the traces from observed.
   28795 sed '/^Starting/d
   28796 /^Entering/d
   28797 /^Stack/d
   28798 /^Reading/d
   28799 /^Reducing/d
   28800 /^Shifting/d
   28801 /^state/d
   28802 /^Cleanup:/d
   28803 /^Error:/d
   28804 /^Next/d
   28805 /^Discarding/d
   28806 / \$[0-9$]* = /d
   28807 /^yydestructor:/d' stderr >at-stderr
   28808 mv at-stderr stderr
   28809 # 2. Create the reference error message.
   28810 cat >expout <<'_ATEOF'
   28811 1.0: syntax error, unexpected end of input
   28812 _ATEOF
   28813 
   28814 # 3. If locations are not used, remove them.
   28815 sed 's/^[-0-9.]*: //' expout >at-expout
   28816 mv at-expout expout
   28817 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   28818 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   28819 mv at-expout expout
   28820 # 5. Check
   28821 $at_traceoff
   28822 echo "calc.at:586: cat stderr"
   28823 echo calc.at:586 >$at_check_line_file
   28824 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   28825 at_status=$?
   28826 grep '^ *+' $at_stder1 >&2
   28827 grep -v '^ *+' $at_stder1 >$at_stderr
   28828 at_failed=false
   28829 $at_diff $at_devnull $at_stderr || at_failed=:
   28830 $at_diff expout $at_stdout || at_failed=:
   28831 case $at_status in
   28832    77) echo 77 > $at_status_file
   28833             exit 77;;
   28834    0) ;;
   28835    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28836       at_failed=:;;
   28837 esac
   28838 if $at_failed; then
   28839 
   28840   echo 1 > $at_status_file
   28841   exit 1
   28842 fi
   28843 
   28844 $at_traceon
   28845 
   28846 
   28847 
   28848 # Exercise the error token: without it, we die at the first error,
   28849 # hence be sure to
   28850 #
   28851 # - have several errors which exercise different shift/discardings
   28852 #   - (): nothing to pop, nothing to discard
   28853 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   28854 #   - (* * *): nothing to pop, a lot to discard
   28855 #   - (1 + 2 * *): some to pop and discard
   28856 #
   28857 # - test the action associated to `error'
   28858 #
   28859 # - check the look-ahead that triggers an error is not discarded
   28860 #   when we enter error recovery.  Below, the look-ahead causing the
   28861 #   first error is ")", which is needed to recover from the error and
   28862 #   produce the "0" that triggers the "0 != 1" error.
   28863 #
   28864 cat >input <<'_ATEOF'
   28865 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   28866 _ATEOF
   28867 
   28868 $at_traceoff
   28869 echo "calc.at:586: \$PREPARSER ./calc input"
   28870 echo calc.at:586 >$at_check_line_file
   28871 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   28872 at_status=$?
   28873 grep '^ *+' $at_stder1 >&2
   28874 grep -v '^ *+' $at_stder1 >$at_stderr
   28875 at_failed=false
   28876 echo stderr:; tee stderr <$at_stderr
   28877 $at_diff $at_devnull $at_stdout || at_failed=:
   28878 case $at_status in
   28879    77) echo 77 > $at_status_file
   28880             exit 77;;
   28881    0) ;;
   28882    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28883       at_failed=:;;
   28884 esac
   28885 if $at_failed; then
   28886 
   28887   echo 1 > $at_status_file
   28888   exit 1
   28889 fi
   28890 
   28891 $at_traceon
   28892 
   28893 
   28894 # Normalize the observed and expected error messages, depending upon the
   28895 # options.
   28896 # 1. Remove the traces from observed.
   28897 sed '/^Starting/d
   28898 /^Entering/d
   28899 /^Stack/d
   28900 /^Reading/d
   28901 /^Reducing/d
   28902 /^Shifting/d
   28903 /^state/d
   28904 /^Cleanup:/d
   28905 /^Error:/d
   28906 /^Next/d
   28907 /^Discarding/d
   28908 / \$[0-9$]* = /d
   28909 /^yydestructor:/d' stderr >at-stderr
   28910 mv at-stderr stderr
   28911 # 2. Create the reference error message.
   28912 cat >expout <<'_ATEOF'
   28913 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   28914 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   28915 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   28916 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   28917 calc: error: 4444 != 1
   28918 _ATEOF
   28919 
   28920 # 3. If locations are not used, remove them.
   28921 sed 's/^[-0-9.]*: //' expout >at-expout
   28922 mv at-expout expout
   28923 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   28924 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   28925 mv at-expout expout
   28926 # 5. Check
   28927 $at_traceoff
   28928 echo "calc.at:586: cat stderr"
   28929 echo calc.at:586 >$at_check_line_file
   28930 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   28931 at_status=$?
   28932 grep '^ *+' $at_stder1 >&2
   28933 grep -v '^ *+' $at_stder1 >$at_stderr
   28934 at_failed=false
   28935 $at_diff $at_devnull $at_stderr || at_failed=:
   28936 $at_diff expout $at_stdout || at_failed=:
   28937 case $at_status in
   28938    77) echo 77 > $at_status_file
   28939             exit 77;;
   28940    0) ;;
   28941    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28942       at_failed=:;;
   28943 esac
   28944 if $at_failed; then
   28945 
   28946   echo 1 > $at_status_file
   28947   exit 1
   28948 fi
   28949 
   28950 $at_traceon
   28951 
   28952 
   28953 
   28954 # The same, but this time exercising explicitly triggered syntax errors.
   28955 # POSIX says the look-ahead causing the error should not be discarded.
   28956 cat >input <<'_ATEOF'
   28957 (!) + (0 0) = 1
   28958 _ATEOF
   28959 
   28960 $at_traceoff
   28961 echo "calc.at:586: \$PREPARSER ./calc input"
   28962 echo calc.at:586 >$at_check_line_file
   28963 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   28964 at_status=$?
   28965 grep '^ *+' $at_stder1 >&2
   28966 grep -v '^ *+' $at_stder1 >$at_stderr
   28967 at_failed=false
   28968 echo stderr:; tee stderr <$at_stderr
   28969 $at_diff $at_devnull $at_stdout || at_failed=:
   28970 case $at_status in
   28971    77) echo 77 > $at_status_file
   28972             exit 77;;
   28973    0) ;;
   28974    *) echo "calc.at:586: exit code was $at_status, expected 0"
   28975       at_failed=:;;
   28976 esac
   28977 if $at_failed; then
   28978 
   28979   echo 1 > $at_status_file
   28980   exit 1
   28981 fi
   28982 
   28983 $at_traceon
   28984 
   28985 
   28986 # Normalize the observed and expected error messages, depending upon the
   28987 # options.
   28988 # 1. Remove the traces from observed.
   28989 sed '/^Starting/d
   28990 /^Entering/d
   28991 /^Stack/d
   28992 /^Reading/d
   28993 /^Reducing/d
   28994 /^Shifting/d
   28995 /^state/d
   28996 /^Cleanup:/d
   28997 /^Error:/d
   28998 /^Next/d
   28999 /^Discarding/d
   29000 / \$[0-9$]* = /d
   29001 /^yydestructor:/d' stderr >at-stderr
   29002 mv at-stderr stderr
   29003 # 2. Create the reference error message.
   29004 cat >expout <<'_ATEOF'
   29005 1.9: syntax error, unexpected number
   29006 calc: error: 2222 != 1
   29007 _ATEOF
   29008 
   29009 # 3. If locations are not used, remove them.
   29010 sed 's/^[-0-9.]*: //' expout >at-expout
   29011 mv at-expout expout
   29012 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   29013 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   29014 mv at-expout expout
   29015 # 5. Check
   29016 $at_traceoff
   29017 echo "calc.at:586: cat stderr"
   29018 echo calc.at:586 >$at_check_line_file
   29019 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   29020 at_status=$?
   29021 grep '^ *+' $at_stder1 >&2
   29022 grep -v '^ *+' $at_stder1 >$at_stderr
   29023 at_failed=false
   29024 $at_diff $at_devnull $at_stderr || at_failed=:
   29025 $at_diff expout $at_stdout || at_failed=:
   29026 case $at_status in
   29027    77) echo 77 > $at_status_file
   29028             exit 77;;
   29029    0) ;;
   29030    *) echo "calc.at:586: exit code was $at_status, expected 0"
   29031       at_failed=:;;
   29032 esac
   29033 if $at_failed; then
   29034 
   29035   echo 1 > $at_status_file
   29036   exit 1
   29037 fi
   29038 
   29039 $at_traceon
   29040 
   29041 
   29042 cat >input <<'_ATEOF'
   29043 (- *) + (0 0) = 1
   29044 _ATEOF
   29045 
   29046 $at_traceoff
   29047 echo "calc.at:586: \$PREPARSER ./calc input"
   29048 echo calc.at:586 >$at_check_line_file
   29049 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   29050 at_status=$?
   29051 grep '^ *+' $at_stder1 >&2
   29052 grep -v '^ *+' $at_stder1 >$at_stderr
   29053 at_failed=false
   29054 echo stderr:; tee stderr <$at_stderr
   29055 $at_diff $at_devnull $at_stdout || at_failed=:
   29056 case $at_status in
   29057    77) echo 77 > $at_status_file
   29058             exit 77;;
   29059    0) ;;
   29060    *) echo "calc.at:586: exit code was $at_status, expected 0"
   29061       at_failed=:;;
   29062 esac
   29063 if $at_failed; then
   29064 
   29065   echo 1 > $at_status_file
   29066   exit 1
   29067 fi
   29068 
   29069 $at_traceon
   29070 
   29071 
   29072 # Normalize the observed and expected error messages, depending upon the
   29073 # options.
   29074 # 1. Remove the traces from observed.
   29075 sed '/^Starting/d
   29076 /^Entering/d
   29077 /^Stack/d
   29078 /^Reading/d
   29079 /^Reducing/d
   29080 /^Shifting/d
   29081 /^state/d
   29082 /^Cleanup:/d
   29083 /^Error:/d
   29084 /^Next/d
   29085 /^Discarding/d
   29086 / \$[0-9$]* = /d
   29087 /^yydestructor:/d' stderr >at-stderr
   29088 mv at-stderr stderr
   29089 # 2. Create the reference error message.
   29090 cat >expout <<'_ATEOF'
   29091 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   29092 1.11: syntax error, unexpected number
   29093 calc: error: 2222 != 1
   29094 _ATEOF
   29095 
   29096 # 3. If locations are not used, remove them.
   29097 sed 's/^[-0-9.]*: //' expout >at-expout
   29098 mv at-expout expout
   29099 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   29100 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   29101 mv at-expout expout
   29102 # 5. Check
   29103 $at_traceoff
   29104 echo "calc.at:586: cat stderr"
   29105 echo calc.at:586 >$at_check_line_file
   29106 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   29107 at_status=$?
   29108 grep '^ *+' $at_stder1 >&2
   29109 grep -v '^ *+' $at_stder1 >$at_stderr
   29110 at_failed=false
   29111 $at_diff $at_devnull $at_stderr || at_failed=:
   29112 $at_diff expout $at_stdout || at_failed=:
   29113 case $at_status in
   29114    77) echo 77 > $at_status_file
   29115             exit 77;;
   29116    0) ;;
   29117    *) echo "calc.at:586: exit code was $at_status, expected 0"
   29118       at_failed=:;;
   29119 esac
   29120 if $at_failed; then
   29121 
   29122   echo 1 > $at_status_file
   29123   exit 1
   29124 fi
   29125 
   29126 $at_traceon
   29127 
   29128 
   29129 
   29130 
   29131 
   29132 
   29133 
   29134 
   29135 
   29136 
   29137 
   29138 
   29139 
   29140 
   29141 
   29142 
   29143 
   29144 
   29145 
   29146 
   29147 
   29148 
   29149 
   29150 
   29151       $at_traceoff
   29152       $at_times_p && times >$at_times_file
   29153     ) 5>&1 2>&1 | eval $at_tee_pipe
   29154     at_status=`cat $at_status_file`
   29155     ;;
   29156 
   29157   85 ) # 85. calc.at:588: Calculator %glr-parser %defines
   29158     at_setup_line='calc.at:588'
   29159     at_desc='Calculator %glr-parser %defines'
   29160     $at_quiet $ECHO_N " 85: Calculator %glr-parser %defines              $ECHO_C"
   29161     at_xfail=no
   29162     (
   29163       echo "85. calc.at:588: testing ..."
   29164       $at_traceon
   29165 
   29166 
   29167 
   29168 
   29169 
   29170 
   29171 
   29172 
   29173 # Using yacc.c?
   29174 
   29175 
   29176 
   29177 
   29178 
   29179 
   29180 
   29181 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   29182 
   29183 # yyerror always sees the locations (when activated), except if
   29184 # yacc & pure & !param.
   29185 
   29186 
   29187 # The interface is pure: either because %pure-parser, or because we
   29188 # are using the C++ parsers.
   29189 
   29190 
   29191 
   29192 
   29193 
   29194 
   29195 
   29196 
   29197 
   29198 
   29199 
   29200 
   29201 cat >calc.y <<'_ATEOF'
   29202 %{
   29203 #ifdef HAVE_CONFIG_H
   29204 # include <config.h>
   29205   /* We don't need perfect functions for these tests. */
   29206 # undef malloc
   29207 # undef memcmp
   29208 # undef realloc
   29209 #endif
   29210 %}
   29211 
   29212 /* Infix notation calculator--calc */
   29213 %glr-parser %defines
   29214 
   29215 %{
   29216 #include <stdio.h>
   29217 
   29218 #include <stdlib.h>
   29219 #include <string.h>
   29220 #if HAVE_UNISTD_H
   29221 # include <unistd.h>
   29222 #else
   29223 # undef alarm
   29224 # define alarm(seconds) /* empty */
   29225 #endif
   29226 #include <ctype.h>
   29227 #define USE(Var)
   29228 
   29229 /* Exercise pre-prologue dependency to %union.  */
   29230 typedef int semantic_value;
   29231 
   29232 static semantic_value global_result = 0;
   29233 static int global_count = 0;
   29234 %}
   29235 
   29236 /* Exercise %union. */
   29237 %union
   29238 {
   29239   semantic_value ival;
   29240 };
   29241 
   29242 %{
   29243 static int power (int base, int exponent);
   29244 /* yyerror receives the location if:
   29245    - %location & %pure & %glr
   29246    - %location & %pure & %yacc & %parse-param. */
   29247 static void yyerror (
   29248 
   29249                      const char *s
   29250                      );
   29251 static int yylex (void);
   29252 static int get_char (void);
   29253 static void unget_char ( int c);
   29254 %}
   29255 
   29256 
   29257 
   29258 /* Bison Declarations */
   29259 %token CALC_EOF 0 "end of input"
   29260 %token <ival> NUM "number"
   29261 %type  <ival> exp
   29262 
   29263 %nonassoc '=' /* comparison	       */
   29264 %left '-' '+'
   29265 %left '*' '/'
   29266 %left NEG     /* negation--unary minus */
   29267 %right '^'    /* exponentiation        */
   29268 
   29269 /* Grammar follows */
   29270 %%
   29271 input:
   29272   line
   29273 | input line         {  }
   29274 ;
   29275 
   29276 line:
   29277   '\n'
   29278 | exp '\n'           { USE ($1); }
   29279 ;
   29280 
   29281 exp:
   29282   NUM                { $$ = $1;             }
   29283 | exp '=' exp
   29284   {
   29285     if ($1 != $3)
   29286       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   29287     $$ = $1;
   29288   }
   29289 | exp '+' exp        { $$ = $1 + $3;        }
   29290 | exp '-' exp        { $$ = $1 - $3;        }
   29291 | exp '*' exp        { $$ = $1 * $3;        }
   29292 | exp '/' exp        { $$ = $1 / $3;        }
   29293 | '-' exp  %prec NEG { $$ = -$2;            }
   29294 | exp '^' exp        { $$ = power ($1, $3); }
   29295 | '(' exp ')'        { $$ = $2;             }
   29296 | '(' error ')'      { $$ = 1111;           }
   29297 | '!'                { $$ = 0; YYERROR;     }
   29298 | '-' error          { $$ = 0; YYERROR;     }
   29299 ;
   29300 %%
   29301 /* The input.  */
   29302 static FILE *input;
   29303 
   29304 static void
   29305 yyerror (
   29306 
   29307          const char *s)
   29308 {
   29309 
   29310 
   29311   fprintf (stderr, "%s\n", s);
   29312 }
   29313 
   29314 
   29315 
   29316 static int
   29317 get_char (void)
   29318 {
   29319   int res = getc (input);
   29320   ;
   29321 
   29322   return res;
   29323 }
   29324 
   29325 
   29326 static void
   29327 unget_char ( int c)
   29328 {
   29329   ;
   29330 
   29331   ungetc (c, input);
   29332 }
   29333 
   29334 static int
   29335 read_signed_integer (void)
   29336 {
   29337   int c = get_char ();
   29338   int sign = 1;
   29339   int n = 0;
   29340 
   29341   ;
   29342   if (c == '-')
   29343     {
   29344       c = get_char ();
   29345       sign = -1;
   29346     }
   29347 
   29348   while (isdigit (c))
   29349     {
   29350       n = 10 * n + (c - '0');
   29351       c = get_char ();
   29352     }
   29353 
   29354   unget_char ( c);
   29355 
   29356   return sign * n;
   29357 }
   29358 
   29359 
   29360 
   29361 /*---------------------------------------------------------------.
   29362 | Lexical analyzer returns an integer on the stack and the token |
   29363 | NUM, or the ASCII character read if not a number.  Skips all   |
   29364 | blanks and tabs, returns 0 for EOF.                            |
   29365 `---------------------------------------------------------------*/
   29366 
   29367 static int
   29368 yylex (void)
   29369 {
   29370   static int init = 1;
   29371   int c;
   29372 
   29373   if (init)
   29374     {
   29375       init = 0;
   29376 
   29377     }
   29378 
   29379 
   29380 
   29381   /* Skip white space.  */
   29382   while ((c = get_char ()) == ' ' || c == '\t')
   29383     {
   29384 
   29385     }
   29386 
   29387   /* process numbers   */
   29388   if (c == '.' || isdigit (c))
   29389     {
   29390       unget_char ( c);
   29391       (yylval).ival = read_signed_integer ();
   29392       return NUM;
   29393     }
   29394 
   29395   /* Return end-of-file.  */
   29396   if (c == EOF)
   29397     return CALC_EOF;
   29398 
   29399   /* Return single chars. */
   29400   return c;
   29401 }
   29402 
   29403 static int
   29404 power (int base, int exponent)
   29405 {
   29406   int res = 1;
   29407   if (exponent < 0)
   29408     exit (3);
   29409   for (/* Niente */; exponent; --exponent)
   29410     res *= base;
   29411   return res;
   29412 }
   29413 
   29414 
   29415 int
   29416 main (int argc, const char **argv)
   29417 {
   29418   semantic_value result = 0;
   29419   int count = 0;
   29420   int status;
   29421 
   29422   /* This used to be alarm (10), but that isn't enough time for
   29423      a July 1995 vintage DEC Alphastation 200 4/100 system,
   29424      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   29425   alarm (100);
   29426 
   29427   if (argc == 2)
   29428     input = fopen (argv[1], "r");
   29429   else
   29430     input = stdin;
   29431 
   29432   if (!input)
   29433     {
   29434       perror (argv[1]);
   29435       return 3;
   29436     }
   29437 
   29438 
   29439   status = yyparse ();
   29440   if (global_result != result)
   29441     abort ();
   29442   if (global_count != count)
   29443     abort ();
   29444   return status;
   29445 }
   29446 _ATEOF
   29447 
   29448 
   29449 
   29450 
   29451 
   29452 $at_traceoff
   29453 echo "calc.at:588: bison -o calc.c calc.y"
   29454 echo calc.at:588 >$at_check_line_file
   29455 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   29456 at_status=$?
   29457 grep '^ *+' $at_stder1 >&2
   29458 grep -v '^ *+' $at_stder1 >$at_stderr
   29459 at_failed=false
   29460 $at_diff $at_devnull $at_stderr || at_failed=:
   29461 $at_diff $at_devnull $at_stdout || at_failed=:
   29462 case $at_status in
   29463    77) echo 77 > $at_status_file
   29464             exit 77;;
   29465    0) ;;
   29466    *) echo "calc.at:588: exit code was $at_status, expected 0"
   29467       at_failed=:;;
   29468 esac
   29469 if $at_failed; then
   29470 
   29471   echo 1 > $at_status_file
   29472   exit 1
   29473 fi
   29474 
   29475 $at_traceon
   29476 
   29477    $at_traceoff
   29478 echo "calc.at:588: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   29479 echo calc.at:588 >$at_check_line_file
   29480 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   29481 at_status=$?
   29482 grep '^ *+' $at_stder1 >&2
   29483 grep -v '^ *+' $at_stder1 >$at_stderr
   29484 at_failed=false
   29485 echo stderr:; cat $at_stderr
   29486 echo stdout:; cat $at_stdout
   29487 case $at_status in
   29488    77) echo 77 > $at_status_file
   29489             exit 77;;
   29490    0) ;;
   29491    *) echo "calc.at:588: exit code was $at_status, expected 0"
   29492       at_failed=:;;
   29493 esac
   29494 if $at_failed; then
   29495 
   29496   echo 1 > $at_status_file
   29497   exit 1
   29498 fi
   29499 
   29500 $at_traceon
   29501 
   29502 
   29503 # Test the priorities.
   29504 cat >input <<'_ATEOF'
   29505 1 + 2 * 3 = 7
   29506 1 + 2 * -3 = -5
   29507 
   29508 -1^2 = -1
   29509 (-1)^2 = 1
   29510 
   29511 ---1 = -1
   29512 
   29513 1 - 2 - 3 = -4
   29514 1 - (2 - 3) = 2
   29515 
   29516 2^2^3 = 256
   29517 (2^2)^3 = 64
   29518 _ATEOF
   29519 
   29520 $at_traceoff
   29521 echo "calc.at:588: \$PREPARSER ./calc input"
   29522 echo calc.at:588 >$at_check_line_file
   29523 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   29524 at_status=$?
   29525 grep '^ *+' $at_stder1 >&2
   29526 grep -v '^ *+' $at_stder1 >$at_stderr
   29527 at_failed=false
   29528 echo stderr:; tee stderr <$at_stderr
   29529 $at_diff $at_devnull $at_stdout || at_failed=:
   29530 case $at_status in
   29531    77) echo 77 > $at_status_file
   29532             exit 77;;
   29533    0) ;;
   29534    *) echo "calc.at:588: exit code was $at_status, expected 0"
   29535       at_failed=:;;
   29536 esac
   29537 if $at_failed; then
   29538 
   29539   echo 1 > $at_status_file
   29540   exit 1
   29541 fi
   29542 
   29543 $at_traceon
   29544 
   29545 
   29546 
   29547 # Some syntax errors.
   29548 cat >input <<'_ATEOF'
   29549 0 0
   29550 _ATEOF
   29551 
   29552 $at_traceoff
   29553 echo "calc.at:588: \$PREPARSER ./calc input"
   29554 echo calc.at:588 >$at_check_line_file
   29555 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   29556 at_status=$?
   29557 grep '^ *+' $at_stder1 >&2
   29558 grep -v '^ *+' $at_stder1 >$at_stderr
   29559 at_failed=false
   29560 echo stderr:; tee stderr <$at_stderr
   29561 $at_diff $at_devnull $at_stdout || at_failed=:
   29562 case $at_status in
   29563    77) echo 77 > $at_status_file
   29564             exit 77;;
   29565    1) ;;
   29566    *) echo "calc.at:588: exit code was $at_status, expected 1"
   29567       at_failed=:;;
   29568 esac
   29569 if $at_failed; then
   29570 
   29571   echo 1 > $at_status_file
   29572   exit 1
   29573 fi
   29574 
   29575 $at_traceon
   29576 
   29577 
   29578 # Normalize the observed and expected error messages, depending upon the
   29579 # options.
   29580 # 1. Remove the traces from observed.
   29581 sed '/^Starting/d
   29582 /^Entering/d
   29583 /^Stack/d
   29584 /^Reading/d
   29585 /^Reducing/d
   29586 /^Shifting/d
   29587 /^state/d
   29588 /^Cleanup:/d
   29589 /^Error:/d
   29590 /^Next/d
   29591 /^Discarding/d
   29592 / \$[0-9$]* = /d
   29593 /^yydestructor:/d' stderr >at-stderr
   29594 mv at-stderr stderr
   29595 # 2. Create the reference error message.
   29596 cat >expout <<'_ATEOF'
   29597 1.2: syntax error, unexpected number
   29598 _ATEOF
   29599 
   29600 # 3. If locations are not used, remove them.
   29601 sed 's/^[-0-9.]*: //' expout >at-expout
   29602 mv at-expout expout
   29603 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   29604 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   29605 mv at-expout expout
   29606 # 5. Check
   29607 $at_traceoff
   29608 echo "calc.at:588: cat stderr"
   29609 echo calc.at:588 >$at_check_line_file
   29610 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   29611 at_status=$?
   29612 grep '^ *+' $at_stder1 >&2
   29613 grep -v '^ *+' $at_stder1 >$at_stderr
   29614 at_failed=false
   29615 $at_diff $at_devnull $at_stderr || at_failed=:
   29616 $at_diff expout $at_stdout || at_failed=:
   29617 case $at_status in
   29618    77) echo 77 > $at_status_file
   29619             exit 77;;
   29620    0) ;;
   29621    *) echo "calc.at:588: exit code was $at_status, expected 0"
   29622       at_failed=:;;
   29623 esac
   29624 if $at_failed; then
   29625 
   29626   echo 1 > $at_status_file
   29627   exit 1
   29628 fi
   29629 
   29630 $at_traceon
   29631 
   29632 
   29633 cat >input <<'_ATEOF'
   29634 1//2
   29635 _ATEOF
   29636 
   29637 $at_traceoff
   29638 echo "calc.at:588: \$PREPARSER ./calc input"
   29639 echo calc.at:588 >$at_check_line_file
   29640 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   29641 at_status=$?
   29642 grep '^ *+' $at_stder1 >&2
   29643 grep -v '^ *+' $at_stder1 >$at_stderr
   29644 at_failed=false
   29645 echo stderr:; tee stderr <$at_stderr
   29646 $at_diff $at_devnull $at_stdout || at_failed=:
   29647 case $at_status in
   29648    77) echo 77 > $at_status_file
   29649             exit 77;;
   29650    1) ;;
   29651    *) echo "calc.at:588: exit code was $at_status, expected 1"
   29652       at_failed=:;;
   29653 esac
   29654 if $at_failed; then
   29655 
   29656   echo 1 > $at_status_file
   29657   exit 1
   29658 fi
   29659 
   29660 $at_traceon
   29661 
   29662 
   29663 # Normalize the observed and expected error messages, depending upon the
   29664 # options.
   29665 # 1. Remove the traces from observed.
   29666 sed '/^Starting/d
   29667 /^Entering/d
   29668 /^Stack/d
   29669 /^Reading/d
   29670 /^Reducing/d
   29671 /^Shifting/d
   29672 /^state/d
   29673 /^Cleanup:/d
   29674 /^Error:/d
   29675 /^Next/d
   29676 /^Discarding/d
   29677 / \$[0-9$]* = /d
   29678 /^yydestructor:/d' stderr >at-stderr
   29679 mv at-stderr stderr
   29680 # 2. Create the reference error message.
   29681 cat >expout <<'_ATEOF'
   29682 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   29683 _ATEOF
   29684 
   29685 # 3. If locations are not used, remove them.
   29686 sed 's/^[-0-9.]*: //' expout >at-expout
   29687 mv at-expout expout
   29688 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   29689 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   29690 mv at-expout expout
   29691 # 5. Check
   29692 $at_traceoff
   29693 echo "calc.at:588: cat stderr"
   29694 echo calc.at:588 >$at_check_line_file
   29695 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   29696 at_status=$?
   29697 grep '^ *+' $at_stder1 >&2
   29698 grep -v '^ *+' $at_stder1 >$at_stderr
   29699 at_failed=false
   29700 $at_diff $at_devnull $at_stderr || at_failed=:
   29701 $at_diff expout $at_stdout || at_failed=:
   29702 case $at_status in
   29703    77) echo 77 > $at_status_file
   29704             exit 77;;
   29705    0) ;;
   29706    *) echo "calc.at:588: exit code was $at_status, expected 0"
   29707       at_failed=:;;
   29708 esac
   29709 if $at_failed; then
   29710 
   29711   echo 1 > $at_status_file
   29712   exit 1
   29713 fi
   29714 
   29715 $at_traceon
   29716 
   29717 
   29718 cat >input <<'_ATEOF'
   29719 error
   29720 _ATEOF
   29721 
   29722 $at_traceoff
   29723 echo "calc.at:588: \$PREPARSER ./calc input"
   29724 echo calc.at:588 >$at_check_line_file
   29725 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   29726 at_status=$?
   29727 grep '^ *+' $at_stder1 >&2
   29728 grep -v '^ *+' $at_stder1 >$at_stderr
   29729 at_failed=false
   29730 echo stderr:; tee stderr <$at_stderr
   29731 $at_diff $at_devnull $at_stdout || at_failed=:
   29732 case $at_status in
   29733    77) echo 77 > $at_status_file
   29734             exit 77;;
   29735    1) ;;
   29736    *) echo "calc.at:588: exit code was $at_status, expected 1"
   29737       at_failed=:;;
   29738 esac
   29739 if $at_failed; then
   29740 
   29741   echo 1 > $at_status_file
   29742   exit 1
   29743 fi
   29744 
   29745 $at_traceon
   29746 
   29747 
   29748 # Normalize the observed and expected error messages, depending upon the
   29749 # options.
   29750 # 1. Remove the traces from observed.
   29751 sed '/^Starting/d
   29752 /^Entering/d
   29753 /^Stack/d
   29754 /^Reading/d
   29755 /^Reducing/d
   29756 /^Shifting/d
   29757 /^state/d
   29758 /^Cleanup:/d
   29759 /^Error:/d
   29760 /^Next/d
   29761 /^Discarding/d
   29762 / \$[0-9$]* = /d
   29763 /^yydestructor:/d' stderr >at-stderr
   29764 mv at-stderr stderr
   29765 # 2. Create the reference error message.
   29766 cat >expout <<'_ATEOF'
   29767 1.0: syntax error, unexpected $undefined
   29768 _ATEOF
   29769 
   29770 # 3. If locations are not used, remove them.
   29771 sed 's/^[-0-9.]*: //' expout >at-expout
   29772 mv at-expout expout
   29773 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   29774 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   29775 mv at-expout expout
   29776 # 5. Check
   29777 $at_traceoff
   29778 echo "calc.at:588: cat stderr"
   29779 echo calc.at:588 >$at_check_line_file
   29780 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   29781 at_status=$?
   29782 grep '^ *+' $at_stder1 >&2
   29783 grep -v '^ *+' $at_stder1 >$at_stderr
   29784 at_failed=false
   29785 $at_diff $at_devnull $at_stderr || at_failed=:
   29786 $at_diff expout $at_stdout || at_failed=:
   29787 case $at_status in
   29788    77) echo 77 > $at_status_file
   29789             exit 77;;
   29790    0) ;;
   29791    *) echo "calc.at:588: exit code was $at_status, expected 0"
   29792       at_failed=:;;
   29793 esac
   29794 if $at_failed; then
   29795 
   29796   echo 1 > $at_status_file
   29797   exit 1
   29798 fi
   29799 
   29800 $at_traceon
   29801 
   29802 
   29803 cat >input <<'_ATEOF'
   29804 1 = 2 = 3
   29805 _ATEOF
   29806 
   29807 $at_traceoff
   29808 echo "calc.at:588: \$PREPARSER ./calc input"
   29809 echo calc.at:588 >$at_check_line_file
   29810 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   29811 at_status=$?
   29812 grep '^ *+' $at_stder1 >&2
   29813 grep -v '^ *+' $at_stder1 >$at_stderr
   29814 at_failed=false
   29815 echo stderr:; tee stderr <$at_stderr
   29816 $at_diff $at_devnull $at_stdout || at_failed=:
   29817 case $at_status in
   29818    77) echo 77 > $at_status_file
   29819             exit 77;;
   29820    1) ;;
   29821    *) echo "calc.at:588: exit code was $at_status, expected 1"
   29822       at_failed=:;;
   29823 esac
   29824 if $at_failed; then
   29825 
   29826   echo 1 > $at_status_file
   29827   exit 1
   29828 fi
   29829 
   29830 $at_traceon
   29831 
   29832 
   29833 # Normalize the observed and expected error messages, depending upon the
   29834 # options.
   29835 # 1. Remove the traces from observed.
   29836 sed '/^Starting/d
   29837 /^Entering/d
   29838 /^Stack/d
   29839 /^Reading/d
   29840 /^Reducing/d
   29841 /^Shifting/d
   29842 /^state/d
   29843 /^Cleanup:/d
   29844 /^Error:/d
   29845 /^Next/d
   29846 /^Discarding/d
   29847 / \$[0-9$]* = /d
   29848 /^yydestructor:/d' stderr >at-stderr
   29849 mv at-stderr stderr
   29850 # 2. Create the reference error message.
   29851 cat >expout <<'_ATEOF'
   29852 1.6: syntax error, unexpected '='
   29853 _ATEOF
   29854 
   29855 # 3. If locations are not used, remove them.
   29856 sed 's/^[-0-9.]*: //' expout >at-expout
   29857 mv at-expout expout
   29858 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   29859 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   29860 mv at-expout expout
   29861 # 5. Check
   29862 $at_traceoff
   29863 echo "calc.at:588: cat stderr"
   29864 echo calc.at:588 >$at_check_line_file
   29865 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   29866 at_status=$?
   29867 grep '^ *+' $at_stder1 >&2
   29868 grep -v '^ *+' $at_stder1 >$at_stderr
   29869 at_failed=false
   29870 $at_diff $at_devnull $at_stderr || at_failed=:
   29871 $at_diff expout $at_stdout || at_failed=:
   29872 case $at_status in
   29873    77) echo 77 > $at_status_file
   29874             exit 77;;
   29875    0) ;;
   29876    *) echo "calc.at:588: exit code was $at_status, expected 0"
   29877       at_failed=:;;
   29878 esac
   29879 if $at_failed; then
   29880 
   29881   echo 1 > $at_status_file
   29882   exit 1
   29883 fi
   29884 
   29885 $at_traceon
   29886 
   29887 
   29888 cat >input <<'_ATEOF'
   29889 
   29890 +1
   29891 _ATEOF
   29892 
   29893 $at_traceoff
   29894 echo "calc.at:588: \$PREPARSER ./calc input"
   29895 echo calc.at:588 >$at_check_line_file
   29896 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   29897 at_status=$?
   29898 grep '^ *+' $at_stder1 >&2
   29899 grep -v '^ *+' $at_stder1 >$at_stderr
   29900 at_failed=false
   29901 echo stderr:; tee stderr <$at_stderr
   29902 $at_diff $at_devnull $at_stdout || at_failed=:
   29903 case $at_status in
   29904    77) echo 77 > $at_status_file
   29905             exit 77;;
   29906    1) ;;
   29907    *) echo "calc.at:588: exit code was $at_status, expected 1"
   29908       at_failed=:;;
   29909 esac
   29910 if $at_failed; then
   29911 
   29912   echo 1 > $at_status_file
   29913   exit 1
   29914 fi
   29915 
   29916 $at_traceon
   29917 
   29918 
   29919 # Normalize the observed and expected error messages, depending upon the
   29920 # options.
   29921 # 1. Remove the traces from observed.
   29922 sed '/^Starting/d
   29923 /^Entering/d
   29924 /^Stack/d
   29925 /^Reading/d
   29926 /^Reducing/d
   29927 /^Shifting/d
   29928 /^state/d
   29929 /^Cleanup:/d
   29930 /^Error:/d
   29931 /^Next/d
   29932 /^Discarding/d
   29933 / \$[0-9$]* = /d
   29934 /^yydestructor:/d' stderr >at-stderr
   29935 mv at-stderr stderr
   29936 # 2. Create the reference error message.
   29937 cat >expout <<'_ATEOF'
   29938 2.0: syntax error, unexpected '+'
   29939 _ATEOF
   29940 
   29941 # 3. If locations are not used, remove them.
   29942 sed 's/^[-0-9.]*: //' expout >at-expout
   29943 mv at-expout expout
   29944 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   29945 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   29946 mv at-expout expout
   29947 # 5. Check
   29948 $at_traceoff
   29949 echo "calc.at:588: cat stderr"
   29950 echo calc.at:588 >$at_check_line_file
   29951 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   29952 at_status=$?
   29953 grep '^ *+' $at_stder1 >&2
   29954 grep -v '^ *+' $at_stder1 >$at_stderr
   29955 at_failed=false
   29956 $at_diff $at_devnull $at_stderr || at_failed=:
   29957 $at_diff expout $at_stdout || at_failed=:
   29958 case $at_status in
   29959    77) echo 77 > $at_status_file
   29960             exit 77;;
   29961    0) ;;
   29962    *) echo "calc.at:588: exit code was $at_status, expected 0"
   29963       at_failed=:;;
   29964 esac
   29965 if $at_failed; then
   29966 
   29967   echo 1 > $at_status_file
   29968   exit 1
   29969 fi
   29970 
   29971 $at_traceon
   29972 
   29973 
   29974 # Exercise error messages with EOF: work on an empty file.
   29975 $at_traceoff
   29976 echo "calc.at:588: \$PREPARSER ./calc /dev/null"
   29977 echo calc.at:588 >$at_check_line_file
   29978 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   29979 at_status=$?
   29980 grep '^ *+' $at_stder1 >&2
   29981 grep -v '^ *+' $at_stder1 >$at_stderr
   29982 at_failed=false
   29983 echo stderr:; tee stderr <$at_stderr
   29984 $at_diff $at_devnull $at_stdout || at_failed=:
   29985 case $at_status in
   29986    77) echo 77 > $at_status_file
   29987             exit 77;;
   29988    1) ;;
   29989    *) echo "calc.at:588: exit code was $at_status, expected 1"
   29990       at_failed=:;;
   29991 esac
   29992 if $at_failed; then
   29993 
   29994   echo 1 > $at_status_file
   29995   exit 1
   29996 fi
   29997 
   29998 $at_traceon
   29999 
   30000 
   30001 # Normalize the observed and expected error messages, depending upon the
   30002 # options.
   30003 # 1. Remove the traces from observed.
   30004 sed '/^Starting/d
   30005 /^Entering/d
   30006 /^Stack/d
   30007 /^Reading/d
   30008 /^Reducing/d
   30009 /^Shifting/d
   30010 /^state/d
   30011 /^Cleanup:/d
   30012 /^Error:/d
   30013 /^Next/d
   30014 /^Discarding/d
   30015 / \$[0-9$]* = /d
   30016 /^yydestructor:/d' stderr >at-stderr
   30017 mv at-stderr stderr
   30018 # 2. Create the reference error message.
   30019 cat >expout <<'_ATEOF'
   30020 1.0: syntax error, unexpected end of input
   30021 _ATEOF
   30022 
   30023 # 3. If locations are not used, remove them.
   30024 sed 's/^[-0-9.]*: //' expout >at-expout
   30025 mv at-expout expout
   30026 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   30027 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   30028 mv at-expout expout
   30029 # 5. Check
   30030 $at_traceoff
   30031 echo "calc.at:588: cat stderr"
   30032 echo calc.at:588 >$at_check_line_file
   30033 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   30034 at_status=$?
   30035 grep '^ *+' $at_stder1 >&2
   30036 grep -v '^ *+' $at_stder1 >$at_stderr
   30037 at_failed=false
   30038 $at_diff $at_devnull $at_stderr || at_failed=:
   30039 $at_diff expout $at_stdout || at_failed=:
   30040 case $at_status in
   30041    77) echo 77 > $at_status_file
   30042             exit 77;;
   30043    0) ;;
   30044    *) echo "calc.at:588: exit code was $at_status, expected 0"
   30045       at_failed=:;;
   30046 esac
   30047 if $at_failed; then
   30048 
   30049   echo 1 > $at_status_file
   30050   exit 1
   30051 fi
   30052 
   30053 $at_traceon
   30054 
   30055 
   30056 
   30057 # Exercise the error token: without it, we die at the first error,
   30058 # hence be sure to
   30059 #
   30060 # - have several errors which exercise different shift/discardings
   30061 #   - (): nothing to pop, nothing to discard
   30062 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   30063 #   - (* * *): nothing to pop, a lot to discard
   30064 #   - (1 + 2 * *): some to pop and discard
   30065 #
   30066 # - test the action associated to `error'
   30067 #
   30068 # - check the look-ahead that triggers an error is not discarded
   30069 #   when we enter error recovery.  Below, the look-ahead causing the
   30070 #   first error is ")", which is needed to recover from the error and
   30071 #   produce the "0" that triggers the "0 != 1" error.
   30072 #
   30073 cat >input <<'_ATEOF'
   30074 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   30075 _ATEOF
   30076 
   30077 $at_traceoff
   30078 echo "calc.at:588: \$PREPARSER ./calc input"
   30079 echo calc.at:588 >$at_check_line_file
   30080 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   30081 at_status=$?
   30082 grep '^ *+' $at_stder1 >&2
   30083 grep -v '^ *+' $at_stder1 >$at_stderr
   30084 at_failed=false
   30085 echo stderr:; tee stderr <$at_stderr
   30086 $at_diff $at_devnull $at_stdout || at_failed=:
   30087 case $at_status in
   30088    77) echo 77 > $at_status_file
   30089             exit 77;;
   30090    0) ;;
   30091    *) echo "calc.at:588: exit code was $at_status, expected 0"
   30092       at_failed=:;;
   30093 esac
   30094 if $at_failed; then
   30095 
   30096   echo 1 > $at_status_file
   30097   exit 1
   30098 fi
   30099 
   30100 $at_traceon
   30101 
   30102 
   30103 # Normalize the observed and expected error messages, depending upon the
   30104 # options.
   30105 # 1. Remove the traces from observed.
   30106 sed '/^Starting/d
   30107 /^Entering/d
   30108 /^Stack/d
   30109 /^Reading/d
   30110 /^Reducing/d
   30111 /^Shifting/d
   30112 /^state/d
   30113 /^Cleanup:/d
   30114 /^Error:/d
   30115 /^Next/d
   30116 /^Discarding/d
   30117 / \$[0-9$]* = /d
   30118 /^yydestructor:/d' stderr >at-stderr
   30119 mv at-stderr stderr
   30120 # 2. Create the reference error message.
   30121 cat >expout <<'_ATEOF'
   30122 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   30123 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   30124 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   30125 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   30126 calc: error: 4444 != 1
   30127 _ATEOF
   30128 
   30129 # 3. If locations are not used, remove them.
   30130 sed 's/^[-0-9.]*: //' expout >at-expout
   30131 mv at-expout expout
   30132 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   30133 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   30134 mv at-expout expout
   30135 # 5. Check
   30136 $at_traceoff
   30137 echo "calc.at:588: cat stderr"
   30138 echo calc.at:588 >$at_check_line_file
   30139 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   30140 at_status=$?
   30141 grep '^ *+' $at_stder1 >&2
   30142 grep -v '^ *+' $at_stder1 >$at_stderr
   30143 at_failed=false
   30144 $at_diff $at_devnull $at_stderr || at_failed=:
   30145 $at_diff expout $at_stdout || at_failed=:
   30146 case $at_status in
   30147    77) echo 77 > $at_status_file
   30148             exit 77;;
   30149    0) ;;
   30150    *) echo "calc.at:588: exit code was $at_status, expected 0"
   30151       at_failed=:;;
   30152 esac
   30153 if $at_failed; then
   30154 
   30155   echo 1 > $at_status_file
   30156   exit 1
   30157 fi
   30158 
   30159 $at_traceon
   30160 
   30161 
   30162 
   30163 # The same, but this time exercising explicitly triggered syntax errors.
   30164 # POSIX says the look-ahead causing the error should not be discarded.
   30165 cat >input <<'_ATEOF'
   30166 (!) + (0 0) = 1
   30167 _ATEOF
   30168 
   30169 $at_traceoff
   30170 echo "calc.at:588: \$PREPARSER ./calc input"
   30171 echo calc.at:588 >$at_check_line_file
   30172 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   30173 at_status=$?
   30174 grep '^ *+' $at_stder1 >&2
   30175 grep -v '^ *+' $at_stder1 >$at_stderr
   30176 at_failed=false
   30177 echo stderr:; tee stderr <$at_stderr
   30178 $at_diff $at_devnull $at_stdout || at_failed=:
   30179 case $at_status in
   30180    77) echo 77 > $at_status_file
   30181             exit 77;;
   30182    0) ;;
   30183    *) echo "calc.at:588: exit code was $at_status, expected 0"
   30184       at_failed=:;;
   30185 esac
   30186 if $at_failed; then
   30187 
   30188   echo 1 > $at_status_file
   30189   exit 1
   30190 fi
   30191 
   30192 $at_traceon
   30193 
   30194 
   30195 # Normalize the observed and expected error messages, depending upon the
   30196 # options.
   30197 # 1. Remove the traces from observed.
   30198 sed '/^Starting/d
   30199 /^Entering/d
   30200 /^Stack/d
   30201 /^Reading/d
   30202 /^Reducing/d
   30203 /^Shifting/d
   30204 /^state/d
   30205 /^Cleanup:/d
   30206 /^Error:/d
   30207 /^Next/d
   30208 /^Discarding/d
   30209 / \$[0-9$]* = /d
   30210 /^yydestructor:/d' stderr >at-stderr
   30211 mv at-stderr stderr
   30212 # 2. Create the reference error message.
   30213 cat >expout <<'_ATEOF'
   30214 1.9: syntax error, unexpected number
   30215 calc: error: 2222 != 1
   30216 _ATEOF
   30217 
   30218 # 3. If locations are not used, remove them.
   30219 sed 's/^[-0-9.]*: //' expout >at-expout
   30220 mv at-expout expout
   30221 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   30222 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   30223 mv at-expout expout
   30224 # 5. Check
   30225 $at_traceoff
   30226 echo "calc.at:588: cat stderr"
   30227 echo calc.at:588 >$at_check_line_file
   30228 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   30229 at_status=$?
   30230 grep '^ *+' $at_stder1 >&2
   30231 grep -v '^ *+' $at_stder1 >$at_stderr
   30232 at_failed=false
   30233 $at_diff $at_devnull $at_stderr || at_failed=:
   30234 $at_diff expout $at_stdout || at_failed=:
   30235 case $at_status in
   30236    77) echo 77 > $at_status_file
   30237             exit 77;;
   30238    0) ;;
   30239    *) echo "calc.at:588: exit code was $at_status, expected 0"
   30240       at_failed=:;;
   30241 esac
   30242 if $at_failed; then
   30243 
   30244   echo 1 > $at_status_file
   30245   exit 1
   30246 fi
   30247 
   30248 $at_traceon
   30249 
   30250 
   30251 cat >input <<'_ATEOF'
   30252 (- *) + (0 0) = 1
   30253 _ATEOF
   30254 
   30255 $at_traceoff
   30256 echo "calc.at:588: \$PREPARSER ./calc input"
   30257 echo calc.at:588 >$at_check_line_file
   30258 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   30259 at_status=$?
   30260 grep '^ *+' $at_stder1 >&2
   30261 grep -v '^ *+' $at_stder1 >$at_stderr
   30262 at_failed=false
   30263 echo stderr:; tee stderr <$at_stderr
   30264 $at_diff $at_devnull $at_stdout || at_failed=:
   30265 case $at_status in
   30266    77) echo 77 > $at_status_file
   30267             exit 77;;
   30268    0) ;;
   30269    *) echo "calc.at:588: exit code was $at_status, expected 0"
   30270       at_failed=:;;
   30271 esac
   30272 if $at_failed; then
   30273 
   30274   echo 1 > $at_status_file
   30275   exit 1
   30276 fi
   30277 
   30278 $at_traceon
   30279 
   30280 
   30281 # Normalize the observed and expected error messages, depending upon the
   30282 # options.
   30283 # 1. Remove the traces from observed.
   30284 sed '/^Starting/d
   30285 /^Entering/d
   30286 /^Stack/d
   30287 /^Reading/d
   30288 /^Reducing/d
   30289 /^Shifting/d
   30290 /^state/d
   30291 /^Cleanup:/d
   30292 /^Error:/d
   30293 /^Next/d
   30294 /^Discarding/d
   30295 / \$[0-9$]* = /d
   30296 /^yydestructor:/d' stderr >at-stderr
   30297 mv at-stderr stderr
   30298 # 2. Create the reference error message.
   30299 cat >expout <<'_ATEOF'
   30300 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   30301 1.11: syntax error, unexpected number
   30302 calc: error: 2222 != 1
   30303 _ATEOF
   30304 
   30305 # 3. If locations are not used, remove them.
   30306 sed 's/^[-0-9.]*: //' expout >at-expout
   30307 mv at-expout expout
   30308 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   30309 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   30310 mv at-expout expout
   30311 # 5. Check
   30312 $at_traceoff
   30313 echo "calc.at:588: cat stderr"
   30314 echo calc.at:588 >$at_check_line_file
   30315 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   30316 at_status=$?
   30317 grep '^ *+' $at_stder1 >&2
   30318 grep -v '^ *+' $at_stder1 >$at_stderr
   30319 at_failed=false
   30320 $at_diff $at_devnull $at_stderr || at_failed=:
   30321 $at_diff expout $at_stdout || at_failed=:
   30322 case $at_status in
   30323    77) echo 77 > $at_status_file
   30324             exit 77;;
   30325    0) ;;
   30326    *) echo "calc.at:588: exit code was $at_status, expected 0"
   30327       at_failed=:;;
   30328 esac
   30329 if $at_failed; then
   30330 
   30331   echo 1 > $at_status_file
   30332   exit 1
   30333 fi
   30334 
   30335 $at_traceon
   30336 
   30337 
   30338 
   30339 
   30340 
   30341 
   30342 
   30343 
   30344 
   30345 
   30346 
   30347 
   30348 
   30349 
   30350 
   30351 
   30352 
   30353 
   30354 
   30355 
   30356 
   30357 
   30358 
   30359 
   30360       $at_traceoff
   30361       $at_times_p && times >$at_times_file
   30362     ) 5>&1 2>&1 | eval $at_tee_pipe
   30363     at_status=`cat $at_status_file`
   30364     ;;
   30365 
   30366   86 ) # 86. calc.at:589: Calculator %glr-parser %locations
   30367     at_setup_line='calc.at:589'
   30368     at_desc='Calculator %glr-parser %locations'
   30369     $at_quiet $ECHO_N " 86: Calculator %glr-parser %locations            $ECHO_C"
   30370     at_xfail=no
   30371     (
   30372       echo "86. calc.at:589: testing ..."
   30373       $at_traceon
   30374 
   30375 
   30376 
   30377 
   30378 
   30379 
   30380 
   30381 
   30382 # Using yacc.c?
   30383 
   30384 
   30385 
   30386 
   30387 
   30388 
   30389 
   30390 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   30391 
   30392 # yyerror always sees the locations (when activated), except if
   30393 # yacc & pure & !param.
   30394 
   30395 
   30396 # The interface is pure: either because %pure-parser, or because we
   30397 # are using the C++ parsers.
   30398 
   30399 
   30400 
   30401 
   30402 
   30403 
   30404 
   30405 
   30406 
   30407 
   30408 
   30409 
   30410 cat >calc.y <<'_ATEOF'
   30411 %{
   30412 #ifdef HAVE_CONFIG_H
   30413 # include <config.h>
   30414   /* We don't need perfect functions for these tests. */
   30415 # undef malloc
   30416 # undef memcmp
   30417 # undef realloc
   30418 #endif
   30419 %}
   30420 
   30421 /* Infix notation calculator--calc */
   30422 %glr-parser %locations
   30423 
   30424 %{
   30425 #include <stdio.h>
   30426 
   30427 #include <stdlib.h>
   30428 #include <string.h>
   30429 #if HAVE_UNISTD_H
   30430 # include <unistd.h>
   30431 #else
   30432 # undef alarm
   30433 # define alarm(seconds) /* empty */
   30434 #endif
   30435 #include <ctype.h>
   30436 #define USE(Var)
   30437 
   30438 /* Exercise pre-prologue dependency to %union.  */
   30439 typedef int semantic_value;
   30440 
   30441 static semantic_value global_result = 0;
   30442 static int global_count = 0;
   30443 %}
   30444 
   30445 /* Exercise %union. */
   30446 %union
   30447 {
   30448   semantic_value ival;
   30449 };
   30450 
   30451 %{
   30452 static int power (int base, int exponent);
   30453 /* yyerror receives the location if:
   30454    - %location & %pure & %glr
   30455    - %location & %pure & %yacc & %parse-param. */
   30456 static void yyerror (
   30457 
   30458                      const char *s
   30459                      );
   30460 static int yylex (void);
   30461 static int get_char (void);
   30462 static void unget_char ( int c);
   30463 %}
   30464 
   30465 
   30466 
   30467 /* Bison Declarations */
   30468 %token CALC_EOF 0 "end of input"
   30469 %token <ival> NUM "number"
   30470 %type  <ival> exp
   30471 
   30472 %nonassoc '=' /* comparison	       */
   30473 %left '-' '+'
   30474 %left '*' '/'
   30475 %left NEG     /* negation--unary minus */
   30476 %right '^'    /* exponentiation        */
   30477 
   30478 /* Grammar follows */
   30479 %%
   30480 input:
   30481   line
   30482 | input line         {  }
   30483 ;
   30484 
   30485 line:
   30486   '\n'
   30487 | exp '\n'           { USE ($1); }
   30488 ;
   30489 
   30490 exp:
   30491   NUM                { $$ = $1;             }
   30492 | exp '=' exp
   30493   {
   30494     if ($1 != $3)
   30495       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   30496     $$ = $1;
   30497   }
   30498 | exp '+' exp        { $$ = $1 + $3;        }
   30499 | exp '-' exp        { $$ = $1 - $3;        }
   30500 | exp '*' exp        { $$ = $1 * $3;        }
   30501 | exp '/' exp        { $$ = $1 / $3;        }
   30502 | '-' exp  %prec NEG { $$ = -$2;            }
   30503 | exp '^' exp        { $$ = power ($1, $3); }
   30504 | '(' exp ')'        { $$ = $2;             }
   30505 | '(' error ')'      { $$ = 1111;           }
   30506 | '!'                { $$ = 0; YYERROR;     }
   30507 | '-' error          { $$ = 0; YYERROR;     }
   30508 ;
   30509 %%
   30510 /* The input.  */
   30511 static FILE *input;
   30512 
   30513 static void
   30514 yyerror (
   30515 
   30516          const char *s)
   30517 {
   30518 
   30519 
   30520   fprintf (stderr, "%d.%d",
   30521            (yylloc).first_line, (yylloc).first_column);
   30522   if ((yylloc).first_line != (yylloc).last_line)
   30523     fprintf (stderr, "-%d.%d",
   30524 	     (yylloc).last_line,  (yylloc).last_column - 1);
   30525   else if ((yylloc).first_column != (yylloc).last_column - 1)
   30526     fprintf (stderr, "-%d",
   30527 	     (yylloc).last_column - 1);
   30528   fprintf (stderr, ": ");
   30529   fprintf (stderr, "%s\n", s);
   30530 }
   30531 
   30532 
   30533 
   30534 static YYLTYPE last_yylloc;
   30535 
   30536 static int
   30537 get_char (void)
   30538 {
   30539   int res = getc (input);
   30540   ;
   30541 
   30542   last_yylloc = (yylloc);
   30543   if (res == '\n')
   30544     {
   30545       (yylloc).last_line++;
   30546       (yylloc).last_column = 0;
   30547     }
   30548   else
   30549     (yylloc).last_column++;
   30550 
   30551   return res;
   30552 }
   30553 
   30554 
   30555 static void
   30556 unget_char ( int c)
   30557 {
   30558   ;
   30559 
   30560   /* Wrong when C == `\n'. */
   30561   (yylloc) = last_yylloc;
   30562 
   30563   ungetc (c, input);
   30564 }
   30565 
   30566 static int
   30567 read_signed_integer (void)
   30568 {
   30569   int c = get_char ();
   30570   int sign = 1;
   30571   int n = 0;
   30572 
   30573   ;
   30574   if (c == '-')
   30575     {
   30576       c = get_char ();
   30577       sign = -1;
   30578     }
   30579 
   30580   while (isdigit (c))
   30581     {
   30582       n = 10 * n + (c - '0');
   30583       c = get_char ();
   30584     }
   30585 
   30586   unget_char ( c);
   30587 
   30588   return sign * n;
   30589 }
   30590 
   30591 
   30592 
   30593 /*---------------------------------------------------------------.
   30594 | Lexical analyzer returns an integer on the stack and the token |
   30595 | NUM, or the ASCII character read if not a number.  Skips all   |
   30596 | blanks and tabs, returns 0 for EOF.                            |
   30597 `---------------------------------------------------------------*/
   30598 
   30599 static int
   30600 yylex (void)
   30601 {
   30602   static int init = 1;
   30603   int c;
   30604 
   30605   if (init)
   30606     {
   30607       init = 0;
   30608 
   30609       (yylloc).last_column = 0;
   30610       (yylloc).last_line = 1;
   30611 
   30612     }
   30613 
   30614 
   30615  (yylloc).first_column = (yylloc).last_column;
   30616   (yylloc).first_line   = (yylloc).last_line;
   30617 
   30618 
   30619   /* Skip white space.  */
   30620   while ((c = get_char ()) == ' ' || c == '\t')
   30621     {
   30622      (yylloc).first_column = (yylloc).last_column;
   30623       (yylloc).first_line   = (yylloc).last_line;
   30624 
   30625     }
   30626 
   30627   /* process numbers   */
   30628   if (c == '.' || isdigit (c))
   30629     {
   30630       unget_char ( c);
   30631       (yylval).ival = read_signed_integer ();
   30632       return NUM;
   30633     }
   30634 
   30635   /* Return end-of-file.  */
   30636   if (c == EOF)
   30637     return CALC_EOF;
   30638 
   30639   /* Return single chars. */
   30640   return c;
   30641 }
   30642 
   30643 static int
   30644 power (int base, int exponent)
   30645 {
   30646   int res = 1;
   30647   if (exponent < 0)
   30648     exit (3);
   30649   for (/* Niente */; exponent; --exponent)
   30650     res *= base;
   30651   return res;
   30652 }
   30653 
   30654 
   30655 int
   30656 main (int argc, const char **argv)
   30657 {
   30658   semantic_value result = 0;
   30659   int count = 0;
   30660   int status;
   30661 
   30662   /* This used to be alarm (10), but that isn't enough time for
   30663      a July 1995 vintage DEC Alphastation 200 4/100 system,
   30664      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   30665   alarm (100);
   30666 
   30667   if (argc == 2)
   30668     input = fopen (argv[1], "r");
   30669   else
   30670     input = stdin;
   30671 
   30672   if (!input)
   30673     {
   30674       perror (argv[1]);
   30675       return 3;
   30676     }
   30677 
   30678 
   30679   status = yyparse ();
   30680   if (global_result != result)
   30681     abort ();
   30682   if (global_count != count)
   30683     abort ();
   30684   return status;
   30685 }
   30686 _ATEOF
   30687 
   30688 
   30689 
   30690 
   30691 
   30692 $at_traceoff
   30693 echo "calc.at:589: bison -o calc.c calc.y"
   30694 echo calc.at:589 >$at_check_line_file
   30695 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   30696 at_status=$?
   30697 grep '^ *+' $at_stder1 >&2
   30698 grep -v '^ *+' $at_stder1 >$at_stderr
   30699 at_failed=false
   30700 $at_diff $at_devnull $at_stderr || at_failed=:
   30701 $at_diff $at_devnull $at_stdout || at_failed=:
   30702 case $at_status in
   30703    77) echo 77 > $at_status_file
   30704             exit 77;;
   30705    0) ;;
   30706    *) echo "calc.at:589: exit code was $at_status, expected 0"
   30707       at_failed=:;;
   30708 esac
   30709 if $at_failed; then
   30710 
   30711   echo 1 > $at_status_file
   30712   exit 1
   30713 fi
   30714 
   30715 $at_traceon
   30716 
   30717    $at_traceoff
   30718 echo "calc.at:589: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   30719 echo calc.at:589 >$at_check_line_file
   30720 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   30721 at_status=$?
   30722 grep '^ *+' $at_stder1 >&2
   30723 grep -v '^ *+' $at_stder1 >$at_stderr
   30724 at_failed=false
   30725 echo stderr:; cat $at_stderr
   30726 echo stdout:; cat $at_stdout
   30727 case $at_status in
   30728    77) echo 77 > $at_status_file
   30729             exit 77;;
   30730    0) ;;
   30731    *) echo "calc.at:589: exit code was $at_status, expected 0"
   30732       at_failed=:;;
   30733 esac
   30734 if $at_failed; then
   30735 
   30736   echo 1 > $at_status_file
   30737   exit 1
   30738 fi
   30739 
   30740 $at_traceon
   30741 
   30742 
   30743 # Test the priorities.
   30744 cat >input <<'_ATEOF'
   30745 1 + 2 * 3 = 7
   30746 1 + 2 * -3 = -5
   30747 
   30748 -1^2 = -1
   30749 (-1)^2 = 1
   30750 
   30751 ---1 = -1
   30752 
   30753 1 - 2 - 3 = -4
   30754 1 - (2 - 3) = 2
   30755 
   30756 2^2^3 = 256
   30757 (2^2)^3 = 64
   30758 _ATEOF
   30759 
   30760 $at_traceoff
   30761 echo "calc.at:589: \$PREPARSER ./calc input"
   30762 echo calc.at:589 >$at_check_line_file
   30763 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   30764 at_status=$?
   30765 grep '^ *+' $at_stder1 >&2
   30766 grep -v '^ *+' $at_stder1 >$at_stderr
   30767 at_failed=false
   30768 echo stderr:; tee stderr <$at_stderr
   30769 $at_diff $at_devnull $at_stdout || at_failed=:
   30770 case $at_status in
   30771    77) echo 77 > $at_status_file
   30772             exit 77;;
   30773    0) ;;
   30774    *) echo "calc.at:589: exit code was $at_status, expected 0"
   30775       at_failed=:;;
   30776 esac
   30777 if $at_failed; then
   30778 
   30779   echo 1 > $at_status_file
   30780   exit 1
   30781 fi
   30782 
   30783 $at_traceon
   30784 
   30785 
   30786 
   30787 # Some syntax errors.
   30788 cat >input <<'_ATEOF'
   30789 0 0
   30790 _ATEOF
   30791 
   30792 $at_traceoff
   30793 echo "calc.at:589: \$PREPARSER ./calc input"
   30794 echo calc.at:589 >$at_check_line_file
   30795 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   30796 at_status=$?
   30797 grep '^ *+' $at_stder1 >&2
   30798 grep -v '^ *+' $at_stder1 >$at_stderr
   30799 at_failed=false
   30800 echo stderr:; tee stderr <$at_stderr
   30801 $at_diff $at_devnull $at_stdout || at_failed=:
   30802 case $at_status in
   30803    77) echo 77 > $at_status_file
   30804             exit 77;;
   30805    1) ;;
   30806    *) echo "calc.at:589: exit code was $at_status, expected 1"
   30807       at_failed=:;;
   30808 esac
   30809 if $at_failed; then
   30810 
   30811   echo 1 > $at_status_file
   30812   exit 1
   30813 fi
   30814 
   30815 $at_traceon
   30816 
   30817 
   30818 # Normalize the observed and expected error messages, depending upon the
   30819 # options.
   30820 # 1. Remove the traces from observed.
   30821 sed '/^Starting/d
   30822 /^Entering/d
   30823 /^Stack/d
   30824 /^Reading/d
   30825 /^Reducing/d
   30826 /^Shifting/d
   30827 /^state/d
   30828 /^Cleanup:/d
   30829 /^Error:/d
   30830 /^Next/d
   30831 /^Discarding/d
   30832 / \$[0-9$]* = /d
   30833 /^yydestructor:/d' stderr >at-stderr
   30834 mv at-stderr stderr
   30835 # 2. Create the reference error message.
   30836 cat >expout <<'_ATEOF'
   30837 1.2: syntax error, unexpected number
   30838 _ATEOF
   30839 
   30840 # 3. If locations are not used, remove them.
   30841 
   30842 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   30843 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   30844 mv at-expout expout
   30845 # 5. Check
   30846 $at_traceoff
   30847 echo "calc.at:589: cat stderr"
   30848 echo calc.at:589 >$at_check_line_file
   30849 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   30850 at_status=$?
   30851 grep '^ *+' $at_stder1 >&2
   30852 grep -v '^ *+' $at_stder1 >$at_stderr
   30853 at_failed=false
   30854 $at_diff $at_devnull $at_stderr || at_failed=:
   30855 $at_diff expout $at_stdout || at_failed=:
   30856 case $at_status in
   30857    77) echo 77 > $at_status_file
   30858             exit 77;;
   30859    0) ;;
   30860    *) echo "calc.at:589: exit code was $at_status, expected 0"
   30861       at_failed=:;;
   30862 esac
   30863 if $at_failed; then
   30864 
   30865   echo 1 > $at_status_file
   30866   exit 1
   30867 fi
   30868 
   30869 $at_traceon
   30870 
   30871 
   30872 cat >input <<'_ATEOF'
   30873 1//2
   30874 _ATEOF
   30875 
   30876 $at_traceoff
   30877 echo "calc.at:589: \$PREPARSER ./calc input"
   30878 echo calc.at:589 >$at_check_line_file
   30879 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   30880 at_status=$?
   30881 grep '^ *+' $at_stder1 >&2
   30882 grep -v '^ *+' $at_stder1 >$at_stderr
   30883 at_failed=false
   30884 echo stderr:; tee stderr <$at_stderr
   30885 $at_diff $at_devnull $at_stdout || at_failed=:
   30886 case $at_status in
   30887    77) echo 77 > $at_status_file
   30888             exit 77;;
   30889    1) ;;
   30890    *) echo "calc.at:589: exit code was $at_status, expected 1"
   30891       at_failed=:;;
   30892 esac
   30893 if $at_failed; then
   30894 
   30895   echo 1 > $at_status_file
   30896   exit 1
   30897 fi
   30898 
   30899 $at_traceon
   30900 
   30901 
   30902 # Normalize the observed and expected error messages, depending upon the
   30903 # options.
   30904 # 1. Remove the traces from observed.
   30905 sed '/^Starting/d
   30906 /^Entering/d
   30907 /^Stack/d
   30908 /^Reading/d
   30909 /^Reducing/d
   30910 /^Shifting/d
   30911 /^state/d
   30912 /^Cleanup:/d
   30913 /^Error:/d
   30914 /^Next/d
   30915 /^Discarding/d
   30916 / \$[0-9$]* = /d
   30917 /^yydestructor:/d' stderr >at-stderr
   30918 mv at-stderr stderr
   30919 # 2. Create the reference error message.
   30920 cat >expout <<'_ATEOF'
   30921 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   30922 _ATEOF
   30923 
   30924 # 3. If locations are not used, remove them.
   30925 
   30926 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   30927 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   30928 mv at-expout expout
   30929 # 5. Check
   30930 $at_traceoff
   30931 echo "calc.at:589: cat stderr"
   30932 echo calc.at:589 >$at_check_line_file
   30933 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   30934 at_status=$?
   30935 grep '^ *+' $at_stder1 >&2
   30936 grep -v '^ *+' $at_stder1 >$at_stderr
   30937 at_failed=false
   30938 $at_diff $at_devnull $at_stderr || at_failed=:
   30939 $at_diff expout $at_stdout || at_failed=:
   30940 case $at_status in
   30941    77) echo 77 > $at_status_file
   30942             exit 77;;
   30943    0) ;;
   30944    *) echo "calc.at:589: exit code was $at_status, expected 0"
   30945       at_failed=:;;
   30946 esac
   30947 if $at_failed; then
   30948 
   30949   echo 1 > $at_status_file
   30950   exit 1
   30951 fi
   30952 
   30953 $at_traceon
   30954 
   30955 
   30956 cat >input <<'_ATEOF'
   30957 error
   30958 _ATEOF
   30959 
   30960 $at_traceoff
   30961 echo "calc.at:589: \$PREPARSER ./calc input"
   30962 echo calc.at:589 >$at_check_line_file
   30963 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   30964 at_status=$?
   30965 grep '^ *+' $at_stder1 >&2
   30966 grep -v '^ *+' $at_stder1 >$at_stderr
   30967 at_failed=false
   30968 echo stderr:; tee stderr <$at_stderr
   30969 $at_diff $at_devnull $at_stdout || at_failed=:
   30970 case $at_status in
   30971    77) echo 77 > $at_status_file
   30972             exit 77;;
   30973    1) ;;
   30974    *) echo "calc.at:589: exit code was $at_status, expected 1"
   30975       at_failed=:;;
   30976 esac
   30977 if $at_failed; then
   30978 
   30979   echo 1 > $at_status_file
   30980   exit 1
   30981 fi
   30982 
   30983 $at_traceon
   30984 
   30985 
   30986 # Normalize the observed and expected error messages, depending upon the
   30987 # options.
   30988 # 1. Remove the traces from observed.
   30989 sed '/^Starting/d
   30990 /^Entering/d
   30991 /^Stack/d
   30992 /^Reading/d
   30993 /^Reducing/d
   30994 /^Shifting/d
   30995 /^state/d
   30996 /^Cleanup:/d
   30997 /^Error:/d
   30998 /^Next/d
   30999 /^Discarding/d
   31000 / \$[0-9$]* = /d
   31001 /^yydestructor:/d' stderr >at-stderr
   31002 mv at-stderr stderr
   31003 # 2. Create the reference error message.
   31004 cat >expout <<'_ATEOF'
   31005 1.0: syntax error, unexpected $undefined
   31006 _ATEOF
   31007 
   31008 # 3. If locations are not used, remove them.
   31009 
   31010 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   31011 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   31012 mv at-expout expout
   31013 # 5. Check
   31014 $at_traceoff
   31015 echo "calc.at:589: cat stderr"
   31016 echo calc.at:589 >$at_check_line_file
   31017 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   31018 at_status=$?
   31019 grep '^ *+' $at_stder1 >&2
   31020 grep -v '^ *+' $at_stder1 >$at_stderr
   31021 at_failed=false
   31022 $at_diff $at_devnull $at_stderr || at_failed=:
   31023 $at_diff expout $at_stdout || at_failed=:
   31024 case $at_status in
   31025    77) echo 77 > $at_status_file
   31026             exit 77;;
   31027    0) ;;
   31028    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31029       at_failed=:;;
   31030 esac
   31031 if $at_failed; then
   31032 
   31033   echo 1 > $at_status_file
   31034   exit 1
   31035 fi
   31036 
   31037 $at_traceon
   31038 
   31039 
   31040 cat >input <<'_ATEOF'
   31041 1 = 2 = 3
   31042 _ATEOF
   31043 
   31044 $at_traceoff
   31045 echo "calc.at:589: \$PREPARSER ./calc input"
   31046 echo calc.at:589 >$at_check_line_file
   31047 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   31048 at_status=$?
   31049 grep '^ *+' $at_stder1 >&2
   31050 grep -v '^ *+' $at_stder1 >$at_stderr
   31051 at_failed=false
   31052 echo stderr:; tee stderr <$at_stderr
   31053 $at_diff $at_devnull $at_stdout || at_failed=:
   31054 case $at_status in
   31055    77) echo 77 > $at_status_file
   31056             exit 77;;
   31057    1) ;;
   31058    *) echo "calc.at:589: exit code was $at_status, expected 1"
   31059       at_failed=:;;
   31060 esac
   31061 if $at_failed; then
   31062 
   31063   echo 1 > $at_status_file
   31064   exit 1
   31065 fi
   31066 
   31067 $at_traceon
   31068 
   31069 
   31070 # Normalize the observed and expected error messages, depending upon the
   31071 # options.
   31072 # 1. Remove the traces from observed.
   31073 sed '/^Starting/d
   31074 /^Entering/d
   31075 /^Stack/d
   31076 /^Reading/d
   31077 /^Reducing/d
   31078 /^Shifting/d
   31079 /^state/d
   31080 /^Cleanup:/d
   31081 /^Error:/d
   31082 /^Next/d
   31083 /^Discarding/d
   31084 / \$[0-9$]* = /d
   31085 /^yydestructor:/d' stderr >at-stderr
   31086 mv at-stderr stderr
   31087 # 2. Create the reference error message.
   31088 cat >expout <<'_ATEOF'
   31089 1.6: syntax error, unexpected '='
   31090 _ATEOF
   31091 
   31092 # 3. If locations are not used, remove them.
   31093 
   31094 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   31095 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   31096 mv at-expout expout
   31097 # 5. Check
   31098 $at_traceoff
   31099 echo "calc.at:589: cat stderr"
   31100 echo calc.at:589 >$at_check_line_file
   31101 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   31102 at_status=$?
   31103 grep '^ *+' $at_stder1 >&2
   31104 grep -v '^ *+' $at_stder1 >$at_stderr
   31105 at_failed=false
   31106 $at_diff $at_devnull $at_stderr || at_failed=:
   31107 $at_diff expout $at_stdout || at_failed=:
   31108 case $at_status in
   31109    77) echo 77 > $at_status_file
   31110             exit 77;;
   31111    0) ;;
   31112    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31113       at_failed=:;;
   31114 esac
   31115 if $at_failed; then
   31116 
   31117   echo 1 > $at_status_file
   31118   exit 1
   31119 fi
   31120 
   31121 $at_traceon
   31122 
   31123 
   31124 cat >input <<'_ATEOF'
   31125 
   31126 +1
   31127 _ATEOF
   31128 
   31129 $at_traceoff
   31130 echo "calc.at:589: \$PREPARSER ./calc input"
   31131 echo calc.at:589 >$at_check_line_file
   31132 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   31133 at_status=$?
   31134 grep '^ *+' $at_stder1 >&2
   31135 grep -v '^ *+' $at_stder1 >$at_stderr
   31136 at_failed=false
   31137 echo stderr:; tee stderr <$at_stderr
   31138 $at_diff $at_devnull $at_stdout || at_failed=:
   31139 case $at_status in
   31140    77) echo 77 > $at_status_file
   31141             exit 77;;
   31142    1) ;;
   31143    *) echo "calc.at:589: exit code was $at_status, expected 1"
   31144       at_failed=:;;
   31145 esac
   31146 if $at_failed; then
   31147 
   31148   echo 1 > $at_status_file
   31149   exit 1
   31150 fi
   31151 
   31152 $at_traceon
   31153 
   31154 
   31155 # Normalize the observed and expected error messages, depending upon the
   31156 # options.
   31157 # 1. Remove the traces from observed.
   31158 sed '/^Starting/d
   31159 /^Entering/d
   31160 /^Stack/d
   31161 /^Reading/d
   31162 /^Reducing/d
   31163 /^Shifting/d
   31164 /^state/d
   31165 /^Cleanup:/d
   31166 /^Error:/d
   31167 /^Next/d
   31168 /^Discarding/d
   31169 / \$[0-9$]* = /d
   31170 /^yydestructor:/d' stderr >at-stderr
   31171 mv at-stderr stderr
   31172 # 2. Create the reference error message.
   31173 cat >expout <<'_ATEOF'
   31174 2.0: syntax error, unexpected '+'
   31175 _ATEOF
   31176 
   31177 # 3. If locations are not used, remove them.
   31178 
   31179 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   31180 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   31181 mv at-expout expout
   31182 # 5. Check
   31183 $at_traceoff
   31184 echo "calc.at:589: cat stderr"
   31185 echo calc.at:589 >$at_check_line_file
   31186 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   31187 at_status=$?
   31188 grep '^ *+' $at_stder1 >&2
   31189 grep -v '^ *+' $at_stder1 >$at_stderr
   31190 at_failed=false
   31191 $at_diff $at_devnull $at_stderr || at_failed=:
   31192 $at_diff expout $at_stdout || at_failed=:
   31193 case $at_status in
   31194    77) echo 77 > $at_status_file
   31195             exit 77;;
   31196    0) ;;
   31197    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31198       at_failed=:;;
   31199 esac
   31200 if $at_failed; then
   31201 
   31202   echo 1 > $at_status_file
   31203   exit 1
   31204 fi
   31205 
   31206 $at_traceon
   31207 
   31208 
   31209 # Exercise error messages with EOF: work on an empty file.
   31210 $at_traceoff
   31211 echo "calc.at:589: \$PREPARSER ./calc /dev/null"
   31212 echo calc.at:589 >$at_check_line_file
   31213 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   31214 at_status=$?
   31215 grep '^ *+' $at_stder1 >&2
   31216 grep -v '^ *+' $at_stder1 >$at_stderr
   31217 at_failed=false
   31218 echo stderr:; tee stderr <$at_stderr
   31219 $at_diff $at_devnull $at_stdout || at_failed=:
   31220 case $at_status in
   31221    77) echo 77 > $at_status_file
   31222             exit 77;;
   31223    1) ;;
   31224    *) echo "calc.at:589: exit code was $at_status, expected 1"
   31225       at_failed=:;;
   31226 esac
   31227 if $at_failed; then
   31228 
   31229   echo 1 > $at_status_file
   31230   exit 1
   31231 fi
   31232 
   31233 $at_traceon
   31234 
   31235 
   31236 # Normalize the observed and expected error messages, depending upon the
   31237 # options.
   31238 # 1. Remove the traces from observed.
   31239 sed '/^Starting/d
   31240 /^Entering/d
   31241 /^Stack/d
   31242 /^Reading/d
   31243 /^Reducing/d
   31244 /^Shifting/d
   31245 /^state/d
   31246 /^Cleanup:/d
   31247 /^Error:/d
   31248 /^Next/d
   31249 /^Discarding/d
   31250 / \$[0-9$]* = /d
   31251 /^yydestructor:/d' stderr >at-stderr
   31252 mv at-stderr stderr
   31253 # 2. Create the reference error message.
   31254 cat >expout <<'_ATEOF'
   31255 1.0: syntax error, unexpected end of input
   31256 _ATEOF
   31257 
   31258 # 3. If locations are not used, remove them.
   31259 
   31260 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   31261 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   31262 mv at-expout expout
   31263 # 5. Check
   31264 $at_traceoff
   31265 echo "calc.at:589: cat stderr"
   31266 echo calc.at:589 >$at_check_line_file
   31267 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   31268 at_status=$?
   31269 grep '^ *+' $at_stder1 >&2
   31270 grep -v '^ *+' $at_stder1 >$at_stderr
   31271 at_failed=false
   31272 $at_diff $at_devnull $at_stderr || at_failed=:
   31273 $at_diff expout $at_stdout || at_failed=:
   31274 case $at_status in
   31275    77) echo 77 > $at_status_file
   31276             exit 77;;
   31277    0) ;;
   31278    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31279       at_failed=:;;
   31280 esac
   31281 if $at_failed; then
   31282 
   31283   echo 1 > $at_status_file
   31284   exit 1
   31285 fi
   31286 
   31287 $at_traceon
   31288 
   31289 
   31290 
   31291 # Exercise the error token: without it, we die at the first error,
   31292 # hence be sure to
   31293 #
   31294 # - have several errors which exercise different shift/discardings
   31295 #   - (): nothing to pop, nothing to discard
   31296 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   31297 #   - (* * *): nothing to pop, a lot to discard
   31298 #   - (1 + 2 * *): some to pop and discard
   31299 #
   31300 # - test the action associated to `error'
   31301 #
   31302 # - check the look-ahead that triggers an error is not discarded
   31303 #   when we enter error recovery.  Below, the look-ahead causing the
   31304 #   first error is ")", which is needed to recover from the error and
   31305 #   produce the "0" that triggers the "0 != 1" error.
   31306 #
   31307 cat >input <<'_ATEOF'
   31308 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   31309 _ATEOF
   31310 
   31311 $at_traceoff
   31312 echo "calc.at:589: \$PREPARSER ./calc input"
   31313 echo calc.at:589 >$at_check_line_file
   31314 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   31315 at_status=$?
   31316 grep '^ *+' $at_stder1 >&2
   31317 grep -v '^ *+' $at_stder1 >$at_stderr
   31318 at_failed=false
   31319 echo stderr:; tee stderr <$at_stderr
   31320 $at_diff $at_devnull $at_stdout || at_failed=:
   31321 case $at_status in
   31322    77) echo 77 > $at_status_file
   31323             exit 77;;
   31324    0) ;;
   31325    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31326       at_failed=:;;
   31327 esac
   31328 if $at_failed; then
   31329 
   31330   echo 1 > $at_status_file
   31331   exit 1
   31332 fi
   31333 
   31334 $at_traceon
   31335 
   31336 
   31337 # Normalize the observed and expected error messages, depending upon the
   31338 # options.
   31339 # 1. Remove the traces from observed.
   31340 sed '/^Starting/d
   31341 /^Entering/d
   31342 /^Stack/d
   31343 /^Reading/d
   31344 /^Reducing/d
   31345 /^Shifting/d
   31346 /^state/d
   31347 /^Cleanup:/d
   31348 /^Error:/d
   31349 /^Next/d
   31350 /^Discarding/d
   31351 / \$[0-9$]* = /d
   31352 /^yydestructor:/d' stderr >at-stderr
   31353 mv at-stderr stderr
   31354 # 2. Create the reference error message.
   31355 cat >expout <<'_ATEOF'
   31356 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   31357 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   31358 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   31359 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   31360 calc: error: 4444 != 1
   31361 _ATEOF
   31362 
   31363 # 3. If locations are not used, remove them.
   31364 
   31365 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   31366 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   31367 mv at-expout expout
   31368 # 5. Check
   31369 $at_traceoff
   31370 echo "calc.at:589: cat stderr"
   31371 echo calc.at:589 >$at_check_line_file
   31372 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   31373 at_status=$?
   31374 grep '^ *+' $at_stder1 >&2
   31375 grep -v '^ *+' $at_stder1 >$at_stderr
   31376 at_failed=false
   31377 $at_diff $at_devnull $at_stderr || at_failed=:
   31378 $at_diff expout $at_stdout || at_failed=:
   31379 case $at_status in
   31380    77) echo 77 > $at_status_file
   31381             exit 77;;
   31382    0) ;;
   31383    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31384       at_failed=:;;
   31385 esac
   31386 if $at_failed; then
   31387 
   31388   echo 1 > $at_status_file
   31389   exit 1
   31390 fi
   31391 
   31392 $at_traceon
   31393 
   31394 
   31395 
   31396 # The same, but this time exercising explicitly triggered syntax errors.
   31397 # POSIX says the look-ahead causing the error should not be discarded.
   31398 cat >input <<'_ATEOF'
   31399 (!) + (0 0) = 1
   31400 _ATEOF
   31401 
   31402 $at_traceoff
   31403 echo "calc.at:589: \$PREPARSER ./calc input"
   31404 echo calc.at:589 >$at_check_line_file
   31405 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   31406 at_status=$?
   31407 grep '^ *+' $at_stder1 >&2
   31408 grep -v '^ *+' $at_stder1 >$at_stderr
   31409 at_failed=false
   31410 echo stderr:; tee stderr <$at_stderr
   31411 $at_diff $at_devnull $at_stdout || at_failed=:
   31412 case $at_status in
   31413    77) echo 77 > $at_status_file
   31414             exit 77;;
   31415    0) ;;
   31416    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31417       at_failed=:;;
   31418 esac
   31419 if $at_failed; then
   31420 
   31421   echo 1 > $at_status_file
   31422   exit 1
   31423 fi
   31424 
   31425 $at_traceon
   31426 
   31427 
   31428 # Normalize the observed and expected error messages, depending upon the
   31429 # options.
   31430 # 1. Remove the traces from observed.
   31431 sed '/^Starting/d
   31432 /^Entering/d
   31433 /^Stack/d
   31434 /^Reading/d
   31435 /^Reducing/d
   31436 /^Shifting/d
   31437 /^state/d
   31438 /^Cleanup:/d
   31439 /^Error:/d
   31440 /^Next/d
   31441 /^Discarding/d
   31442 / \$[0-9$]* = /d
   31443 /^yydestructor:/d' stderr >at-stderr
   31444 mv at-stderr stderr
   31445 # 2. Create the reference error message.
   31446 cat >expout <<'_ATEOF'
   31447 1.9: syntax error, unexpected number
   31448 calc: error: 2222 != 1
   31449 _ATEOF
   31450 
   31451 # 3. If locations are not used, remove them.
   31452 
   31453 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   31454 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   31455 mv at-expout expout
   31456 # 5. Check
   31457 $at_traceoff
   31458 echo "calc.at:589: cat stderr"
   31459 echo calc.at:589 >$at_check_line_file
   31460 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   31461 at_status=$?
   31462 grep '^ *+' $at_stder1 >&2
   31463 grep -v '^ *+' $at_stder1 >$at_stderr
   31464 at_failed=false
   31465 $at_diff $at_devnull $at_stderr || at_failed=:
   31466 $at_diff expout $at_stdout || at_failed=:
   31467 case $at_status in
   31468    77) echo 77 > $at_status_file
   31469             exit 77;;
   31470    0) ;;
   31471    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31472       at_failed=:;;
   31473 esac
   31474 if $at_failed; then
   31475 
   31476   echo 1 > $at_status_file
   31477   exit 1
   31478 fi
   31479 
   31480 $at_traceon
   31481 
   31482 
   31483 cat >input <<'_ATEOF'
   31484 (- *) + (0 0) = 1
   31485 _ATEOF
   31486 
   31487 $at_traceoff
   31488 echo "calc.at:589: \$PREPARSER ./calc input"
   31489 echo calc.at:589 >$at_check_line_file
   31490 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   31491 at_status=$?
   31492 grep '^ *+' $at_stder1 >&2
   31493 grep -v '^ *+' $at_stder1 >$at_stderr
   31494 at_failed=false
   31495 echo stderr:; tee stderr <$at_stderr
   31496 $at_diff $at_devnull $at_stdout || at_failed=:
   31497 case $at_status in
   31498    77) echo 77 > $at_status_file
   31499             exit 77;;
   31500    0) ;;
   31501    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31502       at_failed=:;;
   31503 esac
   31504 if $at_failed; then
   31505 
   31506   echo 1 > $at_status_file
   31507   exit 1
   31508 fi
   31509 
   31510 $at_traceon
   31511 
   31512 
   31513 # Normalize the observed and expected error messages, depending upon the
   31514 # options.
   31515 # 1. Remove the traces from observed.
   31516 sed '/^Starting/d
   31517 /^Entering/d
   31518 /^Stack/d
   31519 /^Reading/d
   31520 /^Reducing/d
   31521 /^Shifting/d
   31522 /^state/d
   31523 /^Cleanup:/d
   31524 /^Error:/d
   31525 /^Next/d
   31526 /^Discarding/d
   31527 / \$[0-9$]* = /d
   31528 /^yydestructor:/d' stderr >at-stderr
   31529 mv at-stderr stderr
   31530 # 2. Create the reference error message.
   31531 cat >expout <<'_ATEOF'
   31532 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   31533 1.11: syntax error, unexpected number
   31534 calc: error: 2222 != 1
   31535 _ATEOF
   31536 
   31537 # 3. If locations are not used, remove them.
   31538 
   31539 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   31540 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   31541 mv at-expout expout
   31542 # 5. Check
   31543 $at_traceoff
   31544 echo "calc.at:589: cat stderr"
   31545 echo calc.at:589 >$at_check_line_file
   31546 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   31547 at_status=$?
   31548 grep '^ *+' $at_stder1 >&2
   31549 grep -v '^ *+' $at_stder1 >$at_stderr
   31550 at_failed=false
   31551 $at_diff $at_devnull $at_stderr || at_failed=:
   31552 $at_diff expout $at_stdout || at_failed=:
   31553 case $at_status in
   31554    77) echo 77 > $at_status_file
   31555             exit 77;;
   31556    0) ;;
   31557    *) echo "calc.at:589: exit code was $at_status, expected 0"
   31558       at_failed=:;;
   31559 esac
   31560 if $at_failed; then
   31561 
   31562   echo 1 > $at_status_file
   31563   exit 1
   31564 fi
   31565 
   31566 $at_traceon
   31567 
   31568 
   31569 
   31570 
   31571 
   31572 
   31573 
   31574 
   31575 
   31576 
   31577 
   31578 
   31579 
   31580 
   31581 
   31582 
   31583 
   31584 
   31585 
   31586 
   31587 
   31588 
   31589 
   31590 
   31591       $at_traceoff
   31592       $at_times_p && times >$at_times_file
   31593     ) 5>&1 2>&1 | eval $at_tee_pipe
   31594     at_status=`cat $at_status_file`
   31595     ;;
   31596 
   31597   87 ) # 87. calc.at:590: Calculator %glr-parser %name-prefix="calc"
   31598     at_setup_line='calc.at:590'
   31599     at_desc='Calculator %glr-parser %name-prefix="calc"'
   31600     $at_quiet $ECHO_N " 87: Calculator %glr-parser %name-prefix="calc"   $ECHO_C"
   31601     at_xfail=no
   31602     (
   31603       echo "87. calc.at:590: testing ..."
   31604       $at_traceon
   31605 
   31606 
   31607 
   31608 
   31609 
   31610 
   31611 
   31612 
   31613 # Using yacc.c?
   31614 
   31615 
   31616 
   31617 
   31618 
   31619 
   31620 
   31621 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   31622 
   31623 # yyerror always sees the locations (when activated), except if
   31624 # yacc & pure & !param.
   31625 
   31626 
   31627 # The interface is pure: either because %pure-parser, or because we
   31628 # are using the C++ parsers.
   31629 
   31630 
   31631 
   31632 
   31633 
   31634 
   31635 
   31636 
   31637 
   31638 
   31639 
   31640 
   31641 cat >calc.y <<'_ATEOF'
   31642 %{
   31643 #ifdef HAVE_CONFIG_H
   31644 # include <config.h>
   31645   /* We don't need perfect functions for these tests. */
   31646 # undef malloc
   31647 # undef memcmp
   31648 # undef realloc
   31649 #endif
   31650 %}
   31651 
   31652 /* Infix notation calculator--calc */
   31653 %glr-parser %name-prefix="calc"
   31654 
   31655 %{
   31656 #include <stdio.h>
   31657 
   31658 #include <stdlib.h>
   31659 #include <string.h>
   31660 #if HAVE_UNISTD_H
   31661 # include <unistd.h>
   31662 #else
   31663 # undef alarm
   31664 # define alarm(seconds) /* empty */
   31665 #endif
   31666 #include <ctype.h>
   31667 #define USE(Var)
   31668 
   31669 /* Exercise pre-prologue dependency to %union.  */
   31670 typedef int semantic_value;
   31671 
   31672 static semantic_value global_result = 0;
   31673 static int global_count = 0;
   31674 %}
   31675 
   31676 /* Exercise %union. */
   31677 %union
   31678 {
   31679   semantic_value ival;
   31680 };
   31681 
   31682 %{
   31683 static int power (int base, int exponent);
   31684 /* yyerror receives the location if:
   31685    - %location & %pure & %glr
   31686    - %location & %pure & %yacc & %parse-param. */
   31687 static void yyerror (
   31688 
   31689                      const char *s
   31690                      );
   31691 static int yylex (void);
   31692 static int get_char (void);
   31693 static void unget_char ( int c);
   31694 %}
   31695 
   31696 
   31697 
   31698 /* Bison Declarations */
   31699 %token CALC_EOF 0 "end of input"
   31700 %token <ival> NUM "number"
   31701 %type  <ival> exp
   31702 
   31703 %nonassoc '=' /* comparison	       */
   31704 %left '-' '+'
   31705 %left '*' '/'
   31706 %left NEG     /* negation--unary minus */
   31707 %right '^'    /* exponentiation        */
   31708 
   31709 /* Grammar follows */
   31710 %%
   31711 input:
   31712   line
   31713 | input line         {  }
   31714 ;
   31715 
   31716 line:
   31717   '\n'
   31718 | exp '\n'           { USE ($1); }
   31719 ;
   31720 
   31721 exp:
   31722   NUM                { $$ = $1;             }
   31723 | exp '=' exp
   31724   {
   31725     if ($1 != $3)
   31726       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   31727     $$ = $1;
   31728   }
   31729 | exp '+' exp        { $$ = $1 + $3;        }
   31730 | exp '-' exp        { $$ = $1 - $3;        }
   31731 | exp '*' exp        { $$ = $1 * $3;        }
   31732 | exp '/' exp        { $$ = $1 / $3;        }
   31733 | '-' exp  %prec NEG { $$ = -$2;            }
   31734 | exp '^' exp        { $$ = power ($1, $3); }
   31735 | '(' exp ')'        { $$ = $2;             }
   31736 | '(' error ')'      { $$ = 1111;           }
   31737 | '!'                { $$ = 0; YYERROR;     }
   31738 | '-' error          { $$ = 0; YYERROR;     }
   31739 ;
   31740 %%
   31741 /* The input.  */
   31742 static FILE *input;
   31743 
   31744 static void
   31745 yyerror (
   31746 
   31747          const char *s)
   31748 {
   31749 
   31750 
   31751   fprintf (stderr, "%s\n", s);
   31752 }
   31753 
   31754 
   31755 
   31756 static int
   31757 get_char (void)
   31758 {
   31759   int res = getc (input);
   31760   ;
   31761 
   31762   return res;
   31763 }
   31764 
   31765 
   31766 static void
   31767 unget_char ( int c)
   31768 {
   31769   ;
   31770 
   31771   ungetc (c, input);
   31772 }
   31773 
   31774 static int
   31775 read_signed_integer (void)
   31776 {
   31777   int c = get_char ();
   31778   int sign = 1;
   31779   int n = 0;
   31780 
   31781   ;
   31782   if (c == '-')
   31783     {
   31784       c = get_char ();
   31785       sign = -1;
   31786     }
   31787 
   31788   while (isdigit (c))
   31789     {
   31790       n = 10 * n + (c - '0');
   31791       c = get_char ();
   31792     }
   31793 
   31794   unget_char ( c);
   31795 
   31796   return sign * n;
   31797 }
   31798 
   31799 
   31800 
   31801 /*---------------------------------------------------------------.
   31802 | Lexical analyzer returns an integer on the stack and the token |
   31803 | NUM, or the ASCII character read if not a number.  Skips all   |
   31804 | blanks and tabs, returns 0 for EOF.                            |
   31805 `---------------------------------------------------------------*/
   31806 
   31807 static int
   31808 yylex (void)
   31809 {
   31810   static int init = 1;
   31811   int c;
   31812 
   31813   if (init)
   31814     {
   31815       init = 0;
   31816 
   31817     }
   31818 
   31819 
   31820 
   31821   /* Skip white space.  */
   31822   while ((c = get_char ()) == ' ' || c == '\t')
   31823     {
   31824 
   31825     }
   31826 
   31827   /* process numbers   */
   31828   if (c == '.' || isdigit (c))
   31829     {
   31830       unget_char ( c);
   31831       (yylval).ival = read_signed_integer ();
   31832       return NUM;
   31833     }
   31834 
   31835   /* Return end-of-file.  */
   31836   if (c == EOF)
   31837     return CALC_EOF;
   31838 
   31839   /* Return single chars. */
   31840   return c;
   31841 }
   31842 
   31843 static int
   31844 power (int base, int exponent)
   31845 {
   31846   int res = 1;
   31847   if (exponent < 0)
   31848     exit (3);
   31849   for (/* Niente */; exponent; --exponent)
   31850     res *= base;
   31851   return res;
   31852 }
   31853 
   31854 
   31855 int
   31856 main (int argc, const char **argv)
   31857 {
   31858   semantic_value result = 0;
   31859   int count = 0;
   31860   int status;
   31861 
   31862   /* This used to be alarm (10), but that isn't enough time for
   31863      a July 1995 vintage DEC Alphastation 200 4/100 system,
   31864      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   31865   alarm (100);
   31866 
   31867   if (argc == 2)
   31868     input = fopen (argv[1], "r");
   31869   else
   31870     input = stdin;
   31871 
   31872   if (!input)
   31873     {
   31874       perror (argv[1]);
   31875       return 3;
   31876     }
   31877 
   31878 
   31879   status = yyparse ();
   31880   if (global_result != result)
   31881     abort ();
   31882   if (global_count != count)
   31883     abort ();
   31884   return status;
   31885 }
   31886 _ATEOF
   31887 
   31888 
   31889 
   31890 
   31891 
   31892 $at_traceoff
   31893 echo "calc.at:590: bison -o calc.c calc.y"
   31894 echo calc.at:590 >$at_check_line_file
   31895 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   31896 at_status=$?
   31897 grep '^ *+' $at_stder1 >&2
   31898 grep -v '^ *+' $at_stder1 >$at_stderr
   31899 at_failed=false
   31900 $at_diff $at_devnull $at_stderr || at_failed=:
   31901 $at_diff $at_devnull $at_stdout || at_failed=:
   31902 case $at_status in
   31903    77) echo 77 > $at_status_file
   31904             exit 77;;
   31905    0) ;;
   31906    *) echo "calc.at:590: exit code was $at_status, expected 0"
   31907       at_failed=:;;
   31908 esac
   31909 if $at_failed; then
   31910 
   31911   echo 1 > $at_status_file
   31912   exit 1
   31913 fi
   31914 
   31915 $at_traceon
   31916 
   31917    $at_traceoff
   31918 echo "calc.at:590: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   31919 echo calc.at:590 >$at_check_line_file
   31920 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   31921 at_status=$?
   31922 grep '^ *+' $at_stder1 >&2
   31923 grep -v '^ *+' $at_stder1 >$at_stderr
   31924 at_failed=false
   31925 echo stderr:; cat $at_stderr
   31926 echo stdout:; cat $at_stdout
   31927 case $at_status in
   31928    77) echo 77 > $at_status_file
   31929             exit 77;;
   31930    0) ;;
   31931    *) echo "calc.at:590: exit code was $at_status, expected 0"
   31932       at_failed=:;;
   31933 esac
   31934 if $at_failed; then
   31935 
   31936   echo 1 > $at_status_file
   31937   exit 1
   31938 fi
   31939 
   31940 $at_traceon
   31941 
   31942 
   31943 # Test the priorities.
   31944 cat >input <<'_ATEOF'
   31945 1 + 2 * 3 = 7
   31946 1 + 2 * -3 = -5
   31947 
   31948 -1^2 = -1
   31949 (-1)^2 = 1
   31950 
   31951 ---1 = -1
   31952 
   31953 1 - 2 - 3 = -4
   31954 1 - (2 - 3) = 2
   31955 
   31956 2^2^3 = 256
   31957 (2^2)^3 = 64
   31958 _ATEOF
   31959 
   31960 $at_traceoff
   31961 echo "calc.at:590: \$PREPARSER ./calc input"
   31962 echo calc.at:590 >$at_check_line_file
   31963 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   31964 at_status=$?
   31965 grep '^ *+' $at_stder1 >&2
   31966 grep -v '^ *+' $at_stder1 >$at_stderr
   31967 at_failed=false
   31968 echo stderr:; tee stderr <$at_stderr
   31969 $at_diff $at_devnull $at_stdout || at_failed=:
   31970 case $at_status in
   31971    77) echo 77 > $at_status_file
   31972             exit 77;;
   31973    0) ;;
   31974    *) echo "calc.at:590: exit code was $at_status, expected 0"
   31975       at_failed=:;;
   31976 esac
   31977 if $at_failed; then
   31978 
   31979   echo 1 > $at_status_file
   31980   exit 1
   31981 fi
   31982 
   31983 $at_traceon
   31984 
   31985 
   31986 
   31987 # Some syntax errors.
   31988 cat >input <<'_ATEOF'
   31989 0 0
   31990 _ATEOF
   31991 
   31992 $at_traceoff
   31993 echo "calc.at:590: \$PREPARSER ./calc input"
   31994 echo calc.at:590 >$at_check_line_file
   31995 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   31996 at_status=$?
   31997 grep '^ *+' $at_stder1 >&2
   31998 grep -v '^ *+' $at_stder1 >$at_stderr
   31999 at_failed=false
   32000 echo stderr:; tee stderr <$at_stderr
   32001 $at_diff $at_devnull $at_stdout || at_failed=:
   32002 case $at_status in
   32003    77) echo 77 > $at_status_file
   32004             exit 77;;
   32005    1) ;;
   32006    *) echo "calc.at:590: exit code was $at_status, expected 1"
   32007       at_failed=:;;
   32008 esac
   32009 if $at_failed; then
   32010 
   32011   echo 1 > $at_status_file
   32012   exit 1
   32013 fi
   32014 
   32015 $at_traceon
   32016 
   32017 
   32018 # Normalize the observed and expected error messages, depending upon the
   32019 # options.
   32020 # 1. Remove the traces from observed.
   32021 sed '/^Starting/d
   32022 /^Entering/d
   32023 /^Stack/d
   32024 /^Reading/d
   32025 /^Reducing/d
   32026 /^Shifting/d
   32027 /^state/d
   32028 /^Cleanup:/d
   32029 /^Error:/d
   32030 /^Next/d
   32031 /^Discarding/d
   32032 / \$[0-9$]* = /d
   32033 /^yydestructor:/d' stderr >at-stderr
   32034 mv at-stderr stderr
   32035 # 2. Create the reference error message.
   32036 cat >expout <<'_ATEOF'
   32037 1.2: syntax error, unexpected number
   32038 _ATEOF
   32039 
   32040 # 3. If locations are not used, remove them.
   32041 sed 's/^[-0-9.]*: //' expout >at-expout
   32042 mv at-expout expout
   32043 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   32044 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   32045 mv at-expout expout
   32046 # 5. Check
   32047 $at_traceoff
   32048 echo "calc.at:590: cat stderr"
   32049 echo calc.at:590 >$at_check_line_file
   32050 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   32051 at_status=$?
   32052 grep '^ *+' $at_stder1 >&2
   32053 grep -v '^ *+' $at_stder1 >$at_stderr
   32054 at_failed=false
   32055 $at_diff $at_devnull $at_stderr || at_failed=:
   32056 $at_diff expout $at_stdout || at_failed=:
   32057 case $at_status in
   32058    77) echo 77 > $at_status_file
   32059             exit 77;;
   32060    0) ;;
   32061    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32062       at_failed=:;;
   32063 esac
   32064 if $at_failed; then
   32065 
   32066   echo 1 > $at_status_file
   32067   exit 1
   32068 fi
   32069 
   32070 $at_traceon
   32071 
   32072 
   32073 cat >input <<'_ATEOF'
   32074 1//2
   32075 _ATEOF
   32076 
   32077 $at_traceoff
   32078 echo "calc.at:590: \$PREPARSER ./calc input"
   32079 echo calc.at:590 >$at_check_line_file
   32080 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   32081 at_status=$?
   32082 grep '^ *+' $at_stder1 >&2
   32083 grep -v '^ *+' $at_stder1 >$at_stderr
   32084 at_failed=false
   32085 echo stderr:; tee stderr <$at_stderr
   32086 $at_diff $at_devnull $at_stdout || at_failed=:
   32087 case $at_status in
   32088    77) echo 77 > $at_status_file
   32089             exit 77;;
   32090    1) ;;
   32091    *) echo "calc.at:590: exit code was $at_status, expected 1"
   32092       at_failed=:;;
   32093 esac
   32094 if $at_failed; then
   32095 
   32096   echo 1 > $at_status_file
   32097   exit 1
   32098 fi
   32099 
   32100 $at_traceon
   32101 
   32102 
   32103 # Normalize the observed and expected error messages, depending upon the
   32104 # options.
   32105 # 1. Remove the traces from observed.
   32106 sed '/^Starting/d
   32107 /^Entering/d
   32108 /^Stack/d
   32109 /^Reading/d
   32110 /^Reducing/d
   32111 /^Shifting/d
   32112 /^state/d
   32113 /^Cleanup:/d
   32114 /^Error:/d
   32115 /^Next/d
   32116 /^Discarding/d
   32117 / \$[0-9$]* = /d
   32118 /^yydestructor:/d' stderr >at-stderr
   32119 mv at-stderr stderr
   32120 # 2. Create the reference error message.
   32121 cat >expout <<'_ATEOF'
   32122 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   32123 _ATEOF
   32124 
   32125 # 3. If locations are not used, remove them.
   32126 sed 's/^[-0-9.]*: //' expout >at-expout
   32127 mv at-expout expout
   32128 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   32129 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   32130 mv at-expout expout
   32131 # 5. Check
   32132 $at_traceoff
   32133 echo "calc.at:590: cat stderr"
   32134 echo calc.at:590 >$at_check_line_file
   32135 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   32136 at_status=$?
   32137 grep '^ *+' $at_stder1 >&2
   32138 grep -v '^ *+' $at_stder1 >$at_stderr
   32139 at_failed=false
   32140 $at_diff $at_devnull $at_stderr || at_failed=:
   32141 $at_diff expout $at_stdout || at_failed=:
   32142 case $at_status in
   32143    77) echo 77 > $at_status_file
   32144             exit 77;;
   32145    0) ;;
   32146    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32147       at_failed=:;;
   32148 esac
   32149 if $at_failed; then
   32150 
   32151   echo 1 > $at_status_file
   32152   exit 1
   32153 fi
   32154 
   32155 $at_traceon
   32156 
   32157 
   32158 cat >input <<'_ATEOF'
   32159 error
   32160 _ATEOF
   32161 
   32162 $at_traceoff
   32163 echo "calc.at:590: \$PREPARSER ./calc input"
   32164 echo calc.at:590 >$at_check_line_file
   32165 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   32166 at_status=$?
   32167 grep '^ *+' $at_stder1 >&2
   32168 grep -v '^ *+' $at_stder1 >$at_stderr
   32169 at_failed=false
   32170 echo stderr:; tee stderr <$at_stderr
   32171 $at_diff $at_devnull $at_stdout || at_failed=:
   32172 case $at_status in
   32173    77) echo 77 > $at_status_file
   32174             exit 77;;
   32175    1) ;;
   32176    *) echo "calc.at:590: exit code was $at_status, expected 1"
   32177       at_failed=:;;
   32178 esac
   32179 if $at_failed; then
   32180 
   32181   echo 1 > $at_status_file
   32182   exit 1
   32183 fi
   32184 
   32185 $at_traceon
   32186 
   32187 
   32188 # Normalize the observed and expected error messages, depending upon the
   32189 # options.
   32190 # 1. Remove the traces from observed.
   32191 sed '/^Starting/d
   32192 /^Entering/d
   32193 /^Stack/d
   32194 /^Reading/d
   32195 /^Reducing/d
   32196 /^Shifting/d
   32197 /^state/d
   32198 /^Cleanup:/d
   32199 /^Error:/d
   32200 /^Next/d
   32201 /^Discarding/d
   32202 / \$[0-9$]* = /d
   32203 /^yydestructor:/d' stderr >at-stderr
   32204 mv at-stderr stderr
   32205 # 2. Create the reference error message.
   32206 cat >expout <<'_ATEOF'
   32207 1.0: syntax error, unexpected $undefined
   32208 _ATEOF
   32209 
   32210 # 3. If locations are not used, remove them.
   32211 sed 's/^[-0-9.]*: //' expout >at-expout
   32212 mv at-expout expout
   32213 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   32214 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   32215 mv at-expout expout
   32216 # 5. Check
   32217 $at_traceoff
   32218 echo "calc.at:590: cat stderr"
   32219 echo calc.at:590 >$at_check_line_file
   32220 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   32221 at_status=$?
   32222 grep '^ *+' $at_stder1 >&2
   32223 grep -v '^ *+' $at_stder1 >$at_stderr
   32224 at_failed=false
   32225 $at_diff $at_devnull $at_stderr || at_failed=:
   32226 $at_diff expout $at_stdout || at_failed=:
   32227 case $at_status in
   32228    77) echo 77 > $at_status_file
   32229             exit 77;;
   32230    0) ;;
   32231    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32232       at_failed=:;;
   32233 esac
   32234 if $at_failed; then
   32235 
   32236   echo 1 > $at_status_file
   32237   exit 1
   32238 fi
   32239 
   32240 $at_traceon
   32241 
   32242 
   32243 cat >input <<'_ATEOF'
   32244 1 = 2 = 3
   32245 _ATEOF
   32246 
   32247 $at_traceoff
   32248 echo "calc.at:590: \$PREPARSER ./calc input"
   32249 echo calc.at:590 >$at_check_line_file
   32250 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   32251 at_status=$?
   32252 grep '^ *+' $at_stder1 >&2
   32253 grep -v '^ *+' $at_stder1 >$at_stderr
   32254 at_failed=false
   32255 echo stderr:; tee stderr <$at_stderr
   32256 $at_diff $at_devnull $at_stdout || at_failed=:
   32257 case $at_status in
   32258    77) echo 77 > $at_status_file
   32259             exit 77;;
   32260    1) ;;
   32261    *) echo "calc.at:590: exit code was $at_status, expected 1"
   32262       at_failed=:;;
   32263 esac
   32264 if $at_failed; then
   32265 
   32266   echo 1 > $at_status_file
   32267   exit 1
   32268 fi
   32269 
   32270 $at_traceon
   32271 
   32272 
   32273 # Normalize the observed and expected error messages, depending upon the
   32274 # options.
   32275 # 1. Remove the traces from observed.
   32276 sed '/^Starting/d
   32277 /^Entering/d
   32278 /^Stack/d
   32279 /^Reading/d
   32280 /^Reducing/d
   32281 /^Shifting/d
   32282 /^state/d
   32283 /^Cleanup:/d
   32284 /^Error:/d
   32285 /^Next/d
   32286 /^Discarding/d
   32287 / \$[0-9$]* = /d
   32288 /^yydestructor:/d' stderr >at-stderr
   32289 mv at-stderr stderr
   32290 # 2. Create the reference error message.
   32291 cat >expout <<'_ATEOF'
   32292 1.6: syntax error, unexpected '='
   32293 _ATEOF
   32294 
   32295 # 3. If locations are not used, remove them.
   32296 sed 's/^[-0-9.]*: //' expout >at-expout
   32297 mv at-expout expout
   32298 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   32299 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   32300 mv at-expout expout
   32301 # 5. Check
   32302 $at_traceoff
   32303 echo "calc.at:590: cat stderr"
   32304 echo calc.at:590 >$at_check_line_file
   32305 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   32306 at_status=$?
   32307 grep '^ *+' $at_stder1 >&2
   32308 grep -v '^ *+' $at_stder1 >$at_stderr
   32309 at_failed=false
   32310 $at_diff $at_devnull $at_stderr || at_failed=:
   32311 $at_diff expout $at_stdout || at_failed=:
   32312 case $at_status in
   32313    77) echo 77 > $at_status_file
   32314             exit 77;;
   32315    0) ;;
   32316    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32317       at_failed=:;;
   32318 esac
   32319 if $at_failed; then
   32320 
   32321   echo 1 > $at_status_file
   32322   exit 1
   32323 fi
   32324 
   32325 $at_traceon
   32326 
   32327 
   32328 cat >input <<'_ATEOF'
   32329 
   32330 +1
   32331 _ATEOF
   32332 
   32333 $at_traceoff
   32334 echo "calc.at:590: \$PREPARSER ./calc input"
   32335 echo calc.at:590 >$at_check_line_file
   32336 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   32337 at_status=$?
   32338 grep '^ *+' $at_stder1 >&2
   32339 grep -v '^ *+' $at_stder1 >$at_stderr
   32340 at_failed=false
   32341 echo stderr:; tee stderr <$at_stderr
   32342 $at_diff $at_devnull $at_stdout || at_failed=:
   32343 case $at_status in
   32344    77) echo 77 > $at_status_file
   32345             exit 77;;
   32346    1) ;;
   32347    *) echo "calc.at:590: exit code was $at_status, expected 1"
   32348       at_failed=:;;
   32349 esac
   32350 if $at_failed; then
   32351 
   32352   echo 1 > $at_status_file
   32353   exit 1
   32354 fi
   32355 
   32356 $at_traceon
   32357 
   32358 
   32359 # Normalize the observed and expected error messages, depending upon the
   32360 # options.
   32361 # 1. Remove the traces from observed.
   32362 sed '/^Starting/d
   32363 /^Entering/d
   32364 /^Stack/d
   32365 /^Reading/d
   32366 /^Reducing/d
   32367 /^Shifting/d
   32368 /^state/d
   32369 /^Cleanup:/d
   32370 /^Error:/d
   32371 /^Next/d
   32372 /^Discarding/d
   32373 / \$[0-9$]* = /d
   32374 /^yydestructor:/d' stderr >at-stderr
   32375 mv at-stderr stderr
   32376 # 2. Create the reference error message.
   32377 cat >expout <<'_ATEOF'
   32378 2.0: syntax error, unexpected '+'
   32379 _ATEOF
   32380 
   32381 # 3. If locations are not used, remove them.
   32382 sed 's/^[-0-9.]*: //' expout >at-expout
   32383 mv at-expout expout
   32384 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   32385 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   32386 mv at-expout expout
   32387 # 5. Check
   32388 $at_traceoff
   32389 echo "calc.at:590: cat stderr"
   32390 echo calc.at:590 >$at_check_line_file
   32391 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   32392 at_status=$?
   32393 grep '^ *+' $at_stder1 >&2
   32394 grep -v '^ *+' $at_stder1 >$at_stderr
   32395 at_failed=false
   32396 $at_diff $at_devnull $at_stderr || at_failed=:
   32397 $at_diff expout $at_stdout || at_failed=:
   32398 case $at_status in
   32399    77) echo 77 > $at_status_file
   32400             exit 77;;
   32401    0) ;;
   32402    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32403       at_failed=:;;
   32404 esac
   32405 if $at_failed; then
   32406 
   32407   echo 1 > $at_status_file
   32408   exit 1
   32409 fi
   32410 
   32411 $at_traceon
   32412 
   32413 
   32414 # Exercise error messages with EOF: work on an empty file.
   32415 $at_traceoff
   32416 echo "calc.at:590: \$PREPARSER ./calc /dev/null"
   32417 echo calc.at:590 >$at_check_line_file
   32418 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   32419 at_status=$?
   32420 grep '^ *+' $at_stder1 >&2
   32421 grep -v '^ *+' $at_stder1 >$at_stderr
   32422 at_failed=false
   32423 echo stderr:; tee stderr <$at_stderr
   32424 $at_diff $at_devnull $at_stdout || at_failed=:
   32425 case $at_status in
   32426    77) echo 77 > $at_status_file
   32427             exit 77;;
   32428    1) ;;
   32429    *) echo "calc.at:590: exit code was $at_status, expected 1"
   32430       at_failed=:;;
   32431 esac
   32432 if $at_failed; then
   32433 
   32434   echo 1 > $at_status_file
   32435   exit 1
   32436 fi
   32437 
   32438 $at_traceon
   32439 
   32440 
   32441 # Normalize the observed and expected error messages, depending upon the
   32442 # options.
   32443 # 1. Remove the traces from observed.
   32444 sed '/^Starting/d
   32445 /^Entering/d
   32446 /^Stack/d
   32447 /^Reading/d
   32448 /^Reducing/d
   32449 /^Shifting/d
   32450 /^state/d
   32451 /^Cleanup:/d
   32452 /^Error:/d
   32453 /^Next/d
   32454 /^Discarding/d
   32455 / \$[0-9$]* = /d
   32456 /^yydestructor:/d' stderr >at-stderr
   32457 mv at-stderr stderr
   32458 # 2. Create the reference error message.
   32459 cat >expout <<'_ATEOF'
   32460 1.0: syntax error, unexpected end of input
   32461 _ATEOF
   32462 
   32463 # 3. If locations are not used, remove them.
   32464 sed 's/^[-0-9.]*: //' expout >at-expout
   32465 mv at-expout expout
   32466 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   32467 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   32468 mv at-expout expout
   32469 # 5. Check
   32470 $at_traceoff
   32471 echo "calc.at:590: cat stderr"
   32472 echo calc.at:590 >$at_check_line_file
   32473 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   32474 at_status=$?
   32475 grep '^ *+' $at_stder1 >&2
   32476 grep -v '^ *+' $at_stder1 >$at_stderr
   32477 at_failed=false
   32478 $at_diff $at_devnull $at_stderr || at_failed=:
   32479 $at_diff expout $at_stdout || at_failed=:
   32480 case $at_status in
   32481    77) echo 77 > $at_status_file
   32482             exit 77;;
   32483    0) ;;
   32484    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32485       at_failed=:;;
   32486 esac
   32487 if $at_failed; then
   32488 
   32489   echo 1 > $at_status_file
   32490   exit 1
   32491 fi
   32492 
   32493 $at_traceon
   32494 
   32495 
   32496 
   32497 # Exercise the error token: without it, we die at the first error,
   32498 # hence be sure to
   32499 #
   32500 # - have several errors which exercise different shift/discardings
   32501 #   - (): nothing to pop, nothing to discard
   32502 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   32503 #   - (* * *): nothing to pop, a lot to discard
   32504 #   - (1 + 2 * *): some to pop and discard
   32505 #
   32506 # - test the action associated to `error'
   32507 #
   32508 # - check the look-ahead that triggers an error is not discarded
   32509 #   when we enter error recovery.  Below, the look-ahead causing the
   32510 #   first error is ")", which is needed to recover from the error and
   32511 #   produce the "0" that triggers the "0 != 1" error.
   32512 #
   32513 cat >input <<'_ATEOF'
   32514 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   32515 _ATEOF
   32516 
   32517 $at_traceoff
   32518 echo "calc.at:590: \$PREPARSER ./calc input"
   32519 echo calc.at:590 >$at_check_line_file
   32520 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   32521 at_status=$?
   32522 grep '^ *+' $at_stder1 >&2
   32523 grep -v '^ *+' $at_stder1 >$at_stderr
   32524 at_failed=false
   32525 echo stderr:; tee stderr <$at_stderr
   32526 $at_diff $at_devnull $at_stdout || at_failed=:
   32527 case $at_status in
   32528    77) echo 77 > $at_status_file
   32529             exit 77;;
   32530    0) ;;
   32531    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32532       at_failed=:;;
   32533 esac
   32534 if $at_failed; then
   32535 
   32536   echo 1 > $at_status_file
   32537   exit 1
   32538 fi
   32539 
   32540 $at_traceon
   32541 
   32542 
   32543 # Normalize the observed and expected error messages, depending upon the
   32544 # options.
   32545 # 1. Remove the traces from observed.
   32546 sed '/^Starting/d
   32547 /^Entering/d
   32548 /^Stack/d
   32549 /^Reading/d
   32550 /^Reducing/d
   32551 /^Shifting/d
   32552 /^state/d
   32553 /^Cleanup:/d
   32554 /^Error:/d
   32555 /^Next/d
   32556 /^Discarding/d
   32557 / \$[0-9$]* = /d
   32558 /^yydestructor:/d' stderr >at-stderr
   32559 mv at-stderr stderr
   32560 # 2. Create the reference error message.
   32561 cat >expout <<'_ATEOF'
   32562 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   32563 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   32564 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   32565 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   32566 calc: error: 4444 != 1
   32567 _ATEOF
   32568 
   32569 # 3. If locations are not used, remove them.
   32570 sed 's/^[-0-9.]*: //' expout >at-expout
   32571 mv at-expout expout
   32572 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   32573 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   32574 mv at-expout expout
   32575 # 5. Check
   32576 $at_traceoff
   32577 echo "calc.at:590: cat stderr"
   32578 echo calc.at:590 >$at_check_line_file
   32579 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   32580 at_status=$?
   32581 grep '^ *+' $at_stder1 >&2
   32582 grep -v '^ *+' $at_stder1 >$at_stderr
   32583 at_failed=false
   32584 $at_diff $at_devnull $at_stderr || at_failed=:
   32585 $at_diff expout $at_stdout || at_failed=:
   32586 case $at_status in
   32587    77) echo 77 > $at_status_file
   32588             exit 77;;
   32589    0) ;;
   32590    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32591       at_failed=:;;
   32592 esac
   32593 if $at_failed; then
   32594 
   32595   echo 1 > $at_status_file
   32596   exit 1
   32597 fi
   32598 
   32599 $at_traceon
   32600 
   32601 
   32602 
   32603 # The same, but this time exercising explicitly triggered syntax errors.
   32604 # POSIX says the look-ahead causing the error should not be discarded.
   32605 cat >input <<'_ATEOF'
   32606 (!) + (0 0) = 1
   32607 _ATEOF
   32608 
   32609 $at_traceoff
   32610 echo "calc.at:590: \$PREPARSER ./calc input"
   32611 echo calc.at:590 >$at_check_line_file
   32612 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   32613 at_status=$?
   32614 grep '^ *+' $at_stder1 >&2
   32615 grep -v '^ *+' $at_stder1 >$at_stderr
   32616 at_failed=false
   32617 echo stderr:; tee stderr <$at_stderr
   32618 $at_diff $at_devnull $at_stdout || at_failed=:
   32619 case $at_status in
   32620    77) echo 77 > $at_status_file
   32621             exit 77;;
   32622    0) ;;
   32623    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32624       at_failed=:;;
   32625 esac
   32626 if $at_failed; then
   32627 
   32628   echo 1 > $at_status_file
   32629   exit 1
   32630 fi
   32631 
   32632 $at_traceon
   32633 
   32634 
   32635 # Normalize the observed and expected error messages, depending upon the
   32636 # options.
   32637 # 1. Remove the traces from observed.
   32638 sed '/^Starting/d
   32639 /^Entering/d
   32640 /^Stack/d
   32641 /^Reading/d
   32642 /^Reducing/d
   32643 /^Shifting/d
   32644 /^state/d
   32645 /^Cleanup:/d
   32646 /^Error:/d
   32647 /^Next/d
   32648 /^Discarding/d
   32649 / \$[0-9$]* = /d
   32650 /^yydestructor:/d' stderr >at-stderr
   32651 mv at-stderr stderr
   32652 # 2. Create the reference error message.
   32653 cat >expout <<'_ATEOF'
   32654 1.9: syntax error, unexpected number
   32655 calc: error: 2222 != 1
   32656 _ATEOF
   32657 
   32658 # 3. If locations are not used, remove them.
   32659 sed 's/^[-0-9.]*: //' expout >at-expout
   32660 mv at-expout expout
   32661 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   32662 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   32663 mv at-expout expout
   32664 # 5. Check
   32665 $at_traceoff
   32666 echo "calc.at:590: cat stderr"
   32667 echo calc.at:590 >$at_check_line_file
   32668 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   32669 at_status=$?
   32670 grep '^ *+' $at_stder1 >&2
   32671 grep -v '^ *+' $at_stder1 >$at_stderr
   32672 at_failed=false
   32673 $at_diff $at_devnull $at_stderr || at_failed=:
   32674 $at_diff expout $at_stdout || at_failed=:
   32675 case $at_status in
   32676    77) echo 77 > $at_status_file
   32677             exit 77;;
   32678    0) ;;
   32679    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32680       at_failed=:;;
   32681 esac
   32682 if $at_failed; then
   32683 
   32684   echo 1 > $at_status_file
   32685   exit 1
   32686 fi
   32687 
   32688 $at_traceon
   32689 
   32690 
   32691 cat >input <<'_ATEOF'
   32692 (- *) + (0 0) = 1
   32693 _ATEOF
   32694 
   32695 $at_traceoff
   32696 echo "calc.at:590: \$PREPARSER ./calc input"
   32697 echo calc.at:590 >$at_check_line_file
   32698 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   32699 at_status=$?
   32700 grep '^ *+' $at_stder1 >&2
   32701 grep -v '^ *+' $at_stder1 >$at_stderr
   32702 at_failed=false
   32703 echo stderr:; tee stderr <$at_stderr
   32704 $at_diff $at_devnull $at_stdout || at_failed=:
   32705 case $at_status in
   32706    77) echo 77 > $at_status_file
   32707             exit 77;;
   32708    0) ;;
   32709    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32710       at_failed=:;;
   32711 esac
   32712 if $at_failed; then
   32713 
   32714   echo 1 > $at_status_file
   32715   exit 1
   32716 fi
   32717 
   32718 $at_traceon
   32719 
   32720 
   32721 # Normalize the observed and expected error messages, depending upon the
   32722 # options.
   32723 # 1. Remove the traces from observed.
   32724 sed '/^Starting/d
   32725 /^Entering/d
   32726 /^Stack/d
   32727 /^Reading/d
   32728 /^Reducing/d
   32729 /^Shifting/d
   32730 /^state/d
   32731 /^Cleanup:/d
   32732 /^Error:/d
   32733 /^Next/d
   32734 /^Discarding/d
   32735 / \$[0-9$]* = /d
   32736 /^yydestructor:/d' stderr >at-stderr
   32737 mv at-stderr stderr
   32738 # 2. Create the reference error message.
   32739 cat >expout <<'_ATEOF'
   32740 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   32741 1.11: syntax error, unexpected number
   32742 calc: error: 2222 != 1
   32743 _ATEOF
   32744 
   32745 # 3. If locations are not used, remove them.
   32746 sed 's/^[-0-9.]*: //' expout >at-expout
   32747 mv at-expout expout
   32748 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   32749 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   32750 mv at-expout expout
   32751 # 5. Check
   32752 $at_traceoff
   32753 echo "calc.at:590: cat stderr"
   32754 echo calc.at:590 >$at_check_line_file
   32755 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   32756 at_status=$?
   32757 grep '^ *+' $at_stder1 >&2
   32758 grep -v '^ *+' $at_stder1 >$at_stderr
   32759 at_failed=false
   32760 $at_diff $at_devnull $at_stderr || at_failed=:
   32761 $at_diff expout $at_stdout || at_failed=:
   32762 case $at_status in
   32763    77) echo 77 > $at_status_file
   32764             exit 77;;
   32765    0) ;;
   32766    *) echo "calc.at:590: exit code was $at_status, expected 0"
   32767       at_failed=:;;
   32768 esac
   32769 if $at_failed; then
   32770 
   32771   echo 1 > $at_status_file
   32772   exit 1
   32773 fi
   32774 
   32775 $at_traceon
   32776 
   32777 
   32778 
   32779 
   32780 
   32781 
   32782 
   32783 
   32784 
   32785 
   32786 
   32787 
   32788 
   32789 
   32790 
   32791 
   32792 
   32793 
   32794 
   32795 
   32796 
   32797 
   32798 
   32799 
   32800       $at_traceoff
   32801       $at_times_p && times >$at_times_file
   32802     ) 5>&1 2>&1 | eval $at_tee_pipe
   32803     at_status=`cat $at_status_file`
   32804     ;;
   32805 
   32806   88 ) # 88. calc.at:591: Calculator %glr-parser %verbose
   32807     at_setup_line='calc.at:591'
   32808     at_desc='Calculator %glr-parser %verbose'
   32809     $at_quiet $ECHO_N " 88: Calculator %glr-parser %verbose              $ECHO_C"
   32810     at_xfail=no
   32811     (
   32812       echo "88. calc.at:591: testing ..."
   32813       $at_traceon
   32814 
   32815 
   32816 
   32817 
   32818 
   32819 
   32820 
   32821 
   32822 # Using yacc.c?
   32823 
   32824 
   32825 
   32826 
   32827 
   32828 
   32829 
   32830 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   32831 
   32832 # yyerror always sees the locations (when activated), except if
   32833 # yacc & pure & !param.
   32834 
   32835 
   32836 # The interface is pure: either because %pure-parser, or because we
   32837 # are using the C++ parsers.
   32838 
   32839 
   32840 
   32841 
   32842 
   32843 
   32844 
   32845 
   32846 
   32847 
   32848 
   32849 
   32850 cat >calc.y <<'_ATEOF'
   32851 %{
   32852 #ifdef HAVE_CONFIG_H
   32853 # include <config.h>
   32854   /* We don't need perfect functions for these tests. */
   32855 # undef malloc
   32856 # undef memcmp
   32857 # undef realloc
   32858 #endif
   32859 %}
   32860 
   32861 /* Infix notation calculator--calc */
   32862 %glr-parser %verbose
   32863 
   32864 %{
   32865 #include <stdio.h>
   32866 
   32867 #include <stdlib.h>
   32868 #include <string.h>
   32869 #if HAVE_UNISTD_H
   32870 # include <unistd.h>
   32871 #else
   32872 # undef alarm
   32873 # define alarm(seconds) /* empty */
   32874 #endif
   32875 #include <ctype.h>
   32876 #define USE(Var)
   32877 
   32878 /* Exercise pre-prologue dependency to %union.  */
   32879 typedef int semantic_value;
   32880 
   32881 static semantic_value global_result = 0;
   32882 static int global_count = 0;
   32883 %}
   32884 
   32885 /* Exercise %union. */
   32886 %union
   32887 {
   32888   semantic_value ival;
   32889 };
   32890 
   32891 %{
   32892 static int power (int base, int exponent);
   32893 /* yyerror receives the location if:
   32894    - %location & %pure & %glr
   32895    - %location & %pure & %yacc & %parse-param. */
   32896 static void yyerror (
   32897 
   32898                      const char *s
   32899                      );
   32900 static int yylex (void);
   32901 static int get_char (void);
   32902 static void unget_char ( int c);
   32903 %}
   32904 
   32905 
   32906 
   32907 /* Bison Declarations */
   32908 %token CALC_EOF 0 "end of input"
   32909 %token <ival> NUM "number"
   32910 %type  <ival> exp
   32911 
   32912 %nonassoc '=' /* comparison	       */
   32913 %left '-' '+'
   32914 %left '*' '/'
   32915 %left NEG     /* negation--unary minus */
   32916 %right '^'    /* exponentiation        */
   32917 
   32918 /* Grammar follows */
   32919 %%
   32920 input:
   32921   line
   32922 | input line         {  }
   32923 ;
   32924 
   32925 line:
   32926   '\n'
   32927 | exp '\n'           { USE ($1); }
   32928 ;
   32929 
   32930 exp:
   32931   NUM                { $$ = $1;             }
   32932 | exp '=' exp
   32933   {
   32934     if ($1 != $3)
   32935       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   32936     $$ = $1;
   32937   }
   32938 | exp '+' exp        { $$ = $1 + $3;        }
   32939 | exp '-' exp        { $$ = $1 - $3;        }
   32940 | exp '*' exp        { $$ = $1 * $3;        }
   32941 | exp '/' exp        { $$ = $1 / $3;        }
   32942 | '-' exp  %prec NEG { $$ = -$2;            }
   32943 | exp '^' exp        { $$ = power ($1, $3); }
   32944 | '(' exp ')'        { $$ = $2;             }
   32945 | '(' error ')'      { $$ = 1111;           }
   32946 | '!'                { $$ = 0; YYERROR;     }
   32947 | '-' error          { $$ = 0; YYERROR;     }
   32948 ;
   32949 %%
   32950 /* The input.  */
   32951 static FILE *input;
   32952 
   32953 static void
   32954 yyerror (
   32955 
   32956          const char *s)
   32957 {
   32958 
   32959 
   32960   fprintf (stderr, "%s\n", s);
   32961 }
   32962 
   32963 
   32964 
   32965 static int
   32966 get_char (void)
   32967 {
   32968   int res = getc (input);
   32969   ;
   32970 
   32971   return res;
   32972 }
   32973 
   32974 
   32975 static void
   32976 unget_char ( int c)
   32977 {
   32978   ;
   32979 
   32980   ungetc (c, input);
   32981 }
   32982 
   32983 static int
   32984 read_signed_integer (void)
   32985 {
   32986   int c = get_char ();
   32987   int sign = 1;
   32988   int n = 0;
   32989 
   32990   ;
   32991   if (c == '-')
   32992     {
   32993       c = get_char ();
   32994       sign = -1;
   32995     }
   32996 
   32997   while (isdigit (c))
   32998     {
   32999       n = 10 * n + (c - '0');
   33000       c = get_char ();
   33001     }
   33002 
   33003   unget_char ( c);
   33004 
   33005   return sign * n;
   33006 }
   33007 
   33008 
   33009 
   33010 /*---------------------------------------------------------------.
   33011 | Lexical analyzer returns an integer on the stack and the token |
   33012 | NUM, or the ASCII character read if not a number.  Skips all   |
   33013 | blanks and tabs, returns 0 for EOF.                            |
   33014 `---------------------------------------------------------------*/
   33015 
   33016 static int
   33017 yylex (void)
   33018 {
   33019   static int init = 1;
   33020   int c;
   33021 
   33022   if (init)
   33023     {
   33024       init = 0;
   33025 
   33026     }
   33027 
   33028 
   33029 
   33030   /* Skip white space.  */
   33031   while ((c = get_char ()) == ' ' || c == '\t')
   33032     {
   33033 
   33034     }
   33035 
   33036   /* process numbers   */
   33037   if (c == '.' || isdigit (c))
   33038     {
   33039       unget_char ( c);
   33040       (yylval).ival = read_signed_integer ();
   33041       return NUM;
   33042     }
   33043 
   33044   /* Return end-of-file.  */
   33045   if (c == EOF)
   33046     return CALC_EOF;
   33047 
   33048   /* Return single chars. */
   33049   return c;
   33050 }
   33051 
   33052 static int
   33053 power (int base, int exponent)
   33054 {
   33055   int res = 1;
   33056   if (exponent < 0)
   33057     exit (3);
   33058   for (/* Niente */; exponent; --exponent)
   33059     res *= base;
   33060   return res;
   33061 }
   33062 
   33063 
   33064 int
   33065 main (int argc, const char **argv)
   33066 {
   33067   semantic_value result = 0;
   33068   int count = 0;
   33069   int status;
   33070 
   33071   /* This used to be alarm (10), but that isn't enough time for
   33072      a July 1995 vintage DEC Alphastation 200 4/100 system,
   33073      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   33074   alarm (100);
   33075 
   33076   if (argc == 2)
   33077     input = fopen (argv[1], "r");
   33078   else
   33079     input = stdin;
   33080 
   33081   if (!input)
   33082     {
   33083       perror (argv[1]);
   33084       return 3;
   33085     }
   33086 
   33087 
   33088   status = yyparse ();
   33089   if (global_result != result)
   33090     abort ();
   33091   if (global_count != count)
   33092     abort ();
   33093   return status;
   33094 }
   33095 _ATEOF
   33096 
   33097 
   33098 
   33099 
   33100 
   33101 $at_traceoff
   33102 echo "calc.at:591: bison -o calc.c calc.y"
   33103 echo calc.at:591 >$at_check_line_file
   33104 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   33105 at_status=$?
   33106 grep '^ *+' $at_stder1 >&2
   33107 grep -v '^ *+' $at_stder1 >$at_stderr
   33108 at_failed=false
   33109 $at_diff $at_devnull $at_stderr || at_failed=:
   33110 $at_diff $at_devnull $at_stdout || at_failed=:
   33111 case $at_status in
   33112    77) echo 77 > $at_status_file
   33113             exit 77;;
   33114    0) ;;
   33115    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33116       at_failed=:;;
   33117 esac
   33118 if $at_failed; then
   33119 
   33120   echo 1 > $at_status_file
   33121   exit 1
   33122 fi
   33123 
   33124 $at_traceon
   33125 
   33126    $at_traceoff
   33127 echo "calc.at:591: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   33128 echo calc.at:591 >$at_check_line_file
   33129 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   33130 at_status=$?
   33131 grep '^ *+' $at_stder1 >&2
   33132 grep -v '^ *+' $at_stder1 >$at_stderr
   33133 at_failed=false
   33134 echo stderr:; cat $at_stderr
   33135 echo stdout:; cat $at_stdout
   33136 case $at_status in
   33137    77) echo 77 > $at_status_file
   33138             exit 77;;
   33139    0) ;;
   33140    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33141       at_failed=:;;
   33142 esac
   33143 if $at_failed; then
   33144 
   33145   echo 1 > $at_status_file
   33146   exit 1
   33147 fi
   33148 
   33149 $at_traceon
   33150 
   33151 
   33152 # Test the priorities.
   33153 cat >input <<'_ATEOF'
   33154 1 + 2 * 3 = 7
   33155 1 + 2 * -3 = -5
   33156 
   33157 -1^2 = -1
   33158 (-1)^2 = 1
   33159 
   33160 ---1 = -1
   33161 
   33162 1 - 2 - 3 = -4
   33163 1 - (2 - 3) = 2
   33164 
   33165 2^2^3 = 256
   33166 (2^2)^3 = 64
   33167 _ATEOF
   33168 
   33169 $at_traceoff
   33170 echo "calc.at:591: \$PREPARSER ./calc input"
   33171 echo calc.at:591 >$at_check_line_file
   33172 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   33173 at_status=$?
   33174 grep '^ *+' $at_stder1 >&2
   33175 grep -v '^ *+' $at_stder1 >$at_stderr
   33176 at_failed=false
   33177 echo stderr:; tee stderr <$at_stderr
   33178 $at_diff $at_devnull $at_stdout || at_failed=:
   33179 case $at_status in
   33180    77) echo 77 > $at_status_file
   33181             exit 77;;
   33182    0) ;;
   33183    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33184       at_failed=:;;
   33185 esac
   33186 if $at_failed; then
   33187 
   33188   echo 1 > $at_status_file
   33189   exit 1
   33190 fi
   33191 
   33192 $at_traceon
   33193 
   33194 
   33195 
   33196 # Some syntax errors.
   33197 cat >input <<'_ATEOF'
   33198 0 0
   33199 _ATEOF
   33200 
   33201 $at_traceoff
   33202 echo "calc.at:591: \$PREPARSER ./calc input"
   33203 echo calc.at:591 >$at_check_line_file
   33204 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   33205 at_status=$?
   33206 grep '^ *+' $at_stder1 >&2
   33207 grep -v '^ *+' $at_stder1 >$at_stderr
   33208 at_failed=false
   33209 echo stderr:; tee stderr <$at_stderr
   33210 $at_diff $at_devnull $at_stdout || at_failed=:
   33211 case $at_status in
   33212    77) echo 77 > $at_status_file
   33213             exit 77;;
   33214    1) ;;
   33215    *) echo "calc.at:591: exit code was $at_status, expected 1"
   33216       at_failed=:;;
   33217 esac
   33218 if $at_failed; then
   33219 
   33220   echo 1 > $at_status_file
   33221   exit 1
   33222 fi
   33223 
   33224 $at_traceon
   33225 
   33226 
   33227 # Normalize the observed and expected error messages, depending upon the
   33228 # options.
   33229 # 1. Remove the traces from observed.
   33230 sed '/^Starting/d
   33231 /^Entering/d
   33232 /^Stack/d
   33233 /^Reading/d
   33234 /^Reducing/d
   33235 /^Shifting/d
   33236 /^state/d
   33237 /^Cleanup:/d
   33238 /^Error:/d
   33239 /^Next/d
   33240 /^Discarding/d
   33241 / \$[0-9$]* = /d
   33242 /^yydestructor:/d' stderr >at-stderr
   33243 mv at-stderr stderr
   33244 # 2. Create the reference error message.
   33245 cat >expout <<'_ATEOF'
   33246 1.2: syntax error, unexpected number
   33247 _ATEOF
   33248 
   33249 # 3. If locations are not used, remove them.
   33250 sed 's/^[-0-9.]*: //' expout >at-expout
   33251 mv at-expout expout
   33252 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   33253 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   33254 mv at-expout expout
   33255 # 5. Check
   33256 $at_traceoff
   33257 echo "calc.at:591: cat stderr"
   33258 echo calc.at:591 >$at_check_line_file
   33259 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   33260 at_status=$?
   33261 grep '^ *+' $at_stder1 >&2
   33262 grep -v '^ *+' $at_stder1 >$at_stderr
   33263 at_failed=false
   33264 $at_diff $at_devnull $at_stderr || at_failed=:
   33265 $at_diff expout $at_stdout || at_failed=:
   33266 case $at_status in
   33267    77) echo 77 > $at_status_file
   33268             exit 77;;
   33269    0) ;;
   33270    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33271       at_failed=:;;
   33272 esac
   33273 if $at_failed; then
   33274 
   33275   echo 1 > $at_status_file
   33276   exit 1
   33277 fi
   33278 
   33279 $at_traceon
   33280 
   33281 
   33282 cat >input <<'_ATEOF'
   33283 1//2
   33284 _ATEOF
   33285 
   33286 $at_traceoff
   33287 echo "calc.at:591: \$PREPARSER ./calc input"
   33288 echo calc.at:591 >$at_check_line_file
   33289 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   33290 at_status=$?
   33291 grep '^ *+' $at_stder1 >&2
   33292 grep -v '^ *+' $at_stder1 >$at_stderr
   33293 at_failed=false
   33294 echo stderr:; tee stderr <$at_stderr
   33295 $at_diff $at_devnull $at_stdout || at_failed=:
   33296 case $at_status in
   33297    77) echo 77 > $at_status_file
   33298             exit 77;;
   33299    1) ;;
   33300    *) echo "calc.at:591: exit code was $at_status, expected 1"
   33301       at_failed=:;;
   33302 esac
   33303 if $at_failed; then
   33304 
   33305   echo 1 > $at_status_file
   33306   exit 1
   33307 fi
   33308 
   33309 $at_traceon
   33310 
   33311 
   33312 # Normalize the observed and expected error messages, depending upon the
   33313 # options.
   33314 # 1. Remove the traces from observed.
   33315 sed '/^Starting/d
   33316 /^Entering/d
   33317 /^Stack/d
   33318 /^Reading/d
   33319 /^Reducing/d
   33320 /^Shifting/d
   33321 /^state/d
   33322 /^Cleanup:/d
   33323 /^Error:/d
   33324 /^Next/d
   33325 /^Discarding/d
   33326 / \$[0-9$]* = /d
   33327 /^yydestructor:/d' stderr >at-stderr
   33328 mv at-stderr stderr
   33329 # 2. Create the reference error message.
   33330 cat >expout <<'_ATEOF'
   33331 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   33332 _ATEOF
   33333 
   33334 # 3. If locations are not used, remove them.
   33335 sed 's/^[-0-9.]*: //' expout >at-expout
   33336 mv at-expout expout
   33337 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   33338 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   33339 mv at-expout expout
   33340 # 5. Check
   33341 $at_traceoff
   33342 echo "calc.at:591: cat stderr"
   33343 echo calc.at:591 >$at_check_line_file
   33344 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   33345 at_status=$?
   33346 grep '^ *+' $at_stder1 >&2
   33347 grep -v '^ *+' $at_stder1 >$at_stderr
   33348 at_failed=false
   33349 $at_diff $at_devnull $at_stderr || at_failed=:
   33350 $at_diff expout $at_stdout || at_failed=:
   33351 case $at_status in
   33352    77) echo 77 > $at_status_file
   33353             exit 77;;
   33354    0) ;;
   33355    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33356       at_failed=:;;
   33357 esac
   33358 if $at_failed; then
   33359 
   33360   echo 1 > $at_status_file
   33361   exit 1
   33362 fi
   33363 
   33364 $at_traceon
   33365 
   33366 
   33367 cat >input <<'_ATEOF'
   33368 error
   33369 _ATEOF
   33370 
   33371 $at_traceoff
   33372 echo "calc.at:591: \$PREPARSER ./calc input"
   33373 echo calc.at:591 >$at_check_line_file
   33374 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   33375 at_status=$?
   33376 grep '^ *+' $at_stder1 >&2
   33377 grep -v '^ *+' $at_stder1 >$at_stderr
   33378 at_failed=false
   33379 echo stderr:; tee stderr <$at_stderr
   33380 $at_diff $at_devnull $at_stdout || at_failed=:
   33381 case $at_status in
   33382    77) echo 77 > $at_status_file
   33383             exit 77;;
   33384    1) ;;
   33385    *) echo "calc.at:591: exit code was $at_status, expected 1"
   33386       at_failed=:;;
   33387 esac
   33388 if $at_failed; then
   33389 
   33390   echo 1 > $at_status_file
   33391   exit 1
   33392 fi
   33393 
   33394 $at_traceon
   33395 
   33396 
   33397 # Normalize the observed and expected error messages, depending upon the
   33398 # options.
   33399 # 1. Remove the traces from observed.
   33400 sed '/^Starting/d
   33401 /^Entering/d
   33402 /^Stack/d
   33403 /^Reading/d
   33404 /^Reducing/d
   33405 /^Shifting/d
   33406 /^state/d
   33407 /^Cleanup:/d
   33408 /^Error:/d
   33409 /^Next/d
   33410 /^Discarding/d
   33411 / \$[0-9$]* = /d
   33412 /^yydestructor:/d' stderr >at-stderr
   33413 mv at-stderr stderr
   33414 # 2. Create the reference error message.
   33415 cat >expout <<'_ATEOF'
   33416 1.0: syntax error, unexpected $undefined
   33417 _ATEOF
   33418 
   33419 # 3. If locations are not used, remove them.
   33420 sed 's/^[-0-9.]*: //' expout >at-expout
   33421 mv at-expout expout
   33422 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   33423 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   33424 mv at-expout expout
   33425 # 5. Check
   33426 $at_traceoff
   33427 echo "calc.at:591: cat stderr"
   33428 echo calc.at:591 >$at_check_line_file
   33429 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   33430 at_status=$?
   33431 grep '^ *+' $at_stder1 >&2
   33432 grep -v '^ *+' $at_stder1 >$at_stderr
   33433 at_failed=false
   33434 $at_diff $at_devnull $at_stderr || at_failed=:
   33435 $at_diff expout $at_stdout || at_failed=:
   33436 case $at_status in
   33437    77) echo 77 > $at_status_file
   33438             exit 77;;
   33439    0) ;;
   33440    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33441       at_failed=:;;
   33442 esac
   33443 if $at_failed; then
   33444 
   33445   echo 1 > $at_status_file
   33446   exit 1
   33447 fi
   33448 
   33449 $at_traceon
   33450 
   33451 
   33452 cat >input <<'_ATEOF'
   33453 1 = 2 = 3
   33454 _ATEOF
   33455 
   33456 $at_traceoff
   33457 echo "calc.at:591: \$PREPARSER ./calc input"
   33458 echo calc.at:591 >$at_check_line_file
   33459 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   33460 at_status=$?
   33461 grep '^ *+' $at_stder1 >&2
   33462 grep -v '^ *+' $at_stder1 >$at_stderr
   33463 at_failed=false
   33464 echo stderr:; tee stderr <$at_stderr
   33465 $at_diff $at_devnull $at_stdout || at_failed=:
   33466 case $at_status in
   33467    77) echo 77 > $at_status_file
   33468             exit 77;;
   33469    1) ;;
   33470    *) echo "calc.at:591: exit code was $at_status, expected 1"
   33471       at_failed=:;;
   33472 esac
   33473 if $at_failed; then
   33474 
   33475   echo 1 > $at_status_file
   33476   exit 1
   33477 fi
   33478 
   33479 $at_traceon
   33480 
   33481 
   33482 # Normalize the observed and expected error messages, depending upon the
   33483 # options.
   33484 # 1. Remove the traces from observed.
   33485 sed '/^Starting/d
   33486 /^Entering/d
   33487 /^Stack/d
   33488 /^Reading/d
   33489 /^Reducing/d
   33490 /^Shifting/d
   33491 /^state/d
   33492 /^Cleanup:/d
   33493 /^Error:/d
   33494 /^Next/d
   33495 /^Discarding/d
   33496 / \$[0-9$]* = /d
   33497 /^yydestructor:/d' stderr >at-stderr
   33498 mv at-stderr stderr
   33499 # 2. Create the reference error message.
   33500 cat >expout <<'_ATEOF'
   33501 1.6: syntax error, unexpected '='
   33502 _ATEOF
   33503 
   33504 # 3. If locations are not used, remove them.
   33505 sed 's/^[-0-9.]*: //' expout >at-expout
   33506 mv at-expout expout
   33507 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   33508 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   33509 mv at-expout expout
   33510 # 5. Check
   33511 $at_traceoff
   33512 echo "calc.at:591: cat stderr"
   33513 echo calc.at:591 >$at_check_line_file
   33514 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   33515 at_status=$?
   33516 grep '^ *+' $at_stder1 >&2
   33517 grep -v '^ *+' $at_stder1 >$at_stderr
   33518 at_failed=false
   33519 $at_diff $at_devnull $at_stderr || at_failed=:
   33520 $at_diff expout $at_stdout || at_failed=:
   33521 case $at_status in
   33522    77) echo 77 > $at_status_file
   33523             exit 77;;
   33524    0) ;;
   33525    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33526       at_failed=:;;
   33527 esac
   33528 if $at_failed; then
   33529 
   33530   echo 1 > $at_status_file
   33531   exit 1
   33532 fi
   33533 
   33534 $at_traceon
   33535 
   33536 
   33537 cat >input <<'_ATEOF'
   33538 
   33539 +1
   33540 _ATEOF
   33541 
   33542 $at_traceoff
   33543 echo "calc.at:591: \$PREPARSER ./calc input"
   33544 echo calc.at:591 >$at_check_line_file
   33545 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   33546 at_status=$?
   33547 grep '^ *+' $at_stder1 >&2
   33548 grep -v '^ *+' $at_stder1 >$at_stderr
   33549 at_failed=false
   33550 echo stderr:; tee stderr <$at_stderr
   33551 $at_diff $at_devnull $at_stdout || at_failed=:
   33552 case $at_status in
   33553    77) echo 77 > $at_status_file
   33554             exit 77;;
   33555    1) ;;
   33556    *) echo "calc.at:591: exit code was $at_status, expected 1"
   33557       at_failed=:;;
   33558 esac
   33559 if $at_failed; then
   33560 
   33561   echo 1 > $at_status_file
   33562   exit 1
   33563 fi
   33564 
   33565 $at_traceon
   33566 
   33567 
   33568 # Normalize the observed and expected error messages, depending upon the
   33569 # options.
   33570 # 1. Remove the traces from observed.
   33571 sed '/^Starting/d
   33572 /^Entering/d
   33573 /^Stack/d
   33574 /^Reading/d
   33575 /^Reducing/d
   33576 /^Shifting/d
   33577 /^state/d
   33578 /^Cleanup:/d
   33579 /^Error:/d
   33580 /^Next/d
   33581 /^Discarding/d
   33582 / \$[0-9$]* = /d
   33583 /^yydestructor:/d' stderr >at-stderr
   33584 mv at-stderr stderr
   33585 # 2. Create the reference error message.
   33586 cat >expout <<'_ATEOF'
   33587 2.0: syntax error, unexpected '+'
   33588 _ATEOF
   33589 
   33590 # 3. If locations are not used, remove them.
   33591 sed 's/^[-0-9.]*: //' expout >at-expout
   33592 mv at-expout expout
   33593 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   33594 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   33595 mv at-expout expout
   33596 # 5. Check
   33597 $at_traceoff
   33598 echo "calc.at:591: cat stderr"
   33599 echo calc.at:591 >$at_check_line_file
   33600 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   33601 at_status=$?
   33602 grep '^ *+' $at_stder1 >&2
   33603 grep -v '^ *+' $at_stder1 >$at_stderr
   33604 at_failed=false
   33605 $at_diff $at_devnull $at_stderr || at_failed=:
   33606 $at_diff expout $at_stdout || at_failed=:
   33607 case $at_status in
   33608    77) echo 77 > $at_status_file
   33609             exit 77;;
   33610    0) ;;
   33611    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33612       at_failed=:;;
   33613 esac
   33614 if $at_failed; then
   33615 
   33616   echo 1 > $at_status_file
   33617   exit 1
   33618 fi
   33619 
   33620 $at_traceon
   33621 
   33622 
   33623 # Exercise error messages with EOF: work on an empty file.
   33624 $at_traceoff
   33625 echo "calc.at:591: \$PREPARSER ./calc /dev/null"
   33626 echo calc.at:591 >$at_check_line_file
   33627 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   33628 at_status=$?
   33629 grep '^ *+' $at_stder1 >&2
   33630 grep -v '^ *+' $at_stder1 >$at_stderr
   33631 at_failed=false
   33632 echo stderr:; tee stderr <$at_stderr
   33633 $at_diff $at_devnull $at_stdout || at_failed=:
   33634 case $at_status in
   33635    77) echo 77 > $at_status_file
   33636             exit 77;;
   33637    1) ;;
   33638    *) echo "calc.at:591: exit code was $at_status, expected 1"
   33639       at_failed=:;;
   33640 esac
   33641 if $at_failed; then
   33642 
   33643   echo 1 > $at_status_file
   33644   exit 1
   33645 fi
   33646 
   33647 $at_traceon
   33648 
   33649 
   33650 # Normalize the observed and expected error messages, depending upon the
   33651 # options.
   33652 # 1. Remove the traces from observed.
   33653 sed '/^Starting/d
   33654 /^Entering/d
   33655 /^Stack/d
   33656 /^Reading/d
   33657 /^Reducing/d
   33658 /^Shifting/d
   33659 /^state/d
   33660 /^Cleanup:/d
   33661 /^Error:/d
   33662 /^Next/d
   33663 /^Discarding/d
   33664 / \$[0-9$]* = /d
   33665 /^yydestructor:/d' stderr >at-stderr
   33666 mv at-stderr stderr
   33667 # 2. Create the reference error message.
   33668 cat >expout <<'_ATEOF'
   33669 1.0: syntax error, unexpected end of input
   33670 _ATEOF
   33671 
   33672 # 3. If locations are not used, remove them.
   33673 sed 's/^[-0-9.]*: //' expout >at-expout
   33674 mv at-expout expout
   33675 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   33676 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   33677 mv at-expout expout
   33678 # 5. Check
   33679 $at_traceoff
   33680 echo "calc.at:591: cat stderr"
   33681 echo calc.at:591 >$at_check_line_file
   33682 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   33683 at_status=$?
   33684 grep '^ *+' $at_stder1 >&2
   33685 grep -v '^ *+' $at_stder1 >$at_stderr
   33686 at_failed=false
   33687 $at_diff $at_devnull $at_stderr || at_failed=:
   33688 $at_diff expout $at_stdout || at_failed=:
   33689 case $at_status in
   33690    77) echo 77 > $at_status_file
   33691             exit 77;;
   33692    0) ;;
   33693    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33694       at_failed=:;;
   33695 esac
   33696 if $at_failed; then
   33697 
   33698   echo 1 > $at_status_file
   33699   exit 1
   33700 fi
   33701 
   33702 $at_traceon
   33703 
   33704 
   33705 
   33706 # Exercise the error token: without it, we die at the first error,
   33707 # hence be sure to
   33708 #
   33709 # - have several errors which exercise different shift/discardings
   33710 #   - (): nothing to pop, nothing to discard
   33711 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   33712 #   - (* * *): nothing to pop, a lot to discard
   33713 #   - (1 + 2 * *): some to pop and discard
   33714 #
   33715 # - test the action associated to `error'
   33716 #
   33717 # - check the look-ahead that triggers an error is not discarded
   33718 #   when we enter error recovery.  Below, the look-ahead causing the
   33719 #   first error is ")", which is needed to recover from the error and
   33720 #   produce the "0" that triggers the "0 != 1" error.
   33721 #
   33722 cat >input <<'_ATEOF'
   33723 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   33724 _ATEOF
   33725 
   33726 $at_traceoff
   33727 echo "calc.at:591: \$PREPARSER ./calc input"
   33728 echo calc.at:591 >$at_check_line_file
   33729 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   33730 at_status=$?
   33731 grep '^ *+' $at_stder1 >&2
   33732 grep -v '^ *+' $at_stder1 >$at_stderr
   33733 at_failed=false
   33734 echo stderr:; tee stderr <$at_stderr
   33735 $at_diff $at_devnull $at_stdout || at_failed=:
   33736 case $at_status in
   33737    77) echo 77 > $at_status_file
   33738             exit 77;;
   33739    0) ;;
   33740    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33741       at_failed=:;;
   33742 esac
   33743 if $at_failed; then
   33744 
   33745   echo 1 > $at_status_file
   33746   exit 1
   33747 fi
   33748 
   33749 $at_traceon
   33750 
   33751 
   33752 # Normalize the observed and expected error messages, depending upon the
   33753 # options.
   33754 # 1. Remove the traces from observed.
   33755 sed '/^Starting/d
   33756 /^Entering/d
   33757 /^Stack/d
   33758 /^Reading/d
   33759 /^Reducing/d
   33760 /^Shifting/d
   33761 /^state/d
   33762 /^Cleanup:/d
   33763 /^Error:/d
   33764 /^Next/d
   33765 /^Discarding/d
   33766 / \$[0-9$]* = /d
   33767 /^yydestructor:/d' stderr >at-stderr
   33768 mv at-stderr stderr
   33769 # 2. Create the reference error message.
   33770 cat >expout <<'_ATEOF'
   33771 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   33772 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   33773 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   33774 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   33775 calc: error: 4444 != 1
   33776 _ATEOF
   33777 
   33778 # 3. If locations are not used, remove them.
   33779 sed 's/^[-0-9.]*: //' expout >at-expout
   33780 mv at-expout expout
   33781 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   33782 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   33783 mv at-expout expout
   33784 # 5. Check
   33785 $at_traceoff
   33786 echo "calc.at:591: cat stderr"
   33787 echo calc.at:591 >$at_check_line_file
   33788 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   33789 at_status=$?
   33790 grep '^ *+' $at_stder1 >&2
   33791 grep -v '^ *+' $at_stder1 >$at_stderr
   33792 at_failed=false
   33793 $at_diff $at_devnull $at_stderr || at_failed=:
   33794 $at_diff expout $at_stdout || at_failed=:
   33795 case $at_status in
   33796    77) echo 77 > $at_status_file
   33797             exit 77;;
   33798    0) ;;
   33799    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33800       at_failed=:;;
   33801 esac
   33802 if $at_failed; then
   33803 
   33804   echo 1 > $at_status_file
   33805   exit 1
   33806 fi
   33807 
   33808 $at_traceon
   33809 
   33810 
   33811 
   33812 # The same, but this time exercising explicitly triggered syntax errors.
   33813 # POSIX says the look-ahead causing the error should not be discarded.
   33814 cat >input <<'_ATEOF'
   33815 (!) + (0 0) = 1
   33816 _ATEOF
   33817 
   33818 $at_traceoff
   33819 echo "calc.at:591: \$PREPARSER ./calc input"
   33820 echo calc.at:591 >$at_check_line_file
   33821 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   33822 at_status=$?
   33823 grep '^ *+' $at_stder1 >&2
   33824 grep -v '^ *+' $at_stder1 >$at_stderr
   33825 at_failed=false
   33826 echo stderr:; tee stderr <$at_stderr
   33827 $at_diff $at_devnull $at_stdout || at_failed=:
   33828 case $at_status in
   33829    77) echo 77 > $at_status_file
   33830             exit 77;;
   33831    0) ;;
   33832    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33833       at_failed=:;;
   33834 esac
   33835 if $at_failed; then
   33836 
   33837   echo 1 > $at_status_file
   33838   exit 1
   33839 fi
   33840 
   33841 $at_traceon
   33842 
   33843 
   33844 # Normalize the observed and expected error messages, depending upon the
   33845 # options.
   33846 # 1. Remove the traces from observed.
   33847 sed '/^Starting/d
   33848 /^Entering/d
   33849 /^Stack/d
   33850 /^Reading/d
   33851 /^Reducing/d
   33852 /^Shifting/d
   33853 /^state/d
   33854 /^Cleanup:/d
   33855 /^Error:/d
   33856 /^Next/d
   33857 /^Discarding/d
   33858 / \$[0-9$]* = /d
   33859 /^yydestructor:/d' stderr >at-stderr
   33860 mv at-stderr stderr
   33861 # 2. Create the reference error message.
   33862 cat >expout <<'_ATEOF'
   33863 1.9: syntax error, unexpected number
   33864 calc: error: 2222 != 1
   33865 _ATEOF
   33866 
   33867 # 3. If locations are not used, remove them.
   33868 sed 's/^[-0-9.]*: //' expout >at-expout
   33869 mv at-expout expout
   33870 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   33871 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   33872 mv at-expout expout
   33873 # 5. Check
   33874 $at_traceoff
   33875 echo "calc.at:591: cat stderr"
   33876 echo calc.at:591 >$at_check_line_file
   33877 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   33878 at_status=$?
   33879 grep '^ *+' $at_stder1 >&2
   33880 grep -v '^ *+' $at_stder1 >$at_stderr
   33881 at_failed=false
   33882 $at_diff $at_devnull $at_stderr || at_failed=:
   33883 $at_diff expout $at_stdout || at_failed=:
   33884 case $at_status in
   33885    77) echo 77 > $at_status_file
   33886             exit 77;;
   33887    0) ;;
   33888    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33889       at_failed=:;;
   33890 esac
   33891 if $at_failed; then
   33892 
   33893   echo 1 > $at_status_file
   33894   exit 1
   33895 fi
   33896 
   33897 $at_traceon
   33898 
   33899 
   33900 cat >input <<'_ATEOF'
   33901 (- *) + (0 0) = 1
   33902 _ATEOF
   33903 
   33904 $at_traceoff
   33905 echo "calc.at:591: \$PREPARSER ./calc input"
   33906 echo calc.at:591 >$at_check_line_file
   33907 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   33908 at_status=$?
   33909 grep '^ *+' $at_stder1 >&2
   33910 grep -v '^ *+' $at_stder1 >$at_stderr
   33911 at_failed=false
   33912 echo stderr:; tee stderr <$at_stderr
   33913 $at_diff $at_devnull $at_stdout || at_failed=:
   33914 case $at_status in
   33915    77) echo 77 > $at_status_file
   33916             exit 77;;
   33917    0) ;;
   33918    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33919       at_failed=:;;
   33920 esac
   33921 if $at_failed; then
   33922 
   33923   echo 1 > $at_status_file
   33924   exit 1
   33925 fi
   33926 
   33927 $at_traceon
   33928 
   33929 
   33930 # Normalize the observed and expected error messages, depending upon the
   33931 # options.
   33932 # 1. Remove the traces from observed.
   33933 sed '/^Starting/d
   33934 /^Entering/d
   33935 /^Stack/d
   33936 /^Reading/d
   33937 /^Reducing/d
   33938 /^Shifting/d
   33939 /^state/d
   33940 /^Cleanup:/d
   33941 /^Error:/d
   33942 /^Next/d
   33943 /^Discarding/d
   33944 / \$[0-9$]* = /d
   33945 /^yydestructor:/d' stderr >at-stderr
   33946 mv at-stderr stderr
   33947 # 2. Create the reference error message.
   33948 cat >expout <<'_ATEOF'
   33949 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   33950 1.11: syntax error, unexpected number
   33951 calc: error: 2222 != 1
   33952 _ATEOF
   33953 
   33954 # 3. If locations are not used, remove them.
   33955 sed 's/^[-0-9.]*: //' expout >at-expout
   33956 mv at-expout expout
   33957 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   33958 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   33959 mv at-expout expout
   33960 # 5. Check
   33961 $at_traceoff
   33962 echo "calc.at:591: cat stderr"
   33963 echo calc.at:591 >$at_check_line_file
   33964 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   33965 at_status=$?
   33966 grep '^ *+' $at_stder1 >&2
   33967 grep -v '^ *+' $at_stder1 >$at_stderr
   33968 at_failed=false
   33969 $at_diff $at_devnull $at_stderr || at_failed=:
   33970 $at_diff expout $at_stdout || at_failed=:
   33971 case $at_status in
   33972    77) echo 77 > $at_status_file
   33973             exit 77;;
   33974    0) ;;
   33975    *) echo "calc.at:591: exit code was $at_status, expected 0"
   33976       at_failed=:;;
   33977 esac
   33978 if $at_failed; then
   33979 
   33980   echo 1 > $at_status_file
   33981   exit 1
   33982 fi
   33983 
   33984 $at_traceon
   33985 
   33986 
   33987 
   33988 
   33989 
   33990 
   33991 
   33992 
   33993 
   33994 
   33995 
   33996 
   33997 
   33998 
   33999 
   34000 
   34001 
   34002 
   34003 
   34004 
   34005 
   34006 
   34007 
   34008 
   34009       $at_traceoff
   34010       $at_times_p && times >$at_times_file
   34011     ) 5>&1 2>&1 | eval $at_tee_pipe
   34012     at_status=`cat $at_status_file`
   34013     ;;
   34014 
   34015   89 ) # 89. calc.at:592: Calculator %glr-parser %yacc
   34016     at_setup_line='calc.at:592'
   34017     at_desc='Calculator %glr-parser %yacc'
   34018     $at_quiet $ECHO_N " 89: Calculator %glr-parser %yacc                 $ECHO_C"
   34019     at_xfail=no
   34020     (
   34021       echo "89. calc.at:592: testing ..."
   34022       $at_traceon
   34023 
   34024 
   34025 
   34026 
   34027 
   34028 
   34029 
   34030 
   34031 # Using yacc.c?
   34032 
   34033 
   34034 
   34035 
   34036 
   34037 
   34038 
   34039 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   34040 
   34041 # yyerror always sees the locations (when activated), except if
   34042 # yacc & pure & !param.
   34043 
   34044 
   34045 # The interface is pure: either because %pure-parser, or because we
   34046 # are using the C++ parsers.
   34047 
   34048 
   34049 
   34050 
   34051 
   34052 
   34053 
   34054 
   34055 
   34056 
   34057 
   34058 
   34059 cat >calc.y <<'_ATEOF'
   34060 %{
   34061 #ifdef HAVE_CONFIG_H
   34062 # include <config.h>
   34063   /* We don't need perfect functions for these tests. */
   34064 # undef malloc
   34065 # undef memcmp
   34066 # undef realloc
   34067 #endif
   34068 %}
   34069 
   34070 /* Infix notation calculator--calc */
   34071 %glr-parser %yacc
   34072 
   34073 %{
   34074 #include <stdio.h>
   34075 
   34076 #include <stdlib.h>
   34077 #include <string.h>
   34078 #if HAVE_UNISTD_H
   34079 # include <unistd.h>
   34080 #else
   34081 # undef alarm
   34082 # define alarm(seconds) /* empty */
   34083 #endif
   34084 #include <ctype.h>
   34085 #define USE(Var)
   34086 
   34087 /* Exercise pre-prologue dependency to %union.  */
   34088 typedef int semantic_value;
   34089 
   34090 static semantic_value global_result = 0;
   34091 static int global_count = 0;
   34092 %}
   34093 
   34094 /* Exercise %union. */
   34095 %union
   34096 {
   34097   semantic_value ival;
   34098 };
   34099 
   34100 %{
   34101 static int power (int base, int exponent);
   34102 /* yyerror receives the location if:
   34103    - %location & %pure & %glr
   34104    - %location & %pure & %yacc & %parse-param. */
   34105 static void yyerror (
   34106 
   34107                      const char *s
   34108                      );
   34109 static int yylex (void);
   34110 static int get_char (void);
   34111 static void unget_char ( int c);
   34112 %}
   34113 
   34114 
   34115 
   34116 /* Bison Declarations */
   34117 %token CALC_EOF 0 "end of input"
   34118 %token <ival> NUM "number"
   34119 %type  <ival> exp
   34120 
   34121 %nonassoc '=' /* comparison	       */
   34122 %left '-' '+'
   34123 %left '*' '/'
   34124 %left NEG     /* negation--unary minus */
   34125 %right '^'    /* exponentiation        */
   34126 
   34127 /* Grammar follows */
   34128 %%
   34129 input:
   34130   line
   34131 | input line         {  }
   34132 ;
   34133 
   34134 line:
   34135   '\n'
   34136 | exp '\n'           { USE ($1); }
   34137 ;
   34138 
   34139 exp:
   34140   NUM                { $$ = $1;             }
   34141 | exp '=' exp
   34142   {
   34143     if ($1 != $3)
   34144       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   34145     $$ = $1;
   34146   }
   34147 | exp '+' exp        { $$ = $1 + $3;        }
   34148 | exp '-' exp        { $$ = $1 - $3;        }
   34149 | exp '*' exp        { $$ = $1 * $3;        }
   34150 | exp '/' exp        { $$ = $1 / $3;        }
   34151 | '-' exp  %prec NEG { $$ = -$2;            }
   34152 | exp '^' exp        { $$ = power ($1, $3); }
   34153 | '(' exp ')'        { $$ = $2;             }
   34154 | '(' error ')'      { $$ = 1111;           }
   34155 | '!'                { $$ = 0; YYERROR;     }
   34156 | '-' error          { $$ = 0; YYERROR;     }
   34157 ;
   34158 %%
   34159 /* The input.  */
   34160 static FILE *input;
   34161 
   34162 static void
   34163 yyerror (
   34164 
   34165          const char *s)
   34166 {
   34167 
   34168 
   34169   fprintf (stderr, "%s\n", s);
   34170 }
   34171 
   34172 
   34173 
   34174 static int
   34175 get_char (void)
   34176 {
   34177   int res = getc (input);
   34178   ;
   34179 
   34180   return res;
   34181 }
   34182 
   34183 
   34184 static void
   34185 unget_char ( int c)
   34186 {
   34187   ;
   34188 
   34189   ungetc (c, input);
   34190 }
   34191 
   34192 static int
   34193 read_signed_integer (void)
   34194 {
   34195   int c = get_char ();
   34196   int sign = 1;
   34197   int n = 0;
   34198 
   34199   ;
   34200   if (c == '-')
   34201     {
   34202       c = get_char ();
   34203       sign = -1;
   34204     }
   34205 
   34206   while (isdigit (c))
   34207     {
   34208       n = 10 * n + (c - '0');
   34209       c = get_char ();
   34210     }
   34211 
   34212   unget_char ( c);
   34213 
   34214   return sign * n;
   34215 }
   34216 
   34217 
   34218 
   34219 /*---------------------------------------------------------------.
   34220 | Lexical analyzer returns an integer on the stack and the token |
   34221 | NUM, or the ASCII character read if not a number.  Skips all   |
   34222 | blanks and tabs, returns 0 for EOF.                            |
   34223 `---------------------------------------------------------------*/
   34224 
   34225 static int
   34226 yylex (void)
   34227 {
   34228   static int init = 1;
   34229   int c;
   34230 
   34231   if (init)
   34232     {
   34233       init = 0;
   34234 
   34235     }
   34236 
   34237 
   34238 
   34239   /* Skip white space.  */
   34240   while ((c = get_char ()) == ' ' || c == '\t')
   34241     {
   34242 
   34243     }
   34244 
   34245   /* process numbers   */
   34246   if (c == '.' || isdigit (c))
   34247     {
   34248       unget_char ( c);
   34249       (yylval).ival = read_signed_integer ();
   34250       return NUM;
   34251     }
   34252 
   34253   /* Return end-of-file.  */
   34254   if (c == EOF)
   34255     return CALC_EOF;
   34256 
   34257   /* Return single chars. */
   34258   return c;
   34259 }
   34260 
   34261 static int
   34262 power (int base, int exponent)
   34263 {
   34264   int res = 1;
   34265   if (exponent < 0)
   34266     exit (3);
   34267   for (/* Niente */; exponent; --exponent)
   34268     res *= base;
   34269   return res;
   34270 }
   34271 
   34272 
   34273 int
   34274 main (int argc, const char **argv)
   34275 {
   34276   semantic_value result = 0;
   34277   int count = 0;
   34278   int status;
   34279 
   34280   /* This used to be alarm (10), but that isn't enough time for
   34281      a July 1995 vintage DEC Alphastation 200 4/100 system,
   34282      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   34283   alarm (100);
   34284 
   34285   if (argc == 2)
   34286     input = fopen (argv[1], "r");
   34287   else
   34288     input = stdin;
   34289 
   34290   if (!input)
   34291     {
   34292       perror (argv[1]);
   34293       return 3;
   34294     }
   34295 
   34296 
   34297   status = yyparse ();
   34298   if (global_result != result)
   34299     abort ();
   34300   if (global_count != count)
   34301     abort ();
   34302   return status;
   34303 }
   34304 _ATEOF
   34305 
   34306 
   34307 
   34308 
   34309 
   34310 $at_traceoff
   34311 echo "calc.at:592: bison -o calc.c calc.y"
   34312 echo calc.at:592 >$at_check_line_file
   34313 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   34314 at_status=$?
   34315 grep '^ *+' $at_stder1 >&2
   34316 grep -v '^ *+' $at_stder1 >$at_stderr
   34317 at_failed=false
   34318 $at_diff $at_devnull $at_stderr || at_failed=:
   34319 $at_diff $at_devnull $at_stdout || at_failed=:
   34320 case $at_status in
   34321    77) echo 77 > $at_status_file
   34322             exit 77;;
   34323    0) ;;
   34324    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34325       at_failed=:;;
   34326 esac
   34327 if $at_failed; then
   34328 
   34329   echo 1 > $at_status_file
   34330   exit 1
   34331 fi
   34332 
   34333 $at_traceon
   34334 
   34335    $at_traceoff
   34336 echo "calc.at:592: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   34337 echo calc.at:592 >$at_check_line_file
   34338 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   34339 at_status=$?
   34340 grep '^ *+' $at_stder1 >&2
   34341 grep -v '^ *+' $at_stder1 >$at_stderr
   34342 at_failed=false
   34343 echo stderr:; cat $at_stderr
   34344 echo stdout:; cat $at_stdout
   34345 case $at_status in
   34346    77) echo 77 > $at_status_file
   34347             exit 77;;
   34348    0) ;;
   34349    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34350       at_failed=:;;
   34351 esac
   34352 if $at_failed; then
   34353 
   34354   echo 1 > $at_status_file
   34355   exit 1
   34356 fi
   34357 
   34358 $at_traceon
   34359 
   34360 
   34361 # Test the priorities.
   34362 cat >input <<'_ATEOF'
   34363 1 + 2 * 3 = 7
   34364 1 + 2 * -3 = -5
   34365 
   34366 -1^2 = -1
   34367 (-1)^2 = 1
   34368 
   34369 ---1 = -1
   34370 
   34371 1 - 2 - 3 = -4
   34372 1 - (2 - 3) = 2
   34373 
   34374 2^2^3 = 256
   34375 (2^2)^3 = 64
   34376 _ATEOF
   34377 
   34378 $at_traceoff
   34379 echo "calc.at:592: \$PREPARSER ./calc input"
   34380 echo calc.at:592 >$at_check_line_file
   34381 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   34382 at_status=$?
   34383 grep '^ *+' $at_stder1 >&2
   34384 grep -v '^ *+' $at_stder1 >$at_stderr
   34385 at_failed=false
   34386 echo stderr:; tee stderr <$at_stderr
   34387 $at_diff $at_devnull $at_stdout || at_failed=:
   34388 case $at_status in
   34389    77) echo 77 > $at_status_file
   34390             exit 77;;
   34391    0) ;;
   34392    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34393       at_failed=:;;
   34394 esac
   34395 if $at_failed; then
   34396 
   34397   echo 1 > $at_status_file
   34398   exit 1
   34399 fi
   34400 
   34401 $at_traceon
   34402 
   34403 
   34404 
   34405 # Some syntax errors.
   34406 cat >input <<'_ATEOF'
   34407 0 0
   34408 _ATEOF
   34409 
   34410 $at_traceoff
   34411 echo "calc.at:592: \$PREPARSER ./calc input"
   34412 echo calc.at:592 >$at_check_line_file
   34413 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   34414 at_status=$?
   34415 grep '^ *+' $at_stder1 >&2
   34416 grep -v '^ *+' $at_stder1 >$at_stderr
   34417 at_failed=false
   34418 echo stderr:; tee stderr <$at_stderr
   34419 $at_diff $at_devnull $at_stdout || at_failed=:
   34420 case $at_status in
   34421    77) echo 77 > $at_status_file
   34422             exit 77;;
   34423    1) ;;
   34424    *) echo "calc.at:592: exit code was $at_status, expected 1"
   34425       at_failed=:;;
   34426 esac
   34427 if $at_failed; then
   34428 
   34429   echo 1 > $at_status_file
   34430   exit 1
   34431 fi
   34432 
   34433 $at_traceon
   34434 
   34435 
   34436 # Normalize the observed and expected error messages, depending upon the
   34437 # options.
   34438 # 1. Remove the traces from observed.
   34439 sed '/^Starting/d
   34440 /^Entering/d
   34441 /^Stack/d
   34442 /^Reading/d
   34443 /^Reducing/d
   34444 /^Shifting/d
   34445 /^state/d
   34446 /^Cleanup:/d
   34447 /^Error:/d
   34448 /^Next/d
   34449 /^Discarding/d
   34450 / \$[0-9$]* = /d
   34451 /^yydestructor:/d' stderr >at-stderr
   34452 mv at-stderr stderr
   34453 # 2. Create the reference error message.
   34454 cat >expout <<'_ATEOF'
   34455 1.2: syntax error, unexpected number
   34456 _ATEOF
   34457 
   34458 # 3. If locations are not used, remove them.
   34459 sed 's/^[-0-9.]*: //' expout >at-expout
   34460 mv at-expout expout
   34461 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   34462 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   34463 mv at-expout expout
   34464 # 5. Check
   34465 $at_traceoff
   34466 echo "calc.at:592: cat stderr"
   34467 echo calc.at:592 >$at_check_line_file
   34468 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   34469 at_status=$?
   34470 grep '^ *+' $at_stder1 >&2
   34471 grep -v '^ *+' $at_stder1 >$at_stderr
   34472 at_failed=false
   34473 $at_diff $at_devnull $at_stderr || at_failed=:
   34474 $at_diff expout $at_stdout || at_failed=:
   34475 case $at_status in
   34476    77) echo 77 > $at_status_file
   34477             exit 77;;
   34478    0) ;;
   34479    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34480       at_failed=:;;
   34481 esac
   34482 if $at_failed; then
   34483 
   34484   echo 1 > $at_status_file
   34485   exit 1
   34486 fi
   34487 
   34488 $at_traceon
   34489 
   34490 
   34491 cat >input <<'_ATEOF'
   34492 1//2
   34493 _ATEOF
   34494 
   34495 $at_traceoff
   34496 echo "calc.at:592: \$PREPARSER ./calc input"
   34497 echo calc.at:592 >$at_check_line_file
   34498 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   34499 at_status=$?
   34500 grep '^ *+' $at_stder1 >&2
   34501 grep -v '^ *+' $at_stder1 >$at_stderr
   34502 at_failed=false
   34503 echo stderr:; tee stderr <$at_stderr
   34504 $at_diff $at_devnull $at_stdout || at_failed=:
   34505 case $at_status in
   34506    77) echo 77 > $at_status_file
   34507             exit 77;;
   34508    1) ;;
   34509    *) echo "calc.at:592: exit code was $at_status, expected 1"
   34510       at_failed=:;;
   34511 esac
   34512 if $at_failed; then
   34513 
   34514   echo 1 > $at_status_file
   34515   exit 1
   34516 fi
   34517 
   34518 $at_traceon
   34519 
   34520 
   34521 # Normalize the observed and expected error messages, depending upon the
   34522 # options.
   34523 # 1. Remove the traces from observed.
   34524 sed '/^Starting/d
   34525 /^Entering/d
   34526 /^Stack/d
   34527 /^Reading/d
   34528 /^Reducing/d
   34529 /^Shifting/d
   34530 /^state/d
   34531 /^Cleanup:/d
   34532 /^Error:/d
   34533 /^Next/d
   34534 /^Discarding/d
   34535 / \$[0-9$]* = /d
   34536 /^yydestructor:/d' stderr >at-stderr
   34537 mv at-stderr stderr
   34538 # 2. Create the reference error message.
   34539 cat >expout <<'_ATEOF'
   34540 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   34541 _ATEOF
   34542 
   34543 # 3. If locations are not used, remove them.
   34544 sed 's/^[-0-9.]*: //' expout >at-expout
   34545 mv at-expout expout
   34546 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   34547 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   34548 mv at-expout expout
   34549 # 5. Check
   34550 $at_traceoff
   34551 echo "calc.at:592: cat stderr"
   34552 echo calc.at:592 >$at_check_line_file
   34553 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   34554 at_status=$?
   34555 grep '^ *+' $at_stder1 >&2
   34556 grep -v '^ *+' $at_stder1 >$at_stderr
   34557 at_failed=false
   34558 $at_diff $at_devnull $at_stderr || at_failed=:
   34559 $at_diff expout $at_stdout || at_failed=:
   34560 case $at_status in
   34561    77) echo 77 > $at_status_file
   34562             exit 77;;
   34563    0) ;;
   34564    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34565       at_failed=:;;
   34566 esac
   34567 if $at_failed; then
   34568 
   34569   echo 1 > $at_status_file
   34570   exit 1
   34571 fi
   34572 
   34573 $at_traceon
   34574 
   34575 
   34576 cat >input <<'_ATEOF'
   34577 error
   34578 _ATEOF
   34579 
   34580 $at_traceoff
   34581 echo "calc.at:592: \$PREPARSER ./calc input"
   34582 echo calc.at:592 >$at_check_line_file
   34583 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   34584 at_status=$?
   34585 grep '^ *+' $at_stder1 >&2
   34586 grep -v '^ *+' $at_stder1 >$at_stderr
   34587 at_failed=false
   34588 echo stderr:; tee stderr <$at_stderr
   34589 $at_diff $at_devnull $at_stdout || at_failed=:
   34590 case $at_status in
   34591    77) echo 77 > $at_status_file
   34592             exit 77;;
   34593    1) ;;
   34594    *) echo "calc.at:592: exit code was $at_status, expected 1"
   34595       at_failed=:;;
   34596 esac
   34597 if $at_failed; then
   34598 
   34599   echo 1 > $at_status_file
   34600   exit 1
   34601 fi
   34602 
   34603 $at_traceon
   34604 
   34605 
   34606 # Normalize the observed and expected error messages, depending upon the
   34607 # options.
   34608 # 1. Remove the traces from observed.
   34609 sed '/^Starting/d
   34610 /^Entering/d
   34611 /^Stack/d
   34612 /^Reading/d
   34613 /^Reducing/d
   34614 /^Shifting/d
   34615 /^state/d
   34616 /^Cleanup:/d
   34617 /^Error:/d
   34618 /^Next/d
   34619 /^Discarding/d
   34620 / \$[0-9$]* = /d
   34621 /^yydestructor:/d' stderr >at-stderr
   34622 mv at-stderr stderr
   34623 # 2. Create the reference error message.
   34624 cat >expout <<'_ATEOF'
   34625 1.0: syntax error, unexpected $undefined
   34626 _ATEOF
   34627 
   34628 # 3. If locations are not used, remove them.
   34629 sed 's/^[-0-9.]*: //' expout >at-expout
   34630 mv at-expout expout
   34631 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   34632 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   34633 mv at-expout expout
   34634 # 5. Check
   34635 $at_traceoff
   34636 echo "calc.at:592: cat stderr"
   34637 echo calc.at:592 >$at_check_line_file
   34638 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   34639 at_status=$?
   34640 grep '^ *+' $at_stder1 >&2
   34641 grep -v '^ *+' $at_stder1 >$at_stderr
   34642 at_failed=false
   34643 $at_diff $at_devnull $at_stderr || at_failed=:
   34644 $at_diff expout $at_stdout || at_failed=:
   34645 case $at_status in
   34646    77) echo 77 > $at_status_file
   34647             exit 77;;
   34648    0) ;;
   34649    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34650       at_failed=:;;
   34651 esac
   34652 if $at_failed; then
   34653 
   34654   echo 1 > $at_status_file
   34655   exit 1
   34656 fi
   34657 
   34658 $at_traceon
   34659 
   34660 
   34661 cat >input <<'_ATEOF'
   34662 1 = 2 = 3
   34663 _ATEOF
   34664 
   34665 $at_traceoff
   34666 echo "calc.at:592: \$PREPARSER ./calc input"
   34667 echo calc.at:592 >$at_check_line_file
   34668 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   34669 at_status=$?
   34670 grep '^ *+' $at_stder1 >&2
   34671 grep -v '^ *+' $at_stder1 >$at_stderr
   34672 at_failed=false
   34673 echo stderr:; tee stderr <$at_stderr
   34674 $at_diff $at_devnull $at_stdout || at_failed=:
   34675 case $at_status in
   34676    77) echo 77 > $at_status_file
   34677             exit 77;;
   34678    1) ;;
   34679    *) echo "calc.at:592: exit code was $at_status, expected 1"
   34680       at_failed=:;;
   34681 esac
   34682 if $at_failed; then
   34683 
   34684   echo 1 > $at_status_file
   34685   exit 1
   34686 fi
   34687 
   34688 $at_traceon
   34689 
   34690 
   34691 # Normalize the observed and expected error messages, depending upon the
   34692 # options.
   34693 # 1. Remove the traces from observed.
   34694 sed '/^Starting/d
   34695 /^Entering/d
   34696 /^Stack/d
   34697 /^Reading/d
   34698 /^Reducing/d
   34699 /^Shifting/d
   34700 /^state/d
   34701 /^Cleanup:/d
   34702 /^Error:/d
   34703 /^Next/d
   34704 /^Discarding/d
   34705 / \$[0-9$]* = /d
   34706 /^yydestructor:/d' stderr >at-stderr
   34707 mv at-stderr stderr
   34708 # 2. Create the reference error message.
   34709 cat >expout <<'_ATEOF'
   34710 1.6: syntax error, unexpected '='
   34711 _ATEOF
   34712 
   34713 # 3. If locations are not used, remove them.
   34714 sed 's/^[-0-9.]*: //' expout >at-expout
   34715 mv at-expout expout
   34716 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   34717 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   34718 mv at-expout expout
   34719 # 5. Check
   34720 $at_traceoff
   34721 echo "calc.at:592: cat stderr"
   34722 echo calc.at:592 >$at_check_line_file
   34723 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   34724 at_status=$?
   34725 grep '^ *+' $at_stder1 >&2
   34726 grep -v '^ *+' $at_stder1 >$at_stderr
   34727 at_failed=false
   34728 $at_diff $at_devnull $at_stderr || at_failed=:
   34729 $at_diff expout $at_stdout || at_failed=:
   34730 case $at_status in
   34731    77) echo 77 > $at_status_file
   34732             exit 77;;
   34733    0) ;;
   34734    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34735       at_failed=:;;
   34736 esac
   34737 if $at_failed; then
   34738 
   34739   echo 1 > $at_status_file
   34740   exit 1
   34741 fi
   34742 
   34743 $at_traceon
   34744 
   34745 
   34746 cat >input <<'_ATEOF'
   34747 
   34748 +1
   34749 _ATEOF
   34750 
   34751 $at_traceoff
   34752 echo "calc.at:592: \$PREPARSER ./calc input"
   34753 echo calc.at:592 >$at_check_line_file
   34754 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   34755 at_status=$?
   34756 grep '^ *+' $at_stder1 >&2
   34757 grep -v '^ *+' $at_stder1 >$at_stderr
   34758 at_failed=false
   34759 echo stderr:; tee stderr <$at_stderr
   34760 $at_diff $at_devnull $at_stdout || at_failed=:
   34761 case $at_status in
   34762    77) echo 77 > $at_status_file
   34763             exit 77;;
   34764    1) ;;
   34765    *) echo "calc.at:592: exit code was $at_status, expected 1"
   34766       at_failed=:;;
   34767 esac
   34768 if $at_failed; then
   34769 
   34770   echo 1 > $at_status_file
   34771   exit 1
   34772 fi
   34773 
   34774 $at_traceon
   34775 
   34776 
   34777 # Normalize the observed and expected error messages, depending upon the
   34778 # options.
   34779 # 1. Remove the traces from observed.
   34780 sed '/^Starting/d
   34781 /^Entering/d
   34782 /^Stack/d
   34783 /^Reading/d
   34784 /^Reducing/d
   34785 /^Shifting/d
   34786 /^state/d
   34787 /^Cleanup:/d
   34788 /^Error:/d
   34789 /^Next/d
   34790 /^Discarding/d
   34791 / \$[0-9$]* = /d
   34792 /^yydestructor:/d' stderr >at-stderr
   34793 mv at-stderr stderr
   34794 # 2. Create the reference error message.
   34795 cat >expout <<'_ATEOF'
   34796 2.0: syntax error, unexpected '+'
   34797 _ATEOF
   34798 
   34799 # 3. If locations are not used, remove them.
   34800 sed 's/^[-0-9.]*: //' expout >at-expout
   34801 mv at-expout expout
   34802 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   34803 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   34804 mv at-expout expout
   34805 # 5. Check
   34806 $at_traceoff
   34807 echo "calc.at:592: cat stderr"
   34808 echo calc.at:592 >$at_check_line_file
   34809 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   34810 at_status=$?
   34811 grep '^ *+' $at_stder1 >&2
   34812 grep -v '^ *+' $at_stder1 >$at_stderr
   34813 at_failed=false
   34814 $at_diff $at_devnull $at_stderr || at_failed=:
   34815 $at_diff expout $at_stdout || at_failed=:
   34816 case $at_status in
   34817    77) echo 77 > $at_status_file
   34818             exit 77;;
   34819    0) ;;
   34820    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34821       at_failed=:;;
   34822 esac
   34823 if $at_failed; then
   34824 
   34825   echo 1 > $at_status_file
   34826   exit 1
   34827 fi
   34828 
   34829 $at_traceon
   34830 
   34831 
   34832 # Exercise error messages with EOF: work on an empty file.
   34833 $at_traceoff
   34834 echo "calc.at:592: \$PREPARSER ./calc /dev/null"
   34835 echo calc.at:592 >$at_check_line_file
   34836 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   34837 at_status=$?
   34838 grep '^ *+' $at_stder1 >&2
   34839 grep -v '^ *+' $at_stder1 >$at_stderr
   34840 at_failed=false
   34841 echo stderr:; tee stderr <$at_stderr
   34842 $at_diff $at_devnull $at_stdout || at_failed=:
   34843 case $at_status in
   34844    77) echo 77 > $at_status_file
   34845             exit 77;;
   34846    1) ;;
   34847    *) echo "calc.at:592: exit code was $at_status, expected 1"
   34848       at_failed=:;;
   34849 esac
   34850 if $at_failed; then
   34851 
   34852   echo 1 > $at_status_file
   34853   exit 1
   34854 fi
   34855 
   34856 $at_traceon
   34857 
   34858 
   34859 # Normalize the observed and expected error messages, depending upon the
   34860 # options.
   34861 # 1. Remove the traces from observed.
   34862 sed '/^Starting/d
   34863 /^Entering/d
   34864 /^Stack/d
   34865 /^Reading/d
   34866 /^Reducing/d
   34867 /^Shifting/d
   34868 /^state/d
   34869 /^Cleanup:/d
   34870 /^Error:/d
   34871 /^Next/d
   34872 /^Discarding/d
   34873 / \$[0-9$]* = /d
   34874 /^yydestructor:/d' stderr >at-stderr
   34875 mv at-stderr stderr
   34876 # 2. Create the reference error message.
   34877 cat >expout <<'_ATEOF'
   34878 1.0: syntax error, unexpected end of input
   34879 _ATEOF
   34880 
   34881 # 3. If locations are not used, remove them.
   34882 sed 's/^[-0-9.]*: //' expout >at-expout
   34883 mv at-expout expout
   34884 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   34885 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   34886 mv at-expout expout
   34887 # 5. Check
   34888 $at_traceoff
   34889 echo "calc.at:592: cat stderr"
   34890 echo calc.at:592 >$at_check_line_file
   34891 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   34892 at_status=$?
   34893 grep '^ *+' $at_stder1 >&2
   34894 grep -v '^ *+' $at_stder1 >$at_stderr
   34895 at_failed=false
   34896 $at_diff $at_devnull $at_stderr || at_failed=:
   34897 $at_diff expout $at_stdout || at_failed=:
   34898 case $at_status in
   34899    77) echo 77 > $at_status_file
   34900             exit 77;;
   34901    0) ;;
   34902    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34903       at_failed=:;;
   34904 esac
   34905 if $at_failed; then
   34906 
   34907   echo 1 > $at_status_file
   34908   exit 1
   34909 fi
   34910 
   34911 $at_traceon
   34912 
   34913 
   34914 
   34915 # Exercise the error token: without it, we die at the first error,
   34916 # hence be sure to
   34917 #
   34918 # - have several errors which exercise different shift/discardings
   34919 #   - (): nothing to pop, nothing to discard
   34920 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   34921 #   - (* * *): nothing to pop, a lot to discard
   34922 #   - (1 + 2 * *): some to pop and discard
   34923 #
   34924 # - test the action associated to `error'
   34925 #
   34926 # - check the look-ahead that triggers an error is not discarded
   34927 #   when we enter error recovery.  Below, the look-ahead causing the
   34928 #   first error is ")", which is needed to recover from the error and
   34929 #   produce the "0" that triggers the "0 != 1" error.
   34930 #
   34931 cat >input <<'_ATEOF'
   34932 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   34933 _ATEOF
   34934 
   34935 $at_traceoff
   34936 echo "calc.at:592: \$PREPARSER ./calc input"
   34937 echo calc.at:592 >$at_check_line_file
   34938 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   34939 at_status=$?
   34940 grep '^ *+' $at_stder1 >&2
   34941 grep -v '^ *+' $at_stder1 >$at_stderr
   34942 at_failed=false
   34943 echo stderr:; tee stderr <$at_stderr
   34944 $at_diff $at_devnull $at_stdout || at_failed=:
   34945 case $at_status in
   34946    77) echo 77 > $at_status_file
   34947             exit 77;;
   34948    0) ;;
   34949    *) echo "calc.at:592: exit code was $at_status, expected 0"
   34950       at_failed=:;;
   34951 esac
   34952 if $at_failed; then
   34953 
   34954   echo 1 > $at_status_file
   34955   exit 1
   34956 fi
   34957 
   34958 $at_traceon
   34959 
   34960 
   34961 # Normalize the observed and expected error messages, depending upon the
   34962 # options.
   34963 # 1. Remove the traces from observed.
   34964 sed '/^Starting/d
   34965 /^Entering/d
   34966 /^Stack/d
   34967 /^Reading/d
   34968 /^Reducing/d
   34969 /^Shifting/d
   34970 /^state/d
   34971 /^Cleanup:/d
   34972 /^Error:/d
   34973 /^Next/d
   34974 /^Discarding/d
   34975 / \$[0-9$]* = /d
   34976 /^yydestructor:/d' stderr >at-stderr
   34977 mv at-stderr stderr
   34978 # 2. Create the reference error message.
   34979 cat >expout <<'_ATEOF'
   34980 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   34981 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   34982 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   34983 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   34984 calc: error: 4444 != 1
   34985 _ATEOF
   34986 
   34987 # 3. If locations are not used, remove them.
   34988 sed 's/^[-0-9.]*: //' expout >at-expout
   34989 mv at-expout expout
   34990 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   34991 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   34992 mv at-expout expout
   34993 # 5. Check
   34994 $at_traceoff
   34995 echo "calc.at:592: cat stderr"
   34996 echo calc.at:592 >$at_check_line_file
   34997 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   34998 at_status=$?
   34999 grep '^ *+' $at_stder1 >&2
   35000 grep -v '^ *+' $at_stder1 >$at_stderr
   35001 at_failed=false
   35002 $at_diff $at_devnull $at_stderr || at_failed=:
   35003 $at_diff expout $at_stdout || at_failed=:
   35004 case $at_status in
   35005    77) echo 77 > $at_status_file
   35006             exit 77;;
   35007    0) ;;
   35008    *) echo "calc.at:592: exit code was $at_status, expected 0"
   35009       at_failed=:;;
   35010 esac
   35011 if $at_failed; then
   35012 
   35013   echo 1 > $at_status_file
   35014   exit 1
   35015 fi
   35016 
   35017 $at_traceon
   35018 
   35019 
   35020 
   35021 # The same, but this time exercising explicitly triggered syntax errors.
   35022 # POSIX says the look-ahead causing the error should not be discarded.
   35023 cat >input <<'_ATEOF'
   35024 (!) + (0 0) = 1
   35025 _ATEOF
   35026 
   35027 $at_traceoff
   35028 echo "calc.at:592: \$PREPARSER ./calc input"
   35029 echo calc.at:592 >$at_check_line_file
   35030 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   35031 at_status=$?
   35032 grep '^ *+' $at_stder1 >&2
   35033 grep -v '^ *+' $at_stder1 >$at_stderr
   35034 at_failed=false
   35035 echo stderr:; tee stderr <$at_stderr
   35036 $at_diff $at_devnull $at_stdout || at_failed=:
   35037 case $at_status in
   35038    77) echo 77 > $at_status_file
   35039             exit 77;;
   35040    0) ;;
   35041    *) echo "calc.at:592: exit code was $at_status, expected 0"
   35042       at_failed=:;;
   35043 esac
   35044 if $at_failed; then
   35045 
   35046   echo 1 > $at_status_file
   35047   exit 1
   35048 fi
   35049 
   35050 $at_traceon
   35051 
   35052 
   35053 # Normalize the observed and expected error messages, depending upon the
   35054 # options.
   35055 # 1. Remove the traces from observed.
   35056 sed '/^Starting/d
   35057 /^Entering/d
   35058 /^Stack/d
   35059 /^Reading/d
   35060 /^Reducing/d
   35061 /^Shifting/d
   35062 /^state/d
   35063 /^Cleanup:/d
   35064 /^Error:/d
   35065 /^Next/d
   35066 /^Discarding/d
   35067 / \$[0-9$]* = /d
   35068 /^yydestructor:/d' stderr >at-stderr
   35069 mv at-stderr stderr
   35070 # 2. Create the reference error message.
   35071 cat >expout <<'_ATEOF'
   35072 1.9: syntax error, unexpected number
   35073 calc: error: 2222 != 1
   35074 _ATEOF
   35075 
   35076 # 3. If locations are not used, remove them.
   35077 sed 's/^[-0-9.]*: //' expout >at-expout
   35078 mv at-expout expout
   35079 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   35080 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   35081 mv at-expout expout
   35082 # 5. Check
   35083 $at_traceoff
   35084 echo "calc.at:592: cat stderr"
   35085 echo calc.at:592 >$at_check_line_file
   35086 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   35087 at_status=$?
   35088 grep '^ *+' $at_stder1 >&2
   35089 grep -v '^ *+' $at_stder1 >$at_stderr
   35090 at_failed=false
   35091 $at_diff $at_devnull $at_stderr || at_failed=:
   35092 $at_diff expout $at_stdout || at_failed=:
   35093 case $at_status in
   35094    77) echo 77 > $at_status_file
   35095             exit 77;;
   35096    0) ;;
   35097    *) echo "calc.at:592: exit code was $at_status, expected 0"
   35098       at_failed=:;;
   35099 esac
   35100 if $at_failed; then
   35101 
   35102   echo 1 > $at_status_file
   35103   exit 1
   35104 fi
   35105 
   35106 $at_traceon
   35107 
   35108 
   35109 cat >input <<'_ATEOF'
   35110 (- *) + (0 0) = 1
   35111 _ATEOF
   35112 
   35113 $at_traceoff
   35114 echo "calc.at:592: \$PREPARSER ./calc input"
   35115 echo calc.at:592 >$at_check_line_file
   35116 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   35117 at_status=$?
   35118 grep '^ *+' $at_stder1 >&2
   35119 grep -v '^ *+' $at_stder1 >$at_stderr
   35120 at_failed=false
   35121 echo stderr:; tee stderr <$at_stderr
   35122 $at_diff $at_devnull $at_stdout || at_failed=:
   35123 case $at_status in
   35124    77) echo 77 > $at_status_file
   35125             exit 77;;
   35126    0) ;;
   35127    *) echo "calc.at:592: exit code was $at_status, expected 0"
   35128       at_failed=:;;
   35129 esac
   35130 if $at_failed; then
   35131 
   35132   echo 1 > $at_status_file
   35133   exit 1
   35134 fi
   35135 
   35136 $at_traceon
   35137 
   35138 
   35139 # Normalize the observed and expected error messages, depending upon the
   35140 # options.
   35141 # 1. Remove the traces from observed.
   35142 sed '/^Starting/d
   35143 /^Entering/d
   35144 /^Stack/d
   35145 /^Reading/d
   35146 /^Reducing/d
   35147 /^Shifting/d
   35148 /^state/d
   35149 /^Cleanup:/d
   35150 /^Error:/d
   35151 /^Next/d
   35152 /^Discarding/d
   35153 / \$[0-9$]* = /d
   35154 /^yydestructor:/d' stderr >at-stderr
   35155 mv at-stderr stderr
   35156 # 2. Create the reference error message.
   35157 cat >expout <<'_ATEOF'
   35158 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   35159 1.11: syntax error, unexpected number
   35160 calc: error: 2222 != 1
   35161 _ATEOF
   35162 
   35163 # 3. If locations are not used, remove them.
   35164 sed 's/^[-0-9.]*: //' expout >at-expout
   35165 mv at-expout expout
   35166 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   35167 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   35168 mv at-expout expout
   35169 # 5. Check
   35170 $at_traceoff
   35171 echo "calc.at:592: cat stderr"
   35172 echo calc.at:592 >$at_check_line_file
   35173 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   35174 at_status=$?
   35175 grep '^ *+' $at_stder1 >&2
   35176 grep -v '^ *+' $at_stder1 >$at_stderr
   35177 at_failed=false
   35178 $at_diff $at_devnull $at_stderr || at_failed=:
   35179 $at_diff expout $at_stdout || at_failed=:
   35180 case $at_status in
   35181    77) echo 77 > $at_status_file
   35182             exit 77;;
   35183    0) ;;
   35184    *) echo "calc.at:592: exit code was $at_status, expected 0"
   35185       at_failed=:;;
   35186 esac
   35187 if $at_failed; then
   35188 
   35189   echo 1 > $at_status_file
   35190   exit 1
   35191 fi
   35192 
   35193 $at_traceon
   35194 
   35195 
   35196 
   35197 
   35198 
   35199 
   35200 
   35201 
   35202 
   35203 
   35204 
   35205 
   35206 
   35207 
   35208 
   35209 
   35210 
   35211 
   35212 
   35213 
   35214 
   35215 
   35216 
   35217 
   35218       $at_traceoff
   35219       $at_times_p && times >$at_times_file
   35220     ) 5>&1 2>&1 | eval $at_tee_pipe
   35221     at_status=`cat $at_status_file`
   35222     ;;
   35223 
   35224   90 ) # 90. calc.at:593: Calculator %glr-parser %error-verbose
   35225     at_setup_line='calc.at:593'
   35226     at_desc='Calculator %glr-parser %error-verbose'
   35227     $at_quiet $ECHO_N " 90: Calculator %glr-parser %error-verbose        $ECHO_C"
   35228     at_xfail=no
   35229     (
   35230       echo "90. calc.at:593: testing ..."
   35231       $at_traceon
   35232 
   35233 
   35234 
   35235 
   35236 
   35237 
   35238 
   35239 
   35240 # Using yacc.c?
   35241 
   35242 
   35243 
   35244 
   35245 
   35246 
   35247 
   35248 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   35249 
   35250 # yyerror always sees the locations (when activated), except if
   35251 # yacc & pure & !param.
   35252 
   35253 
   35254 # The interface is pure: either because %pure-parser, or because we
   35255 # are using the C++ parsers.
   35256 
   35257 
   35258 
   35259 
   35260 
   35261 
   35262 
   35263 
   35264 
   35265 
   35266 
   35267 
   35268 cat >calc.y <<'_ATEOF'
   35269 %{
   35270 #ifdef HAVE_CONFIG_H
   35271 # include <config.h>
   35272   /* We don't need perfect functions for these tests. */
   35273 # undef malloc
   35274 # undef memcmp
   35275 # undef realloc
   35276 #endif
   35277 %}
   35278 
   35279 /* Infix notation calculator--calc */
   35280 %glr-parser %error-verbose
   35281 
   35282 %{
   35283 #include <stdio.h>
   35284 
   35285 #include <stdlib.h>
   35286 #include <string.h>
   35287 #if HAVE_UNISTD_H
   35288 # include <unistd.h>
   35289 #else
   35290 # undef alarm
   35291 # define alarm(seconds) /* empty */
   35292 #endif
   35293 #include <ctype.h>
   35294 #define USE(Var)
   35295 
   35296 /* Exercise pre-prologue dependency to %union.  */
   35297 typedef int semantic_value;
   35298 
   35299 static semantic_value global_result = 0;
   35300 static int global_count = 0;
   35301 %}
   35302 
   35303 /* Exercise %union. */
   35304 %union
   35305 {
   35306   semantic_value ival;
   35307 };
   35308 
   35309 %{
   35310 static int power (int base, int exponent);
   35311 /* yyerror receives the location if:
   35312    - %location & %pure & %glr
   35313    - %location & %pure & %yacc & %parse-param. */
   35314 static void yyerror (
   35315 
   35316                      const char *s
   35317                      );
   35318 static int yylex (void);
   35319 static int get_char (void);
   35320 static void unget_char ( int c);
   35321 %}
   35322 
   35323 
   35324 
   35325 /* Bison Declarations */
   35326 %token CALC_EOF 0 "end of input"
   35327 %token <ival> NUM "number"
   35328 %type  <ival> exp
   35329 
   35330 %nonassoc '=' /* comparison	       */
   35331 %left '-' '+'
   35332 %left '*' '/'
   35333 %left NEG     /* negation--unary minus */
   35334 %right '^'    /* exponentiation        */
   35335 
   35336 /* Grammar follows */
   35337 %%
   35338 input:
   35339   line
   35340 | input line         {  }
   35341 ;
   35342 
   35343 line:
   35344   '\n'
   35345 | exp '\n'           { USE ($1); }
   35346 ;
   35347 
   35348 exp:
   35349   NUM                { $$ = $1;             }
   35350 | exp '=' exp
   35351   {
   35352     if ($1 != $3)
   35353       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   35354     $$ = $1;
   35355   }
   35356 | exp '+' exp        { $$ = $1 + $3;        }
   35357 | exp '-' exp        { $$ = $1 - $3;        }
   35358 | exp '*' exp        { $$ = $1 * $3;        }
   35359 | exp '/' exp        { $$ = $1 / $3;        }
   35360 | '-' exp  %prec NEG { $$ = -$2;            }
   35361 | exp '^' exp        { $$ = power ($1, $3); }
   35362 | '(' exp ')'        { $$ = $2;             }
   35363 | '(' error ')'      { $$ = 1111;           }
   35364 | '!'                { $$ = 0; YYERROR;     }
   35365 | '-' error          { $$ = 0; YYERROR;     }
   35366 ;
   35367 %%
   35368 /* The input.  */
   35369 static FILE *input;
   35370 
   35371 static void
   35372 yyerror (
   35373 
   35374          const char *s)
   35375 {
   35376 
   35377 
   35378   fprintf (stderr, "%s\n", s);
   35379 }
   35380 
   35381 
   35382 
   35383 static int
   35384 get_char (void)
   35385 {
   35386   int res = getc (input);
   35387   ;
   35388 
   35389   return res;
   35390 }
   35391 
   35392 
   35393 static void
   35394 unget_char ( int c)
   35395 {
   35396   ;
   35397 
   35398   ungetc (c, input);
   35399 }
   35400 
   35401 static int
   35402 read_signed_integer (void)
   35403 {
   35404   int c = get_char ();
   35405   int sign = 1;
   35406   int n = 0;
   35407 
   35408   ;
   35409   if (c == '-')
   35410     {
   35411       c = get_char ();
   35412       sign = -1;
   35413     }
   35414 
   35415   while (isdigit (c))
   35416     {
   35417       n = 10 * n + (c - '0');
   35418       c = get_char ();
   35419     }
   35420 
   35421   unget_char ( c);
   35422 
   35423   return sign * n;
   35424 }
   35425 
   35426 
   35427 
   35428 /*---------------------------------------------------------------.
   35429 | Lexical analyzer returns an integer on the stack and the token |
   35430 | NUM, or the ASCII character read if not a number.  Skips all   |
   35431 | blanks and tabs, returns 0 for EOF.                            |
   35432 `---------------------------------------------------------------*/
   35433 
   35434 static int
   35435 yylex (void)
   35436 {
   35437   static int init = 1;
   35438   int c;
   35439 
   35440   if (init)
   35441     {
   35442       init = 0;
   35443 
   35444     }
   35445 
   35446 
   35447 
   35448   /* Skip white space.  */
   35449   while ((c = get_char ()) == ' ' || c == '\t')
   35450     {
   35451 
   35452     }
   35453 
   35454   /* process numbers   */
   35455   if (c == '.' || isdigit (c))
   35456     {
   35457       unget_char ( c);
   35458       (yylval).ival = read_signed_integer ();
   35459       return NUM;
   35460     }
   35461 
   35462   /* Return end-of-file.  */
   35463   if (c == EOF)
   35464     return CALC_EOF;
   35465 
   35466   /* Return single chars. */
   35467   return c;
   35468 }
   35469 
   35470 static int
   35471 power (int base, int exponent)
   35472 {
   35473   int res = 1;
   35474   if (exponent < 0)
   35475     exit (3);
   35476   for (/* Niente */; exponent; --exponent)
   35477     res *= base;
   35478   return res;
   35479 }
   35480 
   35481 
   35482 int
   35483 main (int argc, const char **argv)
   35484 {
   35485   semantic_value result = 0;
   35486   int count = 0;
   35487   int status;
   35488 
   35489   /* This used to be alarm (10), but that isn't enough time for
   35490      a July 1995 vintage DEC Alphastation 200 4/100 system,
   35491      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   35492   alarm (100);
   35493 
   35494   if (argc == 2)
   35495     input = fopen (argv[1], "r");
   35496   else
   35497     input = stdin;
   35498 
   35499   if (!input)
   35500     {
   35501       perror (argv[1]);
   35502       return 3;
   35503     }
   35504 
   35505 
   35506   status = yyparse ();
   35507   if (global_result != result)
   35508     abort ();
   35509   if (global_count != count)
   35510     abort ();
   35511   return status;
   35512 }
   35513 _ATEOF
   35514 
   35515 
   35516 
   35517 
   35518 
   35519 $at_traceoff
   35520 echo "calc.at:593: bison -o calc.c calc.y"
   35521 echo calc.at:593 >$at_check_line_file
   35522 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   35523 at_status=$?
   35524 grep '^ *+' $at_stder1 >&2
   35525 grep -v '^ *+' $at_stder1 >$at_stderr
   35526 at_failed=false
   35527 $at_diff $at_devnull $at_stderr || at_failed=:
   35528 $at_diff $at_devnull $at_stdout || at_failed=:
   35529 case $at_status in
   35530    77) echo 77 > $at_status_file
   35531             exit 77;;
   35532    0) ;;
   35533    *) echo "calc.at:593: exit code was $at_status, expected 0"
   35534       at_failed=:;;
   35535 esac
   35536 if $at_failed; then
   35537 
   35538   echo 1 > $at_status_file
   35539   exit 1
   35540 fi
   35541 
   35542 $at_traceon
   35543 
   35544    $at_traceoff
   35545 echo "calc.at:593: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   35546 echo calc.at:593 >$at_check_line_file
   35547 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   35548 at_status=$?
   35549 grep '^ *+' $at_stder1 >&2
   35550 grep -v '^ *+' $at_stder1 >$at_stderr
   35551 at_failed=false
   35552 echo stderr:; cat $at_stderr
   35553 echo stdout:; cat $at_stdout
   35554 case $at_status in
   35555    77) echo 77 > $at_status_file
   35556             exit 77;;
   35557    0) ;;
   35558    *) echo "calc.at:593: exit code was $at_status, expected 0"
   35559       at_failed=:;;
   35560 esac
   35561 if $at_failed; then
   35562 
   35563   echo 1 > $at_status_file
   35564   exit 1
   35565 fi
   35566 
   35567 $at_traceon
   35568 
   35569 
   35570 # Test the priorities.
   35571 cat >input <<'_ATEOF'
   35572 1 + 2 * 3 = 7
   35573 1 + 2 * -3 = -5
   35574 
   35575 -1^2 = -1
   35576 (-1)^2 = 1
   35577 
   35578 ---1 = -1
   35579 
   35580 1 - 2 - 3 = -4
   35581 1 - (2 - 3) = 2
   35582 
   35583 2^2^3 = 256
   35584 (2^2)^3 = 64
   35585 _ATEOF
   35586 
   35587 $at_traceoff
   35588 echo "calc.at:593: \$PREPARSER ./calc input"
   35589 echo calc.at:593 >$at_check_line_file
   35590 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   35591 at_status=$?
   35592 grep '^ *+' $at_stder1 >&2
   35593 grep -v '^ *+' $at_stder1 >$at_stderr
   35594 at_failed=false
   35595 echo stderr:; tee stderr <$at_stderr
   35596 $at_diff $at_devnull $at_stdout || at_failed=:
   35597 case $at_status in
   35598    77) echo 77 > $at_status_file
   35599             exit 77;;
   35600    0) ;;
   35601    *) echo "calc.at:593: exit code was $at_status, expected 0"
   35602       at_failed=:;;
   35603 esac
   35604 if $at_failed; then
   35605 
   35606   echo 1 > $at_status_file
   35607   exit 1
   35608 fi
   35609 
   35610 $at_traceon
   35611 
   35612 
   35613 
   35614 # Some syntax errors.
   35615 cat >input <<'_ATEOF'
   35616 0 0
   35617 _ATEOF
   35618 
   35619 $at_traceoff
   35620 echo "calc.at:593: \$PREPARSER ./calc input"
   35621 echo calc.at:593 >$at_check_line_file
   35622 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   35623 at_status=$?
   35624 grep '^ *+' $at_stder1 >&2
   35625 grep -v '^ *+' $at_stder1 >$at_stderr
   35626 at_failed=false
   35627 echo stderr:; tee stderr <$at_stderr
   35628 $at_diff $at_devnull $at_stdout || at_failed=:
   35629 case $at_status in
   35630    77) echo 77 > $at_status_file
   35631             exit 77;;
   35632    1) ;;
   35633    *) echo "calc.at:593: exit code was $at_status, expected 1"
   35634       at_failed=:;;
   35635 esac
   35636 if $at_failed; then
   35637 
   35638   echo 1 > $at_status_file
   35639   exit 1
   35640 fi
   35641 
   35642 $at_traceon
   35643 
   35644 
   35645 # Normalize the observed and expected error messages, depending upon the
   35646 # options.
   35647 # 1. Remove the traces from observed.
   35648 sed '/^Starting/d
   35649 /^Entering/d
   35650 /^Stack/d
   35651 /^Reading/d
   35652 /^Reducing/d
   35653 /^Shifting/d
   35654 /^state/d
   35655 /^Cleanup:/d
   35656 /^Error:/d
   35657 /^Next/d
   35658 /^Discarding/d
   35659 / \$[0-9$]* = /d
   35660 /^yydestructor:/d' stderr >at-stderr
   35661 mv at-stderr stderr
   35662 # 2. Create the reference error message.
   35663 cat >expout <<'_ATEOF'
   35664 1.2: syntax error, unexpected number
   35665 _ATEOF
   35666 
   35667 # 3. If locations are not used, remove them.
   35668 sed 's/^[-0-9.]*: //' expout >at-expout
   35669 mv at-expout expout
   35670 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   35671 
   35672 # 5. Check
   35673 $at_traceoff
   35674 echo "calc.at:593: cat stderr"
   35675 echo calc.at:593 >$at_check_line_file
   35676 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   35677 at_status=$?
   35678 grep '^ *+' $at_stder1 >&2
   35679 grep -v '^ *+' $at_stder1 >$at_stderr
   35680 at_failed=false
   35681 $at_diff $at_devnull $at_stderr || at_failed=:
   35682 $at_diff expout $at_stdout || at_failed=:
   35683 case $at_status in
   35684    77) echo 77 > $at_status_file
   35685             exit 77;;
   35686    0) ;;
   35687    *) echo "calc.at:593: exit code was $at_status, expected 0"
   35688       at_failed=:;;
   35689 esac
   35690 if $at_failed; then
   35691 
   35692   echo 1 > $at_status_file
   35693   exit 1
   35694 fi
   35695 
   35696 $at_traceon
   35697 
   35698 
   35699 cat >input <<'_ATEOF'
   35700 1//2
   35701 _ATEOF
   35702 
   35703 $at_traceoff
   35704 echo "calc.at:593: \$PREPARSER ./calc input"
   35705 echo calc.at:593 >$at_check_line_file
   35706 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   35707 at_status=$?
   35708 grep '^ *+' $at_stder1 >&2
   35709 grep -v '^ *+' $at_stder1 >$at_stderr
   35710 at_failed=false
   35711 echo stderr:; tee stderr <$at_stderr
   35712 $at_diff $at_devnull $at_stdout || at_failed=:
   35713 case $at_status in
   35714    77) echo 77 > $at_status_file
   35715             exit 77;;
   35716    1) ;;
   35717    *) echo "calc.at:593: exit code was $at_status, expected 1"
   35718       at_failed=:;;
   35719 esac
   35720 if $at_failed; then
   35721 
   35722   echo 1 > $at_status_file
   35723   exit 1
   35724 fi
   35725 
   35726 $at_traceon
   35727 
   35728 
   35729 # Normalize the observed and expected error messages, depending upon the
   35730 # options.
   35731 # 1. Remove the traces from observed.
   35732 sed '/^Starting/d
   35733 /^Entering/d
   35734 /^Stack/d
   35735 /^Reading/d
   35736 /^Reducing/d
   35737 /^Shifting/d
   35738 /^state/d
   35739 /^Cleanup:/d
   35740 /^Error:/d
   35741 /^Next/d
   35742 /^Discarding/d
   35743 / \$[0-9$]* = /d
   35744 /^yydestructor:/d' stderr >at-stderr
   35745 mv at-stderr stderr
   35746 # 2. Create the reference error message.
   35747 cat >expout <<'_ATEOF'
   35748 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   35749 _ATEOF
   35750 
   35751 # 3. If locations are not used, remove them.
   35752 sed 's/^[-0-9.]*: //' expout >at-expout
   35753 mv at-expout expout
   35754 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   35755 
   35756 # 5. Check
   35757 $at_traceoff
   35758 echo "calc.at:593: cat stderr"
   35759 echo calc.at:593 >$at_check_line_file
   35760 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   35761 at_status=$?
   35762 grep '^ *+' $at_stder1 >&2
   35763 grep -v '^ *+' $at_stder1 >$at_stderr
   35764 at_failed=false
   35765 $at_diff $at_devnull $at_stderr || at_failed=:
   35766 $at_diff expout $at_stdout || at_failed=:
   35767 case $at_status in
   35768    77) echo 77 > $at_status_file
   35769             exit 77;;
   35770    0) ;;
   35771    *) echo "calc.at:593: exit code was $at_status, expected 0"
   35772       at_failed=:;;
   35773 esac
   35774 if $at_failed; then
   35775 
   35776   echo 1 > $at_status_file
   35777   exit 1
   35778 fi
   35779 
   35780 $at_traceon
   35781 
   35782 
   35783 cat >input <<'_ATEOF'
   35784 error
   35785 _ATEOF
   35786 
   35787 $at_traceoff
   35788 echo "calc.at:593: \$PREPARSER ./calc input"
   35789 echo calc.at:593 >$at_check_line_file
   35790 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   35791 at_status=$?
   35792 grep '^ *+' $at_stder1 >&2
   35793 grep -v '^ *+' $at_stder1 >$at_stderr
   35794 at_failed=false
   35795 echo stderr:; tee stderr <$at_stderr
   35796 $at_diff $at_devnull $at_stdout || at_failed=:
   35797 case $at_status in
   35798    77) echo 77 > $at_status_file
   35799             exit 77;;
   35800    1) ;;
   35801    *) echo "calc.at:593: exit code was $at_status, expected 1"
   35802       at_failed=:;;
   35803 esac
   35804 if $at_failed; then
   35805 
   35806   echo 1 > $at_status_file
   35807   exit 1
   35808 fi
   35809 
   35810 $at_traceon
   35811 
   35812 
   35813 # Normalize the observed and expected error messages, depending upon the
   35814 # options.
   35815 # 1. Remove the traces from observed.
   35816 sed '/^Starting/d
   35817 /^Entering/d
   35818 /^Stack/d
   35819 /^Reading/d
   35820 /^Reducing/d
   35821 /^Shifting/d
   35822 /^state/d
   35823 /^Cleanup:/d
   35824 /^Error:/d
   35825 /^Next/d
   35826 /^Discarding/d
   35827 / \$[0-9$]* = /d
   35828 /^yydestructor:/d' stderr >at-stderr
   35829 mv at-stderr stderr
   35830 # 2. Create the reference error message.
   35831 cat >expout <<'_ATEOF'
   35832 1.0: syntax error, unexpected $undefined
   35833 _ATEOF
   35834 
   35835 # 3. If locations are not used, remove them.
   35836 sed 's/^[-0-9.]*: //' expout >at-expout
   35837 mv at-expout expout
   35838 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   35839 
   35840 # 5. Check
   35841 $at_traceoff
   35842 echo "calc.at:593: cat stderr"
   35843 echo calc.at:593 >$at_check_line_file
   35844 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   35845 at_status=$?
   35846 grep '^ *+' $at_stder1 >&2
   35847 grep -v '^ *+' $at_stder1 >$at_stderr
   35848 at_failed=false
   35849 $at_diff $at_devnull $at_stderr || at_failed=:
   35850 $at_diff expout $at_stdout || at_failed=:
   35851 case $at_status in
   35852    77) echo 77 > $at_status_file
   35853             exit 77;;
   35854    0) ;;
   35855    *) echo "calc.at:593: exit code was $at_status, expected 0"
   35856       at_failed=:;;
   35857 esac
   35858 if $at_failed; then
   35859 
   35860   echo 1 > $at_status_file
   35861   exit 1
   35862 fi
   35863 
   35864 $at_traceon
   35865 
   35866 
   35867 cat >input <<'_ATEOF'
   35868 1 = 2 = 3
   35869 _ATEOF
   35870 
   35871 $at_traceoff
   35872 echo "calc.at:593: \$PREPARSER ./calc input"
   35873 echo calc.at:593 >$at_check_line_file
   35874 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   35875 at_status=$?
   35876 grep '^ *+' $at_stder1 >&2
   35877 grep -v '^ *+' $at_stder1 >$at_stderr
   35878 at_failed=false
   35879 echo stderr:; tee stderr <$at_stderr
   35880 $at_diff $at_devnull $at_stdout || at_failed=:
   35881 case $at_status in
   35882    77) echo 77 > $at_status_file
   35883             exit 77;;
   35884    1) ;;
   35885    *) echo "calc.at:593: exit code was $at_status, expected 1"
   35886       at_failed=:;;
   35887 esac
   35888 if $at_failed; then
   35889 
   35890   echo 1 > $at_status_file
   35891   exit 1
   35892 fi
   35893 
   35894 $at_traceon
   35895 
   35896 
   35897 # Normalize the observed and expected error messages, depending upon the
   35898 # options.
   35899 # 1. Remove the traces from observed.
   35900 sed '/^Starting/d
   35901 /^Entering/d
   35902 /^Stack/d
   35903 /^Reading/d
   35904 /^Reducing/d
   35905 /^Shifting/d
   35906 /^state/d
   35907 /^Cleanup:/d
   35908 /^Error:/d
   35909 /^Next/d
   35910 /^Discarding/d
   35911 / \$[0-9$]* = /d
   35912 /^yydestructor:/d' stderr >at-stderr
   35913 mv at-stderr stderr
   35914 # 2. Create the reference error message.
   35915 cat >expout <<'_ATEOF'
   35916 1.6: syntax error, unexpected '='
   35917 _ATEOF
   35918 
   35919 # 3. If locations are not used, remove them.
   35920 sed 's/^[-0-9.]*: //' expout >at-expout
   35921 mv at-expout expout
   35922 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   35923 
   35924 # 5. Check
   35925 $at_traceoff
   35926 echo "calc.at:593: cat stderr"
   35927 echo calc.at:593 >$at_check_line_file
   35928 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   35929 at_status=$?
   35930 grep '^ *+' $at_stder1 >&2
   35931 grep -v '^ *+' $at_stder1 >$at_stderr
   35932 at_failed=false
   35933 $at_diff $at_devnull $at_stderr || at_failed=:
   35934 $at_diff expout $at_stdout || at_failed=:
   35935 case $at_status in
   35936    77) echo 77 > $at_status_file
   35937             exit 77;;
   35938    0) ;;
   35939    *) echo "calc.at:593: exit code was $at_status, expected 0"
   35940       at_failed=:;;
   35941 esac
   35942 if $at_failed; then
   35943 
   35944   echo 1 > $at_status_file
   35945   exit 1
   35946 fi
   35947 
   35948 $at_traceon
   35949 
   35950 
   35951 cat >input <<'_ATEOF'
   35952 
   35953 +1
   35954 _ATEOF
   35955 
   35956 $at_traceoff
   35957 echo "calc.at:593: \$PREPARSER ./calc input"
   35958 echo calc.at:593 >$at_check_line_file
   35959 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   35960 at_status=$?
   35961 grep '^ *+' $at_stder1 >&2
   35962 grep -v '^ *+' $at_stder1 >$at_stderr
   35963 at_failed=false
   35964 echo stderr:; tee stderr <$at_stderr
   35965 $at_diff $at_devnull $at_stdout || at_failed=:
   35966 case $at_status in
   35967    77) echo 77 > $at_status_file
   35968             exit 77;;
   35969    1) ;;
   35970    *) echo "calc.at:593: exit code was $at_status, expected 1"
   35971       at_failed=:;;
   35972 esac
   35973 if $at_failed; then
   35974 
   35975   echo 1 > $at_status_file
   35976   exit 1
   35977 fi
   35978 
   35979 $at_traceon
   35980 
   35981 
   35982 # Normalize the observed and expected error messages, depending upon the
   35983 # options.
   35984 # 1. Remove the traces from observed.
   35985 sed '/^Starting/d
   35986 /^Entering/d
   35987 /^Stack/d
   35988 /^Reading/d
   35989 /^Reducing/d
   35990 /^Shifting/d
   35991 /^state/d
   35992 /^Cleanup:/d
   35993 /^Error:/d
   35994 /^Next/d
   35995 /^Discarding/d
   35996 / \$[0-9$]* = /d
   35997 /^yydestructor:/d' stderr >at-stderr
   35998 mv at-stderr stderr
   35999 # 2. Create the reference error message.
   36000 cat >expout <<'_ATEOF'
   36001 2.0: syntax error, unexpected '+'
   36002 _ATEOF
   36003 
   36004 # 3. If locations are not used, remove them.
   36005 sed 's/^[-0-9.]*: //' expout >at-expout
   36006 mv at-expout expout
   36007 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   36008 
   36009 # 5. Check
   36010 $at_traceoff
   36011 echo "calc.at:593: cat stderr"
   36012 echo calc.at:593 >$at_check_line_file
   36013 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   36014 at_status=$?
   36015 grep '^ *+' $at_stder1 >&2
   36016 grep -v '^ *+' $at_stder1 >$at_stderr
   36017 at_failed=false
   36018 $at_diff $at_devnull $at_stderr || at_failed=:
   36019 $at_diff expout $at_stdout || at_failed=:
   36020 case $at_status in
   36021    77) echo 77 > $at_status_file
   36022             exit 77;;
   36023    0) ;;
   36024    *) echo "calc.at:593: exit code was $at_status, expected 0"
   36025       at_failed=:;;
   36026 esac
   36027 if $at_failed; then
   36028 
   36029   echo 1 > $at_status_file
   36030   exit 1
   36031 fi
   36032 
   36033 $at_traceon
   36034 
   36035 
   36036 # Exercise error messages with EOF: work on an empty file.
   36037 $at_traceoff
   36038 echo "calc.at:593: \$PREPARSER ./calc /dev/null"
   36039 echo calc.at:593 >$at_check_line_file
   36040 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   36041 at_status=$?
   36042 grep '^ *+' $at_stder1 >&2
   36043 grep -v '^ *+' $at_stder1 >$at_stderr
   36044 at_failed=false
   36045 echo stderr:; tee stderr <$at_stderr
   36046 $at_diff $at_devnull $at_stdout || at_failed=:
   36047 case $at_status in
   36048    77) echo 77 > $at_status_file
   36049             exit 77;;
   36050    1) ;;
   36051    *) echo "calc.at:593: exit code was $at_status, expected 1"
   36052       at_failed=:;;
   36053 esac
   36054 if $at_failed; then
   36055 
   36056   echo 1 > $at_status_file
   36057   exit 1
   36058 fi
   36059 
   36060 $at_traceon
   36061 
   36062 
   36063 # Normalize the observed and expected error messages, depending upon the
   36064 # options.
   36065 # 1. Remove the traces from observed.
   36066 sed '/^Starting/d
   36067 /^Entering/d
   36068 /^Stack/d
   36069 /^Reading/d
   36070 /^Reducing/d
   36071 /^Shifting/d
   36072 /^state/d
   36073 /^Cleanup:/d
   36074 /^Error:/d
   36075 /^Next/d
   36076 /^Discarding/d
   36077 / \$[0-9$]* = /d
   36078 /^yydestructor:/d' stderr >at-stderr
   36079 mv at-stderr stderr
   36080 # 2. Create the reference error message.
   36081 cat >expout <<'_ATEOF'
   36082 1.0: syntax error, unexpected end of input
   36083 _ATEOF
   36084 
   36085 # 3. If locations are not used, remove them.
   36086 sed 's/^[-0-9.]*: //' expout >at-expout
   36087 mv at-expout expout
   36088 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   36089 
   36090 # 5. Check
   36091 $at_traceoff
   36092 echo "calc.at:593: cat stderr"
   36093 echo calc.at:593 >$at_check_line_file
   36094 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   36095 at_status=$?
   36096 grep '^ *+' $at_stder1 >&2
   36097 grep -v '^ *+' $at_stder1 >$at_stderr
   36098 at_failed=false
   36099 $at_diff $at_devnull $at_stderr || at_failed=:
   36100 $at_diff expout $at_stdout || at_failed=:
   36101 case $at_status in
   36102    77) echo 77 > $at_status_file
   36103             exit 77;;
   36104    0) ;;
   36105    *) echo "calc.at:593: exit code was $at_status, expected 0"
   36106       at_failed=:;;
   36107 esac
   36108 if $at_failed; then
   36109 
   36110   echo 1 > $at_status_file
   36111   exit 1
   36112 fi
   36113 
   36114 $at_traceon
   36115 
   36116 
   36117 
   36118 # Exercise the error token: without it, we die at the first error,
   36119 # hence be sure to
   36120 #
   36121 # - have several errors which exercise different shift/discardings
   36122 #   - (): nothing to pop, nothing to discard
   36123 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   36124 #   - (* * *): nothing to pop, a lot to discard
   36125 #   - (1 + 2 * *): some to pop and discard
   36126 #
   36127 # - test the action associated to `error'
   36128 #
   36129 # - check the look-ahead that triggers an error is not discarded
   36130 #   when we enter error recovery.  Below, the look-ahead causing the
   36131 #   first error is ")", which is needed to recover from the error and
   36132 #   produce the "0" that triggers the "0 != 1" error.
   36133 #
   36134 cat >input <<'_ATEOF'
   36135 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   36136 _ATEOF
   36137 
   36138 $at_traceoff
   36139 echo "calc.at:593: \$PREPARSER ./calc input"
   36140 echo calc.at:593 >$at_check_line_file
   36141 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   36142 at_status=$?
   36143 grep '^ *+' $at_stder1 >&2
   36144 grep -v '^ *+' $at_stder1 >$at_stderr
   36145 at_failed=false
   36146 echo stderr:; tee stderr <$at_stderr
   36147 $at_diff $at_devnull $at_stdout || at_failed=:
   36148 case $at_status in
   36149    77) echo 77 > $at_status_file
   36150             exit 77;;
   36151    0) ;;
   36152    *) echo "calc.at:593: exit code was $at_status, expected 0"
   36153       at_failed=:;;
   36154 esac
   36155 if $at_failed; then
   36156 
   36157   echo 1 > $at_status_file
   36158   exit 1
   36159 fi
   36160 
   36161 $at_traceon
   36162 
   36163 
   36164 # Normalize the observed and expected error messages, depending upon the
   36165 # options.
   36166 # 1. Remove the traces from observed.
   36167 sed '/^Starting/d
   36168 /^Entering/d
   36169 /^Stack/d
   36170 /^Reading/d
   36171 /^Reducing/d
   36172 /^Shifting/d
   36173 /^state/d
   36174 /^Cleanup:/d
   36175 /^Error:/d
   36176 /^Next/d
   36177 /^Discarding/d
   36178 / \$[0-9$]* = /d
   36179 /^yydestructor:/d' stderr >at-stderr
   36180 mv at-stderr stderr
   36181 # 2. Create the reference error message.
   36182 cat >expout <<'_ATEOF'
   36183 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   36184 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   36185 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   36186 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   36187 calc: error: 4444 != 1
   36188 _ATEOF
   36189 
   36190 # 3. If locations are not used, remove them.
   36191 sed 's/^[-0-9.]*: //' expout >at-expout
   36192 mv at-expout expout
   36193 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   36194 
   36195 # 5. Check
   36196 $at_traceoff
   36197 echo "calc.at:593: cat stderr"
   36198 echo calc.at:593 >$at_check_line_file
   36199 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   36200 at_status=$?
   36201 grep '^ *+' $at_stder1 >&2
   36202 grep -v '^ *+' $at_stder1 >$at_stderr
   36203 at_failed=false
   36204 $at_diff $at_devnull $at_stderr || at_failed=:
   36205 $at_diff expout $at_stdout || at_failed=:
   36206 case $at_status in
   36207    77) echo 77 > $at_status_file
   36208             exit 77;;
   36209    0) ;;
   36210    *) echo "calc.at:593: exit code was $at_status, expected 0"
   36211       at_failed=:;;
   36212 esac
   36213 if $at_failed; then
   36214 
   36215   echo 1 > $at_status_file
   36216   exit 1
   36217 fi
   36218 
   36219 $at_traceon
   36220 
   36221 
   36222 
   36223 # The same, but this time exercising explicitly triggered syntax errors.
   36224 # POSIX says the look-ahead causing the error should not be discarded.
   36225 cat >input <<'_ATEOF'
   36226 (!) + (0 0) = 1
   36227 _ATEOF
   36228 
   36229 $at_traceoff
   36230 echo "calc.at:593: \$PREPARSER ./calc input"
   36231 echo calc.at:593 >$at_check_line_file
   36232 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   36233 at_status=$?
   36234 grep '^ *+' $at_stder1 >&2
   36235 grep -v '^ *+' $at_stder1 >$at_stderr
   36236 at_failed=false
   36237 echo stderr:; tee stderr <$at_stderr
   36238 $at_diff $at_devnull $at_stdout || at_failed=:
   36239 case $at_status in
   36240    77) echo 77 > $at_status_file
   36241             exit 77;;
   36242    0) ;;
   36243    *) echo "calc.at:593: exit code was $at_status, expected 0"
   36244       at_failed=:;;
   36245 esac
   36246 if $at_failed; then
   36247 
   36248   echo 1 > $at_status_file
   36249   exit 1
   36250 fi
   36251 
   36252 $at_traceon
   36253 
   36254 
   36255 # Normalize the observed and expected error messages, depending upon the
   36256 # options.
   36257 # 1. Remove the traces from observed.
   36258 sed '/^Starting/d
   36259 /^Entering/d
   36260 /^Stack/d
   36261 /^Reading/d
   36262 /^Reducing/d
   36263 /^Shifting/d
   36264 /^state/d
   36265 /^Cleanup:/d
   36266 /^Error:/d
   36267 /^Next/d
   36268 /^Discarding/d
   36269 / \$[0-9$]* = /d
   36270 /^yydestructor:/d' stderr >at-stderr
   36271 mv at-stderr stderr
   36272 # 2. Create the reference error message.
   36273 cat >expout <<'_ATEOF'
   36274 1.9: syntax error, unexpected number
   36275 calc: error: 2222 != 1
   36276 _ATEOF
   36277 
   36278 # 3. If locations are not used, remove them.
   36279 sed 's/^[-0-9.]*: //' expout >at-expout
   36280 mv at-expout expout
   36281 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   36282 
   36283 # 5. Check
   36284 $at_traceoff
   36285 echo "calc.at:593: cat stderr"
   36286 echo calc.at:593 >$at_check_line_file
   36287 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   36288 at_status=$?
   36289 grep '^ *+' $at_stder1 >&2
   36290 grep -v '^ *+' $at_stder1 >$at_stderr
   36291 at_failed=false
   36292 $at_diff $at_devnull $at_stderr || at_failed=:
   36293 $at_diff expout $at_stdout || at_failed=:
   36294 case $at_status in
   36295    77) echo 77 > $at_status_file
   36296             exit 77;;
   36297    0) ;;
   36298    *) echo "calc.at:593: exit code was $at_status, expected 0"
   36299       at_failed=:;;
   36300 esac
   36301 if $at_failed; then
   36302 
   36303   echo 1 > $at_status_file
   36304   exit 1
   36305 fi
   36306 
   36307 $at_traceon
   36308 
   36309 
   36310 cat >input <<'_ATEOF'
   36311 (- *) + (0 0) = 1
   36312 _ATEOF
   36313 
   36314 $at_traceoff
   36315 echo "calc.at:593: \$PREPARSER ./calc input"
   36316 echo calc.at:593 >$at_check_line_file
   36317 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   36318 at_status=$?
   36319 grep '^ *+' $at_stder1 >&2
   36320 grep -v '^ *+' $at_stder1 >$at_stderr
   36321 at_failed=false
   36322 echo stderr:; tee stderr <$at_stderr
   36323 $at_diff $at_devnull $at_stdout || at_failed=:
   36324 case $at_status in
   36325    77) echo 77 > $at_status_file
   36326             exit 77;;
   36327    0) ;;
   36328    *) echo "calc.at:593: exit code was $at_status, expected 0"
   36329       at_failed=:;;
   36330 esac
   36331 if $at_failed; then
   36332 
   36333   echo 1 > $at_status_file
   36334   exit 1
   36335 fi
   36336 
   36337 $at_traceon
   36338 
   36339 
   36340 # Normalize the observed and expected error messages, depending upon the
   36341 # options.
   36342 # 1. Remove the traces from observed.
   36343 sed '/^Starting/d
   36344 /^Entering/d
   36345 /^Stack/d
   36346 /^Reading/d
   36347 /^Reducing/d
   36348 /^Shifting/d
   36349 /^state/d
   36350 /^Cleanup:/d
   36351 /^Error:/d
   36352 /^Next/d
   36353 /^Discarding/d
   36354 / \$[0-9$]* = /d
   36355 /^yydestructor:/d' stderr >at-stderr
   36356 mv at-stderr stderr
   36357 # 2. Create the reference error message.
   36358 cat >expout <<'_ATEOF'
   36359 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   36360 1.11: syntax error, unexpected number
   36361 calc: error: 2222 != 1
   36362 _ATEOF
   36363 
   36364 # 3. If locations are not used, remove them.
   36365 sed 's/^[-0-9.]*: //' expout >at-expout
   36366 mv at-expout expout
   36367 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   36368 
   36369 # 5. Check
   36370 $at_traceoff
   36371 echo "calc.at:593: cat stderr"
   36372 echo calc.at:593 >$at_check_line_file
   36373 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   36374 at_status=$?
   36375 grep '^ *+' $at_stder1 >&2
   36376 grep -v '^ *+' $at_stder1 >$at_stderr
   36377 at_failed=false
   36378 $at_diff $at_devnull $at_stderr || at_failed=:
   36379 $at_diff expout $at_stdout || at_failed=:
   36380 case $at_status in
   36381    77) echo 77 > $at_status_file
   36382             exit 77;;
   36383    0) ;;
   36384    *) echo "calc.at:593: exit code was $at_status, expected 0"
   36385       at_failed=:;;
   36386 esac
   36387 if $at_failed; then
   36388 
   36389   echo 1 > $at_status_file
   36390   exit 1
   36391 fi
   36392 
   36393 $at_traceon
   36394 
   36395 
   36396 
   36397 
   36398 
   36399 
   36400 
   36401 
   36402 
   36403 
   36404 
   36405 
   36406 
   36407 
   36408 
   36409 
   36410 
   36411 
   36412 
   36413 
   36414 
   36415 
   36416 
   36417 
   36418       $at_traceoff
   36419       $at_times_p && times >$at_times_file
   36420     ) 5>&1 2>&1 | eval $at_tee_pipe
   36421     at_status=`cat $at_status_file`
   36422     ;;
   36423 
   36424   91 ) # 91. calc.at:595: Calculator %glr-parser %pure-parser %locations
   36425     at_setup_line='calc.at:595'
   36426     at_desc='Calculator %glr-parser %pure-parser %locations'
   36427     $at_quiet $ECHO_N " 91: Calculator %glr-parser %pure-parser %locations$ECHO_C"
   36428     at_xfail=no
   36429     (
   36430       echo "91. calc.at:595: testing ..."
   36431       $at_traceon
   36432 
   36433 
   36434 
   36435 
   36436 
   36437 
   36438 
   36439 
   36440 # Using yacc.c?
   36441 
   36442 
   36443 
   36444 
   36445 
   36446 
   36447 
   36448 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   36449 
   36450 # yyerror always sees the locations (when activated), except if
   36451 # yacc & pure & !param.
   36452 
   36453 
   36454 # The interface is pure: either because %pure-parser, or because we
   36455 # are using the C++ parsers.
   36456 
   36457 
   36458 
   36459 
   36460 
   36461 
   36462 
   36463 
   36464 
   36465 
   36466 
   36467 
   36468 cat >calc.y <<'_ATEOF'
   36469 %{
   36470 #ifdef HAVE_CONFIG_H
   36471 # include <config.h>
   36472   /* We don't need perfect functions for these tests. */
   36473 # undef malloc
   36474 # undef memcmp
   36475 # undef realloc
   36476 #endif
   36477 %}
   36478 
   36479 /* Infix notation calculator--calc */
   36480 %glr-parser %pure-parser %locations
   36481 
   36482 %{
   36483 #include <stdio.h>
   36484 
   36485 #include <stdlib.h>
   36486 #include <string.h>
   36487 #if HAVE_UNISTD_H
   36488 # include <unistd.h>
   36489 #else
   36490 # undef alarm
   36491 # define alarm(seconds) /* empty */
   36492 #endif
   36493 #include <ctype.h>
   36494 #define USE(Var)
   36495 
   36496 /* Exercise pre-prologue dependency to %union.  */
   36497 typedef int semantic_value;
   36498 
   36499 static semantic_value global_result = 0;
   36500 static int global_count = 0;
   36501 %}
   36502 
   36503 /* Exercise %union. */
   36504 %union
   36505 {
   36506   semantic_value ival;
   36507 };
   36508 
   36509 %{
   36510 static int power (int base, int exponent);
   36511 /* yyerror receives the location if:
   36512    - %location & %pure & %glr
   36513    - %location & %pure & %yacc & %parse-param. */
   36514 static void yyerror (YYLTYPE *llocp,
   36515 
   36516                      const char *s
   36517                      );
   36518 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   36519 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   36520 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   36521 %}
   36522 
   36523 
   36524 
   36525 /* Bison Declarations */
   36526 %token CALC_EOF 0 "end of input"
   36527 %token <ival> NUM "number"
   36528 %type  <ival> exp
   36529 
   36530 %nonassoc '=' /* comparison	       */
   36531 %left '-' '+'
   36532 %left '*' '/'
   36533 %left NEG     /* negation--unary minus */
   36534 %right '^'    /* exponentiation        */
   36535 
   36536 /* Grammar follows */
   36537 %%
   36538 input:
   36539   line
   36540 | input line         {  }
   36541 ;
   36542 
   36543 line:
   36544   '\n'
   36545 | exp '\n'           { USE ($1); }
   36546 ;
   36547 
   36548 exp:
   36549   NUM                { $$ = $1;             }
   36550 | exp '=' exp
   36551   {
   36552     if ($1 != $3)
   36553       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   36554     $$ = $1;
   36555   }
   36556 | exp '+' exp        { $$ = $1 + $3;        }
   36557 | exp '-' exp        { $$ = $1 - $3;        }
   36558 | exp '*' exp        { $$ = $1 * $3;        }
   36559 | exp '/' exp        { $$ = $1 / $3;        }
   36560 | '-' exp  %prec NEG { $$ = -$2;            }
   36561 | exp '^' exp        { $$ = power ($1, $3); }
   36562 | '(' exp ')'        { $$ = $2;             }
   36563 | '(' error ')'      { $$ = 1111;           }
   36564 | '!'                { $$ = 0; YYERROR;     }
   36565 | '-' error          { $$ = 0; YYERROR;     }
   36566 ;
   36567 %%
   36568 /* The input.  */
   36569 static FILE *input;
   36570 
   36571 static void
   36572 yyerror (YYLTYPE *llocp,
   36573 
   36574          const char *s)
   36575 {
   36576 
   36577 
   36578   fprintf (stderr, "%d.%d",
   36579            (*llocp).first_line, (*llocp).first_column);
   36580   if ((*llocp).first_line != (*llocp).last_line)
   36581     fprintf (stderr, "-%d.%d",
   36582 	     (*llocp).last_line,  (*llocp).last_column - 1);
   36583   else if ((*llocp).first_column != (*llocp).last_column - 1)
   36584     fprintf (stderr, "-%d",
   36585 	     (*llocp).last_column - 1);
   36586   fprintf (stderr, ": ");
   36587   fprintf (stderr, "%s\n", s);
   36588 }
   36589 
   36590 
   36591 
   36592 static YYLTYPE last_yylloc;
   36593 
   36594 static int
   36595 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   36596 {
   36597   int res = getc (input);
   36598   (void) lvalp;(void) llocp;
   36599 
   36600   last_yylloc = (*llocp);
   36601   if (res == '\n')
   36602     {
   36603       (*llocp).last_line++;
   36604       (*llocp).last_column = 0;
   36605     }
   36606   else
   36607     (*llocp).last_column++;
   36608 
   36609   return res;
   36610 }
   36611 
   36612 
   36613 static void
   36614 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   36615 {
   36616   (void) lvalp;(void) llocp;
   36617 
   36618   /* Wrong when C == `\n'. */
   36619   (*llocp) = last_yylloc;
   36620 
   36621   ungetc (c, input);
   36622 }
   36623 
   36624 static int
   36625 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   36626 {
   36627   int c = get_char (lvalp, llocp);
   36628   int sign = 1;
   36629   int n = 0;
   36630 
   36631   (void) lvalp;(void) llocp;
   36632   if (c == '-')
   36633     {
   36634       c = get_char (lvalp, llocp);
   36635       sign = -1;
   36636     }
   36637 
   36638   while (isdigit (c))
   36639     {
   36640       n = 10 * n + (c - '0');
   36641       c = get_char (lvalp, llocp);
   36642     }
   36643 
   36644   unget_char (lvalp, llocp,  c);
   36645 
   36646   return sign * n;
   36647 }
   36648 
   36649 
   36650 
   36651 /*---------------------------------------------------------------.
   36652 | Lexical analyzer returns an integer on the stack and the token |
   36653 | NUM, or the ASCII character read if not a number.  Skips all   |
   36654 | blanks and tabs, returns 0 for EOF.                            |
   36655 `---------------------------------------------------------------*/
   36656 
   36657 static int
   36658 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   36659 {
   36660   static int init = 1;
   36661   int c;
   36662 
   36663   if (init)
   36664     {
   36665       init = 0;
   36666 
   36667       (*llocp).last_column = 0;
   36668       (*llocp).last_line = 1;
   36669 
   36670     }
   36671 
   36672 
   36673  (*llocp).first_column = (*llocp).last_column;
   36674   (*llocp).first_line   = (*llocp).last_line;
   36675 
   36676 
   36677   /* Skip white space.  */
   36678   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   36679     {
   36680      (*llocp).first_column = (*llocp).last_column;
   36681       (*llocp).first_line   = (*llocp).last_line;
   36682 
   36683     }
   36684 
   36685   /* process numbers   */
   36686   if (c == '.' || isdigit (c))
   36687     {
   36688       unget_char (lvalp, llocp,  c);
   36689       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   36690       return NUM;
   36691     }
   36692 
   36693   /* Return end-of-file.  */
   36694   if (c == EOF)
   36695     return CALC_EOF;
   36696 
   36697   /* Return single chars. */
   36698   return c;
   36699 }
   36700 
   36701 static int
   36702 power (int base, int exponent)
   36703 {
   36704   int res = 1;
   36705   if (exponent < 0)
   36706     exit (3);
   36707   for (/* Niente */; exponent; --exponent)
   36708     res *= base;
   36709   return res;
   36710 }
   36711 
   36712 
   36713 int
   36714 main (int argc, const char **argv)
   36715 {
   36716   semantic_value result = 0;
   36717   int count = 0;
   36718   int status;
   36719 
   36720   /* This used to be alarm (10), but that isn't enough time for
   36721      a July 1995 vintage DEC Alphastation 200 4/100 system,
   36722      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   36723   alarm (100);
   36724 
   36725   if (argc == 2)
   36726     input = fopen (argv[1], "r");
   36727   else
   36728     input = stdin;
   36729 
   36730   if (!input)
   36731     {
   36732       perror (argv[1]);
   36733       return 3;
   36734     }
   36735 
   36736 
   36737   status = yyparse ();
   36738   if (global_result != result)
   36739     abort ();
   36740   if (global_count != count)
   36741     abort ();
   36742   return status;
   36743 }
   36744 _ATEOF
   36745 
   36746 
   36747 
   36748 
   36749 
   36750 $at_traceoff
   36751 echo "calc.at:595: bison -o calc.c calc.y"
   36752 echo calc.at:595 >$at_check_line_file
   36753 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   36754 at_status=$?
   36755 grep '^ *+' $at_stder1 >&2
   36756 grep -v '^ *+' $at_stder1 >$at_stderr
   36757 at_failed=false
   36758 $at_diff $at_devnull $at_stderr || at_failed=:
   36759 $at_diff $at_devnull $at_stdout || at_failed=:
   36760 case $at_status in
   36761    77) echo 77 > $at_status_file
   36762             exit 77;;
   36763    0) ;;
   36764    *) echo "calc.at:595: exit code was $at_status, expected 0"
   36765       at_failed=:;;
   36766 esac
   36767 if $at_failed; then
   36768 
   36769   echo 1 > $at_status_file
   36770   exit 1
   36771 fi
   36772 
   36773 $at_traceon
   36774 
   36775    $at_traceoff
   36776 echo "calc.at:595: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   36777 echo calc.at:595 >$at_check_line_file
   36778 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   36779 at_status=$?
   36780 grep '^ *+' $at_stder1 >&2
   36781 grep -v '^ *+' $at_stder1 >$at_stderr
   36782 at_failed=false
   36783 echo stderr:; cat $at_stderr
   36784 echo stdout:; cat $at_stdout
   36785 case $at_status in
   36786    77) echo 77 > $at_status_file
   36787             exit 77;;
   36788    0) ;;
   36789    *) echo "calc.at:595: exit code was $at_status, expected 0"
   36790       at_failed=:;;
   36791 esac
   36792 if $at_failed; then
   36793 
   36794   echo 1 > $at_status_file
   36795   exit 1
   36796 fi
   36797 
   36798 $at_traceon
   36799 
   36800 
   36801 # Test the priorities.
   36802 cat >input <<'_ATEOF'
   36803 1 + 2 * 3 = 7
   36804 1 + 2 * -3 = -5
   36805 
   36806 -1^2 = -1
   36807 (-1)^2 = 1
   36808 
   36809 ---1 = -1
   36810 
   36811 1 - 2 - 3 = -4
   36812 1 - (2 - 3) = 2
   36813 
   36814 2^2^3 = 256
   36815 (2^2)^3 = 64
   36816 _ATEOF
   36817 
   36818 $at_traceoff
   36819 echo "calc.at:595: \$PREPARSER ./calc input"
   36820 echo calc.at:595 >$at_check_line_file
   36821 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   36822 at_status=$?
   36823 grep '^ *+' $at_stder1 >&2
   36824 grep -v '^ *+' $at_stder1 >$at_stderr
   36825 at_failed=false
   36826 echo stderr:; tee stderr <$at_stderr
   36827 $at_diff $at_devnull $at_stdout || at_failed=:
   36828 case $at_status in
   36829    77) echo 77 > $at_status_file
   36830             exit 77;;
   36831    0) ;;
   36832    *) echo "calc.at:595: exit code was $at_status, expected 0"
   36833       at_failed=:;;
   36834 esac
   36835 if $at_failed; then
   36836 
   36837   echo 1 > $at_status_file
   36838   exit 1
   36839 fi
   36840 
   36841 $at_traceon
   36842 
   36843 
   36844 
   36845 # Some syntax errors.
   36846 cat >input <<'_ATEOF'
   36847 0 0
   36848 _ATEOF
   36849 
   36850 $at_traceoff
   36851 echo "calc.at:595: \$PREPARSER ./calc input"
   36852 echo calc.at:595 >$at_check_line_file
   36853 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   36854 at_status=$?
   36855 grep '^ *+' $at_stder1 >&2
   36856 grep -v '^ *+' $at_stder1 >$at_stderr
   36857 at_failed=false
   36858 echo stderr:; tee stderr <$at_stderr
   36859 $at_diff $at_devnull $at_stdout || at_failed=:
   36860 case $at_status in
   36861    77) echo 77 > $at_status_file
   36862             exit 77;;
   36863    1) ;;
   36864    *) echo "calc.at:595: exit code was $at_status, expected 1"
   36865       at_failed=:;;
   36866 esac
   36867 if $at_failed; then
   36868 
   36869   echo 1 > $at_status_file
   36870   exit 1
   36871 fi
   36872 
   36873 $at_traceon
   36874 
   36875 
   36876 # Normalize the observed and expected error messages, depending upon the
   36877 # options.
   36878 # 1. Remove the traces from observed.
   36879 sed '/^Starting/d
   36880 /^Entering/d
   36881 /^Stack/d
   36882 /^Reading/d
   36883 /^Reducing/d
   36884 /^Shifting/d
   36885 /^state/d
   36886 /^Cleanup:/d
   36887 /^Error:/d
   36888 /^Next/d
   36889 /^Discarding/d
   36890 / \$[0-9$]* = /d
   36891 /^yydestructor:/d' stderr >at-stderr
   36892 mv at-stderr stderr
   36893 # 2. Create the reference error message.
   36894 cat >expout <<'_ATEOF'
   36895 1.2: syntax error, unexpected number
   36896 _ATEOF
   36897 
   36898 # 3. If locations are not used, remove them.
   36899 
   36900 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   36901 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   36902 mv at-expout expout
   36903 # 5. Check
   36904 $at_traceoff
   36905 echo "calc.at:595: cat stderr"
   36906 echo calc.at:595 >$at_check_line_file
   36907 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   36908 at_status=$?
   36909 grep '^ *+' $at_stder1 >&2
   36910 grep -v '^ *+' $at_stder1 >$at_stderr
   36911 at_failed=false
   36912 $at_diff $at_devnull $at_stderr || at_failed=:
   36913 $at_diff expout $at_stdout || at_failed=:
   36914 case $at_status in
   36915    77) echo 77 > $at_status_file
   36916             exit 77;;
   36917    0) ;;
   36918    *) echo "calc.at:595: exit code was $at_status, expected 0"
   36919       at_failed=:;;
   36920 esac
   36921 if $at_failed; then
   36922 
   36923   echo 1 > $at_status_file
   36924   exit 1
   36925 fi
   36926 
   36927 $at_traceon
   36928 
   36929 
   36930 cat >input <<'_ATEOF'
   36931 1//2
   36932 _ATEOF
   36933 
   36934 $at_traceoff
   36935 echo "calc.at:595: \$PREPARSER ./calc input"
   36936 echo calc.at:595 >$at_check_line_file
   36937 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   36938 at_status=$?
   36939 grep '^ *+' $at_stder1 >&2
   36940 grep -v '^ *+' $at_stder1 >$at_stderr
   36941 at_failed=false
   36942 echo stderr:; tee stderr <$at_stderr
   36943 $at_diff $at_devnull $at_stdout || at_failed=:
   36944 case $at_status in
   36945    77) echo 77 > $at_status_file
   36946             exit 77;;
   36947    1) ;;
   36948    *) echo "calc.at:595: exit code was $at_status, expected 1"
   36949       at_failed=:;;
   36950 esac
   36951 if $at_failed; then
   36952 
   36953   echo 1 > $at_status_file
   36954   exit 1
   36955 fi
   36956 
   36957 $at_traceon
   36958 
   36959 
   36960 # Normalize the observed and expected error messages, depending upon the
   36961 # options.
   36962 # 1. Remove the traces from observed.
   36963 sed '/^Starting/d
   36964 /^Entering/d
   36965 /^Stack/d
   36966 /^Reading/d
   36967 /^Reducing/d
   36968 /^Shifting/d
   36969 /^state/d
   36970 /^Cleanup:/d
   36971 /^Error:/d
   36972 /^Next/d
   36973 /^Discarding/d
   36974 / \$[0-9$]* = /d
   36975 /^yydestructor:/d' stderr >at-stderr
   36976 mv at-stderr stderr
   36977 # 2. Create the reference error message.
   36978 cat >expout <<'_ATEOF'
   36979 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   36980 _ATEOF
   36981 
   36982 # 3. If locations are not used, remove them.
   36983 
   36984 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   36985 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   36986 mv at-expout expout
   36987 # 5. Check
   36988 $at_traceoff
   36989 echo "calc.at:595: cat stderr"
   36990 echo calc.at:595 >$at_check_line_file
   36991 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   36992 at_status=$?
   36993 grep '^ *+' $at_stder1 >&2
   36994 grep -v '^ *+' $at_stder1 >$at_stderr
   36995 at_failed=false
   36996 $at_diff $at_devnull $at_stderr || at_failed=:
   36997 $at_diff expout $at_stdout || at_failed=:
   36998 case $at_status in
   36999    77) echo 77 > $at_status_file
   37000             exit 77;;
   37001    0) ;;
   37002    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37003       at_failed=:;;
   37004 esac
   37005 if $at_failed; then
   37006 
   37007   echo 1 > $at_status_file
   37008   exit 1
   37009 fi
   37010 
   37011 $at_traceon
   37012 
   37013 
   37014 cat >input <<'_ATEOF'
   37015 error
   37016 _ATEOF
   37017 
   37018 $at_traceoff
   37019 echo "calc.at:595: \$PREPARSER ./calc input"
   37020 echo calc.at:595 >$at_check_line_file
   37021 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   37022 at_status=$?
   37023 grep '^ *+' $at_stder1 >&2
   37024 grep -v '^ *+' $at_stder1 >$at_stderr
   37025 at_failed=false
   37026 echo stderr:; tee stderr <$at_stderr
   37027 $at_diff $at_devnull $at_stdout || at_failed=:
   37028 case $at_status in
   37029    77) echo 77 > $at_status_file
   37030             exit 77;;
   37031    1) ;;
   37032    *) echo "calc.at:595: exit code was $at_status, expected 1"
   37033       at_failed=:;;
   37034 esac
   37035 if $at_failed; then
   37036 
   37037   echo 1 > $at_status_file
   37038   exit 1
   37039 fi
   37040 
   37041 $at_traceon
   37042 
   37043 
   37044 # Normalize the observed and expected error messages, depending upon the
   37045 # options.
   37046 # 1. Remove the traces from observed.
   37047 sed '/^Starting/d
   37048 /^Entering/d
   37049 /^Stack/d
   37050 /^Reading/d
   37051 /^Reducing/d
   37052 /^Shifting/d
   37053 /^state/d
   37054 /^Cleanup:/d
   37055 /^Error:/d
   37056 /^Next/d
   37057 /^Discarding/d
   37058 / \$[0-9$]* = /d
   37059 /^yydestructor:/d' stderr >at-stderr
   37060 mv at-stderr stderr
   37061 # 2. Create the reference error message.
   37062 cat >expout <<'_ATEOF'
   37063 1.0: syntax error, unexpected $undefined
   37064 _ATEOF
   37065 
   37066 # 3. If locations are not used, remove them.
   37067 
   37068 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   37069 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   37070 mv at-expout expout
   37071 # 5. Check
   37072 $at_traceoff
   37073 echo "calc.at:595: cat stderr"
   37074 echo calc.at:595 >$at_check_line_file
   37075 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   37076 at_status=$?
   37077 grep '^ *+' $at_stder1 >&2
   37078 grep -v '^ *+' $at_stder1 >$at_stderr
   37079 at_failed=false
   37080 $at_diff $at_devnull $at_stderr || at_failed=:
   37081 $at_diff expout $at_stdout || at_failed=:
   37082 case $at_status in
   37083    77) echo 77 > $at_status_file
   37084             exit 77;;
   37085    0) ;;
   37086    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37087       at_failed=:;;
   37088 esac
   37089 if $at_failed; then
   37090 
   37091   echo 1 > $at_status_file
   37092   exit 1
   37093 fi
   37094 
   37095 $at_traceon
   37096 
   37097 
   37098 cat >input <<'_ATEOF'
   37099 1 = 2 = 3
   37100 _ATEOF
   37101 
   37102 $at_traceoff
   37103 echo "calc.at:595: \$PREPARSER ./calc input"
   37104 echo calc.at:595 >$at_check_line_file
   37105 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   37106 at_status=$?
   37107 grep '^ *+' $at_stder1 >&2
   37108 grep -v '^ *+' $at_stder1 >$at_stderr
   37109 at_failed=false
   37110 echo stderr:; tee stderr <$at_stderr
   37111 $at_diff $at_devnull $at_stdout || at_failed=:
   37112 case $at_status in
   37113    77) echo 77 > $at_status_file
   37114             exit 77;;
   37115    1) ;;
   37116    *) echo "calc.at:595: exit code was $at_status, expected 1"
   37117       at_failed=:;;
   37118 esac
   37119 if $at_failed; then
   37120 
   37121   echo 1 > $at_status_file
   37122   exit 1
   37123 fi
   37124 
   37125 $at_traceon
   37126 
   37127 
   37128 # Normalize the observed and expected error messages, depending upon the
   37129 # options.
   37130 # 1. Remove the traces from observed.
   37131 sed '/^Starting/d
   37132 /^Entering/d
   37133 /^Stack/d
   37134 /^Reading/d
   37135 /^Reducing/d
   37136 /^Shifting/d
   37137 /^state/d
   37138 /^Cleanup:/d
   37139 /^Error:/d
   37140 /^Next/d
   37141 /^Discarding/d
   37142 / \$[0-9$]* = /d
   37143 /^yydestructor:/d' stderr >at-stderr
   37144 mv at-stderr stderr
   37145 # 2. Create the reference error message.
   37146 cat >expout <<'_ATEOF'
   37147 1.6: syntax error, unexpected '='
   37148 _ATEOF
   37149 
   37150 # 3. If locations are not used, remove them.
   37151 
   37152 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   37153 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   37154 mv at-expout expout
   37155 # 5. Check
   37156 $at_traceoff
   37157 echo "calc.at:595: cat stderr"
   37158 echo calc.at:595 >$at_check_line_file
   37159 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   37160 at_status=$?
   37161 grep '^ *+' $at_stder1 >&2
   37162 grep -v '^ *+' $at_stder1 >$at_stderr
   37163 at_failed=false
   37164 $at_diff $at_devnull $at_stderr || at_failed=:
   37165 $at_diff expout $at_stdout || at_failed=:
   37166 case $at_status in
   37167    77) echo 77 > $at_status_file
   37168             exit 77;;
   37169    0) ;;
   37170    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37171       at_failed=:;;
   37172 esac
   37173 if $at_failed; then
   37174 
   37175   echo 1 > $at_status_file
   37176   exit 1
   37177 fi
   37178 
   37179 $at_traceon
   37180 
   37181 
   37182 cat >input <<'_ATEOF'
   37183 
   37184 +1
   37185 _ATEOF
   37186 
   37187 $at_traceoff
   37188 echo "calc.at:595: \$PREPARSER ./calc input"
   37189 echo calc.at:595 >$at_check_line_file
   37190 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   37191 at_status=$?
   37192 grep '^ *+' $at_stder1 >&2
   37193 grep -v '^ *+' $at_stder1 >$at_stderr
   37194 at_failed=false
   37195 echo stderr:; tee stderr <$at_stderr
   37196 $at_diff $at_devnull $at_stdout || at_failed=:
   37197 case $at_status in
   37198    77) echo 77 > $at_status_file
   37199             exit 77;;
   37200    1) ;;
   37201    *) echo "calc.at:595: exit code was $at_status, expected 1"
   37202       at_failed=:;;
   37203 esac
   37204 if $at_failed; then
   37205 
   37206   echo 1 > $at_status_file
   37207   exit 1
   37208 fi
   37209 
   37210 $at_traceon
   37211 
   37212 
   37213 # Normalize the observed and expected error messages, depending upon the
   37214 # options.
   37215 # 1. Remove the traces from observed.
   37216 sed '/^Starting/d
   37217 /^Entering/d
   37218 /^Stack/d
   37219 /^Reading/d
   37220 /^Reducing/d
   37221 /^Shifting/d
   37222 /^state/d
   37223 /^Cleanup:/d
   37224 /^Error:/d
   37225 /^Next/d
   37226 /^Discarding/d
   37227 / \$[0-9$]* = /d
   37228 /^yydestructor:/d' stderr >at-stderr
   37229 mv at-stderr stderr
   37230 # 2. Create the reference error message.
   37231 cat >expout <<'_ATEOF'
   37232 2.0: syntax error, unexpected '+'
   37233 _ATEOF
   37234 
   37235 # 3. If locations are not used, remove them.
   37236 
   37237 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   37238 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   37239 mv at-expout expout
   37240 # 5. Check
   37241 $at_traceoff
   37242 echo "calc.at:595: cat stderr"
   37243 echo calc.at:595 >$at_check_line_file
   37244 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   37245 at_status=$?
   37246 grep '^ *+' $at_stder1 >&2
   37247 grep -v '^ *+' $at_stder1 >$at_stderr
   37248 at_failed=false
   37249 $at_diff $at_devnull $at_stderr || at_failed=:
   37250 $at_diff expout $at_stdout || at_failed=:
   37251 case $at_status in
   37252    77) echo 77 > $at_status_file
   37253             exit 77;;
   37254    0) ;;
   37255    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37256       at_failed=:;;
   37257 esac
   37258 if $at_failed; then
   37259 
   37260   echo 1 > $at_status_file
   37261   exit 1
   37262 fi
   37263 
   37264 $at_traceon
   37265 
   37266 
   37267 # Exercise error messages with EOF: work on an empty file.
   37268 $at_traceoff
   37269 echo "calc.at:595: \$PREPARSER ./calc /dev/null"
   37270 echo calc.at:595 >$at_check_line_file
   37271 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   37272 at_status=$?
   37273 grep '^ *+' $at_stder1 >&2
   37274 grep -v '^ *+' $at_stder1 >$at_stderr
   37275 at_failed=false
   37276 echo stderr:; tee stderr <$at_stderr
   37277 $at_diff $at_devnull $at_stdout || at_failed=:
   37278 case $at_status in
   37279    77) echo 77 > $at_status_file
   37280             exit 77;;
   37281    1) ;;
   37282    *) echo "calc.at:595: exit code was $at_status, expected 1"
   37283       at_failed=:;;
   37284 esac
   37285 if $at_failed; then
   37286 
   37287   echo 1 > $at_status_file
   37288   exit 1
   37289 fi
   37290 
   37291 $at_traceon
   37292 
   37293 
   37294 # Normalize the observed and expected error messages, depending upon the
   37295 # options.
   37296 # 1. Remove the traces from observed.
   37297 sed '/^Starting/d
   37298 /^Entering/d
   37299 /^Stack/d
   37300 /^Reading/d
   37301 /^Reducing/d
   37302 /^Shifting/d
   37303 /^state/d
   37304 /^Cleanup:/d
   37305 /^Error:/d
   37306 /^Next/d
   37307 /^Discarding/d
   37308 / \$[0-9$]* = /d
   37309 /^yydestructor:/d' stderr >at-stderr
   37310 mv at-stderr stderr
   37311 # 2. Create the reference error message.
   37312 cat >expout <<'_ATEOF'
   37313 1.0: syntax error, unexpected end of input
   37314 _ATEOF
   37315 
   37316 # 3. If locations are not used, remove them.
   37317 
   37318 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   37319 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   37320 mv at-expout expout
   37321 # 5. Check
   37322 $at_traceoff
   37323 echo "calc.at:595: cat stderr"
   37324 echo calc.at:595 >$at_check_line_file
   37325 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   37326 at_status=$?
   37327 grep '^ *+' $at_stder1 >&2
   37328 grep -v '^ *+' $at_stder1 >$at_stderr
   37329 at_failed=false
   37330 $at_diff $at_devnull $at_stderr || at_failed=:
   37331 $at_diff expout $at_stdout || at_failed=:
   37332 case $at_status in
   37333    77) echo 77 > $at_status_file
   37334             exit 77;;
   37335    0) ;;
   37336    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37337       at_failed=:;;
   37338 esac
   37339 if $at_failed; then
   37340 
   37341   echo 1 > $at_status_file
   37342   exit 1
   37343 fi
   37344 
   37345 $at_traceon
   37346 
   37347 
   37348 
   37349 # Exercise the error token: without it, we die at the first error,
   37350 # hence be sure to
   37351 #
   37352 # - have several errors which exercise different shift/discardings
   37353 #   - (): nothing to pop, nothing to discard
   37354 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   37355 #   - (* * *): nothing to pop, a lot to discard
   37356 #   - (1 + 2 * *): some to pop and discard
   37357 #
   37358 # - test the action associated to `error'
   37359 #
   37360 # - check the look-ahead that triggers an error is not discarded
   37361 #   when we enter error recovery.  Below, the look-ahead causing the
   37362 #   first error is ")", which is needed to recover from the error and
   37363 #   produce the "0" that triggers the "0 != 1" error.
   37364 #
   37365 cat >input <<'_ATEOF'
   37366 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   37367 _ATEOF
   37368 
   37369 $at_traceoff
   37370 echo "calc.at:595: \$PREPARSER ./calc input"
   37371 echo calc.at:595 >$at_check_line_file
   37372 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   37373 at_status=$?
   37374 grep '^ *+' $at_stder1 >&2
   37375 grep -v '^ *+' $at_stder1 >$at_stderr
   37376 at_failed=false
   37377 echo stderr:; tee stderr <$at_stderr
   37378 $at_diff $at_devnull $at_stdout || at_failed=:
   37379 case $at_status in
   37380    77) echo 77 > $at_status_file
   37381             exit 77;;
   37382    0) ;;
   37383    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37384       at_failed=:;;
   37385 esac
   37386 if $at_failed; then
   37387 
   37388   echo 1 > $at_status_file
   37389   exit 1
   37390 fi
   37391 
   37392 $at_traceon
   37393 
   37394 
   37395 # Normalize the observed and expected error messages, depending upon the
   37396 # options.
   37397 # 1. Remove the traces from observed.
   37398 sed '/^Starting/d
   37399 /^Entering/d
   37400 /^Stack/d
   37401 /^Reading/d
   37402 /^Reducing/d
   37403 /^Shifting/d
   37404 /^state/d
   37405 /^Cleanup:/d
   37406 /^Error:/d
   37407 /^Next/d
   37408 /^Discarding/d
   37409 / \$[0-9$]* = /d
   37410 /^yydestructor:/d' stderr >at-stderr
   37411 mv at-stderr stderr
   37412 # 2. Create the reference error message.
   37413 cat >expout <<'_ATEOF'
   37414 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   37415 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   37416 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   37417 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   37418 calc: error: 4444 != 1
   37419 _ATEOF
   37420 
   37421 # 3. If locations are not used, remove them.
   37422 
   37423 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   37424 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   37425 mv at-expout expout
   37426 # 5. Check
   37427 $at_traceoff
   37428 echo "calc.at:595: cat stderr"
   37429 echo calc.at:595 >$at_check_line_file
   37430 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   37431 at_status=$?
   37432 grep '^ *+' $at_stder1 >&2
   37433 grep -v '^ *+' $at_stder1 >$at_stderr
   37434 at_failed=false
   37435 $at_diff $at_devnull $at_stderr || at_failed=:
   37436 $at_diff expout $at_stdout || at_failed=:
   37437 case $at_status in
   37438    77) echo 77 > $at_status_file
   37439             exit 77;;
   37440    0) ;;
   37441    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37442       at_failed=:;;
   37443 esac
   37444 if $at_failed; then
   37445 
   37446   echo 1 > $at_status_file
   37447   exit 1
   37448 fi
   37449 
   37450 $at_traceon
   37451 
   37452 
   37453 
   37454 # The same, but this time exercising explicitly triggered syntax errors.
   37455 # POSIX says the look-ahead causing the error should not be discarded.
   37456 cat >input <<'_ATEOF'
   37457 (!) + (0 0) = 1
   37458 _ATEOF
   37459 
   37460 $at_traceoff
   37461 echo "calc.at:595: \$PREPARSER ./calc input"
   37462 echo calc.at:595 >$at_check_line_file
   37463 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   37464 at_status=$?
   37465 grep '^ *+' $at_stder1 >&2
   37466 grep -v '^ *+' $at_stder1 >$at_stderr
   37467 at_failed=false
   37468 echo stderr:; tee stderr <$at_stderr
   37469 $at_diff $at_devnull $at_stdout || at_failed=:
   37470 case $at_status in
   37471    77) echo 77 > $at_status_file
   37472             exit 77;;
   37473    0) ;;
   37474    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37475       at_failed=:;;
   37476 esac
   37477 if $at_failed; then
   37478 
   37479   echo 1 > $at_status_file
   37480   exit 1
   37481 fi
   37482 
   37483 $at_traceon
   37484 
   37485 
   37486 # Normalize the observed and expected error messages, depending upon the
   37487 # options.
   37488 # 1. Remove the traces from observed.
   37489 sed '/^Starting/d
   37490 /^Entering/d
   37491 /^Stack/d
   37492 /^Reading/d
   37493 /^Reducing/d
   37494 /^Shifting/d
   37495 /^state/d
   37496 /^Cleanup:/d
   37497 /^Error:/d
   37498 /^Next/d
   37499 /^Discarding/d
   37500 / \$[0-9$]* = /d
   37501 /^yydestructor:/d' stderr >at-stderr
   37502 mv at-stderr stderr
   37503 # 2. Create the reference error message.
   37504 cat >expout <<'_ATEOF'
   37505 1.9: syntax error, unexpected number
   37506 calc: error: 2222 != 1
   37507 _ATEOF
   37508 
   37509 # 3. If locations are not used, remove them.
   37510 
   37511 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   37512 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   37513 mv at-expout expout
   37514 # 5. Check
   37515 $at_traceoff
   37516 echo "calc.at:595: cat stderr"
   37517 echo calc.at:595 >$at_check_line_file
   37518 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   37519 at_status=$?
   37520 grep '^ *+' $at_stder1 >&2
   37521 grep -v '^ *+' $at_stder1 >$at_stderr
   37522 at_failed=false
   37523 $at_diff $at_devnull $at_stderr || at_failed=:
   37524 $at_diff expout $at_stdout || at_failed=:
   37525 case $at_status in
   37526    77) echo 77 > $at_status_file
   37527             exit 77;;
   37528    0) ;;
   37529    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37530       at_failed=:;;
   37531 esac
   37532 if $at_failed; then
   37533 
   37534   echo 1 > $at_status_file
   37535   exit 1
   37536 fi
   37537 
   37538 $at_traceon
   37539 
   37540 
   37541 cat >input <<'_ATEOF'
   37542 (- *) + (0 0) = 1
   37543 _ATEOF
   37544 
   37545 $at_traceoff
   37546 echo "calc.at:595: \$PREPARSER ./calc input"
   37547 echo calc.at:595 >$at_check_line_file
   37548 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   37549 at_status=$?
   37550 grep '^ *+' $at_stder1 >&2
   37551 grep -v '^ *+' $at_stder1 >$at_stderr
   37552 at_failed=false
   37553 echo stderr:; tee stderr <$at_stderr
   37554 $at_diff $at_devnull $at_stdout || at_failed=:
   37555 case $at_status in
   37556    77) echo 77 > $at_status_file
   37557             exit 77;;
   37558    0) ;;
   37559    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37560       at_failed=:;;
   37561 esac
   37562 if $at_failed; then
   37563 
   37564   echo 1 > $at_status_file
   37565   exit 1
   37566 fi
   37567 
   37568 $at_traceon
   37569 
   37570 
   37571 # Normalize the observed and expected error messages, depending upon the
   37572 # options.
   37573 # 1. Remove the traces from observed.
   37574 sed '/^Starting/d
   37575 /^Entering/d
   37576 /^Stack/d
   37577 /^Reading/d
   37578 /^Reducing/d
   37579 /^Shifting/d
   37580 /^state/d
   37581 /^Cleanup:/d
   37582 /^Error:/d
   37583 /^Next/d
   37584 /^Discarding/d
   37585 / \$[0-9$]* = /d
   37586 /^yydestructor:/d' stderr >at-stderr
   37587 mv at-stderr stderr
   37588 # 2. Create the reference error message.
   37589 cat >expout <<'_ATEOF'
   37590 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   37591 1.11: syntax error, unexpected number
   37592 calc: error: 2222 != 1
   37593 _ATEOF
   37594 
   37595 # 3. If locations are not used, remove them.
   37596 
   37597 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   37598 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   37599 mv at-expout expout
   37600 # 5. Check
   37601 $at_traceoff
   37602 echo "calc.at:595: cat stderr"
   37603 echo calc.at:595 >$at_check_line_file
   37604 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   37605 at_status=$?
   37606 grep '^ *+' $at_stder1 >&2
   37607 grep -v '^ *+' $at_stder1 >$at_stderr
   37608 at_failed=false
   37609 $at_diff $at_devnull $at_stderr || at_failed=:
   37610 $at_diff expout $at_stdout || at_failed=:
   37611 case $at_status in
   37612    77) echo 77 > $at_status_file
   37613             exit 77;;
   37614    0) ;;
   37615    *) echo "calc.at:595: exit code was $at_status, expected 0"
   37616       at_failed=:;;
   37617 esac
   37618 if $at_failed; then
   37619 
   37620   echo 1 > $at_status_file
   37621   exit 1
   37622 fi
   37623 
   37624 $at_traceon
   37625 
   37626 
   37627 
   37628 
   37629 
   37630 
   37631 
   37632 
   37633 
   37634 
   37635 
   37636 
   37637 
   37638 
   37639 
   37640 
   37641 
   37642 
   37643 
   37644 
   37645 
   37646 
   37647 
   37648 
   37649       $at_traceoff
   37650       $at_times_p && times >$at_times_file
   37651     ) 5>&1 2>&1 | eval $at_tee_pipe
   37652     at_status=`cat $at_status_file`
   37653     ;;
   37654 
   37655   92 ) # 92. calc.at:596: Calculator %glr-parser %error-verbose %locations
   37656     at_setup_line='calc.at:596'
   37657     at_desc='Calculator %glr-parser %error-verbose %locations'
   37658     $at_quiet $ECHO_N " 92: Calculator %glr-parser %error-verbose %locations$ECHO_C"
   37659     at_xfail=no
   37660     (
   37661       echo "92. calc.at:596: testing ..."
   37662       $at_traceon
   37663 
   37664 
   37665 
   37666 
   37667 
   37668 
   37669 
   37670 
   37671 # Using yacc.c?
   37672 
   37673 
   37674 
   37675 
   37676 
   37677 
   37678 
   37679 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   37680 
   37681 # yyerror always sees the locations (when activated), except if
   37682 # yacc & pure & !param.
   37683 
   37684 
   37685 # The interface is pure: either because %pure-parser, or because we
   37686 # are using the C++ parsers.
   37687 
   37688 
   37689 
   37690 
   37691 
   37692 
   37693 
   37694 
   37695 
   37696 
   37697 
   37698 
   37699 cat >calc.y <<'_ATEOF'
   37700 %{
   37701 #ifdef HAVE_CONFIG_H
   37702 # include <config.h>
   37703   /* We don't need perfect functions for these tests. */
   37704 # undef malloc
   37705 # undef memcmp
   37706 # undef realloc
   37707 #endif
   37708 %}
   37709 
   37710 /* Infix notation calculator--calc */
   37711 %glr-parser %error-verbose %locations
   37712 
   37713 %{
   37714 #include <stdio.h>
   37715 
   37716 #include <stdlib.h>
   37717 #include <string.h>
   37718 #if HAVE_UNISTD_H
   37719 # include <unistd.h>
   37720 #else
   37721 # undef alarm
   37722 # define alarm(seconds) /* empty */
   37723 #endif
   37724 #include <ctype.h>
   37725 #define USE(Var)
   37726 
   37727 /* Exercise pre-prologue dependency to %union.  */
   37728 typedef int semantic_value;
   37729 
   37730 static semantic_value global_result = 0;
   37731 static int global_count = 0;
   37732 %}
   37733 
   37734 /* Exercise %union. */
   37735 %union
   37736 {
   37737   semantic_value ival;
   37738 };
   37739 
   37740 %{
   37741 static int power (int base, int exponent);
   37742 /* yyerror receives the location if:
   37743    - %location & %pure & %glr
   37744    - %location & %pure & %yacc & %parse-param. */
   37745 static void yyerror (
   37746 
   37747                      const char *s
   37748                      );
   37749 static int yylex (void);
   37750 static int get_char (void);
   37751 static void unget_char ( int c);
   37752 %}
   37753 
   37754 
   37755 
   37756 /* Bison Declarations */
   37757 %token CALC_EOF 0 "end of input"
   37758 %token <ival> NUM "number"
   37759 %type  <ival> exp
   37760 
   37761 %nonassoc '=' /* comparison	       */
   37762 %left '-' '+'
   37763 %left '*' '/'
   37764 %left NEG     /* negation--unary minus */
   37765 %right '^'    /* exponentiation        */
   37766 
   37767 /* Grammar follows */
   37768 %%
   37769 input:
   37770   line
   37771 | input line         {  }
   37772 ;
   37773 
   37774 line:
   37775   '\n'
   37776 | exp '\n'           { USE ($1); }
   37777 ;
   37778 
   37779 exp:
   37780   NUM                { $$ = $1;             }
   37781 | exp '=' exp
   37782   {
   37783     if ($1 != $3)
   37784       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   37785     $$ = $1;
   37786   }
   37787 | exp '+' exp        { $$ = $1 + $3;        }
   37788 | exp '-' exp        { $$ = $1 - $3;        }
   37789 | exp '*' exp        { $$ = $1 * $3;        }
   37790 | exp '/' exp        { $$ = $1 / $3;        }
   37791 | '-' exp  %prec NEG { $$ = -$2;            }
   37792 | exp '^' exp        { $$ = power ($1, $3); }
   37793 | '(' exp ')'        { $$ = $2;             }
   37794 | '(' error ')'      { $$ = 1111;           }
   37795 | '!'                { $$ = 0; YYERROR;     }
   37796 | '-' error          { $$ = 0; YYERROR;     }
   37797 ;
   37798 %%
   37799 /* The input.  */
   37800 static FILE *input;
   37801 
   37802 static void
   37803 yyerror (
   37804 
   37805          const char *s)
   37806 {
   37807 
   37808 
   37809   fprintf (stderr, "%d.%d",
   37810            (yylloc).first_line, (yylloc).first_column);
   37811   if ((yylloc).first_line != (yylloc).last_line)
   37812     fprintf (stderr, "-%d.%d",
   37813 	     (yylloc).last_line,  (yylloc).last_column - 1);
   37814   else if ((yylloc).first_column != (yylloc).last_column - 1)
   37815     fprintf (stderr, "-%d",
   37816 	     (yylloc).last_column - 1);
   37817   fprintf (stderr, ": ");
   37818   fprintf (stderr, "%s\n", s);
   37819 }
   37820 
   37821 
   37822 
   37823 static YYLTYPE last_yylloc;
   37824 
   37825 static int
   37826 get_char (void)
   37827 {
   37828   int res = getc (input);
   37829   ;
   37830 
   37831   last_yylloc = (yylloc);
   37832   if (res == '\n')
   37833     {
   37834       (yylloc).last_line++;
   37835       (yylloc).last_column = 0;
   37836     }
   37837   else
   37838     (yylloc).last_column++;
   37839 
   37840   return res;
   37841 }
   37842 
   37843 
   37844 static void
   37845 unget_char ( int c)
   37846 {
   37847   ;
   37848 
   37849   /* Wrong when C == `\n'. */
   37850   (yylloc) = last_yylloc;
   37851 
   37852   ungetc (c, input);
   37853 }
   37854 
   37855 static int
   37856 read_signed_integer (void)
   37857 {
   37858   int c = get_char ();
   37859   int sign = 1;
   37860   int n = 0;
   37861 
   37862   ;
   37863   if (c == '-')
   37864     {
   37865       c = get_char ();
   37866       sign = -1;
   37867     }
   37868 
   37869   while (isdigit (c))
   37870     {
   37871       n = 10 * n + (c - '0');
   37872       c = get_char ();
   37873     }
   37874 
   37875   unget_char ( c);
   37876 
   37877   return sign * n;
   37878 }
   37879 
   37880 
   37881 
   37882 /*---------------------------------------------------------------.
   37883 | Lexical analyzer returns an integer on the stack and the token |
   37884 | NUM, or the ASCII character read if not a number.  Skips all   |
   37885 | blanks and tabs, returns 0 for EOF.                            |
   37886 `---------------------------------------------------------------*/
   37887 
   37888 static int
   37889 yylex (void)
   37890 {
   37891   static int init = 1;
   37892   int c;
   37893 
   37894   if (init)
   37895     {
   37896       init = 0;
   37897 
   37898       (yylloc).last_column = 0;
   37899       (yylloc).last_line = 1;
   37900 
   37901     }
   37902 
   37903 
   37904  (yylloc).first_column = (yylloc).last_column;
   37905   (yylloc).first_line   = (yylloc).last_line;
   37906 
   37907 
   37908   /* Skip white space.  */
   37909   while ((c = get_char ()) == ' ' || c == '\t')
   37910     {
   37911      (yylloc).first_column = (yylloc).last_column;
   37912       (yylloc).first_line   = (yylloc).last_line;
   37913 
   37914     }
   37915 
   37916   /* process numbers   */
   37917   if (c == '.' || isdigit (c))
   37918     {
   37919       unget_char ( c);
   37920       (yylval).ival = read_signed_integer ();
   37921       return NUM;
   37922     }
   37923 
   37924   /* Return end-of-file.  */
   37925   if (c == EOF)
   37926     return CALC_EOF;
   37927 
   37928   /* Return single chars. */
   37929   return c;
   37930 }
   37931 
   37932 static int
   37933 power (int base, int exponent)
   37934 {
   37935   int res = 1;
   37936   if (exponent < 0)
   37937     exit (3);
   37938   for (/* Niente */; exponent; --exponent)
   37939     res *= base;
   37940   return res;
   37941 }
   37942 
   37943 
   37944 int
   37945 main (int argc, const char **argv)
   37946 {
   37947   semantic_value result = 0;
   37948   int count = 0;
   37949   int status;
   37950 
   37951   /* This used to be alarm (10), but that isn't enough time for
   37952      a July 1995 vintage DEC Alphastation 200 4/100 system,
   37953      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   37954   alarm (100);
   37955 
   37956   if (argc == 2)
   37957     input = fopen (argv[1], "r");
   37958   else
   37959     input = stdin;
   37960 
   37961   if (!input)
   37962     {
   37963       perror (argv[1]);
   37964       return 3;
   37965     }
   37966 
   37967 
   37968   status = yyparse ();
   37969   if (global_result != result)
   37970     abort ();
   37971   if (global_count != count)
   37972     abort ();
   37973   return status;
   37974 }
   37975 _ATEOF
   37976 
   37977 
   37978 
   37979 
   37980 
   37981 $at_traceoff
   37982 echo "calc.at:596: bison -o calc.c calc.y"
   37983 echo calc.at:596 >$at_check_line_file
   37984 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   37985 at_status=$?
   37986 grep '^ *+' $at_stder1 >&2
   37987 grep -v '^ *+' $at_stder1 >$at_stderr
   37988 at_failed=false
   37989 $at_diff $at_devnull $at_stderr || at_failed=:
   37990 $at_diff $at_devnull $at_stdout || at_failed=:
   37991 case $at_status in
   37992    77) echo 77 > $at_status_file
   37993             exit 77;;
   37994    0) ;;
   37995    *) echo "calc.at:596: exit code was $at_status, expected 0"
   37996       at_failed=:;;
   37997 esac
   37998 if $at_failed; then
   37999 
   38000   echo 1 > $at_status_file
   38001   exit 1
   38002 fi
   38003 
   38004 $at_traceon
   38005 
   38006    $at_traceoff
   38007 echo "calc.at:596: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   38008 echo calc.at:596 >$at_check_line_file
   38009 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   38010 at_status=$?
   38011 grep '^ *+' $at_stder1 >&2
   38012 grep -v '^ *+' $at_stder1 >$at_stderr
   38013 at_failed=false
   38014 echo stderr:; cat $at_stderr
   38015 echo stdout:; cat $at_stdout
   38016 case $at_status in
   38017    77) echo 77 > $at_status_file
   38018             exit 77;;
   38019    0) ;;
   38020    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38021       at_failed=:;;
   38022 esac
   38023 if $at_failed; then
   38024 
   38025   echo 1 > $at_status_file
   38026   exit 1
   38027 fi
   38028 
   38029 $at_traceon
   38030 
   38031 
   38032 # Test the priorities.
   38033 cat >input <<'_ATEOF'
   38034 1 + 2 * 3 = 7
   38035 1 + 2 * -3 = -5
   38036 
   38037 -1^2 = -1
   38038 (-1)^2 = 1
   38039 
   38040 ---1 = -1
   38041 
   38042 1 - 2 - 3 = -4
   38043 1 - (2 - 3) = 2
   38044 
   38045 2^2^3 = 256
   38046 (2^2)^3 = 64
   38047 _ATEOF
   38048 
   38049 $at_traceoff
   38050 echo "calc.at:596: \$PREPARSER ./calc input"
   38051 echo calc.at:596 >$at_check_line_file
   38052 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   38053 at_status=$?
   38054 grep '^ *+' $at_stder1 >&2
   38055 grep -v '^ *+' $at_stder1 >$at_stderr
   38056 at_failed=false
   38057 echo stderr:; tee stderr <$at_stderr
   38058 $at_diff $at_devnull $at_stdout || at_failed=:
   38059 case $at_status in
   38060    77) echo 77 > $at_status_file
   38061             exit 77;;
   38062    0) ;;
   38063    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38064       at_failed=:;;
   38065 esac
   38066 if $at_failed; then
   38067 
   38068   echo 1 > $at_status_file
   38069   exit 1
   38070 fi
   38071 
   38072 $at_traceon
   38073 
   38074 
   38075 
   38076 # Some syntax errors.
   38077 cat >input <<'_ATEOF'
   38078 0 0
   38079 _ATEOF
   38080 
   38081 $at_traceoff
   38082 echo "calc.at:596: \$PREPARSER ./calc input"
   38083 echo calc.at:596 >$at_check_line_file
   38084 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   38085 at_status=$?
   38086 grep '^ *+' $at_stder1 >&2
   38087 grep -v '^ *+' $at_stder1 >$at_stderr
   38088 at_failed=false
   38089 echo stderr:; tee stderr <$at_stderr
   38090 $at_diff $at_devnull $at_stdout || at_failed=:
   38091 case $at_status in
   38092    77) echo 77 > $at_status_file
   38093             exit 77;;
   38094    1) ;;
   38095    *) echo "calc.at:596: exit code was $at_status, expected 1"
   38096       at_failed=:;;
   38097 esac
   38098 if $at_failed; then
   38099 
   38100   echo 1 > $at_status_file
   38101   exit 1
   38102 fi
   38103 
   38104 $at_traceon
   38105 
   38106 
   38107 # Normalize the observed and expected error messages, depending upon the
   38108 # options.
   38109 # 1. Remove the traces from observed.
   38110 sed '/^Starting/d
   38111 /^Entering/d
   38112 /^Stack/d
   38113 /^Reading/d
   38114 /^Reducing/d
   38115 /^Shifting/d
   38116 /^state/d
   38117 /^Cleanup:/d
   38118 /^Error:/d
   38119 /^Next/d
   38120 /^Discarding/d
   38121 / \$[0-9$]* = /d
   38122 /^yydestructor:/d' stderr >at-stderr
   38123 mv at-stderr stderr
   38124 # 2. Create the reference error message.
   38125 cat >expout <<'_ATEOF'
   38126 1.2: syntax error, unexpected number
   38127 _ATEOF
   38128 
   38129 # 3. If locations are not used, remove them.
   38130 
   38131 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   38132 
   38133 # 5. Check
   38134 $at_traceoff
   38135 echo "calc.at:596: cat stderr"
   38136 echo calc.at:596 >$at_check_line_file
   38137 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   38138 at_status=$?
   38139 grep '^ *+' $at_stder1 >&2
   38140 grep -v '^ *+' $at_stder1 >$at_stderr
   38141 at_failed=false
   38142 $at_diff $at_devnull $at_stderr || at_failed=:
   38143 $at_diff expout $at_stdout || at_failed=:
   38144 case $at_status in
   38145    77) echo 77 > $at_status_file
   38146             exit 77;;
   38147    0) ;;
   38148    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38149       at_failed=:;;
   38150 esac
   38151 if $at_failed; then
   38152 
   38153   echo 1 > $at_status_file
   38154   exit 1
   38155 fi
   38156 
   38157 $at_traceon
   38158 
   38159 
   38160 cat >input <<'_ATEOF'
   38161 1//2
   38162 _ATEOF
   38163 
   38164 $at_traceoff
   38165 echo "calc.at:596: \$PREPARSER ./calc input"
   38166 echo calc.at:596 >$at_check_line_file
   38167 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   38168 at_status=$?
   38169 grep '^ *+' $at_stder1 >&2
   38170 grep -v '^ *+' $at_stder1 >$at_stderr
   38171 at_failed=false
   38172 echo stderr:; tee stderr <$at_stderr
   38173 $at_diff $at_devnull $at_stdout || at_failed=:
   38174 case $at_status in
   38175    77) echo 77 > $at_status_file
   38176             exit 77;;
   38177    1) ;;
   38178    *) echo "calc.at:596: exit code was $at_status, expected 1"
   38179       at_failed=:;;
   38180 esac
   38181 if $at_failed; then
   38182 
   38183   echo 1 > $at_status_file
   38184   exit 1
   38185 fi
   38186 
   38187 $at_traceon
   38188 
   38189 
   38190 # Normalize the observed and expected error messages, depending upon the
   38191 # options.
   38192 # 1. Remove the traces from observed.
   38193 sed '/^Starting/d
   38194 /^Entering/d
   38195 /^Stack/d
   38196 /^Reading/d
   38197 /^Reducing/d
   38198 /^Shifting/d
   38199 /^state/d
   38200 /^Cleanup:/d
   38201 /^Error:/d
   38202 /^Next/d
   38203 /^Discarding/d
   38204 / \$[0-9$]* = /d
   38205 /^yydestructor:/d' stderr >at-stderr
   38206 mv at-stderr stderr
   38207 # 2. Create the reference error message.
   38208 cat >expout <<'_ATEOF'
   38209 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   38210 _ATEOF
   38211 
   38212 # 3. If locations are not used, remove them.
   38213 
   38214 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   38215 
   38216 # 5. Check
   38217 $at_traceoff
   38218 echo "calc.at:596: cat stderr"
   38219 echo calc.at:596 >$at_check_line_file
   38220 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   38221 at_status=$?
   38222 grep '^ *+' $at_stder1 >&2
   38223 grep -v '^ *+' $at_stder1 >$at_stderr
   38224 at_failed=false
   38225 $at_diff $at_devnull $at_stderr || at_failed=:
   38226 $at_diff expout $at_stdout || at_failed=:
   38227 case $at_status in
   38228    77) echo 77 > $at_status_file
   38229             exit 77;;
   38230    0) ;;
   38231    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38232       at_failed=:;;
   38233 esac
   38234 if $at_failed; then
   38235 
   38236   echo 1 > $at_status_file
   38237   exit 1
   38238 fi
   38239 
   38240 $at_traceon
   38241 
   38242 
   38243 cat >input <<'_ATEOF'
   38244 error
   38245 _ATEOF
   38246 
   38247 $at_traceoff
   38248 echo "calc.at:596: \$PREPARSER ./calc input"
   38249 echo calc.at:596 >$at_check_line_file
   38250 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   38251 at_status=$?
   38252 grep '^ *+' $at_stder1 >&2
   38253 grep -v '^ *+' $at_stder1 >$at_stderr
   38254 at_failed=false
   38255 echo stderr:; tee stderr <$at_stderr
   38256 $at_diff $at_devnull $at_stdout || at_failed=:
   38257 case $at_status in
   38258    77) echo 77 > $at_status_file
   38259             exit 77;;
   38260    1) ;;
   38261    *) echo "calc.at:596: exit code was $at_status, expected 1"
   38262       at_failed=:;;
   38263 esac
   38264 if $at_failed; then
   38265 
   38266   echo 1 > $at_status_file
   38267   exit 1
   38268 fi
   38269 
   38270 $at_traceon
   38271 
   38272 
   38273 # Normalize the observed and expected error messages, depending upon the
   38274 # options.
   38275 # 1. Remove the traces from observed.
   38276 sed '/^Starting/d
   38277 /^Entering/d
   38278 /^Stack/d
   38279 /^Reading/d
   38280 /^Reducing/d
   38281 /^Shifting/d
   38282 /^state/d
   38283 /^Cleanup:/d
   38284 /^Error:/d
   38285 /^Next/d
   38286 /^Discarding/d
   38287 / \$[0-9$]* = /d
   38288 /^yydestructor:/d' stderr >at-stderr
   38289 mv at-stderr stderr
   38290 # 2. Create the reference error message.
   38291 cat >expout <<'_ATEOF'
   38292 1.0: syntax error, unexpected $undefined
   38293 _ATEOF
   38294 
   38295 # 3. If locations are not used, remove them.
   38296 
   38297 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   38298 
   38299 # 5. Check
   38300 $at_traceoff
   38301 echo "calc.at:596: cat stderr"
   38302 echo calc.at:596 >$at_check_line_file
   38303 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   38304 at_status=$?
   38305 grep '^ *+' $at_stder1 >&2
   38306 grep -v '^ *+' $at_stder1 >$at_stderr
   38307 at_failed=false
   38308 $at_diff $at_devnull $at_stderr || at_failed=:
   38309 $at_diff expout $at_stdout || at_failed=:
   38310 case $at_status in
   38311    77) echo 77 > $at_status_file
   38312             exit 77;;
   38313    0) ;;
   38314    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38315       at_failed=:;;
   38316 esac
   38317 if $at_failed; then
   38318 
   38319   echo 1 > $at_status_file
   38320   exit 1
   38321 fi
   38322 
   38323 $at_traceon
   38324 
   38325 
   38326 cat >input <<'_ATEOF'
   38327 1 = 2 = 3
   38328 _ATEOF
   38329 
   38330 $at_traceoff
   38331 echo "calc.at:596: \$PREPARSER ./calc input"
   38332 echo calc.at:596 >$at_check_line_file
   38333 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   38334 at_status=$?
   38335 grep '^ *+' $at_stder1 >&2
   38336 grep -v '^ *+' $at_stder1 >$at_stderr
   38337 at_failed=false
   38338 echo stderr:; tee stderr <$at_stderr
   38339 $at_diff $at_devnull $at_stdout || at_failed=:
   38340 case $at_status in
   38341    77) echo 77 > $at_status_file
   38342             exit 77;;
   38343    1) ;;
   38344    *) echo "calc.at:596: exit code was $at_status, expected 1"
   38345       at_failed=:;;
   38346 esac
   38347 if $at_failed; then
   38348 
   38349   echo 1 > $at_status_file
   38350   exit 1
   38351 fi
   38352 
   38353 $at_traceon
   38354 
   38355 
   38356 # Normalize the observed and expected error messages, depending upon the
   38357 # options.
   38358 # 1. Remove the traces from observed.
   38359 sed '/^Starting/d
   38360 /^Entering/d
   38361 /^Stack/d
   38362 /^Reading/d
   38363 /^Reducing/d
   38364 /^Shifting/d
   38365 /^state/d
   38366 /^Cleanup:/d
   38367 /^Error:/d
   38368 /^Next/d
   38369 /^Discarding/d
   38370 / \$[0-9$]* = /d
   38371 /^yydestructor:/d' stderr >at-stderr
   38372 mv at-stderr stderr
   38373 # 2. Create the reference error message.
   38374 cat >expout <<'_ATEOF'
   38375 1.6: syntax error, unexpected '='
   38376 _ATEOF
   38377 
   38378 # 3. If locations are not used, remove them.
   38379 
   38380 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   38381 
   38382 # 5. Check
   38383 $at_traceoff
   38384 echo "calc.at:596: cat stderr"
   38385 echo calc.at:596 >$at_check_line_file
   38386 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   38387 at_status=$?
   38388 grep '^ *+' $at_stder1 >&2
   38389 grep -v '^ *+' $at_stder1 >$at_stderr
   38390 at_failed=false
   38391 $at_diff $at_devnull $at_stderr || at_failed=:
   38392 $at_diff expout $at_stdout || at_failed=:
   38393 case $at_status in
   38394    77) echo 77 > $at_status_file
   38395             exit 77;;
   38396    0) ;;
   38397    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38398       at_failed=:;;
   38399 esac
   38400 if $at_failed; then
   38401 
   38402   echo 1 > $at_status_file
   38403   exit 1
   38404 fi
   38405 
   38406 $at_traceon
   38407 
   38408 
   38409 cat >input <<'_ATEOF'
   38410 
   38411 +1
   38412 _ATEOF
   38413 
   38414 $at_traceoff
   38415 echo "calc.at:596: \$PREPARSER ./calc input"
   38416 echo calc.at:596 >$at_check_line_file
   38417 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   38418 at_status=$?
   38419 grep '^ *+' $at_stder1 >&2
   38420 grep -v '^ *+' $at_stder1 >$at_stderr
   38421 at_failed=false
   38422 echo stderr:; tee stderr <$at_stderr
   38423 $at_diff $at_devnull $at_stdout || at_failed=:
   38424 case $at_status in
   38425    77) echo 77 > $at_status_file
   38426             exit 77;;
   38427    1) ;;
   38428    *) echo "calc.at:596: exit code was $at_status, expected 1"
   38429       at_failed=:;;
   38430 esac
   38431 if $at_failed; then
   38432 
   38433   echo 1 > $at_status_file
   38434   exit 1
   38435 fi
   38436 
   38437 $at_traceon
   38438 
   38439 
   38440 # Normalize the observed and expected error messages, depending upon the
   38441 # options.
   38442 # 1. Remove the traces from observed.
   38443 sed '/^Starting/d
   38444 /^Entering/d
   38445 /^Stack/d
   38446 /^Reading/d
   38447 /^Reducing/d
   38448 /^Shifting/d
   38449 /^state/d
   38450 /^Cleanup:/d
   38451 /^Error:/d
   38452 /^Next/d
   38453 /^Discarding/d
   38454 / \$[0-9$]* = /d
   38455 /^yydestructor:/d' stderr >at-stderr
   38456 mv at-stderr stderr
   38457 # 2. Create the reference error message.
   38458 cat >expout <<'_ATEOF'
   38459 2.0: syntax error, unexpected '+'
   38460 _ATEOF
   38461 
   38462 # 3. If locations are not used, remove them.
   38463 
   38464 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   38465 
   38466 # 5. Check
   38467 $at_traceoff
   38468 echo "calc.at:596: cat stderr"
   38469 echo calc.at:596 >$at_check_line_file
   38470 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   38471 at_status=$?
   38472 grep '^ *+' $at_stder1 >&2
   38473 grep -v '^ *+' $at_stder1 >$at_stderr
   38474 at_failed=false
   38475 $at_diff $at_devnull $at_stderr || at_failed=:
   38476 $at_diff expout $at_stdout || at_failed=:
   38477 case $at_status in
   38478    77) echo 77 > $at_status_file
   38479             exit 77;;
   38480    0) ;;
   38481    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38482       at_failed=:;;
   38483 esac
   38484 if $at_failed; then
   38485 
   38486   echo 1 > $at_status_file
   38487   exit 1
   38488 fi
   38489 
   38490 $at_traceon
   38491 
   38492 
   38493 # Exercise error messages with EOF: work on an empty file.
   38494 $at_traceoff
   38495 echo "calc.at:596: \$PREPARSER ./calc /dev/null"
   38496 echo calc.at:596 >$at_check_line_file
   38497 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   38498 at_status=$?
   38499 grep '^ *+' $at_stder1 >&2
   38500 grep -v '^ *+' $at_stder1 >$at_stderr
   38501 at_failed=false
   38502 echo stderr:; tee stderr <$at_stderr
   38503 $at_diff $at_devnull $at_stdout || at_failed=:
   38504 case $at_status in
   38505    77) echo 77 > $at_status_file
   38506             exit 77;;
   38507    1) ;;
   38508    *) echo "calc.at:596: exit code was $at_status, expected 1"
   38509       at_failed=:;;
   38510 esac
   38511 if $at_failed; then
   38512 
   38513   echo 1 > $at_status_file
   38514   exit 1
   38515 fi
   38516 
   38517 $at_traceon
   38518 
   38519 
   38520 # Normalize the observed and expected error messages, depending upon the
   38521 # options.
   38522 # 1. Remove the traces from observed.
   38523 sed '/^Starting/d
   38524 /^Entering/d
   38525 /^Stack/d
   38526 /^Reading/d
   38527 /^Reducing/d
   38528 /^Shifting/d
   38529 /^state/d
   38530 /^Cleanup:/d
   38531 /^Error:/d
   38532 /^Next/d
   38533 /^Discarding/d
   38534 / \$[0-9$]* = /d
   38535 /^yydestructor:/d' stderr >at-stderr
   38536 mv at-stderr stderr
   38537 # 2. Create the reference error message.
   38538 cat >expout <<'_ATEOF'
   38539 1.0: syntax error, unexpected end of input
   38540 _ATEOF
   38541 
   38542 # 3. If locations are not used, remove them.
   38543 
   38544 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   38545 
   38546 # 5. Check
   38547 $at_traceoff
   38548 echo "calc.at:596: cat stderr"
   38549 echo calc.at:596 >$at_check_line_file
   38550 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   38551 at_status=$?
   38552 grep '^ *+' $at_stder1 >&2
   38553 grep -v '^ *+' $at_stder1 >$at_stderr
   38554 at_failed=false
   38555 $at_diff $at_devnull $at_stderr || at_failed=:
   38556 $at_diff expout $at_stdout || at_failed=:
   38557 case $at_status in
   38558    77) echo 77 > $at_status_file
   38559             exit 77;;
   38560    0) ;;
   38561    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38562       at_failed=:;;
   38563 esac
   38564 if $at_failed; then
   38565 
   38566   echo 1 > $at_status_file
   38567   exit 1
   38568 fi
   38569 
   38570 $at_traceon
   38571 
   38572 
   38573 
   38574 # Exercise the error token: without it, we die at the first error,
   38575 # hence be sure to
   38576 #
   38577 # - have several errors which exercise different shift/discardings
   38578 #   - (): nothing to pop, nothing to discard
   38579 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   38580 #   - (* * *): nothing to pop, a lot to discard
   38581 #   - (1 + 2 * *): some to pop and discard
   38582 #
   38583 # - test the action associated to `error'
   38584 #
   38585 # - check the look-ahead that triggers an error is not discarded
   38586 #   when we enter error recovery.  Below, the look-ahead causing the
   38587 #   first error is ")", which is needed to recover from the error and
   38588 #   produce the "0" that triggers the "0 != 1" error.
   38589 #
   38590 cat >input <<'_ATEOF'
   38591 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   38592 _ATEOF
   38593 
   38594 $at_traceoff
   38595 echo "calc.at:596: \$PREPARSER ./calc input"
   38596 echo calc.at:596 >$at_check_line_file
   38597 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   38598 at_status=$?
   38599 grep '^ *+' $at_stder1 >&2
   38600 grep -v '^ *+' $at_stder1 >$at_stderr
   38601 at_failed=false
   38602 echo stderr:; tee stderr <$at_stderr
   38603 $at_diff $at_devnull $at_stdout || at_failed=:
   38604 case $at_status in
   38605    77) echo 77 > $at_status_file
   38606             exit 77;;
   38607    0) ;;
   38608    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38609       at_failed=:;;
   38610 esac
   38611 if $at_failed; then
   38612 
   38613   echo 1 > $at_status_file
   38614   exit 1
   38615 fi
   38616 
   38617 $at_traceon
   38618 
   38619 
   38620 # Normalize the observed and expected error messages, depending upon the
   38621 # options.
   38622 # 1. Remove the traces from observed.
   38623 sed '/^Starting/d
   38624 /^Entering/d
   38625 /^Stack/d
   38626 /^Reading/d
   38627 /^Reducing/d
   38628 /^Shifting/d
   38629 /^state/d
   38630 /^Cleanup:/d
   38631 /^Error:/d
   38632 /^Next/d
   38633 /^Discarding/d
   38634 / \$[0-9$]* = /d
   38635 /^yydestructor:/d' stderr >at-stderr
   38636 mv at-stderr stderr
   38637 # 2. Create the reference error message.
   38638 cat >expout <<'_ATEOF'
   38639 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   38640 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   38641 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   38642 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   38643 calc: error: 4444 != 1
   38644 _ATEOF
   38645 
   38646 # 3. If locations are not used, remove them.
   38647 
   38648 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   38649 
   38650 # 5. Check
   38651 $at_traceoff
   38652 echo "calc.at:596: cat stderr"
   38653 echo calc.at:596 >$at_check_line_file
   38654 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   38655 at_status=$?
   38656 grep '^ *+' $at_stder1 >&2
   38657 grep -v '^ *+' $at_stder1 >$at_stderr
   38658 at_failed=false
   38659 $at_diff $at_devnull $at_stderr || at_failed=:
   38660 $at_diff expout $at_stdout || at_failed=:
   38661 case $at_status in
   38662    77) echo 77 > $at_status_file
   38663             exit 77;;
   38664    0) ;;
   38665    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38666       at_failed=:;;
   38667 esac
   38668 if $at_failed; then
   38669 
   38670   echo 1 > $at_status_file
   38671   exit 1
   38672 fi
   38673 
   38674 $at_traceon
   38675 
   38676 
   38677 
   38678 # The same, but this time exercising explicitly triggered syntax errors.
   38679 # POSIX says the look-ahead causing the error should not be discarded.
   38680 cat >input <<'_ATEOF'
   38681 (!) + (0 0) = 1
   38682 _ATEOF
   38683 
   38684 $at_traceoff
   38685 echo "calc.at:596: \$PREPARSER ./calc input"
   38686 echo calc.at:596 >$at_check_line_file
   38687 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   38688 at_status=$?
   38689 grep '^ *+' $at_stder1 >&2
   38690 grep -v '^ *+' $at_stder1 >$at_stderr
   38691 at_failed=false
   38692 echo stderr:; tee stderr <$at_stderr
   38693 $at_diff $at_devnull $at_stdout || at_failed=:
   38694 case $at_status in
   38695    77) echo 77 > $at_status_file
   38696             exit 77;;
   38697    0) ;;
   38698    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38699       at_failed=:;;
   38700 esac
   38701 if $at_failed; then
   38702 
   38703   echo 1 > $at_status_file
   38704   exit 1
   38705 fi
   38706 
   38707 $at_traceon
   38708 
   38709 
   38710 # Normalize the observed and expected error messages, depending upon the
   38711 # options.
   38712 # 1. Remove the traces from observed.
   38713 sed '/^Starting/d
   38714 /^Entering/d
   38715 /^Stack/d
   38716 /^Reading/d
   38717 /^Reducing/d
   38718 /^Shifting/d
   38719 /^state/d
   38720 /^Cleanup:/d
   38721 /^Error:/d
   38722 /^Next/d
   38723 /^Discarding/d
   38724 / \$[0-9$]* = /d
   38725 /^yydestructor:/d' stderr >at-stderr
   38726 mv at-stderr stderr
   38727 # 2. Create the reference error message.
   38728 cat >expout <<'_ATEOF'
   38729 1.9: syntax error, unexpected number
   38730 calc: error: 2222 != 1
   38731 _ATEOF
   38732 
   38733 # 3. If locations are not used, remove them.
   38734 
   38735 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   38736 
   38737 # 5. Check
   38738 $at_traceoff
   38739 echo "calc.at:596: cat stderr"
   38740 echo calc.at:596 >$at_check_line_file
   38741 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   38742 at_status=$?
   38743 grep '^ *+' $at_stder1 >&2
   38744 grep -v '^ *+' $at_stder1 >$at_stderr
   38745 at_failed=false
   38746 $at_diff $at_devnull $at_stderr || at_failed=:
   38747 $at_diff expout $at_stdout || at_failed=:
   38748 case $at_status in
   38749    77) echo 77 > $at_status_file
   38750             exit 77;;
   38751    0) ;;
   38752    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38753       at_failed=:;;
   38754 esac
   38755 if $at_failed; then
   38756 
   38757   echo 1 > $at_status_file
   38758   exit 1
   38759 fi
   38760 
   38761 $at_traceon
   38762 
   38763 
   38764 cat >input <<'_ATEOF'
   38765 (- *) + (0 0) = 1
   38766 _ATEOF
   38767 
   38768 $at_traceoff
   38769 echo "calc.at:596: \$PREPARSER ./calc input"
   38770 echo calc.at:596 >$at_check_line_file
   38771 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   38772 at_status=$?
   38773 grep '^ *+' $at_stder1 >&2
   38774 grep -v '^ *+' $at_stder1 >$at_stderr
   38775 at_failed=false
   38776 echo stderr:; tee stderr <$at_stderr
   38777 $at_diff $at_devnull $at_stdout || at_failed=:
   38778 case $at_status in
   38779    77) echo 77 > $at_status_file
   38780             exit 77;;
   38781    0) ;;
   38782    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38783       at_failed=:;;
   38784 esac
   38785 if $at_failed; then
   38786 
   38787   echo 1 > $at_status_file
   38788   exit 1
   38789 fi
   38790 
   38791 $at_traceon
   38792 
   38793 
   38794 # Normalize the observed and expected error messages, depending upon the
   38795 # options.
   38796 # 1. Remove the traces from observed.
   38797 sed '/^Starting/d
   38798 /^Entering/d
   38799 /^Stack/d
   38800 /^Reading/d
   38801 /^Reducing/d
   38802 /^Shifting/d
   38803 /^state/d
   38804 /^Cleanup:/d
   38805 /^Error:/d
   38806 /^Next/d
   38807 /^Discarding/d
   38808 / \$[0-9$]* = /d
   38809 /^yydestructor:/d' stderr >at-stderr
   38810 mv at-stderr stderr
   38811 # 2. Create the reference error message.
   38812 cat >expout <<'_ATEOF'
   38813 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   38814 1.11: syntax error, unexpected number
   38815 calc: error: 2222 != 1
   38816 _ATEOF
   38817 
   38818 # 3. If locations are not used, remove them.
   38819 
   38820 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   38821 
   38822 # 5. Check
   38823 $at_traceoff
   38824 echo "calc.at:596: cat stderr"
   38825 echo calc.at:596 >$at_check_line_file
   38826 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   38827 at_status=$?
   38828 grep '^ *+' $at_stder1 >&2
   38829 grep -v '^ *+' $at_stder1 >$at_stderr
   38830 at_failed=false
   38831 $at_diff $at_devnull $at_stderr || at_failed=:
   38832 $at_diff expout $at_stdout || at_failed=:
   38833 case $at_status in
   38834    77) echo 77 > $at_status_file
   38835             exit 77;;
   38836    0) ;;
   38837    *) echo "calc.at:596: exit code was $at_status, expected 0"
   38838       at_failed=:;;
   38839 esac
   38840 if $at_failed; then
   38841 
   38842   echo 1 > $at_status_file
   38843   exit 1
   38844 fi
   38845 
   38846 $at_traceon
   38847 
   38848 
   38849 
   38850 
   38851 
   38852 
   38853 
   38854 
   38855 
   38856 
   38857 
   38858 
   38859 
   38860 
   38861 
   38862 
   38863 
   38864 
   38865 
   38866 
   38867 
   38868 
   38869 
   38870 
   38871       $at_traceoff
   38872       $at_times_p && times >$at_times_file
   38873     ) 5>&1 2>&1 | eval $at_tee_pipe
   38874     at_status=`cat $at_status_file`
   38875     ;;
   38876 
   38877   93 ) # 93. calc.at:598: Calculator %glr-parser %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc
   38878     at_setup_line='calc.at:598'
   38879     at_desc='Calculator %glr-parser %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc'
   38880     $at_quiet $ECHO_N " 93: Calculator %glr-parser %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc$ECHO_C"
   38881     at_xfail=no
   38882     (
   38883       echo "93. calc.at:598: testing ..."
   38884       $at_traceon
   38885 
   38886 
   38887 
   38888 
   38889 
   38890 
   38891 
   38892 
   38893 # Using yacc.c?
   38894 
   38895 
   38896 
   38897 
   38898 
   38899 
   38900 
   38901 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   38902 
   38903 # yyerror always sees the locations (when activated), except if
   38904 # yacc & pure & !param.
   38905 
   38906 
   38907 # The interface is pure: either because %pure-parser, or because we
   38908 # are using the C++ parsers.
   38909 
   38910 
   38911 
   38912 
   38913 
   38914 
   38915 
   38916 
   38917 
   38918 
   38919 
   38920 
   38921 cat >calc.y <<'_ATEOF'
   38922 %{
   38923 #ifdef HAVE_CONFIG_H
   38924 # include <config.h>
   38925   /* We don't need perfect functions for these tests. */
   38926 # undef malloc
   38927 # undef memcmp
   38928 # undef realloc
   38929 #endif
   38930 %}
   38931 
   38932 /* Infix notation calculator--calc */
   38933 %glr-parser %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc
   38934 
   38935 %{
   38936 #include <stdio.h>
   38937 
   38938 #include <stdlib.h>
   38939 #include <string.h>
   38940 #if HAVE_UNISTD_H
   38941 # include <unistd.h>
   38942 #else
   38943 # undef alarm
   38944 # define alarm(seconds) /* empty */
   38945 #endif
   38946 #include <ctype.h>
   38947 #define USE(Var)
   38948 
   38949 /* Exercise pre-prologue dependency to %union.  */
   38950 typedef int semantic_value;
   38951 
   38952 static semantic_value global_result = 0;
   38953 static int global_count = 0;
   38954 %}
   38955 
   38956 /* Exercise %union. */
   38957 %union
   38958 {
   38959   semantic_value ival;
   38960 };
   38961 
   38962 %{
   38963 static int power (int base, int exponent);
   38964 /* yyerror receives the location if:
   38965    - %location & %pure & %glr
   38966    - %location & %pure & %yacc & %parse-param. */
   38967 static void yyerror (
   38968 
   38969                      const char *s
   38970                      );
   38971 static int yylex (void);
   38972 static int get_char (void);
   38973 static void unget_char ( int c);
   38974 %}
   38975 
   38976 
   38977 
   38978 /* Bison Declarations */
   38979 %token CALC_EOF 0 "end of input"
   38980 %token <ival> NUM "number"
   38981 %type  <ival> exp
   38982 
   38983 %nonassoc '=' /* comparison	       */
   38984 %left '-' '+'
   38985 %left '*' '/'
   38986 %left NEG     /* negation--unary minus */
   38987 %right '^'    /* exponentiation        */
   38988 
   38989 /* Grammar follows */
   38990 %%
   38991 input:
   38992   line
   38993 | input line         {  }
   38994 ;
   38995 
   38996 line:
   38997   '\n'
   38998 | exp '\n'           { USE ($1); }
   38999 ;
   39000 
   39001 exp:
   39002   NUM                { $$ = $1;             }
   39003 | exp '=' exp
   39004   {
   39005     if ($1 != $3)
   39006       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   39007     $$ = $1;
   39008   }
   39009 | exp '+' exp        { $$ = $1 + $3;        }
   39010 | exp '-' exp        { $$ = $1 - $3;        }
   39011 | exp '*' exp        { $$ = $1 * $3;        }
   39012 | exp '/' exp        { $$ = $1 / $3;        }
   39013 | '-' exp  %prec NEG { $$ = -$2;            }
   39014 | exp '^' exp        { $$ = power ($1, $3); }
   39015 | '(' exp ')'        { $$ = $2;             }
   39016 | '(' error ')'      { $$ = 1111;           }
   39017 | '!'                { $$ = 0; YYERROR;     }
   39018 | '-' error          { $$ = 0; YYERROR;     }
   39019 ;
   39020 %%
   39021 /* The input.  */
   39022 static FILE *input;
   39023 
   39024 static void
   39025 yyerror (
   39026 
   39027          const char *s)
   39028 {
   39029 
   39030 
   39031   fprintf (stderr, "%d.%d",
   39032            (yylloc).first_line, (yylloc).first_column);
   39033   if ((yylloc).first_line != (yylloc).last_line)
   39034     fprintf (stderr, "-%d.%d",
   39035 	     (yylloc).last_line,  (yylloc).last_column - 1);
   39036   else if ((yylloc).first_column != (yylloc).last_column - 1)
   39037     fprintf (stderr, "-%d",
   39038 	     (yylloc).last_column - 1);
   39039   fprintf (stderr, ": ");
   39040   fprintf (stderr, "%s\n", s);
   39041 }
   39042 
   39043 
   39044 
   39045 static YYLTYPE last_yylloc;
   39046 
   39047 static int
   39048 get_char (void)
   39049 {
   39050   int res = getc (input);
   39051   ;
   39052 
   39053   last_yylloc = (yylloc);
   39054   if (res == '\n')
   39055     {
   39056       (yylloc).last_line++;
   39057       (yylloc).last_column = 0;
   39058     }
   39059   else
   39060     (yylloc).last_column++;
   39061 
   39062   return res;
   39063 }
   39064 
   39065 
   39066 static void
   39067 unget_char ( int c)
   39068 {
   39069   ;
   39070 
   39071   /* Wrong when C == `\n'. */
   39072   (yylloc) = last_yylloc;
   39073 
   39074   ungetc (c, input);
   39075 }
   39076 
   39077 static int
   39078 read_signed_integer (void)
   39079 {
   39080   int c = get_char ();
   39081   int sign = 1;
   39082   int n = 0;
   39083 
   39084   ;
   39085   if (c == '-')
   39086     {
   39087       c = get_char ();
   39088       sign = -1;
   39089     }
   39090 
   39091   while (isdigit (c))
   39092     {
   39093       n = 10 * n + (c - '0');
   39094       c = get_char ();
   39095     }
   39096 
   39097   unget_char ( c);
   39098 
   39099   return sign * n;
   39100 }
   39101 
   39102 
   39103 
   39104 /*---------------------------------------------------------------.
   39105 | Lexical analyzer returns an integer on the stack and the token |
   39106 | NUM, or the ASCII character read if not a number.  Skips all   |
   39107 | blanks and tabs, returns 0 for EOF.                            |
   39108 `---------------------------------------------------------------*/
   39109 
   39110 static int
   39111 yylex (void)
   39112 {
   39113   static int init = 1;
   39114   int c;
   39115 
   39116   if (init)
   39117     {
   39118       init = 0;
   39119 
   39120       (yylloc).last_column = 0;
   39121       (yylloc).last_line = 1;
   39122 
   39123     }
   39124 
   39125 
   39126  (yylloc).first_column = (yylloc).last_column;
   39127   (yylloc).first_line   = (yylloc).last_line;
   39128 
   39129 
   39130   /* Skip white space.  */
   39131   while ((c = get_char ()) == ' ' || c == '\t')
   39132     {
   39133      (yylloc).first_column = (yylloc).last_column;
   39134       (yylloc).first_line   = (yylloc).last_line;
   39135 
   39136     }
   39137 
   39138   /* process numbers   */
   39139   if (c == '.' || isdigit (c))
   39140     {
   39141       unget_char ( c);
   39142       (yylval).ival = read_signed_integer ();
   39143       return NUM;
   39144     }
   39145 
   39146   /* Return end-of-file.  */
   39147   if (c == EOF)
   39148     return CALC_EOF;
   39149 
   39150   /* Return single chars. */
   39151   return c;
   39152 }
   39153 
   39154 static int
   39155 power (int base, int exponent)
   39156 {
   39157   int res = 1;
   39158   if (exponent < 0)
   39159     exit (3);
   39160   for (/* Niente */; exponent; --exponent)
   39161     res *= base;
   39162   return res;
   39163 }
   39164 
   39165 
   39166 int
   39167 main (int argc, const char **argv)
   39168 {
   39169   semantic_value result = 0;
   39170   int count = 0;
   39171   int status;
   39172 
   39173   /* This used to be alarm (10), but that isn't enough time for
   39174      a July 1995 vintage DEC Alphastation 200 4/100 system,
   39175      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   39176   alarm (100);
   39177 
   39178   if (argc == 2)
   39179     input = fopen (argv[1], "r");
   39180   else
   39181     input = stdin;
   39182 
   39183   if (!input)
   39184     {
   39185       perror (argv[1]);
   39186       return 3;
   39187     }
   39188 
   39189 
   39190   status = yyparse ();
   39191   if (global_result != result)
   39192     abort ();
   39193   if (global_count != count)
   39194     abort ();
   39195   return status;
   39196 }
   39197 _ATEOF
   39198 
   39199 
   39200 
   39201 
   39202 
   39203 $at_traceoff
   39204 echo "calc.at:598: bison -o calc.c calc.y"
   39205 echo calc.at:598 >$at_check_line_file
   39206 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   39207 at_status=$?
   39208 grep '^ *+' $at_stder1 >&2
   39209 grep -v '^ *+' $at_stder1 >$at_stderr
   39210 at_failed=false
   39211 $at_diff $at_devnull $at_stderr || at_failed=:
   39212 $at_diff $at_devnull $at_stdout || at_failed=:
   39213 case $at_status in
   39214    77) echo 77 > $at_status_file
   39215             exit 77;;
   39216    0) ;;
   39217    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39218       at_failed=:;;
   39219 esac
   39220 if $at_failed; then
   39221 
   39222   echo 1 > $at_status_file
   39223   exit 1
   39224 fi
   39225 
   39226 $at_traceon
   39227 
   39228    $at_traceoff
   39229 echo "calc.at:598: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   39230 echo calc.at:598 >$at_check_line_file
   39231 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   39232 at_status=$?
   39233 grep '^ *+' $at_stder1 >&2
   39234 grep -v '^ *+' $at_stder1 >$at_stderr
   39235 at_failed=false
   39236 echo stderr:; cat $at_stderr
   39237 echo stdout:; cat $at_stdout
   39238 case $at_status in
   39239    77) echo 77 > $at_status_file
   39240             exit 77;;
   39241    0) ;;
   39242    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39243       at_failed=:;;
   39244 esac
   39245 if $at_failed; then
   39246 
   39247   echo 1 > $at_status_file
   39248   exit 1
   39249 fi
   39250 
   39251 $at_traceon
   39252 
   39253 
   39254 # Test the priorities.
   39255 cat >input <<'_ATEOF'
   39256 1 + 2 * 3 = 7
   39257 1 + 2 * -3 = -5
   39258 
   39259 -1^2 = -1
   39260 (-1)^2 = 1
   39261 
   39262 ---1 = -1
   39263 
   39264 1 - 2 - 3 = -4
   39265 1 - (2 - 3) = 2
   39266 
   39267 2^2^3 = 256
   39268 (2^2)^3 = 64
   39269 _ATEOF
   39270 
   39271 $at_traceoff
   39272 echo "calc.at:598: \$PREPARSER ./calc input"
   39273 echo calc.at:598 >$at_check_line_file
   39274 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   39275 at_status=$?
   39276 grep '^ *+' $at_stder1 >&2
   39277 grep -v '^ *+' $at_stder1 >$at_stderr
   39278 at_failed=false
   39279 echo stderr:; tee stderr <$at_stderr
   39280 $at_diff $at_devnull $at_stdout || at_failed=:
   39281 case $at_status in
   39282    77) echo 77 > $at_status_file
   39283             exit 77;;
   39284    0) ;;
   39285    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39286       at_failed=:;;
   39287 esac
   39288 if $at_failed; then
   39289 
   39290   echo 1 > $at_status_file
   39291   exit 1
   39292 fi
   39293 
   39294 $at_traceon
   39295 
   39296 
   39297 
   39298 # Some syntax errors.
   39299 cat >input <<'_ATEOF'
   39300 0 0
   39301 _ATEOF
   39302 
   39303 $at_traceoff
   39304 echo "calc.at:598: \$PREPARSER ./calc input"
   39305 echo calc.at:598 >$at_check_line_file
   39306 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   39307 at_status=$?
   39308 grep '^ *+' $at_stder1 >&2
   39309 grep -v '^ *+' $at_stder1 >$at_stderr
   39310 at_failed=false
   39311 echo stderr:; tee stderr <$at_stderr
   39312 $at_diff $at_devnull $at_stdout || at_failed=:
   39313 case $at_status in
   39314    77) echo 77 > $at_status_file
   39315             exit 77;;
   39316    1) ;;
   39317    *) echo "calc.at:598: exit code was $at_status, expected 1"
   39318       at_failed=:;;
   39319 esac
   39320 if $at_failed; then
   39321 
   39322   echo 1 > $at_status_file
   39323   exit 1
   39324 fi
   39325 
   39326 $at_traceon
   39327 
   39328 
   39329 # Normalize the observed and expected error messages, depending upon the
   39330 # options.
   39331 # 1. Remove the traces from observed.
   39332 sed '/^Starting/d
   39333 /^Entering/d
   39334 /^Stack/d
   39335 /^Reading/d
   39336 /^Reducing/d
   39337 /^Shifting/d
   39338 /^state/d
   39339 /^Cleanup:/d
   39340 /^Error:/d
   39341 /^Next/d
   39342 /^Discarding/d
   39343 / \$[0-9$]* = /d
   39344 /^yydestructor:/d' stderr >at-stderr
   39345 mv at-stderr stderr
   39346 # 2. Create the reference error message.
   39347 cat >expout <<'_ATEOF'
   39348 1.2: syntax error, unexpected number
   39349 _ATEOF
   39350 
   39351 # 3. If locations are not used, remove them.
   39352 
   39353 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   39354 
   39355 # 5. Check
   39356 $at_traceoff
   39357 echo "calc.at:598: cat stderr"
   39358 echo calc.at:598 >$at_check_line_file
   39359 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   39360 at_status=$?
   39361 grep '^ *+' $at_stder1 >&2
   39362 grep -v '^ *+' $at_stder1 >$at_stderr
   39363 at_failed=false
   39364 $at_diff $at_devnull $at_stderr || at_failed=:
   39365 $at_diff expout $at_stdout || at_failed=:
   39366 case $at_status in
   39367    77) echo 77 > $at_status_file
   39368             exit 77;;
   39369    0) ;;
   39370    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39371       at_failed=:;;
   39372 esac
   39373 if $at_failed; then
   39374 
   39375   echo 1 > $at_status_file
   39376   exit 1
   39377 fi
   39378 
   39379 $at_traceon
   39380 
   39381 
   39382 cat >input <<'_ATEOF'
   39383 1//2
   39384 _ATEOF
   39385 
   39386 $at_traceoff
   39387 echo "calc.at:598: \$PREPARSER ./calc input"
   39388 echo calc.at:598 >$at_check_line_file
   39389 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   39390 at_status=$?
   39391 grep '^ *+' $at_stder1 >&2
   39392 grep -v '^ *+' $at_stder1 >$at_stderr
   39393 at_failed=false
   39394 echo stderr:; tee stderr <$at_stderr
   39395 $at_diff $at_devnull $at_stdout || at_failed=:
   39396 case $at_status in
   39397    77) echo 77 > $at_status_file
   39398             exit 77;;
   39399    1) ;;
   39400    *) echo "calc.at:598: exit code was $at_status, expected 1"
   39401       at_failed=:;;
   39402 esac
   39403 if $at_failed; then
   39404 
   39405   echo 1 > $at_status_file
   39406   exit 1
   39407 fi
   39408 
   39409 $at_traceon
   39410 
   39411 
   39412 # Normalize the observed and expected error messages, depending upon the
   39413 # options.
   39414 # 1. Remove the traces from observed.
   39415 sed '/^Starting/d
   39416 /^Entering/d
   39417 /^Stack/d
   39418 /^Reading/d
   39419 /^Reducing/d
   39420 /^Shifting/d
   39421 /^state/d
   39422 /^Cleanup:/d
   39423 /^Error:/d
   39424 /^Next/d
   39425 /^Discarding/d
   39426 / \$[0-9$]* = /d
   39427 /^yydestructor:/d' stderr >at-stderr
   39428 mv at-stderr stderr
   39429 # 2. Create the reference error message.
   39430 cat >expout <<'_ATEOF'
   39431 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   39432 _ATEOF
   39433 
   39434 # 3. If locations are not used, remove them.
   39435 
   39436 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   39437 
   39438 # 5. Check
   39439 $at_traceoff
   39440 echo "calc.at:598: cat stderr"
   39441 echo calc.at:598 >$at_check_line_file
   39442 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   39443 at_status=$?
   39444 grep '^ *+' $at_stder1 >&2
   39445 grep -v '^ *+' $at_stder1 >$at_stderr
   39446 at_failed=false
   39447 $at_diff $at_devnull $at_stderr || at_failed=:
   39448 $at_diff expout $at_stdout || at_failed=:
   39449 case $at_status in
   39450    77) echo 77 > $at_status_file
   39451             exit 77;;
   39452    0) ;;
   39453    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39454       at_failed=:;;
   39455 esac
   39456 if $at_failed; then
   39457 
   39458   echo 1 > $at_status_file
   39459   exit 1
   39460 fi
   39461 
   39462 $at_traceon
   39463 
   39464 
   39465 cat >input <<'_ATEOF'
   39466 error
   39467 _ATEOF
   39468 
   39469 $at_traceoff
   39470 echo "calc.at:598: \$PREPARSER ./calc input"
   39471 echo calc.at:598 >$at_check_line_file
   39472 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   39473 at_status=$?
   39474 grep '^ *+' $at_stder1 >&2
   39475 grep -v '^ *+' $at_stder1 >$at_stderr
   39476 at_failed=false
   39477 echo stderr:; tee stderr <$at_stderr
   39478 $at_diff $at_devnull $at_stdout || at_failed=:
   39479 case $at_status in
   39480    77) echo 77 > $at_status_file
   39481             exit 77;;
   39482    1) ;;
   39483    *) echo "calc.at:598: exit code was $at_status, expected 1"
   39484       at_failed=:;;
   39485 esac
   39486 if $at_failed; then
   39487 
   39488   echo 1 > $at_status_file
   39489   exit 1
   39490 fi
   39491 
   39492 $at_traceon
   39493 
   39494 
   39495 # Normalize the observed and expected error messages, depending upon the
   39496 # options.
   39497 # 1. Remove the traces from observed.
   39498 sed '/^Starting/d
   39499 /^Entering/d
   39500 /^Stack/d
   39501 /^Reading/d
   39502 /^Reducing/d
   39503 /^Shifting/d
   39504 /^state/d
   39505 /^Cleanup:/d
   39506 /^Error:/d
   39507 /^Next/d
   39508 /^Discarding/d
   39509 / \$[0-9$]* = /d
   39510 /^yydestructor:/d' stderr >at-stderr
   39511 mv at-stderr stderr
   39512 # 2. Create the reference error message.
   39513 cat >expout <<'_ATEOF'
   39514 1.0: syntax error, unexpected $undefined
   39515 _ATEOF
   39516 
   39517 # 3. If locations are not used, remove them.
   39518 
   39519 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   39520 
   39521 # 5. Check
   39522 $at_traceoff
   39523 echo "calc.at:598: cat stderr"
   39524 echo calc.at:598 >$at_check_line_file
   39525 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   39526 at_status=$?
   39527 grep '^ *+' $at_stder1 >&2
   39528 grep -v '^ *+' $at_stder1 >$at_stderr
   39529 at_failed=false
   39530 $at_diff $at_devnull $at_stderr || at_failed=:
   39531 $at_diff expout $at_stdout || at_failed=:
   39532 case $at_status in
   39533    77) echo 77 > $at_status_file
   39534             exit 77;;
   39535    0) ;;
   39536    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39537       at_failed=:;;
   39538 esac
   39539 if $at_failed; then
   39540 
   39541   echo 1 > $at_status_file
   39542   exit 1
   39543 fi
   39544 
   39545 $at_traceon
   39546 
   39547 
   39548 cat >input <<'_ATEOF'
   39549 1 = 2 = 3
   39550 _ATEOF
   39551 
   39552 $at_traceoff
   39553 echo "calc.at:598: \$PREPARSER ./calc input"
   39554 echo calc.at:598 >$at_check_line_file
   39555 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   39556 at_status=$?
   39557 grep '^ *+' $at_stder1 >&2
   39558 grep -v '^ *+' $at_stder1 >$at_stderr
   39559 at_failed=false
   39560 echo stderr:; tee stderr <$at_stderr
   39561 $at_diff $at_devnull $at_stdout || at_failed=:
   39562 case $at_status in
   39563    77) echo 77 > $at_status_file
   39564             exit 77;;
   39565    1) ;;
   39566    *) echo "calc.at:598: exit code was $at_status, expected 1"
   39567       at_failed=:;;
   39568 esac
   39569 if $at_failed; then
   39570 
   39571   echo 1 > $at_status_file
   39572   exit 1
   39573 fi
   39574 
   39575 $at_traceon
   39576 
   39577 
   39578 # Normalize the observed and expected error messages, depending upon the
   39579 # options.
   39580 # 1. Remove the traces from observed.
   39581 sed '/^Starting/d
   39582 /^Entering/d
   39583 /^Stack/d
   39584 /^Reading/d
   39585 /^Reducing/d
   39586 /^Shifting/d
   39587 /^state/d
   39588 /^Cleanup:/d
   39589 /^Error:/d
   39590 /^Next/d
   39591 /^Discarding/d
   39592 / \$[0-9$]* = /d
   39593 /^yydestructor:/d' stderr >at-stderr
   39594 mv at-stderr stderr
   39595 # 2. Create the reference error message.
   39596 cat >expout <<'_ATEOF'
   39597 1.6: syntax error, unexpected '='
   39598 _ATEOF
   39599 
   39600 # 3. If locations are not used, remove them.
   39601 
   39602 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   39603 
   39604 # 5. Check
   39605 $at_traceoff
   39606 echo "calc.at:598: cat stderr"
   39607 echo calc.at:598 >$at_check_line_file
   39608 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   39609 at_status=$?
   39610 grep '^ *+' $at_stder1 >&2
   39611 grep -v '^ *+' $at_stder1 >$at_stderr
   39612 at_failed=false
   39613 $at_diff $at_devnull $at_stderr || at_failed=:
   39614 $at_diff expout $at_stdout || at_failed=:
   39615 case $at_status in
   39616    77) echo 77 > $at_status_file
   39617             exit 77;;
   39618    0) ;;
   39619    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39620       at_failed=:;;
   39621 esac
   39622 if $at_failed; then
   39623 
   39624   echo 1 > $at_status_file
   39625   exit 1
   39626 fi
   39627 
   39628 $at_traceon
   39629 
   39630 
   39631 cat >input <<'_ATEOF'
   39632 
   39633 +1
   39634 _ATEOF
   39635 
   39636 $at_traceoff
   39637 echo "calc.at:598: \$PREPARSER ./calc input"
   39638 echo calc.at:598 >$at_check_line_file
   39639 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   39640 at_status=$?
   39641 grep '^ *+' $at_stder1 >&2
   39642 grep -v '^ *+' $at_stder1 >$at_stderr
   39643 at_failed=false
   39644 echo stderr:; tee stderr <$at_stderr
   39645 $at_diff $at_devnull $at_stdout || at_failed=:
   39646 case $at_status in
   39647    77) echo 77 > $at_status_file
   39648             exit 77;;
   39649    1) ;;
   39650    *) echo "calc.at:598: exit code was $at_status, expected 1"
   39651       at_failed=:;;
   39652 esac
   39653 if $at_failed; then
   39654 
   39655   echo 1 > $at_status_file
   39656   exit 1
   39657 fi
   39658 
   39659 $at_traceon
   39660 
   39661 
   39662 # Normalize the observed and expected error messages, depending upon the
   39663 # options.
   39664 # 1. Remove the traces from observed.
   39665 sed '/^Starting/d
   39666 /^Entering/d
   39667 /^Stack/d
   39668 /^Reading/d
   39669 /^Reducing/d
   39670 /^Shifting/d
   39671 /^state/d
   39672 /^Cleanup:/d
   39673 /^Error:/d
   39674 /^Next/d
   39675 /^Discarding/d
   39676 / \$[0-9$]* = /d
   39677 /^yydestructor:/d' stderr >at-stderr
   39678 mv at-stderr stderr
   39679 # 2. Create the reference error message.
   39680 cat >expout <<'_ATEOF'
   39681 2.0: syntax error, unexpected '+'
   39682 _ATEOF
   39683 
   39684 # 3. If locations are not used, remove them.
   39685 
   39686 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   39687 
   39688 # 5. Check
   39689 $at_traceoff
   39690 echo "calc.at:598: cat stderr"
   39691 echo calc.at:598 >$at_check_line_file
   39692 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   39693 at_status=$?
   39694 grep '^ *+' $at_stder1 >&2
   39695 grep -v '^ *+' $at_stder1 >$at_stderr
   39696 at_failed=false
   39697 $at_diff $at_devnull $at_stderr || at_failed=:
   39698 $at_diff expout $at_stdout || at_failed=:
   39699 case $at_status in
   39700    77) echo 77 > $at_status_file
   39701             exit 77;;
   39702    0) ;;
   39703    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39704       at_failed=:;;
   39705 esac
   39706 if $at_failed; then
   39707 
   39708   echo 1 > $at_status_file
   39709   exit 1
   39710 fi
   39711 
   39712 $at_traceon
   39713 
   39714 
   39715 # Exercise error messages with EOF: work on an empty file.
   39716 $at_traceoff
   39717 echo "calc.at:598: \$PREPARSER ./calc /dev/null"
   39718 echo calc.at:598 >$at_check_line_file
   39719 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   39720 at_status=$?
   39721 grep '^ *+' $at_stder1 >&2
   39722 grep -v '^ *+' $at_stder1 >$at_stderr
   39723 at_failed=false
   39724 echo stderr:; tee stderr <$at_stderr
   39725 $at_diff $at_devnull $at_stdout || at_failed=:
   39726 case $at_status in
   39727    77) echo 77 > $at_status_file
   39728             exit 77;;
   39729    1) ;;
   39730    *) echo "calc.at:598: exit code was $at_status, expected 1"
   39731       at_failed=:;;
   39732 esac
   39733 if $at_failed; then
   39734 
   39735   echo 1 > $at_status_file
   39736   exit 1
   39737 fi
   39738 
   39739 $at_traceon
   39740 
   39741 
   39742 # Normalize the observed and expected error messages, depending upon the
   39743 # options.
   39744 # 1. Remove the traces from observed.
   39745 sed '/^Starting/d
   39746 /^Entering/d
   39747 /^Stack/d
   39748 /^Reading/d
   39749 /^Reducing/d
   39750 /^Shifting/d
   39751 /^state/d
   39752 /^Cleanup:/d
   39753 /^Error:/d
   39754 /^Next/d
   39755 /^Discarding/d
   39756 / \$[0-9$]* = /d
   39757 /^yydestructor:/d' stderr >at-stderr
   39758 mv at-stderr stderr
   39759 # 2. Create the reference error message.
   39760 cat >expout <<'_ATEOF'
   39761 1.0: syntax error, unexpected end of input
   39762 _ATEOF
   39763 
   39764 # 3. If locations are not used, remove them.
   39765 
   39766 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   39767 
   39768 # 5. Check
   39769 $at_traceoff
   39770 echo "calc.at:598: cat stderr"
   39771 echo calc.at:598 >$at_check_line_file
   39772 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   39773 at_status=$?
   39774 grep '^ *+' $at_stder1 >&2
   39775 grep -v '^ *+' $at_stder1 >$at_stderr
   39776 at_failed=false
   39777 $at_diff $at_devnull $at_stderr || at_failed=:
   39778 $at_diff expout $at_stdout || at_failed=:
   39779 case $at_status in
   39780    77) echo 77 > $at_status_file
   39781             exit 77;;
   39782    0) ;;
   39783    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39784       at_failed=:;;
   39785 esac
   39786 if $at_failed; then
   39787 
   39788   echo 1 > $at_status_file
   39789   exit 1
   39790 fi
   39791 
   39792 $at_traceon
   39793 
   39794 
   39795 
   39796 # Exercise the error token: without it, we die at the first error,
   39797 # hence be sure to
   39798 #
   39799 # - have several errors which exercise different shift/discardings
   39800 #   - (): nothing to pop, nothing to discard
   39801 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   39802 #   - (* * *): nothing to pop, a lot to discard
   39803 #   - (1 + 2 * *): some to pop and discard
   39804 #
   39805 # - test the action associated to `error'
   39806 #
   39807 # - check the look-ahead that triggers an error is not discarded
   39808 #   when we enter error recovery.  Below, the look-ahead causing the
   39809 #   first error is ")", which is needed to recover from the error and
   39810 #   produce the "0" that triggers the "0 != 1" error.
   39811 #
   39812 cat >input <<'_ATEOF'
   39813 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   39814 _ATEOF
   39815 
   39816 $at_traceoff
   39817 echo "calc.at:598: \$PREPARSER ./calc input"
   39818 echo calc.at:598 >$at_check_line_file
   39819 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   39820 at_status=$?
   39821 grep '^ *+' $at_stder1 >&2
   39822 grep -v '^ *+' $at_stder1 >$at_stderr
   39823 at_failed=false
   39824 echo stderr:; tee stderr <$at_stderr
   39825 $at_diff $at_devnull $at_stdout || at_failed=:
   39826 case $at_status in
   39827    77) echo 77 > $at_status_file
   39828             exit 77;;
   39829    0) ;;
   39830    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39831       at_failed=:;;
   39832 esac
   39833 if $at_failed; then
   39834 
   39835   echo 1 > $at_status_file
   39836   exit 1
   39837 fi
   39838 
   39839 $at_traceon
   39840 
   39841 
   39842 # Normalize the observed and expected error messages, depending upon the
   39843 # options.
   39844 # 1. Remove the traces from observed.
   39845 sed '/^Starting/d
   39846 /^Entering/d
   39847 /^Stack/d
   39848 /^Reading/d
   39849 /^Reducing/d
   39850 /^Shifting/d
   39851 /^state/d
   39852 /^Cleanup:/d
   39853 /^Error:/d
   39854 /^Next/d
   39855 /^Discarding/d
   39856 / \$[0-9$]* = /d
   39857 /^yydestructor:/d' stderr >at-stderr
   39858 mv at-stderr stderr
   39859 # 2. Create the reference error message.
   39860 cat >expout <<'_ATEOF'
   39861 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   39862 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   39863 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   39864 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   39865 calc: error: 4444 != 1
   39866 _ATEOF
   39867 
   39868 # 3. If locations are not used, remove them.
   39869 
   39870 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   39871 
   39872 # 5. Check
   39873 $at_traceoff
   39874 echo "calc.at:598: cat stderr"
   39875 echo calc.at:598 >$at_check_line_file
   39876 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   39877 at_status=$?
   39878 grep '^ *+' $at_stder1 >&2
   39879 grep -v '^ *+' $at_stder1 >$at_stderr
   39880 at_failed=false
   39881 $at_diff $at_devnull $at_stderr || at_failed=:
   39882 $at_diff expout $at_stdout || at_failed=:
   39883 case $at_status in
   39884    77) echo 77 > $at_status_file
   39885             exit 77;;
   39886    0) ;;
   39887    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39888       at_failed=:;;
   39889 esac
   39890 if $at_failed; then
   39891 
   39892   echo 1 > $at_status_file
   39893   exit 1
   39894 fi
   39895 
   39896 $at_traceon
   39897 
   39898 
   39899 
   39900 # The same, but this time exercising explicitly triggered syntax errors.
   39901 # POSIX says the look-ahead causing the error should not be discarded.
   39902 cat >input <<'_ATEOF'
   39903 (!) + (0 0) = 1
   39904 _ATEOF
   39905 
   39906 $at_traceoff
   39907 echo "calc.at:598: \$PREPARSER ./calc input"
   39908 echo calc.at:598 >$at_check_line_file
   39909 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   39910 at_status=$?
   39911 grep '^ *+' $at_stder1 >&2
   39912 grep -v '^ *+' $at_stder1 >$at_stderr
   39913 at_failed=false
   39914 echo stderr:; tee stderr <$at_stderr
   39915 $at_diff $at_devnull $at_stdout || at_failed=:
   39916 case $at_status in
   39917    77) echo 77 > $at_status_file
   39918             exit 77;;
   39919    0) ;;
   39920    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39921       at_failed=:;;
   39922 esac
   39923 if $at_failed; then
   39924 
   39925   echo 1 > $at_status_file
   39926   exit 1
   39927 fi
   39928 
   39929 $at_traceon
   39930 
   39931 
   39932 # Normalize the observed and expected error messages, depending upon the
   39933 # options.
   39934 # 1. Remove the traces from observed.
   39935 sed '/^Starting/d
   39936 /^Entering/d
   39937 /^Stack/d
   39938 /^Reading/d
   39939 /^Reducing/d
   39940 /^Shifting/d
   39941 /^state/d
   39942 /^Cleanup:/d
   39943 /^Error:/d
   39944 /^Next/d
   39945 /^Discarding/d
   39946 / \$[0-9$]* = /d
   39947 /^yydestructor:/d' stderr >at-stderr
   39948 mv at-stderr stderr
   39949 # 2. Create the reference error message.
   39950 cat >expout <<'_ATEOF'
   39951 1.9: syntax error, unexpected number
   39952 calc: error: 2222 != 1
   39953 _ATEOF
   39954 
   39955 # 3. If locations are not used, remove them.
   39956 
   39957 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   39958 
   39959 # 5. Check
   39960 $at_traceoff
   39961 echo "calc.at:598: cat stderr"
   39962 echo calc.at:598 >$at_check_line_file
   39963 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   39964 at_status=$?
   39965 grep '^ *+' $at_stder1 >&2
   39966 grep -v '^ *+' $at_stder1 >$at_stderr
   39967 at_failed=false
   39968 $at_diff $at_devnull $at_stderr || at_failed=:
   39969 $at_diff expout $at_stdout || at_failed=:
   39970 case $at_status in
   39971    77) echo 77 > $at_status_file
   39972             exit 77;;
   39973    0) ;;
   39974    *) echo "calc.at:598: exit code was $at_status, expected 0"
   39975       at_failed=:;;
   39976 esac
   39977 if $at_failed; then
   39978 
   39979   echo 1 > $at_status_file
   39980   exit 1
   39981 fi
   39982 
   39983 $at_traceon
   39984 
   39985 
   39986 cat >input <<'_ATEOF'
   39987 (- *) + (0 0) = 1
   39988 _ATEOF
   39989 
   39990 $at_traceoff
   39991 echo "calc.at:598: \$PREPARSER ./calc input"
   39992 echo calc.at:598 >$at_check_line_file
   39993 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   39994 at_status=$?
   39995 grep '^ *+' $at_stder1 >&2
   39996 grep -v '^ *+' $at_stder1 >$at_stderr
   39997 at_failed=false
   39998 echo stderr:; tee stderr <$at_stderr
   39999 $at_diff $at_devnull $at_stdout || at_failed=:
   40000 case $at_status in
   40001    77) echo 77 > $at_status_file
   40002             exit 77;;
   40003    0) ;;
   40004    *) echo "calc.at:598: exit code was $at_status, expected 0"
   40005       at_failed=:;;
   40006 esac
   40007 if $at_failed; then
   40008 
   40009   echo 1 > $at_status_file
   40010   exit 1
   40011 fi
   40012 
   40013 $at_traceon
   40014 
   40015 
   40016 # Normalize the observed and expected error messages, depending upon the
   40017 # options.
   40018 # 1. Remove the traces from observed.
   40019 sed '/^Starting/d
   40020 /^Entering/d
   40021 /^Stack/d
   40022 /^Reading/d
   40023 /^Reducing/d
   40024 /^Shifting/d
   40025 /^state/d
   40026 /^Cleanup:/d
   40027 /^Error:/d
   40028 /^Next/d
   40029 /^Discarding/d
   40030 / \$[0-9$]* = /d
   40031 /^yydestructor:/d' stderr >at-stderr
   40032 mv at-stderr stderr
   40033 # 2. Create the reference error message.
   40034 cat >expout <<'_ATEOF'
   40035 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   40036 1.11: syntax error, unexpected number
   40037 calc: error: 2222 != 1
   40038 _ATEOF
   40039 
   40040 # 3. If locations are not used, remove them.
   40041 
   40042 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   40043 
   40044 # 5. Check
   40045 $at_traceoff
   40046 echo "calc.at:598: cat stderr"
   40047 echo calc.at:598 >$at_check_line_file
   40048 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   40049 at_status=$?
   40050 grep '^ *+' $at_stder1 >&2
   40051 grep -v '^ *+' $at_stder1 >$at_stderr
   40052 at_failed=false
   40053 $at_diff $at_devnull $at_stderr || at_failed=:
   40054 $at_diff expout $at_stdout || at_failed=:
   40055 case $at_status in
   40056    77) echo 77 > $at_status_file
   40057             exit 77;;
   40058    0) ;;
   40059    *) echo "calc.at:598: exit code was $at_status, expected 0"
   40060       at_failed=:;;
   40061 esac
   40062 if $at_failed; then
   40063 
   40064   echo 1 > $at_status_file
   40065   exit 1
   40066 fi
   40067 
   40068 $at_traceon
   40069 
   40070 
   40071 
   40072 
   40073 
   40074 
   40075 
   40076 
   40077 
   40078 
   40079 
   40080 
   40081 
   40082 
   40083 
   40084 
   40085 
   40086 
   40087 
   40088 
   40089 
   40090 
   40091 
   40092 
   40093       $at_traceoff
   40094       $at_times_p && times >$at_times_file
   40095     ) 5>&1 2>&1 | eval $at_tee_pipe
   40096     at_status=`cat $at_status_file`
   40097     ;;
   40098 
   40099   94 ) # 94. calc.at:600: Calculator %glr-parser %debug
   40100     at_setup_line='calc.at:600'
   40101     at_desc='Calculator %glr-parser %debug'
   40102     $at_quiet $ECHO_N " 94: Calculator %glr-parser %debug                $ECHO_C"
   40103     at_xfail=no
   40104     (
   40105       echo "94. calc.at:600: testing ..."
   40106       $at_traceon
   40107 
   40108 
   40109 
   40110 
   40111 
   40112 
   40113 
   40114 
   40115 # Using yacc.c?
   40116 
   40117 
   40118 
   40119 
   40120 
   40121 
   40122 
   40123 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   40124 
   40125 # yyerror always sees the locations (when activated), except if
   40126 # yacc & pure & !param.
   40127 
   40128 
   40129 # The interface is pure: either because %pure-parser, or because we
   40130 # are using the C++ parsers.
   40131 
   40132 
   40133 
   40134 
   40135 
   40136 
   40137 
   40138 
   40139 
   40140 
   40141 
   40142 
   40143 cat >calc.y <<'_ATEOF'
   40144 %{
   40145 #ifdef HAVE_CONFIG_H
   40146 # include <config.h>
   40147   /* We don't need perfect functions for these tests. */
   40148 # undef malloc
   40149 # undef memcmp
   40150 # undef realloc
   40151 #endif
   40152 %}
   40153 
   40154 /* Infix notation calculator--calc */
   40155 %glr-parser %debug
   40156 
   40157 %{
   40158 #include <stdio.h>
   40159 
   40160 #include <stdlib.h>
   40161 #include <string.h>
   40162 #if HAVE_UNISTD_H
   40163 # include <unistd.h>
   40164 #else
   40165 # undef alarm
   40166 # define alarm(seconds) /* empty */
   40167 #endif
   40168 #include <ctype.h>
   40169 #define USE(Var)
   40170 
   40171 /* Exercise pre-prologue dependency to %union.  */
   40172 typedef int semantic_value;
   40173 
   40174 static semantic_value global_result = 0;
   40175 static int global_count = 0;
   40176 %}
   40177 
   40178 /* Exercise %union. */
   40179 %union
   40180 {
   40181   semantic_value ival;
   40182 };
   40183 
   40184 %{
   40185 static int power (int base, int exponent);
   40186 /* yyerror receives the location if:
   40187    - %location & %pure & %glr
   40188    - %location & %pure & %yacc & %parse-param. */
   40189 static void yyerror (
   40190 
   40191                      const char *s
   40192                      );
   40193 static int yylex (void);
   40194 static int get_char (void);
   40195 static void unget_char ( int c);
   40196 %}
   40197 
   40198 
   40199 
   40200 /* Bison Declarations */
   40201 %token CALC_EOF 0 "end of input"
   40202 %token <ival> NUM "number"
   40203 %type  <ival> exp
   40204 
   40205 %nonassoc '=' /* comparison	       */
   40206 %left '-' '+'
   40207 %left '*' '/'
   40208 %left NEG     /* negation--unary minus */
   40209 %right '^'    /* exponentiation        */
   40210 
   40211 /* Grammar follows */
   40212 %%
   40213 input:
   40214   line
   40215 | input line         {  }
   40216 ;
   40217 
   40218 line:
   40219   '\n'
   40220 | exp '\n'           { USE ($1); }
   40221 ;
   40222 
   40223 exp:
   40224   NUM                { $$ = $1;             }
   40225 | exp '=' exp
   40226   {
   40227     if ($1 != $3)
   40228       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   40229     $$ = $1;
   40230   }
   40231 | exp '+' exp        { $$ = $1 + $3;        }
   40232 | exp '-' exp        { $$ = $1 - $3;        }
   40233 | exp '*' exp        { $$ = $1 * $3;        }
   40234 | exp '/' exp        { $$ = $1 / $3;        }
   40235 | '-' exp  %prec NEG { $$ = -$2;            }
   40236 | exp '^' exp        { $$ = power ($1, $3); }
   40237 | '(' exp ')'        { $$ = $2;             }
   40238 | '(' error ')'      { $$ = 1111;           }
   40239 | '!'                { $$ = 0; YYERROR;     }
   40240 | '-' error          { $$ = 0; YYERROR;     }
   40241 ;
   40242 %%
   40243 /* The input.  */
   40244 static FILE *input;
   40245 
   40246 static void
   40247 yyerror (
   40248 
   40249          const char *s)
   40250 {
   40251 
   40252 
   40253   fprintf (stderr, "%s\n", s);
   40254 }
   40255 
   40256 
   40257 
   40258 static int
   40259 get_char (void)
   40260 {
   40261   int res = getc (input);
   40262   ;
   40263 
   40264   return res;
   40265 }
   40266 
   40267 
   40268 static void
   40269 unget_char ( int c)
   40270 {
   40271   ;
   40272 
   40273   ungetc (c, input);
   40274 }
   40275 
   40276 static int
   40277 read_signed_integer (void)
   40278 {
   40279   int c = get_char ();
   40280   int sign = 1;
   40281   int n = 0;
   40282 
   40283   ;
   40284   if (c == '-')
   40285     {
   40286       c = get_char ();
   40287       sign = -1;
   40288     }
   40289 
   40290   while (isdigit (c))
   40291     {
   40292       n = 10 * n + (c - '0');
   40293       c = get_char ();
   40294     }
   40295 
   40296   unget_char ( c);
   40297 
   40298   return sign * n;
   40299 }
   40300 
   40301 
   40302 
   40303 /*---------------------------------------------------------------.
   40304 | Lexical analyzer returns an integer on the stack and the token |
   40305 | NUM, or the ASCII character read if not a number.  Skips all   |
   40306 | blanks and tabs, returns 0 for EOF.                            |
   40307 `---------------------------------------------------------------*/
   40308 
   40309 static int
   40310 yylex (void)
   40311 {
   40312   static int init = 1;
   40313   int c;
   40314 
   40315   if (init)
   40316     {
   40317       init = 0;
   40318 
   40319     }
   40320 
   40321 
   40322 
   40323   /* Skip white space.  */
   40324   while ((c = get_char ()) == ' ' || c == '\t')
   40325     {
   40326 
   40327     }
   40328 
   40329   /* process numbers   */
   40330   if (c == '.' || isdigit (c))
   40331     {
   40332       unget_char ( c);
   40333       (yylval).ival = read_signed_integer ();
   40334       return NUM;
   40335     }
   40336 
   40337   /* Return end-of-file.  */
   40338   if (c == EOF)
   40339     return CALC_EOF;
   40340 
   40341   /* Return single chars. */
   40342   return c;
   40343 }
   40344 
   40345 static int
   40346 power (int base, int exponent)
   40347 {
   40348   int res = 1;
   40349   if (exponent < 0)
   40350     exit (3);
   40351   for (/* Niente */; exponent; --exponent)
   40352     res *= base;
   40353   return res;
   40354 }
   40355 
   40356 
   40357 int
   40358 main (int argc, const char **argv)
   40359 {
   40360   semantic_value result = 0;
   40361   int count = 0;
   40362   int status;
   40363 
   40364   /* This used to be alarm (10), but that isn't enough time for
   40365      a July 1995 vintage DEC Alphastation 200 4/100 system,
   40366      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   40367   alarm (100);
   40368 
   40369   if (argc == 2)
   40370     input = fopen (argv[1], "r");
   40371   else
   40372     input = stdin;
   40373 
   40374   if (!input)
   40375     {
   40376       perror (argv[1]);
   40377       return 3;
   40378     }
   40379 
   40380   yydebug = 1;
   40381   status = yyparse ();
   40382   if (global_result != result)
   40383     abort ();
   40384   if (global_count != count)
   40385     abort ();
   40386   return status;
   40387 }
   40388 _ATEOF
   40389 
   40390 
   40391 
   40392 
   40393 
   40394 $at_traceoff
   40395 echo "calc.at:600: bison -o calc.c calc.y"
   40396 echo calc.at:600 >$at_check_line_file
   40397 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   40398 at_status=$?
   40399 grep '^ *+' $at_stder1 >&2
   40400 grep -v '^ *+' $at_stder1 >$at_stderr
   40401 at_failed=false
   40402 $at_diff $at_devnull $at_stderr || at_failed=:
   40403 $at_diff $at_devnull $at_stdout || at_failed=:
   40404 case $at_status in
   40405    77) echo 77 > $at_status_file
   40406             exit 77;;
   40407    0) ;;
   40408    *) echo "calc.at:600: exit code was $at_status, expected 0"
   40409       at_failed=:;;
   40410 esac
   40411 if $at_failed; then
   40412 
   40413   echo 1 > $at_status_file
   40414   exit 1
   40415 fi
   40416 
   40417 $at_traceon
   40418 
   40419    $at_traceoff
   40420 echo "calc.at:600: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   40421 echo calc.at:600 >$at_check_line_file
   40422 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   40423 at_status=$?
   40424 grep '^ *+' $at_stder1 >&2
   40425 grep -v '^ *+' $at_stder1 >$at_stderr
   40426 at_failed=false
   40427 echo stderr:; cat $at_stderr
   40428 echo stdout:; cat $at_stdout
   40429 case $at_status in
   40430    77) echo 77 > $at_status_file
   40431             exit 77;;
   40432    0) ;;
   40433    *) echo "calc.at:600: exit code was $at_status, expected 0"
   40434       at_failed=:;;
   40435 esac
   40436 if $at_failed; then
   40437 
   40438   echo 1 > $at_status_file
   40439   exit 1
   40440 fi
   40441 
   40442 $at_traceon
   40443 
   40444 
   40445 # Test the priorities.
   40446 cat >input <<'_ATEOF'
   40447 1 + 2 * 3 = 7
   40448 1 + 2 * -3 = -5
   40449 
   40450 -1^2 = -1
   40451 (-1)^2 = 1
   40452 
   40453 ---1 = -1
   40454 
   40455 1 - 2 - 3 = -4
   40456 1 - (2 - 3) = 2
   40457 
   40458 2^2^3 = 256
   40459 (2^2)^3 = 64
   40460 _ATEOF
   40461 
   40462 $at_traceoff
   40463 echo "calc.at:600: \$PREPARSER ./calc input"
   40464 echo calc.at:600 >$at_check_line_file
   40465 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   40466 at_status=$?
   40467 grep '^ *+' $at_stder1 >&2
   40468 grep -v '^ *+' $at_stder1 >$at_stderr
   40469 at_failed=false
   40470 echo stderr:; tee stderr <$at_stderr
   40471 $at_diff $at_devnull $at_stdout || at_failed=:
   40472 case $at_status in
   40473    77) echo 77 > $at_status_file
   40474             exit 77;;
   40475    0) ;;
   40476    *) echo "calc.at:600: exit code was $at_status, expected 0"
   40477       at_failed=:;;
   40478 esac
   40479 if $at_failed; then
   40480 
   40481   echo 1 > $at_status_file
   40482   exit 1
   40483 fi
   40484 
   40485 $at_traceon
   40486 
   40487 
   40488 
   40489 # Some syntax errors.
   40490 cat >input <<'_ATEOF'
   40491 0 0
   40492 _ATEOF
   40493 
   40494 $at_traceoff
   40495 echo "calc.at:600: \$PREPARSER ./calc input"
   40496 echo calc.at:600 >$at_check_line_file
   40497 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   40498 at_status=$?
   40499 grep '^ *+' $at_stder1 >&2
   40500 grep -v '^ *+' $at_stder1 >$at_stderr
   40501 at_failed=false
   40502 echo stderr:; tee stderr <$at_stderr
   40503 $at_diff $at_devnull $at_stdout || at_failed=:
   40504 case $at_status in
   40505    77) echo 77 > $at_status_file
   40506             exit 77;;
   40507    1) ;;
   40508    *) echo "calc.at:600: exit code was $at_status, expected 1"
   40509       at_failed=:;;
   40510 esac
   40511 if $at_failed; then
   40512 
   40513   echo 1 > $at_status_file
   40514   exit 1
   40515 fi
   40516 
   40517 $at_traceon
   40518 
   40519 
   40520 # Normalize the observed and expected error messages, depending upon the
   40521 # options.
   40522 # 1. Remove the traces from observed.
   40523 sed '/^Starting/d
   40524 /^Entering/d
   40525 /^Stack/d
   40526 /^Reading/d
   40527 /^Reducing/d
   40528 /^Shifting/d
   40529 /^state/d
   40530 /^Cleanup:/d
   40531 /^Error:/d
   40532 /^Next/d
   40533 /^Discarding/d
   40534 / \$[0-9$]* = /d
   40535 /^yydestructor:/d' stderr >at-stderr
   40536 mv at-stderr stderr
   40537 # 2. Create the reference error message.
   40538 cat >expout <<'_ATEOF'
   40539 1.2: syntax error, unexpected number
   40540 _ATEOF
   40541 
   40542 # 3. If locations are not used, remove them.
   40543 sed 's/^[-0-9.]*: //' expout >at-expout
   40544 mv at-expout expout
   40545 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   40546 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   40547 mv at-expout expout
   40548 # 5. Check
   40549 $at_traceoff
   40550 echo "calc.at:600: cat stderr"
   40551 echo calc.at:600 >$at_check_line_file
   40552 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   40553 at_status=$?
   40554 grep '^ *+' $at_stder1 >&2
   40555 grep -v '^ *+' $at_stder1 >$at_stderr
   40556 at_failed=false
   40557 $at_diff $at_devnull $at_stderr || at_failed=:
   40558 $at_diff expout $at_stdout || at_failed=:
   40559 case $at_status in
   40560    77) echo 77 > $at_status_file
   40561             exit 77;;
   40562    0) ;;
   40563    *) echo "calc.at:600: exit code was $at_status, expected 0"
   40564       at_failed=:;;
   40565 esac
   40566 if $at_failed; then
   40567 
   40568   echo 1 > $at_status_file
   40569   exit 1
   40570 fi
   40571 
   40572 $at_traceon
   40573 
   40574 
   40575 cat >input <<'_ATEOF'
   40576 1//2
   40577 _ATEOF
   40578 
   40579 $at_traceoff
   40580 echo "calc.at:600: \$PREPARSER ./calc input"
   40581 echo calc.at:600 >$at_check_line_file
   40582 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   40583 at_status=$?
   40584 grep '^ *+' $at_stder1 >&2
   40585 grep -v '^ *+' $at_stder1 >$at_stderr
   40586 at_failed=false
   40587 echo stderr:; tee stderr <$at_stderr
   40588 $at_diff $at_devnull $at_stdout || at_failed=:
   40589 case $at_status in
   40590    77) echo 77 > $at_status_file
   40591             exit 77;;
   40592    1) ;;
   40593    *) echo "calc.at:600: exit code was $at_status, expected 1"
   40594       at_failed=:;;
   40595 esac
   40596 if $at_failed; then
   40597 
   40598   echo 1 > $at_status_file
   40599   exit 1
   40600 fi
   40601 
   40602 $at_traceon
   40603 
   40604 
   40605 # Normalize the observed and expected error messages, depending upon the
   40606 # options.
   40607 # 1. Remove the traces from observed.
   40608 sed '/^Starting/d
   40609 /^Entering/d
   40610 /^Stack/d
   40611 /^Reading/d
   40612 /^Reducing/d
   40613 /^Shifting/d
   40614 /^state/d
   40615 /^Cleanup:/d
   40616 /^Error:/d
   40617 /^Next/d
   40618 /^Discarding/d
   40619 / \$[0-9$]* = /d
   40620 /^yydestructor:/d' stderr >at-stderr
   40621 mv at-stderr stderr
   40622 # 2. Create the reference error message.
   40623 cat >expout <<'_ATEOF'
   40624 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   40625 _ATEOF
   40626 
   40627 # 3. If locations are not used, remove them.
   40628 sed 's/^[-0-9.]*: //' expout >at-expout
   40629 mv at-expout expout
   40630 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   40631 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   40632 mv at-expout expout
   40633 # 5. Check
   40634 $at_traceoff
   40635 echo "calc.at:600: cat stderr"
   40636 echo calc.at:600 >$at_check_line_file
   40637 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   40638 at_status=$?
   40639 grep '^ *+' $at_stder1 >&2
   40640 grep -v '^ *+' $at_stder1 >$at_stderr
   40641 at_failed=false
   40642 $at_diff $at_devnull $at_stderr || at_failed=:
   40643 $at_diff expout $at_stdout || at_failed=:
   40644 case $at_status in
   40645    77) echo 77 > $at_status_file
   40646             exit 77;;
   40647    0) ;;
   40648    *) echo "calc.at:600: exit code was $at_status, expected 0"
   40649       at_failed=:;;
   40650 esac
   40651 if $at_failed; then
   40652 
   40653   echo 1 > $at_status_file
   40654   exit 1
   40655 fi
   40656 
   40657 $at_traceon
   40658 
   40659 
   40660 cat >input <<'_ATEOF'
   40661 error
   40662 _ATEOF
   40663 
   40664 $at_traceoff
   40665 echo "calc.at:600: \$PREPARSER ./calc input"
   40666 echo calc.at:600 >$at_check_line_file
   40667 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   40668 at_status=$?
   40669 grep '^ *+' $at_stder1 >&2
   40670 grep -v '^ *+' $at_stder1 >$at_stderr
   40671 at_failed=false
   40672 echo stderr:; tee stderr <$at_stderr
   40673 $at_diff $at_devnull $at_stdout || at_failed=:
   40674 case $at_status in
   40675    77) echo 77 > $at_status_file
   40676             exit 77;;
   40677    1) ;;
   40678    *) echo "calc.at:600: exit code was $at_status, expected 1"
   40679       at_failed=:;;
   40680 esac
   40681 if $at_failed; then
   40682 
   40683   echo 1 > $at_status_file
   40684   exit 1
   40685 fi
   40686 
   40687 $at_traceon
   40688 
   40689 
   40690 # Normalize the observed and expected error messages, depending upon the
   40691 # options.
   40692 # 1. Remove the traces from observed.
   40693 sed '/^Starting/d
   40694 /^Entering/d
   40695 /^Stack/d
   40696 /^Reading/d
   40697 /^Reducing/d
   40698 /^Shifting/d
   40699 /^state/d
   40700 /^Cleanup:/d
   40701 /^Error:/d
   40702 /^Next/d
   40703 /^Discarding/d
   40704 / \$[0-9$]* = /d
   40705 /^yydestructor:/d' stderr >at-stderr
   40706 mv at-stderr stderr
   40707 # 2. Create the reference error message.
   40708 cat >expout <<'_ATEOF'
   40709 1.0: syntax error, unexpected $undefined
   40710 _ATEOF
   40711 
   40712 # 3. If locations are not used, remove them.
   40713 sed 's/^[-0-9.]*: //' expout >at-expout
   40714 mv at-expout expout
   40715 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   40716 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   40717 mv at-expout expout
   40718 # 5. Check
   40719 $at_traceoff
   40720 echo "calc.at:600: cat stderr"
   40721 echo calc.at:600 >$at_check_line_file
   40722 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   40723 at_status=$?
   40724 grep '^ *+' $at_stder1 >&2
   40725 grep -v '^ *+' $at_stder1 >$at_stderr
   40726 at_failed=false
   40727 $at_diff $at_devnull $at_stderr || at_failed=:
   40728 $at_diff expout $at_stdout || at_failed=:
   40729 case $at_status in
   40730    77) echo 77 > $at_status_file
   40731             exit 77;;
   40732    0) ;;
   40733    *) echo "calc.at:600: exit code was $at_status, expected 0"
   40734       at_failed=:;;
   40735 esac
   40736 if $at_failed; then
   40737 
   40738   echo 1 > $at_status_file
   40739   exit 1
   40740 fi
   40741 
   40742 $at_traceon
   40743 
   40744 
   40745 cat >input <<'_ATEOF'
   40746 1 = 2 = 3
   40747 _ATEOF
   40748 
   40749 $at_traceoff
   40750 echo "calc.at:600: \$PREPARSER ./calc input"
   40751 echo calc.at:600 >$at_check_line_file
   40752 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   40753 at_status=$?
   40754 grep '^ *+' $at_stder1 >&2
   40755 grep -v '^ *+' $at_stder1 >$at_stderr
   40756 at_failed=false
   40757 echo stderr:; tee stderr <$at_stderr
   40758 $at_diff $at_devnull $at_stdout || at_failed=:
   40759 case $at_status in
   40760    77) echo 77 > $at_status_file
   40761             exit 77;;
   40762    1) ;;
   40763    *) echo "calc.at:600: exit code was $at_status, expected 1"
   40764       at_failed=:;;
   40765 esac
   40766 if $at_failed; then
   40767 
   40768   echo 1 > $at_status_file
   40769   exit 1
   40770 fi
   40771 
   40772 $at_traceon
   40773 
   40774 
   40775 # Normalize the observed and expected error messages, depending upon the
   40776 # options.
   40777 # 1. Remove the traces from observed.
   40778 sed '/^Starting/d
   40779 /^Entering/d
   40780 /^Stack/d
   40781 /^Reading/d
   40782 /^Reducing/d
   40783 /^Shifting/d
   40784 /^state/d
   40785 /^Cleanup:/d
   40786 /^Error:/d
   40787 /^Next/d
   40788 /^Discarding/d
   40789 / \$[0-9$]* = /d
   40790 /^yydestructor:/d' stderr >at-stderr
   40791 mv at-stderr stderr
   40792 # 2. Create the reference error message.
   40793 cat >expout <<'_ATEOF'
   40794 1.6: syntax error, unexpected '='
   40795 _ATEOF
   40796 
   40797 # 3. If locations are not used, remove them.
   40798 sed 's/^[-0-9.]*: //' expout >at-expout
   40799 mv at-expout expout
   40800 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   40801 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   40802 mv at-expout expout
   40803 # 5. Check
   40804 $at_traceoff
   40805 echo "calc.at:600: cat stderr"
   40806 echo calc.at:600 >$at_check_line_file
   40807 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   40808 at_status=$?
   40809 grep '^ *+' $at_stder1 >&2
   40810 grep -v '^ *+' $at_stder1 >$at_stderr
   40811 at_failed=false
   40812 $at_diff $at_devnull $at_stderr || at_failed=:
   40813 $at_diff expout $at_stdout || at_failed=:
   40814 case $at_status in
   40815    77) echo 77 > $at_status_file
   40816             exit 77;;
   40817    0) ;;
   40818    *) echo "calc.at:600: exit code was $at_status, expected 0"
   40819       at_failed=:;;
   40820 esac
   40821 if $at_failed; then
   40822 
   40823   echo 1 > $at_status_file
   40824   exit 1
   40825 fi
   40826 
   40827 $at_traceon
   40828 
   40829 
   40830 cat >input <<'_ATEOF'
   40831 
   40832 +1
   40833 _ATEOF
   40834 
   40835 $at_traceoff
   40836 echo "calc.at:600: \$PREPARSER ./calc input"
   40837 echo calc.at:600 >$at_check_line_file
   40838 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   40839 at_status=$?
   40840 grep '^ *+' $at_stder1 >&2
   40841 grep -v '^ *+' $at_stder1 >$at_stderr
   40842 at_failed=false
   40843 echo stderr:; tee stderr <$at_stderr
   40844 $at_diff $at_devnull $at_stdout || at_failed=:
   40845 case $at_status in
   40846    77) echo 77 > $at_status_file
   40847             exit 77;;
   40848    1) ;;
   40849    *) echo "calc.at:600: exit code was $at_status, expected 1"
   40850       at_failed=:;;
   40851 esac
   40852 if $at_failed; then
   40853 
   40854   echo 1 > $at_status_file
   40855   exit 1
   40856 fi
   40857 
   40858 $at_traceon
   40859 
   40860 
   40861 # Normalize the observed and expected error messages, depending upon the
   40862 # options.
   40863 # 1. Remove the traces from observed.
   40864 sed '/^Starting/d
   40865 /^Entering/d
   40866 /^Stack/d
   40867 /^Reading/d
   40868 /^Reducing/d
   40869 /^Shifting/d
   40870 /^state/d
   40871 /^Cleanup:/d
   40872 /^Error:/d
   40873 /^Next/d
   40874 /^Discarding/d
   40875 / \$[0-9$]* = /d
   40876 /^yydestructor:/d' stderr >at-stderr
   40877 mv at-stderr stderr
   40878 # 2. Create the reference error message.
   40879 cat >expout <<'_ATEOF'
   40880 2.0: syntax error, unexpected '+'
   40881 _ATEOF
   40882 
   40883 # 3. If locations are not used, remove them.
   40884 sed 's/^[-0-9.]*: //' expout >at-expout
   40885 mv at-expout expout
   40886 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   40887 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   40888 mv at-expout expout
   40889 # 5. Check
   40890 $at_traceoff
   40891 echo "calc.at:600: cat stderr"
   40892 echo calc.at:600 >$at_check_line_file
   40893 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   40894 at_status=$?
   40895 grep '^ *+' $at_stder1 >&2
   40896 grep -v '^ *+' $at_stder1 >$at_stderr
   40897 at_failed=false
   40898 $at_diff $at_devnull $at_stderr || at_failed=:
   40899 $at_diff expout $at_stdout || at_failed=:
   40900 case $at_status in
   40901    77) echo 77 > $at_status_file
   40902             exit 77;;
   40903    0) ;;
   40904    *) echo "calc.at:600: exit code was $at_status, expected 0"
   40905       at_failed=:;;
   40906 esac
   40907 if $at_failed; then
   40908 
   40909   echo 1 > $at_status_file
   40910   exit 1
   40911 fi
   40912 
   40913 $at_traceon
   40914 
   40915 
   40916 # Exercise error messages with EOF: work on an empty file.
   40917 $at_traceoff
   40918 echo "calc.at:600: \$PREPARSER ./calc /dev/null"
   40919 echo calc.at:600 >$at_check_line_file
   40920 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   40921 at_status=$?
   40922 grep '^ *+' $at_stder1 >&2
   40923 grep -v '^ *+' $at_stder1 >$at_stderr
   40924 at_failed=false
   40925 echo stderr:; tee stderr <$at_stderr
   40926 $at_diff $at_devnull $at_stdout || at_failed=:
   40927 case $at_status in
   40928    77) echo 77 > $at_status_file
   40929             exit 77;;
   40930    1) ;;
   40931    *) echo "calc.at:600: exit code was $at_status, expected 1"
   40932       at_failed=:;;
   40933 esac
   40934 if $at_failed; then
   40935 
   40936   echo 1 > $at_status_file
   40937   exit 1
   40938 fi
   40939 
   40940 $at_traceon
   40941 
   40942 
   40943 # Normalize the observed and expected error messages, depending upon the
   40944 # options.
   40945 # 1. Remove the traces from observed.
   40946 sed '/^Starting/d
   40947 /^Entering/d
   40948 /^Stack/d
   40949 /^Reading/d
   40950 /^Reducing/d
   40951 /^Shifting/d
   40952 /^state/d
   40953 /^Cleanup:/d
   40954 /^Error:/d
   40955 /^Next/d
   40956 /^Discarding/d
   40957 / \$[0-9$]* = /d
   40958 /^yydestructor:/d' stderr >at-stderr
   40959 mv at-stderr stderr
   40960 # 2. Create the reference error message.
   40961 cat >expout <<'_ATEOF'
   40962 1.0: syntax error, unexpected end of input
   40963 _ATEOF
   40964 
   40965 # 3. If locations are not used, remove them.
   40966 sed 's/^[-0-9.]*: //' expout >at-expout
   40967 mv at-expout expout
   40968 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   40969 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   40970 mv at-expout expout
   40971 # 5. Check
   40972 $at_traceoff
   40973 echo "calc.at:600: cat stderr"
   40974 echo calc.at:600 >$at_check_line_file
   40975 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   40976 at_status=$?
   40977 grep '^ *+' $at_stder1 >&2
   40978 grep -v '^ *+' $at_stder1 >$at_stderr
   40979 at_failed=false
   40980 $at_diff $at_devnull $at_stderr || at_failed=:
   40981 $at_diff expout $at_stdout || at_failed=:
   40982 case $at_status in
   40983    77) echo 77 > $at_status_file
   40984             exit 77;;
   40985    0) ;;
   40986    *) echo "calc.at:600: exit code was $at_status, expected 0"
   40987       at_failed=:;;
   40988 esac
   40989 if $at_failed; then
   40990 
   40991   echo 1 > $at_status_file
   40992   exit 1
   40993 fi
   40994 
   40995 $at_traceon
   40996 
   40997 
   40998 
   40999 # Exercise the error token: without it, we die at the first error,
   41000 # hence be sure to
   41001 #
   41002 # - have several errors which exercise different shift/discardings
   41003 #   - (): nothing to pop, nothing to discard
   41004 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   41005 #   - (* * *): nothing to pop, a lot to discard
   41006 #   - (1 + 2 * *): some to pop and discard
   41007 #
   41008 # - test the action associated to `error'
   41009 #
   41010 # - check the look-ahead that triggers an error is not discarded
   41011 #   when we enter error recovery.  Below, the look-ahead causing the
   41012 #   first error is ")", which is needed to recover from the error and
   41013 #   produce the "0" that triggers the "0 != 1" error.
   41014 #
   41015 cat >input <<'_ATEOF'
   41016 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   41017 _ATEOF
   41018 
   41019 $at_traceoff
   41020 echo "calc.at:600: \$PREPARSER ./calc input"
   41021 echo calc.at:600 >$at_check_line_file
   41022 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   41023 at_status=$?
   41024 grep '^ *+' $at_stder1 >&2
   41025 grep -v '^ *+' $at_stder1 >$at_stderr
   41026 at_failed=false
   41027 echo stderr:; tee stderr <$at_stderr
   41028 $at_diff $at_devnull $at_stdout || at_failed=:
   41029 case $at_status in
   41030    77) echo 77 > $at_status_file
   41031             exit 77;;
   41032    0) ;;
   41033    *) echo "calc.at:600: exit code was $at_status, expected 0"
   41034       at_failed=:;;
   41035 esac
   41036 if $at_failed; then
   41037 
   41038   echo 1 > $at_status_file
   41039   exit 1
   41040 fi
   41041 
   41042 $at_traceon
   41043 
   41044 
   41045 # Normalize the observed and expected error messages, depending upon the
   41046 # options.
   41047 # 1. Remove the traces from observed.
   41048 sed '/^Starting/d
   41049 /^Entering/d
   41050 /^Stack/d
   41051 /^Reading/d
   41052 /^Reducing/d
   41053 /^Shifting/d
   41054 /^state/d
   41055 /^Cleanup:/d
   41056 /^Error:/d
   41057 /^Next/d
   41058 /^Discarding/d
   41059 / \$[0-9$]* = /d
   41060 /^yydestructor:/d' stderr >at-stderr
   41061 mv at-stderr stderr
   41062 # 2. Create the reference error message.
   41063 cat >expout <<'_ATEOF'
   41064 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   41065 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   41066 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   41067 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   41068 calc: error: 4444 != 1
   41069 _ATEOF
   41070 
   41071 # 3. If locations are not used, remove them.
   41072 sed 's/^[-0-9.]*: //' expout >at-expout
   41073 mv at-expout expout
   41074 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   41075 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   41076 mv at-expout expout
   41077 # 5. Check
   41078 $at_traceoff
   41079 echo "calc.at:600: cat stderr"
   41080 echo calc.at:600 >$at_check_line_file
   41081 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   41082 at_status=$?
   41083 grep '^ *+' $at_stder1 >&2
   41084 grep -v '^ *+' $at_stder1 >$at_stderr
   41085 at_failed=false
   41086 $at_diff $at_devnull $at_stderr || at_failed=:
   41087 $at_diff expout $at_stdout || at_failed=:
   41088 case $at_status in
   41089    77) echo 77 > $at_status_file
   41090             exit 77;;
   41091    0) ;;
   41092    *) echo "calc.at:600: exit code was $at_status, expected 0"
   41093       at_failed=:;;
   41094 esac
   41095 if $at_failed; then
   41096 
   41097   echo 1 > $at_status_file
   41098   exit 1
   41099 fi
   41100 
   41101 $at_traceon
   41102 
   41103 
   41104 
   41105 # The same, but this time exercising explicitly triggered syntax errors.
   41106 # POSIX says the look-ahead causing the error should not be discarded.
   41107 cat >input <<'_ATEOF'
   41108 (!) + (0 0) = 1
   41109 _ATEOF
   41110 
   41111 $at_traceoff
   41112 echo "calc.at:600: \$PREPARSER ./calc input"
   41113 echo calc.at:600 >$at_check_line_file
   41114 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   41115 at_status=$?
   41116 grep '^ *+' $at_stder1 >&2
   41117 grep -v '^ *+' $at_stder1 >$at_stderr
   41118 at_failed=false
   41119 echo stderr:; tee stderr <$at_stderr
   41120 $at_diff $at_devnull $at_stdout || at_failed=:
   41121 case $at_status in
   41122    77) echo 77 > $at_status_file
   41123             exit 77;;
   41124    0) ;;
   41125    *) echo "calc.at:600: exit code was $at_status, expected 0"
   41126       at_failed=:;;
   41127 esac
   41128 if $at_failed; then
   41129 
   41130   echo 1 > $at_status_file
   41131   exit 1
   41132 fi
   41133 
   41134 $at_traceon
   41135 
   41136 
   41137 # Normalize the observed and expected error messages, depending upon the
   41138 # options.
   41139 # 1. Remove the traces from observed.
   41140 sed '/^Starting/d
   41141 /^Entering/d
   41142 /^Stack/d
   41143 /^Reading/d
   41144 /^Reducing/d
   41145 /^Shifting/d
   41146 /^state/d
   41147 /^Cleanup:/d
   41148 /^Error:/d
   41149 /^Next/d
   41150 /^Discarding/d
   41151 / \$[0-9$]* = /d
   41152 /^yydestructor:/d' stderr >at-stderr
   41153 mv at-stderr stderr
   41154 # 2. Create the reference error message.
   41155 cat >expout <<'_ATEOF'
   41156 1.9: syntax error, unexpected number
   41157 calc: error: 2222 != 1
   41158 _ATEOF
   41159 
   41160 # 3. If locations are not used, remove them.
   41161 sed 's/^[-0-9.]*: //' expout >at-expout
   41162 mv at-expout expout
   41163 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   41164 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   41165 mv at-expout expout
   41166 # 5. Check
   41167 $at_traceoff
   41168 echo "calc.at:600: cat stderr"
   41169 echo calc.at:600 >$at_check_line_file
   41170 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   41171 at_status=$?
   41172 grep '^ *+' $at_stder1 >&2
   41173 grep -v '^ *+' $at_stder1 >$at_stderr
   41174 at_failed=false
   41175 $at_diff $at_devnull $at_stderr || at_failed=:
   41176 $at_diff expout $at_stdout || at_failed=:
   41177 case $at_status in
   41178    77) echo 77 > $at_status_file
   41179             exit 77;;
   41180    0) ;;
   41181    *) echo "calc.at:600: exit code was $at_status, expected 0"
   41182       at_failed=:;;
   41183 esac
   41184 if $at_failed; then
   41185 
   41186   echo 1 > $at_status_file
   41187   exit 1
   41188 fi
   41189 
   41190 $at_traceon
   41191 
   41192 
   41193 cat >input <<'_ATEOF'
   41194 (- *) + (0 0) = 1
   41195 _ATEOF
   41196 
   41197 $at_traceoff
   41198 echo "calc.at:600: \$PREPARSER ./calc input"
   41199 echo calc.at:600 >$at_check_line_file
   41200 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   41201 at_status=$?
   41202 grep '^ *+' $at_stder1 >&2
   41203 grep -v '^ *+' $at_stder1 >$at_stderr
   41204 at_failed=false
   41205 echo stderr:; tee stderr <$at_stderr
   41206 $at_diff $at_devnull $at_stdout || at_failed=:
   41207 case $at_status in
   41208    77) echo 77 > $at_status_file
   41209             exit 77;;
   41210    0) ;;
   41211    *) echo "calc.at:600: exit code was $at_status, expected 0"
   41212       at_failed=:;;
   41213 esac
   41214 if $at_failed; then
   41215 
   41216   echo 1 > $at_status_file
   41217   exit 1
   41218 fi
   41219 
   41220 $at_traceon
   41221 
   41222 
   41223 # Normalize the observed and expected error messages, depending upon the
   41224 # options.
   41225 # 1. Remove the traces from observed.
   41226 sed '/^Starting/d
   41227 /^Entering/d
   41228 /^Stack/d
   41229 /^Reading/d
   41230 /^Reducing/d
   41231 /^Shifting/d
   41232 /^state/d
   41233 /^Cleanup:/d
   41234 /^Error:/d
   41235 /^Next/d
   41236 /^Discarding/d
   41237 / \$[0-9$]* = /d
   41238 /^yydestructor:/d' stderr >at-stderr
   41239 mv at-stderr stderr
   41240 # 2. Create the reference error message.
   41241 cat >expout <<'_ATEOF'
   41242 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   41243 1.11: syntax error, unexpected number
   41244 calc: error: 2222 != 1
   41245 _ATEOF
   41246 
   41247 # 3. If locations are not used, remove them.
   41248 sed 's/^[-0-9.]*: //' expout >at-expout
   41249 mv at-expout expout
   41250 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   41251 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   41252 mv at-expout expout
   41253 # 5. Check
   41254 $at_traceoff
   41255 echo "calc.at:600: cat stderr"
   41256 echo calc.at:600 >$at_check_line_file
   41257 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   41258 at_status=$?
   41259 grep '^ *+' $at_stder1 >&2
   41260 grep -v '^ *+' $at_stder1 >$at_stderr
   41261 at_failed=false
   41262 $at_diff $at_devnull $at_stderr || at_failed=:
   41263 $at_diff expout $at_stdout || at_failed=:
   41264 case $at_status in
   41265    77) echo 77 > $at_status_file
   41266             exit 77;;
   41267    0) ;;
   41268    *) echo "calc.at:600: exit code was $at_status, expected 0"
   41269       at_failed=:;;
   41270 esac
   41271 if $at_failed; then
   41272 
   41273   echo 1 > $at_status_file
   41274   exit 1
   41275 fi
   41276 
   41277 $at_traceon
   41278 
   41279 
   41280 
   41281 
   41282 
   41283 
   41284 
   41285 
   41286 
   41287 
   41288 
   41289 
   41290 
   41291 
   41292 
   41293 
   41294 
   41295 
   41296 
   41297 
   41298 
   41299 
   41300 
   41301 
   41302       $at_traceoff
   41303       $at_times_p && times >$at_times_file
   41304     ) 5>&1 2>&1 | eval $at_tee_pipe
   41305     at_status=`cat $at_status_file`
   41306     ;;
   41307 
   41308   95 ) # 95. calc.at:601: Calculator %glr-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
   41309     at_setup_line='calc.at:601'
   41310     at_desc='Calculator %glr-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc'
   41311     $at_quiet $ECHO_N " 95: Calculator %glr-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc$ECHO_C"
   41312     at_xfail=no
   41313     (
   41314       echo "95. calc.at:601: testing ..."
   41315       $at_traceon
   41316 
   41317 
   41318 
   41319 
   41320 
   41321 
   41322 
   41323 
   41324 # Using yacc.c?
   41325 
   41326 
   41327 
   41328 
   41329 
   41330 
   41331 
   41332 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   41333 
   41334 # yyerror always sees the locations (when activated), except if
   41335 # yacc & pure & !param.
   41336 
   41337 
   41338 # The interface is pure: either because %pure-parser, or because we
   41339 # are using the C++ parsers.
   41340 
   41341 
   41342 
   41343 
   41344 
   41345 
   41346 
   41347 
   41348 
   41349 
   41350 
   41351 
   41352 cat >calc.y <<'_ATEOF'
   41353 %{
   41354 #ifdef HAVE_CONFIG_H
   41355 # include <config.h>
   41356   /* We don't need perfect functions for these tests. */
   41357 # undef malloc
   41358 # undef memcmp
   41359 # undef realloc
   41360 #endif
   41361 %}
   41362 
   41363 /* Infix notation calculator--calc */
   41364 %glr-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
   41365 
   41366 %{
   41367 #include <stdio.h>
   41368 
   41369 #include <stdlib.h>
   41370 #include <string.h>
   41371 #if HAVE_UNISTD_H
   41372 # include <unistd.h>
   41373 #else
   41374 # undef alarm
   41375 # define alarm(seconds) /* empty */
   41376 #endif
   41377 #include <ctype.h>
   41378 #define USE(Var)
   41379 
   41380 /* Exercise pre-prologue dependency to %union.  */
   41381 typedef int semantic_value;
   41382 
   41383 static semantic_value global_result = 0;
   41384 static int global_count = 0;
   41385 %}
   41386 
   41387 /* Exercise %union. */
   41388 %union
   41389 {
   41390   semantic_value ival;
   41391 };
   41392 
   41393 %{
   41394 static int power (int base, int exponent);
   41395 /* yyerror receives the location if:
   41396    - %location & %pure & %glr
   41397    - %location & %pure & %yacc & %parse-param. */
   41398 static void yyerror (
   41399 
   41400                      const char *s
   41401                      );
   41402 static int yylex (void);
   41403 static int get_char (void);
   41404 static void unget_char ( int c);
   41405 %}
   41406 
   41407 
   41408 
   41409 /* Bison Declarations */
   41410 %token CALC_EOF 0 "end of input"
   41411 %token <ival> NUM "number"
   41412 %type  <ival> exp
   41413 
   41414 %nonassoc '=' /* comparison	       */
   41415 %left '-' '+'
   41416 %left '*' '/'
   41417 %left NEG     /* negation--unary minus */
   41418 %right '^'    /* exponentiation        */
   41419 
   41420 /* Grammar follows */
   41421 %%
   41422 input:
   41423   line
   41424 | input line         {  }
   41425 ;
   41426 
   41427 line:
   41428   '\n'
   41429 | exp '\n'           { USE ($1); }
   41430 ;
   41431 
   41432 exp:
   41433   NUM                { $$ = $1;             }
   41434 | exp '=' exp
   41435   {
   41436     if ($1 != $3)
   41437       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   41438     $$ = $1;
   41439   }
   41440 | exp '+' exp        { $$ = $1 + $3;        }
   41441 | exp '-' exp        { $$ = $1 - $3;        }
   41442 | exp '*' exp        { $$ = $1 * $3;        }
   41443 | exp '/' exp        { $$ = $1 / $3;        }
   41444 | '-' exp  %prec NEG { $$ = -$2;            }
   41445 | exp '^' exp        { $$ = power ($1, $3); }
   41446 | '(' exp ')'        { $$ = $2;             }
   41447 | '(' error ')'      { $$ = 1111;           }
   41448 | '!'                { $$ = 0; YYERROR;     }
   41449 | '-' error          { $$ = 0; YYERROR;     }
   41450 ;
   41451 %%
   41452 /* The input.  */
   41453 static FILE *input;
   41454 
   41455 static void
   41456 yyerror (
   41457 
   41458          const char *s)
   41459 {
   41460 
   41461 
   41462   fprintf (stderr, "%d.%d",
   41463            (yylloc).first_line, (yylloc).first_column);
   41464   if ((yylloc).first_line != (yylloc).last_line)
   41465     fprintf (stderr, "-%d.%d",
   41466 	     (yylloc).last_line,  (yylloc).last_column - 1);
   41467   else if ((yylloc).first_column != (yylloc).last_column - 1)
   41468     fprintf (stderr, "-%d",
   41469 	     (yylloc).last_column - 1);
   41470   fprintf (stderr, ": ");
   41471   fprintf (stderr, "%s\n", s);
   41472 }
   41473 
   41474 
   41475 
   41476 static YYLTYPE last_yylloc;
   41477 
   41478 static int
   41479 get_char (void)
   41480 {
   41481   int res = getc (input);
   41482   ;
   41483 
   41484   last_yylloc = (yylloc);
   41485   if (res == '\n')
   41486     {
   41487       (yylloc).last_line++;
   41488       (yylloc).last_column = 0;
   41489     }
   41490   else
   41491     (yylloc).last_column++;
   41492 
   41493   return res;
   41494 }
   41495 
   41496 
   41497 static void
   41498 unget_char ( int c)
   41499 {
   41500   ;
   41501 
   41502   /* Wrong when C == `\n'. */
   41503   (yylloc) = last_yylloc;
   41504 
   41505   ungetc (c, input);
   41506 }
   41507 
   41508 static int
   41509 read_signed_integer (void)
   41510 {
   41511   int c = get_char ();
   41512   int sign = 1;
   41513   int n = 0;
   41514 
   41515   ;
   41516   if (c == '-')
   41517     {
   41518       c = get_char ();
   41519       sign = -1;
   41520     }
   41521 
   41522   while (isdigit (c))
   41523     {
   41524       n = 10 * n + (c - '0');
   41525       c = get_char ();
   41526     }
   41527 
   41528   unget_char ( c);
   41529 
   41530   return sign * n;
   41531 }
   41532 
   41533 
   41534 
   41535 /*---------------------------------------------------------------.
   41536 | Lexical analyzer returns an integer on the stack and the token |
   41537 | NUM, or the ASCII character read if not a number.  Skips all   |
   41538 | blanks and tabs, returns 0 for EOF.                            |
   41539 `---------------------------------------------------------------*/
   41540 
   41541 static int
   41542 yylex (void)
   41543 {
   41544   static int init = 1;
   41545   int c;
   41546 
   41547   if (init)
   41548     {
   41549       init = 0;
   41550 
   41551       (yylloc).last_column = 0;
   41552       (yylloc).last_line = 1;
   41553 
   41554     }
   41555 
   41556 
   41557  (yylloc).first_column = (yylloc).last_column;
   41558   (yylloc).first_line   = (yylloc).last_line;
   41559 
   41560 
   41561   /* Skip white space.  */
   41562   while ((c = get_char ()) == ' ' || c == '\t')
   41563     {
   41564      (yylloc).first_column = (yylloc).last_column;
   41565       (yylloc).first_line   = (yylloc).last_line;
   41566 
   41567     }
   41568 
   41569   /* process numbers   */
   41570   if (c == '.' || isdigit (c))
   41571     {
   41572       unget_char ( c);
   41573       (yylval).ival = read_signed_integer ();
   41574       return NUM;
   41575     }
   41576 
   41577   /* Return end-of-file.  */
   41578   if (c == EOF)
   41579     return CALC_EOF;
   41580 
   41581   /* Return single chars. */
   41582   return c;
   41583 }
   41584 
   41585 static int
   41586 power (int base, int exponent)
   41587 {
   41588   int res = 1;
   41589   if (exponent < 0)
   41590     exit (3);
   41591   for (/* Niente */; exponent; --exponent)
   41592     res *= base;
   41593   return res;
   41594 }
   41595 
   41596 
   41597 int
   41598 main (int argc, const char **argv)
   41599 {
   41600   semantic_value result = 0;
   41601   int count = 0;
   41602   int status;
   41603 
   41604   /* This used to be alarm (10), but that isn't enough time for
   41605      a July 1995 vintage DEC Alphastation 200 4/100 system,
   41606      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   41607   alarm (100);
   41608 
   41609   if (argc == 2)
   41610     input = fopen (argv[1], "r");
   41611   else
   41612     input = stdin;
   41613 
   41614   if (!input)
   41615     {
   41616       perror (argv[1]);
   41617       return 3;
   41618     }
   41619 
   41620   yydebug = 1;
   41621   status = yyparse ();
   41622   if (global_result != result)
   41623     abort ();
   41624   if (global_count != count)
   41625     abort ();
   41626   return status;
   41627 }
   41628 _ATEOF
   41629 
   41630 
   41631 
   41632 
   41633 
   41634 $at_traceoff
   41635 echo "calc.at:601: bison -o calc.c calc.y"
   41636 echo calc.at:601 >$at_check_line_file
   41637 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   41638 at_status=$?
   41639 grep '^ *+' $at_stder1 >&2
   41640 grep -v '^ *+' $at_stder1 >$at_stderr
   41641 at_failed=false
   41642 $at_diff $at_devnull $at_stderr || at_failed=:
   41643 $at_diff $at_devnull $at_stdout || at_failed=:
   41644 case $at_status in
   41645    77) echo 77 > $at_status_file
   41646             exit 77;;
   41647    0) ;;
   41648    *) echo "calc.at:601: exit code was $at_status, expected 0"
   41649       at_failed=:;;
   41650 esac
   41651 if $at_failed; then
   41652 
   41653   echo 1 > $at_status_file
   41654   exit 1
   41655 fi
   41656 
   41657 $at_traceon
   41658 
   41659    $at_traceoff
   41660 echo "calc.at:601: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   41661 echo calc.at:601 >$at_check_line_file
   41662 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   41663 at_status=$?
   41664 grep '^ *+' $at_stder1 >&2
   41665 grep -v '^ *+' $at_stder1 >$at_stderr
   41666 at_failed=false
   41667 echo stderr:; cat $at_stderr
   41668 echo stdout:; cat $at_stdout
   41669 case $at_status in
   41670    77) echo 77 > $at_status_file
   41671             exit 77;;
   41672    0) ;;
   41673    *) echo "calc.at:601: exit code was $at_status, expected 0"
   41674       at_failed=:;;
   41675 esac
   41676 if $at_failed; then
   41677 
   41678   echo 1 > $at_status_file
   41679   exit 1
   41680 fi
   41681 
   41682 $at_traceon
   41683 
   41684 
   41685 # Test the priorities.
   41686 cat >input <<'_ATEOF'
   41687 1 + 2 * 3 = 7
   41688 1 + 2 * -3 = -5
   41689 
   41690 -1^2 = -1
   41691 (-1)^2 = 1
   41692 
   41693 ---1 = -1
   41694 
   41695 1 - 2 - 3 = -4
   41696 1 - (2 - 3) = 2
   41697 
   41698 2^2^3 = 256
   41699 (2^2)^3 = 64
   41700 _ATEOF
   41701 
   41702 $at_traceoff
   41703 echo "calc.at:601: \$PREPARSER ./calc input"
   41704 echo calc.at:601 >$at_check_line_file
   41705 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   41706 at_status=$?
   41707 grep '^ *+' $at_stder1 >&2
   41708 grep -v '^ *+' $at_stder1 >$at_stderr
   41709 at_failed=false
   41710 echo stderr:; tee stderr <$at_stderr
   41711 $at_diff $at_devnull $at_stdout || at_failed=:
   41712 case $at_status in
   41713    77) echo 77 > $at_status_file
   41714             exit 77;;
   41715    0) ;;
   41716    *) echo "calc.at:601: exit code was $at_status, expected 0"
   41717       at_failed=:;;
   41718 esac
   41719 if $at_failed; then
   41720 
   41721   echo 1 > $at_status_file
   41722   exit 1
   41723 fi
   41724 
   41725 $at_traceon
   41726 
   41727 
   41728 
   41729 # Some syntax errors.
   41730 cat >input <<'_ATEOF'
   41731 0 0
   41732 _ATEOF
   41733 
   41734 $at_traceoff
   41735 echo "calc.at:601: \$PREPARSER ./calc input"
   41736 echo calc.at:601 >$at_check_line_file
   41737 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   41738 at_status=$?
   41739 grep '^ *+' $at_stder1 >&2
   41740 grep -v '^ *+' $at_stder1 >$at_stderr
   41741 at_failed=false
   41742 echo stderr:; tee stderr <$at_stderr
   41743 $at_diff $at_devnull $at_stdout || at_failed=:
   41744 case $at_status in
   41745    77) echo 77 > $at_status_file
   41746             exit 77;;
   41747    1) ;;
   41748    *) echo "calc.at:601: exit code was $at_status, expected 1"
   41749       at_failed=:;;
   41750 esac
   41751 if $at_failed; then
   41752 
   41753   echo 1 > $at_status_file
   41754   exit 1
   41755 fi
   41756 
   41757 $at_traceon
   41758 
   41759 
   41760 # Normalize the observed and expected error messages, depending upon the
   41761 # options.
   41762 # 1. Remove the traces from observed.
   41763 sed '/^Starting/d
   41764 /^Entering/d
   41765 /^Stack/d
   41766 /^Reading/d
   41767 /^Reducing/d
   41768 /^Shifting/d
   41769 /^state/d
   41770 /^Cleanup:/d
   41771 /^Error:/d
   41772 /^Next/d
   41773 /^Discarding/d
   41774 / \$[0-9$]* = /d
   41775 /^yydestructor:/d' stderr >at-stderr
   41776 mv at-stderr stderr
   41777 # 2. Create the reference error message.
   41778 cat >expout <<'_ATEOF'
   41779 1.2: syntax error, unexpected number
   41780 _ATEOF
   41781 
   41782 # 3. If locations are not used, remove them.
   41783 
   41784 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   41785 
   41786 # 5. Check
   41787 $at_traceoff
   41788 echo "calc.at:601: cat stderr"
   41789 echo calc.at:601 >$at_check_line_file
   41790 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   41791 at_status=$?
   41792 grep '^ *+' $at_stder1 >&2
   41793 grep -v '^ *+' $at_stder1 >$at_stderr
   41794 at_failed=false
   41795 $at_diff $at_devnull $at_stderr || at_failed=:
   41796 $at_diff expout $at_stdout || at_failed=:
   41797 case $at_status in
   41798    77) echo 77 > $at_status_file
   41799             exit 77;;
   41800    0) ;;
   41801    *) echo "calc.at:601: exit code was $at_status, expected 0"
   41802       at_failed=:;;
   41803 esac
   41804 if $at_failed; then
   41805 
   41806   echo 1 > $at_status_file
   41807   exit 1
   41808 fi
   41809 
   41810 $at_traceon
   41811 
   41812 
   41813 cat >input <<'_ATEOF'
   41814 1//2
   41815 _ATEOF
   41816 
   41817 $at_traceoff
   41818 echo "calc.at:601: \$PREPARSER ./calc input"
   41819 echo calc.at:601 >$at_check_line_file
   41820 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   41821 at_status=$?
   41822 grep '^ *+' $at_stder1 >&2
   41823 grep -v '^ *+' $at_stder1 >$at_stderr
   41824 at_failed=false
   41825 echo stderr:; tee stderr <$at_stderr
   41826 $at_diff $at_devnull $at_stdout || at_failed=:
   41827 case $at_status in
   41828    77) echo 77 > $at_status_file
   41829             exit 77;;
   41830    1) ;;
   41831    *) echo "calc.at:601: exit code was $at_status, expected 1"
   41832       at_failed=:;;
   41833 esac
   41834 if $at_failed; then
   41835 
   41836   echo 1 > $at_status_file
   41837   exit 1
   41838 fi
   41839 
   41840 $at_traceon
   41841 
   41842 
   41843 # Normalize the observed and expected error messages, depending upon the
   41844 # options.
   41845 # 1. Remove the traces from observed.
   41846 sed '/^Starting/d
   41847 /^Entering/d
   41848 /^Stack/d
   41849 /^Reading/d
   41850 /^Reducing/d
   41851 /^Shifting/d
   41852 /^state/d
   41853 /^Cleanup:/d
   41854 /^Error:/d
   41855 /^Next/d
   41856 /^Discarding/d
   41857 / \$[0-9$]* = /d
   41858 /^yydestructor:/d' stderr >at-stderr
   41859 mv at-stderr stderr
   41860 # 2. Create the reference error message.
   41861 cat >expout <<'_ATEOF'
   41862 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   41863 _ATEOF
   41864 
   41865 # 3. If locations are not used, remove them.
   41866 
   41867 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   41868 
   41869 # 5. Check
   41870 $at_traceoff
   41871 echo "calc.at:601: cat stderr"
   41872 echo calc.at:601 >$at_check_line_file
   41873 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   41874 at_status=$?
   41875 grep '^ *+' $at_stder1 >&2
   41876 grep -v '^ *+' $at_stder1 >$at_stderr
   41877 at_failed=false
   41878 $at_diff $at_devnull $at_stderr || at_failed=:
   41879 $at_diff expout $at_stdout || at_failed=:
   41880 case $at_status in
   41881    77) echo 77 > $at_status_file
   41882             exit 77;;
   41883    0) ;;
   41884    *) echo "calc.at:601: exit code was $at_status, expected 0"
   41885       at_failed=:;;
   41886 esac
   41887 if $at_failed; then
   41888 
   41889   echo 1 > $at_status_file
   41890   exit 1
   41891 fi
   41892 
   41893 $at_traceon
   41894 
   41895 
   41896 cat >input <<'_ATEOF'
   41897 error
   41898 _ATEOF
   41899 
   41900 $at_traceoff
   41901 echo "calc.at:601: \$PREPARSER ./calc input"
   41902 echo calc.at:601 >$at_check_line_file
   41903 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   41904 at_status=$?
   41905 grep '^ *+' $at_stder1 >&2
   41906 grep -v '^ *+' $at_stder1 >$at_stderr
   41907 at_failed=false
   41908 echo stderr:; tee stderr <$at_stderr
   41909 $at_diff $at_devnull $at_stdout || at_failed=:
   41910 case $at_status in
   41911    77) echo 77 > $at_status_file
   41912             exit 77;;
   41913    1) ;;
   41914    *) echo "calc.at:601: exit code was $at_status, expected 1"
   41915       at_failed=:;;
   41916 esac
   41917 if $at_failed; then
   41918 
   41919   echo 1 > $at_status_file
   41920   exit 1
   41921 fi
   41922 
   41923 $at_traceon
   41924 
   41925 
   41926 # Normalize the observed and expected error messages, depending upon the
   41927 # options.
   41928 # 1. Remove the traces from observed.
   41929 sed '/^Starting/d
   41930 /^Entering/d
   41931 /^Stack/d
   41932 /^Reading/d
   41933 /^Reducing/d
   41934 /^Shifting/d
   41935 /^state/d
   41936 /^Cleanup:/d
   41937 /^Error:/d
   41938 /^Next/d
   41939 /^Discarding/d
   41940 / \$[0-9$]* = /d
   41941 /^yydestructor:/d' stderr >at-stderr
   41942 mv at-stderr stderr
   41943 # 2. Create the reference error message.
   41944 cat >expout <<'_ATEOF'
   41945 1.0: syntax error, unexpected $undefined
   41946 _ATEOF
   41947 
   41948 # 3. If locations are not used, remove them.
   41949 
   41950 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   41951 
   41952 # 5. Check
   41953 $at_traceoff
   41954 echo "calc.at:601: cat stderr"
   41955 echo calc.at:601 >$at_check_line_file
   41956 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   41957 at_status=$?
   41958 grep '^ *+' $at_stder1 >&2
   41959 grep -v '^ *+' $at_stder1 >$at_stderr
   41960 at_failed=false
   41961 $at_diff $at_devnull $at_stderr || at_failed=:
   41962 $at_diff expout $at_stdout || at_failed=:
   41963 case $at_status in
   41964    77) echo 77 > $at_status_file
   41965             exit 77;;
   41966    0) ;;
   41967    *) echo "calc.at:601: exit code was $at_status, expected 0"
   41968       at_failed=:;;
   41969 esac
   41970 if $at_failed; then
   41971 
   41972   echo 1 > $at_status_file
   41973   exit 1
   41974 fi
   41975 
   41976 $at_traceon
   41977 
   41978 
   41979 cat >input <<'_ATEOF'
   41980 1 = 2 = 3
   41981 _ATEOF
   41982 
   41983 $at_traceoff
   41984 echo "calc.at:601: \$PREPARSER ./calc input"
   41985 echo calc.at:601 >$at_check_line_file
   41986 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   41987 at_status=$?
   41988 grep '^ *+' $at_stder1 >&2
   41989 grep -v '^ *+' $at_stder1 >$at_stderr
   41990 at_failed=false
   41991 echo stderr:; tee stderr <$at_stderr
   41992 $at_diff $at_devnull $at_stdout || at_failed=:
   41993 case $at_status in
   41994    77) echo 77 > $at_status_file
   41995             exit 77;;
   41996    1) ;;
   41997    *) echo "calc.at:601: exit code was $at_status, expected 1"
   41998       at_failed=:;;
   41999 esac
   42000 if $at_failed; then
   42001 
   42002   echo 1 > $at_status_file
   42003   exit 1
   42004 fi
   42005 
   42006 $at_traceon
   42007 
   42008 
   42009 # Normalize the observed and expected error messages, depending upon the
   42010 # options.
   42011 # 1. Remove the traces from observed.
   42012 sed '/^Starting/d
   42013 /^Entering/d
   42014 /^Stack/d
   42015 /^Reading/d
   42016 /^Reducing/d
   42017 /^Shifting/d
   42018 /^state/d
   42019 /^Cleanup:/d
   42020 /^Error:/d
   42021 /^Next/d
   42022 /^Discarding/d
   42023 / \$[0-9$]* = /d
   42024 /^yydestructor:/d' stderr >at-stderr
   42025 mv at-stderr stderr
   42026 # 2. Create the reference error message.
   42027 cat >expout <<'_ATEOF'
   42028 1.6: syntax error, unexpected '='
   42029 _ATEOF
   42030 
   42031 # 3. If locations are not used, remove them.
   42032 
   42033 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   42034 
   42035 # 5. Check
   42036 $at_traceoff
   42037 echo "calc.at:601: cat stderr"
   42038 echo calc.at:601 >$at_check_line_file
   42039 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   42040 at_status=$?
   42041 grep '^ *+' $at_stder1 >&2
   42042 grep -v '^ *+' $at_stder1 >$at_stderr
   42043 at_failed=false
   42044 $at_diff $at_devnull $at_stderr || at_failed=:
   42045 $at_diff expout $at_stdout || at_failed=:
   42046 case $at_status in
   42047    77) echo 77 > $at_status_file
   42048             exit 77;;
   42049    0) ;;
   42050    *) echo "calc.at:601: exit code was $at_status, expected 0"
   42051       at_failed=:;;
   42052 esac
   42053 if $at_failed; then
   42054 
   42055   echo 1 > $at_status_file
   42056   exit 1
   42057 fi
   42058 
   42059 $at_traceon
   42060 
   42061 
   42062 cat >input <<'_ATEOF'
   42063 
   42064 +1
   42065 _ATEOF
   42066 
   42067 $at_traceoff
   42068 echo "calc.at:601: \$PREPARSER ./calc input"
   42069 echo calc.at:601 >$at_check_line_file
   42070 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   42071 at_status=$?
   42072 grep '^ *+' $at_stder1 >&2
   42073 grep -v '^ *+' $at_stder1 >$at_stderr
   42074 at_failed=false
   42075 echo stderr:; tee stderr <$at_stderr
   42076 $at_diff $at_devnull $at_stdout || at_failed=:
   42077 case $at_status in
   42078    77) echo 77 > $at_status_file
   42079             exit 77;;
   42080    1) ;;
   42081    *) echo "calc.at:601: exit code was $at_status, expected 1"
   42082       at_failed=:;;
   42083 esac
   42084 if $at_failed; then
   42085 
   42086   echo 1 > $at_status_file
   42087   exit 1
   42088 fi
   42089 
   42090 $at_traceon
   42091 
   42092 
   42093 # Normalize the observed and expected error messages, depending upon the
   42094 # options.
   42095 # 1. Remove the traces from observed.
   42096 sed '/^Starting/d
   42097 /^Entering/d
   42098 /^Stack/d
   42099 /^Reading/d
   42100 /^Reducing/d
   42101 /^Shifting/d
   42102 /^state/d
   42103 /^Cleanup:/d
   42104 /^Error:/d
   42105 /^Next/d
   42106 /^Discarding/d
   42107 / \$[0-9$]* = /d
   42108 /^yydestructor:/d' stderr >at-stderr
   42109 mv at-stderr stderr
   42110 # 2. Create the reference error message.
   42111 cat >expout <<'_ATEOF'
   42112 2.0: syntax error, unexpected '+'
   42113 _ATEOF
   42114 
   42115 # 3. If locations are not used, remove them.
   42116 
   42117 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   42118 
   42119 # 5. Check
   42120 $at_traceoff
   42121 echo "calc.at:601: cat stderr"
   42122 echo calc.at:601 >$at_check_line_file
   42123 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   42124 at_status=$?
   42125 grep '^ *+' $at_stder1 >&2
   42126 grep -v '^ *+' $at_stder1 >$at_stderr
   42127 at_failed=false
   42128 $at_diff $at_devnull $at_stderr || at_failed=:
   42129 $at_diff expout $at_stdout || at_failed=:
   42130 case $at_status in
   42131    77) echo 77 > $at_status_file
   42132             exit 77;;
   42133    0) ;;
   42134    *) echo "calc.at:601: exit code was $at_status, expected 0"
   42135       at_failed=:;;
   42136 esac
   42137 if $at_failed; then
   42138 
   42139   echo 1 > $at_status_file
   42140   exit 1
   42141 fi
   42142 
   42143 $at_traceon
   42144 
   42145 
   42146 # Exercise error messages with EOF: work on an empty file.
   42147 $at_traceoff
   42148 echo "calc.at:601: \$PREPARSER ./calc /dev/null"
   42149 echo calc.at:601 >$at_check_line_file
   42150 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   42151 at_status=$?
   42152 grep '^ *+' $at_stder1 >&2
   42153 grep -v '^ *+' $at_stder1 >$at_stderr
   42154 at_failed=false
   42155 echo stderr:; tee stderr <$at_stderr
   42156 $at_diff $at_devnull $at_stdout || at_failed=:
   42157 case $at_status in
   42158    77) echo 77 > $at_status_file
   42159             exit 77;;
   42160    1) ;;
   42161    *) echo "calc.at:601: exit code was $at_status, expected 1"
   42162       at_failed=:;;
   42163 esac
   42164 if $at_failed; then
   42165 
   42166   echo 1 > $at_status_file
   42167   exit 1
   42168 fi
   42169 
   42170 $at_traceon
   42171 
   42172 
   42173 # Normalize the observed and expected error messages, depending upon the
   42174 # options.
   42175 # 1. Remove the traces from observed.
   42176 sed '/^Starting/d
   42177 /^Entering/d
   42178 /^Stack/d
   42179 /^Reading/d
   42180 /^Reducing/d
   42181 /^Shifting/d
   42182 /^state/d
   42183 /^Cleanup:/d
   42184 /^Error:/d
   42185 /^Next/d
   42186 /^Discarding/d
   42187 / \$[0-9$]* = /d
   42188 /^yydestructor:/d' stderr >at-stderr
   42189 mv at-stderr stderr
   42190 # 2. Create the reference error message.
   42191 cat >expout <<'_ATEOF'
   42192 1.0: syntax error, unexpected end of input
   42193 _ATEOF
   42194 
   42195 # 3. If locations are not used, remove them.
   42196 
   42197 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   42198 
   42199 # 5. Check
   42200 $at_traceoff
   42201 echo "calc.at:601: cat stderr"
   42202 echo calc.at:601 >$at_check_line_file
   42203 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   42204 at_status=$?
   42205 grep '^ *+' $at_stder1 >&2
   42206 grep -v '^ *+' $at_stder1 >$at_stderr
   42207 at_failed=false
   42208 $at_diff $at_devnull $at_stderr || at_failed=:
   42209 $at_diff expout $at_stdout || at_failed=:
   42210 case $at_status in
   42211    77) echo 77 > $at_status_file
   42212             exit 77;;
   42213    0) ;;
   42214    *) echo "calc.at:601: exit code was $at_status, expected 0"
   42215       at_failed=:;;
   42216 esac
   42217 if $at_failed; then
   42218 
   42219   echo 1 > $at_status_file
   42220   exit 1
   42221 fi
   42222 
   42223 $at_traceon
   42224 
   42225 
   42226 
   42227 # Exercise the error token: without it, we die at the first error,
   42228 # hence be sure to
   42229 #
   42230 # - have several errors which exercise different shift/discardings
   42231 #   - (): nothing to pop, nothing to discard
   42232 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   42233 #   - (* * *): nothing to pop, a lot to discard
   42234 #   - (1 + 2 * *): some to pop and discard
   42235 #
   42236 # - test the action associated to `error'
   42237 #
   42238 # - check the look-ahead that triggers an error is not discarded
   42239 #   when we enter error recovery.  Below, the look-ahead causing the
   42240 #   first error is ")", which is needed to recover from the error and
   42241 #   produce the "0" that triggers the "0 != 1" error.
   42242 #
   42243 cat >input <<'_ATEOF'
   42244 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   42245 _ATEOF
   42246 
   42247 $at_traceoff
   42248 echo "calc.at:601: \$PREPARSER ./calc input"
   42249 echo calc.at:601 >$at_check_line_file
   42250 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   42251 at_status=$?
   42252 grep '^ *+' $at_stder1 >&2
   42253 grep -v '^ *+' $at_stder1 >$at_stderr
   42254 at_failed=false
   42255 echo stderr:; tee stderr <$at_stderr
   42256 $at_diff $at_devnull $at_stdout || at_failed=:
   42257 case $at_status in
   42258    77) echo 77 > $at_status_file
   42259             exit 77;;
   42260    0) ;;
   42261    *) echo "calc.at:601: exit code was $at_status, expected 0"
   42262       at_failed=:;;
   42263 esac
   42264 if $at_failed; then
   42265 
   42266   echo 1 > $at_status_file
   42267   exit 1
   42268 fi
   42269 
   42270 $at_traceon
   42271 
   42272 
   42273 # Normalize the observed and expected error messages, depending upon the
   42274 # options.
   42275 # 1. Remove the traces from observed.
   42276 sed '/^Starting/d
   42277 /^Entering/d
   42278 /^Stack/d
   42279 /^Reading/d
   42280 /^Reducing/d
   42281 /^Shifting/d
   42282 /^state/d
   42283 /^Cleanup:/d
   42284 /^Error:/d
   42285 /^Next/d
   42286 /^Discarding/d
   42287 / \$[0-9$]* = /d
   42288 /^yydestructor:/d' stderr >at-stderr
   42289 mv at-stderr stderr
   42290 # 2. Create the reference error message.
   42291 cat >expout <<'_ATEOF'
   42292 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   42293 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   42294 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   42295 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   42296 calc: error: 4444 != 1
   42297 _ATEOF
   42298 
   42299 # 3. If locations are not used, remove them.
   42300 
   42301 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   42302 
   42303 # 5. Check
   42304 $at_traceoff
   42305 echo "calc.at:601: cat stderr"
   42306 echo calc.at:601 >$at_check_line_file
   42307 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   42308 at_status=$?
   42309 grep '^ *+' $at_stder1 >&2
   42310 grep -v '^ *+' $at_stder1 >$at_stderr
   42311 at_failed=false
   42312 $at_diff $at_devnull $at_stderr || at_failed=:
   42313 $at_diff expout $at_stdout || at_failed=:
   42314 case $at_status in
   42315    77) echo 77 > $at_status_file
   42316             exit 77;;
   42317    0) ;;
   42318    *) echo "calc.at:601: exit code was $at_status, expected 0"
   42319       at_failed=:;;
   42320 esac
   42321 if $at_failed; then
   42322 
   42323   echo 1 > $at_status_file
   42324   exit 1
   42325 fi
   42326 
   42327 $at_traceon
   42328 
   42329 
   42330 
   42331 # The same, but this time exercising explicitly triggered syntax errors.
   42332 # POSIX says the look-ahead causing the error should not be discarded.
   42333 cat >input <<'_ATEOF'
   42334 (!) + (0 0) = 1
   42335 _ATEOF
   42336 
   42337 $at_traceoff
   42338 echo "calc.at:601: \$PREPARSER ./calc input"
   42339 echo calc.at:601 >$at_check_line_file
   42340 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   42341 at_status=$?
   42342 grep '^ *+' $at_stder1 >&2
   42343 grep -v '^ *+' $at_stder1 >$at_stderr
   42344 at_failed=false
   42345 echo stderr:; tee stderr <$at_stderr
   42346 $at_diff $at_devnull $at_stdout || at_failed=:
   42347 case $at_status in
   42348    77) echo 77 > $at_status_file
   42349             exit 77;;
   42350    0) ;;
   42351    *) echo "calc.at:601: exit code was $at_status, expected 0"
   42352       at_failed=:;;
   42353 esac
   42354 if $at_failed; then
   42355 
   42356   echo 1 > $at_status_file
   42357   exit 1
   42358 fi
   42359 
   42360 $at_traceon
   42361 
   42362 
   42363 # Normalize the observed and expected error messages, depending upon the
   42364 # options.
   42365 # 1. Remove the traces from observed.
   42366 sed '/^Starting/d
   42367 /^Entering/d
   42368 /^Stack/d
   42369 /^Reading/d
   42370 /^Reducing/d
   42371 /^Shifting/d
   42372 /^state/d
   42373 /^Cleanup:/d
   42374 /^Error:/d
   42375 /^Next/d
   42376 /^Discarding/d
   42377 / \$[0-9$]* = /d
   42378 /^yydestructor:/d' stderr >at-stderr
   42379 mv at-stderr stderr
   42380 # 2. Create the reference error message.
   42381 cat >expout <<'_ATEOF'
   42382 1.9: syntax error, unexpected number
   42383 calc: error: 2222 != 1
   42384 _ATEOF
   42385 
   42386 # 3. If locations are not used, remove them.
   42387 
   42388 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   42389 
   42390 # 5. Check
   42391 $at_traceoff
   42392 echo "calc.at:601: cat stderr"
   42393 echo calc.at:601 >$at_check_line_file
   42394 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   42395 at_status=$?
   42396 grep '^ *+' $at_stder1 >&2
   42397 grep -v '^ *+' $at_stder1 >$at_stderr
   42398 at_failed=false
   42399 $at_diff $at_devnull $at_stderr || at_failed=:
   42400 $at_diff expout $at_stdout || at_failed=:
   42401 case $at_status in
   42402    77) echo 77 > $at_status_file
   42403             exit 77;;
   42404    0) ;;
   42405    *) echo "calc.at:601: exit code was $at_status, expected 0"
   42406       at_failed=:;;
   42407 esac
   42408 if $at_failed; then
   42409 
   42410   echo 1 > $at_status_file
   42411   exit 1
   42412 fi
   42413 
   42414 $at_traceon
   42415 
   42416 
   42417 cat >input <<'_ATEOF'
   42418 (- *) + (0 0) = 1
   42419 _ATEOF
   42420 
   42421 $at_traceoff
   42422 echo "calc.at:601: \$PREPARSER ./calc input"
   42423 echo calc.at:601 >$at_check_line_file
   42424 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   42425 at_status=$?
   42426 grep '^ *+' $at_stder1 >&2
   42427 grep -v '^ *+' $at_stder1 >$at_stderr
   42428 at_failed=false
   42429 echo stderr:; tee stderr <$at_stderr
   42430 $at_diff $at_devnull $at_stdout || at_failed=:
   42431 case $at_status in
   42432    77) echo 77 > $at_status_file
   42433             exit 77;;
   42434    0) ;;
   42435    *) echo "calc.at:601: exit code was $at_status, expected 0"
   42436       at_failed=:;;
   42437 esac
   42438 if $at_failed; then
   42439 
   42440   echo 1 > $at_status_file
   42441   exit 1
   42442 fi
   42443 
   42444 $at_traceon
   42445 
   42446 
   42447 # Normalize the observed and expected error messages, depending upon the
   42448 # options.
   42449 # 1. Remove the traces from observed.
   42450 sed '/^Starting/d
   42451 /^Entering/d
   42452 /^Stack/d
   42453 /^Reading/d
   42454 /^Reducing/d
   42455 /^Shifting/d
   42456 /^state/d
   42457 /^Cleanup:/d
   42458 /^Error:/d
   42459 /^Next/d
   42460 /^Discarding/d
   42461 / \$[0-9$]* = /d
   42462 /^yydestructor:/d' stderr >at-stderr
   42463 mv at-stderr stderr
   42464 # 2. Create the reference error message.
   42465 cat >expout <<'_ATEOF'
   42466 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   42467 1.11: syntax error, unexpected number
   42468 calc: error: 2222 != 1
   42469 _ATEOF
   42470 
   42471 # 3. If locations are not used, remove them.
   42472 
   42473 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   42474 
   42475 # 5. Check
   42476 $at_traceoff
   42477 echo "calc.at:601: cat stderr"
   42478 echo calc.at:601 >$at_check_line_file
   42479 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   42480 at_status=$?
   42481 grep '^ *+' $at_stder1 >&2
   42482 grep -v '^ *+' $at_stder1 >$at_stderr
   42483 at_failed=false
   42484 $at_diff $at_devnull $at_stderr || at_failed=:
   42485 $at_diff expout $at_stdout || at_failed=:
   42486 case $at_status in
   42487    77) echo 77 > $at_status_file
   42488             exit 77;;
   42489    0) ;;
   42490    *) echo "calc.at:601: exit code was $at_status, expected 0"
   42491       at_failed=:;;
   42492 esac
   42493 if $at_failed; then
   42494 
   42495   echo 1 > $at_status_file
   42496   exit 1
   42497 fi
   42498 
   42499 $at_traceon
   42500 
   42501 
   42502 
   42503 
   42504 
   42505 
   42506 
   42507 
   42508 
   42509 
   42510 
   42511 
   42512 
   42513 
   42514 
   42515 
   42516 
   42517 
   42518 
   42519 
   42520 
   42521 
   42522 
   42523 
   42524       $at_traceoff
   42525       $at_times_p && times >$at_times_file
   42526     ) 5>&1 2>&1 | eval $at_tee_pipe
   42527     at_status=`cat $at_status_file`
   42528     ;;
   42529 
   42530   96 ) # 96. calc.at:603: Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
   42531     at_setup_line='calc.at:603'
   42532     at_desc='Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc'
   42533     $at_quiet $ECHO_N " 96: Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc$ECHO_C"
   42534     at_xfail=no
   42535     (
   42536       echo "96. calc.at:603: testing ..."
   42537       $at_traceon
   42538 
   42539 
   42540 
   42541 
   42542 
   42543 
   42544 
   42545 
   42546 # Using yacc.c?
   42547 
   42548 
   42549 
   42550 
   42551 
   42552 
   42553 
   42554 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   42555 
   42556 # yyerror always sees the locations (when activated), except if
   42557 # yacc & pure & !param.
   42558 
   42559 
   42560 # The interface is pure: either because %pure-parser, or because we
   42561 # are using the C++ parsers.
   42562 
   42563 
   42564 
   42565 
   42566 
   42567 
   42568 
   42569 
   42570 
   42571 
   42572 
   42573 
   42574 cat >calc.y <<'_ATEOF'
   42575 %{
   42576 #ifdef HAVE_CONFIG_H
   42577 # include <config.h>
   42578   /* We don't need perfect functions for these tests. */
   42579 # undef malloc
   42580 # undef memcmp
   42581 # undef realloc
   42582 #endif
   42583 %}
   42584 
   42585 /* Infix notation calculator--calc */
   42586 %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
   42587 
   42588 %{
   42589 #include <stdio.h>
   42590 
   42591 #include <stdlib.h>
   42592 #include <string.h>
   42593 #if HAVE_UNISTD_H
   42594 # include <unistd.h>
   42595 #else
   42596 # undef alarm
   42597 # define alarm(seconds) /* empty */
   42598 #endif
   42599 #include <ctype.h>
   42600 #define USE(Var)
   42601 
   42602 /* Exercise pre-prologue dependency to %union.  */
   42603 typedef int semantic_value;
   42604 
   42605 static semantic_value global_result = 0;
   42606 static int global_count = 0;
   42607 %}
   42608 
   42609 /* Exercise %union. */
   42610 %union
   42611 {
   42612   semantic_value ival;
   42613 };
   42614 
   42615 %{
   42616 static int power (int base, int exponent);
   42617 /* yyerror receives the location if:
   42618    - %location & %pure & %glr
   42619    - %location & %pure & %yacc & %parse-param. */
   42620 static void yyerror (YYLTYPE *llocp,
   42621 
   42622                      const char *s
   42623                      );
   42624 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   42625 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   42626 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   42627 %}
   42628 
   42629 
   42630 
   42631 /* Bison Declarations */
   42632 %token CALC_EOF 0 "end of input"
   42633 %token <ival> NUM "number"
   42634 %type  <ival> exp
   42635 
   42636 %nonassoc '=' /* comparison	       */
   42637 %left '-' '+'
   42638 %left '*' '/'
   42639 %left NEG     /* negation--unary minus */
   42640 %right '^'    /* exponentiation        */
   42641 
   42642 /* Grammar follows */
   42643 %%
   42644 input:
   42645   line
   42646 | input line         {  }
   42647 ;
   42648 
   42649 line:
   42650   '\n'
   42651 | exp '\n'           { USE ($1); }
   42652 ;
   42653 
   42654 exp:
   42655   NUM                { $$ = $1;             }
   42656 | exp '=' exp
   42657   {
   42658     if ($1 != $3)
   42659       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   42660     $$ = $1;
   42661   }
   42662 | exp '+' exp        { $$ = $1 + $3;        }
   42663 | exp '-' exp        { $$ = $1 - $3;        }
   42664 | exp '*' exp        { $$ = $1 * $3;        }
   42665 | exp '/' exp        { $$ = $1 / $3;        }
   42666 | '-' exp  %prec NEG { $$ = -$2;            }
   42667 | exp '^' exp        { $$ = power ($1, $3); }
   42668 | '(' exp ')'        { $$ = $2;             }
   42669 | '(' error ')'      { $$ = 1111;           }
   42670 | '!'                { $$ = 0; YYERROR;     }
   42671 | '-' error          { $$ = 0; YYERROR;     }
   42672 ;
   42673 %%
   42674 /* The input.  */
   42675 static FILE *input;
   42676 
   42677 static void
   42678 yyerror (YYLTYPE *llocp,
   42679 
   42680          const char *s)
   42681 {
   42682 
   42683 
   42684   fprintf (stderr, "%d.%d",
   42685            (*llocp).first_line, (*llocp).first_column);
   42686   if ((*llocp).first_line != (*llocp).last_line)
   42687     fprintf (stderr, "-%d.%d",
   42688 	     (*llocp).last_line,  (*llocp).last_column - 1);
   42689   else if ((*llocp).first_column != (*llocp).last_column - 1)
   42690     fprintf (stderr, "-%d",
   42691 	     (*llocp).last_column - 1);
   42692   fprintf (stderr, ": ");
   42693   fprintf (stderr, "%s\n", s);
   42694 }
   42695 
   42696 
   42697 
   42698 static YYLTYPE last_yylloc;
   42699 
   42700 static int
   42701 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   42702 {
   42703   int res = getc (input);
   42704   (void) lvalp;(void) llocp;
   42705 
   42706   last_yylloc = (*llocp);
   42707   if (res == '\n')
   42708     {
   42709       (*llocp).last_line++;
   42710       (*llocp).last_column = 0;
   42711     }
   42712   else
   42713     (*llocp).last_column++;
   42714 
   42715   return res;
   42716 }
   42717 
   42718 
   42719 static void
   42720 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   42721 {
   42722   (void) lvalp;(void) llocp;
   42723 
   42724   /* Wrong when C == `\n'. */
   42725   (*llocp) = last_yylloc;
   42726 
   42727   ungetc (c, input);
   42728 }
   42729 
   42730 static int
   42731 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   42732 {
   42733   int c = get_char (lvalp, llocp);
   42734   int sign = 1;
   42735   int n = 0;
   42736 
   42737   (void) lvalp;(void) llocp;
   42738   if (c == '-')
   42739     {
   42740       c = get_char (lvalp, llocp);
   42741       sign = -1;
   42742     }
   42743 
   42744   while (isdigit (c))
   42745     {
   42746       n = 10 * n + (c - '0');
   42747       c = get_char (lvalp, llocp);
   42748     }
   42749 
   42750   unget_char (lvalp, llocp,  c);
   42751 
   42752   return sign * n;
   42753 }
   42754 
   42755 
   42756 
   42757 /*---------------------------------------------------------------.
   42758 | Lexical analyzer returns an integer on the stack and the token |
   42759 | NUM, or the ASCII character read if not a number.  Skips all   |
   42760 | blanks and tabs, returns 0 for EOF.                            |
   42761 `---------------------------------------------------------------*/
   42762 
   42763 static int
   42764 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   42765 {
   42766   static int init = 1;
   42767   int c;
   42768 
   42769   if (init)
   42770     {
   42771       init = 0;
   42772 
   42773       (*llocp).last_column = 0;
   42774       (*llocp).last_line = 1;
   42775 
   42776     }
   42777 
   42778 
   42779  (*llocp).first_column = (*llocp).last_column;
   42780   (*llocp).first_line   = (*llocp).last_line;
   42781 
   42782 
   42783   /* Skip white space.  */
   42784   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   42785     {
   42786      (*llocp).first_column = (*llocp).last_column;
   42787       (*llocp).first_line   = (*llocp).last_line;
   42788 
   42789     }
   42790 
   42791   /* process numbers   */
   42792   if (c == '.' || isdigit (c))
   42793     {
   42794       unget_char (lvalp, llocp,  c);
   42795       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   42796       return NUM;
   42797     }
   42798 
   42799   /* Return end-of-file.  */
   42800   if (c == EOF)
   42801     return CALC_EOF;
   42802 
   42803   /* Return single chars. */
   42804   return c;
   42805 }
   42806 
   42807 static int
   42808 power (int base, int exponent)
   42809 {
   42810   int res = 1;
   42811   if (exponent < 0)
   42812     exit (3);
   42813   for (/* Niente */; exponent; --exponent)
   42814     res *= base;
   42815   return res;
   42816 }
   42817 
   42818 
   42819 int
   42820 main (int argc, const char **argv)
   42821 {
   42822   semantic_value result = 0;
   42823   int count = 0;
   42824   int status;
   42825 
   42826   /* This used to be alarm (10), but that isn't enough time for
   42827      a July 1995 vintage DEC Alphastation 200 4/100 system,
   42828      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   42829   alarm (100);
   42830 
   42831   if (argc == 2)
   42832     input = fopen (argv[1], "r");
   42833   else
   42834     input = stdin;
   42835 
   42836   if (!input)
   42837     {
   42838       perror (argv[1]);
   42839       return 3;
   42840     }
   42841 
   42842   yydebug = 1;
   42843   status = yyparse ();
   42844   if (global_result != result)
   42845     abort ();
   42846   if (global_count != count)
   42847     abort ();
   42848   return status;
   42849 }
   42850 _ATEOF
   42851 
   42852 
   42853 
   42854 
   42855 
   42856 $at_traceoff
   42857 echo "calc.at:603: bison -o calc.c calc.y"
   42858 echo calc.at:603 >$at_check_line_file
   42859 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   42860 at_status=$?
   42861 grep '^ *+' $at_stder1 >&2
   42862 grep -v '^ *+' $at_stder1 >$at_stderr
   42863 at_failed=false
   42864 $at_diff $at_devnull $at_stderr || at_failed=:
   42865 $at_diff $at_devnull $at_stdout || at_failed=:
   42866 case $at_status in
   42867    77) echo 77 > $at_status_file
   42868             exit 77;;
   42869    0) ;;
   42870    *) echo "calc.at:603: exit code was $at_status, expected 0"
   42871       at_failed=:;;
   42872 esac
   42873 if $at_failed; then
   42874 
   42875   echo 1 > $at_status_file
   42876   exit 1
   42877 fi
   42878 
   42879 $at_traceon
   42880 
   42881    $at_traceoff
   42882 echo "calc.at:603: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   42883 echo calc.at:603 >$at_check_line_file
   42884 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   42885 at_status=$?
   42886 grep '^ *+' $at_stder1 >&2
   42887 grep -v '^ *+' $at_stder1 >$at_stderr
   42888 at_failed=false
   42889 echo stderr:; cat $at_stderr
   42890 echo stdout:; cat $at_stdout
   42891 case $at_status in
   42892    77) echo 77 > $at_status_file
   42893             exit 77;;
   42894    0) ;;
   42895    *) echo "calc.at:603: exit code was $at_status, expected 0"
   42896       at_failed=:;;
   42897 esac
   42898 if $at_failed; then
   42899 
   42900   echo 1 > $at_status_file
   42901   exit 1
   42902 fi
   42903 
   42904 $at_traceon
   42905 
   42906 
   42907 # Test the priorities.
   42908 cat >input <<'_ATEOF'
   42909 1 + 2 * 3 = 7
   42910 1 + 2 * -3 = -5
   42911 
   42912 -1^2 = -1
   42913 (-1)^2 = 1
   42914 
   42915 ---1 = -1
   42916 
   42917 1 - 2 - 3 = -4
   42918 1 - (2 - 3) = 2
   42919 
   42920 2^2^3 = 256
   42921 (2^2)^3 = 64
   42922 _ATEOF
   42923 
   42924 $at_traceoff
   42925 echo "calc.at:603: \$PREPARSER ./calc input"
   42926 echo calc.at:603 >$at_check_line_file
   42927 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   42928 at_status=$?
   42929 grep '^ *+' $at_stder1 >&2
   42930 grep -v '^ *+' $at_stder1 >$at_stderr
   42931 at_failed=false
   42932 echo stderr:; tee stderr <$at_stderr
   42933 $at_diff $at_devnull $at_stdout || at_failed=:
   42934 case $at_status in
   42935    77) echo 77 > $at_status_file
   42936             exit 77;;
   42937    0) ;;
   42938    *) echo "calc.at:603: exit code was $at_status, expected 0"
   42939       at_failed=:;;
   42940 esac
   42941 if $at_failed; then
   42942 
   42943   echo 1 > $at_status_file
   42944   exit 1
   42945 fi
   42946 
   42947 $at_traceon
   42948 
   42949 
   42950 
   42951 # Some syntax errors.
   42952 cat >input <<'_ATEOF'
   42953 0 0
   42954 _ATEOF
   42955 
   42956 $at_traceoff
   42957 echo "calc.at:603: \$PREPARSER ./calc input"
   42958 echo calc.at:603 >$at_check_line_file
   42959 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   42960 at_status=$?
   42961 grep '^ *+' $at_stder1 >&2
   42962 grep -v '^ *+' $at_stder1 >$at_stderr
   42963 at_failed=false
   42964 echo stderr:; tee stderr <$at_stderr
   42965 $at_diff $at_devnull $at_stdout || at_failed=:
   42966 case $at_status in
   42967    77) echo 77 > $at_status_file
   42968             exit 77;;
   42969    1) ;;
   42970    *) echo "calc.at:603: exit code was $at_status, expected 1"
   42971       at_failed=:;;
   42972 esac
   42973 if $at_failed; then
   42974 
   42975   echo 1 > $at_status_file
   42976   exit 1
   42977 fi
   42978 
   42979 $at_traceon
   42980 
   42981 
   42982 # Normalize the observed and expected error messages, depending upon the
   42983 # options.
   42984 # 1. Remove the traces from observed.
   42985 sed '/^Starting/d
   42986 /^Entering/d
   42987 /^Stack/d
   42988 /^Reading/d
   42989 /^Reducing/d
   42990 /^Shifting/d
   42991 /^state/d
   42992 /^Cleanup:/d
   42993 /^Error:/d
   42994 /^Next/d
   42995 /^Discarding/d
   42996 / \$[0-9$]* = /d
   42997 /^yydestructor:/d' stderr >at-stderr
   42998 mv at-stderr stderr
   42999 # 2. Create the reference error message.
   43000 cat >expout <<'_ATEOF'
   43001 1.2: syntax error, unexpected number
   43002 _ATEOF
   43003 
   43004 # 3. If locations are not used, remove them.
   43005 
   43006 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   43007 
   43008 # 5. Check
   43009 $at_traceoff
   43010 echo "calc.at:603: cat stderr"
   43011 echo calc.at:603 >$at_check_line_file
   43012 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   43013 at_status=$?
   43014 grep '^ *+' $at_stder1 >&2
   43015 grep -v '^ *+' $at_stder1 >$at_stderr
   43016 at_failed=false
   43017 $at_diff $at_devnull $at_stderr || at_failed=:
   43018 $at_diff expout $at_stdout || at_failed=:
   43019 case $at_status in
   43020    77) echo 77 > $at_status_file
   43021             exit 77;;
   43022    0) ;;
   43023    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43024       at_failed=:;;
   43025 esac
   43026 if $at_failed; then
   43027 
   43028   echo 1 > $at_status_file
   43029   exit 1
   43030 fi
   43031 
   43032 $at_traceon
   43033 
   43034 
   43035 cat >input <<'_ATEOF'
   43036 1//2
   43037 _ATEOF
   43038 
   43039 $at_traceoff
   43040 echo "calc.at:603: \$PREPARSER ./calc input"
   43041 echo calc.at:603 >$at_check_line_file
   43042 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   43043 at_status=$?
   43044 grep '^ *+' $at_stder1 >&2
   43045 grep -v '^ *+' $at_stder1 >$at_stderr
   43046 at_failed=false
   43047 echo stderr:; tee stderr <$at_stderr
   43048 $at_diff $at_devnull $at_stdout || at_failed=:
   43049 case $at_status in
   43050    77) echo 77 > $at_status_file
   43051             exit 77;;
   43052    1) ;;
   43053    *) echo "calc.at:603: exit code was $at_status, expected 1"
   43054       at_failed=:;;
   43055 esac
   43056 if $at_failed; then
   43057 
   43058   echo 1 > $at_status_file
   43059   exit 1
   43060 fi
   43061 
   43062 $at_traceon
   43063 
   43064 
   43065 # Normalize the observed and expected error messages, depending upon the
   43066 # options.
   43067 # 1. Remove the traces from observed.
   43068 sed '/^Starting/d
   43069 /^Entering/d
   43070 /^Stack/d
   43071 /^Reading/d
   43072 /^Reducing/d
   43073 /^Shifting/d
   43074 /^state/d
   43075 /^Cleanup:/d
   43076 /^Error:/d
   43077 /^Next/d
   43078 /^Discarding/d
   43079 / \$[0-9$]* = /d
   43080 /^yydestructor:/d' stderr >at-stderr
   43081 mv at-stderr stderr
   43082 # 2. Create the reference error message.
   43083 cat >expout <<'_ATEOF'
   43084 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   43085 _ATEOF
   43086 
   43087 # 3. If locations are not used, remove them.
   43088 
   43089 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   43090 
   43091 # 5. Check
   43092 $at_traceoff
   43093 echo "calc.at:603: cat stderr"
   43094 echo calc.at:603 >$at_check_line_file
   43095 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   43096 at_status=$?
   43097 grep '^ *+' $at_stder1 >&2
   43098 grep -v '^ *+' $at_stder1 >$at_stderr
   43099 at_failed=false
   43100 $at_diff $at_devnull $at_stderr || at_failed=:
   43101 $at_diff expout $at_stdout || at_failed=:
   43102 case $at_status in
   43103    77) echo 77 > $at_status_file
   43104             exit 77;;
   43105    0) ;;
   43106    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43107       at_failed=:;;
   43108 esac
   43109 if $at_failed; then
   43110 
   43111   echo 1 > $at_status_file
   43112   exit 1
   43113 fi
   43114 
   43115 $at_traceon
   43116 
   43117 
   43118 cat >input <<'_ATEOF'
   43119 error
   43120 _ATEOF
   43121 
   43122 $at_traceoff
   43123 echo "calc.at:603: \$PREPARSER ./calc input"
   43124 echo calc.at:603 >$at_check_line_file
   43125 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   43126 at_status=$?
   43127 grep '^ *+' $at_stder1 >&2
   43128 grep -v '^ *+' $at_stder1 >$at_stderr
   43129 at_failed=false
   43130 echo stderr:; tee stderr <$at_stderr
   43131 $at_diff $at_devnull $at_stdout || at_failed=:
   43132 case $at_status in
   43133    77) echo 77 > $at_status_file
   43134             exit 77;;
   43135    1) ;;
   43136    *) echo "calc.at:603: exit code was $at_status, expected 1"
   43137       at_failed=:;;
   43138 esac
   43139 if $at_failed; then
   43140 
   43141   echo 1 > $at_status_file
   43142   exit 1
   43143 fi
   43144 
   43145 $at_traceon
   43146 
   43147 
   43148 # Normalize the observed and expected error messages, depending upon the
   43149 # options.
   43150 # 1. Remove the traces from observed.
   43151 sed '/^Starting/d
   43152 /^Entering/d
   43153 /^Stack/d
   43154 /^Reading/d
   43155 /^Reducing/d
   43156 /^Shifting/d
   43157 /^state/d
   43158 /^Cleanup:/d
   43159 /^Error:/d
   43160 /^Next/d
   43161 /^Discarding/d
   43162 / \$[0-9$]* = /d
   43163 /^yydestructor:/d' stderr >at-stderr
   43164 mv at-stderr stderr
   43165 # 2. Create the reference error message.
   43166 cat >expout <<'_ATEOF'
   43167 1.0: syntax error, unexpected $undefined
   43168 _ATEOF
   43169 
   43170 # 3. If locations are not used, remove them.
   43171 
   43172 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   43173 
   43174 # 5. Check
   43175 $at_traceoff
   43176 echo "calc.at:603: cat stderr"
   43177 echo calc.at:603 >$at_check_line_file
   43178 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   43179 at_status=$?
   43180 grep '^ *+' $at_stder1 >&2
   43181 grep -v '^ *+' $at_stder1 >$at_stderr
   43182 at_failed=false
   43183 $at_diff $at_devnull $at_stderr || at_failed=:
   43184 $at_diff expout $at_stdout || at_failed=:
   43185 case $at_status in
   43186    77) echo 77 > $at_status_file
   43187             exit 77;;
   43188    0) ;;
   43189    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43190       at_failed=:;;
   43191 esac
   43192 if $at_failed; then
   43193 
   43194   echo 1 > $at_status_file
   43195   exit 1
   43196 fi
   43197 
   43198 $at_traceon
   43199 
   43200 
   43201 cat >input <<'_ATEOF'
   43202 1 = 2 = 3
   43203 _ATEOF
   43204 
   43205 $at_traceoff
   43206 echo "calc.at:603: \$PREPARSER ./calc input"
   43207 echo calc.at:603 >$at_check_line_file
   43208 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   43209 at_status=$?
   43210 grep '^ *+' $at_stder1 >&2
   43211 grep -v '^ *+' $at_stder1 >$at_stderr
   43212 at_failed=false
   43213 echo stderr:; tee stderr <$at_stderr
   43214 $at_diff $at_devnull $at_stdout || at_failed=:
   43215 case $at_status in
   43216    77) echo 77 > $at_status_file
   43217             exit 77;;
   43218    1) ;;
   43219    *) echo "calc.at:603: exit code was $at_status, expected 1"
   43220       at_failed=:;;
   43221 esac
   43222 if $at_failed; then
   43223 
   43224   echo 1 > $at_status_file
   43225   exit 1
   43226 fi
   43227 
   43228 $at_traceon
   43229 
   43230 
   43231 # Normalize the observed and expected error messages, depending upon the
   43232 # options.
   43233 # 1. Remove the traces from observed.
   43234 sed '/^Starting/d
   43235 /^Entering/d
   43236 /^Stack/d
   43237 /^Reading/d
   43238 /^Reducing/d
   43239 /^Shifting/d
   43240 /^state/d
   43241 /^Cleanup:/d
   43242 /^Error:/d
   43243 /^Next/d
   43244 /^Discarding/d
   43245 / \$[0-9$]* = /d
   43246 /^yydestructor:/d' stderr >at-stderr
   43247 mv at-stderr stderr
   43248 # 2. Create the reference error message.
   43249 cat >expout <<'_ATEOF'
   43250 1.6: syntax error, unexpected '='
   43251 _ATEOF
   43252 
   43253 # 3. If locations are not used, remove them.
   43254 
   43255 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   43256 
   43257 # 5. Check
   43258 $at_traceoff
   43259 echo "calc.at:603: cat stderr"
   43260 echo calc.at:603 >$at_check_line_file
   43261 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   43262 at_status=$?
   43263 grep '^ *+' $at_stder1 >&2
   43264 grep -v '^ *+' $at_stder1 >$at_stderr
   43265 at_failed=false
   43266 $at_diff $at_devnull $at_stderr || at_failed=:
   43267 $at_diff expout $at_stdout || at_failed=:
   43268 case $at_status in
   43269    77) echo 77 > $at_status_file
   43270             exit 77;;
   43271    0) ;;
   43272    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43273       at_failed=:;;
   43274 esac
   43275 if $at_failed; then
   43276 
   43277   echo 1 > $at_status_file
   43278   exit 1
   43279 fi
   43280 
   43281 $at_traceon
   43282 
   43283 
   43284 cat >input <<'_ATEOF'
   43285 
   43286 +1
   43287 _ATEOF
   43288 
   43289 $at_traceoff
   43290 echo "calc.at:603: \$PREPARSER ./calc input"
   43291 echo calc.at:603 >$at_check_line_file
   43292 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   43293 at_status=$?
   43294 grep '^ *+' $at_stder1 >&2
   43295 grep -v '^ *+' $at_stder1 >$at_stderr
   43296 at_failed=false
   43297 echo stderr:; tee stderr <$at_stderr
   43298 $at_diff $at_devnull $at_stdout || at_failed=:
   43299 case $at_status in
   43300    77) echo 77 > $at_status_file
   43301             exit 77;;
   43302    1) ;;
   43303    *) echo "calc.at:603: exit code was $at_status, expected 1"
   43304       at_failed=:;;
   43305 esac
   43306 if $at_failed; then
   43307 
   43308   echo 1 > $at_status_file
   43309   exit 1
   43310 fi
   43311 
   43312 $at_traceon
   43313 
   43314 
   43315 # Normalize the observed and expected error messages, depending upon the
   43316 # options.
   43317 # 1. Remove the traces from observed.
   43318 sed '/^Starting/d
   43319 /^Entering/d
   43320 /^Stack/d
   43321 /^Reading/d
   43322 /^Reducing/d
   43323 /^Shifting/d
   43324 /^state/d
   43325 /^Cleanup:/d
   43326 /^Error:/d
   43327 /^Next/d
   43328 /^Discarding/d
   43329 / \$[0-9$]* = /d
   43330 /^yydestructor:/d' stderr >at-stderr
   43331 mv at-stderr stderr
   43332 # 2. Create the reference error message.
   43333 cat >expout <<'_ATEOF'
   43334 2.0: syntax error, unexpected '+'
   43335 _ATEOF
   43336 
   43337 # 3. If locations are not used, remove them.
   43338 
   43339 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   43340 
   43341 # 5. Check
   43342 $at_traceoff
   43343 echo "calc.at:603: cat stderr"
   43344 echo calc.at:603 >$at_check_line_file
   43345 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   43346 at_status=$?
   43347 grep '^ *+' $at_stder1 >&2
   43348 grep -v '^ *+' $at_stder1 >$at_stderr
   43349 at_failed=false
   43350 $at_diff $at_devnull $at_stderr || at_failed=:
   43351 $at_diff expout $at_stdout || at_failed=:
   43352 case $at_status in
   43353    77) echo 77 > $at_status_file
   43354             exit 77;;
   43355    0) ;;
   43356    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43357       at_failed=:;;
   43358 esac
   43359 if $at_failed; then
   43360 
   43361   echo 1 > $at_status_file
   43362   exit 1
   43363 fi
   43364 
   43365 $at_traceon
   43366 
   43367 
   43368 # Exercise error messages with EOF: work on an empty file.
   43369 $at_traceoff
   43370 echo "calc.at:603: \$PREPARSER ./calc /dev/null"
   43371 echo calc.at:603 >$at_check_line_file
   43372 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   43373 at_status=$?
   43374 grep '^ *+' $at_stder1 >&2
   43375 grep -v '^ *+' $at_stder1 >$at_stderr
   43376 at_failed=false
   43377 echo stderr:; tee stderr <$at_stderr
   43378 $at_diff $at_devnull $at_stdout || at_failed=:
   43379 case $at_status in
   43380    77) echo 77 > $at_status_file
   43381             exit 77;;
   43382    1) ;;
   43383    *) echo "calc.at:603: exit code was $at_status, expected 1"
   43384       at_failed=:;;
   43385 esac
   43386 if $at_failed; then
   43387 
   43388   echo 1 > $at_status_file
   43389   exit 1
   43390 fi
   43391 
   43392 $at_traceon
   43393 
   43394 
   43395 # Normalize the observed and expected error messages, depending upon the
   43396 # options.
   43397 # 1. Remove the traces from observed.
   43398 sed '/^Starting/d
   43399 /^Entering/d
   43400 /^Stack/d
   43401 /^Reading/d
   43402 /^Reducing/d
   43403 /^Shifting/d
   43404 /^state/d
   43405 /^Cleanup:/d
   43406 /^Error:/d
   43407 /^Next/d
   43408 /^Discarding/d
   43409 / \$[0-9$]* = /d
   43410 /^yydestructor:/d' stderr >at-stderr
   43411 mv at-stderr stderr
   43412 # 2. Create the reference error message.
   43413 cat >expout <<'_ATEOF'
   43414 1.0: syntax error, unexpected end of input
   43415 _ATEOF
   43416 
   43417 # 3. If locations are not used, remove them.
   43418 
   43419 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   43420 
   43421 # 5. Check
   43422 $at_traceoff
   43423 echo "calc.at:603: cat stderr"
   43424 echo calc.at:603 >$at_check_line_file
   43425 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   43426 at_status=$?
   43427 grep '^ *+' $at_stder1 >&2
   43428 grep -v '^ *+' $at_stder1 >$at_stderr
   43429 at_failed=false
   43430 $at_diff $at_devnull $at_stderr || at_failed=:
   43431 $at_diff expout $at_stdout || at_failed=:
   43432 case $at_status in
   43433    77) echo 77 > $at_status_file
   43434             exit 77;;
   43435    0) ;;
   43436    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43437       at_failed=:;;
   43438 esac
   43439 if $at_failed; then
   43440 
   43441   echo 1 > $at_status_file
   43442   exit 1
   43443 fi
   43444 
   43445 $at_traceon
   43446 
   43447 
   43448 
   43449 # Exercise the error token: without it, we die at the first error,
   43450 # hence be sure to
   43451 #
   43452 # - have several errors which exercise different shift/discardings
   43453 #   - (): nothing to pop, nothing to discard
   43454 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   43455 #   - (* * *): nothing to pop, a lot to discard
   43456 #   - (1 + 2 * *): some to pop and discard
   43457 #
   43458 # - test the action associated to `error'
   43459 #
   43460 # - check the look-ahead that triggers an error is not discarded
   43461 #   when we enter error recovery.  Below, the look-ahead causing the
   43462 #   first error is ")", which is needed to recover from the error and
   43463 #   produce the "0" that triggers the "0 != 1" error.
   43464 #
   43465 cat >input <<'_ATEOF'
   43466 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   43467 _ATEOF
   43468 
   43469 $at_traceoff
   43470 echo "calc.at:603: \$PREPARSER ./calc input"
   43471 echo calc.at:603 >$at_check_line_file
   43472 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   43473 at_status=$?
   43474 grep '^ *+' $at_stder1 >&2
   43475 grep -v '^ *+' $at_stder1 >$at_stderr
   43476 at_failed=false
   43477 echo stderr:; tee stderr <$at_stderr
   43478 $at_diff $at_devnull $at_stdout || at_failed=:
   43479 case $at_status in
   43480    77) echo 77 > $at_status_file
   43481             exit 77;;
   43482    0) ;;
   43483    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43484       at_failed=:;;
   43485 esac
   43486 if $at_failed; then
   43487 
   43488   echo 1 > $at_status_file
   43489   exit 1
   43490 fi
   43491 
   43492 $at_traceon
   43493 
   43494 
   43495 # Normalize the observed and expected error messages, depending upon the
   43496 # options.
   43497 # 1. Remove the traces from observed.
   43498 sed '/^Starting/d
   43499 /^Entering/d
   43500 /^Stack/d
   43501 /^Reading/d
   43502 /^Reducing/d
   43503 /^Shifting/d
   43504 /^state/d
   43505 /^Cleanup:/d
   43506 /^Error:/d
   43507 /^Next/d
   43508 /^Discarding/d
   43509 / \$[0-9$]* = /d
   43510 /^yydestructor:/d' stderr >at-stderr
   43511 mv at-stderr stderr
   43512 # 2. Create the reference error message.
   43513 cat >expout <<'_ATEOF'
   43514 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   43515 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   43516 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   43517 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   43518 calc: error: 4444 != 1
   43519 _ATEOF
   43520 
   43521 # 3. If locations are not used, remove them.
   43522 
   43523 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   43524 
   43525 # 5. Check
   43526 $at_traceoff
   43527 echo "calc.at:603: cat stderr"
   43528 echo calc.at:603 >$at_check_line_file
   43529 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   43530 at_status=$?
   43531 grep '^ *+' $at_stder1 >&2
   43532 grep -v '^ *+' $at_stder1 >$at_stderr
   43533 at_failed=false
   43534 $at_diff $at_devnull $at_stderr || at_failed=:
   43535 $at_diff expout $at_stdout || at_failed=:
   43536 case $at_status in
   43537    77) echo 77 > $at_status_file
   43538             exit 77;;
   43539    0) ;;
   43540    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43541       at_failed=:;;
   43542 esac
   43543 if $at_failed; then
   43544 
   43545   echo 1 > $at_status_file
   43546   exit 1
   43547 fi
   43548 
   43549 $at_traceon
   43550 
   43551 
   43552 
   43553 # The same, but this time exercising explicitly triggered syntax errors.
   43554 # POSIX says the look-ahead causing the error should not be discarded.
   43555 cat >input <<'_ATEOF'
   43556 (!) + (0 0) = 1
   43557 _ATEOF
   43558 
   43559 $at_traceoff
   43560 echo "calc.at:603: \$PREPARSER ./calc input"
   43561 echo calc.at:603 >$at_check_line_file
   43562 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   43563 at_status=$?
   43564 grep '^ *+' $at_stder1 >&2
   43565 grep -v '^ *+' $at_stder1 >$at_stderr
   43566 at_failed=false
   43567 echo stderr:; tee stderr <$at_stderr
   43568 $at_diff $at_devnull $at_stdout || at_failed=:
   43569 case $at_status in
   43570    77) echo 77 > $at_status_file
   43571             exit 77;;
   43572    0) ;;
   43573    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43574       at_failed=:;;
   43575 esac
   43576 if $at_failed; then
   43577 
   43578   echo 1 > $at_status_file
   43579   exit 1
   43580 fi
   43581 
   43582 $at_traceon
   43583 
   43584 
   43585 # Normalize the observed and expected error messages, depending upon the
   43586 # options.
   43587 # 1. Remove the traces from observed.
   43588 sed '/^Starting/d
   43589 /^Entering/d
   43590 /^Stack/d
   43591 /^Reading/d
   43592 /^Reducing/d
   43593 /^Shifting/d
   43594 /^state/d
   43595 /^Cleanup:/d
   43596 /^Error:/d
   43597 /^Next/d
   43598 /^Discarding/d
   43599 / \$[0-9$]* = /d
   43600 /^yydestructor:/d' stderr >at-stderr
   43601 mv at-stderr stderr
   43602 # 2. Create the reference error message.
   43603 cat >expout <<'_ATEOF'
   43604 1.9: syntax error, unexpected number
   43605 calc: error: 2222 != 1
   43606 _ATEOF
   43607 
   43608 # 3. If locations are not used, remove them.
   43609 
   43610 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   43611 
   43612 # 5. Check
   43613 $at_traceoff
   43614 echo "calc.at:603: cat stderr"
   43615 echo calc.at:603 >$at_check_line_file
   43616 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   43617 at_status=$?
   43618 grep '^ *+' $at_stder1 >&2
   43619 grep -v '^ *+' $at_stder1 >$at_stderr
   43620 at_failed=false
   43621 $at_diff $at_devnull $at_stderr || at_failed=:
   43622 $at_diff expout $at_stdout || at_failed=:
   43623 case $at_status in
   43624    77) echo 77 > $at_status_file
   43625             exit 77;;
   43626    0) ;;
   43627    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43628       at_failed=:;;
   43629 esac
   43630 if $at_failed; then
   43631 
   43632   echo 1 > $at_status_file
   43633   exit 1
   43634 fi
   43635 
   43636 $at_traceon
   43637 
   43638 
   43639 cat >input <<'_ATEOF'
   43640 (- *) + (0 0) = 1
   43641 _ATEOF
   43642 
   43643 $at_traceoff
   43644 echo "calc.at:603: \$PREPARSER ./calc input"
   43645 echo calc.at:603 >$at_check_line_file
   43646 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   43647 at_status=$?
   43648 grep '^ *+' $at_stder1 >&2
   43649 grep -v '^ *+' $at_stder1 >$at_stderr
   43650 at_failed=false
   43651 echo stderr:; tee stderr <$at_stderr
   43652 $at_diff $at_devnull $at_stdout || at_failed=:
   43653 case $at_status in
   43654    77) echo 77 > $at_status_file
   43655             exit 77;;
   43656    0) ;;
   43657    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43658       at_failed=:;;
   43659 esac
   43660 if $at_failed; then
   43661 
   43662   echo 1 > $at_status_file
   43663   exit 1
   43664 fi
   43665 
   43666 $at_traceon
   43667 
   43668 
   43669 # Normalize the observed and expected error messages, depending upon the
   43670 # options.
   43671 # 1. Remove the traces from observed.
   43672 sed '/^Starting/d
   43673 /^Entering/d
   43674 /^Stack/d
   43675 /^Reading/d
   43676 /^Reducing/d
   43677 /^Shifting/d
   43678 /^state/d
   43679 /^Cleanup:/d
   43680 /^Error:/d
   43681 /^Next/d
   43682 /^Discarding/d
   43683 / \$[0-9$]* = /d
   43684 /^yydestructor:/d' stderr >at-stderr
   43685 mv at-stderr stderr
   43686 # 2. Create the reference error message.
   43687 cat >expout <<'_ATEOF'
   43688 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   43689 1.11: syntax error, unexpected number
   43690 calc: error: 2222 != 1
   43691 _ATEOF
   43692 
   43693 # 3. If locations are not used, remove them.
   43694 
   43695 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   43696 
   43697 # 5. Check
   43698 $at_traceoff
   43699 echo "calc.at:603: cat stderr"
   43700 echo calc.at:603 >$at_check_line_file
   43701 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   43702 at_status=$?
   43703 grep '^ *+' $at_stder1 >&2
   43704 grep -v '^ *+' $at_stder1 >$at_stderr
   43705 at_failed=false
   43706 $at_diff $at_devnull $at_stderr || at_failed=:
   43707 $at_diff expout $at_stdout || at_failed=:
   43708 case $at_status in
   43709    77) echo 77 > $at_status_file
   43710             exit 77;;
   43711    0) ;;
   43712    *) echo "calc.at:603: exit code was $at_status, expected 0"
   43713       at_failed=:;;
   43714 esac
   43715 if $at_failed; then
   43716 
   43717   echo 1 > $at_status_file
   43718   exit 1
   43719 fi
   43720 
   43721 $at_traceon
   43722 
   43723 
   43724 
   43725 
   43726 
   43727 
   43728 
   43729 
   43730 
   43731 
   43732 
   43733 
   43734 
   43735 
   43736 
   43737 
   43738 
   43739 
   43740 
   43741 
   43742 
   43743 
   43744 
   43745 
   43746       $at_traceoff
   43747       $at_times_p && times >$at_times_file
   43748     ) 5>&1 2>&1 | eval $at_tee_pipe
   43749     at_status=`cat $at_status_file`
   43750     ;;
   43751 
   43752   97 ) # 97. calc.at:605: Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}
   43753     at_setup_line='calc.at:605'
   43754     at_desc='Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}'
   43755     $at_quiet $ECHO_N " 97: Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}$ECHO_C"
   43756     at_xfail=no
   43757     (
   43758       echo "97. calc.at:605: testing ..."
   43759       $at_traceon
   43760 
   43761 
   43762 
   43763 
   43764 
   43765 
   43766 
   43767 
   43768 # Using yacc.c?
   43769 
   43770 
   43771 
   43772 
   43773 
   43774 
   43775 
   43776 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   43777 
   43778 # yyerror always sees the locations (when activated), except if
   43779 # yacc & pure & !param.
   43780 
   43781 
   43782 # The interface is pure: either because %pure-parser, or because we
   43783 # are using the C++ parsers.
   43784 
   43785 
   43786 
   43787 
   43788 
   43789 
   43790 
   43791 
   43792 
   43793 
   43794 
   43795 
   43796 cat >calc.y <<'_ATEOF'
   43797 %{
   43798 #ifdef HAVE_CONFIG_H
   43799 # include <config.h>
   43800   /* We don't need perfect functions for these tests. */
   43801 # undef malloc
   43802 # undef memcmp
   43803 # undef realloc
   43804 #endif
   43805 %}
   43806 
   43807 /* Infix notation calculator--calc */
   43808 %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}
   43809 
   43810 %{
   43811 #include <stdio.h>
   43812 
   43813 #include <stdlib.h>
   43814 #include <string.h>
   43815 #if HAVE_UNISTD_H
   43816 # include <unistd.h>
   43817 #else
   43818 # undef alarm
   43819 # define alarm(seconds) /* empty */
   43820 #endif
   43821 #include <ctype.h>
   43822 #define USE(Var)
   43823 
   43824 /* Exercise pre-prologue dependency to %union.  */
   43825 typedef int semantic_value;
   43826 
   43827 static semantic_value global_result = 0;
   43828 static int global_count = 0;
   43829 %}
   43830 
   43831 /* Exercise %union. */
   43832 %union
   43833 {
   43834   semantic_value ival;
   43835 };
   43836 
   43837 %{
   43838 static int power (int base, int exponent);
   43839 /* yyerror receives the location if:
   43840    - %location & %pure & %glr
   43841    - %location & %pure & %yacc & %parse-param. */
   43842 static void yyerror (YYLTYPE *llocp,
   43843                      semantic_value *result, int *count,
   43844                      const char *s
   43845                      );
   43846 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   43847 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   43848 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   43849 %}
   43850 
   43851 
   43852 
   43853 /* Bison Declarations */
   43854 %token CALC_EOF 0 "end of input"
   43855 %token <ival> NUM "number"
   43856 %type  <ival> exp
   43857 
   43858 %nonassoc '=' /* comparison	       */
   43859 %left '-' '+'
   43860 %left '*' '/'
   43861 %left NEG     /* negation--unary minus */
   43862 %right '^'    /* exponentiation        */
   43863 
   43864 /* Grammar follows */
   43865 %%
   43866 input:
   43867   line
   43868 | input line         { ++*count; ++global_count; }
   43869 ;
   43870 
   43871 line:
   43872   '\n'
   43873 | exp '\n'           { *result = global_result = $1; }
   43874 ;
   43875 
   43876 exp:
   43877   NUM                { $$ = $1;             }
   43878 | exp '=' exp
   43879   {
   43880     if ($1 != $3)
   43881       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   43882     $$ = $1;
   43883   }
   43884 | exp '+' exp        { $$ = $1 + $3;        }
   43885 | exp '-' exp        { $$ = $1 - $3;        }
   43886 | exp '*' exp        { $$ = $1 * $3;        }
   43887 | exp '/' exp        { $$ = $1 / $3;        }
   43888 | '-' exp  %prec NEG { $$ = -$2;            }
   43889 | exp '^' exp        { $$ = power ($1, $3); }
   43890 | '(' exp ')'        { $$ = $2;             }
   43891 | '(' error ')'      { $$ = 1111;           }
   43892 | '!'                { $$ = 0; YYERROR;     }
   43893 | '-' error          { $$ = 0; YYERROR;     }
   43894 ;
   43895 %%
   43896 /* The input.  */
   43897 static FILE *input;
   43898 
   43899 static void
   43900 yyerror (YYLTYPE *llocp,
   43901          semantic_value *result, int *count,
   43902          const char *s)
   43903 {
   43904 (void) result; (void) count;
   43905 
   43906   fprintf (stderr, "%d.%d",
   43907            (*llocp).first_line, (*llocp).first_column);
   43908   if ((*llocp).first_line != (*llocp).last_line)
   43909     fprintf (stderr, "-%d.%d",
   43910 	     (*llocp).last_line,  (*llocp).last_column - 1);
   43911   else if ((*llocp).first_column != (*llocp).last_column - 1)
   43912     fprintf (stderr, "-%d",
   43913 	     (*llocp).last_column - 1);
   43914   fprintf (stderr, ": ");
   43915   fprintf (stderr, "%s\n", s);
   43916 }
   43917 
   43918 
   43919 
   43920 static YYLTYPE last_yylloc;
   43921 
   43922 static int
   43923 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   43924 {
   43925   int res = getc (input);
   43926   (void) lvalp;(void) llocp;
   43927 
   43928   last_yylloc = (*llocp);
   43929   if (res == '\n')
   43930     {
   43931       (*llocp).last_line++;
   43932       (*llocp).last_column = 0;
   43933     }
   43934   else
   43935     (*llocp).last_column++;
   43936 
   43937   return res;
   43938 }
   43939 
   43940 
   43941 static void
   43942 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   43943 {
   43944   (void) lvalp;(void) llocp;
   43945 
   43946   /* Wrong when C == `\n'. */
   43947   (*llocp) = last_yylloc;
   43948 
   43949   ungetc (c, input);
   43950 }
   43951 
   43952 static int
   43953 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   43954 {
   43955   int c = get_char (lvalp, llocp);
   43956   int sign = 1;
   43957   int n = 0;
   43958 
   43959   (void) lvalp;(void) llocp;
   43960   if (c == '-')
   43961     {
   43962       c = get_char (lvalp, llocp);
   43963       sign = -1;
   43964     }
   43965 
   43966   while (isdigit (c))
   43967     {
   43968       n = 10 * n + (c - '0');
   43969       c = get_char (lvalp, llocp);
   43970     }
   43971 
   43972   unget_char (lvalp, llocp,  c);
   43973 
   43974   return sign * n;
   43975 }
   43976 
   43977 
   43978 
   43979 /*---------------------------------------------------------------.
   43980 | Lexical analyzer returns an integer on the stack and the token |
   43981 | NUM, or the ASCII character read if not a number.  Skips all   |
   43982 | blanks and tabs, returns 0 for EOF.                            |
   43983 `---------------------------------------------------------------*/
   43984 
   43985 static int
   43986 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   43987 {
   43988   static int init = 1;
   43989   int c;
   43990 
   43991   if (init)
   43992     {
   43993       init = 0;
   43994 
   43995       (*llocp).last_column = 0;
   43996       (*llocp).last_line = 1;
   43997 
   43998     }
   43999 
   44000 
   44001  (*llocp).first_column = (*llocp).last_column;
   44002   (*llocp).first_line   = (*llocp).last_line;
   44003 
   44004 
   44005   /* Skip white space.  */
   44006   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   44007     {
   44008      (*llocp).first_column = (*llocp).last_column;
   44009       (*llocp).first_line   = (*llocp).last_line;
   44010 
   44011     }
   44012 
   44013   /* process numbers   */
   44014   if (c == '.' || isdigit (c))
   44015     {
   44016       unget_char (lvalp, llocp,  c);
   44017       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   44018       return NUM;
   44019     }
   44020 
   44021   /* Return end-of-file.  */
   44022   if (c == EOF)
   44023     return CALC_EOF;
   44024 
   44025   /* Return single chars. */
   44026   return c;
   44027 }
   44028 
   44029 static int
   44030 power (int base, int exponent)
   44031 {
   44032   int res = 1;
   44033   if (exponent < 0)
   44034     exit (3);
   44035   for (/* Niente */; exponent; --exponent)
   44036     res *= base;
   44037   return res;
   44038 }
   44039 
   44040 
   44041 int
   44042 main (int argc, const char **argv)
   44043 {
   44044   semantic_value result = 0;
   44045   int count = 0;
   44046   int status;
   44047 
   44048   /* This used to be alarm (10), but that isn't enough time for
   44049      a July 1995 vintage DEC Alphastation 200 4/100 system,
   44050      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   44051   alarm (100);
   44052 
   44053   if (argc == 2)
   44054     input = fopen (argv[1], "r");
   44055   else
   44056     input = stdin;
   44057 
   44058   if (!input)
   44059     {
   44060       perror (argv[1]);
   44061       return 3;
   44062     }
   44063 
   44064   yydebug = 1;
   44065   status = yyparse (&result, &count);
   44066   if (global_result != result)
   44067     abort ();
   44068   if (global_count != count)
   44069     abort ();
   44070   return status;
   44071 }
   44072 _ATEOF
   44073 
   44074 
   44075 
   44076 
   44077 
   44078 $at_traceoff
   44079 echo "calc.at:605: bison -o calc.c calc.y"
   44080 echo calc.at:605 >$at_check_line_file
   44081 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   44082 at_status=$?
   44083 grep '^ *+' $at_stder1 >&2
   44084 grep -v '^ *+' $at_stder1 >$at_stderr
   44085 at_failed=false
   44086 $at_diff $at_devnull $at_stderr || at_failed=:
   44087 $at_diff $at_devnull $at_stdout || at_failed=:
   44088 case $at_status in
   44089    77) echo 77 > $at_status_file
   44090             exit 77;;
   44091    0) ;;
   44092    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44093       at_failed=:;;
   44094 esac
   44095 if $at_failed; then
   44096 
   44097   echo 1 > $at_status_file
   44098   exit 1
   44099 fi
   44100 
   44101 $at_traceon
   44102 
   44103    $at_traceoff
   44104 echo "calc.at:605: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   44105 echo calc.at:605 >$at_check_line_file
   44106 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   44107 at_status=$?
   44108 grep '^ *+' $at_stder1 >&2
   44109 grep -v '^ *+' $at_stder1 >$at_stderr
   44110 at_failed=false
   44111 echo stderr:; cat $at_stderr
   44112 echo stdout:; cat $at_stdout
   44113 case $at_status in
   44114    77) echo 77 > $at_status_file
   44115             exit 77;;
   44116    0) ;;
   44117    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44118       at_failed=:;;
   44119 esac
   44120 if $at_failed; then
   44121 
   44122   echo 1 > $at_status_file
   44123   exit 1
   44124 fi
   44125 
   44126 $at_traceon
   44127 
   44128 
   44129 # Test the priorities.
   44130 cat >input <<'_ATEOF'
   44131 1 + 2 * 3 = 7
   44132 1 + 2 * -3 = -5
   44133 
   44134 -1^2 = -1
   44135 (-1)^2 = 1
   44136 
   44137 ---1 = -1
   44138 
   44139 1 - 2 - 3 = -4
   44140 1 - (2 - 3) = 2
   44141 
   44142 2^2^3 = 256
   44143 (2^2)^3 = 64
   44144 _ATEOF
   44145 
   44146 $at_traceoff
   44147 echo "calc.at:605: \$PREPARSER ./calc input"
   44148 echo calc.at:605 >$at_check_line_file
   44149 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   44150 at_status=$?
   44151 grep '^ *+' $at_stder1 >&2
   44152 grep -v '^ *+' $at_stder1 >$at_stderr
   44153 at_failed=false
   44154 echo stderr:; tee stderr <$at_stderr
   44155 $at_diff $at_devnull $at_stdout || at_failed=:
   44156 case $at_status in
   44157    77) echo 77 > $at_status_file
   44158             exit 77;;
   44159    0) ;;
   44160    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44161       at_failed=:;;
   44162 esac
   44163 if $at_failed; then
   44164 
   44165   echo 1 > $at_status_file
   44166   exit 1
   44167 fi
   44168 
   44169 $at_traceon
   44170 
   44171 
   44172 
   44173 # Some syntax errors.
   44174 cat >input <<'_ATEOF'
   44175 0 0
   44176 _ATEOF
   44177 
   44178 $at_traceoff
   44179 echo "calc.at:605: \$PREPARSER ./calc input"
   44180 echo calc.at:605 >$at_check_line_file
   44181 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   44182 at_status=$?
   44183 grep '^ *+' $at_stder1 >&2
   44184 grep -v '^ *+' $at_stder1 >$at_stderr
   44185 at_failed=false
   44186 echo stderr:; tee stderr <$at_stderr
   44187 $at_diff $at_devnull $at_stdout || at_failed=:
   44188 case $at_status in
   44189    77) echo 77 > $at_status_file
   44190             exit 77;;
   44191    1) ;;
   44192    *) echo "calc.at:605: exit code was $at_status, expected 1"
   44193       at_failed=:;;
   44194 esac
   44195 if $at_failed; then
   44196 
   44197   echo 1 > $at_status_file
   44198   exit 1
   44199 fi
   44200 
   44201 $at_traceon
   44202 
   44203 
   44204 # Normalize the observed and expected error messages, depending upon the
   44205 # options.
   44206 # 1. Remove the traces from observed.
   44207 sed '/^Starting/d
   44208 /^Entering/d
   44209 /^Stack/d
   44210 /^Reading/d
   44211 /^Reducing/d
   44212 /^Shifting/d
   44213 /^state/d
   44214 /^Cleanup:/d
   44215 /^Error:/d
   44216 /^Next/d
   44217 /^Discarding/d
   44218 / \$[0-9$]* = /d
   44219 /^yydestructor:/d' stderr >at-stderr
   44220 mv at-stderr stderr
   44221 # 2. Create the reference error message.
   44222 cat >expout <<'_ATEOF'
   44223 1.2: syntax error, unexpected number
   44224 _ATEOF
   44225 
   44226 # 3. If locations are not used, remove them.
   44227 
   44228 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   44229 
   44230 # 5. Check
   44231 $at_traceoff
   44232 echo "calc.at:605: cat stderr"
   44233 echo calc.at:605 >$at_check_line_file
   44234 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   44235 at_status=$?
   44236 grep '^ *+' $at_stder1 >&2
   44237 grep -v '^ *+' $at_stder1 >$at_stderr
   44238 at_failed=false
   44239 $at_diff $at_devnull $at_stderr || at_failed=:
   44240 $at_diff expout $at_stdout || at_failed=:
   44241 case $at_status in
   44242    77) echo 77 > $at_status_file
   44243             exit 77;;
   44244    0) ;;
   44245    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44246       at_failed=:;;
   44247 esac
   44248 if $at_failed; then
   44249 
   44250   echo 1 > $at_status_file
   44251   exit 1
   44252 fi
   44253 
   44254 $at_traceon
   44255 
   44256 
   44257 cat >input <<'_ATEOF'
   44258 1//2
   44259 _ATEOF
   44260 
   44261 $at_traceoff
   44262 echo "calc.at:605: \$PREPARSER ./calc input"
   44263 echo calc.at:605 >$at_check_line_file
   44264 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   44265 at_status=$?
   44266 grep '^ *+' $at_stder1 >&2
   44267 grep -v '^ *+' $at_stder1 >$at_stderr
   44268 at_failed=false
   44269 echo stderr:; tee stderr <$at_stderr
   44270 $at_diff $at_devnull $at_stdout || at_failed=:
   44271 case $at_status in
   44272    77) echo 77 > $at_status_file
   44273             exit 77;;
   44274    1) ;;
   44275    *) echo "calc.at:605: exit code was $at_status, expected 1"
   44276       at_failed=:;;
   44277 esac
   44278 if $at_failed; then
   44279 
   44280   echo 1 > $at_status_file
   44281   exit 1
   44282 fi
   44283 
   44284 $at_traceon
   44285 
   44286 
   44287 # Normalize the observed and expected error messages, depending upon the
   44288 # options.
   44289 # 1. Remove the traces from observed.
   44290 sed '/^Starting/d
   44291 /^Entering/d
   44292 /^Stack/d
   44293 /^Reading/d
   44294 /^Reducing/d
   44295 /^Shifting/d
   44296 /^state/d
   44297 /^Cleanup:/d
   44298 /^Error:/d
   44299 /^Next/d
   44300 /^Discarding/d
   44301 / \$[0-9$]* = /d
   44302 /^yydestructor:/d' stderr >at-stderr
   44303 mv at-stderr stderr
   44304 # 2. Create the reference error message.
   44305 cat >expout <<'_ATEOF'
   44306 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   44307 _ATEOF
   44308 
   44309 # 3. If locations are not used, remove them.
   44310 
   44311 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   44312 
   44313 # 5. Check
   44314 $at_traceoff
   44315 echo "calc.at:605: cat stderr"
   44316 echo calc.at:605 >$at_check_line_file
   44317 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   44318 at_status=$?
   44319 grep '^ *+' $at_stder1 >&2
   44320 grep -v '^ *+' $at_stder1 >$at_stderr
   44321 at_failed=false
   44322 $at_diff $at_devnull $at_stderr || at_failed=:
   44323 $at_diff expout $at_stdout || at_failed=:
   44324 case $at_status in
   44325    77) echo 77 > $at_status_file
   44326             exit 77;;
   44327    0) ;;
   44328    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44329       at_failed=:;;
   44330 esac
   44331 if $at_failed; then
   44332 
   44333   echo 1 > $at_status_file
   44334   exit 1
   44335 fi
   44336 
   44337 $at_traceon
   44338 
   44339 
   44340 cat >input <<'_ATEOF'
   44341 error
   44342 _ATEOF
   44343 
   44344 $at_traceoff
   44345 echo "calc.at:605: \$PREPARSER ./calc input"
   44346 echo calc.at:605 >$at_check_line_file
   44347 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   44348 at_status=$?
   44349 grep '^ *+' $at_stder1 >&2
   44350 grep -v '^ *+' $at_stder1 >$at_stderr
   44351 at_failed=false
   44352 echo stderr:; tee stderr <$at_stderr
   44353 $at_diff $at_devnull $at_stdout || at_failed=:
   44354 case $at_status in
   44355    77) echo 77 > $at_status_file
   44356             exit 77;;
   44357    1) ;;
   44358    *) echo "calc.at:605: exit code was $at_status, expected 1"
   44359       at_failed=:;;
   44360 esac
   44361 if $at_failed; then
   44362 
   44363   echo 1 > $at_status_file
   44364   exit 1
   44365 fi
   44366 
   44367 $at_traceon
   44368 
   44369 
   44370 # Normalize the observed and expected error messages, depending upon the
   44371 # options.
   44372 # 1. Remove the traces from observed.
   44373 sed '/^Starting/d
   44374 /^Entering/d
   44375 /^Stack/d
   44376 /^Reading/d
   44377 /^Reducing/d
   44378 /^Shifting/d
   44379 /^state/d
   44380 /^Cleanup:/d
   44381 /^Error:/d
   44382 /^Next/d
   44383 /^Discarding/d
   44384 / \$[0-9$]* = /d
   44385 /^yydestructor:/d' stderr >at-stderr
   44386 mv at-stderr stderr
   44387 # 2. Create the reference error message.
   44388 cat >expout <<'_ATEOF'
   44389 1.0: syntax error, unexpected $undefined
   44390 _ATEOF
   44391 
   44392 # 3. If locations are not used, remove them.
   44393 
   44394 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   44395 
   44396 # 5. Check
   44397 $at_traceoff
   44398 echo "calc.at:605: cat stderr"
   44399 echo calc.at:605 >$at_check_line_file
   44400 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   44401 at_status=$?
   44402 grep '^ *+' $at_stder1 >&2
   44403 grep -v '^ *+' $at_stder1 >$at_stderr
   44404 at_failed=false
   44405 $at_diff $at_devnull $at_stderr || at_failed=:
   44406 $at_diff expout $at_stdout || at_failed=:
   44407 case $at_status in
   44408    77) echo 77 > $at_status_file
   44409             exit 77;;
   44410    0) ;;
   44411    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44412       at_failed=:;;
   44413 esac
   44414 if $at_failed; then
   44415 
   44416   echo 1 > $at_status_file
   44417   exit 1
   44418 fi
   44419 
   44420 $at_traceon
   44421 
   44422 
   44423 cat >input <<'_ATEOF'
   44424 1 = 2 = 3
   44425 _ATEOF
   44426 
   44427 $at_traceoff
   44428 echo "calc.at:605: \$PREPARSER ./calc input"
   44429 echo calc.at:605 >$at_check_line_file
   44430 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   44431 at_status=$?
   44432 grep '^ *+' $at_stder1 >&2
   44433 grep -v '^ *+' $at_stder1 >$at_stderr
   44434 at_failed=false
   44435 echo stderr:; tee stderr <$at_stderr
   44436 $at_diff $at_devnull $at_stdout || at_failed=:
   44437 case $at_status in
   44438    77) echo 77 > $at_status_file
   44439             exit 77;;
   44440    1) ;;
   44441    *) echo "calc.at:605: exit code was $at_status, expected 1"
   44442       at_failed=:;;
   44443 esac
   44444 if $at_failed; then
   44445 
   44446   echo 1 > $at_status_file
   44447   exit 1
   44448 fi
   44449 
   44450 $at_traceon
   44451 
   44452 
   44453 # Normalize the observed and expected error messages, depending upon the
   44454 # options.
   44455 # 1. Remove the traces from observed.
   44456 sed '/^Starting/d
   44457 /^Entering/d
   44458 /^Stack/d
   44459 /^Reading/d
   44460 /^Reducing/d
   44461 /^Shifting/d
   44462 /^state/d
   44463 /^Cleanup:/d
   44464 /^Error:/d
   44465 /^Next/d
   44466 /^Discarding/d
   44467 / \$[0-9$]* = /d
   44468 /^yydestructor:/d' stderr >at-stderr
   44469 mv at-stderr stderr
   44470 # 2. Create the reference error message.
   44471 cat >expout <<'_ATEOF'
   44472 1.6: syntax error, unexpected '='
   44473 _ATEOF
   44474 
   44475 # 3. If locations are not used, remove them.
   44476 
   44477 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   44478 
   44479 # 5. Check
   44480 $at_traceoff
   44481 echo "calc.at:605: cat stderr"
   44482 echo calc.at:605 >$at_check_line_file
   44483 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   44484 at_status=$?
   44485 grep '^ *+' $at_stder1 >&2
   44486 grep -v '^ *+' $at_stder1 >$at_stderr
   44487 at_failed=false
   44488 $at_diff $at_devnull $at_stderr || at_failed=:
   44489 $at_diff expout $at_stdout || at_failed=:
   44490 case $at_status in
   44491    77) echo 77 > $at_status_file
   44492             exit 77;;
   44493    0) ;;
   44494    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44495       at_failed=:;;
   44496 esac
   44497 if $at_failed; then
   44498 
   44499   echo 1 > $at_status_file
   44500   exit 1
   44501 fi
   44502 
   44503 $at_traceon
   44504 
   44505 
   44506 cat >input <<'_ATEOF'
   44507 
   44508 +1
   44509 _ATEOF
   44510 
   44511 $at_traceoff
   44512 echo "calc.at:605: \$PREPARSER ./calc input"
   44513 echo calc.at:605 >$at_check_line_file
   44514 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   44515 at_status=$?
   44516 grep '^ *+' $at_stder1 >&2
   44517 grep -v '^ *+' $at_stder1 >$at_stderr
   44518 at_failed=false
   44519 echo stderr:; tee stderr <$at_stderr
   44520 $at_diff $at_devnull $at_stdout || at_failed=:
   44521 case $at_status in
   44522    77) echo 77 > $at_status_file
   44523             exit 77;;
   44524    1) ;;
   44525    *) echo "calc.at:605: exit code was $at_status, expected 1"
   44526       at_failed=:;;
   44527 esac
   44528 if $at_failed; then
   44529 
   44530   echo 1 > $at_status_file
   44531   exit 1
   44532 fi
   44533 
   44534 $at_traceon
   44535 
   44536 
   44537 # Normalize the observed and expected error messages, depending upon the
   44538 # options.
   44539 # 1. Remove the traces from observed.
   44540 sed '/^Starting/d
   44541 /^Entering/d
   44542 /^Stack/d
   44543 /^Reading/d
   44544 /^Reducing/d
   44545 /^Shifting/d
   44546 /^state/d
   44547 /^Cleanup:/d
   44548 /^Error:/d
   44549 /^Next/d
   44550 /^Discarding/d
   44551 / \$[0-9$]* = /d
   44552 /^yydestructor:/d' stderr >at-stderr
   44553 mv at-stderr stderr
   44554 # 2. Create the reference error message.
   44555 cat >expout <<'_ATEOF'
   44556 2.0: syntax error, unexpected '+'
   44557 _ATEOF
   44558 
   44559 # 3. If locations are not used, remove them.
   44560 
   44561 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   44562 
   44563 # 5. Check
   44564 $at_traceoff
   44565 echo "calc.at:605: cat stderr"
   44566 echo calc.at:605 >$at_check_line_file
   44567 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   44568 at_status=$?
   44569 grep '^ *+' $at_stder1 >&2
   44570 grep -v '^ *+' $at_stder1 >$at_stderr
   44571 at_failed=false
   44572 $at_diff $at_devnull $at_stderr || at_failed=:
   44573 $at_diff expout $at_stdout || at_failed=:
   44574 case $at_status in
   44575    77) echo 77 > $at_status_file
   44576             exit 77;;
   44577    0) ;;
   44578    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44579       at_failed=:;;
   44580 esac
   44581 if $at_failed; then
   44582 
   44583   echo 1 > $at_status_file
   44584   exit 1
   44585 fi
   44586 
   44587 $at_traceon
   44588 
   44589 
   44590 # Exercise error messages with EOF: work on an empty file.
   44591 $at_traceoff
   44592 echo "calc.at:605: \$PREPARSER ./calc /dev/null"
   44593 echo calc.at:605 >$at_check_line_file
   44594 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   44595 at_status=$?
   44596 grep '^ *+' $at_stder1 >&2
   44597 grep -v '^ *+' $at_stder1 >$at_stderr
   44598 at_failed=false
   44599 echo stderr:; tee stderr <$at_stderr
   44600 $at_diff $at_devnull $at_stdout || at_failed=:
   44601 case $at_status in
   44602    77) echo 77 > $at_status_file
   44603             exit 77;;
   44604    1) ;;
   44605    *) echo "calc.at:605: exit code was $at_status, expected 1"
   44606       at_failed=:;;
   44607 esac
   44608 if $at_failed; then
   44609 
   44610   echo 1 > $at_status_file
   44611   exit 1
   44612 fi
   44613 
   44614 $at_traceon
   44615 
   44616 
   44617 # Normalize the observed and expected error messages, depending upon the
   44618 # options.
   44619 # 1. Remove the traces from observed.
   44620 sed '/^Starting/d
   44621 /^Entering/d
   44622 /^Stack/d
   44623 /^Reading/d
   44624 /^Reducing/d
   44625 /^Shifting/d
   44626 /^state/d
   44627 /^Cleanup:/d
   44628 /^Error:/d
   44629 /^Next/d
   44630 /^Discarding/d
   44631 / \$[0-9$]* = /d
   44632 /^yydestructor:/d' stderr >at-stderr
   44633 mv at-stderr stderr
   44634 # 2. Create the reference error message.
   44635 cat >expout <<'_ATEOF'
   44636 1.0: syntax error, unexpected end of input
   44637 _ATEOF
   44638 
   44639 # 3. If locations are not used, remove them.
   44640 
   44641 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   44642 
   44643 # 5. Check
   44644 $at_traceoff
   44645 echo "calc.at:605: cat stderr"
   44646 echo calc.at:605 >$at_check_line_file
   44647 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   44648 at_status=$?
   44649 grep '^ *+' $at_stder1 >&2
   44650 grep -v '^ *+' $at_stder1 >$at_stderr
   44651 at_failed=false
   44652 $at_diff $at_devnull $at_stderr || at_failed=:
   44653 $at_diff expout $at_stdout || at_failed=:
   44654 case $at_status in
   44655    77) echo 77 > $at_status_file
   44656             exit 77;;
   44657    0) ;;
   44658    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44659       at_failed=:;;
   44660 esac
   44661 if $at_failed; then
   44662 
   44663   echo 1 > $at_status_file
   44664   exit 1
   44665 fi
   44666 
   44667 $at_traceon
   44668 
   44669 
   44670 
   44671 # Exercise the error token: without it, we die at the first error,
   44672 # hence be sure to
   44673 #
   44674 # - have several errors which exercise different shift/discardings
   44675 #   - (): nothing to pop, nothing to discard
   44676 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   44677 #   - (* * *): nothing to pop, a lot to discard
   44678 #   - (1 + 2 * *): some to pop and discard
   44679 #
   44680 # - test the action associated to `error'
   44681 #
   44682 # - check the look-ahead that triggers an error is not discarded
   44683 #   when we enter error recovery.  Below, the look-ahead causing the
   44684 #   first error is ")", which is needed to recover from the error and
   44685 #   produce the "0" that triggers the "0 != 1" error.
   44686 #
   44687 cat >input <<'_ATEOF'
   44688 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   44689 _ATEOF
   44690 
   44691 $at_traceoff
   44692 echo "calc.at:605: \$PREPARSER ./calc input"
   44693 echo calc.at:605 >$at_check_line_file
   44694 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   44695 at_status=$?
   44696 grep '^ *+' $at_stder1 >&2
   44697 grep -v '^ *+' $at_stder1 >$at_stderr
   44698 at_failed=false
   44699 echo stderr:; tee stderr <$at_stderr
   44700 $at_diff $at_devnull $at_stdout || at_failed=:
   44701 case $at_status in
   44702    77) echo 77 > $at_status_file
   44703             exit 77;;
   44704    0) ;;
   44705    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44706       at_failed=:;;
   44707 esac
   44708 if $at_failed; then
   44709 
   44710   echo 1 > $at_status_file
   44711   exit 1
   44712 fi
   44713 
   44714 $at_traceon
   44715 
   44716 
   44717 # Normalize the observed and expected error messages, depending upon the
   44718 # options.
   44719 # 1. Remove the traces from observed.
   44720 sed '/^Starting/d
   44721 /^Entering/d
   44722 /^Stack/d
   44723 /^Reading/d
   44724 /^Reducing/d
   44725 /^Shifting/d
   44726 /^state/d
   44727 /^Cleanup:/d
   44728 /^Error:/d
   44729 /^Next/d
   44730 /^Discarding/d
   44731 / \$[0-9$]* = /d
   44732 /^yydestructor:/d' stderr >at-stderr
   44733 mv at-stderr stderr
   44734 # 2. Create the reference error message.
   44735 cat >expout <<'_ATEOF'
   44736 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   44737 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   44738 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   44739 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   44740 calc: error: 4444 != 1
   44741 _ATEOF
   44742 
   44743 # 3. If locations are not used, remove them.
   44744 
   44745 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   44746 
   44747 # 5. Check
   44748 $at_traceoff
   44749 echo "calc.at:605: cat stderr"
   44750 echo calc.at:605 >$at_check_line_file
   44751 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   44752 at_status=$?
   44753 grep '^ *+' $at_stder1 >&2
   44754 grep -v '^ *+' $at_stder1 >$at_stderr
   44755 at_failed=false
   44756 $at_diff $at_devnull $at_stderr || at_failed=:
   44757 $at_diff expout $at_stdout || at_failed=:
   44758 case $at_status in
   44759    77) echo 77 > $at_status_file
   44760             exit 77;;
   44761    0) ;;
   44762    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44763       at_failed=:;;
   44764 esac
   44765 if $at_failed; then
   44766 
   44767   echo 1 > $at_status_file
   44768   exit 1
   44769 fi
   44770 
   44771 $at_traceon
   44772 
   44773 
   44774 
   44775 # The same, but this time exercising explicitly triggered syntax errors.
   44776 # POSIX says the look-ahead causing the error should not be discarded.
   44777 cat >input <<'_ATEOF'
   44778 (!) + (0 0) = 1
   44779 _ATEOF
   44780 
   44781 $at_traceoff
   44782 echo "calc.at:605: \$PREPARSER ./calc input"
   44783 echo calc.at:605 >$at_check_line_file
   44784 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   44785 at_status=$?
   44786 grep '^ *+' $at_stder1 >&2
   44787 grep -v '^ *+' $at_stder1 >$at_stderr
   44788 at_failed=false
   44789 echo stderr:; tee stderr <$at_stderr
   44790 $at_diff $at_devnull $at_stdout || at_failed=:
   44791 case $at_status in
   44792    77) echo 77 > $at_status_file
   44793             exit 77;;
   44794    0) ;;
   44795    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44796       at_failed=:;;
   44797 esac
   44798 if $at_failed; then
   44799 
   44800   echo 1 > $at_status_file
   44801   exit 1
   44802 fi
   44803 
   44804 $at_traceon
   44805 
   44806 
   44807 # Normalize the observed and expected error messages, depending upon the
   44808 # options.
   44809 # 1. Remove the traces from observed.
   44810 sed '/^Starting/d
   44811 /^Entering/d
   44812 /^Stack/d
   44813 /^Reading/d
   44814 /^Reducing/d
   44815 /^Shifting/d
   44816 /^state/d
   44817 /^Cleanup:/d
   44818 /^Error:/d
   44819 /^Next/d
   44820 /^Discarding/d
   44821 / \$[0-9$]* = /d
   44822 /^yydestructor:/d' stderr >at-stderr
   44823 mv at-stderr stderr
   44824 # 2. Create the reference error message.
   44825 cat >expout <<'_ATEOF'
   44826 1.9: syntax error, unexpected number
   44827 calc: error: 2222 != 1
   44828 _ATEOF
   44829 
   44830 # 3. If locations are not used, remove them.
   44831 
   44832 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   44833 
   44834 # 5. Check
   44835 $at_traceoff
   44836 echo "calc.at:605: cat stderr"
   44837 echo calc.at:605 >$at_check_line_file
   44838 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   44839 at_status=$?
   44840 grep '^ *+' $at_stder1 >&2
   44841 grep -v '^ *+' $at_stder1 >$at_stderr
   44842 at_failed=false
   44843 $at_diff $at_devnull $at_stderr || at_failed=:
   44844 $at_diff expout $at_stdout || at_failed=:
   44845 case $at_status in
   44846    77) echo 77 > $at_status_file
   44847             exit 77;;
   44848    0) ;;
   44849    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44850       at_failed=:;;
   44851 esac
   44852 if $at_failed; then
   44853 
   44854   echo 1 > $at_status_file
   44855   exit 1
   44856 fi
   44857 
   44858 $at_traceon
   44859 
   44860 
   44861 cat >input <<'_ATEOF'
   44862 (- *) + (0 0) = 1
   44863 _ATEOF
   44864 
   44865 $at_traceoff
   44866 echo "calc.at:605: \$PREPARSER ./calc input"
   44867 echo calc.at:605 >$at_check_line_file
   44868 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   44869 at_status=$?
   44870 grep '^ *+' $at_stder1 >&2
   44871 grep -v '^ *+' $at_stder1 >$at_stderr
   44872 at_failed=false
   44873 echo stderr:; tee stderr <$at_stderr
   44874 $at_diff $at_devnull $at_stdout || at_failed=:
   44875 case $at_status in
   44876    77) echo 77 > $at_status_file
   44877             exit 77;;
   44878    0) ;;
   44879    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44880       at_failed=:;;
   44881 esac
   44882 if $at_failed; then
   44883 
   44884   echo 1 > $at_status_file
   44885   exit 1
   44886 fi
   44887 
   44888 $at_traceon
   44889 
   44890 
   44891 # Normalize the observed and expected error messages, depending upon the
   44892 # options.
   44893 # 1. Remove the traces from observed.
   44894 sed '/^Starting/d
   44895 /^Entering/d
   44896 /^Stack/d
   44897 /^Reading/d
   44898 /^Reducing/d
   44899 /^Shifting/d
   44900 /^state/d
   44901 /^Cleanup:/d
   44902 /^Error:/d
   44903 /^Next/d
   44904 /^Discarding/d
   44905 / \$[0-9$]* = /d
   44906 /^yydestructor:/d' stderr >at-stderr
   44907 mv at-stderr stderr
   44908 # 2. Create the reference error message.
   44909 cat >expout <<'_ATEOF'
   44910 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   44911 1.11: syntax error, unexpected number
   44912 calc: error: 2222 != 1
   44913 _ATEOF
   44914 
   44915 # 3. If locations are not used, remove them.
   44916 
   44917 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   44918 
   44919 # 5. Check
   44920 $at_traceoff
   44921 echo "calc.at:605: cat stderr"
   44922 echo calc.at:605 >$at_check_line_file
   44923 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   44924 at_status=$?
   44925 grep '^ *+' $at_stder1 >&2
   44926 grep -v '^ *+' $at_stder1 >$at_stderr
   44927 at_failed=false
   44928 $at_diff $at_devnull $at_stderr || at_failed=:
   44929 $at_diff expout $at_stdout || at_failed=:
   44930 case $at_status in
   44931    77) echo 77 > $at_status_file
   44932             exit 77;;
   44933    0) ;;
   44934    *) echo "calc.at:605: exit code was $at_status, expected 0"
   44935       at_failed=:;;
   44936 esac
   44937 if $at_failed; then
   44938 
   44939   echo 1 > $at_status_file
   44940   exit 1
   44941 fi
   44942 
   44943 $at_traceon
   44944 
   44945 
   44946 
   44947 
   44948 
   44949 
   44950 
   44951 
   44952 
   44953 
   44954 
   44955 
   44956 
   44957 
   44958 
   44959 
   44960 
   44961 
   44962 
   44963 
   44964 
   44965 
   44966 
   44967 
   44968       $at_traceoff
   44969       $at_times_p && times >$at_times_file
   44970     ) 5>&1 2>&1 | eval $at_tee_pipe
   44971     at_status=`cat $at_status_file`
   44972     ;;
   44973 
   44974 
   44975   banner-11 ) # Banner 11. calc.at:612
   44976     cat <<\_ATEOF
   44977 
   44978 Simple LALR(1) C++ Calculator.
   44979 
   44980 _ATEOF
   44981     ;;
   44982 
   44983   98 ) # 98. calc.at:621: Calculator %skeleton "lalr1.cc" %defines %locations
   44984     at_setup_line='calc.at:621'
   44985     at_desc='Calculator %skeleton "lalr1.cc" %defines %locations '
   44986     $at_quiet $ECHO_N " 98: Calculator %skeleton "lalr1.cc" %defines %locations $ECHO_C"
   44987     at_xfail=no
   44988     (
   44989       echo "98. calc.at:621: testing ..."
   44990       $at_traceon
   44991 
   44992 
   44993 
   44994 
   44995 
   44996 
   44997 
   44998 
   44999 # Using yacc.c?
   45000 
   45001 
   45002 
   45003 
   45004 
   45005 
   45006 
   45007 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   45008 
   45009 # yyerror always sees the locations (when activated), except if
   45010 # yacc & pure & !param.
   45011 
   45012 
   45013 # The interface is pure: either because %pure-parser, or because we
   45014 # are using the C++ parsers.
   45015 
   45016 
   45017 
   45018 
   45019 
   45020 
   45021 
   45022 
   45023 
   45024 
   45025 
   45026 
   45027 cat >calc.y <<'_ATEOF'
   45028 %{
   45029 #ifdef HAVE_CONFIG_H
   45030 # include <config.h>
   45031   /* We don't need perfect functions for these tests. */
   45032 # undef malloc
   45033 # undef memcmp
   45034 # undef realloc
   45035 #endif
   45036 %}
   45037 
   45038 /* Infix notation calculator--calc */
   45039 %skeleton "lalr1.cc" %defines %locations
   45040 %define "global_tokens_and_yystype"
   45041 %{
   45042 #include <stdio.h>
   45043 
   45044 #include <stdlib.h>
   45045 #include <string.h>
   45046 #if HAVE_UNISTD_H
   45047 # include <unistd.h>
   45048 #else
   45049 # undef alarm
   45050 # define alarm(seconds) /* empty */
   45051 #endif
   45052 #include <ctype.h>
   45053 #define USE(Var)
   45054 
   45055 /* Exercise pre-prologue dependency to %union.  */
   45056 typedef int semantic_value;
   45057 
   45058 static semantic_value global_result = 0;
   45059 static int global_count = 0;
   45060 %}
   45061 
   45062 /* Exercise %union. */
   45063 %union
   45064 {
   45065   semantic_value ival;
   45066 };
   45067 
   45068 %{
   45069 static int power (int base, int exponent);
   45070 #ifndef YYLTYPE
   45071 # define YYLTYPE yy::location
   45072 #endif
   45073 #define first_line   begin.line
   45074 #define first_column begin.column
   45075 #define last_line    end.line
   45076 #define last_column  end.column
   45077 
   45078 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   45079 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   45080 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   45081 %}
   45082 
   45083 /* The lalr1.cc skeleton, for backward compatibility, defines
   45084    a constructor for position that initializes the filename.  The
   45085    glr.cc skeleton does not (and in fact cannot: location/position
   45086    are stored in a union, from which objects with constructors are
   45087    excluded in C++. */
   45088 %initial-action {
   45089   @$.initialize (0);
   45090 }
   45091 
   45092 
   45093 /* Bison Declarations */
   45094 %token CALC_EOF 0 "end of input"
   45095 %token <ival> NUM "number"
   45096 %type  <ival> exp
   45097 
   45098 %nonassoc '=' /* comparison	       */
   45099 %left '-' '+'
   45100 %left '*' '/'
   45101 %left NEG     /* negation--unary minus */
   45102 %right '^'    /* exponentiation        */
   45103 
   45104 /* Grammar follows */
   45105 %%
   45106 input:
   45107   line
   45108 | input line         {  }
   45109 ;
   45110 
   45111 line:
   45112   '\n'
   45113 | exp '\n'           { USE ($1); }
   45114 ;
   45115 
   45116 exp:
   45117   NUM                { $$ = $1;             }
   45118 | exp '=' exp
   45119   {
   45120     if ($1 != $3)
   45121       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   45122     $$ = $1;
   45123   }
   45124 | exp '+' exp        { $$ = $1 + $3;        }
   45125 | exp '-' exp        { $$ = $1 - $3;        }
   45126 | exp '*' exp        { $$ = $1 * $3;        }
   45127 | exp '/' exp        { $$ = $1 / $3;        }
   45128 | '-' exp  %prec NEG { $$ = -$2;            }
   45129 | exp '^' exp        { $$ = power ($1, $3); }
   45130 | '(' exp ')'        { $$ = $2;             }
   45131 | '(' error ')'      { $$ = 1111;           }
   45132 | '!'                { $$ = 0; YYERROR;     }
   45133 | '-' error          { $$ = 0; YYERROR;     }
   45134 ;
   45135 %%
   45136 /* The input.  */
   45137 static FILE *input;
   45138 
   45139 /* A C++ error reporting function.  */
   45140 void
   45141 yy::parser::error (const location& l, const std::string& m)
   45142 {
   45143   (void) l;
   45144   std::cerr << l << ": " << m << std::endl;
   45145 }
   45146 
   45147 int
   45148 yyparse ()
   45149 {
   45150   yy::parser parser;
   45151   parser.set_debug_level (!!YYDEBUG);
   45152   return parser.parse ();
   45153 }
   45154 
   45155 
   45156 
   45157 
   45158 static YYLTYPE last_yylloc;
   45159 
   45160 static int
   45161 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   45162 {
   45163   int res = getc (input);
   45164   (void) lvalp;(void) llocp;
   45165 
   45166   last_yylloc = (*llocp);
   45167   if (res == '\n')
   45168     {
   45169       (*llocp).last_line++;
   45170       (*llocp).last_column = 0;
   45171     }
   45172   else
   45173     (*llocp).last_column++;
   45174 
   45175   return res;
   45176 }
   45177 
   45178 
   45179 static void
   45180 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   45181 {
   45182   (void) lvalp;(void) llocp;
   45183 
   45184   /* Wrong when C == `\n'. */
   45185   (*llocp) = last_yylloc;
   45186 
   45187   ungetc (c, input);
   45188 }
   45189 
   45190 static int
   45191 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   45192 {
   45193   int c = get_char (lvalp, llocp);
   45194   int sign = 1;
   45195   int n = 0;
   45196 
   45197   (void) lvalp;(void) llocp;
   45198   if (c == '-')
   45199     {
   45200       c = get_char (lvalp, llocp);
   45201       sign = -1;
   45202     }
   45203 
   45204   while (isdigit (c))
   45205     {
   45206       n = 10 * n + (c - '0');
   45207       c = get_char (lvalp, llocp);
   45208     }
   45209 
   45210   unget_char (lvalp, llocp,  c);
   45211 
   45212   return sign * n;
   45213 }
   45214 
   45215 
   45216 
   45217 /*---------------------------------------------------------------.
   45218 | Lexical analyzer returns an integer on the stack and the token |
   45219 | NUM, or the ASCII character read if not a number.  Skips all   |
   45220 | blanks and tabs, returns 0 for EOF.                            |
   45221 `---------------------------------------------------------------*/
   45222 
   45223 static int
   45224 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   45225 {
   45226   static int init = 1;
   45227   int c;
   45228 
   45229   if (init)
   45230     {
   45231       init = 0;
   45232 
   45233       (*llocp).last_column = 0;
   45234       (*llocp).last_line = 1;
   45235 
   45236     }
   45237 
   45238 
   45239  (*llocp).first_column = (*llocp).last_column;
   45240   (*llocp).first_line   = (*llocp).last_line;
   45241 
   45242 
   45243   /* Skip white space.  */
   45244   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   45245     {
   45246      (*llocp).first_column = (*llocp).last_column;
   45247       (*llocp).first_line   = (*llocp).last_line;
   45248 
   45249     }
   45250 
   45251   /* process numbers   */
   45252   if (c == '.' || isdigit (c))
   45253     {
   45254       unget_char (lvalp, llocp,  c);
   45255       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   45256       return NUM;
   45257     }
   45258 
   45259   /* Return end-of-file.  */
   45260   if (c == EOF)
   45261     return CALC_EOF;
   45262 
   45263   /* Return single chars. */
   45264   return c;
   45265 }
   45266 
   45267 static int
   45268 power (int base, int exponent)
   45269 {
   45270   int res = 1;
   45271   if (exponent < 0)
   45272     exit (3);
   45273   for (/* Niente */; exponent; --exponent)
   45274     res *= base;
   45275   return res;
   45276 }
   45277 
   45278 
   45279 int
   45280 main (int argc, const char **argv)
   45281 {
   45282   semantic_value result = 0;
   45283   int count = 0;
   45284   int status;
   45285 
   45286   /* This used to be alarm (10), but that isn't enough time for
   45287      a July 1995 vintage DEC Alphastation 200 4/100 system,
   45288      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   45289   alarm (100);
   45290 
   45291   if (argc == 2)
   45292     input = fopen (argv[1], "r");
   45293   else
   45294     input = stdin;
   45295 
   45296   if (!input)
   45297     {
   45298       perror (argv[1]);
   45299       return 3;
   45300     }
   45301 
   45302 
   45303   status = yyparse ();
   45304   if (global_result != result)
   45305     abort ();
   45306   if (global_count != count)
   45307     abort ();
   45308   return status;
   45309 }
   45310 _ATEOF
   45311 
   45312 
   45313 
   45314 
   45315 
   45316 $at_traceoff
   45317 echo "calc.at:621: bison -o calc.cc calc.y"
   45318 echo calc.at:621 >$at_check_line_file
   45319 ( $at_traceon; bison -o calc.cc calc.y ) >$at_stdout 2>$at_stder1
   45320 at_status=$?
   45321 grep '^ *+' $at_stder1 >&2
   45322 grep -v '^ *+' $at_stder1 >$at_stderr
   45323 at_failed=false
   45324 $at_diff $at_devnull $at_stderr || at_failed=:
   45325 $at_diff $at_devnull $at_stdout || at_failed=:
   45326 case $at_status in
   45327    77) echo 77 > $at_status_file
   45328             exit 77;;
   45329    0) ;;
   45330    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45331       at_failed=:;;
   45332 esac
   45333 if $at_failed; then
   45334 
   45335   echo 1 > $at_status_file
   45336   exit 1
   45337 fi
   45338 
   45339 $at_traceon
   45340 
   45341 
   45342 $at_traceoff
   45343 echo "calc.at:621: \$BISON_CXX_WORKS"
   45344 echo calc.at:621 >$at_check_line_file
   45345 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   45346 at_status=$?
   45347 grep '^ *+' $at_stder1 >&2
   45348 grep -v '^ *+' $at_stder1 >$at_stderr
   45349 at_failed=false
   45350 echo stderr:; cat $at_stderr
   45351 echo stdout:; cat $at_stdout
   45352 case $at_status in
   45353    77) echo 77 > $at_status_file
   45354             exit 77;;
   45355    0) ;;
   45356    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45357       at_failed=:;;
   45358 esac
   45359 if $at_failed; then
   45360 
   45361   echo 1 > $at_status_file
   45362   exit 1
   45363 fi
   45364 
   45365 $at_traceon
   45366 
   45367 $at_traceoff
   45368 echo "calc.at:621: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.cc \$LIBS"
   45369 echo calc.at:621 >$at_check_line_file
   45370 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o calc calc.cc $LIBS ) >$at_stdout 2>$at_stder1
   45371 at_status=$?
   45372 grep '^ *+' $at_stder1 >&2
   45373 grep -v '^ *+' $at_stder1 >$at_stderr
   45374 at_failed=false
   45375 echo stderr:; cat $at_stderr
   45376 echo stdout:; cat $at_stdout
   45377 case $at_status in
   45378    77) echo 77 > $at_status_file
   45379             exit 77;;
   45380    0) ;;
   45381    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45382       at_failed=:;;
   45383 esac
   45384 if $at_failed; then
   45385 
   45386   echo 1 > $at_status_file
   45387   exit 1
   45388 fi
   45389 
   45390 $at_traceon
   45391 
   45392 
   45393 # Test the priorities.
   45394 cat >input <<'_ATEOF'
   45395 1 + 2 * 3 = 7
   45396 1 + 2 * -3 = -5
   45397 
   45398 -1^2 = -1
   45399 (-1)^2 = 1
   45400 
   45401 ---1 = -1
   45402 
   45403 1 - 2 - 3 = -4
   45404 1 - (2 - 3) = 2
   45405 
   45406 2^2^3 = 256
   45407 (2^2)^3 = 64
   45408 _ATEOF
   45409 
   45410 $at_traceoff
   45411 echo "calc.at:621: \$PREPARSER ./calc input"
   45412 echo calc.at:621 >$at_check_line_file
   45413 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   45414 at_status=$?
   45415 grep '^ *+' $at_stder1 >&2
   45416 grep -v '^ *+' $at_stder1 >$at_stderr
   45417 at_failed=false
   45418 echo stderr:; tee stderr <$at_stderr
   45419 $at_diff $at_devnull $at_stdout || at_failed=:
   45420 case $at_status in
   45421    77) echo 77 > $at_status_file
   45422             exit 77;;
   45423    0) ;;
   45424    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45425       at_failed=:;;
   45426 esac
   45427 if $at_failed; then
   45428 
   45429   echo 1 > $at_status_file
   45430   exit 1
   45431 fi
   45432 
   45433 $at_traceon
   45434 
   45435 
   45436 
   45437 # Some syntax errors.
   45438 cat >input <<'_ATEOF'
   45439 0 0
   45440 _ATEOF
   45441 
   45442 $at_traceoff
   45443 echo "calc.at:621: \$PREPARSER ./calc input"
   45444 echo calc.at:621 >$at_check_line_file
   45445 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   45446 at_status=$?
   45447 grep '^ *+' $at_stder1 >&2
   45448 grep -v '^ *+' $at_stder1 >$at_stderr
   45449 at_failed=false
   45450 echo stderr:; tee stderr <$at_stderr
   45451 $at_diff $at_devnull $at_stdout || at_failed=:
   45452 case $at_status in
   45453    77) echo 77 > $at_status_file
   45454             exit 77;;
   45455    1) ;;
   45456    *) echo "calc.at:621: exit code was $at_status, expected 1"
   45457       at_failed=:;;
   45458 esac
   45459 if $at_failed; then
   45460 
   45461   echo 1 > $at_status_file
   45462   exit 1
   45463 fi
   45464 
   45465 $at_traceon
   45466 
   45467 
   45468 # Normalize the observed and expected error messages, depending upon the
   45469 # options.
   45470 # 1. Remove the traces from observed.
   45471 sed '/^Starting/d
   45472 /^Entering/d
   45473 /^Stack/d
   45474 /^Reading/d
   45475 /^Reducing/d
   45476 /^Shifting/d
   45477 /^state/d
   45478 /^Cleanup:/d
   45479 /^Error:/d
   45480 /^Next/d
   45481 /^Discarding/d
   45482 / \$[0-9$]* = /d
   45483 /^yydestructor:/d' stderr >at-stderr
   45484 mv at-stderr stderr
   45485 # 2. Create the reference error message.
   45486 cat >expout <<'_ATEOF'
   45487 1.2: syntax error, unexpected number
   45488 _ATEOF
   45489 
   45490 # 3. If locations are not used, remove them.
   45491 
   45492 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   45493 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   45494 mv at-expout expout
   45495 # 5. Check
   45496 $at_traceoff
   45497 echo "calc.at:621: cat stderr"
   45498 echo calc.at:621 >$at_check_line_file
   45499 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   45500 at_status=$?
   45501 grep '^ *+' $at_stder1 >&2
   45502 grep -v '^ *+' $at_stder1 >$at_stderr
   45503 at_failed=false
   45504 $at_diff $at_devnull $at_stderr || at_failed=:
   45505 $at_diff expout $at_stdout || at_failed=:
   45506 case $at_status in
   45507    77) echo 77 > $at_status_file
   45508             exit 77;;
   45509    0) ;;
   45510    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45511       at_failed=:;;
   45512 esac
   45513 if $at_failed; then
   45514 
   45515   echo 1 > $at_status_file
   45516   exit 1
   45517 fi
   45518 
   45519 $at_traceon
   45520 
   45521 
   45522 cat >input <<'_ATEOF'
   45523 1//2
   45524 _ATEOF
   45525 
   45526 $at_traceoff
   45527 echo "calc.at:621: \$PREPARSER ./calc input"
   45528 echo calc.at:621 >$at_check_line_file
   45529 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   45530 at_status=$?
   45531 grep '^ *+' $at_stder1 >&2
   45532 grep -v '^ *+' $at_stder1 >$at_stderr
   45533 at_failed=false
   45534 echo stderr:; tee stderr <$at_stderr
   45535 $at_diff $at_devnull $at_stdout || at_failed=:
   45536 case $at_status in
   45537    77) echo 77 > $at_status_file
   45538             exit 77;;
   45539    1) ;;
   45540    *) echo "calc.at:621: exit code was $at_status, expected 1"
   45541       at_failed=:;;
   45542 esac
   45543 if $at_failed; then
   45544 
   45545   echo 1 > $at_status_file
   45546   exit 1
   45547 fi
   45548 
   45549 $at_traceon
   45550 
   45551 
   45552 # Normalize the observed and expected error messages, depending upon the
   45553 # options.
   45554 # 1. Remove the traces from observed.
   45555 sed '/^Starting/d
   45556 /^Entering/d
   45557 /^Stack/d
   45558 /^Reading/d
   45559 /^Reducing/d
   45560 /^Shifting/d
   45561 /^state/d
   45562 /^Cleanup:/d
   45563 /^Error:/d
   45564 /^Next/d
   45565 /^Discarding/d
   45566 / \$[0-9$]* = /d
   45567 /^yydestructor:/d' stderr >at-stderr
   45568 mv at-stderr stderr
   45569 # 2. Create the reference error message.
   45570 cat >expout <<'_ATEOF'
   45571 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   45572 _ATEOF
   45573 
   45574 # 3. If locations are not used, remove them.
   45575 
   45576 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   45577 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   45578 mv at-expout expout
   45579 # 5. Check
   45580 $at_traceoff
   45581 echo "calc.at:621: cat stderr"
   45582 echo calc.at:621 >$at_check_line_file
   45583 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   45584 at_status=$?
   45585 grep '^ *+' $at_stder1 >&2
   45586 grep -v '^ *+' $at_stder1 >$at_stderr
   45587 at_failed=false
   45588 $at_diff $at_devnull $at_stderr || at_failed=:
   45589 $at_diff expout $at_stdout || at_failed=:
   45590 case $at_status in
   45591    77) echo 77 > $at_status_file
   45592             exit 77;;
   45593    0) ;;
   45594    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45595       at_failed=:;;
   45596 esac
   45597 if $at_failed; then
   45598 
   45599   echo 1 > $at_status_file
   45600   exit 1
   45601 fi
   45602 
   45603 $at_traceon
   45604 
   45605 
   45606 cat >input <<'_ATEOF'
   45607 error
   45608 _ATEOF
   45609 
   45610 $at_traceoff
   45611 echo "calc.at:621: \$PREPARSER ./calc input"
   45612 echo calc.at:621 >$at_check_line_file
   45613 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   45614 at_status=$?
   45615 grep '^ *+' $at_stder1 >&2
   45616 grep -v '^ *+' $at_stder1 >$at_stderr
   45617 at_failed=false
   45618 echo stderr:; tee stderr <$at_stderr
   45619 $at_diff $at_devnull $at_stdout || at_failed=:
   45620 case $at_status in
   45621    77) echo 77 > $at_status_file
   45622             exit 77;;
   45623    1) ;;
   45624    *) echo "calc.at:621: exit code was $at_status, expected 1"
   45625       at_failed=:;;
   45626 esac
   45627 if $at_failed; then
   45628 
   45629   echo 1 > $at_status_file
   45630   exit 1
   45631 fi
   45632 
   45633 $at_traceon
   45634 
   45635 
   45636 # Normalize the observed and expected error messages, depending upon the
   45637 # options.
   45638 # 1. Remove the traces from observed.
   45639 sed '/^Starting/d
   45640 /^Entering/d
   45641 /^Stack/d
   45642 /^Reading/d
   45643 /^Reducing/d
   45644 /^Shifting/d
   45645 /^state/d
   45646 /^Cleanup:/d
   45647 /^Error:/d
   45648 /^Next/d
   45649 /^Discarding/d
   45650 / \$[0-9$]* = /d
   45651 /^yydestructor:/d' stderr >at-stderr
   45652 mv at-stderr stderr
   45653 # 2. Create the reference error message.
   45654 cat >expout <<'_ATEOF'
   45655 1.0: syntax error, unexpected $undefined
   45656 _ATEOF
   45657 
   45658 # 3. If locations are not used, remove them.
   45659 
   45660 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   45661 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   45662 mv at-expout expout
   45663 # 5. Check
   45664 $at_traceoff
   45665 echo "calc.at:621: cat stderr"
   45666 echo calc.at:621 >$at_check_line_file
   45667 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   45668 at_status=$?
   45669 grep '^ *+' $at_stder1 >&2
   45670 grep -v '^ *+' $at_stder1 >$at_stderr
   45671 at_failed=false
   45672 $at_diff $at_devnull $at_stderr || at_failed=:
   45673 $at_diff expout $at_stdout || at_failed=:
   45674 case $at_status in
   45675    77) echo 77 > $at_status_file
   45676             exit 77;;
   45677    0) ;;
   45678    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45679       at_failed=:;;
   45680 esac
   45681 if $at_failed; then
   45682 
   45683   echo 1 > $at_status_file
   45684   exit 1
   45685 fi
   45686 
   45687 $at_traceon
   45688 
   45689 
   45690 cat >input <<'_ATEOF'
   45691 1 = 2 = 3
   45692 _ATEOF
   45693 
   45694 $at_traceoff
   45695 echo "calc.at:621: \$PREPARSER ./calc input"
   45696 echo calc.at:621 >$at_check_line_file
   45697 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   45698 at_status=$?
   45699 grep '^ *+' $at_stder1 >&2
   45700 grep -v '^ *+' $at_stder1 >$at_stderr
   45701 at_failed=false
   45702 echo stderr:; tee stderr <$at_stderr
   45703 $at_diff $at_devnull $at_stdout || at_failed=:
   45704 case $at_status in
   45705    77) echo 77 > $at_status_file
   45706             exit 77;;
   45707    1) ;;
   45708    *) echo "calc.at:621: exit code was $at_status, expected 1"
   45709       at_failed=:;;
   45710 esac
   45711 if $at_failed; then
   45712 
   45713   echo 1 > $at_status_file
   45714   exit 1
   45715 fi
   45716 
   45717 $at_traceon
   45718 
   45719 
   45720 # Normalize the observed and expected error messages, depending upon the
   45721 # options.
   45722 # 1. Remove the traces from observed.
   45723 sed '/^Starting/d
   45724 /^Entering/d
   45725 /^Stack/d
   45726 /^Reading/d
   45727 /^Reducing/d
   45728 /^Shifting/d
   45729 /^state/d
   45730 /^Cleanup:/d
   45731 /^Error:/d
   45732 /^Next/d
   45733 /^Discarding/d
   45734 / \$[0-9$]* = /d
   45735 /^yydestructor:/d' stderr >at-stderr
   45736 mv at-stderr stderr
   45737 # 2. Create the reference error message.
   45738 cat >expout <<'_ATEOF'
   45739 1.6: syntax error, unexpected '='
   45740 _ATEOF
   45741 
   45742 # 3. If locations are not used, remove them.
   45743 
   45744 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   45745 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   45746 mv at-expout expout
   45747 # 5. Check
   45748 $at_traceoff
   45749 echo "calc.at:621: cat stderr"
   45750 echo calc.at:621 >$at_check_line_file
   45751 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   45752 at_status=$?
   45753 grep '^ *+' $at_stder1 >&2
   45754 grep -v '^ *+' $at_stder1 >$at_stderr
   45755 at_failed=false
   45756 $at_diff $at_devnull $at_stderr || at_failed=:
   45757 $at_diff expout $at_stdout || at_failed=:
   45758 case $at_status in
   45759    77) echo 77 > $at_status_file
   45760             exit 77;;
   45761    0) ;;
   45762    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45763       at_failed=:;;
   45764 esac
   45765 if $at_failed; then
   45766 
   45767   echo 1 > $at_status_file
   45768   exit 1
   45769 fi
   45770 
   45771 $at_traceon
   45772 
   45773 
   45774 cat >input <<'_ATEOF'
   45775 
   45776 +1
   45777 _ATEOF
   45778 
   45779 $at_traceoff
   45780 echo "calc.at:621: \$PREPARSER ./calc input"
   45781 echo calc.at:621 >$at_check_line_file
   45782 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   45783 at_status=$?
   45784 grep '^ *+' $at_stder1 >&2
   45785 grep -v '^ *+' $at_stder1 >$at_stderr
   45786 at_failed=false
   45787 echo stderr:; tee stderr <$at_stderr
   45788 $at_diff $at_devnull $at_stdout || at_failed=:
   45789 case $at_status in
   45790    77) echo 77 > $at_status_file
   45791             exit 77;;
   45792    1) ;;
   45793    *) echo "calc.at:621: exit code was $at_status, expected 1"
   45794       at_failed=:;;
   45795 esac
   45796 if $at_failed; then
   45797 
   45798   echo 1 > $at_status_file
   45799   exit 1
   45800 fi
   45801 
   45802 $at_traceon
   45803 
   45804 
   45805 # Normalize the observed and expected error messages, depending upon the
   45806 # options.
   45807 # 1. Remove the traces from observed.
   45808 sed '/^Starting/d
   45809 /^Entering/d
   45810 /^Stack/d
   45811 /^Reading/d
   45812 /^Reducing/d
   45813 /^Shifting/d
   45814 /^state/d
   45815 /^Cleanup:/d
   45816 /^Error:/d
   45817 /^Next/d
   45818 /^Discarding/d
   45819 / \$[0-9$]* = /d
   45820 /^yydestructor:/d' stderr >at-stderr
   45821 mv at-stderr stderr
   45822 # 2. Create the reference error message.
   45823 cat >expout <<'_ATEOF'
   45824 2.0: syntax error, unexpected '+'
   45825 _ATEOF
   45826 
   45827 # 3. If locations are not used, remove them.
   45828 
   45829 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   45830 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   45831 mv at-expout expout
   45832 # 5. Check
   45833 $at_traceoff
   45834 echo "calc.at:621: cat stderr"
   45835 echo calc.at:621 >$at_check_line_file
   45836 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   45837 at_status=$?
   45838 grep '^ *+' $at_stder1 >&2
   45839 grep -v '^ *+' $at_stder1 >$at_stderr
   45840 at_failed=false
   45841 $at_diff $at_devnull $at_stderr || at_failed=:
   45842 $at_diff expout $at_stdout || at_failed=:
   45843 case $at_status in
   45844    77) echo 77 > $at_status_file
   45845             exit 77;;
   45846    0) ;;
   45847    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45848       at_failed=:;;
   45849 esac
   45850 if $at_failed; then
   45851 
   45852   echo 1 > $at_status_file
   45853   exit 1
   45854 fi
   45855 
   45856 $at_traceon
   45857 
   45858 
   45859 # Exercise error messages with EOF: work on an empty file.
   45860 $at_traceoff
   45861 echo "calc.at:621: \$PREPARSER ./calc /dev/null"
   45862 echo calc.at:621 >$at_check_line_file
   45863 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   45864 at_status=$?
   45865 grep '^ *+' $at_stder1 >&2
   45866 grep -v '^ *+' $at_stder1 >$at_stderr
   45867 at_failed=false
   45868 echo stderr:; tee stderr <$at_stderr
   45869 $at_diff $at_devnull $at_stdout || at_failed=:
   45870 case $at_status in
   45871    77) echo 77 > $at_status_file
   45872             exit 77;;
   45873    1) ;;
   45874    *) echo "calc.at:621: exit code was $at_status, expected 1"
   45875       at_failed=:;;
   45876 esac
   45877 if $at_failed; then
   45878 
   45879   echo 1 > $at_status_file
   45880   exit 1
   45881 fi
   45882 
   45883 $at_traceon
   45884 
   45885 
   45886 # Normalize the observed and expected error messages, depending upon the
   45887 # options.
   45888 # 1. Remove the traces from observed.
   45889 sed '/^Starting/d
   45890 /^Entering/d
   45891 /^Stack/d
   45892 /^Reading/d
   45893 /^Reducing/d
   45894 /^Shifting/d
   45895 /^state/d
   45896 /^Cleanup:/d
   45897 /^Error:/d
   45898 /^Next/d
   45899 /^Discarding/d
   45900 / \$[0-9$]* = /d
   45901 /^yydestructor:/d' stderr >at-stderr
   45902 mv at-stderr stderr
   45903 # 2. Create the reference error message.
   45904 cat >expout <<'_ATEOF'
   45905 1.0: syntax error, unexpected end of input
   45906 _ATEOF
   45907 
   45908 # 3. If locations are not used, remove them.
   45909 
   45910 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   45911 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   45912 mv at-expout expout
   45913 # 5. Check
   45914 $at_traceoff
   45915 echo "calc.at:621: cat stderr"
   45916 echo calc.at:621 >$at_check_line_file
   45917 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   45918 at_status=$?
   45919 grep '^ *+' $at_stder1 >&2
   45920 grep -v '^ *+' $at_stder1 >$at_stderr
   45921 at_failed=false
   45922 $at_diff $at_devnull $at_stderr || at_failed=:
   45923 $at_diff expout $at_stdout || at_failed=:
   45924 case $at_status in
   45925    77) echo 77 > $at_status_file
   45926             exit 77;;
   45927    0) ;;
   45928    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45929       at_failed=:;;
   45930 esac
   45931 if $at_failed; then
   45932 
   45933   echo 1 > $at_status_file
   45934   exit 1
   45935 fi
   45936 
   45937 $at_traceon
   45938 
   45939 
   45940 
   45941 # Exercise the error token: without it, we die at the first error,
   45942 # hence be sure to
   45943 #
   45944 # - have several errors which exercise different shift/discardings
   45945 #   - (): nothing to pop, nothing to discard
   45946 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   45947 #   - (* * *): nothing to pop, a lot to discard
   45948 #   - (1 + 2 * *): some to pop and discard
   45949 #
   45950 # - test the action associated to `error'
   45951 #
   45952 # - check the look-ahead that triggers an error is not discarded
   45953 #   when we enter error recovery.  Below, the look-ahead causing the
   45954 #   first error is ")", which is needed to recover from the error and
   45955 #   produce the "0" that triggers the "0 != 1" error.
   45956 #
   45957 cat >input <<'_ATEOF'
   45958 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   45959 _ATEOF
   45960 
   45961 $at_traceoff
   45962 echo "calc.at:621: \$PREPARSER ./calc input"
   45963 echo calc.at:621 >$at_check_line_file
   45964 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   45965 at_status=$?
   45966 grep '^ *+' $at_stder1 >&2
   45967 grep -v '^ *+' $at_stder1 >$at_stderr
   45968 at_failed=false
   45969 echo stderr:; tee stderr <$at_stderr
   45970 $at_diff $at_devnull $at_stdout || at_failed=:
   45971 case $at_status in
   45972    77) echo 77 > $at_status_file
   45973             exit 77;;
   45974    0) ;;
   45975    *) echo "calc.at:621: exit code was $at_status, expected 0"
   45976       at_failed=:;;
   45977 esac
   45978 if $at_failed; then
   45979 
   45980   echo 1 > $at_status_file
   45981   exit 1
   45982 fi
   45983 
   45984 $at_traceon
   45985 
   45986 
   45987 # Normalize the observed and expected error messages, depending upon the
   45988 # options.
   45989 # 1. Remove the traces from observed.
   45990 sed '/^Starting/d
   45991 /^Entering/d
   45992 /^Stack/d
   45993 /^Reading/d
   45994 /^Reducing/d
   45995 /^Shifting/d
   45996 /^state/d
   45997 /^Cleanup:/d
   45998 /^Error:/d
   45999 /^Next/d
   46000 /^Discarding/d
   46001 / \$[0-9$]* = /d
   46002 /^yydestructor:/d' stderr >at-stderr
   46003 mv at-stderr stderr
   46004 # 2. Create the reference error message.
   46005 cat >expout <<'_ATEOF'
   46006 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   46007 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   46008 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   46009 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   46010 calc: error: 4444 != 1
   46011 _ATEOF
   46012 
   46013 # 3. If locations are not used, remove them.
   46014 
   46015 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   46016 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   46017 mv at-expout expout
   46018 # 5. Check
   46019 $at_traceoff
   46020 echo "calc.at:621: cat stderr"
   46021 echo calc.at:621 >$at_check_line_file
   46022 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   46023 at_status=$?
   46024 grep '^ *+' $at_stder1 >&2
   46025 grep -v '^ *+' $at_stder1 >$at_stderr
   46026 at_failed=false
   46027 $at_diff $at_devnull $at_stderr || at_failed=:
   46028 $at_diff expout $at_stdout || at_failed=:
   46029 case $at_status in
   46030    77) echo 77 > $at_status_file
   46031             exit 77;;
   46032    0) ;;
   46033    *) echo "calc.at:621: exit code was $at_status, expected 0"
   46034       at_failed=:;;
   46035 esac
   46036 if $at_failed; then
   46037 
   46038   echo 1 > $at_status_file
   46039   exit 1
   46040 fi
   46041 
   46042 $at_traceon
   46043 
   46044 
   46045 
   46046 # The same, but this time exercising explicitly triggered syntax errors.
   46047 # POSIX says the look-ahead causing the error should not be discarded.
   46048 cat >input <<'_ATEOF'
   46049 (!) + (0 0) = 1
   46050 _ATEOF
   46051 
   46052 $at_traceoff
   46053 echo "calc.at:621: \$PREPARSER ./calc input"
   46054 echo calc.at:621 >$at_check_line_file
   46055 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   46056 at_status=$?
   46057 grep '^ *+' $at_stder1 >&2
   46058 grep -v '^ *+' $at_stder1 >$at_stderr
   46059 at_failed=false
   46060 echo stderr:; tee stderr <$at_stderr
   46061 $at_diff $at_devnull $at_stdout || at_failed=:
   46062 case $at_status in
   46063    77) echo 77 > $at_status_file
   46064             exit 77;;
   46065    0) ;;
   46066    *) echo "calc.at:621: exit code was $at_status, expected 0"
   46067       at_failed=:;;
   46068 esac
   46069 if $at_failed; then
   46070 
   46071   echo 1 > $at_status_file
   46072   exit 1
   46073 fi
   46074 
   46075 $at_traceon
   46076 
   46077 
   46078 # Normalize the observed and expected error messages, depending upon the
   46079 # options.
   46080 # 1. Remove the traces from observed.
   46081 sed '/^Starting/d
   46082 /^Entering/d
   46083 /^Stack/d
   46084 /^Reading/d
   46085 /^Reducing/d
   46086 /^Shifting/d
   46087 /^state/d
   46088 /^Cleanup:/d
   46089 /^Error:/d
   46090 /^Next/d
   46091 /^Discarding/d
   46092 / \$[0-9$]* = /d
   46093 /^yydestructor:/d' stderr >at-stderr
   46094 mv at-stderr stderr
   46095 # 2. Create the reference error message.
   46096 cat >expout <<'_ATEOF'
   46097 1.9: syntax error, unexpected number
   46098 calc: error: 2222 != 1
   46099 _ATEOF
   46100 
   46101 # 3. If locations are not used, remove them.
   46102 
   46103 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   46104 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   46105 mv at-expout expout
   46106 # 5. Check
   46107 $at_traceoff
   46108 echo "calc.at:621: cat stderr"
   46109 echo calc.at:621 >$at_check_line_file
   46110 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   46111 at_status=$?
   46112 grep '^ *+' $at_stder1 >&2
   46113 grep -v '^ *+' $at_stder1 >$at_stderr
   46114 at_failed=false
   46115 $at_diff $at_devnull $at_stderr || at_failed=:
   46116 $at_diff expout $at_stdout || at_failed=:
   46117 case $at_status in
   46118    77) echo 77 > $at_status_file
   46119             exit 77;;
   46120    0) ;;
   46121    *) echo "calc.at:621: exit code was $at_status, expected 0"
   46122       at_failed=:;;
   46123 esac
   46124 if $at_failed; then
   46125 
   46126   echo 1 > $at_status_file
   46127   exit 1
   46128 fi
   46129 
   46130 $at_traceon
   46131 
   46132 
   46133 cat >input <<'_ATEOF'
   46134 (- *) + (0 0) = 1
   46135 _ATEOF
   46136 
   46137 $at_traceoff
   46138 echo "calc.at:621: \$PREPARSER ./calc input"
   46139 echo calc.at:621 >$at_check_line_file
   46140 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   46141 at_status=$?
   46142 grep '^ *+' $at_stder1 >&2
   46143 grep -v '^ *+' $at_stder1 >$at_stderr
   46144 at_failed=false
   46145 echo stderr:; tee stderr <$at_stderr
   46146 $at_diff $at_devnull $at_stdout || at_failed=:
   46147 case $at_status in
   46148    77) echo 77 > $at_status_file
   46149             exit 77;;
   46150    0) ;;
   46151    *) echo "calc.at:621: exit code was $at_status, expected 0"
   46152       at_failed=:;;
   46153 esac
   46154 if $at_failed; then
   46155 
   46156   echo 1 > $at_status_file
   46157   exit 1
   46158 fi
   46159 
   46160 $at_traceon
   46161 
   46162 
   46163 # Normalize the observed and expected error messages, depending upon the
   46164 # options.
   46165 # 1. Remove the traces from observed.
   46166 sed '/^Starting/d
   46167 /^Entering/d
   46168 /^Stack/d
   46169 /^Reading/d
   46170 /^Reducing/d
   46171 /^Shifting/d
   46172 /^state/d
   46173 /^Cleanup:/d
   46174 /^Error:/d
   46175 /^Next/d
   46176 /^Discarding/d
   46177 / \$[0-9$]* = /d
   46178 /^yydestructor:/d' stderr >at-stderr
   46179 mv at-stderr stderr
   46180 # 2. Create the reference error message.
   46181 cat >expout <<'_ATEOF'
   46182 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   46183 1.11: syntax error, unexpected number
   46184 calc: error: 2222 != 1
   46185 _ATEOF
   46186 
   46187 # 3. If locations are not used, remove them.
   46188 
   46189 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   46190 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   46191 mv at-expout expout
   46192 # 5. Check
   46193 $at_traceoff
   46194 echo "calc.at:621: cat stderr"
   46195 echo calc.at:621 >$at_check_line_file
   46196 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   46197 at_status=$?
   46198 grep '^ *+' $at_stder1 >&2
   46199 grep -v '^ *+' $at_stder1 >$at_stderr
   46200 at_failed=false
   46201 $at_diff $at_devnull $at_stderr || at_failed=:
   46202 $at_diff expout $at_stdout || at_failed=:
   46203 case $at_status in
   46204    77) echo 77 > $at_status_file
   46205             exit 77;;
   46206    0) ;;
   46207    *) echo "calc.at:621: exit code was $at_status, expected 0"
   46208       at_failed=:;;
   46209 esac
   46210 if $at_failed; then
   46211 
   46212   echo 1 > $at_status_file
   46213   exit 1
   46214 fi
   46215 
   46216 $at_traceon
   46217 
   46218 
   46219 
   46220 
   46221 
   46222 
   46223 
   46224 
   46225 
   46226 
   46227 
   46228 
   46229 
   46230 
   46231 
   46232 
   46233 
   46234 
   46235 
   46236 
   46237 
   46238 
   46239 
   46240 
   46241       $at_traceoff
   46242       $at_times_p && times >$at_times_file
   46243     ) 5>&1 2>&1 | eval $at_tee_pipe
   46244     at_status=`cat $at_status_file`
   46245     ;;
   46246 
   46247   99 ) # 99. calc.at:622: Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %name-prefix="calc" %verbose %yacc
   46248     at_setup_line='calc.at:622'
   46249     at_desc='Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %name-prefix="calc" %verbose %yacc'
   46250     $at_quiet $ECHO_N " 99: Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %name-prefix="calc" %verbose %yacc$ECHO_C"
   46251     at_xfail=no
   46252     (
   46253       echo "99. calc.at:622: testing ..."
   46254       $at_traceon
   46255 
   46256 
   46257 
   46258 
   46259 
   46260 
   46261 
   46262 
   46263 # Using yacc.c?
   46264 
   46265 
   46266 
   46267 
   46268 
   46269 
   46270 
   46271 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   46272 
   46273 # yyerror always sees the locations (when activated), except if
   46274 # yacc & pure & !param.
   46275 
   46276 
   46277 # The interface is pure: either because %pure-parser, or because we
   46278 # are using the C++ parsers.
   46279 
   46280 
   46281 
   46282 
   46283 
   46284 
   46285 
   46286 
   46287 
   46288 
   46289 
   46290 
   46291 cat >calc.y <<'_ATEOF'
   46292 %{
   46293 #ifdef HAVE_CONFIG_H
   46294 # include <config.h>
   46295   /* We don't need perfect functions for these tests. */
   46296 # undef malloc
   46297 # undef memcmp
   46298 # undef realloc
   46299 #endif
   46300 %}
   46301 
   46302 /* Infix notation calculator--calc */
   46303 %skeleton "lalr1.cc" %defines %locations %error-verbose %name-prefix="calc" %verbose %yacc
   46304 %define "global_tokens_and_yystype"
   46305 %{
   46306 #include <stdio.h>
   46307 
   46308 #include <stdlib.h>
   46309 #include <string.h>
   46310 #if HAVE_UNISTD_H
   46311 # include <unistd.h>
   46312 #else
   46313 # undef alarm
   46314 # define alarm(seconds) /* empty */
   46315 #endif
   46316 #include <ctype.h>
   46317 #define USE(Var)
   46318 
   46319 /* Exercise pre-prologue dependency to %union.  */
   46320 typedef int semantic_value;
   46321 
   46322 static semantic_value global_result = 0;
   46323 static int global_count = 0;
   46324 %}
   46325 
   46326 /* Exercise %union. */
   46327 %union
   46328 {
   46329   semantic_value ival;
   46330 };
   46331 
   46332 %{
   46333 static int power (int base, int exponent);
   46334 #ifndef YYLTYPE
   46335 # define YYLTYPE calc::location
   46336 #endif
   46337 #define first_line   begin.line
   46338 #define first_column begin.column
   46339 #define last_line    end.line
   46340 #define last_column  end.column
   46341 
   46342 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   46343 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   46344 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   46345 %}
   46346 
   46347 /* The lalr1.cc skeleton, for backward compatibility, defines
   46348    a constructor for position that initializes the filename.  The
   46349    glr.cc skeleton does not (and in fact cannot: location/position
   46350    are stored in a union, from which objects with constructors are
   46351    excluded in C++. */
   46352 %initial-action {
   46353   @$.initialize (0);
   46354 }
   46355 
   46356 
   46357 /* Bison Declarations */
   46358 %token CALC_EOF 0 "end of input"
   46359 %token <ival> NUM "number"
   46360 %type  <ival> exp
   46361 
   46362 %nonassoc '=' /* comparison	       */
   46363 %left '-' '+'
   46364 %left '*' '/'
   46365 %left NEG     /* negation--unary minus */
   46366 %right '^'    /* exponentiation        */
   46367 
   46368 /* Grammar follows */
   46369 %%
   46370 input:
   46371   line
   46372 | input line         {  }
   46373 ;
   46374 
   46375 line:
   46376   '\n'
   46377 | exp '\n'           { USE ($1); }
   46378 ;
   46379 
   46380 exp:
   46381   NUM                { $$ = $1;             }
   46382 | exp '=' exp
   46383   {
   46384     if ($1 != $3)
   46385       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   46386     $$ = $1;
   46387   }
   46388 | exp '+' exp        { $$ = $1 + $3;        }
   46389 | exp '-' exp        { $$ = $1 - $3;        }
   46390 | exp '*' exp        { $$ = $1 * $3;        }
   46391 | exp '/' exp        { $$ = $1 / $3;        }
   46392 | '-' exp  %prec NEG { $$ = -$2;            }
   46393 | exp '^' exp        { $$ = power ($1, $3); }
   46394 | '(' exp ')'        { $$ = $2;             }
   46395 | '(' error ')'      { $$ = 1111;           }
   46396 | '!'                { $$ = 0; YYERROR;     }
   46397 | '-' error          { $$ = 0; YYERROR;     }
   46398 ;
   46399 %%
   46400 /* The input.  */
   46401 static FILE *input;
   46402 
   46403 /* A C++ error reporting function.  */
   46404 void
   46405 calc::parser::error (const location& l, const std::string& m)
   46406 {
   46407   (void) l;
   46408   std::cerr << l << ": " << m << std::endl;
   46409 }
   46410 
   46411 int
   46412 yyparse ()
   46413 {
   46414   calc::parser parser;
   46415   parser.set_debug_level (!!YYDEBUG);
   46416   return parser.parse ();
   46417 }
   46418 
   46419 
   46420 
   46421 
   46422 static YYLTYPE last_yylloc;
   46423 
   46424 static int
   46425 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   46426 {
   46427   int res = getc (input);
   46428   (void) lvalp;(void) llocp;
   46429 
   46430   last_yylloc = (*llocp);
   46431   if (res == '\n')
   46432     {
   46433       (*llocp).last_line++;
   46434       (*llocp).last_column = 0;
   46435     }
   46436   else
   46437     (*llocp).last_column++;
   46438 
   46439   return res;
   46440 }
   46441 
   46442 
   46443 static void
   46444 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   46445 {
   46446   (void) lvalp;(void) llocp;
   46447 
   46448   /* Wrong when C == `\n'. */
   46449   (*llocp) = last_yylloc;
   46450 
   46451   ungetc (c, input);
   46452 }
   46453 
   46454 static int
   46455 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   46456 {
   46457   int c = get_char (lvalp, llocp);
   46458   int sign = 1;
   46459   int n = 0;
   46460 
   46461   (void) lvalp;(void) llocp;
   46462   if (c == '-')
   46463     {
   46464       c = get_char (lvalp, llocp);
   46465       sign = -1;
   46466     }
   46467 
   46468   while (isdigit (c))
   46469     {
   46470       n = 10 * n + (c - '0');
   46471       c = get_char (lvalp, llocp);
   46472     }
   46473 
   46474   unget_char (lvalp, llocp,  c);
   46475 
   46476   return sign * n;
   46477 }
   46478 
   46479 
   46480 
   46481 /*---------------------------------------------------------------.
   46482 | Lexical analyzer returns an integer on the stack and the token |
   46483 | NUM, or the ASCII character read if not a number.  Skips all   |
   46484 | blanks and tabs, returns 0 for EOF.                            |
   46485 `---------------------------------------------------------------*/
   46486 
   46487 static int
   46488 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   46489 {
   46490   static int init = 1;
   46491   int c;
   46492 
   46493   if (init)
   46494     {
   46495       init = 0;
   46496 
   46497       (*llocp).last_column = 0;
   46498       (*llocp).last_line = 1;
   46499 
   46500     }
   46501 
   46502 
   46503  (*llocp).first_column = (*llocp).last_column;
   46504   (*llocp).first_line   = (*llocp).last_line;
   46505 
   46506 
   46507   /* Skip white space.  */
   46508   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   46509     {
   46510      (*llocp).first_column = (*llocp).last_column;
   46511       (*llocp).first_line   = (*llocp).last_line;
   46512 
   46513     }
   46514 
   46515   /* process numbers   */
   46516   if (c == '.' || isdigit (c))
   46517     {
   46518       unget_char (lvalp, llocp,  c);
   46519       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   46520       return NUM;
   46521     }
   46522 
   46523   /* Return end-of-file.  */
   46524   if (c == EOF)
   46525     return CALC_EOF;
   46526 
   46527   /* Return single chars. */
   46528   return c;
   46529 }
   46530 
   46531 static int
   46532 power (int base, int exponent)
   46533 {
   46534   int res = 1;
   46535   if (exponent < 0)
   46536     exit (3);
   46537   for (/* Niente */; exponent; --exponent)
   46538     res *= base;
   46539   return res;
   46540 }
   46541 
   46542 
   46543 int
   46544 main (int argc, const char **argv)
   46545 {
   46546   semantic_value result = 0;
   46547   int count = 0;
   46548   int status;
   46549 
   46550   /* This used to be alarm (10), but that isn't enough time for
   46551      a July 1995 vintage DEC Alphastation 200 4/100 system,
   46552      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   46553   alarm (100);
   46554 
   46555   if (argc == 2)
   46556     input = fopen (argv[1], "r");
   46557   else
   46558     input = stdin;
   46559 
   46560   if (!input)
   46561     {
   46562       perror (argv[1]);
   46563       return 3;
   46564     }
   46565 
   46566 
   46567   status = yyparse ();
   46568   if (global_result != result)
   46569     abort ();
   46570   if (global_count != count)
   46571     abort ();
   46572   return status;
   46573 }
   46574 _ATEOF
   46575 
   46576 
   46577 
   46578 
   46579 
   46580 $at_traceoff
   46581 echo "calc.at:622: bison -o calc.cc calc.y"
   46582 echo calc.at:622 >$at_check_line_file
   46583 ( $at_traceon; bison -o calc.cc calc.y ) >$at_stdout 2>$at_stder1
   46584 at_status=$?
   46585 grep '^ *+' $at_stder1 >&2
   46586 grep -v '^ *+' $at_stder1 >$at_stderr
   46587 at_failed=false
   46588 $at_diff $at_devnull $at_stderr || at_failed=:
   46589 $at_diff $at_devnull $at_stdout || at_failed=:
   46590 case $at_status in
   46591    77) echo 77 > $at_status_file
   46592             exit 77;;
   46593    0) ;;
   46594    *) echo "calc.at:622: exit code was $at_status, expected 0"
   46595       at_failed=:;;
   46596 esac
   46597 if $at_failed; then
   46598 
   46599   echo 1 > $at_status_file
   46600   exit 1
   46601 fi
   46602 
   46603 $at_traceon
   46604 
   46605 
   46606 $at_traceoff
   46607 echo "calc.at:622: \$BISON_CXX_WORKS"
   46608 echo calc.at:622 >$at_check_line_file
   46609 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   46610 at_status=$?
   46611 grep '^ *+' $at_stder1 >&2
   46612 grep -v '^ *+' $at_stder1 >$at_stderr
   46613 at_failed=false
   46614 echo stderr:; cat $at_stderr
   46615 echo stdout:; cat $at_stdout
   46616 case $at_status in
   46617    77) echo 77 > $at_status_file
   46618             exit 77;;
   46619    0) ;;
   46620    *) echo "calc.at:622: exit code was $at_status, expected 0"
   46621       at_failed=:;;
   46622 esac
   46623 if $at_failed; then
   46624 
   46625   echo 1 > $at_status_file
   46626   exit 1
   46627 fi
   46628 
   46629 $at_traceon
   46630 
   46631 $at_traceoff
   46632 echo "calc.at:622: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.cc \$LIBS"
   46633 echo calc.at:622 >$at_check_line_file
   46634 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o calc calc.cc $LIBS ) >$at_stdout 2>$at_stder1
   46635 at_status=$?
   46636 grep '^ *+' $at_stder1 >&2
   46637 grep -v '^ *+' $at_stder1 >$at_stderr
   46638 at_failed=false
   46639 echo stderr:; cat $at_stderr
   46640 echo stdout:; cat $at_stdout
   46641 case $at_status in
   46642    77) echo 77 > $at_status_file
   46643             exit 77;;
   46644    0) ;;
   46645    *) echo "calc.at:622: exit code was $at_status, expected 0"
   46646       at_failed=:;;
   46647 esac
   46648 if $at_failed; then
   46649 
   46650   echo 1 > $at_status_file
   46651   exit 1
   46652 fi
   46653 
   46654 $at_traceon
   46655 
   46656 
   46657 # Test the priorities.
   46658 cat >input <<'_ATEOF'
   46659 1 + 2 * 3 = 7
   46660 1 + 2 * -3 = -5
   46661 
   46662 -1^2 = -1
   46663 (-1)^2 = 1
   46664 
   46665 ---1 = -1
   46666 
   46667 1 - 2 - 3 = -4
   46668 1 - (2 - 3) = 2
   46669 
   46670 2^2^3 = 256
   46671 (2^2)^3 = 64
   46672 _ATEOF
   46673 
   46674 $at_traceoff
   46675 echo "calc.at:622: \$PREPARSER ./calc input"
   46676 echo calc.at:622 >$at_check_line_file
   46677 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   46678 at_status=$?
   46679 grep '^ *+' $at_stder1 >&2
   46680 grep -v '^ *+' $at_stder1 >$at_stderr
   46681 at_failed=false
   46682 echo stderr:; tee stderr <$at_stderr
   46683 $at_diff $at_devnull $at_stdout || at_failed=:
   46684 case $at_status in
   46685    77) echo 77 > $at_status_file
   46686             exit 77;;
   46687    0) ;;
   46688    *) echo "calc.at:622: exit code was $at_status, expected 0"
   46689       at_failed=:;;
   46690 esac
   46691 if $at_failed; then
   46692 
   46693   echo 1 > $at_status_file
   46694   exit 1
   46695 fi
   46696 
   46697 $at_traceon
   46698 
   46699 
   46700 
   46701 # Some syntax errors.
   46702 cat >input <<'_ATEOF'
   46703 0 0
   46704 _ATEOF
   46705 
   46706 $at_traceoff
   46707 echo "calc.at:622: \$PREPARSER ./calc input"
   46708 echo calc.at:622 >$at_check_line_file
   46709 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   46710 at_status=$?
   46711 grep '^ *+' $at_stder1 >&2
   46712 grep -v '^ *+' $at_stder1 >$at_stderr
   46713 at_failed=false
   46714 echo stderr:; tee stderr <$at_stderr
   46715 $at_diff $at_devnull $at_stdout || at_failed=:
   46716 case $at_status in
   46717    77) echo 77 > $at_status_file
   46718             exit 77;;
   46719    1) ;;
   46720    *) echo "calc.at:622: exit code was $at_status, expected 1"
   46721       at_failed=:;;
   46722 esac
   46723 if $at_failed; then
   46724 
   46725   echo 1 > $at_status_file
   46726   exit 1
   46727 fi
   46728 
   46729 $at_traceon
   46730 
   46731 
   46732 # Normalize the observed and expected error messages, depending upon the
   46733 # options.
   46734 # 1. Remove the traces from observed.
   46735 sed '/^Starting/d
   46736 /^Entering/d
   46737 /^Stack/d
   46738 /^Reading/d
   46739 /^Reducing/d
   46740 /^Shifting/d
   46741 /^state/d
   46742 /^Cleanup:/d
   46743 /^Error:/d
   46744 /^Next/d
   46745 /^Discarding/d
   46746 / \$[0-9$]* = /d
   46747 /^yydestructor:/d' stderr >at-stderr
   46748 mv at-stderr stderr
   46749 # 2. Create the reference error message.
   46750 cat >expout <<'_ATEOF'
   46751 1.2: syntax error, unexpected number
   46752 _ATEOF
   46753 
   46754 # 3. If locations are not used, remove them.
   46755 
   46756 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   46757 
   46758 # 5. Check
   46759 $at_traceoff
   46760 echo "calc.at:622: cat stderr"
   46761 echo calc.at:622 >$at_check_line_file
   46762 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   46763 at_status=$?
   46764 grep '^ *+' $at_stder1 >&2
   46765 grep -v '^ *+' $at_stder1 >$at_stderr
   46766 at_failed=false
   46767 $at_diff $at_devnull $at_stderr || at_failed=:
   46768 $at_diff expout $at_stdout || at_failed=:
   46769 case $at_status in
   46770    77) echo 77 > $at_status_file
   46771             exit 77;;
   46772    0) ;;
   46773    *) echo "calc.at:622: exit code was $at_status, expected 0"
   46774       at_failed=:;;
   46775 esac
   46776 if $at_failed; then
   46777 
   46778   echo 1 > $at_status_file
   46779   exit 1
   46780 fi
   46781 
   46782 $at_traceon
   46783 
   46784 
   46785 cat >input <<'_ATEOF'
   46786 1//2
   46787 _ATEOF
   46788 
   46789 $at_traceoff
   46790 echo "calc.at:622: \$PREPARSER ./calc input"
   46791 echo calc.at:622 >$at_check_line_file
   46792 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   46793 at_status=$?
   46794 grep '^ *+' $at_stder1 >&2
   46795 grep -v '^ *+' $at_stder1 >$at_stderr
   46796 at_failed=false
   46797 echo stderr:; tee stderr <$at_stderr
   46798 $at_diff $at_devnull $at_stdout || at_failed=:
   46799 case $at_status in
   46800    77) echo 77 > $at_status_file
   46801             exit 77;;
   46802    1) ;;
   46803    *) echo "calc.at:622: exit code was $at_status, expected 1"
   46804       at_failed=:;;
   46805 esac
   46806 if $at_failed; then
   46807 
   46808   echo 1 > $at_status_file
   46809   exit 1
   46810 fi
   46811 
   46812 $at_traceon
   46813 
   46814 
   46815 # Normalize the observed and expected error messages, depending upon the
   46816 # options.
   46817 # 1. Remove the traces from observed.
   46818 sed '/^Starting/d
   46819 /^Entering/d
   46820 /^Stack/d
   46821 /^Reading/d
   46822 /^Reducing/d
   46823 /^Shifting/d
   46824 /^state/d
   46825 /^Cleanup:/d
   46826 /^Error:/d
   46827 /^Next/d
   46828 /^Discarding/d
   46829 / \$[0-9$]* = /d
   46830 /^yydestructor:/d' stderr >at-stderr
   46831 mv at-stderr stderr
   46832 # 2. Create the reference error message.
   46833 cat >expout <<'_ATEOF'
   46834 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   46835 _ATEOF
   46836 
   46837 # 3. If locations are not used, remove them.
   46838 
   46839 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   46840 
   46841 # 5. Check
   46842 $at_traceoff
   46843 echo "calc.at:622: cat stderr"
   46844 echo calc.at:622 >$at_check_line_file
   46845 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   46846 at_status=$?
   46847 grep '^ *+' $at_stder1 >&2
   46848 grep -v '^ *+' $at_stder1 >$at_stderr
   46849 at_failed=false
   46850 $at_diff $at_devnull $at_stderr || at_failed=:
   46851 $at_diff expout $at_stdout || at_failed=:
   46852 case $at_status in
   46853    77) echo 77 > $at_status_file
   46854             exit 77;;
   46855    0) ;;
   46856    *) echo "calc.at:622: exit code was $at_status, expected 0"
   46857       at_failed=:;;
   46858 esac
   46859 if $at_failed; then
   46860 
   46861   echo 1 > $at_status_file
   46862   exit 1
   46863 fi
   46864 
   46865 $at_traceon
   46866 
   46867 
   46868 cat >input <<'_ATEOF'
   46869 error
   46870 _ATEOF
   46871 
   46872 $at_traceoff
   46873 echo "calc.at:622: \$PREPARSER ./calc input"
   46874 echo calc.at:622 >$at_check_line_file
   46875 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   46876 at_status=$?
   46877 grep '^ *+' $at_stder1 >&2
   46878 grep -v '^ *+' $at_stder1 >$at_stderr
   46879 at_failed=false
   46880 echo stderr:; tee stderr <$at_stderr
   46881 $at_diff $at_devnull $at_stdout || at_failed=:
   46882 case $at_status in
   46883    77) echo 77 > $at_status_file
   46884             exit 77;;
   46885    1) ;;
   46886    *) echo "calc.at:622: exit code was $at_status, expected 1"
   46887       at_failed=:;;
   46888 esac
   46889 if $at_failed; then
   46890 
   46891   echo 1 > $at_status_file
   46892   exit 1
   46893 fi
   46894 
   46895 $at_traceon
   46896 
   46897 
   46898 # Normalize the observed and expected error messages, depending upon the
   46899 # options.
   46900 # 1. Remove the traces from observed.
   46901 sed '/^Starting/d
   46902 /^Entering/d
   46903 /^Stack/d
   46904 /^Reading/d
   46905 /^Reducing/d
   46906 /^Shifting/d
   46907 /^state/d
   46908 /^Cleanup:/d
   46909 /^Error:/d
   46910 /^Next/d
   46911 /^Discarding/d
   46912 / \$[0-9$]* = /d
   46913 /^yydestructor:/d' stderr >at-stderr
   46914 mv at-stderr stderr
   46915 # 2. Create the reference error message.
   46916 cat >expout <<'_ATEOF'
   46917 1.0: syntax error, unexpected $undefined
   46918 _ATEOF
   46919 
   46920 # 3. If locations are not used, remove them.
   46921 
   46922 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   46923 
   46924 # 5. Check
   46925 $at_traceoff
   46926 echo "calc.at:622: cat stderr"
   46927 echo calc.at:622 >$at_check_line_file
   46928 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   46929 at_status=$?
   46930 grep '^ *+' $at_stder1 >&2
   46931 grep -v '^ *+' $at_stder1 >$at_stderr
   46932 at_failed=false
   46933 $at_diff $at_devnull $at_stderr || at_failed=:
   46934 $at_diff expout $at_stdout || at_failed=:
   46935 case $at_status in
   46936    77) echo 77 > $at_status_file
   46937             exit 77;;
   46938    0) ;;
   46939    *) echo "calc.at:622: exit code was $at_status, expected 0"
   46940       at_failed=:;;
   46941 esac
   46942 if $at_failed; then
   46943 
   46944   echo 1 > $at_status_file
   46945   exit 1
   46946 fi
   46947 
   46948 $at_traceon
   46949 
   46950 
   46951 cat >input <<'_ATEOF'
   46952 1 = 2 = 3
   46953 _ATEOF
   46954 
   46955 $at_traceoff
   46956 echo "calc.at:622: \$PREPARSER ./calc input"
   46957 echo calc.at:622 >$at_check_line_file
   46958 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   46959 at_status=$?
   46960 grep '^ *+' $at_stder1 >&2
   46961 grep -v '^ *+' $at_stder1 >$at_stderr
   46962 at_failed=false
   46963 echo stderr:; tee stderr <$at_stderr
   46964 $at_diff $at_devnull $at_stdout || at_failed=:
   46965 case $at_status in
   46966    77) echo 77 > $at_status_file
   46967             exit 77;;
   46968    1) ;;
   46969    *) echo "calc.at:622: exit code was $at_status, expected 1"
   46970       at_failed=:;;
   46971 esac
   46972 if $at_failed; then
   46973 
   46974   echo 1 > $at_status_file
   46975   exit 1
   46976 fi
   46977 
   46978 $at_traceon
   46979 
   46980 
   46981 # Normalize the observed and expected error messages, depending upon the
   46982 # options.
   46983 # 1. Remove the traces from observed.
   46984 sed '/^Starting/d
   46985 /^Entering/d
   46986 /^Stack/d
   46987 /^Reading/d
   46988 /^Reducing/d
   46989 /^Shifting/d
   46990 /^state/d
   46991 /^Cleanup:/d
   46992 /^Error:/d
   46993 /^Next/d
   46994 /^Discarding/d
   46995 / \$[0-9$]* = /d
   46996 /^yydestructor:/d' stderr >at-stderr
   46997 mv at-stderr stderr
   46998 # 2. Create the reference error message.
   46999 cat >expout <<'_ATEOF'
   47000 1.6: syntax error, unexpected '='
   47001 _ATEOF
   47002 
   47003 # 3. If locations are not used, remove them.
   47004 
   47005 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   47006 
   47007 # 5. Check
   47008 $at_traceoff
   47009 echo "calc.at:622: cat stderr"
   47010 echo calc.at:622 >$at_check_line_file
   47011 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   47012 at_status=$?
   47013 grep '^ *+' $at_stder1 >&2
   47014 grep -v '^ *+' $at_stder1 >$at_stderr
   47015 at_failed=false
   47016 $at_diff $at_devnull $at_stderr || at_failed=:
   47017 $at_diff expout $at_stdout || at_failed=:
   47018 case $at_status in
   47019    77) echo 77 > $at_status_file
   47020             exit 77;;
   47021    0) ;;
   47022    *) echo "calc.at:622: exit code was $at_status, expected 0"
   47023       at_failed=:;;
   47024 esac
   47025 if $at_failed; then
   47026 
   47027   echo 1 > $at_status_file
   47028   exit 1
   47029 fi
   47030 
   47031 $at_traceon
   47032 
   47033 
   47034 cat >input <<'_ATEOF'
   47035 
   47036 +1
   47037 _ATEOF
   47038 
   47039 $at_traceoff
   47040 echo "calc.at:622: \$PREPARSER ./calc input"
   47041 echo calc.at:622 >$at_check_line_file
   47042 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   47043 at_status=$?
   47044 grep '^ *+' $at_stder1 >&2
   47045 grep -v '^ *+' $at_stder1 >$at_stderr
   47046 at_failed=false
   47047 echo stderr:; tee stderr <$at_stderr
   47048 $at_diff $at_devnull $at_stdout || at_failed=:
   47049 case $at_status in
   47050    77) echo 77 > $at_status_file
   47051             exit 77;;
   47052    1) ;;
   47053    *) echo "calc.at:622: exit code was $at_status, expected 1"
   47054       at_failed=:;;
   47055 esac
   47056 if $at_failed; then
   47057 
   47058   echo 1 > $at_status_file
   47059   exit 1
   47060 fi
   47061 
   47062 $at_traceon
   47063 
   47064 
   47065 # Normalize the observed and expected error messages, depending upon the
   47066 # options.
   47067 # 1. Remove the traces from observed.
   47068 sed '/^Starting/d
   47069 /^Entering/d
   47070 /^Stack/d
   47071 /^Reading/d
   47072 /^Reducing/d
   47073 /^Shifting/d
   47074 /^state/d
   47075 /^Cleanup:/d
   47076 /^Error:/d
   47077 /^Next/d
   47078 /^Discarding/d
   47079 / \$[0-9$]* = /d
   47080 /^yydestructor:/d' stderr >at-stderr
   47081 mv at-stderr stderr
   47082 # 2. Create the reference error message.
   47083 cat >expout <<'_ATEOF'
   47084 2.0: syntax error, unexpected '+'
   47085 _ATEOF
   47086 
   47087 # 3. If locations are not used, remove them.
   47088 
   47089 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   47090 
   47091 # 5. Check
   47092 $at_traceoff
   47093 echo "calc.at:622: cat stderr"
   47094 echo calc.at:622 >$at_check_line_file
   47095 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   47096 at_status=$?
   47097 grep '^ *+' $at_stder1 >&2
   47098 grep -v '^ *+' $at_stder1 >$at_stderr
   47099 at_failed=false
   47100 $at_diff $at_devnull $at_stderr || at_failed=:
   47101 $at_diff expout $at_stdout || at_failed=:
   47102 case $at_status in
   47103    77) echo 77 > $at_status_file
   47104             exit 77;;
   47105    0) ;;
   47106    *) echo "calc.at:622: exit code was $at_status, expected 0"
   47107       at_failed=:;;
   47108 esac
   47109 if $at_failed; then
   47110 
   47111   echo 1 > $at_status_file
   47112   exit 1
   47113 fi
   47114 
   47115 $at_traceon
   47116 
   47117 
   47118 # Exercise error messages with EOF: work on an empty file.
   47119 $at_traceoff
   47120 echo "calc.at:622: \$PREPARSER ./calc /dev/null"
   47121 echo calc.at:622 >$at_check_line_file
   47122 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   47123 at_status=$?
   47124 grep '^ *+' $at_stder1 >&2
   47125 grep -v '^ *+' $at_stder1 >$at_stderr
   47126 at_failed=false
   47127 echo stderr:; tee stderr <$at_stderr
   47128 $at_diff $at_devnull $at_stdout || at_failed=:
   47129 case $at_status in
   47130    77) echo 77 > $at_status_file
   47131             exit 77;;
   47132    1) ;;
   47133    *) echo "calc.at:622: exit code was $at_status, expected 1"
   47134       at_failed=:;;
   47135 esac
   47136 if $at_failed; then
   47137 
   47138   echo 1 > $at_status_file
   47139   exit 1
   47140 fi
   47141 
   47142 $at_traceon
   47143 
   47144 
   47145 # Normalize the observed and expected error messages, depending upon the
   47146 # options.
   47147 # 1. Remove the traces from observed.
   47148 sed '/^Starting/d
   47149 /^Entering/d
   47150 /^Stack/d
   47151 /^Reading/d
   47152 /^Reducing/d
   47153 /^Shifting/d
   47154 /^state/d
   47155 /^Cleanup:/d
   47156 /^Error:/d
   47157 /^Next/d
   47158 /^Discarding/d
   47159 / \$[0-9$]* = /d
   47160 /^yydestructor:/d' stderr >at-stderr
   47161 mv at-stderr stderr
   47162 # 2. Create the reference error message.
   47163 cat >expout <<'_ATEOF'
   47164 1.0: syntax error, unexpected end of input
   47165 _ATEOF
   47166 
   47167 # 3. If locations are not used, remove them.
   47168 
   47169 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   47170 
   47171 # 5. Check
   47172 $at_traceoff
   47173 echo "calc.at:622: cat stderr"
   47174 echo calc.at:622 >$at_check_line_file
   47175 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   47176 at_status=$?
   47177 grep '^ *+' $at_stder1 >&2
   47178 grep -v '^ *+' $at_stder1 >$at_stderr
   47179 at_failed=false
   47180 $at_diff $at_devnull $at_stderr || at_failed=:
   47181 $at_diff expout $at_stdout || at_failed=:
   47182 case $at_status in
   47183    77) echo 77 > $at_status_file
   47184             exit 77;;
   47185    0) ;;
   47186    *) echo "calc.at:622: exit code was $at_status, expected 0"
   47187       at_failed=:;;
   47188 esac
   47189 if $at_failed; then
   47190 
   47191   echo 1 > $at_status_file
   47192   exit 1
   47193 fi
   47194 
   47195 $at_traceon
   47196 
   47197 
   47198 
   47199 # Exercise the error token: without it, we die at the first error,
   47200 # hence be sure to
   47201 #
   47202 # - have several errors which exercise different shift/discardings
   47203 #   - (): nothing to pop, nothing to discard
   47204 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   47205 #   - (* * *): nothing to pop, a lot to discard
   47206 #   - (1 + 2 * *): some to pop and discard
   47207 #
   47208 # - test the action associated to `error'
   47209 #
   47210 # - check the look-ahead that triggers an error is not discarded
   47211 #   when we enter error recovery.  Below, the look-ahead causing the
   47212 #   first error is ")", which is needed to recover from the error and
   47213 #   produce the "0" that triggers the "0 != 1" error.
   47214 #
   47215 cat >input <<'_ATEOF'
   47216 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   47217 _ATEOF
   47218 
   47219 $at_traceoff
   47220 echo "calc.at:622: \$PREPARSER ./calc input"
   47221 echo calc.at:622 >$at_check_line_file
   47222 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   47223 at_status=$?
   47224 grep '^ *+' $at_stder1 >&2
   47225 grep -v '^ *+' $at_stder1 >$at_stderr
   47226 at_failed=false
   47227 echo stderr:; tee stderr <$at_stderr
   47228 $at_diff $at_devnull $at_stdout || at_failed=:
   47229 case $at_status in
   47230    77) echo 77 > $at_status_file
   47231             exit 77;;
   47232    0) ;;
   47233    *) echo "calc.at:622: exit code was $at_status, expected 0"
   47234       at_failed=:;;
   47235 esac
   47236 if $at_failed; then
   47237 
   47238   echo 1 > $at_status_file
   47239   exit 1
   47240 fi
   47241 
   47242 $at_traceon
   47243 
   47244 
   47245 # Normalize the observed and expected error messages, depending upon the
   47246 # options.
   47247 # 1. Remove the traces from observed.
   47248 sed '/^Starting/d
   47249 /^Entering/d
   47250 /^Stack/d
   47251 /^Reading/d
   47252 /^Reducing/d
   47253 /^Shifting/d
   47254 /^state/d
   47255 /^Cleanup:/d
   47256 /^Error:/d
   47257 /^Next/d
   47258 /^Discarding/d
   47259 / \$[0-9$]* = /d
   47260 /^yydestructor:/d' stderr >at-stderr
   47261 mv at-stderr stderr
   47262 # 2. Create the reference error message.
   47263 cat >expout <<'_ATEOF'
   47264 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   47265 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   47266 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   47267 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   47268 calc: error: 4444 != 1
   47269 _ATEOF
   47270 
   47271 # 3. If locations are not used, remove them.
   47272 
   47273 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   47274 
   47275 # 5. Check
   47276 $at_traceoff
   47277 echo "calc.at:622: cat stderr"
   47278 echo calc.at:622 >$at_check_line_file
   47279 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   47280 at_status=$?
   47281 grep '^ *+' $at_stder1 >&2
   47282 grep -v '^ *+' $at_stder1 >$at_stderr
   47283 at_failed=false
   47284 $at_diff $at_devnull $at_stderr || at_failed=:
   47285 $at_diff expout $at_stdout || at_failed=:
   47286 case $at_status in
   47287    77) echo 77 > $at_status_file
   47288             exit 77;;
   47289    0) ;;
   47290    *) echo "calc.at:622: exit code was $at_status, expected 0"
   47291       at_failed=:;;
   47292 esac
   47293 if $at_failed; then
   47294 
   47295   echo 1 > $at_status_file
   47296   exit 1
   47297 fi
   47298 
   47299 $at_traceon
   47300 
   47301 
   47302 
   47303 # The same, but this time exercising explicitly triggered syntax errors.
   47304 # POSIX says the look-ahead causing the error should not be discarded.
   47305 cat >input <<'_ATEOF'
   47306 (!) + (0 0) = 1
   47307 _ATEOF
   47308 
   47309 $at_traceoff
   47310 echo "calc.at:622: \$PREPARSER ./calc input"
   47311 echo calc.at:622 >$at_check_line_file
   47312 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   47313 at_status=$?
   47314 grep '^ *+' $at_stder1 >&2
   47315 grep -v '^ *+' $at_stder1 >$at_stderr
   47316 at_failed=false
   47317 echo stderr:; tee stderr <$at_stderr
   47318 $at_diff $at_devnull $at_stdout || at_failed=:
   47319 case $at_status in
   47320    77) echo 77 > $at_status_file
   47321             exit 77;;
   47322    0) ;;
   47323    *) echo "calc.at:622: exit code was $at_status, expected 0"
   47324       at_failed=:;;
   47325 esac
   47326 if $at_failed; then
   47327 
   47328   echo 1 > $at_status_file
   47329   exit 1
   47330 fi
   47331 
   47332 $at_traceon
   47333 
   47334 
   47335 # Normalize the observed and expected error messages, depending upon the
   47336 # options.
   47337 # 1. Remove the traces from observed.
   47338 sed '/^Starting/d
   47339 /^Entering/d
   47340 /^Stack/d
   47341 /^Reading/d
   47342 /^Reducing/d
   47343 /^Shifting/d
   47344 /^state/d
   47345 /^Cleanup:/d
   47346 /^Error:/d
   47347 /^Next/d
   47348 /^Discarding/d
   47349 / \$[0-9$]* = /d
   47350 /^yydestructor:/d' stderr >at-stderr
   47351 mv at-stderr stderr
   47352 # 2. Create the reference error message.
   47353 cat >expout <<'_ATEOF'
   47354 1.9: syntax error, unexpected number
   47355 calc: error: 2222 != 1
   47356 _ATEOF
   47357 
   47358 # 3. If locations are not used, remove them.
   47359 
   47360 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   47361 
   47362 # 5. Check
   47363 $at_traceoff
   47364 echo "calc.at:622: cat stderr"
   47365 echo calc.at:622 >$at_check_line_file
   47366 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   47367 at_status=$?
   47368 grep '^ *+' $at_stder1 >&2
   47369 grep -v '^ *+' $at_stder1 >$at_stderr
   47370 at_failed=false
   47371 $at_diff $at_devnull $at_stderr || at_failed=:
   47372 $at_diff expout $at_stdout || at_failed=:
   47373 case $at_status in
   47374    77) echo 77 > $at_status_file
   47375             exit 77;;
   47376    0) ;;
   47377    *) echo "calc.at:622: exit code was $at_status, expected 0"
   47378       at_failed=:;;
   47379 esac
   47380 if $at_failed; then
   47381 
   47382   echo 1 > $at_status_file
   47383   exit 1
   47384 fi
   47385 
   47386 $at_traceon
   47387 
   47388 
   47389 cat >input <<'_ATEOF'
   47390 (- *) + (0 0) = 1
   47391 _ATEOF
   47392 
   47393 $at_traceoff
   47394 echo "calc.at:622: \$PREPARSER ./calc input"
   47395 echo calc.at:622 >$at_check_line_file
   47396 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   47397 at_status=$?
   47398 grep '^ *+' $at_stder1 >&2
   47399 grep -v '^ *+' $at_stder1 >$at_stderr
   47400 at_failed=false
   47401 echo stderr:; tee stderr <$at_stderr
   47402 $at_diff $at_devnull $at_stdout || at_failed=:
   47403 case $at_status in
   47404    77) echo 77 > $at_status_file
   47405             exit 77;;
   47406    0) ;;
   47407    *) echo "calc.at:622: exit code was $at_status, expected 0"
   47408       at_failed=:;;
   47409 esac
   47410 if $at_failed; then
   47411 
   47412   echo 1 > $at_status_file
   47413   exit 1
   47414 fi
   47415 
   47416 $at_traceon
   47417 
   47418 
   47419 # Normalize the observed and expected error messages, depending upon the
   47420 # options.
   47421 # 1. Remove the traces from observed.
   47422 sed '/^Starting/d
   47423 /^Entering/d
   47424 /^Stack/d
   47425 /^Reading/d
   47426 /^Reducing/d
   47427 /^Shifting/d
   47428 /^state/d
   47429 /^Cleanup:/d
   47430 /^Error:/d
   47431 /^Next/d
   47432 /^Discarding/d
   47433 / \$[0-9$]* = /d
   47434 /^yydestructor:/d' stderr >at-stderr
   47435 mv at-stderr stderr
   47436 # 2. Create the reference error message.
   47437 cat >expout <<'_ATEOF'
   47438 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   47439 1.11: syntax error, unexpected number
   47440 calc: error: 2222 != 1
   47441 _ATEOF
   47442 
   47443 # 3. If locations are not used, remove them.
   47444 
   47445 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   47446 
   47447 # 5. Check
   47448 $at_traceoff
   47449 echo "calc.at:622: cat stderr"
   47450 echo calc.at:622 >$at_check_line_file
   47451 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   47452 at_status=$?
   47453 grep '^ *+' $at_stder1 >&2
   47454 grep -v '^ *+' $at_stder1 >$at_stderr
   47455 at_failed=false
   47456 $at_diff $at_devnull $at_stderr || at_failed=:
   47457 $at_diff expout $at_stdout || at_failed=:
   47458 case $at_status in
   47459    77) echo 77 > $at_status_file
   47460             exit 77;;
   47461    0) ;;
   47462    *) echo "calc.at:622: exit code was $at_status, expected 0"
   47463       at_failed=:;;
   47464 esac
   47465 if $at_failed; then
   47466 
   47467   echo 1 > $at_status_file
   47468   exit 1
   47469 fi
   47470 
   47471 $at_traceon
   47472 
   47473 
   47474 
   47475 
   47476 
   47477 
   47478 
   47479 
   47480 
   47481 
   47482 
   47483 
   47484 
   47485 
   47486 
   47487 
   47488 
   47489 
   47490 
   47491 
   47492 
   47493 
   47494 
   47495 
   47496       $at_traceoff
   47497       $at_times_p && times >$at_times_file
   47498     ) 5>&1 2>&1 | eval $at_tee_pipe
   47499     at_status=`cat $at_status_file`
   47500     ;;
   47501 
   47502   100 ) # 100. calc.at:624: Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %debug %name-prefix="calc" %verbose %yacc
   47503     at_setup_line='calc.at:624'
   47504     at_desc='Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %debug %name-prefix="calc" %verbose %yacc'
   47505     $at_quiet $ECHO_N "100: Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %debug %name-prefix="calc" %verbose %yacc$ECHO_C"
   47506     at_xfail=no
   47507     (
   47508       echo "100. calc.at:624: testing ..."
   47509       $at_traceon
   47510 
   47511 
   47512 
   47513 
   47514 
   47515 
   47516 
   47517 
   47518 # Using yacc.c?
   47519 
   47520 
   47521 
   47522 
   47523 
   47524 
   47525 
   47526 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   47527 
   47528 # yyerror always sees the locations (when activated), except if
   47529 # yacc & pure & !param.
   47530 
   47531 
   47532 # The interface is pure: either because %pure-parser, or because we
   47533 # are using the C++ parsers.
   47534 
   47535 
   47536 
   47537 
   47538 
   47539 
   47540 
   47541 
   47542 
   47543 
   47544 
   47545 
   47546 cat >calc.y <<'_ATEOF'
   47547 %{
   47548 #ifdef HAVE_CONFIG_H
   47549 # include <config.h>
   47550   /* We don't need perfect functions for these tests. */
   47551 # undef malloc
   47552 # undef memcmp
   47553 # undef realloc
   47554 #endif
   47555 %}
   47556 
   47557 /* Infix notation calculator--calc */
   47558 %skeleton "lalr1.cc" %defines %locations %error-verbose %debug %name-prefix="calc" %verbose %yacc
   47559 %define "global_tokens_and_yystype"
   47560 %{
   47561 #include <stdio.h>
   47562 
   47563 #include <stdlib.h>
   47564 #include <string.h>
   47565 #if HAVE_UNISTD_H
   47566 # include <unistd.h>
   47567 #else
   47568 # undef alarm
   47569 # define alarm(seconds) /* empty */
   47570 #endif
   47571 #include <ctype.h>
   47572 #define USE(Var)
   47573 
   47574 /* Exercise pre-prologue dependency to %union.  */
   47575 typedef int semantic_value;
   47576 
   47577 static semantic_value global_result = 0;
   47578 static int global_count = 0;
   47579 %}
   47580 
   47581 /* Exercise %union. */
   47582 %union
   47583 {
   47584   semantic_value ival;
   47585 };
   47586 
   47587 %{
   47588 static int power (int base, int exponent);
   47589 #ifndef YYLTYPE
   47590 # define YYLTYPE calc::location
   47591 #endif
   47592 #define first_line   begin.line
   47593 #define first_column begin.column
   47594 #define last_line    end.line
   47595 #define last_column  end.column
   47596 
   47597 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   47598 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   47599 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   47600 %}
   47601 
   47602 /* The lalr1.cc skeleton, for backward compatibility, defines
   47603    a constructor for position that initializes the filename.  The
   47604    glr.cc skeleton does not (and in fact cannot: location/position
   47605    are stored in a union, from which objects with constructors are
   47606    excluded in C++. */
   47607 %initial-action {
   47608   @$.initialize (0);
   47609 }
   47610 
   47611 
   47612 /* Bison Declarations */
   47613 %token CALC_EOF 0 "end of input"
   47614 %token <ival> NUM "number"
   47615 %type  <ival> exp
   47616 
   47617 %nonassoc '=' /* comparison	       */
   47618 %left '-' '+'
   47619 %left '*' '/'
   47620 %left NEG     /* negation--unary minus */
   47621 %right '^'    /* exponentiation        */
   47622 
   47623 /* Grammar follows */
   47624 %%
   47625 input:
   47626   line
   47627 | input line         {  }
   47628 ;
   47629 
   47630 line:
   47631   '\n'
   47632 | exp '\n'           { USE ($1); }
   47633 ;
   47634 
   47635 exp:
   47636   NUM                { $$ = $1;             }
   47637 | exp '=' exp
   47638   {
   47639     if ($1 != $3)
   47640       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   47641     $$ = $1;
   47642   }
   47643 | exp '+' exp        { $$ = $1 + $3;        }
   47644 | exp '-' exp        { $$ = $1 - $3;        }
   47645 | exp '*' exp        { $$ = $1 * $3;        }
   47646 | exp '/' exp        { $$ = $1 / $3;        }
   47647 | '-' exp  %prec NEG { $$ = -$2;            }
   47648 | exp '^' exp        { $$ = power ($1, $3); }
   47649 | '(' exp ')'        { $$ = $2;             }
   47650 | '(' error ')'      { $$ = 1111;           }
   47651 | '!'                { $$ = 0; YYERROR;     }
   47652 | '-' error          { $$ = 0; YYERROR;     }
   47653 ;
   47654 %%
   47655 /* The input.  */
   47656 static FILE *input;
   47657 
   47658 /* A C++ error reporting function.  */
   47659 void
   47660 calc::parser::error (const location& l, const std::string& m)
   47661 {
   47662   (void) l;
   47663   std::cerr << l << ": " << m << std::endl;
   47664 }
   47665 
   47666 int
   47667 yyparse ()
   47668 {
   47669   calc::parser parser;
   47670   parser.set_debug_level (!!YYDEBUG);
   47671   return parser.parse ();
   47672 }
   47673 
   47674 
   47675 
   47676 
   47677 static YYLTYPE last_yylloc;
   47678 
   47679 static int
   47680 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   47681 {
   47682   int res = getc (input);
   47683   (void) lvalp;(void) llocp;
   47684 
   47685   last_yylloc = (*llocp);
   47686   if (res == '\n')
   47687     {
   47688       (*llocp).last_line++;
   47689       (*llocp).last_column = 0;
   47690     }
   47691   else
   47692     (*llocp).last_column++;
   47693 
   47694   return res;
   47695 }
   47696 
   47697 
   47698 static void
   47699 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   47700 {
   47701   (void) lvalp;(void) llocp;
   47702 
   47703   /* Wrong when C == `\n'. */
   47704   (*llocp) = last_yylloc;
   47705 
   47706   ungetc (c, input);
   47707 }
   47708 
   47709 static int
   47710 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   47711 {
   47712   int c = get_char (lvalp, llocp);
   47713   int sign = 1;
   47714   int n = 0;
   47715 
   47716   (void) lvalp;(void) llocp;
   47717   if (c == '-')
   47718     {
   47719       c = get_char (lvalp, llocp);
   47720       sign = -1;
   47721     }
   47722 
   47723   while (isdigit (c))
   47724     {
   47725       n = 10 * n + (c - '0');
   47726       c = get_char (lvalp, llocp);
   47727     }
   47728 
   47729   unget_char (lvalp, llocp,  c);
   47730 
   47731   return sign * n;
   47732 }
   47733 
   47734 
   47735 
   47736 /*---------------------------------------------------------------.
   47737 | Lexical analyzer returns an integer on the stack and the token |
   47738 | NUM, or the ASCII character read if not a number.  Skips all   |
   47739 | blanks and tabs, returns 0 for EOF.                            |
   47740 `---------------------------------------------------------------*/
   47741 
   47742 static int
   47743 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   47744 {
   47745   static int init = 1;
   47746   int c;
   47747 
   47748   if (init)
   47749     {
   47750       init = 0;
   47751 
   47752       (*llocp).last_column = 0;
   47753       (*llocp).last_line = 1;
   47754 
   47755     }
   47756 
   47757 
   47758  (*llocp).first_column = (*llocp).last_column;
   47759   (*llocp).first_line   = (*llocp).last_line;
   47760 
   47761 
   47762   /* Skip white space.  */
   47763   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   47764     {
   47765      (*llocp).first_column = (*llocp).last_column;
   47766       (*llocp).first_line   = (*llocp).last_line;
   47767 
   47768     }
   47769 
   47770   /* process numbers   */
   47771   if (c == '.' || isdigit (c))
   47772     {
   47773       unget_char (lvalp, llocp,  c);
   47774       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   47775       return NUM;
   47776     }
   47777 
   47778   /* Return end-of-file.  */
   47779   if (c == EOF)
   47780     return CALC_EOF;
   47781 
   47782   /* Return single chars. */
   47783   return c;
   47784 }
   47785 
   47786 static int
   47787 power (int base, int exponent)
   47788 {
   47789   int res = 1;
   47790   if (exponent < 0)
   47791     exit (3);
   47792   for (/* Niente */; exponent; --exponent)
   47793     res *= base;
   47794   return res;
   47795 }
   47796 
   47797 
   47798 int
   47799 main (int argc, const char **argv)
   47800 {
   47801   semantic_value result = 0;
   47802   int count = 0;
   47803   int status;
   47804 
   47805   /* This used to be alarm (10), but that isn't enough time for
   47806      a July 1995 vintage DEC Alphastation 200 4/100 system,
   47807      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   47808   alarm (100);
   47809 
   47810   if (argc == 2)
   47811     input = fopen (argv[1], "r");
   47812   else
   47813     input = stdin;
   47814 
   47815   if (!input)
   47816     {
   47817       perror (argv[1]);
   47818       return 3;
   47819     }
   47820 
   47821 
   47822   status = yyparse ();
   47823   if (global_result != result)
   47824     abort ();
   47825   if (global_count != count)
   47826     abort ();
   47827   return status;
   47828 }
   47829 _ATEOF
   47830 
   47831 
   47832 
   47833 
   47834 
   47835 $at_traceoff
   47836 echo "calc.at:624: bison -o calc.cc calc.y"
   47837 echo calc.at:624 >$at_check_line_file
   47838 ( $at_traceon; bison -o calc.cc calc.y ) >$at_stdout 2>$at_stder1
   47839 at_status=$?
   47840 grep '^ *+' $at_stder1 >&2
   47841 grep -v '^ *+' $at_stder1 >$at_stderr
   47842 at_failed=false
   47843 $at_diff $at_devnull $at_stderr || at_failed=:
   47844 $at_diff $at_devnull $at_stdout || at_failed=:
   47845 case $at_status in
   47846    77) echo 77 > $at_status_file
   47847             exit 77;;
   47848    0) ;;
   47849    *) echo "calc.at:624: exit code was $at_status, expected 0"
   47850       at_failed=:;;
   47851 esac
   47852 if $at_failed; then
   47853 
   47854   echo 1 > $at_status_file
   47855   exit 1
   47856 fi
   47857 
   47858 $at_traceon
   47859 
   47860 
   47861 $at_traceoff
   47862 echo "calc.at:624: \$BISON_CXX_WORKS"
   47863 echo calc.at:624 >$at_check_line_file
   47864 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   47865 at_status=$?
   47866 grep '^ *+' $at_stder1 >&2
   47867 grep -v '^ *+' $at_stder1 >$at_stderr
   47868 at_failed=false
   47869 echo stderr:; cat $at_stderr
   47870 echo stdout:; cat $at_stdout
   47871 case $at_status in
   47872    77) echo 77 > $at_status_file
   47873             exit 77;;
   47874    0) ;;
   47875    *) echo "calc.at:624: exit code was $at_status, expected 0"
   47876       at_failed=:;;
   47877 esac
   47878 if $at_failed; then
   47879 
   47880   echo 1 > $at_status_file
   47881   exit 1
   47882 fi
   47883 
   47884 $at_traceon
   47885 
   47886 $at_traceoff
   47887 echo "calc.at:624: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.cc \$LIBS"
   47888 echo calc.at:624 >$at_check_line_file
   47889 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o calc calc.cc $LIBS ) >$at_stdout 2>$at_stder1
   47890 at_status=$?
   47891 grep '^ *+' $at_stder1 >&2
   47892 grep -v '^ *+' $at_stder1 >$at_stderr
   47893 at_failed=false
   47894 echo stderr:; cat $at_stderr
   47895 echo stdout:; cat $at_stdout
   47896 case $at_status in
   47897    77) echo 77 > $at_status_file
   47898             exit 77;;
   47899    0) ;;
   47900    *) echo "calc.at:624: exit code was $at_status, expected 0"
   47901       at_failed=:;;
   47902 esac
   47903 if $at_failed; then
   47904 
   47905   echo 1 > $at_status_file
   47906   exit 1
   47907 fi
   47908 
   47909 $at_traceon
   47910 
   47911 
   47912 # Test the priorities.
   47913 cat >input <<'_ATEOF'
   47914 1 + 2 * 3 = 7
   47915 1 + 2 * -3 = -5
   47916 
   47917 -1^2 = -1
   47918 (-1)^2 = 1
   47919 
   47920 ---1 = -1
   47921 
   47922 1 - 2 - 3 = -4
   47923 1 - (2 - 3) = 2
   47924 
   47925 2^2^3 = 256
   47926 (2^2)^3 = 64
   47927 _ATEOF
   47928 
   47929 $at_traceoff
   47930 echo "calc.at:624: \$PREPARSER ./calc input"
   47931 echo calc.at:624 >$at_check_line_file
   47932 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   47933 at_status=$?
   47934 grep '^ *+' $at_stder1 >&2
   47935 grep -v '^ *+' $at_stder1 >$at_stderr
   47936 at_failed=false
   47937 echo stderr:; tee stderr <$at_stderr
   47938 $at_diff $at_devnull $at_stdout || at_failed=:
   47939 case $at_status in
   47940    77) echo 77 > $at_status_file
   47941             exit 77;;
   47942    0) ;;
   47943    *) echo "calc.at:624: exit code was $at_status, expected 0"
   47944       at_failed=:;;
   47945 esac
   47946 if $at_failed; then
   47947 
   47948   echo 1 > $at_status_file
   47949   exit 1
   47950 fi
   47951 
   47952 $at_traceon
   47953 
   47954 
   47955 
   47956 # Some syntax errors.
   47957 cat >input <<'_ATEOF'
   47958 0 0
   47959 _ATEOF
   47960 
   47961 $at_traceoff
   47962 echo "calc.at:624: \$PREPARSER ./calc input"
   47963 echo calc.at:624 >$at_check_line_file
   47964 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   47965 at_status=$?
   47966 grep '^ *+' $at_stder1 >&2
   47967 grep -v '^ *+' $at_stder1 >$at_stderr
   47968 at_failed=false
   47969 echo stderr:; tee stderr <$at_stderr
   47970 $at_diff $at_devnull $at_stdout || at_failed=:
   47971 case $at_status in
   47972    77) echo 77 > $at_status_file
   47973             exit 77;;
   47974    1) ;;
   47975    *) echo "calc.at:624: exit code was $at_status, expected 1"
   47976       at_failed=:;;
   47977 esac
   47978 if $at_failed; then
   47979 
   47980   echo 1 > $at_status_file
   47981   exit 1
   47982 fi
   47983 
   47984 $at_traceon
   47985 
   47986 
   47987 # Normalize the observed and expected error messages, depending upon the
   47988 # options.
   47989 # 1. Remove the traces from observed.
   47990 sed '/^Starting/d
   47991 /^Entering/d
   47992 /^Stack/d
   47993 /^Reading/d
   47994 /^Reducing/d
   47995 /^Shifting/d
   47996 /^state/d
   47997 /^Cleanup:/d
   47998 /^Error:/d
   47999 /^Next/d
   48000 /^Discarding/d
   48001 / \$[0-9$]* = /d
   48002 /^yydestructor:/d' stderr >at-stderr
   48003 mv at-stderr stderr
   48004 # 2. Create the reference error message.
   48005 cat >expout <<'_ATEOF'
   48006 1.2: syntax error, unexpected number
   48007 _ATEOF
   48008 
   48009 # 3. If locations are not used, remove them.
   48010 
   48011 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   48012 
   48013 # 5. Check
   48014 $at_traceoff
   48015 echo "calc.at:624: cat stderr"
   48016 echo calc.at:624 >$at_check_line_file
   48017 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   48018 at_status=$?
   48019 grep '^ *+' $at_stder1 >&2
   48020 grep -v '^ *+' $at_stder1 >$at_stderr
   48021 at_failed=false
   48022 $at_diff $at_devnull $at_stderr || at_failed=:
   48023 $at_diff expout $at_stdout || at_failed=:
   48024 case $at_status in
   48025    77) echo 77 > $at_status_file
   48026             exit 77;;
   48027    0) ;;
   48028    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48029       at_failed=:;;
   48030 esac
   48031 if $at_failed; then
   48032 
   48033   echo 1 > $at_status_file
   48034   exit 1
   48035 fi
   48036 
   48037 $at_traceon
   48038 
   48039 
   48040 cat >input <<'_ATEOF'
   48041 1//2
   48042 _ATEOF
   48043 
   48044 $at_traceoff
   48045 echo "calc.at:624: \$PREPARSER ./calc input"
   48046 echo calc.at:624 >$at_check_line_file
   48047 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   48048 at_status=$?
   48049 grep '^ *+' $at_stder1 >&2
   48050 grep -v '^ *+' $at_stder1 >$at_stderr
   48051 at_failed=false
   48052 echo stderr:; tee stderr <$at_stderr
   48053 $at_diff $at_devnull $at_stdout || at_failed=:
   48054 case $at_status in
   48055    77) echo 77 > $at_status_file
   48056             exit 77;;
   48057    1) ;;
   48058    *) echo "calc.at:624: exit code was $at_status, expected 1"
   48059       at_failed=:;;
   48060 esac
   48061 if $at_failed; then
   48062 
   48063   echo 1 > $at_status_file
   48064   exit 1
   48065 fi
   48066 
   48067 $at_traceon
   48068 
   48069 
   48070 # Normalize the observed and expected error messages, depending upon the
   48071 # options.
   48072 # 1. Remove the traces from observed.
   48073 sed '/^Starting/d
   48074 /^Entering/d
   48075 /^Stack/d
   48076 /^Reading/d
   48077 /^Reducing/d
   48078 /^Shifting/d
   48079 /^state/d
   48080 /^Cleanup:/d
   48081 /^Error:/d
   48082 /^Next/d
   48083 /^Discarding/d
   48084 / \$[0-9$]* = /d
   48085 /^yydestructor:/d' stderr >at-stderr
   48086 mv at-stderr stderr
   48087 # 2. Create the reference error message.
   48088 cat >expout <<'_ATEOF'
   48089 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   48090 _ATEOF
   48091 
   48092 # 3. If locations are not used, remove them.
   48093 
   48094 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   48095 
   48096 # 5. Check
   48097 $at_traceoff
   48098 echo "calc.at:624: cat stderr"
   48099 echo calc.at:624 >$at_check_line_file
   48100 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   48101 at_status=$?
   48102 grep '^ *+' $at_stder1 >&2
   48103 grep -v '^ *+' $at_stder1 >$at_stderr
   48104 at_failed=false
   48105 $at_diff $at_devnull $at_stderr || at_failed=:
   48106 $at_diff expout $at_stdout || at_failed=:
   48107 case $at_status in
   48108    77) echo 77 > $at_status_file
   48109             exit 77;;
   48110    0) ;;
   48111    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48112       at_failed=:;;
   48113 esac
   48114 if $at_failed; then
   48115 
   48116   echo 1 > $at_status_file
   48117   exit 1
   48118 fi
   48119 
   48120 $at_traceon
   48121 
   48122 
   48123 cat >input <<'_ATEOF'
   48124 error
   48125 _ATEOF
   48126 
   48127 $at_traceoff
   48128 echo "calc.at:624: \$PREPARSER ./calc input"
   48129 echo calc.at:624 >$at_check_line_file
   48130 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   48131 at_status=$?
   48132 grep '^ *+' $at_stder1 >&2
   48133 grep -v '^ *+' $at_stder1 >$at_stderr
   48134 at_failed=false
   48135 echo stderr:; tee stderr <$at_stderr
   48136 $at_diff $at_devnull $at_stdout || at_failed=:
   48137 case $at_status in
   48138    77) echo 77 > $at_status_file
   48139             exit 77;;
   48140    1) ;;
   48141    *) echo "calc.at:624: exit code was $at_status, expected 1"
   48142       at_failed=:;;
   48143 esac
   48144 if $at_failed; then
   48145 
   48146   echo 1 > $at_status_file
   48147   exit 1
   48148 fi
   48149 
   48150 $at_traceon
   48151 
   48152 
   48153 # Normalize the observed and expected error messages, depending upon the
   48154 # options.
   48155 # 1. Remove the traces from observed.
   48156 sed '/^Starting/d
   48157 /^Entering/d
   48158 /^Stack/d
   48159 /^Reading/d
   48160 /^Reducing/d
   48161 /^Shifting/d
   48162 /^state/d
   48163 /^Cleanup:/d
   48164 /^Error:/d
   48165 /^Next/d
   48166 /^Discarding/d
   48167 / \$[0-9$]* = /d
   48168 /^yydestructor:/d' stderr >at-stderr
   48169 mv at-stderr stderr
   48170 # 2. Create the reference error message.
   48171 cat >expout <<'_ATEOF'
   48172 1.0: syntax error, unexpected $undefined
   48173 _ATEOF
   48174 
   48175 # 3. If locations are not used, remove them.
   48176 
   48177 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   48178 
   48179 # 5. Check
   48180 $at_traceoff
   48181 echo "calc.at:624: cat stderr"
   48182 echo calc.at:624 >$at_check_line_file
   48183 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   48184 at_status=$?
   48185 grep '^ *+' $at_stder1 >&2
   48186 grep -v '^ *+' $at_stder1 >$at_stderr
   48187 at_failed=false
   48188 $at_diff $at_devnull $at_stderr || at_failed=:
   48189 $at_diff expout $at_stdout || at_failed=:
   48190 case $at_status in
   48191    77) echo 77 > $at_status_file
   48192             exit 77;;
   48193    0) ;;
   48194    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48195       at_failed=:;;
   48196 esac
   48197 if $at_failed; then
   48198 
   48199   echo 1 > $at_status_file
   48200   exit 1
   48201 fi
   48202 
   48203 $at_traceon
   48204 
   48205 
   48206 cat >input <<'_ATEOF'
   48207 1 = 2 = 3
   48208 _ATEOF
   48209 
   48210 $at_traceoff
   48211 echo "calc.at:624: \$PREPARSER ./calc input"
   48212 echo calc.at:624 >$at_check_line_file
   48213 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   48214 at_status=$?
   48215 grep '^ *+' $at_stder1 >&2
   48216 grep -v '^ *+' $at_stder1 >$at_stderr
   48217 at_failed=false
   48218 echo stderr:; tee stderr <$at_stderr
   48219 $at_diff $at_devnull $at_stdout || at_failed=:
   48220 case $at_status in
   48221    77) echo 77 > $at_status_file
   48222             exit 77;;
   48223    1) ;;
   48224    *) echo "calc.at:624: exit code was $at_status, expected 1"
   48225       at_failed=:;;
   48226 esac
   48227 if $at_failed; then
   48228 
   48229   echo 1 > $at_status_file
   48230   exit 1
   48231 fi
   48232 
   48233 $at_traceon
   48234 
   48235 
   48236 # Normalize the observed and expected error messages, depending upon the
   48237 # options.
   48238 # 1. Remove the traces from observed.
   48239 sed '/^Starting/d
   48240 /^Entering/d
   48241 /^Stack/d
   48242 /^Reading/d
   48243 /^Reducing/d
   48244 /^Shifting/d
   48245 /^state/d
   48246 /^Cleanup:/d
   48247 /^Error:/d
   48248 /^Next/d
   48249 /^Discarding/d
   48250 / \$[0-9$]* = /d
   48251 /^yydestructor:/d' stderr >at-stderr
   48252 mv at-stderr stderr
   48253 # 2. Create the reference error message.
   48254 cat >expout <<'_ATEOF'
   48255 1.6: syntax error, unexpected '='
   48256 _ATEOF
   48257 
   48258 # 3. If locations are not used, remove them.
   48259 
   48260 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   48261 
   48262 # 5. Check
   48263 $at_traceoff
   48264 echo "calc.at:624: cat stderr"
   48265 echo calc.at:624 >$at_check_line_file
   48266 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   48267 at_status=$?
   48268 grep '^ *+' $at_stder1 >&2
   48269 grep -v '^ *+' $at_stder1 >$at_stderr
   48270 at_failed=false
   48271 $at_diff $at_devnull $at_stderr || at_failed=:
   48272 $at_diff expout $at_stdout || at_failed=:
   48273 case $at_status in
   48274    77) echo 77 > $at_status_file
   48275             exit 77;;
   48276    0) ;;
   48277    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48278       at_failed=:;;
   48279 esac
   48280 if $at_failed; then
   48281 
   48282   echo 1 > $at_status_file
   48283   exit 1
   48284 fi
   48285 
   48286 $at_traceon
   48287 
   48288 
   48289 cat >input <<'_ATEOF'
   48290 
   48291 +1
   48292 _ATEOF
   48293 
   48294 $at_traceoff
   48295 echo "calc.at:624: \$PREPARSER ./calc input"
   48296 echo calc.at:624 >$at_check_line_file
   48297 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   48298 at_status=$?
   48299 grep '^ *+' $at_stder1 >&2
   48300 grep -v '^ *+' $at_stder1 >$at_stderr
   48301 at_failed=false
   48302 echo stderr:; tee stderr <$at_stderr
   48303 $at_diff $at_devnull $at_stdout || at_failed=:
   48304 case $at_status in
   48305    77) echo 77 > $at_status_file
   48306             exit 77;;
   48307    1) ;;
   48308    *) echo "calc.at:624: exit code was $at_status, expected 1"
   48309       at_failed=:;;
   48310 esac
   48311 if $at_failed; then
   48312 
   48313   echo 1 > $at_status_file
   48314   exit 1
   48315 fi
   48316 
   48317 $at_traceon
   48318 
   48319 
   48320 # Normalize the observed and expected error messages, depending upon the
   48321 # options.
   48322 # 1. Remove the traces from observed.
   48323 sed '/^Starting/d
   48324 /^Entering/d
   48325 /^Stack/d
   48326 /^Reading/d
   48327 /^Reducing/d
   48328 /^Shifting/d
   48329 /^state/d
   48330 /^Cleanup:/d
   48331 /^Error:/d
   48332 /^Next/d
   48333 /^Discarding/d
   48334 / \$[0-9$]* = /d
   48335 /^yydestructor:/d' stderr >at-stderr
   48336 mv at-stderr stderr
   48337 # 2. Create the reference error message.
   48338 cat >expout <<'_ATEOF'
   48339 2.0: syntax error, unexpected '+'
   48340 _ATEOF
   48341 
   48342 # 3. If locations are not used, remove them.
   48343 
   48344 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   48345 
   48346 # 5. Check
   48347 $at_traceoff
   48348 echo "calc.at:624: cat stderr"
   48349 echo calc.at:624 >$at_check_line_file
   48350 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   48351 at_status=$?
   48352 grep '^ *+' $at_stder1 >&2
   48353 grep -v '^ *+' $at_stder1 >$at_stderr
   48354 at_failed=false
   48355 $at_diff $at_devnull $at_stderr || at_failed=:
   48356 $at_diff expout $at_stdout || at_failed=:
   48357 case $at_status in
   48358    77) echo 77 > $at_status_file
   48359             exit 77;;
   48360    0) ;;
   48361    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48362       at_failed=:;;
   48363 esac
   48364 if $at_failed; then
   48365 
   48366   echo 1 > $at_status_file
   48367   exit 1
   48368 fi
   48369 
   48370 $at_traceon
   48371 
   48372 
   48373 # Exercise error messages with EOF: work on an empty file.
   48374 $at_traceoff
   48375 echo "calc.at:624: \$PREPARSER ./calc /dev/null"
   48376 echo calc.at:624 >$at_check_line_file
   48377 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   48378 at_status=$?
   48379 grep '^ *+' $at_stder1 >&2
   48380 grep -v '^ *+' $at_stder1 >$at_stderr
   48381 at_failed=false
   48382 echo stderr:; tee stderr <$at_stderr
   48383 $at_diff $at_devnull $at_stdout || at_failed=:
   48384 case $at_status in
   48385    77) echo 77 > $at_status_file
   48386             exit 77;;
   48387    1) ;;
   48388    *) echo "calc.at:624: exit code was $at_status, expected 1"
   48389       at_failed=:;;
   48390 esac
   48391 if $at_failed; then
   48392 
   48393   echo 1 > $at_status_file
   48394   exit 1
   48395 fi
   48396 
   48397 $at_traceon
   48398 
   48399 
   48400 # Normalize the observed and expected error messages, depending upon the
   48401 # options.
   48402 # 1. Remove the traces from observed.
   48403 sed '/^Starting/d
   48404 /^Entering/d
   48405 /^Stack/d
   48406 /^Reading/d
   48407 /^Reducing/d
   48408 /^Shifting/d
   48409 /^state/d
   48410 /^Cleanup:/d
   48411 /^Error:/d
   48412 /^Next/d
   48413 /^Discarding/d
   48414 / \$[0-9$]* = /d
   48415 /^yydestructor:/d' stderr >at-stderr
   48416 mv at-stderr stderr
   48417 # 2. Create the reference error message.
   48418 cat >expout <<'_ATEOF'
   48419 1.0: syntax error, unexpected end of input
   48420 _ATEOF
   48421 
   48422 # 3. If locations are not used, remove them.
   48423 
   48424 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   48425 
   48426 # 5. Check
   48427 $at_traceoff
   48428 echo "calc.at:624: cat stderr"
   48429 echo calc.at:624 >$at_check_line_file
   48430 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   48431 at_status=$?
   48432 grep '^ *+' $at_stder1 >&2
   48433 grep -v '^ *+' $at_stder1 >$at_stderr
   48434 at_failed=false
   48435 $at_diff $at_devnull $at_stderr || at_failed=:
   48436 $at_diff expout $at_stdout || at_failed=:
   48437 case $at_status in
   48438    77) echo 77 > $at_status_file
   48439             exit 77;;
   48440    0) ;;
   48441    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48442       at_failed=:;;
   48443 esac
   48444 if $at_failed; then
   48445 
   48446   echo 1 > $at_status_file
   48447   exit 1
   48448 fi
   48449 
   48450 $at_traceon
   48451 
   48452 
   48453 
   48454 # Exercise the error token: without it, we die at the first error,
   48455 # hence be sure to
   48456 #
   48457 # - have several errors which exercise different shift/discardings
   48458 #   - (): nothing to pop, nothing to discard
   48459 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   48460 #   - (* * *): nothing to pop, a lot to discard
   48461 #   - (1 + 2 * *): some to pop and discard
   48462 #
   48463 # - test the action associated to `error'
   48464 #
   48465 # - check the look-ahead that triggers an error is not discarded
   48466 #   when we enter error recovery.  Below, the look-ahead causing the
   48467 #   first error is ")", which is needed to recover from the error and
   48468 #   produce the "0" that triggers the "0 != 1" error.
   48469 #
   48470 cat >input <<'_ATEOF'
   48471 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   48472 _ATEOF
   48473 
   48474 $at_traceoff
   48475 echo "calc.at:624: \$PREPARSER ./calc input"
   48476 echo calc.at:624 >$at_check_line_file
   48477 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   48478 at_status=$?
   48479 grep '^ *+' $at_stder1 >&2
   48480 grep -v '^ *+' $at_stder1 >$at_stderr
   48481 at_failed=false
   48482 echo stderr:; tee stderr <$at_stderr
   48483 $at_diff $at_devnull $at_stdout || at_failed=:
   48484 case $at_status in
   48485    77) echo 77 > $at_status_file
   48486             exit 77;;
   48487    0) ;;
   48488    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48489       at_failed=:;;
   48490 esac
   48491 if $at_failed; then
   48492 
   48493   echo 1 > $at_status_file
   48494   exit 1
   48495 fi
   48496 
   48497 $at_traceon
   48498 
   48499 
   48500 # Normalize the observed and expected error messages, depending upon the
   48501 # options.
   48502 # 1. Remove the traces from observed.
   48503 sed '/^Starting/d
   48504 /^Entering/d
   48505 /^Stack/d
   48506 /^Reading/d
   48507 /^Reducing/d
   48508 /^Shifting/d
   48509 /^state/d
   48510 /^Cleanup:/d
   48511 /^Error:/d
   48512 /^Next/d
   48513 /^Discarding/d
   48514 / \$[0-9$]* = /d
   48515 /^yydestructor:/d' stderr >at-stderr
   48516 mv at-stderr stderr
   48517 # 2. Create the reference error message.
   48518 cat >expout <<'_ATEOF'
   48519 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   48520 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   48521 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   48522 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   48523 calc: error: 4444 != 1
   48524 _ATEOF
   48525 
   48526 # 3. If locations are not used, remove them.
   48527 
   48528 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   48529 
   48530 # 5. Check
   48531 $at_traceoff
   48532 echo "calc.at:624: cat stderr"
   48533 echo calc.at:624 >$at_check_line_file
   48534 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   48535 at_status=$?
   48536 grep '^ *+' $at_stder1 >&2
   48537 grep -v '^ *+' $at_stder1 >$at_stderr
   48538 at_failed=false
   48539 $at_diff $at_devnull $at_stderr || at_failed=:
   48540 $at_diff expout $at_stdout || at_failed=:
   48541 case $at_status in
   48542    77) echo 77 > $at_status_file
   48543             exit 77;;
   48544    0) ;;
   48545    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48546       at_failed=:;;
   48547 esac
   48548 if $at_failed; then
   48549 
   48550   echo 1 > $at_status_file
   48551   exit 1
   48552 fi
   48553 
   48554 $at_traceon
   48555 
   48556 
   48557 
   48558 # The same, but this time exercising explicitly triggered syntax errors.
   48559 # POSIX says the look-ahead causing the error should not be discarded.
   48560 cat >input <<'_ATEOF'
   48561 (!) + (0 0) = 1
   48562 _ATEOF
   48563 
   48564 $at_traceoff
   48565 echo "calc.at:624: \$PREPARSER ./calc input"
   48566 echo calc.at:624 >$at_check_line_file
   48567 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   48568 at_status=$?
   48569 grep '^ *+' $at_stder1 >&2
   48570 grep -v '^ *+' $at_stder1 >$at_stderr
   48571 at_failed=false
   48572 echo stderr:; tee stderr <$at_stderr
   48573 $at_diff $at_devnull $at_stdout || at_failed=:
   48574 case $at_status in
   48575    77) echo 77 > $at_status_file
   48576             exit 77;;
   48577    0) ;;
   48578    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48579       at_failed=:;;
   48580 esac
   48581 if $at_failed; then
   48582 
   48583   echo 1 > $at_status_file
   48584   exit 1
   48585 fi
   48586 
   48587 $at_traceon
   48588 
   48589 
   48590 # Normalize the observed and expected error messages, depending upon the
   48591 # options.
   48592 # 1. Remove the traces from observed.
   48593 sed '/^Starting/d
   48594 /^Entering/d
   48595 /^Stack/d
   48596 /^Reading/d
   48597 /^Reducing/d
   48598 /^Shifting/d
   48599 /^state/d
   48600 /^Cleanup:/d
   48601 /^Error:/d
   48602 /^Next/d
   48603 /^Discarding/d
   48604 / \$[0-9$]* = /d
   48605 /^yydestructor:/d' stderr >at-stderr
   48606 mv at-stderr stderr
   48607 # 2. Create the reference error message.
   48608 cat >expout <<'_ATEOF'
   48609 1.9: syntax error, unexpected number
   48610 calc: error: 2222 != 1
   48611 _ATEOF
   48612 
   48613 # 3. If locations are not used, remove them.
   48614 
   48615 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   48616 
   48617 # 5. Check
   48618 $at_traceoff
   48619 echo "calc.at:624: cat stderr"
   48620 echo calc.at:624 >$at_check_line_file
   48621 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   48622 at_status=$?
   48623 grep '^ *+' $at_stder1 >&2
   48624 grep -v '^ *+' $at_stder1 >$at_stderr
   48625 at_failed=false
   48626 $at_diff $at_devnull $at_stderr || at_failed=:
   48627 $at_diff expout $at_stdout || at_failed=:
   48628 case $at_status in
   48629    77) echo 77 > $at_status_file
   48630             exit 77;;
   48631    0) ;;
   48632    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48633       at_failed=:;;
   48634 esac
   48635 if $at_failed; then
   48636 
   48637   echo 1 > $at_status_file
   48638   exit 1
   48639 fi
   48640 
   48641 $at_traceon
   48642 
   48643 
   48644 cat >input <<'_ATEOF'
   48645 (- *) + (0 0) = 1
   48646 _ATEOF
   48647 
   48648 $at_traceoff
   48649 echo "calc.at:624: \$PREPARSER ./calc input"
   48650 echo calc.at:624 >$at_check_line_file
   48651 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   48652 at_status=$?
   48653 grep '^ *+' $at_stder1 >&2
   48654 grep -v '^ *+' $at_stder1 >$at_stderr
   48655 at_failed=false
   48656 echo stderr:; tee stderr <$at_stderr
   48657 $at_diff $at_devnull $at_stdout || at_failed=:
   48658 case $at_status in
   48659    77) echo 77 > $at_status_file
   48660             exit 77;;
   48661    0) ;;
   48662    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48663       at_failed=:;;
   48664 esac
   48665 if $at_failed; then
   48666 
   48667   echo 1 > $at_status_file
   48668   exit 1
   48669 fi
   48670 
   48671 $at_traceon
   48672 
   48673 
   48674 # Normalize the observed and expected error messages, depending upon the
   48675 # options.
   48676 # 1. Remove the traces from observed.
   48677 sed '/^Starting/d
   48678 /^Entering/d
   48679 /^Stack/d
   48680 /^Reading/d
   48681 /^Reducing/d
   48682 /^Shifting/d
   48683 /^state/d
   48684 /^Cleanup:/d
   48685 /^Error:/d
   48686 /^Next/d
   48687 /^Discarding/d
   48688 / \$[0-9$]* = /d
   48689 /^yydestructor:/d' stderr >at-stderr
   48690 mv at-stderr stderr
   48691 # 2. Create the reference error message.
   48692 cat >expout <<'_ATEOF'
   48693 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   48694 1.11: syntax error, unexpected number
   48695 calc: error: 2222 != 1
   48696 _ATEOF
   48697 
   48698 # 3. If locations are not used, remove them.
   48699 
   48700 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   48701 
   48702 # 5. Check
   48703 $at_traceoff
   48704 echo "calc.at:624: cat stderr"
   48705 echo calc.at:624 >$at_check_line_file
   48706 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   48707 at_status=$?
   48708 grep '^ *+' $at_stder1 >&2
   48709 grep -v '^ *+' $at_stder1 >$at_stderr
   48710 at_failed=false
   48711 $at_diff $at_devnull $at_stderr || at_failed=:
   48712 $at_diff expout $at_stdout || at_failed=:
   48713 case $at_status in
   48714    77) echo 77 > $at_status_file
   48715             exit 77;;
   48716    0) ;;
   48717    *) echo "calc.at:624: exit code was $at_status, expected 0"
   48718       at_failed=:;;
   48719 esac
   48720 if $at_failed; then
   48721 
   48722   echo 1 > $at_status_file
   48723   exit 1
   48724 fi
   48725 
   48726 $at_traceon
   48727 
   48728 
   48729 
   48730 
   48731 
   48732 
   48733 
   48734 
   48735 
   48736 
   48737 
   48738 
   48739 
   48740 
   48741 
   48742 
   48743 
   48744 
   48745 
   48746 
   48747 
   48748 
   48749 
   48750 
   48751       $at_traceoff
   48752       $at_times_p && times >$at_times_file
   48753     ) 5>&1 2>&1 | eval $at_tee_pipe
   48754     at_status=`cat $at_status_file`
   48755     ;;
   48756 
   48757   101 ) # 101. calc.at:626: Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc
   48758     at_setup_line='calc.at:626'
   48759     at_desc='Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc'
   48760     $at_quiet $ECHO_N "101: Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc$ECHO_C"
   48761     at_xfail=no
   48762     (
   48763       echo "101. calc.at:626: testing ..."
   48764       $at_traceon
   48765 
   48766 
   48767 
   48768 
   48769 
   48770 
   48771 
   48772 
   48773 # Using yacc.c?
   48774 
   48775 
   48776 
   48777 
   48778 
   48779 
   48780 
   48781 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   48782 
   48783 # yyerror always sees the locations (when activated), except if
   48784 # yacc & pure & !param.
   48785 
   48786 
   48787 # The interface is pure: either because %pure-parser, or because we
   48788 # are using the C++ parsers.
   48789 
   48790 
   48791 
   48792 
   48793 
   48794 
   48795 
   48796 
   48797 
   48798 
   48799 
   48800 
   48801 cat >calc.y <<'_ATEOF'
   48802 %{
   48803 #ifdef HAVE_CONFIG_H
   48804 # include <config.h>
   48805   /* We don't need perfect functions for these tests. */
   48806 # undef malloc
   48807 # undef memcmp
   48808 # undef realloc
   48809 #endif
   48810 %}
   48811 
   48812 /* Infix notation calculator--calc */
   48813 %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc
   48814 %define "global_tokens_and_yystype"
   48815 %{
   48816 #include <stdio.h>
   48817 
   48818 #include <stdlib.h>
   48819 #include <string.h>
   48820 #if HAVE_UNISTD_H
   48821 # include <unistd.h>
   48822 #else
   48823 # undef alarm
   48824 # define alarm(seconds) /* empty */
   48825 #endif
   48826 #include <ctype.h>
   48827 #define USE(Var)
   48828 
   48829 /* Exercise pre-prologue dependency to %union.  */
   48830 typedef int semantic_value;
   48831 
   48832 static semantic_value global_result = 0;
   48833 static int global_count = 0;
   48834 %}
   48835 
   48836 /* Exercise %union. */
   48837 %union
   48838 {
   48839   semantic_value ival;
   48840 };
   48841 
   48842 %{
   48843 static int power (int base, int exponent);
   48844 #ifndef YYLTYPE
   48845 # define YYLTYPE calc::location
   48846 #endif
   48847 #define first_line   begin.line
   48848 #define first_column begin.column
   48849 #define last_line    end.line
   48850 #define last_column  end.column
   48851 
   48852 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   48853 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   48854 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   48855 %}
   48856 
   48857 /* The lalr1.cc skeleton, for backward compatibility, defines
   48858    a constructor for position that initializes the filename.  The
   48859    glr.cc skeleton does not (and in fact cannot: location/position
   48860    are stored in a union, from which objects with constructors are
   48861    excluded in C++. */
   48862 %initial-action {
   48863   @$.initialize (0);
   48864 }
   48865 
   48866 
   48867 /* Bison Declarations */
   48868 %token CALC_EOF 0 "end of input"
   48869 %token <ival> NUM "number"
   48870 %type  <ival> exp
   48871 
   48872 %nonassoc '=' /* comparison	       */
   48873 %left '-' '+'
   48874 %left '*' '/'
   48875 %left NEG     /* negation--unary minus */
   48876 %right '^'    /* exponentiation        */
   48877 
   48878 /* Grammar follows */
   48879 %%
   48880 input:
   48881   line
   48882 | input line         {  }
   48883 ;
   48884 
   48885 line:
   48886   '\n'
   48887 | exp '\n'           { USE ($1); }
   48888 ;
   48889 
   48890 exp:
   48891   NUM                { $$ = $1;             }
   48892 | exp '=' exp
   48893   {
   48894     if ($1 != $3)
   48895       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   48896     $$ = $1;
   48897   }
   48898 | exp '+' exp        { $$ = $1 + $3;        }
   48899 | exp '-' exp        { $$ = $1 - $3;        }
   48900 | exp '*' exp        { $$ = $1 * $3;        }
   48901 | exp '/' exp        { $$ = $1 / $3;        }
   48902 | '-' exp  %prec NEG { $$ = -$2;            }
   48903 | exp '^' exp        { $$ = power ($1, $3); }
   48904 | '(' exp ')'        { $$ = $2;             }
   48905 | '(' error ')'      { $$ = 1111;           }
   48906 | '!'                { $$ = 0; YYERROR;     }
   48907 | '-' error          { $$ = 0; YYERROR;     }
   48908 ;
   48909 %%
   48910 /* The input.  */
   48911 static FILE *input;
   48912 
   48913 /* A C++ error reporting function.  */
   48914 void
   48915 calc::parser::error (const location& l, const std::string& m)
   48916 {
   48917   (void) l;
   48918   std::cerr << l << ": " << m << std::endl;
   48919 }
   48920 
   48921 int
   48922 yyparse ()
   48923 {
   48924   calc::parser parser;
   48925   parser.set_debug_level (!!YYDEBUG);
   48926   return parser.parse ();
   48927 }
   48928 
   48929 
   48930 
   48931 
   48932 static YYLTYPE last_yylloc;
   48933 
   48934 static int
   48935 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   48936 {
   48937   int res = getc (input);
   48938   (void) lvalp;(void) llocp;
   48939 
   48940   last_yylloc = (*llocp);
   48941   if (res == '\n')
   48942     {
   48943       (*llocp).last_line++;
   48944       (*llocp).last_column = 0;
   48945     }
   48946   else
   48947     (*llocp).last_column++;
   48948 
   48949   return res;
   48950 }
   48951 
   48952 
   48953 static void
   48954 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   48955 {
   48956   (void) lvalp;(void) llocp;
   48957 
   48958   /* Wrong when C == `\n'. */
   48959   (*llocp) = last_yylloc;
   48960 
   48961   ungetc (c, input);
   48962 }
   48963 
   48964 static int
   48965 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   48966 {
   48967   int c = get_char (lvalp, llocp);
   48968   int sign = 1;
   48969   int n = 0;
   48970 
   48971   (void) lvalp;(void) llocp;
   48972   if (c == '-')
   48973     {
   48974       c = get_char (lvalp, llocp);
   48975       sign = -1;
   48976     }
   48977 
   48978   while (isdigit (c))
   48979     {
   48980       n = 10 * n + (c - '0');
   48981       c = get_char (lvalp, llocp);
   48982     }
   48983 
   48984   unget_char (lvalp, llocp,  c);
   48985 
   48986   return sign * n;
   48987 }
   48988 
   48989 
   48990 
   48991 /*---------------------------------------------------------------.
   48992 | Lexical analyzer returns an integer on the stack and the token |
   48993 | NUM, or the ASCII character read if not a number.  Skips all   |
   48994 | blanks and tabs, returns 0 for EOF.                            |
   48995 `---------------------------------------------------------------*/
   48996 
   48997 static int
   48998 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   48999 {
   49000   static int init = 1;
   49001   int c;
   49002 
   49003   if (init)
   49004     {
   49005       init = 0;
   49006 
   49007       (*llocp).last_column = 0;
   49008       (*llocp).last_line = 1;
   49009 
   49010     }
   49011 
   49012 
   49013  (*llocp).first_column = (*llocp).last_column;
   49014   (*llocp).first_line   = (*llocp).last_line;
   49015 
   49016 
   49017   /* Skip white space.  */
   49018   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   49019     {
   49020      (*llocp).first_column = (*llocp).last_column;
   49021       (*llocp).first_line   = (*llocp).last_line;
   49022 
   49023     }
   49024 
   49025   /* process numbers   */
   49026   if (c == '.' || isdigit (c))
   49027     {
   49028       unget_char (lvalp, llocp,  c);
   49029       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   49030       return NUM;
   49031     }
   49032 
   49033   /* Return end-of-file.  */
   49034   if (c == EOF)
   49035     return CALC_EOF;
   49036 
   49037   /* Return single chars. */
   49038   return c;
   49039 }
   49040 
   49041 static int
   49042 power (int base, int exponent)
   49043 {
   49044   int res = 1;
   49045   if (exponent < 0)
   49046     exit (3);
   49047   for (/* Niente */; exponent; --exponent)
   49048     res *= base;
   49049   return res;
   49050 }
   49051 
   49052 
   49053 int
   49054 main (int argc, const char **argv)
   49055 {
   49056   semantic_value result = 0;
   49057   int count = 0;
   49058   int status;
   49059 
   49060   /* This used to be alarm (10), but that isn't enough time for
   49061      a July 1995 vintage DEC Alphastation 200 4/100 system,
   49062      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   49063   alarm (100);
   49064 
   49065   if (argc == 2)
   49066     input = fopen (argv[1], "r");
   49067   else
   49068     input = stdin;
   49069 
   49070   if (!input)
   49071     {
   49072       perror (argv[1]);
   49073       return 3;
   49074     }
   49075 
   49076 
   49077   status = yyparse ();
   49078   if (global_result != result)
   49079     abort ();
   49080   if (global_count != count)
   49081     abort ();
   49082   return status;
   49083 }
   49084 _ATEOF
   49085 
   49086 
   49087 
   49088 
   49089 
   49090 $at_traceoff
   49091 echo "calc.at:626: bison -o calc.cc calc.y"
   49092 echo calc.at:626 >$at_check_line_file
   49093 ( $at_traceon; bison -o calc.cc calc.y ) >$at_stdout 2>$at_stder1
   49094 at_status=$?
   49095 grep '^ *+' $at_stder1 >&2
   49096 grep -v '^ *+' $at_stder1 >$at_stderr
   49097 at_failed=false
   49098 $at_diff $at_devnull $at_stderr || at_failed=:
   49099 $at_diff $at_devnull $at_stdout || at_failed=:
   49100 case $at_status in
   49101    77) echo 77 > $at_status_file
   49102             exit 77;;
   49103    0) ;;
   49104    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49105       at_failed=:;;
   49106 esac
   49107 if $at_failed; then
   49108 
   49109   echo 1 > $at_status_file
   49110   exit 1
   49111 fi
   49112 
   49113 $at_traceon
   49114 
   49115 
   49116 $at_traceoff
   49117 echo "calc.at:626: \$BISON_CXX_WORKS"
   49118 echo calc.at:626 >$at_check_line_file
   49119 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   49120 at_status=$?
   49121 grep '^ *+' $at_stder1 >&2
   49122 grep -v '^ *+' $at_stder1 >$at_stderr
   49123 at_failed=false
   49124 echo stderr:; cat $at_stderr
   49125 echo stdout:; cat $at_stdout
   49126 case $at_status in
   49127    77) echo 77 > $at_status_file
   49128             exit 77;;
   49129    0) ;;
   49130    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49131       at_failed=:;;
   49132 esac
   49133 if $at_failed; then
   49134 
   49135   echo 1 > $at_status_file
   49136   exit 1
   49137 fi
   49138 
   49139 $at_traceon
   49140 
   49141 $at_traceoff
   49142 echo "calc.at:626: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.cc \$LIBS"
   49143 echo calc.at:626 >$at_check_line_file
   49144 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o calc calc.cc $LIBS ) >$at_stdout 2>$at_stder1
   49145 at_status=$?
   49146 grep '^ *+' $at_stder1 >&2
   49147 grep -v '^ *+' $at_stder1 >$at_stderr
   49148 at_failed=false
   49149 echo stderr:; cat $at_stderr
   49150 echo stdout:; cat $at_stdout
   49151 case $at_status in
   49152    77) echo 77 > $at_status_file
   49153             exit 77;;
   49154    0) ;;
   49155    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49156       at_failed=:;;
   49157 esac
   49158 if $at_failed; then
   49159 
   49160   echo 1 > $at_status_file
   49161   exit 1
   49162 fi
   49163 
   49164 $at_traceon
   49165 
   49166 
   49167 # Test the priorities.
   49168 cat >input <<'_ATEOF'
   49169 1 + 2 * 3 = 7
   49170 1 + 2 * -3 = -5
   49171 
   49172 -1^2 = -1
   49173 (-1)^2 = 1
   49174 
   49175 ---1 = -1
   49176 
   49177 1 - 2 - 3 = -4
   49178 1 - (2 - 3) = 2
   49179 
   49180 2^2^3 = 256
   49181 (2^2)^3 = 64
   49182 _ATEOF
   49183 
   49184 $at_traceoff
   49185 echo "calc.at:626: \$PREPARSER ./calc input"
   49186 echo calc.at:626 >$at_check_line_file
   49187 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   49188 at_status=$?
   49189 grep '^ *+' $at_stder1 >&2
   49190 grep -v '^ *+' $at_stder1 >$at_stderr
   49191 at_failed=false
   49192 echo stderr:; tee stderr <$at_stderr
   49193 $at_diff $at_devnull $at_stdout || at_failed=:
   49194 case $at_status in
   49195    77) echo 77 > $at_status_file
   49196             exit 77;;
   49197    0) ;;
   49198    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49199       at_failed=:;;
   49200 esac
   49201 if $at_failed; then
   49202 
   49203   echo 1 > $at_status_file
   49204   exit 1
   49205 fi
   49206 
   49207 $at_traceon
   49208 
   49209 
   49210 
   49211 # Some syntax errors.
   49212 cat >input <<'_ATEOF'
   49213 0 0
   49214 _ATEOF
   49215 
   49216 $at_traceoff
   49217 echo "calc.at:626: \$PREPARSER ./calc input"
   49218 echo calc.at:626 >$at_check_line_file
   49219 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   49220 at_status=$?
   49221 grep '^ *+' $at_stder1 >&2
   49222 grep -v '^ *+' $at_stder1 >$at_stderr
   49223 at_failed=false
   49224 echo stderr:; tee stderr <$at_stderr
   49225 $at_diff $at_devnull $at_stdout || at_failed=:
   49226 case $at_status in
   49227    77) echo 77 > $at_status_file
   49228             exit 77;;
   49229    1) ;;
   49230    *) echo "calc.at:626: exit code was $at_status, expected 1"
   49231       at_failed=:;;
   49232 esac
   49233 if $at_failed; then
   49234 
   49235   echo 1 > $at_status_file
   49236   exit 1
   49237 fi
   49238 
   49239 $at_traceon
   49240 
   49241 
   49242 # Normalize the observed and expected error messages, depending upon the
   49243 # options.
   49244 # 1. Remove the traces from observed.
   49245 sed '/^Starting/d
   49246 /^Entering/d
   49247 /^Stack/d
   49248 /^Reading/d
   49249 /^Reducing/d
   49250 /^Shifting/d
   49251 /^state/d
   49252 /^Cleanup:/d
   49253 /^Error:/d
   49254 /^Next/d
   49255 /^Discarding/d
   49256 / \$[0-9$]* = /d
   49257 /^yydestructor:/d' stderr >at-stderr
   49258 mv at-stderr stderr
   49259 # 2. Create the reference error message.
   49260 cat >expout <<'_ATEOF'
   49261 1.2: syntax error, unexpected number
   49262 _ATEOF
   49263 
   49264 # 3. If locations are not used, remove them.
   49265 
   49266 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   49267 
   49268 # 5. Check
   49269 $at_traceoff
   49270 echo "calc.at:626: cat stderr"
   49271 echo calc.at:626 >$at_check_line_file
   49272 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   49273 at_status=$?
   49274 grep '^ *+' $at_stder1 >&2
   49275 grep -v '^ *+' $at_stder1 >$at_stderr
   49276 at_failed=false
   49277 $at_diff $at_devnull $at_stderr || at_failed=:
   49278 $at_diff expout $at_stdout || at_failed=:
   49279 case $at_status in
   49280    77) echo 77 > $at_status_file
   49281             exit 77;;
   49282    0) ;;
   49283    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49284       at_failed=:;;
   49285 esac
   49286 if $at_failed; then
   49287 
   49288   echo 1 > $at_status_file
   49289   exit 1
   49290 fi
   49291 
   49292 $at_traceon
   49293 
   49294 
   49295 cat >input <<'_ATEOF'
   49296 1//2
   49297 _ATEOF
   49298 
   49299 $at_traceoff
   49300 echo "calc.at:626: \$PREPARSER ./calc input"
   49301 echo calc.at:626 >$at_check_line_file
   49302 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   49303 at_status=$?
   49304 grep '^ *+' $at_stder1 >&2
   49305 grep -v '^ *+' $at_stder1 >$at_stderr
   49306 at_failed=false
   49307 echo stderr:; tee stderr <$at_stderr
   49308 $at_diff $at_devnull $at_stdout || at_failed=:
   49309 case $at_status in
   49310    77) echo 77 > $at_status_file
   49311             exit 77;;
   49312    1) ;;
   49313    *) echo "calc.at:626: exit code was $at_status, expected 1"
   49314       at_failed=:;;
   49315 esac
   49316 if $at_failed; then
   49317 
   49318   echo 1 > $at_status_file
   49319   exit 1
   49320 fi
   49321 
   49322 $at_traceon
   49323 
   49324 
   49325 # Normalize the observed and expected error messages, depending upon the
   49326 # options.
   49327 # 1. Remove the traces from observed.
   49328 sed '/^Starting/d
   49329 /^Entering/d
   49330 /^Stack/d
   49331 /^Reading/d
   49332 /^Reducing/d
   49333 /^Shifting/d
   49334 /^state/d
   49335 /^Cleanup:/d
   49336 /^Error:/d
   49337 /^Next/d
   49338 /^Discarding/d
   49339 / \$[0-9$]* = /d
   49340 /^yydestructor:/d' stderr >at-stderr
   49341 mv at-stderr stderr
   49342 # 2. Create the reference error message.
   49343 cat >expout <<'_ATEOF'
   49344 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   49345 _ATEOF
   49346 
   49347 # 3. If locations are not used, remove them.
   49348 
   49349 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   49350 
   49351 # 5. Check
   49352 $at_traceoff
   49353 echo "calc.at:626: cat stderr"
   49354 echo calc.at:626 >$at_check_line_file
   49355 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   49356 at_status=$?
   49357 grep '^ *+' $at_stder1 >&2
   49358 grep -v '^ *+' $at_stder1 >$at_stderr
   49359 at_failed=false
   49360 $at_diff $at_devnull $at_stderr || at_failed=:
   49361 $at_diff expout $at_stdout || at_failed=:
   49362 case $at_status in
   49363    77) echo 77 > $at_status_file
   49364             exit 77;;
   49365    0) ;;
   49366    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49367       at_failed=:;;
   49368 esac
   49369 if $at_failed; then
   49370 
   49371   echo 1 > $at_status_file
   49372   exit 1
   49373 fi
   49374 
   49375 $at_traceon
   49376 
   49377 
   49378 cat >input <<'_ATEOF'
   49379 error
   49380 _ATEOF
   49381 
   49382 $at_traceoff
   49383 echo "calc.at:626: \$PREPARSER ./calc input"
   49384 echo calc.at:626 >$at_check_line_file
   49385 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   49386 at_status=$?
   49387 grep '^ *+' $at_stder1 >&2
   49388 grep -v '^ *+' $at_stder1 >$at_stderr
   49389 at_failed=false
   49390 echo stderr:; tee stderr <$at_stderr
   49391 $at_diff $at_devnull $at_stdout || at_failed=:
   49392 case $at_status in
   49393    77) echo 77 > $at_status_file
   49394             exit 77;;
   49395    1) ;;
   49396    *) echo "calc.at:626: exit code was $at_status, expected 1"
   49397       at_failed=:;;
   49398 esac
   49399 if $at_failed; then
   49400 
   49401   echo 1 > $at_status_file
   49402   exit 1
   49403 fi
   49404 
   49405 $at_traceon
   49406 
   49407 
   49408 # Normalize the observed and expected error messages, depending upon the
   49409 # options.
   49410 # 1. Remove the traces from observed.
   49411 sed '/^Starting/d
   49412 /^Entering/d
   49413 /^Stack/d
   49414 /^Reading/d
   49415 /^Reducing/d
   49416 /^Shifting/d
   49417 /^state/d
   49418 /^Cleanup:/d
   49419 /^Error:/d
   49420 /^Next/d
   49421 /^Discarding/d
   49422 / \$[0-9$]* = /d
   49423 /^yydestructor:/d' stderr >at-stderr
   49424 mv at-stderr stderr
   49425 # 2. Create the reference error message.
   49426 cat >expout <<'_ATEOF'
   49427 1.0: syntax error, unexpected $undefined
   49428 _ATEOF
   49429 
   49430 # 3. If locations are not used, remove them.
   49431 
   49432 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   49433 
   49434 # 5. Check
   49435 $at_traceoff
   49436 echo "calc.at:626: cat stderr"
   49437 echo calc.at:626 >$at_check_line_file
   49438 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   49439 at_status=$?
   49440 grep '^ *+' $at_stder1 >&2
   49441 grep -v '^ *+' $at_stder1 >$at_stderr
   49442 at_failed=false
   49443 $at_diff $at_devnull $at_stderr || at_failed=:
   49444 $at_diff expout $at_stdout || at_failed=:
   49445 case $at_status in
   49446    77) echo 77 > $at_status_file
   49447             exit 77;;
   49448    0) ;;
   49449    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49450       at_failed=:;;
   49451 esac
   49452 if $at_failed; then
   49453 
   49454   echo 1 > $at_status_file
   49455   exit 1
   49456 fi
   49457 
   49458 $at_traceon
   49459 
   49460 
   49461 cat >input <<'_ATEOF'
   49462 1 = 2 = 3
   49463 _ATEOF
   49464 
   49465 $at_traceoff
   49466 echo "calc.at:626: \$PREPARSER ./calc input"
   49467 echo calc.at:626 >$at_check_line_file
   49468 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   49469 at_status=$?
   49470 grep '^ *+' $at_stder1 >&2
   49471 grep -v '^ *+' $at_stder1 >$at_stderr
   49472 at_failed=false
   49473 echo stderr:; tee stderr <$at_stderr
   49474 $at_diff $at_devnull $at_stdout || at_failed=:
   49475 case $at_status in
   49476    77) echo 77 > $at_status_file
   49477             exit 77;;
   49478    1) ;;
   49479    *) echo "calc.at:626: exit code was $at_status, expected 1"
   49480       at_failed=:;;
   49481 esac
   49482 if $at_failed; then
   49483 
   49484   echo 1 > $at_status_file
   49485   exit 1
   49486 fi
   49487 
   49488 $at_traceon
   49489 
   49490 
   49491 # Normalize the observed and expected error messages, depending upon the
   49492 # options.
   49493 # 1. Remove the traces from observed.
   49494 sed '/^Starting/d
   49495 /^Entering/d
   49496 /^Stack/d
   49497 /^Reading/d
   49498 /^Reducing/d
   49499 /^Shifting/d
   49500 /^state/d
   49501 /^Cleanup:/d
   49502 /^Error:/d
   49503 /^Next/d
   49504 /^Discarding/d
   49505 / \$[0-9$]* = /d
   49506 /^yydestructor:/d' stderr >at-stderr
   49507 mv at-stderr stderr
   49508 # 2. Create the reference error message.
   49509 cat >expout <<'_ATEOF'
   49510 1.6: syntax error, unexpected '='
   49511 _ATEOF
   49512 
   49513 # 3. If locations are not used, remove them.
   49514 
   49515 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   49516 
   49517 # 5. Check
   49518 $at_traceoff
   49519 echo "calc.at:626: cat stderr"
   49520 echo calc.at:626 >$at_check_line_file
   49521 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   49522 at_status=$?
   49523 grep '^ *+' $at_stder1 >&2
   49524 grep -v '^ *+' $at_stder1 >$at_stderr
   49525 at_failed=false
   49526 $at_diff $at_devnull $at_stderr || at_failed=:
   49527 $at_diff expout $at_stdout || at_failed=:
   49528 case $at_status in
   49529    77) echo 77 > $at_status_file
   49530             exit 77;;
   49531    0) ;;
   49532    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49533       at_failed=:;;
   49534 esac
   49535 if $at_failed; then
   49536 
   49537   echo 1 > $at_status_file
   49538   exit 1
   49539 fi
   49540 
   49541 $at_traceon
   49542 
   49543 
   49544 cat >input <<'_ATEOF'
   49545 
   49546 +1
   49547 _ATEOF
   49548 
   49549 $at_traceoff
   49550 echo "calc.at:626: \$PREPARSER ./calc input"
   49551 echo calc.at:626 >$at_check_line_file
   49552 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   49553 at_status=$?
   49554 grep '^ *+' $at_stder1 >&2
   49555 grep -v '^ *+' $at_stder1 >$at_stderr
   49556 at_failed=false
   49557 echo stderr:; tee stderr <$at_stderr
   49558 $at_diff $at_devnull $at_stdout || at_failed=:
   49559 case $at_status in
   49560    77) echo 77 > $at_status_file
   49561             exit 77;;
   49562    1) ;;
   49563    *) echo "calc.at:626: exit code was $at_status, expected 1"
   49564       at_failed=:;;
   49565 esac
   49566 if $at_failed; then
   49567 
   49568   echo 1 > $at_status_file
   49569   exit 1
   49570 fi
   49571 
   49572 $at_traceon
   49573 
   49574 
   49575 # Normalize the observed and expected error messages, depending upon the
   49576 # options.
   49577 # 1. Remove the traces from observed.
   49578 sed '/^Starting/d
   49579 /^Entering/d
   49580 /^Stack/d
   49581 /^Reading/d
   49582 /^Reducing/d
   49583 /^Shifting/d
   49584 /^state/d
   49585 /^Cleanup:/d
   49586 /^Error:/d
   49587 /^Next/d
   49588 /^Discarding/d
   49589 / \$[0-9$]* = /d
   49590 /^yydestructor:/d' stderr >at-stderr
   49591 mv at-stderr stderr
   49592 # 2. Create the reference error message.
   49593 cat >expout <<'_ATEOF'
   49594 2.0: syntax error, unexpected '+'
   49595 _ATEOF
   49596 
   49597 # 3. If locations are not used, remove them.
   49598 
   49599 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   49600 
   49601 # 5. Check
   49602 $at_traceoff
   49603 echo "calc.at:626: cat stderr"
   49604 echo calc.at:626 >$at_check_line_file
   49605 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   49606 at_status=$?
   49607 grep '^ *+' $at_stder1 >&2
   49608 grep -v '^ *+' $at_stder1 >$at_stderr
   49609 at_failed=false
   49610 $at_diff $at_devnull $at_stderr || at_failed=:
   49611 $at_diff expout $at_stdout || at_failed=:
   49612 case $at_status in
   49613    77) echo 77 > $at_status_file
   49614             exit 77;;
   49615    0) ;;
   49616    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49617       at_failed=:;;
   49618 esac
   49619 if $at_failed; then
   49620 
   49621   echo 1 > $at_status_file
   49622   exit 1
   49623 fi
   49624 
   49625 $at_traceon
   49626 
   49627 
   49628 # Exercise error messages with EOF: work on an empty file.
   49629 $at_traceoff
   49630 echo "calc.at:626: \$PREPARSER ./calc /dev/null"
   49631 echo calc.at:626 >$at_check_line_file
   49632 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   49633 at_status=$?
   49634 grep '^ *+' $at_stder1 >&2
   49635 grep -v '^ *+' $at_stder1 >$at_stderr
   49636 at_failed=false
   49637 echo stderr:; tee stderr <$at_stderr
   49638 $at_diff $at_devnull $at_stdout || at_failed=:
   49639 case $at_status in
   49640    77) echo 77 > $at_status_file
   49641             exit 77;;
   49642    1) ;;
   49643    *) echo "calc.at:626: exit code was $at_status, expected 1"
   49644       at_failed=:;;
   49645 esac
   49646 if $at_failed; then
   49647 
   49648   echo 1 > $at_status_file
   49649   exit 1
   49650 fi
   49651 
   49652 $at_traceon
   49653 
   49654 
   49655 # Normalize the observed and expected error messages, depending upon the
   49656 # options.
   49657 # 1. Remove the traces from observed.
   49658 sed '/^Starting/d
   49659 /^Entering/d
   49660 /^Stack/d
   49661 /^Reading/d
   49662 /^Reducing/d
   49663 /^Shifting/d
   49664 /^state/d
   49665 /^Cleanup:/d
   49666 /^Error:/d
   49667 /^Next/d
   49668 /^Discarding/d
   49669 / \$[0-9$]* = /d
   49670 /^yydestructor:/d' stderr >at-stderr
   49671 mv at-stderr stderr
   49672 # 2. Create the reference error message.
   49673 cat >expout <<'_ATEOF'
   49674 1.0: syntax error, unexpected end of input
   49675 _ATEOF
   49676 
   49677 # 3. If locations are not used, remove them.
   49678 
   49679 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   49680 
   49681 # 5. Check
   49682 $at_traceoff
   49683 echo "calc.at:626: cat stderr"
   49684 echo calc.at:626 >$at_check_line_file
   49685 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   49686 at_status=$?
   49687 grep '^ *+' $at_stder1 >&2
   49688 grep -v '^ *+' $at_stder1 >$at_stderr
   49689 at_failed=false
   49690 $at_diff $at_devnull $at_stderr || at_failed=:
   49691 $at_diff expout $at_stdout || at_failed=:
   49692 case $at_status in
   49693    77) echo 77 > $at_status_file
   49694             exit 77;;
   49695    0) ;;
   49696    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49697       at_failed=:;;
   49698 esac
   49699 if $at_failed; then
   49700 
   49701   echo 1 > $at_status_file
   49702   exit 1
   49703 fi
   49704 
   49705 $at_traceon
   49706 
   49707 
   49708 
   49709 # Exercise the error token: without it, we die at the first error,
   49710 # hence be sure to
   49711 #
   49712 # - have several errors which exercise different shift/discardings
   49713 #   - (): nothing to pop, nothing to discard
   49714 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   49715 #   - (* * *): nothing to pop, a lot to discard
   49716 #   - (1 + 2 * *): some to pop and discard
   49717 #
   49718 # - test the action associated to `error'
   49719 #
   49720 # - check the look-ahead that triggers an error is not discarded
   49721 #   when we enter error recovery.  Below, the look-ahead causing the
   49722 #   first error is ")", which is needed to recover from the error and
   49723 #   produce the "0" that triggers the "0 != 1" error.
   49724 #
   49725 cat >input <<'_ATEOF'
   49726 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   49727 _ATEOF
   49728 
   49729 $at_traceoff
   49730 echo "calc.at:626: \$PREPARSER ./calc input"
   49731 echo calc.at:626 >$at_check_line_file
   49732 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   49733 at_status=$?
   49734 grep '^ *+' $at_stder1 >&2
   49735 grep -v '^ *+' $at_stder1 >$at_stderr
   49736 at_failed=false
   49737 echo stderr:; tee stderr <$at_stderr
   49738 $at_diff $at_devnull $at_stdout || at_failed=:
   49739 case $at_status in
   49740    77) echo 77 > $at_status_file
   49741             exit 77;;
   49742    0) ;;
   49743    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49744       at_failed=:;;
   49745 esac
   49746 if $at_failed; then
   49747 
   49748   echo 1 > $at_status_file
   49749   exit 1
   49750 fi
   49751 
   49752 $at_traceon
   49753 
   49754 
   49755 # Normalize the observed and expected error messages, depending upon the
   49756 # options.
   49757 # 1. Remove the traces from observed.
   49758 sed '/^Starting/d
   49759 /^Entering/d
   49760 /^Stack/d
   49761 /^Reading/d
   49762 /^Reducing/d
   49763 /^Shifting/d
   49764 /^state/d
   49765 /^Cleanup:/d
   49766 /^Error:/d
   49767 /^Next/d
   49768 /^Discarding/d
   49769 / \$[0-9$]* = /d
   49770 /^yydestructor:/d' stderr >at-stderr
   49771 mv at-stderr stderr
   49772 # 2. Create the reference error message.
   49773 cat >expout <<'_ATEOF'
   49774 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   49775 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   49776 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   49777 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   49778 calc: error: 4444 != 1
   49779 _ATEOF
   49780 
   49781 # 3. If locations are not used, remove them.
   49782 
   49783 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   49784 
   49785 # 5. Check
   49786 $at_traceoff
   49787 echo "calc.at:626: cat stderr"
   49788 echo calc.at:626 >$at_check_line_file
   49789 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   49790 at_status=$?
   49791 grep '^ *+' $at_stder1 >&2
   49792 grep -v '^ *+' $at_stder1 >$at_stderr
   49793 at_failed=false
   49794 $at_diff $at_devnull $at_stderr || at_failed=:
   49795 $at_diff expout $at_stdout || at_failed=:
   49796 case $at_status in
   49797    77) echo 77 > $at_status_file
   49798             exit 77;;
   49799    0) ;;
   49800    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49801       at_failed=:;;
   49802 esac
   49803 if $at_failed; then
   49804 
   49805   echo 1 > $at_status_file
   49806   exit 1
   49807 fi
   49808 
   49809 $at_traceon
   49810 
   49811 
   49812 
   49813 # The same, but this time exercising explicitly triggered syntax errors.
   49814 # POSIX says the look-ahead causing the error should not be discarded.
   49815 cat >input <<'_ATEOF'
   49816 (!) + (0 0) = 1
   49817 _ATEOF
   49818 
   49819 $at_traceoff
   49820 echo "calc.at:626: \$PREPARSER ./calc input"
   49821 echo calc.at:626 >$at_check_line_file
   49822 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   49823 at_status=$?
   49824 grep '^ *+' $at_stder1 >&2
   49825 grep -v '^ *+' $at_stder1 >$at_stderr
   49826 at_failed=false
   49827 echo stderr:; tee stderr <$at_stderr
   49828 $at_diff $at_devnull $at_stdout || at_failed=:
   49829 case $at_status in
   49830    77) echo 77 > $at_status_file
   49831             exit 77;;
   49832    0) ;;
   49833    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49834       at_failed=:;;
   49835 esac
   49836 if $at_failed; then
   49837 
   49838   echo 1 > $at_status_file
   49839   exit 1
   49840 fi
   49841 
   49842 $at_traceon
   49843 
   49844 
   49845 # Normalize the observed and expected error messages, depending upon the
   49846 # options.
   49847 # 1. Remove the traces from observed.
   49848 sed '/^Starting/d
   49849 /^Entering/d
   49850 /^Stack/d
   49851 /^Reading/d
   49852 /^Reducing/d
   49853 /^Shifting/d
   49854 /^state/d
   49855 /^Cleanup:/d
   49856 /^Error:/d
   49857 /^Next/d
   49858 /^Discarding/d
   49859 / \$[0-9$]* = /d
   49860 /^yydestructor:/d' stderr >at-stderr
   49861 mv at-stderr stderr
   49862 # 2. Create the reference error message.
   49863 cat >expout <<'_ATEOF'
   49864 1.9: syntax error, unexpected number
   49865 calc: error: 2222 != 1
   49866 _ATEOF
   49867 
   49868 # 3. If locations are not used, remove them.
   49869 
   49870 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   49871 
   49872 # 5. Check
   49873 $at_traceoff
   49874 echo "calc.at:626: cat stderr"
   49875 echo calc.at:626 >$at_check_line_file
   49876 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   49877 at_status=$?
   49878 grep '^ *+' $at_stder1 >&2
   49879 grep -v '^ *+' $at_stder1 >$at_stderr
   49880 at_failed=false
   49881 $at_diff $at_devnull $at_stderr || at_failed=:
   49882 $at_diff expout $at_stdout || at_failed=:
   49883 case $at_status in
   49884    77) echo 77 > $at_status_file
   49885             exit 77;;
   49886    0) ;;
   49887    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49888       at_failed=:;;
   49889 esac
   49890 if $at_failed; then
   49891 
   49892   echo 1 > $at_status_file
   49893   exit 1
   49894 fi
   49895 
   49896 $at_traceon
   49897 
   49898 
   49899 cat >input <<'_ATEOF'
   49900 (- *) + (0 0) = 1
   49901 _ATEOF
   49902 
   49903 $at_traceoff
   49904 echo "calc.at:626: \$PREPARSER ./calc input"
   49905 echo calc.at:626 >$at_check_line_file
   49906 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   49907 at_status=$?
   49908 grep '^ *+' $at_stder1 >&2
   49909 grep -v '^ *+' $at_stder1 >$at_stderr
   49910 at_failed=false
   49911 echo stderr:; tee stderr <$at_stderr
   49912 $at_diff $at_devnull $at_stdout || at_failed=:
   49913 case $at_status in
   49914    77) echo 77 > $at_status_file
   49915             exit 77;;
   49916    0) ;;
   49917    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49918       at_failed=:;;
   49919 esac
   49920 if $at_failed; then
   49921 
   49922   echo 1 > $at_status_file
   49923   exit 1
   49924 fi
   49925 
   49926 $at_traceon
   49927 
   49928 
   49929 # Normalize the observed and expected error messages, depending upon the
   49930 # options.
   49931 # 1. Remove the traces from observed.
   49932 sed '/^Starting/d
   49933 /^Entering/d
   49934 /^Stack/d
   49935 /^Reading/d
   49936 /^Reducing/d
   49937 /^Shifting/d
   49938 /^state/d
   49939 /^Cleanup:/d
   49940 /^Error:/d
   49941 /^Next/d
   49942 /^Discarding/d
   49943 / \$[0-9$]* = /d
   49944 /^yydestructor:/d' stderr >at-stderr
   49945 mv at-stderr stderr
   49946 # 2. Create the reference error message.
   49947 cat >expout <<'_ATEOF'
   49948 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   49949 1.11: syntax error, unexpected number
   49950 calc: error: 2222 != 1
   49951 _ATEOF
   49952 
   49953 # 3. If locations are not used, remove them.
   49954 
   49955 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   49956 
   49957 # 5. Check
   49958 $at_traceoff
   49959 echo "calc.at:626: cat stderr"
   49960 echo calc.at:626 >$at_check_line_file
   49961 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   49962 at_status=$?
   49963 grep '^ *+' $at_stder1 >&2
   49964 grep -v '^ *+' $at_stder1 >$at_stderr
   49965 at_failed=false
   49966 $at_diff $at_devnull $at_stderr || at_failed=:
   49967 $at_diff expout $at_stdout || at_failed=:
   49968 case $at_status in
   49969    77) echo 77 > $at_status_file
   49970             exit 77;;
   49971    0) ;;
   49972    *) echo "calc.at:626: exit code was $at_status, expected 0"
   49973       at_failed=:;;
   49974 esac
   49975 if $at_failed; then
   49976 
   49977   echo 1 > $at_status_file
   49978   exit 1
   49979 fi
   49980 
   49981 $at_traceon
   49982 
   49983 
   49984 
   49985 
   49986 
   49987 
   49988 
   49989 
   49990 
   49991 
   49992 
   49993 
   49994 
   49995 
   49996 
   49997 
   49998 
   49999 
   50000 
   50001 
   50002 
   50003 
   50004 
   50005 
   50006       $at_traceoff
   50007       $at_times_p && times >$at_times_file
   50008     ) 5>&1 2>&1 | eval $at_tee_pipe
   50009     at_status=`cat $at_status_file`
   50010     ;;
   50011 
   50012   102 ) # 102. calc.at:628: Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}
   50013     at_setup_line='calc.at:628'
   50014     at_desc='Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}'
   50015     $at_quiet $ECHO_N "102: Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}$ECHO_C"
   50016     at_xfail=no
   50017     (
   50018       echo "102. calc.at:628: testing ..."
   50019       $at_traceon
   50020 
   50021 
   50022 
   50023 
   50024 
   50025 
   50026 
   50027 
   50028 # Using yacc.c?
   50029 
   50030 
   50031 
   50032 
   50033 
   50034 
   50035 
   50036 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   50037 
   50038 # yyerror always sees the locations (when activated), except if
   50039 # yacc & pure & !param.
   50040 
   50041 
   50042 # The interface is pure: either because %pure-parser, or because we
   50043 # are using the C++ parsers.
   50044 
   50045 
   50046 
   50047 
   50048 
   50049 
   50050 
   50051 
   50052 
   50053 
   50054 
   50055 
   50056 cat >calc.y <<'_ATEOF'
   50057 %{
   50058 #ifdef HAVE_CONFIG_H
   50059 # include <config.h>
   50060   /* We don't need perfect functions for these tests. */
   50061 # undef malloc
   50062 # undef memcmp
   50063 # undef realloc
   50064 #endif
   50065 %}
   50066 
   50067 /* Infix notation calculator--calc */
   50068 %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}
   50069 %define "global_tokens_and_yystype"
   50070 %{
   50071 #include <stdio.h>
   50072 
   50073 #include <stdlib.h>
   50074 #include <string.h>
   50075 #if HAVE_UNISTD_H
   50076 # include <unistd.h>
   50077 #else
   50078 # undef alarm
   50079 # define alarm(seconds) /* empty */
   50080 #endif
   50081 #include <ctype.h>
   50082 #define USE(Var)
   50083 
   50084 /* Exercise pre-prologue dependency to %union.  */
   50085 typedef int semantic_value;
   50086 
   50087 static semantic_value global_result = 0;
   50088 static int global_count = 0;
   50089 %}
   50090 
   50091 /* Exercise %union. */
   50092 %union
   50093 {
   50094   semantic_value ival;
   50095 };
   50096 
   50097 %{
   50098 static int power (int base, int exponent);
   50099 #ifndef YYLTYPE
   50100 # define YYLTYPE calc::location
   50101 #endif
   50102 #define first_line   begin.line
   50103 #define first_column begin.column
   50104 #define last_line    end.line
   50105 #define last_column  end.column
   50106 
   50107 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   50108 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   50109 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   50110 %}
   50111 
   50112 /* The lalr1.cc skeleton, for backward compatibility, defines
   50113    a constructor for position that initializes the filename.  The
   50114    glr.cc skeleton does not (and in fact cannot: location/position
   50115    are stored in a union, from which objects with constructors are
   50116    excluded in C++. */
   50117 %initial-action {
   50118   @$.initialize (0);
   50119 }
   50120 
   50121 
   50122 /* Bison Declarations */
   50123 %token CALC_EOF 0 "end of input"
   50124 %token <ival> NUM "number"
   50125 %type  <ival> exp
   50126 
   50127 %nonassoc '=' /* comparison	       */
   50128 %left '-' '+'
   50129 %left '*' '/'
   50130 %left NEG     /* negation--unary minus */
   50131 %right '^'    /* exponentiation        */
   50132 
   50133 /* Grammar follows */
   50134 %%
   50135 input:
   50136   line
   50137 | input line         { ++*count; ++global_count; }
   50138 ;
   50139 
   50140 line:
   50141   '\n'
   50142 | exp '\n'           { *result = global_result = $1; }
   50143 ;
   50144 
   50145 exp:
   50146   NUM                { $$ = $1;             }
   50147 | exp '=' exp
   50148   {
   50149     if ($1 != $3)
   50150       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   50151     $$ = $1;
   50152   }
   50153 | exp '+' exp        { $$ = $1 + $3;        }
   50154 | exp '-' exp        { $$ = $1 - $3;        }
   50155 | exp '*' exp        { $$ = $1 * $3;        }
   50156 | exp '/' exp        { $$ = $1 / $3;        }
   50157 | '-' exp  %prec NEG { $$ = -$2;            }
   50158 | exp '^' exp        { $$ = power ($1, $3); }
   50159 | '(' exp ')'        { $$ = $2;             }
   50160 | '(' error ')'      { $$ = 1111;           }
   50161 | '!'                { $$ = 0; YYERROR;     }
   50162 | '-' error          { $$ = 0; YYERROR;     }
   50163 ;
   50164 %%
   50165 /* The input.  */
   50166 static FILE *input;
   50167 
   50168 /* A C++ error reporting function.  */
   50169 void
   50170 calc::parser::error (const location& l, const std::string& m)
   50171 {
   50172   (void) l;
   50173   std::cerr << l << ": " << m << std::endl;
   50174 }
   50175 
   50176 int
   50177 yyparse (semantic_value *result, int *count)
   50178 {
   50179   calc::parser parser (result, count);
   50180   parser.set_debug_level (!!YYDEBUG);
   50181   return parser.parse ();
   50182 }
   50183 
   50184 
   50185 
   50186 
   50187 static YYLTYPE last_yylloc;
   50188 
   50189 static int
   50190 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   50191 {
   50192   int res = getc (input);
   50193   (void) lvalp;(void) llocp;
   50194 
   50195   last_yylloc = (*llocp);
   50196   if (res == '\n')
   50197     {
   50198       (*llocp).last_line++;
   50199       (*llocp).last_column = 0;
   50200     }
   50201   else
   50202     (*llocp).last_column++;
   50203 
   50204   return res;
   50205 }
   50206 
   50207 
   50208 static void
   50209 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   50210 {
   50211   (void) lvalp;(void) llocp;
   50212 
   50213   /* Wrong when C == `\n'. */
   50214   (*llocp) = last_yylloc;
   50215 
   50216   ungetc (c, input);
   50217 }
   50218 
   50219 static int
   50220 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   50221 {
   50222   int c = get_char (lvalp, llocp);
   50223   int sign = 1;
   50224   int n = 0;
   50225 
   50226   (void) lvalp;(void) llocp;
   50227   if (c == '-')
   50228     {
   50229       c = get_char (lvalp, llocp);
   50230       sign = -1;
   50231     }
   50232 
   50233   while (isdigit (c))
   50234     {
   50235       n = 10 * n + (c - '0');
   50236       c = get_char (lvalp, llocp);
   50237     }
   50238 
   50239   unget_char (lvalp, llocp,  c);
   50240 
   50241   return sign * n;
   50242 }
   50243 
   50244 
   50245 
   50246 /*---------------------------------------------------------------.
   50247 | Lexical analyzer returns an integer on the stack and the token |
   50248 | NUM, or the ASCII character read if not a number.  Skips all   |
   50249 | blanks and tabs, returns 0 for EOF.                            |
   50250 `---------------------------------------------------------------*/
   50251 
   50252 static int
   50253 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   50254 {
   50255   static int init = 1;
   50256   int c;
   50257 
   50258   if (init)
   50259     {
   50260       init = 0;
   50261 
   50262       (*llocp).last_column = 0;
   50263       (*llocp).last_line = 1;
   50264 
   50265     }
   50266 
   50267 
   50268  (*llocp).first_column = (*llocp).last_column;
   50269   (*llocp).first_line   = (*llocp).last_line;
   50270 
   50271 
   50272   /* Skip white space.  */
   50273   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   50274     {
   50275      (*llocp).first_column = (*llocp).last_column;
   50276       (*llocp).first_line   = (*llocp).last_line;
   50277 
   50278     }
   50279 
   50280   /* process numbers   */
   50281   if (c == '.' || isdigit (c))
   50282     {
   50283       unget_char (lvalp, llocp,  c);
   50284       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   50285       return NUM;
   50286     }
   50287 
   50288   /* Return end-of-file.  */
   50289   if (c == EOF)
   50290     return CALC_EOF;
   50291 
   50292   /* Return single chars. */
   50293   return c;
   50294 }
   50295 
   50296 static int
   50297 power (int base, int exponent)
   50298 {
   50299   int res = 1;
   50300   if (exponent < 0)
   50301     exit (3);
   50302   for (/* Niente */; exponent; --exponent)
   50303     res *= base;
   50304   return res;
   50305 }
   50306 
   50307 
   50308 int
   50309 main (int argc, const char **argv)
   50310 {
   50311   semantic_value result = 0;
   50312   int count = 0;
   50313   int status;
   50314 
   50315   /* This used to be alarm (10), but that isn't enough time for
   50316      a July 1995 vintage DEC Alphastation 200 4/100 system,
   50317      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   50318   alarm (100);
   50319 
   50320   if (argc == 2)
   50321     input = fopen (argv[1], "r");
   50322   else
   50323     input = stdin;
   50324 
   50325   if (!input)
   50326     {
   50327       perror (argv[1]);
   50328       return 3;
   50329     }
   50330 
   50331 
   50332   status = yyparse (&result, &count);
   50333   if (global_result != result)
   50334     abort ();
   50335   if (global_count != count)
   50336     abort ();
   50337   return status;
   50338 }
   50339 _ATEOF
   50340 
   50341 
   50342 
   50343 
   50344 
   50345 $at_traceoff
   50346 echo "calc.at:628: bison -o calc.cc calc.y"
   50347 echo calc.at:628 >$at_check_line_file
   50348 ( $at_traceon; bison -o calc.cc calc.y ) >$at_stdout 2>$at_stder1
   50349 at_status=$?
   50350 grep '^ *+' $at_stder1 >&2
   50351 grep -v '^ *+' $at_stder1 >$at_stderr
   50352 at_failed=false
   50353 $at_diff $at_devnull $at_stderr || at_failed=:
   50354 $at_diff $at_devnull $at_stdout || at_failed=:
   50355 case $at_status in
   50356    77) echo 77 > $at_status_file
   50357             exit 77;;
   50358    0) ;;
   50359    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50360       at_failed=:;;
   50361 esac
   50362 if $at_failed; then
   50363 
   50364   echo 1 > $at_status_file
   50365   exit 1
   50366 fi
   50367 
   50368 $at_traceon
   50369 
   50370 
   50371 $at_traceoff
   50372 echo "calc.at:628: \$BISON_CXX_WORKS"
   50373 echo calc.at:628 >$at_check_line_file
   50374 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   50375 at_status=$?
   50376 grep '^ *+' $at_stder1 >&2
   50377 grep -v '^ *+' $at_stder1 >$at_stderr
   50378 at_failed=false
   50379 echo stderr:; cat $at_stderr
   50380 echo stdout:; cat $at_stdout
   50381 case $at_status in
   50382    77) echo 77 > $at_status_file
   50383             exit 77;;
   50384    0) ;;
   50385    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50386       at_failed=:;;
   50387 esac
   50388 if $at_failed; then
   50389 
   50390   echo 1 > $at_status_file
   50391   exit 1
   50392 fi
   50393 
   50394 $at_traceon
   50395 
   50396 $at_traceoff
   50397 echo "calc.at:628: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.cc \$LIBS"
   50398 echo calc.at:628 >$at_check_line_file
   50399 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o calc calc.cc $LIBS ) >$at_stdout 2>$at_stder1
   50400 at_status=$?
   50401 grep '^ *+' $at_stder1 >&2
   50402 grep -v '^ *+' $at_stder1 >$at_stderr
   50403 at_failed=false
   50404 echo stderr:; cat $at_stderr
   50405 echo stdout:; cat $at_stdout
   50406 case $at_status in
   50407    77) echo 77 > $at_status_file
   50408             exit 77;;
   50409    0) ;;
   50410    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50411       at_failed=:;;
   50412 esac
   50413 if $at_failed; then
   50414 
   50415   echo 1 > $at_status_file
   50416   exit 1
   50417 fi
   50418 
   50419 $at_traceon
   50420 
   50421 
   50422 # Test the priorities.
   50423 cat >input <<'_ATEOF'
   50424 1 + 2 * 3 = 7
   50425 1 + 2 * -3 = -5
   50426 
   50427 -1^2 = -1
   50428 (-1)^2 = 1
   50429 
   50430 ---1 = -1
   50431 
   50432 1 - 2 - 3 = -4
   50433 1 - (2 - 3) = 2
   50434 
   50435 2^2^3 = 256
   50436 (2^2)^3 = 64
   50437 _ATEOF
   50438 
   50439 $at_traceoff
   50440 echo "calc.at:628: \$PREPARSER ./calc input"
   50441 echo calc.at:628 >$at_check_line_file
   50442 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   50443 at_status=$?
   50444 grep '^ *+' $at_stder1 >&2
   50445 grep -v '^ *+' $at_stder1 >$at_stderr
   50446 at_failed=false
   50447 echo stderr:; tee stderr <$at_stderr
   50448 $at_diff $at_devnull $at_stdout || at_failed=:
   50449 case $at_status in
   50450    77) echo 77 > $at_status_file
   50451             exit 77;;
   50452    0) ;;
   50453    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50454       at_failed=:;;
   50455 esac
   50456 if $at_failed; then
   50457 
   50458   echo 1 > $at_status_file
   50459   exit 1
   50460 fi
   50461 
   50462 $at_traceon
   50463 
   50464 
   50465 
   50466 # Some syntax errors.
   50467 cat >input <<'_ATEOF'
   50468 0 0
   50469 _ATEOF
   50470 
   50471 $at_traceoff
   50472 echo "calc.at:628: \$PREPARSER ./calc input"
   50473 echo calc.at:628 >$at_check_line_file
   50474 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   50475 at_status=$?
   50476 grep '^ *+' $at_stder1 >&2
   50477 grep -v '^ *+' $at_stder1 >$at_stderr
   50478 at_failed=false
   50479 echo stderr:; tee stderr <$at_stderr
   50480 $at_diff $at_devnull $at_stdout || at_failed=:
   50481 case $at_status in
   50482    77) echo 77 > $at_status_file
   50483             exit 77;;
   50484    1) ;;
   50485    *) echo "calc.at:628: exit code was $at_status, expected 1"
   50486       at_failed=:;;
   50487 esac
   50488 if $at_failed; then
   50489 
   50490   echo 1 > $at_status_file
   50491   exit 1
   50492 fi
   50493 
   50494 $at_traceon
   50495 
   50496 
   50497 # Normalize the observed and expected error messages, depending upon the
   50498 # options.
   50499 # 1. Remove the traces from observed.
   50500 sed '/^Starting/d
   50501 /^Entering/d
   50502 /^Stack/d
   50503 /^Reading/d
   50504 /^Reducing/d
   50505 /^Shifting/d
   50506 /^state/d
   50507 /^Cleanup:/d
   50508 /^Error:/d
   50509 /^Next/d
   50510 /^Discarding/d
   50511 / \$[0-9$]* = /d
   50512 /^yydestructor:/d' stderr >at-stderr
   50513 mv at-stderr stderr
   50514 # 2. Create the reference error message.
   50515 cat >expout <<'_ATEOF'
   50516 1.2: syntax error, unexpected number
   50517 _ATEOF
   50518 
   50519 # 3. If locations are not used, remove them.
   50520 
   50521 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   50522 
   50523 # 5. Check
   50524 $at_traceoff
   50525 echo "calc.at:628: cat stderr"
   50526 echo calc.at:628 >$at_check_line_file
   50527 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   50528 at_status=$?
   50529 grep '^ *+' $at_stder1 >&2
   50530 grep -v '^ *+' $at_stder1 >$at_stderr
   50531 at_failed=false
   50532 $at_diff $at_devnull $at_stderr || at_failed=:
   50533 $at_diff expout $at_stdout || at_failed=:
   50534 case $at_status in
   50535    77) echo 77 > $at_status_file
   50536             exit 77;;
   50537    0) ;;
   50538    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50539       at_failed=:;;
   50540 esac
   50541 if $at_failed; then
   50542 
   50543   echo 1 > $at_status_file
   50544   exit 1
   50545 fi
   50546 
   50547 $at_traceon
   50548 
   50549 
   50550 cat >input <<'_ATEOF'
   50551 1//2
   50552 _ATEOF
   50553 
   50554 $at_traceoff
   50555 echo "calc.at:628: \$PREPARSER ./calc input"
   50556 echo calc.at:628 >$at_check_line_file
   50557 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   50558 at_status=$?
   50559 grep '^ *+' $at_stder1 >&2
   50560 grep -v '^ *+' $at_stder1 >$at_stderr
   50561 at_failed=false
   50562 echo stderr:; tee stderr <$at_stderr
   50563 $at_diff $at_devnull $at_stdout || at_failed=:
   50564 case $at_status in
   50565    77) echo 77 > $at_status_file
   50566             exit 77;;
   50567    1) ;;
   50568    *) echo "calc.at:628: exit code was $at_status, expected 1"
   50569       at_failed=:;;
   50570 esac
   50571 if $at_failed; then
   50572 
   50573   echo 1 > $at_status_file
   50574   exit 1
   50575 fi
   50576 
   50577 $at_traceon
   50578 
   50579 
   50580 # Normalize the observed and expected error messages, depending upon the
   50581 # options.
   50582 # 1. Remove the traces from observed.
   50583 sed '/^Starting/d
   50584 /^Entering/d
   50585 /^Stack/d
   50586 /^Reading/d
   50587 /^Reducing/d
   50588 /^Shifting/d
   50589 /^state/d
   50590 /^Cleanup:/d
   50591 /^Error:/d
   50592 /^Next/d
   50593 /^Discarding/d
   50594 / \$[0-9$]* = /d
   50595 /^yydestructor:/d' stderr >at-stderr
   50596 mv at-stderr stderr
   50597 # 2. Create the reference error message.
   50598 cat >expout <<'_ATEOF'
   50599 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   50600 _ATEOF
   50601 
   50602 # 3. If locations are not used, remove them.
   50603 
   50604 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   50605 
   50606 # 5. Check
   50607 $at_traceoff
   50608 echo "calc.at:628: cat stderr"
   50609 echo calc.at:628 >$at_check_line_file
   50610 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   50611 at_status=$?
   50612 grep '^ *+' $at_stder1 >&2
   50613 grep -v '^ *+' $at_stder1 >$at_stderr
   50614 at_failed=false
   50615 $at_diff $at_devnull $at_stderr || at_failed=:
   50616 $at_diff expout $at_stdout || at_failed=:
   50617 case $at_status in
   50618    77) echo 77 > $at_status_file
   50619             exit 77;;
   50620    0) ;;
   50621    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50622       at_failed=:;;
   50623 esac
   50624 if $at_failed; then
   50625 
   50626   echo 1 > $at_status_file
   50627   exit 1
   50628 fi
   50629 
   50630 $at_traceon
   50631 
   50632 
   50633 cat >input <<'_ATEOF'
   50634 error
   50635 _ATEOF
   50636 
   50637 $at_traceoff
   50638 echo "calc.at:628: \$PREPARSER ./calc input"
   50639 echo calc.at:628 >$at_check_line_file
   50640 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   50641 at_status=$?
   50642 grep '^ *+' $at_stder1 >&2
   50643 grep -v '^ *+' $at_stder1 >$at_stderr
   50644 at_failed=false
   50645 echo stderr:; tee stderr <$at_stderr
   50646 $at_diff $at_devnull $at_stdout || at_failed=:
   50647 case $at_status in
   50648    77) echo 77 > $at_status_file
   50649             exit 77;;
   50650    1) ;;
   50651    *) echo "calc.at:628: exit code was $at_status, expected 1"
   50652       at_failed=:;;
   50653 esac
   50654 if $at_failed; then
   50655 
   50656   echo 1 > $at_status_file
   50657   exit 1
   50658 fi
   50659 
   50660 $at_traceon
   50661 
   50662 
   50663 # Normalize the observed and expected error messages, depending upon the
   50664 # options.
   50665 # 1. Remove the traces from observed.
   50666 sed '/^Starting/d
   50667 /^Entering/d
   50668 /^Stack/d
   50669 /^Reading/d
   50670 /^Reducing/d
   50671 /^Shifting/d
   50672 /^state/d
   50673 /^Cleanup:/d
   50674 /^Error:/d
   50675 /^Next/d
   50676 /^Discarding/d
   50677 / \$[0-9$]* = /d
   50678 /^yydestructor:/d' stderr >at-stderr
   50679 mv at-stderr stderr
   50680 # 2. Create the reference error message.
   50681 cat >expout <<'_ATEOF'
   50682 1.0: syntax error, unexpected $undefined
   50683 _ATEOF
   50684 
   50685 # 3. If locations are not used, remove them.
   50686 
   50687 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   50688 
   50689 # 5. Check
   50690 $at_traceoff
   50691 echo "calc.at:628: cat stderr"
   50692 echo calc.at:628 >$at_check_line_file
   50693 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   50694 at_status=$?
   50695 grep '^ *+' $at_stder1 >&2
   50696 grep -v '^ *+' $at_stder1 >$at_stderr
   50697 at_failed=false
   50698 $at_diff $at_devnull $at_stderr || at_failed=:
   50699 $at_diff expout $at_stdout || at_failed=:
   50700 case $at_status in
   50701    77) echo 77 > $at_status_file
   50702             exit 77;;
   50703    0) ;;
   50704    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50705       at_failed=:;;
   50706 esac
   50707 if $at_failed; then
   50708 
   50709   echo 1 > $at_status_file
   50710   exit 1
   50711 fi
   50712 
   50713 $at_traceon
   50714 
   50715 
   50716 cat >input <<'_ATEOF'
   50717 1 = 2 = 3
   50718 _ATEOF
   50719 
   50720 $at_traceoff
   50721 echo "calc.at:628: \$PREPARSER ./calc input"
   50722 echo calc.at:628 >$at_check_line_file
   50723 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   50724 at_status=$?
   50725 grep '^ *+' $at_stder1 >&2
   50726 grep -v '^ *+' $at_stder1 >$at_stderr
   50727 at_failed=false
   50728 echo stderr:; tee stderr <$at_stderr
   50729 $at_diff $at_devnull $at_stdout || at_failed=:
   50730 case $at_status in
   50731    77) echo 77 > $at_status_file
   50732             exit 77;;
   50733    1) ;;
   50734    *) echo "calc.at:628: exit code was $at_status, expected 1"
   50735       at_failed=:;;
   50736 esac
   50737 if $at_failed; then
   50738 
   50739   echo 1 > $at_status_file
   50740   exit 1
   50741 fi
   50742 
   50743 $at_traceon
   50744 
   50745 
   50746 # Normalize the observed and expected error messages, depending upon the
   50747 # options.
   50748 # 1. Remove the traces from observed.
   50749 sed '/^Starting/d
   50750 /^Entering/d
   50751 /^Stack/d
   50752 /^Reading/d
   50753 /^Reducing/d
   50754 /^Shifting/d
   50755 /^state/d
   50756 /^Cleanup:/d
   50757 /^Error:/d
   50758 /^Next/d
   50759 /^Discarding/d
   50760 / \$[0-9$]* = /d
   50761 /^yydestructor:/d' stderr >at-stderr
   50762 mv at-stderr stderr
   50763 # 2. Create the reference error message.
   50764 cat >expout <<'_ATEOF'
   50765 1.6: syntax error, unexpected '='
   50766 _ATEOF
   50767 
   50768 # 3. If locations are not used, remove them.
   50769 
   50770 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   50771 
   50772 # 5. Check
   50773 $at_traceoff
   50774 echo "calc.at:628: cat stderr"
   50775 echo calc.at:628 >$at_check_line_file
   50776 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   50777 at_status=$?
   50778 grep '^ *+' $at_stder1 >&2
   50779 grep -v '^ *+' $at_stder1 >$at_stderr
   50780 at_failed=false
   50781 $at_diff $at_devnull $at_stderr || at_failed=:
   50782 $at_diff expout $at_stdout || at_failed=:
   50783 case $at_status in
   50784    77) echo 77 > $at_status_file
   50785             exit 77;;
   50786    0) ;;
   50787    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50788       at_failed=:;;
   50789 esac
   50790 if $at_failed; then
   50791 
   50792   echo 1 > $at_status_file
   50793   exit 1
   50794 fi
   50795 
   50796 $at_traceon
   50797 
   50798 
   50799 cat >input <<'_ATEOF'
   50800 
   50801 +1
   50802 _ATEOF
   50803 
   50804 $at_traceoff
   50805 echo "calc.at:628: \$PREPARSER ./calc input"
   50806 echo calc.at:628 >$at_check_line_file
   50807 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   50808 at_status=$?
   50809 grep '^ *+' $at_stder1 >&2
   50810 grep -v '^ *+' $at_stder1 >$at_stderr
   50811 at_failed=false
   50812 echo stderr:; tee stderr <$at_stderr
   50813 $at_diff $at_devnull $at_stdout || at_failed=:
   50814 case $at_status in
   50815    77) echo 77 > $at_status_file
   50816             exit 77;;
   50817    1) ;;
   50818    *) echo "calc.at:628: exit code was $at_status, expected 1"
   50819       at_failed=:;;
   50820 esac
   50821 if $at_failed; then
   50822 
   50823   echo 1 > $at_status_file
   50824   exit 1
   50825 fi
   50826 
   50827 $at_traceon
   50828 
   50829 
   50830 # Normalize the observed and expected error messages, depending upon the
   50831 # options.
   50832 # 1. Remove the traces from observed.
   50833 sed '/^Starting/d
   50834 /^Entering/d
   50835 /^Stack/d
   50836 /^Reading/d
   50837 /^Reducing/d
   50838 /^Shifting/d
   50839 /^state/d
   50840 /^Cleanup:/d
   50841 /^Error:/d
   50842 /^Next/d
   50843 /^Discarding/d
   50844 / \$[0-9$]* = /d
   50845 /^yydestructor:/d' stderr >at-stderr
   50846 mv at-stderr stderr
   50847 # 2. Create the reference error message.
   50848 cat >expout <<'_ATEOF'
   50849 2.0: syntax error, unexpected '+'
   50850 _ATEOF
   50851 
   50852 # 3. If locations are not used, remove them.
   50853 
   50854 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   50855 
   50856 # 5. Check
   50857 $at_traceoff
   50858 echo "calc.at:628: cat stderr"
   50859 echo calc.at:628 >$at_check_line_file
   50860 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   50861 at_status=$?
   50862 grep '^ *+' $at_stder1 >&2
   50863 grep -v '^ *+' $at_stder1 >$at_stderr
   50864 at_failed=false
   50865 $at_diff $at_devnull $at_stderr || at_failed=:
   50866 $at_diff expout $at_stdout || at_failed=:
   50867 case $at_status in
   50868    77) echo 77 > $at_status_file
   50869             exit 77;;
   50870    0) ;;
   50871    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50872       at_failed=:;;
   50873 esac
   50874 if $at_failed; then
   50875 
   50876   echo 1 > $at_status_file
   50877   exit 1
   50878 fi
   50879 
   50880 $at_traceon
   50881 
   50882 
   50883 # Exercise error messages with EOF: work on an empty file.
   50884 $at_traceoff
   50885 echo "calc.at:628: \$PREPARSER ./calc /dev/null"
   50886 echo calc.at:628 >$at_check_line_file
   50887 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   50888 at_status=$?
   50889 grep '^ *+' $at_stder1 >&2
   50890 grep -v '^ *+' $at_stder1 >$at_stderr
   50891 at_failed=false
   50892 echo stderr:; tee stderr <$at_stderr
   50893 $at_diff $at_devnull $at_stdout || at_failed=:
   50894 case $at_status in
   50895    77) echo 77 > $at_status_file
   50896             exit 77;;
   50897    1) ;;
   50898    *) echo "calc.at:628: exit code was $at_status, expected 1"
   50899       at_failed=:;;
   50900 esac
   50901 if $at_failed; then
   50902 
   50903   echo 1 > $at_status_file
   50904   exit 1
   50905 fi
   50906 
   50907 $at_traceon
   50908 
   50909 
   50910 # Normalize the observed and expected error messages, depending upon the
   50911 # options.
   50912 # 1. Remove the traces from observed.
   50913 sed '/^Starting/d
   50914 /^Entering/d
   50915 /^Stack/d
   50916 /^Reading/d
   50917 /^Reducing/d
   50918 /^Shifting/d
   50919 /^state/d
   50920 /^Cleanup:/d
   50921 /^Error:/d
   50922 /^Next/d
   50923 /^Discarding/d
   50924 / \$[0-9$]* = /d
   50925 /^yydestructor:/d' stderr >at-stderr
   50926 mv at-stderr stderr
   50927 # 2. Create the reference error message.
   50928 cat >expout <<'_ATEOF'
   50929 1.0: syntax error, unexpected end of input
   50930 _ATEOF
   50931 
   50932 # 3. If locations are not used, remove them.
   50933 
   50934 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   50935 
   50936 # 5. Check
   50937 $at_traceoff
   50938 echo "calc.at:628: cat stderr"
   50939 echo calc.at:628 >$at_check_line_file
   50940 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   50941 at_status=$?
   50942 grep '^ *+' $at_stder1 >&2
   50943 grep -v '^ *+' $at_stder1 >$at_stderr
   50944 at_failed=false
   50945 $at_diff $at_devnull $at_stderr || at_failed=:
   50946 $at_diff expout $at_stdout || at_failed=:
   50947 case $at_status in
   50948    77) echo 77 > $at_status_file
   50949             exit 77;;
   50950    0) ;;
   50951    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50952       at_failed=:;;
   50953 esac
   50954 if $at_failed; then
   50955 
   50956   echo 1 > $at_status_file
   50957   exit 1
   50958 fi
   50959 
   50960 $at_traceon
   50961 
   50962 
   50963 
   50964 # Exercise the error token: without it, we die at the first error,
   50965 # hence be sure to
   50966 #
   50967 # - have several errors which exercise different shift/discardings
   50968 #   - (): nothing to pop, nothing to discard
   50969 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   50970 #   - (* * *): nothing to pop, a lot to discard
   50971 #   - (1 + 2 * *): some to pop and discard
   50972 #
   50973 # - test the action associated to `error'
   50974 #
   50975 # - check the look-ahead that triggers an error is not discarded
   50976 #   when we enter error recovery.  Below, the look-ahead causing the
   50977 #   first error is ")", which is needed to recover from the error and
   50978 #   produce the "0" that triggers the "0 != 1" error.
   50979 #
   50980 cat >input <<'_ATEOF'
   50981 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   50982 _ATEOF
   50983 
   50984 $at_traceoff
   50985 echo "calc.at:628: \$PREPARSER ./calc input"
   50986 echo calc.at:628 >$at_check_line_file
   50987 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   50988 at_status=$?
   50989 grep '^ *+' $at_stder1 >&2
   50990 grep -v '^ *+' $at_stder1 >$at_stderr
   50991 at_failed=false
   50992 echo stderr:; tee stderr <$at_stderr
   50993 $at_diff $at_devnull $at_stdout || at_failed=:
   50994 case $at_status in
   50995    77) echo 77 > $at_status_file
   50996             exit 77;;
   50997    0) ;;
   50998    *) echo "calc.at:628: exit code was $at_status, expected 0"
   50999       at_failed=:;;
   51000 esac
   51001 if $at_failed; then
   51002 
   51003   echo 1 > $at_status_file
   51004   exit 1
   51005 fi
   51006 
   51007 $at_traceon
   51008 
   51009 
   51010 # Normalize the observed and expected error messages, depending upon the
   51011 # options.
   51012 # 1. Remove the traces from observed.
   51013 sed '/^Starting/d
   51014 /^Entering/d
   51015 /^Stack/d
   51016 /^Reading/d
   51017 /^Reducing/d
   51018 /^Shifting/d
   51019 /^state/d
   51020 /^Cleanup:/d
   51021 /^Error:/d
   51022 /^Next/d
   51023 /^Discarding/d
   51024 / \$[0-9$]* = /d
   51025 /^yydestructor:/d' stderr >at-stderr
   51026 mv at-stderr stderr
   51027 # 2. Create the reference error message.
   51028 cat >expout <<'_ATEOF'
   51029 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   51030 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   51031 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   51032 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   51033 calc: error: 4444 != 1
   51034 _ATEOF
   51035 
   51036 # 3. If locations are not used, remove them.
   51037 
   51038 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   51039 
   51040 # 5. Check
   51041 $at_traceoff
   51042 echo "calc.at:628: cat stderr"
   51043 echo calc.at:628 >$at_check_line_file
   51044 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   51045 at_status=$?
   51046 grep '^ *+' $at_stder1 >&2
   51047 grep -v '^ *+' $at_stder1 >$at_stderr
   51048 at_failed=false
   51049 $at_diff $at_devnull $at_stderr || at_failed=:
   51050 $at_diff expout $at_stdout || at_failed=:
   51051 case $at_status in
   51052    77) echo 77 > $at_status_file
   51053             exit 77;;
   51054    0) ;;
   51055    *) echo "calc.at:628: exit code was $at_status, expected 0"
   51056       at_failed=:;;
   51057 esac
   51058 if $at_failed; then
   51059 
   51060   echo 1 > $at_status_file
   51061   exit 1
   51062 fi
   51063 
   51064 $at_traceon
   51065 
   51066 
   51067 
   51068 # The same, but this time exercising explicitly triggered syntax errors.
   51069 # POSIX says the look-ahead causing the error should not be discarded.
   51070 cat >input <<'_ATEOF'
   51071 (!) + (0 0) = 1
   51072 _ATEOF
   51073 
   51074 $at_traceoff
   51075 echo "calc.at:628: \$PREPARSER ./calc input"
   51076 echo calc.at:628 >$at_check_line_file
   51077 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   51078 at_status=$?
   51079 grep '^ *+' $at_stder1 >&2
   51080 grep -v '^ *+' $at_stder1 >$at_stderr
   51081 at_failed=false
   51082 echo stderr:; tee stderr <$at_stderr
   51083 $at_diff $at_devnull $at_stdout || at_failed=:
   51084 case $at_status in
   51085    77) echo 77 > $at_status_file
   51086             exit 77;;
   51087    0) ;;
   51088    *) echo "calc.at:628: exit code was $at_status, expected 0"
   51089       at_failed=:;;
   51090 esac
   51091 if $at_failed; then
   51092 
   51093   echo 1 > $at_status_file
   51094   exit 1
   51095 fi
   51096 
   51097 $at_traceon
   51098 
   51099 
   51100 # Normalize the observed and expected error messages, depending upon the
   51101 # options.
   51102 # 1. Remove the traces from observed.
   51103 sed '/^Starting/d
   51104 /^Entering/d
   51105 /^Stack/d
   51106 /^Reading/d
   51107 /^Reducing/d
   51108 /^Shifting/d
   51109 /^state/d
   51110 /^Cleanup:/d
   51111 /^Error:/d
   51112 /^Next/d
   51113 /^Discarding/d
   51114 / \$[0-9$]* = /d
   51115 /^yydestructor:/d' stderr >at-stderr
   51116 mv at-stderr stderr
   51117 # 2. Create the reference error message.
   51118 cat >expout <<'_ATEOF'
   51119 1.9: syntax error, unexpected number
   51120 calc: error: 2222 != 1
   51121 _ATEOF
   51122 
   51123 # 3. If locations are not used, remove them.
   51124 
   51125 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   51126 
   51127 # 5. Check
   51128 $at_traceoff
   51129 echo "calc.at:628: cat stderr"
   51130 echo calc.at:628 >$at_check_line_file
   51131 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   51132 at_status=$?
   51133 grep '^ *+' $at_stder1 >&2
   51134 grep -v '^ *+' $at_stder1 >$at_stderr
   51135 at_failed=false
   51136 $at_diff $at_devnull $at_stderr || at_failed=:
   51137 $at_diff expout $at_stdout || at_failed=:
   51138 case $at_status in
   51139    77) echo 77 > $at_status_file
   51140             exit 77;;
   51141    0) ;;
   51142    *) echo "calc.at:628: exit code was $at_status, expected 0"
   51143       at_failed=:;;
   51144 esac
   51145 if $at_failed; then
   51146 
   51147   echo 1 > $at_status_file
   51148   exit 1
   51149 fi
   51150 
   51151 $at_traceon
   51152 
   51153 
   51154 cat >input <<'_ATEOF'
   51155 (- *) + (0 0) = 1
   51156 _ATEOF
   51157 
   51158 $at_traceoff
   51159 echo "calc.at:628: \$PREPARSER ./calc input"
   51160 echo calc.at:628 >$at_check_line_file
   51161 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   51162 at_status=$?
   51163 grep '^ *+' $at_stder1 >&2
   51164 grep -v '^ *+' $at_stder1 >$at_stderr
   51165 at_failed=false
   51166 echo stderr:; tee stderr <$at_stderr
   51167 $at_diff $at_devnull $at_stdout || at_failed=:
   51168 case $at_status in
   51169    77) echo 77 > $at_status_file
   51170             exit 77;;
   51171    0) ;;
   51172    *) echo "calc.at:628: exit code was $at_status, expected 0"
   51173       at_failed=:;;
   51174 esac
   51175 if $at_failed; then
   51176 
   51177   echo 1 > $at_status_file
   51178   exit 1
   51179 fi
   51180 
   51181 $at_traceon
   51182 
   51183 
   51184 # Normalize the observed and expected error messages, depending upon the
   51185 # options.
   51186 # 1. Remove the traces from observed.
   51187 sed '/^Starting/d
   51188 /^Entering/d
   51189 /^Stack/d
   51190 /^Reading/d
   51191 /^Reducing/d
   51192 /^Shifting/d
   51193 /^state/d
   51194 /^Cleanup:/d
   51195 /^Error:/d
   51196 /^Next/d
   51197 /^Discarding/d
   51198 / \$[0-9$]* = /d
   51199 /^yydestructor:/d' stderr >at-stderr
   51200 mv at-stderr stderr
   51201 # 2. Create the reference error message.
   51202 cat >expout <<'_ATEOF'
   51203 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   51204 1.11: syntax error, unexpected number
   51205 calc: error: 2222 != 1
   51206 _ATEOF
   51207 
   51208 # 3. If locations are not used, remove them.
   51209 
   51210 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   51211 
   51212 # 5. Check
   51213 $at_traceoff
   51214 echo "calc.at:628: cat stderr"
   51215 echo calc.at:628 >$at_check_line_file
   51216 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   51217 at_status=$?
   51218 grep '^ *+' $at_stder1 >&2
   51219 grep -v '^ *+' $at_stder1 >$at_stderr
   51220 at_failed=false
   51221 $at_diff $at_devnull $at_stderr || at_failed=:
   51222 $at_diff expout $at_stdout || at_failed=:
   51223 case $at_status in
   51224    77) echo 77 > $at_status_file
   51225             exit 77;;
   51226    0) ;;
   51227    *) echo "calc.at:628: exit code was $at_status, expected 0"
   51228       at_failed=:;;
   51229 esac
   51230 if $at_failed; then
   51231 
   51232   echo 1 > $at_status_file
   51233   exit 1
   51234 fi
   51235 
   51236 $at_traceon
   51237 
   51238 
   51239 
   51240 
   51241 
   51242 
   51243 
   51244 
   51245 
   51246 
   51247 
   51248 
   51249 
   51250 
   51251 
   51252 
   51253 
   51254 
   51255 
   51256 
   51257 
   51258 
   51259 
   51260 
   51261       $at_traceoff
   51262       $at_times_p && times >$at_times_file
   51263     ) 5>&1 2>&1 | eval $at_tee_pipe
   51264     at_status=`cat $at_status_file`
   51265     ;;
   51266 
   51267 
   51268   banner-12 ) # Banner 12. calc.at:636
   51269     cat <<\_ATEOF
   51270 
   51271 Simple GLR C++ Calculator.
   51272 
   51273 _ATEOF
   51274     ;;
   51275 
   51276   103 ) # 103. calc.at:651: Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc
   51277     at_setup_line='calc.at:651'
   51278     at_desc='Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc'
   51279     $at_quiet $ECHO_N "103: Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc$ECHO_C"
   51280     at_xfail=no
   51281     (
   51282       echo "103. calc.at:651: testing ..."
   51283       $at_traceon
   51284 
   51285 
   51286 
   51287 
   51288 
   51289 
   51290 
   51291 
   51292 # Using yacc.c?
   51293 
   51294 
   51295 
   51296 
   51297 
   51298 
   51299 
   51300 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   51301 
   51302 # yyerror always sees the locations (when activated), except if
   51303 # yacc & pure & !param.
   51304 
   51305 
   51306 # The interface is pure: either because %pure-parser, or because we
   51307 # are using the C++ parsers.
   51308 
   51309 
   51310 
   51311 
   51312 
   51313 
   51314 
   51315 
   51316 
   51317 
   51318 
   51319 
   51320 cat >calc.y <<'_ATEOF'
   51321 %{
   51322 #ifdef HAVE_CONFIG_H
   51323 # include <config.h>
   51324   /* We don't need perfect functions for these tests. */
   51325 # undef malloc
   51326 # undef memcmp
   51327 # undef realloc
   51328 #endif
   51329 %}
   51330 
   51331 /* Infix notation calculator--calc */
   51332 %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc
   51333 %define "global_tokens_and_yystype"
   51334 %{
   51335 #include <stdio.h>
   51336 
   51337 #include <stdlib.h>
   51338 #include <string.h>
   51339 #if HAVE_UNISTD_H
   51340 # include <unistd.h>
   51341 #else
   51342 # undef alarm
   51343 # define alarm(seconds) /* empty */
   51344 #endif
   51345 #include <ctype.h>
   51346 #define USE(Var)
   51347 
   51348 /* Exercise pre-prologue dependency to %union.  */
   51349 typedef int semantic_value;
   51350 
   51351 static semantic_value global_result = 0;
   51352 static int global_count = 0;
   51353 %}
   51354 
   51355 /* Exercise %union. */
   51356 %union
   51357 {
   51358   semantic_value ival;
   51359 };
   51360 
   51361 %{
   51362 static int power (int base, int exponent);
   51363 #ifndef YYLTYPE
   51364 # define YYLTYPE calc::location
   51365 #endif
   51366 #define first_line   begin.line
   51367 #define first_column begin.column
   51368 #define last_line    end.line
   51369 #define last_column  end.column
   51370 
   51371 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   51372 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   51373 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   51374 %}
   51375 
   51376 /* The lalr1.cc skeleton, for backward compatibility, defines
   51377    a constructor for position that initializes the filename.  The
   51378    glr.cc skeleton does not (and in fact cannot: location/position
   51379    are stored in a union, from which objects with constructors are
   51380    excluded in C++. */
   51381 %initial-action {
   51382   @$.initialize (0);
   51383 }
   51384 
   51385 
   51386 /* Bison Declarations */
   51387 %token CALC_EOF 0 "end of input"
   51388 %token <ival> NUM "number"
   51389 %type  <ival> exp
   51390 
   51391 %nonassoc '=' /* comparison	       */
   51392 %left '-' '+'
   51393 %left '*' '/'
   51394 %left NEG     /* negation--unary minus */
   51395 %right '^'    /* exponentiation        */
   51396 
   51397 /* Grammar follows */
   51398 %%
   51399 input:
   51400   line
   51401 | input line         {  }
   51402 ;
   51403 
   51404 line:
   51405   '\n'
   51406 | exp '\n'           { USE ($1); }
   51407 ;
   51408 
   51409 exp:
   51410   NUM                { $$ = $1;             }
   51411 | exp '=' exp
   51412   {
   51413     if ($1 != $3)
   51414       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   51415     $$ = $1;
   51416   }
   51417 | exp '+' exp        { $$ = $1 + $3;        }
   51418 | exp '-' exp        { $$ = $1 - $3;        }
   51419 | exp '*' exp        { $$ = $1 * $3;        }
   51420 | exp '/' exp        { $$ = $1 / $3;        }
   51421 | '-' exp  %prec NEG { $$ = -$2;            }
   51422 | exp '^' exp        { $$ = power ($1, $3); }
   51423 | '(' exp ')'        { $$ = $2;             }
   51424 | '(' error ')'      { $$ = 1111;           }
   51425 | '!'                { $$ = 0; YYERROR;     }
   51426 | '-' error          { $$ = 0; YYERROR;     }
   51427 ;
   51428 %%
   51429 /* The input.  */
   51430 static FILE *input;
   51431 
   51432 /* A C++ error reporting function.  */
   51433 void
   51434 calc::parser::error (const location& l, const std::string& m)
   51435 {
   51436   (void) l;
   51437   std::cerr << l << ": " << m << std::endl;
   51438 }
   51439 
   51440 int
   51441 yyparse ()
   51442 {
   51443   calc::parser parser;
   51444   parser.set_debug_level (!!YYDEBUG);
   51445   return parser.parse ();
   51446 }
   51447 
   51448 
   51449 
   51450 
   51451 static YYLTYPE last_yylloc;
   51452 
   51453 static int
   51454 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   51455 {
   51456   int res = getc (input);
   51457   (void) lvalp;(void) llocp;
   51458 
   51459   last_yylloc = (*llocp);
   51460   if (res == '\n')
   51461     {
   51462       (*llocp).last_line++;
   51463       (*llocp).last_column = 0;
   51464     }
   51465   else
   51466     (*llocp).last_column++;
   51467 
   51468   return res;
   51469 }
   51470 
   51471 
   51472 static void
   51473 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   51474 {
   51475   (void) lvalp;(void) llocp;
   51476 
   51477   /* Wrong when C == `\n'. */
   51478   (*llocp) = last_yylloc;
   51479 
   51480   ungetc (c, input);
   51481 }
   51482 
   51483 static int
   51484 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   51485 {
   51486   int c = get_char (lvalp, llocp);
   51487   int sign = 1;
   51488   int n = 0;
   51489 
   51490   (void) lvalp;(void) llocp;
   51491   if (c == '-')
   51492     {
   51493       c = get_char (lvalp, llocp);
   51494       sign = -1;
   51495     }
   51496 
   51497   while (isdigit (c))
   51498     {
   51499       n = 10 * n + (c - '0');
   51500       c = get_char (lvalp, llocp);
   51501     }
   51502 
   51503   unget_char (lvalp, llocp,  c);
   51504 
   51505   return sign * n;
   51506 }
   51507 
   51508 
   51509 
   51510 /*---------------------------------------------------------------.
   51511 | Lexical analyzer returns an integer on the stack and the token |
   51512 | NUM, or the ASCII character read if not a number.  Skips all   |
   51513 | blanks and tabs, returns 0 for EOF.                            |
   51514 `---------------------------------------------------------------*/
   51515 
   51516 static int
   51517 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   51518 {
   51519   static int init = 1;
   51520   int c;
   51521 
   51522   if (init)
   51523     {
   51524       init = 0;
   51525 
   51526       (*llocp).last_column = 0;
   51527       (*llocp).last_line = 1;
   51528 
   51529     }
   51530 
   51531 
   51532  (*llocp).first_column = (*llocp).last_column;
   51533   (*llocp).first_line   = (*llocp).last_line;
   51534 
   51535 
   51536   /* Skip white space.  */
   51537   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   51538     {
   51539      (*llocp).first_column = (*llocp).last_column;
   51540       (*llocp).first_line   = (*llocp).last_line;
   51541 
   51542     }
   51543 
   51544   /* process numbers   */
   51545   if (c == '.' || isdigit (c))
   51546     {
   51547       unget_char (lvalp, llocp,  c);
   51548       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   51549       return NUM;
   51550     }
   51551 
   51552   /* Return end-of-file.  */
   51553   if (c == EOF)
   51554     return CALC_EOF;
   51555 
   51556   /* Return single chars. */
   51557   return c;
   51558 }
   51559 
   51560 static int
   51561 power (int base, int exponent)
   51562 {
   51563   int res = 1;
   51564   if (exponent < 0)
   51565     exit (3);
   51566   for (/* Niente */; exponent; --exponent)
   51567     res *= base;
   51568   return res;
   51569 }
   51570 
   51571 
   51572 int
   51573 main (int argc, const char **argv)
   51574 {
   51575   semantic_value result = 0;
   51576   int count = 0;
   51577   int status;
   51578 
   51579   /* This used to be alarm (10), but that isn't enough time for
   51580      a July 1995 vintage DEC Alphastation 200 4/100 system,
   51581      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   51582   alarm (100);
   51583 
   51584   if (argc == 2)
   51585     input = fopen (argv[1], "r");
   51586   else
   51587     input = stdin;
   51588 
   51589   if (!input)
   51590     {
   51591       perror (argv[1]);
   51592       return 3;
   51593     }
   51594 
   51595 
   51596   status = yyparse ();
   51597   if (global_result != result)
   51598     abort ();
   51599   if (global_count != count)
   51600     abort ();
   51601   return status;
   51602 }
   51603 _ATEOF
   51604 
   51605 
   51606 
   51607 
   51608 
   51609 $at_traceoff
   51610 echo "calc.at:651: bison -o calc.cc calc.y"
   51611 echo calc.at:651 >$at_check_line_file
   51612 ( $at_traceon; bison -o calc.cc calc.y ) >$at_stdout 2>$at_stder1
   51613 at_status=$?
   51614 grep '^ *+' $at_stder1 >&2
   51615 grep -v '^ *+' $at_stder1 >$at_stderr
   51616 at_failed=false
   51617 $at_diff $at_devnull $at_stderr || at_failed=:
   51618 $at_diff $at_devnull $at_stdout || at_failed=:
   51619 case $at_status in
   51620    77) echo 77 > $at_status_file
   51621             exit 77;;
   51622    0) ;;
   51623    *) echo "calc.at:651: exit code was $at_status, expected 0"
   51624       at_failed=:;;
   51625 esac
   51626 if $at_failed; then
   51627 
   51628   echo 1 > $at_status_file
   51629   exit 1
   51630 fi
   51631 
   51632 $at_traceon
   51633 
   51634 
   51635 $at_traceoff
   51636 echo "calc.at:651: \$BISON_CXX_WORKS"
   51637 echo calc.at:651 >$at_check_line_file
   51638 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   51639 at_status=$?
   51640 grep '^ *+' $at_stder1 >&2
   51641 grep -v '^ *+' $at_stder1 >$at_stderr
   51642 at_failed=false
   51643 echo stderr:; cat $at_stderr
   51644 echo stdout:; cat $at_stdout
   51645 case $at_status in
   51646    77) echo 77 > $at_status_file
   51647             exit 77;;
   51648    0) ;;
   51649    *) echo "calc.at:651: exit code was $at_status, expected 0"
   51650       at_failed=:;;
   51651 esac
   51652 if $at_failed; then
   51653 
   51654   echo 1 > $at_status_file
   51655   exit 1
   51656 fi
   51657 
   51658 $at_traceon
   51659 
   51660 $at_traceoff
   51661 echo "calc.at:651: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.cc \$LIBS"
   51662 echo calc.at:651 >$at_check_line_file
   51663 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o calc calc.cc $LIBS ) >$at_stdout 2>$at_stder1
   51664 at_status=$?
   51665 grep '^ *+' $at_stder1 >&2
   51666 grep -v '^ *+' $at_stder1 >$at_stderr
   51667 at_failed=false
   51668 echo stderr:; cat $at_stderr
   51669 echo stdout:; cat $at_stdout
   51670 case $at_status in
   51671    77) echo 77 > $at_status_file
   51672             exit 77;;
   51673    0) ;;
   51674    *) echo "calc.at:651: exit code was $at_status, expected 0"
   51675       at_failed=:;;
   51676 esac
   51677 if $at_failed; then
   51678 
   51679   echo 1 > $at_status_file
   51680   exit 1
   51681 fi
   51682 
   51683 $at_traceon
   51684 
   51685 
   51686 # Test the priorities.
   51687 cat >input <<'_ATEOF'
   51688 1 + 2 * 3 = 7
   51689 1 + 2 * -3 = -5
   51690 
   51691 -1^2 = -1
   51692 (-1)^2 = 1
   51693 
   51694 ---1 = -1
   51695 
   51696 1 - 2 - 3 = -4
   51697 1 - (2 - 3) = 2
   51698 
   51699 2^2^3 = 256
   51700 (2^2)^3 = 64
   51701 _ATEOF
   51702 
   51703 $at_traceoff
   51704 echo "calc.at:651: \$PREPARSER ./calc input"
   51705 echo calc.at:651 >$at_check_line_file
   51706 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   51707 at_status=$?
   51708 grep '^ *+' $at_stder1 >&2
   51709 grep -v '^ *+' $at_stder1 >$at_stderr
   51710 at_failed=false
   51711 echo stderr:; tee stderr <$at_stderr
   51712 $at_diff $at_devnull $at_stdout || at_failed=:
   51713 case $at_status in
   51714    77) echo 77 > $at_status_file
   51715             exit 77;;
   51716    0) ;;
   51717    *) echo "calc.at:651: exit code was $at_status, expected 0"
   51718       at_failed=:;;
   51719 esac
   51720 if $at_failed; then
   51721 
   51722   echo 1 > $at_status_file
   51723   exit 1
   51724 fi
   51725 
   51726 $at_traceon
   51727 
   51728 
   51729 
   51730 # Some syntax errors.
   51731 cat >input <<'_ATEOF'
   51732 0 0
   51733 _ATEOF
   51734 
   51735 $at_traceoff
   51736 echo "calc.at:651: \$PREPARSER ./calc input"
   51737 echo calc.at:651 >$at_check_line_file
   51738 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   51739 at_status=$?
   51740 grep '^ *+' $at_stder1 >&2
   51741 grep -v '^ *+' $at_stder1 >$at_stderr
   51742 at_failed=false
   51743 echo stderr:; tee stderr <$at_stderr
   51744 $at_diff $at_devnull $at_stdout || at_failed=:
   51745 case $at_status in
   51746    77) echo 77 > $at_status_file
   51747             exit 77;;
   51748    1) ;;
   51749    *) echo "calc.at:651: exit code was $at_status, expected 1"
   51750       at_failed=:;;
   51751 esac
   51752 if $at_failed; then
   51753 
   51754   echo 1 > $at_status_file
   51755   exit 1
   51756 fi
   51757 
   51758 $at_traceon
   51759 
   51760 
   51761 # Normalize the observed and expected error messages, depending upon the
   51762 # options.
   51763 # 1. Remove the traces from observed.
   51764 sed '/^Starting/d
   51765 /^Entering/d
   51766 /^Stack/d
   51767 /^Reading/d
   51768 /^Reducing/d
   51769 /^Shifting/d
   51770 /^state/d
   51771 /^Cleanup:/d
   51772 /^Error:/d
   51773 /^Next/d
   51774 /^Discarding/d
   51775 / \$[0-9$]* = /d
   51776 /^yydestructor:/d' stderr >at-stderr
   51777 mv at-stderr stderr
   51778 # 2. Create the reference error message.
   51779 cat >expout <<'_ATEOF'
   51780 1.2: syntax error, unexpected number
   51781 _ATEOF
   51782 
   51783 # 3. If locations are not used, remove them.
   51784 
   51785 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   51786 
   51787 # 5. Check
   51788 $at_traceoff
   51789 echo "calc.at:651: cat stderr"
   51790 echo calc.at:651 >$at_check_line_file
   51791 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   51792 at_status=$?
   51793 grep '^ *+' $at_stder1 >&2
   51794 grep -v '^ *+' $at_stder1 >$at_stderr
   51795 at_failed=false
   51796 $at_diff $at_devnull $at_stderr || at_failed=:
   51797 $at_diff expout $at_stdout || at_failed=:
   51798 case $at_status in
   51799    77) echo 77 > $at_status_file
   51800             exit 77;;
   51801    0) ;;
   51802    *) echo "calc.at:651: exit code was $at_status, expected 0"
   51803       at_failed=:;;
   51804 esac
   51805 if $at_failed; then
   51806 
   51807   echo 1 > $at_status_file
   51808   exit 1
   51809 fi
   51810 
   51811 $at_traceon
   51812 
   51813 
   51814 cat >input <<'_ATEOF'
   51815 1//2
   51816 _ATEOF
   51817 
   51818 $at_traceoff
   51819 echo "calc.at:651: \$PREPARSER ./calc input"
   51820 echo calc.at:651 >$at_check_line_file
   51821 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   51822 at_status=$?
   51823 grep '^ *+' $at_stder1 >&2
   51824 grep -v '^ *+' $at_stder1 >$at_stderr
   51825 at_failed=false
   51826 echo stderr:; tee stderr <$at_stderr
   51827 $at_diff $at_devnull $at_stdout || at_failed=:
   51828 case $at_status in
   51829    77) echo 77 > $at_status_file
   51830             exit 77;;
   51831    1) ;;
   51832    *) echo "calc.at:651: exit code was $at_status, expected 1"
   51833       at_failed=:;;
   51834 esac
   51835 if $at_failed; then
   51836 
   51837   echo 1 > $at_status_file
   51838   exit 1
   51839 fi
   51840 
   51841 $at_traceon
   51842 
   51843 
   51844 # Normalize the observed and expected error messages, depending upon the
   51845 # options.
   51846 # 1. Remove the traces from observed.
   51847 sed '/^Starting/d
   51848 /^Entering/d
   51849 /^Stack/d
   51850 /^Reading/d
   51851 /^Reducing/d
   51852 /^Shifting/d
   51853 /^state/d
   51854 /^Cleanup:/d
   51855 /^Error:/d
   51856 /^Next/d
   51857 /^Discarding/d
   51858 / \$[0-9$]* = /d
   51859 /^yydestructor:/d' stderr >at-stderr
   51860 mv at-stderr stderr
   51861 # 2. Create the reference error message.
   51862 cat >expout <<'_ATEOF'
   51863 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   51864 _ATEOF
   51865 
   51866 # 3. If locations are not used, remove them.
   51867 
   51868 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   51869 
   51870 # 5. Check
   51871 $at_traceoff
   51872 echo "calc.at:651: cat stderr"
   51873 echo calc.at:651 >$at_check_line_file
   51874 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   51875 at_status=$?
   51876 grep '^ *+' $at_stder1 >&2
   51877 grep -v '^ *+' $at_stder1 >$at_stderr
   51878 at_failed=false
   51879 $at_diff $at_devnull $at_stderr || at_failed=:
   51880 $at_diff expout $at_stdout || at_failed=:
   51881 case $at_status in
   51882    77) echo 77 > $at_status_file
   51883             exit 77;;
   51884    0) ;;
   51885    *) echo "calc.at:651: exit code was $at_status, expected 0"
   51886       at_failed=:;;
   51887 esac
   51888 if $at_failed; then
   51889 
   51890   echo 1 > $at_status_file
   51891   exit 1
   51892 fi
   51893 
   51894 $at_traceon
   51895 
   51896 
   51897 cat >input <<'_ATEOF'
   51898 error
   51899 _ATEOF
   51900 
   51901 $at_traceoff
   51902 echo "calc.at:651: \$PREPARSER ./calc input"
   51903 echo calc.at:651 >$at_check_line_file
   51904 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   51905 at_status=$?
   51906 grep '^ *+' $at_stder1 >&2
   51907 grep -v '^ *+' $at_stder1 >$at_stderr
   51908 at_failed=false
   51909 echo stderr:; tee stderr <$at_stderr
   51910 $at_diff $at_devnull $at_stdout || at_failed=:
   51911 case $at_status in
   51912    77) echo 77 > $at_status_file
   51913             exit 77;;
   51914    1) ;;
   51915    *) echo "calc.at:651: exit code was $at_status, expected 1"
   51916       at_failed=:;;
   51917 esac
   51918 if $at_failed; then
   51919 
   51920   echo 1 > $at_status_file
   51921   exit 1
   51922 fi
   51923 
   51924 $at_traceon
   51925 
   51926 
   51927 # Normalize the observed and expected error messages, depending upon the
   51928 # options.
   51929 # 1. Remove the traces from observed.
   51930 sed '/^Starting/d
   51931 /^Entering/d
   51932 /^Stack/d
   51933 /^Reading/d
   51934 /^Reducing/d
   51935 /^Shifting/d
   51936 /^state/d
   51937 /^Cleanup:/d
   51938 /^Error:/d
   51939 /^Next/d
   51940 /^Discarding/d
   51941 / \$[0-9$]* = /d
   51942 /^yydestructor:/d' stderr >at-stderr
   51943 mv at-stderr stderr
   51944 # 2. Create the reference error message.
   51945 cat >expout <<'_ATEOF'
   51946 1.0: syntax error, unexpected $undefined
   51947 _ATEOF
   51948 
   51949 # 3. If locations are not used, remove them.
   51950 
   51951 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   51952 
   51953 # 5. Check
   51954 $at_traceoff
   51955 echo "calc.at:651: cat stderr"
   51956 echo calc.at:651 >$at_check_line_file
   51957 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   51958 at_status=$?
   51959 grep '^ *+' $at_stder1 >&2
   51960 grep -v '^ *+' $at_stder1 >$at_stderr
   51961 at_failed=false
   51962 $at_diff $at_devnull $at_stderr || at_failed=:
   51963 $at_diff expout $at_stdout || at_failed=:
   51964 case $at_status in
   51965    77) echo 77 > $at_status_file
   51966             exit 77;;
   51967    0) ;;
   51968    *) echo "calc.at:651: exit code was $at_status, expected 0"
   51969       at_failed=:;;
   51970 esac
   51971 if $at_failed; then
   51972 
   51973   echo 1 > $at_status_file
   51974   exit 1
   51975 fi
   51976 
   51977 $at_traceon
   51978 
   51979 
   51980 cat >input <<'_ATEOF'
   51981 1 = 2 = 3
   51982 _ATEOF
   51983 
   51984 $at_traceoff
   51985 echo "calc.at:651: \$PREPARSER ./calc input"
   51986 echo calc.at:651 >$at_check_line_file
   51987 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   51988 at_status=$?
   51989 grep '^ *+' $at_stder1 >&2
   51990 grep -v '^ *+' $at_stder1 >$at_stderr
   51991 at_failed=false
   51992 echo stderr:; tee stderr <$at_stderr
   51993 $at_diff $at_devnull $at_stdout || at_failed=:
   51994 case $at_status in
   51995    77) echo 77 > $at_status_file
   51996             exit 77;;
   51997    1) ;;
   51998    *) echo "calc.at:651: exit code was $at_status, expected 1"
   51999       at_failed=:;;
   52000 esac
   52001 if $at_failed; then
   52002 
   52003   echo 1 > $at_status_file
   52004   exit 1
   52005 fi
   52006 
   52007 $at_traceon
   52008 
   52009 
   52010 # Normalize the observed and expected error messages, depending upon the
   52011 # options.
   52012 # 1. Remove the traces from observed.
   52013 sed '/^Starting/d
   52014 /^Entering/d
   52015 /^Stack/d
   52016 /^Reading/d
   52017 /^Reducing/d
   52018 /^Shifting/d
   52019 /^state/d
   52020 /^Cleanup:/d
   52021 /^Error:/d
   52022 /^Next/d
   52023 /^Discarding/d
   52024 / \$[0-9$]* = /d
   52025 /^yydestructor:/d' stderr >at-stderr
   52026 mv at-stderr stderr
   52027 # 2. Create the reference error message.
   52028 cat >expout <<'_ATEOF'
   52029 1.6: syntax error, unexpected '='
   52030 _ATEOF
   52031 
   52032 # 3. If locations are not used, remove them.
   52033 
   52034 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   52035 
   52036 # 5. Check
   52037 $at_traceoff
   52038 echo "calc.at:651: cat stderr"
   52039 echo calc.at:651 >$at_check_line_file
   52040 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   52041 at_status=$?
   52042 grep '^ *+' $at_stder1 >&2
   52043 grep -v '^ *+' $at_stder1 >$at_stderr
   52044 at_failed=false
   52045 $at_diff $at_devnull $at_stderr || at_failed=:
   52046 $at_diff expout $at_stdout || at_failed=:
   52047 case $at_status in
   52048    77) echo 77 > $at_status_file
   52049             exit 77;;
   52050    0) ;;
   52051    *) echo "calc.at:651: exit code was $at_status, expected 0"
   52052       at_failed=:;;
   52053 esac
   52054 if $at_failed; then
   52055 
   52056   echo 1 > $at_status_file
   52057   exit 1
   52058 fi
   52059 
   52060 $at_traceon
   52061 
   52062 
   52063 cat >input <<'_ATEOF'
   52064 
   52065 +1
   52066 _ATEOF
   52067 
   52068 $at_traceoff
   52069 echo "calc.at:651: \$PREPARSER ./calc input"
   52070 echo calc.at:651 >$at_check_line_file
   52071 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   52072 at_status=$?
   52073 grep '^ *+' $at_stder1 >&2
   52074 grep -v '^ *+' $at_stder1 >$at_stderr
   52075 at_failed=false
   52076 echo stderr:; tee stderr <$at_stderr
   52077 $at_diff $at_devnull $at_stdout || at_failed=:
   52078 case $at_status in
   52079    77) echo 77 > $at_status_file
   52080             exit 77;;
   52081    1) ;;
   52082    *) echo "calc.at:651: exit code was $at_status, expected 1"
   52083       at_failed=:;;
   52084 esac
   52085 if $at_failed; then
   52086 
   52087   echo 1 > $at_status_file
   52088   exit 1
   52089 fi
   52090 
   52091 $at_traceon
   52092 
   52093 
   52094 # Normalize the observed and expected error messages, depending upon the
   52095 # options.
   52096 # 1. Remove the traces from observed.
   52097 sed '/^Starting/d
   52098 /^Entering/d
   52099 /^Stack/d
   52100 /^Reading/d
   52101 /^Reducing/d
   52102 /^Shifting/d
   52103 /^state/d
   52104 /^Cleanup:/d
   52105 /^Error:/d
   52106 /^Next/d
   52107 /^Discarding/d
   52108 / \$[0-9$]* = /d
   52109 /^yydestructor:/d' stderr >at-stderr
   52110 mv at-stderr stderr
   52111 # 2. Create the reference error message.
   52112 cat >expout <<'_ATEOF'
   52113 2.0: syntax error, unexpected '+'
   52114 _ATEOF
   52115 
   52116 # 3. If locations are not used, remove them.
   52117 
   52118 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   52119 
   52120 # 5. Check
   52121 $at_traceoff
   52122 echo "calc.at:651: cat stderr"
   52123 echo calc.at:651 >$at_check_line_file
   52124 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   52125 at_status=$?
   52126 grep '^ *+' $at_stder1 >&2
   52127 grep -v '^ *+' $at_stder1 >$at_stderr
   52128 at_failed=false
   52129 $at_diff $at_devnull $at_stderr || at_failed=:
   52130 $at_diff expout $at_stdout || at_failed=:
   52131 case $at_status in
   52132    77) echo 77 > $at_status_file
   52133             exit 77;;
   52134    0) ;;
   52135    *) echo "calc.at:651: exit code was $at_status, expected 0"
   52136       at_failed=:;;
   52137 esac
   52138 if $at_failed; then
   52139 
   52140   echo 1 > $at_status_file
   52141   exit 1
   52142 fi
   52143 
   52144 $at_traceon
   52145 
   52146 
   52147 # Exercise error messages with EOF: work on an empty file.
   52148 $at_traceoff
   52149 echo "calc.at:651: \$PREPARSER ./calc /dev/null"
   52150 echo calc.at:651 >$at_check_line_file
   52151 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   52152 at_status=$?
   52153 grep '^ *+' $at_stder1 >&2
   52154 grep -v '^ *+' $at_stder1 >$at_stderr
   52155 at_failed=false
   52156 echo stderr:; tee stderr <$at_stderr
   52157 $at_diff $at_devnull $at_stdout || at_failed=:
   52158 case $at_status in
   52159    77) echo 77 > $at_status_file
   52160             exit 77;;
   52161    1) ;;
   52162    *) echo "calc.at:651: exit code was $at_status, expected 1"
   52163       at_failed=:;;
   52164 esac
   52165 if $at_failed; then
   52166 
   52167   echo 1 > $at_status_file
   52168   exit 1
   52169 fi
   52170 
   52171 $at_traceon
   52172 
   52173 
   52174 # Normalize the observed and expected error messages, depending upon the
   52175 # options.
   52176 # 1. Remove the traces from observed.
   52177 sed '/^Starting/d
   52178 /^Entering/d
   52179 /^Stack/d
   52180 /^Reading/d
   52181 /^Reducing/d
   52182 /^Shifting/d
   52183 /^state/d
   52184 /^Cleanup:/d
   52185 /^Error:/d
   52186 /^Next/d
   52187 /^Discarding/d
   52188 / \$[0-9$]* = /d
   52189 /^yydestructor:/d' stderr >at-stderr
   52190 mv at-stderr stderr
   52191 # 2. Create the reference error message.
   52192 cat >expout <<'_ATEOF'
   52193 1.0: syntax error, unexpected end of input
   52194 _ATEOF
   52195 
   52196 # 3. If locations are not used, remove them.
   52197 
   52198 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   52199 
   52200 # 5. Check
   52201 $at_traceoff
   52202 echo "calc.at:651: cat stderr"
   52203 echo calc.at:651 >$at_check_line_file
   52204 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   52205 at_status=$?
   52206 grep '^ *+' $at_stder1 >&2
   52207 grep -v '^ *+' $at_stder1 >$at_stderr
   52208 at_failed=false
   52209 $at_diff $at_devnull $at_stderr || at_failed=:
   52210 $at_diff expout $at_stdout || at_failed=:
   52211 case $at_status in
   52212    77) echo 77 > $at_status_file
   52213             exit 77;;
   52214    0) ;;
   52215    *) echo "calc.at:651: exit code was $at_status, expected 0"
   52216       at_failed=:;;
   52217 esac
   52218 if $at_failed; then
   52219 
   52220   echo 1 > $at_status_file
   52221   exit 1
   52222 fi
   52223 
   52224 $at_traceon
   52225 
   52226 
   52227 
   52228 # Exercise the error token: without it, we die at the first error,
   52229 # hence be sure to
   52230 #
   52231 # - have several errors which exercise different shift/discardings
   52232 #   - (): nothing to pop, nothing to discard
   52233 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   52234 #   - (* * *): nothing to pop, a lot to discard
   52235 #   - (1 + 2 * *): some to pop and discard
   52236 #
   52237 # - test the action associated to `error'
   52238 #
   52239 # - check the look-ahead that triggers an error is not discarded
   52240 #   when we enter error recovery.  Below, the look-ahead causing the
   52241 #   first error is ")", which is needed to recover from the error and
   52242 #   produce the "0" that triggers the "0 != 1" error.
   52243 #
   52244 cat >input <<'_ATEOF'
   52245 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   52246 _ATEOF
   52247 
   52248 $at_traceoff
   52249 echo "calc.at:651: \$PREPARSER ./calc input"
   52250 echo calc.at:651 >$at_check_line_file
   52251 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   52252 at_status=$?
   52253 grep '^ *+' $at_stder1 >&2
   52254 grep -v '^ *+' $at_stder1 >$at_stderr
   52255 at_failed=false
   52256 echo stderr:; tee stderr <$at_stderr
   52257 $at_diff $at_devnull $at_stdout || at_failed=:
   52258 case $at_status in
   52259    77) echo 77 > $at_status_file
   52260             exit 77;;
   52261    0) ;;
   52262    *) echo "calc.at:651: exit code was $at_status, expected 0"
   52263       at_failed=:;;
   52264 esac
   52265 if $at_failed; then
   52266 
   52267   echo 1 > $at_status_file
   52268   exit 1
   52269 fi
   52270 
   52271 $at_traceon
   52272 
   52273 
   52274 # Normalize the observed and expected error messages, depending upon the
   52275 # options.
   52276 # 1. Remove the traces from observed.
   52277 sed '/^Starting/d
   52278 /^Entering/d
   52279 /^Stack/d
   52280 /^Reading/d
   52281 /^Reducing/d
   52282 /^Shifting/d
   52283 /^state/d
   52284 /^Cleanup:/d
   52285 /^Error:/d
   52286 /^Next/d
   52287 /^Discarding/d
   52288 / \$[0-9$]* = /d
   52289 /^yydestructor:/d' stderr >at-stderr
   52290 mv at-stderr stderr
   52291 # 2. Create the reference error message.
   52292 cat >expout <<'_ATEOF'
   52293 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   52294 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   52295 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   52296 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   52297 calc: error: 4444 != 1
   52298 _ATEOF
   52299 
   52300 # 3. If locations are not used, remove them.
   52301 
   52302 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   52303 
   52304 # 5. Check
   52305 $at_traceoff
   52306 echo "calc.at:651: cat stderr"
   52307 echo calc.at:651 >$at_check_line_file
   52308 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   52309 at_status=$?
   52310 grep '^ *+' $at_stder1 >&2
   52311 grep -v '^ *+' $at_stder1 >$at_stderr
   52312 at_failed=false
   52313 $at_diff $at_devnull $at_stderr || at_failed=:
   52314 $at_diff expout $at_stdout || at_failed=:
   52315 case $at_status in
   52316    77) echo 77 > $at_status_file
   52317             exit 77;;
   52318    0) ;;
   52319    *) echo "calc.at:651: exit code was $at_status, expected 0"
   52320       at_failed=:;;
   52321 esac
   52322 if $at_failed; then
   52323 
   52324   echo 1 > $at_status_file
   52325   exit 1
   52326 fi
   52327 
   52328 $at_traceon
   52329 
   52330 
   52331 
   52332 # The same, but this time exercising explicitly triggered syntax errors.
   52333 # POSIX says the look-ahead causing the error should not be discarded.
   52334 cat >input <<'_ATEOF'
   52335 (!) + (0 0) = 1
   52336 _ATEOF
   52337 
   52338 $at_traceoff
   52339 echo "calc.at:651: \$PREPARSER ./calc input"
   52340 echo calc.at:651 >$at_check_line_file
   52341 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   52342 at_status=$?
   52343 grep '^ *+' $at_stder1 >&2
   52344 grep -v '^ *+' $at_stder1 >$at_stderr
   52345 at_failed=false
   52346 echo stderr:; tee stderr <$at_stderr
   52347 $at_diff $at_devnull $at_stdout || at_failed=:
   52348 case $at_status in
   52349    77) echo 77 > $at_status_file
   52350             exit 77;;
   52351    0) ;;
   52352    *) echo "calc.at:651: exit code was $at_status, expected 0"
   52353       at_failed=:;;
   52354 esac
   52355 if $at_failed; then
   52356 
   52357   echo 1 > $at_status_file
   52358   exit 1
   52359 fi
   52360 
   52361 $at_traceon
   52362 
   52363 
   52364 # Normalize the observed and expected error messages, depending upon the
   52365 # options.
   52366 # 1. Remove the traces from observed.
   52367 sed '/^Starting/d
   52368 /^Entering/d
   52369 /^Stack/d
   52370 /^Reading/d
   52371 /^Reducing/d
   52372 /^Shifting/d
   52373 /^state/d
   52374 /^Cleanup:/d
   52375 /^Error:/d
   52376 /^Next/d
   52377 /^Discarding/d
   52378 / \$[0-9$]* = /d
   52379 /^yydestructor:/d' stderr >at-stderr
   52380 mv at-stderr stderr
   52381 # 2. Create the reference error message.
   52382 cat >expout <<'_ATEOF'
   52383 1.9: syntax error, unexpected number
   52384 calc: error: 2222 != 1
   52385 _ATEOF
   52386 
   52387 # 3. If locations are not used, remove them.
   52388 
   52389 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   52390 
   52391 # 5. Check
   52392 $at_traceoff
   52393 echo "calc.at:651: cat stderr"
   52394 echo calc.at:651 >$at_check_line_file
   52395 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   52396 at_status=$?
   52397 grep '^ *+' $at_stder1 >&2
   52398 grep -v '^ *+' $at_stder1 >$at_stderr
   52399 at_failed=false
   52400 $at_diff $at_devnull $at_stderr || at_failed=:
   52401 $at_diff expout $at_stdout || at_failed=:
   52402 case $at_status in
   52403    77) echo 77 > $at_status_file
   52404             exit 77;;
   52405    0) ;;
   52406    *) echo "calc.at:651: exit code was $at_status, expected 0"
   52407       at_failed=:;;
   52408 esac
   52409 if $at_failed; then
   52410 
   52411   echo 1 > $at_status_file
   52412   exit 1
   52413 fi
   52414 
   52415 $at_traceon
   52416 
   52417 
   52418 cat >input <<'_ATEOF'
   52419 (- *) + (0 0) = 1
   52420 _ATEOF
   52421 
   52422 $at_traceoff
   52423 echo "calc.at:651: \$PREPARSER ./calc input"
   52424 echo calc.at:651 >$at_check_line_file
   52425 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   52426 at_status=$?
   52427 grep '^ *+' $at_stder1 >&2
   52428 grep -v '^ *+' $at_stder1 >$at_stderr
   52429 at_failed=false
   52430 echo stderr:; tee stderr <$at_stderr
   52431 $at_diff $at_devnull $at_stdout || at_failed=:
   52432 case $at_status in
   52433    77) echo 77 > $at_status_file
   52434             exit 77;;
   52435    0) ;;
   52436    *) echo "calc.at:651: exit code was $at_status, expected 0"
   52437       at_failed=:;;
   52438 esac
   52439 if $at_failed; then
   52440 
   52441   echo 1 > $at_status_file
   52442   exit 1
   52443 fi
   52444 
   52445 $at_traceon
   52446 
   52447 
   52448 # Normalize the observed and expected error messages, depending upon the
   52449 # options.
   52450 # 1. Remove the traces from observed.
   52451 sed '/^Starting/d
   52452 /^Entering/d
   52453 /^Stack/d
   52454 /^Reading/d
   52455 /^Reducing/d
   52456 /^Shifting/d
   52457 /^state/d
   52458 /^Cleanup:/d
   52459 /^Error:/d
   52460 /^Next/d
   52461 /^Discarding/d
   52462 / \$[0-9$]* = /d
   52463 /^yydestructor:/d' stderr >at-stderr
   52464 mv at-stderr stderr
   52465 # 2. Create the reference error message.
   52466 cat >expout <<'_ATEOF'
   52467 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   52468 1.11: syntax error, unexpected number
   52469 calc: error: 2222 != 1
   52470 _ATEOF
   52471 
   52472 # 3. If locations are not used, remove them.
   52473 
   52474 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   52475 
   52476 # 5. Check
   52477 $at_traceoff
   52478 echo "calc.at:651: cat stderr"
   52479 echo calc.at:651 >$at_check_line_file
   52480 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   52481 at_status=$?
   52482 grep '^ *+' $at_stder1 >&2
   52483 grep -v '^ *+' $at_stder1 >$at_stderr
   52484 at_failed=false
   52485 $at_diff $at_devnull $at_stderr || at_failed=:
   52486 $at_diff expout $at_stdout || at_failed=:
   52487 case $at_status in
   52488    77) echo 77 > $at_status_file
   52489             exit 77;;
   52490    0) ;;
   52491    *) echo "calc.at:651: exit code was $at_status, expected 0"
   52492       at_failed=:;;
   52493 esac
   52494 if $at_failed; then
   52495 
   52496   echo 1 > $at_status_file
   52497   exit 1
   52498 fi
   52499 
   52500 $at_traceon
   52501 
   52502 
   52503 
   52504 
   52505 
   52506 
   52507 
   52508 
   52509 
   52510 
   52511 
   52512 
   52513 
   52514 
   52515 
   52516 
   52517 
   52518 
   52519 
   52520 
   52521 
   52522 
   52523 
   52524 
   52525       $at_traceoff
   52526       $at_times_p && times >$at_times_file
   52527     ) 5>&1 2>&1 | eval $at_tee_pipe
   52528     at_status=`cat $at_status_file`
   52529     ;;
   52530 
   52531   104 ) # 104. calc.at:653: Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}
   52532     at_setup_line='calc.at:653'
   52533     at_desc='Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}'
   52534     $at_quiet $ECHO_N "104: Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}$ECHO_C"
   52535     at_xfail=no
   52536     (
   52537       echo "104. calc.at:653: testing ..."
   52538       $at_traceon
   52539 
   52540 
   52541 
   52542 
   52543 
   52544 
   52545 
   52546 
   52547 # Using yacc.c?
   52548 
   52549 
   52550 
   52551 
   52552 
   52553 
   52554 
   52555 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   52556 
   52557 # yyerror always sees the locations (when activated), except if
   52558 # yacc & pure & !param.
   52559 
   52560 
   52561 # The interface is pure: either because %pure-parser, or because we
   52562 # are using the C++ parsers.
   52563 
   52564 
   52565 
   52566 
   52567 
   52568 
   52569 
   52570 
   52571 
   52572 
   52573 
   52574 
   52575 cat >calc.y <<'_ATEOF'
   52576 %{
   52577 #ifdef HAVE_CONFIG_H
   52578 # include <config.h>
   52579   /* We don't need perfect functions for these tests. */
   52580 # undef malloc
   52581 # undef memcmp
   52582 # undef realloc
   52583 #endif
   52584 %}
   52585 
   52586 /* Infix notation calculator--calc */
   52587 %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}
   52588 %define "global_tokens_and_yystype"
   52589 %{
   52590 #include <stdio.h>
   52591 
   52592 #include <stdlib.h>
   52593 #include <string.h>
   52594 #if HAVE_UNISTD_H
   52595 # include <unistd.h>
   52596 #else
   52597 # undef alarm
   52598 # define alarm(seconds) /* empty */
   52599 #endif
   52600 #include <ctype.h>
   52601 #define USE(Var)
   52602 
   52603 /* Exercise pre-prologue dependency to %union.  */
   52604 typedef int semantic_value;
   52605 
   52606 static semantic_value global_result = 0;
   52607 static int global_count = 0;
   52608 %}
   52609 
   52610 /* Exercise %union. */
   52611 %union
   52612 {
   52613   semantic_value ival;
   52614 };
   52615 
   52616 %{
   52617 static int power (int base, int exponent);
   52618 #ifndef YYLTYPE
   52619 # define YYLTYPE calc::location
   52620 #endif
   52621 #define first_line   begin.line
   52622 #define first_column begin.column
   52623 #define last_line    end.line
   52624 #define last_column  end.column
   52625 
   52626 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   52627 static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
   52628 static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c);
   52629 %}
   52630 
   52631 /* The lalr1.cc skeleton, for backward compatibility, defines
   52632    a constructor for position that initializes the filename.  The
   52633    glr.cc skeleton does not (and in fact cannot: location/position
   52634    are stored in a union, from which objects with constructors are
   52635    excluded in C++. */
   52636 %initial-action {
   52637   @$.initialize (0);
   52638 }
   52639 
   52640 
   52641 /* Bison Declarations */
   52642 %token CALC_EOF 0 "end of input"
   52643 %token <ival> NUM "number"
   52644 %type  <ival> exp
   52645 
   52646 %nonassoc '=' /* comparison	       */
   52647 %left '-' '+'
   52648 %left '*' '/'
   52649 %left NEG     /* negation--unary minus */
   52650 %right '^'    /* exponentiation        */
   52651 
   52652 /* Grammar follows */
   52653 %%
   52654 input:
   52655   line
   52656 | input line         { ++*count; ++global_count; }
   52657 ;
   52658 
   52659 line:
   52660   '\n'
   52661 | exp '\n'           { *result = global_result = $1; }
   52662 ;
   52663 
   52664 exp:
   52665   NUM                { $$ = $1;             }
   52666 | exp '=' exp
   52667   {
   52668     if ($1 != $3)
   52669       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   52670     $$ = $1;
   52671   }
   52672 | exp '+' exp        { $$ = $1 + $3;        }
   52673 | exp '-' exp        { $$ = $1 - $3;        }
   52674 | exp '*' exp        { $$ = $1 * $3;        }
   52675 | exp '/' exp        { $$ = $1 / $3;        }
   52676 | '-' exp  %prec NEG { $$ = -$2;            }
   52677 | exp '^' exp        { $$ = power ($1, $3); }
   52678 | '(' exp ')'        { $$ = $2;             }
   52679 | '(' error ')'      { $$ = 1111;           }
   52680 | '!'                { $$ = 0; YYERROR;     }
   52681 | '-' error          { $$ = 0; YYERROR;     }
   52682 ;
   52683 %%
   52684 /* The input.  */
   52685 static FILE *input;
   52686 
   52687 /* A C++ error reporting function.  */
   52688 void
   52689 calc::parser::error (const location& l, const std::string& m)
   52690 {
   52691   (void) l;
   52692   std::cerr << l << ": " << m << std::endl;
   52693 }
   52694 
   52695 int
   52696 yyparse (semantic_value *result, int *count)
   52697 {
   52698   calc::parser parser (result, count);
   52699   parser.set_debug_level (!!YYDEBUG);
   52700   return parser.parse ();
   52701 }
   52702 
   52703 
   52704 
   52705 
   52706 static YYLTYPE last_yylloc;
   52707 
   52708 static int
   52709 get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
   52710 {
   52711   int res = getc (input);
   52712   (void) lvalp;(void) llocp;
   52713 
   52714   last_yylloc = (*llocp);
   52715   if (res == '\n')
   52716     {
   52717       (*llocp).last_line++;
   52718       (*llocp).last_column = 0;
   52719     }
   52720   else
   52721     (*llocp).last_column++;
   52722 
   52723   return res;
   52724 }
   52725 
   52726 
   52727 static void
   52728 unget_char (YYSTYPE *lvalp, YYLTYPE *llocp,  int c)
   52729 {
   52730   (void) lvalp;(void) llocp;
   52731 
   52732   /* Wrong when C == `\n'. */
   52733   (*llocp) = last_yylloc;
   52734 
   52735   ungetc (c, input);
   52736 }
   52737 
   52738 static int
   52739 read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
   52740 {
   52741   int c = get_char (lvalp, llocp);
   52742   int sign = 1;
   52743   int n = 0;
   52744 
   52745   (void) lvalp;(void) llocp;
   52746   if (c == '-')
   52747     {
   52748       c = get_char (lvalp, llocp);
   52749       sign = -1;
   52750     }
   52751 
   52752   while (isdigit (c))
   52753     {
   52754       n = 10 * n + (c - '0');
   52755       c = get_char (lvalp, llocp);
   52756     }
   52757 
   52758   unget_char (lvalp, llocp,  c);
   52759 
   52760   return sign * n;
   52761 }
   52762 
   52763 
   52764 
   52765 /*---------------------------------------------------------------.
   52766 | Lexical analyzer returns an integer on the stack and the token |
   52767 | NUM, or the ASCII character read if not a number.  Skips all   |
   52768 | blanks and tabs, returns 0 for EOF.                            |
   52769 `---------------------------------------------------------------*/
   52770 
   52771 static int
   52772 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   52773 {
   52774   static int init = 1;
   52775   int c;
   52776 
   52777   if (init)
   52778     {
   52779       init = 0;
   52780 
   52781       (*llocp).last_column = 0;
   52782       (*llocp).last_line = 1;
   52783 
   52784     }
   52785 
   52786 
   52787  (*llocp).first_column = (*llocp).last_column;
   52788   (*llocp).first_line   = (*llocp).last_line;
   52789 
   52790 
   52791   /* Skip white space.  */
   52792   while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
   52793     {
   52794      (*llocp).first_column = (*llocp).last_column;
   52795       (*llocp).first_line   = (*llocp).last_line;
   52796 
   52797     }
   52798 
   52799   /* process numbers   */
   52800   if (c == '.' || isdigit (c))
   52801     {
   52802       unget_char (lvalp, llocp,  c);
   52803       (*lvalp).ival = read_signed_integer (lvalp, llocp);
   52804       return NUM;
   52805     }
   52806 
   52807   /* Return end-of-file.  */
   52808   if (c == EOF)
   52809     return CALC_EOF;
   52810 
   52811   /* Return single chars. */
   52812   return c;
   52813 }
   52814 
   52815 static int
   52816 power (int base, int exponent)
   52817 {
   52818   int res = 1;
   52819   if (exponent < 0)
   52820     exit (3);
   52821   for (/* Niente */; exponent; --exponent)
   52822     res *= base;
   52823   return res;
   52824 }
   52825 
   52826 
   52827 int
   52828 main (int argc, const char **argv)
   52829 {
   52830   semantic_value result = 0;
   52831   int count = 0;
   52832   int status;
   52833 
   52834   /* This used to be alarm (10), but that isn't enough time for
   52835      a July 1995 vintage DEC Alphastation 200 4/100 system,
   52836      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   52837   alarm (100);
   52838 
   52839   if (argc == 2)
   52840     input = fopen (argv[1], "r");
   52841   else
   52842     input = stdin;
   52843 
   52844   if (!input)
   52845     {
   52846       perror (argv[1]);
   52847       return 3;
   52848     }
   52849 
   52850 
   52851   status = yyparse (&result, &count);
   52852   if (global_result != result)
   52853     abort ();
   52854   if (global_count != count)
   52855     abort ();
   52856   return status;
   52857 }
   52858 _ATEOF
   52859 
   52860 
   52861 
   52862 
   52863 
   52864 $at_traceoff
   52865 echo "calc.at:653: bison -o calc.cc calc.y"
   52866 echo calc.at:653 >$at_check_line_file
   52867 ( $at_traceon; bison -o calc.cc calc.y ) >$at_stdout 2>$at_stder1
   52868 at_status=$?
   52869 grep '^ *+' $at_stder1 >&2
   52870 grep -v '^ *+' $at_stder1 >$at_stderr
   52871 at_failed=false
   52872 $at_diff $at_devnull $at_stderr || at_failed=:
   52873 $at_diff $at_devnull $at_stdout || at_failed=:
   52874 case $at_status in
   52875    77) echo 77 > $at_status_file
   52876             exit 77;;
   52877    0) ;;
   52878    *) echo "calc.at:653: exit code was $at_status, expected 0"
   52879       at_failed=:;;
   52880 esac
   52881 if $at_failed; then
   52882 
   52883   echo 1 > $at_status_file
   52884   exit 1
   52885 fi
   52886 
   52887 $at_traceon
   52888 
   52889 
   52890 $at_traceoff
   52891 echo "calc.at:653: \$BISON_CXX_WORKS"
   52892 echo calc.at:653 >$at_check_line_file
   52893 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   52894 at_status=$?
   52895 grep '^ *+' $at_stder1 >&2
   52896 grep -v '^ *+' $at_stder1 >$at_stderr
   52897 at_failed=false
   52898 echo stderr:; cat $at_stderr
   52899 echo stdout:; cat $at_stdout
   52900 case $at_status in
   52901    77) echo 77 > $at_status_file
   52902             exit 77;;
   52903    0) ;;
   52904    *) echo "calc.at:653: exit code was $at_status, expected 0"
   52905       at_failed=:;;
   52906 esac
   52907 if $at_failed; then
   52908 
   52909   echo 1 > $at_status_file
   52910   exit 1
   52911 fi
   52912 
   52913 $at_traceon
   52914 
   52915 $at_traceoff
   52916 echo "calc.at:653: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.cc \$LIBS"
   52917 echo calc.at:653 >$at_check_line_file
   52918 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o calc calc.cc $LIBS ) >$at_stdout 2>$at_stder1
   52919 at_status=$?
   52920 grep '^ *+' $at_stder1 >&2
   52921 grep -v '^ *+' $at_stder1 >$at_stderr
   52922 at_failed=false
   52923 echo stderr:; cat $at_stderr
   52924 echo stdout:; cat $at_stdout
   52925 case $at_status in
   52926    77) echo 77 > $at_status_file
   52927             exit 77;;
   52928    0) ;;
   52929    *) echo "calc.at:653: exit code was $at_status, expected 0"
   52930       at_failed=:;;
   52931 esac
   52932 if $at_failed; then
   52933 
   52934   echo 1 > $at_status_file
   52935   exit 1
   52936 fi
   52937 
   52938 $at_traceon
   52939 
   52940 
   52941 # Test the priorities.
   52942 cat >input <<'_ATEOF'
   52943 1 + 2 * 3 = 7
   52944 1 + 2 * -3 = -5
   52945 
   52946 -1^2 = -1
   52947 (-1)^2 = 1
   52948 
   52949 ---1 = -1
   52950 
   52951 1 - 2 - 3 = -4
   52952 1 - (2 - 3) = 2
   52953 
   52954 2^2^3 = 256
   52955 (2^2)^3 = 64
   52956 _ATEOF
   52957 
   52958 $at_traceoff
   52959 echo "calc.at:653: \$PREPARSER ./calc input"
   52960 echo calc.at:653 >$at_check_line_file
   52961 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   52962 at_status=$?
   52963 grep '^ *+' $at_stder1 >&2
   52964 grep -v '^ *+' $at_stder1 >$at_stderr
   52965 at_failed=false
   52966 echo stderr:; tee stderr <$at_stderr
   52967 $at_diff $at_devnull $at_stdout || at_failed=:
   52968 case $at_status in
   52969    77) echo 77 > $at_status_file
   52970             exit 77;;
   52971    0) ;;
   52972    *) echo "calc.at:653: exit code was $at_status, expected 0"
   52973       at_failed=:;;
   52974 esac
   52975 if $at_failed; then
   52976 
   52977   echo 1 > $at_status_file
   52978   exit 1
   52979 fi
   52980 
   52981 $at_traceon
   52982 
   52983 
   52984 
   52985 # Some syntax errors.
   52986 cat >input <<'_ATEOF'
   52987 0 0
   52988 _ATEOF
   52989 
   52990 $at_traceoff
   52991 echo "calc.at:653: \$PREPARSER ./calc input"
   52992 echo calc.at:653 >$at_check_line_file
   52993 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   52994 at_status=$?
   52995 grep '^ *+' $at_stder1 >&2
   52996 grep -v '^ *+' $at_stder1 >$at_stderr
   52997 at_failed=false
   52998 echo stderr:; tee stderr <$at_stderr
   52999 $at_diff $at_devnull $at_stdout || at_failed=:
   53000 case $at_status in
   53001    77) echo 77 > $at_status_file
   53002             exit 77;;
   53003    1) ;;
   53004    *) echo "calc.at:653: exit code was $at_status, expected 1"
   53005       at_failed=:;;
   53006 esac
   53007 if $at_failed; then
   53008 
   53009   echo 1 > $at_status_file
   53010   exit 1
   53011 fi
   53012 
   53013 $at_traceon
   53014 
   53015 
   53016 # Normalize the observed and expected error messages, depending upon the
   53017 # options.
   53018 # 1. Remove the traces from observed.
   53019 sed '/^Starting/d
   53020 /^Entering/d
   53021 /^Stack/d
   53022 /^Reading/d
   53023 /^Reducing/d
   53024 /^Shifting/d
   53025 /^state/d
   53026 /^Cleanup:/d
   53027 /^Error:/d
   53028 /^Next/d
   53029 /^Discarding/d
   53030 / \$[0-9$]* = /d
   53031 /^yydestructor:/d' stderr >at-stderr
   53032 mv at-stderr stderr
   53033 # 2. Create the reference error message.
   53034 cat >expout <<'_ATEOF'
   53035 1.2: syntax error, unexpected number
   53036 _ATEOF
   53037 
   53038 # 3. If locations are not used, remove them.
   53039 
   53040 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   53041 
   53042 # 5. Check
   53043 $at_traceoff
   53044 echo "calc.at:653: cat stderr"
   53045 echo calc.at:653 >$at_check_line_file
   53046 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   53047 at_status=$?
   53048 grep '^ *+' $at_stder1 >&2
   53049 grep -v '^ *+' $at_stder1 >$at_stderr
   53050 at_failed=false
   53051 $at_diff $at_devnull $at_stderr || at_failed=:
   53052 $at_diff expout $at_stdout || at_failed=:
   53053 case $at_status in
   53054    77) echo 77 > $at_status_file
   53055             exit 77;;
   53056    0) ;;
   53057    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53058       at_failed=:;;
   53059 esac
   53060 if $at_failed; then
   53061 
   53062   echo 1 > $at_status_file
   53063   exit 1
   53064 fi
   53065 
   53066 $at_traceon
   53067 
   53068 
   53069 cat >input <<'_ATEOF'
   53070 1//2
   53071 _ATEOF
   53072 
   53073 $at_traceoff
   53074 echo "calc.at:653: \$PREPARSER ./calc input"
   53075 echo calc.at:653 >$at_check_line_file
   53076 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   53077 at_status=$?
   53078 grep '^ *+' $at_stder1 >&2
   53079 grep -v '^ *+' $at_stder1 >$at_stderr
   53080 at_failed=false
   53081 echo stderr:; tee stderr <$at_stderr
   53082 $at_diff $at_devnull $at_stdout || at_failed=:
   53083 case $at_status in
   53084    77) echo 77 > $at_status_file
   53085             exit 77;;
   53086    1) ;;
   53087    *) echo "calc.at:653: exit code was $at_status, expected 1"
   53088       at_failed=:;;
   53089 esac
   53090 if $at_failed; then
   53091 
   53092   echo 1 > $at_status_file
   53093   exit 1
   53094 fi
   53095 
   53096 $at_traceon
   53097 
   53098 
   53099 # Normalize the observed and expected error messages, depending upon the
   53100 # options.
   53101 # 1. Remove the traces from observed.
   53102 sed '/^Starting/d
   53103 /^Entering/d
   53104 /^Stack/d
   53105 /^Reading/d
   53106 /^Reducing/d
   53107 /^Shifting/d
   53108 /^state/d
   53109 /^Cleanup:/d
   53110 /^Error:/d
   53111 /^Next/d
   53112 /^Discarding/d
   53113 / \$[0-9$]* = /d
   53114 /^yydestructor:/d' stderr >at-stderr
   53115 mv at-stderr stderr
   53116 # 2. Create the reference error message.
   53117 cat >expout <<'_ATEOF'
   53118 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   53119 _ATEOF
   53120 
   53121 # 3. If locations are not used, remove them.
   53122 
   53123 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   53124 
   53125 # 5. Check
   53126 $at_traceoff
   53127 echo "calc.at:653: cat stderr"
   53128 echo calc.at:653 >$at_check_line_file
   53129 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   53130 at_status=$?
   53131 grep '^ *+' $at_stder1 >&2
   53132 grep -v '^ *+' $at_stder1 >$at_stderr
   53133 at_failed=false
   53134 $at_diff $at_devnull $at_stderr || at_failed=:
   53135 $at_diff expout $at_stdout || at_failed=:
   53136 case $at_status in
   53137    77) echo 77 > $at_status_file
   53138             exit 77;;
   53139    0) ;;
   53140    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53141       at_failed=:;;
   53142 esac
   53143 if $at_failed; then
   53144 
   53145   echo 1 > $at_status_file
   53146   exit 1
   53147 fi
   53148 
   53149 $at_traceon
   53150 
   53151 
   53152 cat >input <<'_ATEOF'
   53153 error
   53154 _ATEOF
   53155 
   53156 $at_traceoff
   53157 echo "calc.at:653: \$PREPARSER ./calc input"
   53158 echo calc.at:653 >$at_check_line_file
   53159 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   53160 at_status=$?
   53161 grep '^ *+' $at_stder1 >&2
   53162 grep -v '^ *+' $at_stder1 >$at_stderr
   53163 at_failed=false
   53164 echo stderr:; tee stderr <$at_stderr
   53165 $at_diff $at_devnull $at_stdout || at_failed=:
   53166 case $at_status in
   53167    77) echo 77 > $at_status_file
   53168             exit 77;;
   53169    1) ;;
   53170    *) echo "calc.at:653: exit code was $at_status, expected 1"
   53171       at_failed=:;;
   53172 esac
   53173 if $at_failed; then
   53174 
   53175   echo 1 > $at_status_file
   53176   exit 1
   53177 fi
   53178 
   53179 $at_traceon
   53180 
   53181 
   53182 # Normalize the observed and expected error messages, depending upon the
   53183 # options.
   53184 # 1. Remove the traces from observed.
   53185 sed '/^Starting/d
   53186 /^Entering/d
   53187 /^Stack/d
   53188 /^Reading/d
   53189 /^Reducing/d
   53190 /^Shifting/d
   53191 /^state/d
   53192 /^Cleanup:/d
   53193 /^Error:/d
   53194 /^Next/d
   53195 /^Discarding/d
   53196 / \$[0-9$]* = /d
   53197 /^yydestructor:/d' stderr >at-stderr
   53198 mv at-stderr stderr
   53199 # 2. Create the reference error message.
   53200 cat >expout <<'_ATEOF'
   53201 1.0: syntax error, unexpected $undefined
   53202 _ATEOF
   53203 
   53204 # 3. If locations are not used, remove them.
   53205 
   53206 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   53207 
   53208 # 5. Check
   53209 $at_traceoff
   53210 echo "calc.at:653: cat stderr"
   53211 echo calc.at:653 >$at_check_line_file
   53212 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   53213 at_status=$?
   53214 grep '^ *+' $at_stder1 >&2
   53215 grep -v '^ *+' $at_stder1 >$at_stderr
   53216 at_failed=false
   53217 $at_diff $at_devnull $at_stderr || at_failed=:
   53218 $at_diff expout $at_stdout || at_failed=:
   53219 case $at_status in
   53220    77) echo 77 > $at_status_file
   53221             exit 77;;
   53222    0) ;;
   53223    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53224       at_failed=:;;
   53225 esac
   53226 if $at_failed; then
   53227 
   53228   echo 1 > $at_status_file
   53229   exit 1
   53230 fi
   53231 
   53232 $at_traceon
   53233 
   53234 
   53235 cat >input <<'_ATEOF'
   53236 1 = 2 = 3
   53237 _ATEOF
   53238 
   53239 $at_traceoff
   53240 echo "calc.at:653: \$PREPARSER ./calc input"
   53241 echo calc.at:653 >$at_check_line_file
   53242 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   53243 at_status=$?
   53244 grep '^ *+' $at_stder1 >&2
   53245 grep -v '^ *+' $at_stder1 >$at_stderr
   53246 at_failed=false
   53247 echo stderr:; tee stderr <$at_stderr
   53248 $at_diff $at_devnull $at_stdout || at_failed=:
   53249 case $at_status in
   53250    77) echo 77 > $at_status_file
   53251             exit 77;;
   53252    1) ;;
   53253    *) echo "calc.at:653: exit code was $at_status, expected 1"
   53254       at_failed=:;;
   53255 esac
   53256 if $at_failed; then
   53257 
   53258   echo 1 > $at_status_file
   53259   exit 1
   53260 fi
   53261 
   53262 $at_traceon
   53263 
   53264 
   53265 # Normalize the observed and expected error messages, depending upon the
   53266 # options.
   53267 # 1. Remove the traces from observed.
   53268 sed '/^Starting/d
   53269 /^Entering/d
   53270 /^Stack/d
   53271 /^Reading/d
   53272 /^Reducing/d
   53273 /^Shifting/d
   53274 /^state/d
   53275 /^Cleanup:/d
   53276 /^Error:/d
   53277 /^Next/d
   53278 /^Discarding/d
   53279 / \$[0-9$]* = /d
   53280 /^yydestructor:/d' stderr >at-stderr
   53281 mv at-stderr stderr
   53282 # 2. Create the reference error message.
   53283 cat >expout <<'_ATEOF'
   53284 1.6: syntax error, unexpected '='
   53285 _ATEOF
   53286 
   53287 # 3. If locations are not used, remove them.
   53288 
   53289 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   53290 
   53291 # 5. Check
   53292 $at_traceoff
   53293 echo "calc.at:653: cat stderr"
   53294 echo calc.at:653 >$at_check_line_file
   53295 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   53296 at_status=$?
   53297 grep '^ *+' $at_stder1 >&2
   53298 grep -v '^ *+' $at_stder1 >$at_stderr
   53299 at_failed=false
   53300 $at_diff $at_devnull $at_stderr || at_failed=:
   53301 $at_diff expout $at_stdout || at_failed=:
   53302 case $at_status in
   53303    77) echo 77 > $at_status_file
   53304             exit 77;;
   53305    0) ;;
   53306    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53307       at_failed=:;;
   53308 esac
   53309 if $at_failed; then
   53310 
   53311   echo 1 > $at_status_file
   53312   exit 1
   53313 fi
   53314 
   53315 $at_traceon
   53316 
   53317 
   53318 cat >input <<'_ATEOF'
   53319 
   53320 +1
   53321 _ATEOF
   53322 
   53323 $at_traceoff
   53324 echo "calc.at:653: \$PREPARSER ./calc input"
   53325 echo calc.at:653 >$at_check_line_file
   53326 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   53327 at_status=$?
   53328 grep '^ *+' $at_stder1 >&2
   53329 grep -v '^ *+' $at_stder1 >$at_stderr
   53330 at_failed=false
   53331 echo stderr:; tee stderr <$at_stderr
   53332 $at_diff $at_devnull $at_stdout || at_failed=:
   53333 case $at_status in
   53334    77) echo 77 > $at_status_file
   53335             exit 77;;
   53336    1) ;;
   53337    *) echo "calc.at:653: exit code was $at_status, expected 1"
   53338       at_failed=:;;
   53339 esac
   53340 if $at_failed; then
   53341 
   53342   echo 1 > $at_status_file
   53343   exit 1
   53344 fi
   53345 
   53346 $at_traceon
   53347 
   53348 
   53349 # Normalize the observed and expected error messages, depending upon the
   53350 # options.
   53351 # 1. Remove the traces from observed.
   53352 sed '/^Starting/d
   53353 /^Entering/d
   53354 /^Stack/d
   53355 /^Reading/d
   53356 /^Reducing/d
   53357 /^Shifting/d
   53358 /^state/d
   53359 /^Cleanup:/d
   53360 /^Error:/d
   53361 /^Next/d
   53362 /^Discarding/d
   53363 / \$[0-9$]* = /d
   53364 /^yydestructor:/d' stderr >at-stderr
   53365 mv at-stderr stderr
   53366 # 2. Create the reference error message.
   53367 cat >expout <<'_ATEOF'
   53368 2.0: syntax error, unexpected '+'
   53369 _ATEOF
   53370 
   53371 # 3. If locations are not used, remove them.
   53372 
   53373 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   53374 
   53375 # 5. Check
   53376 $at_traceoff
   53377 echo "calc.at:653: cat stderr"
   53378 echo calc.at:653 >$at_check_line_file
   53379 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   53380 at_status=$?
   53381 grep '^ *+' $at_stder1 >&2
   53382 grep -v '^ *+' $at_stder1 >$at_stderr
   53383 at_failed=false
   53384 $at_diff $at_devnull $at_stderr || at_failed=:
   53385 $at_diff expout $at_stdout || at_failed=:
   53386 case $at_status in
   53387    77) echo 77 > $at_status_file
   53388             exit 77;;
   53389    0) ;;
   53390    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53391       at_failed=:;;
   53392 esac
   53393 if $at_failed; then
   53394 
   53395   echo 1 > $at_status_file
   53396   exit 1
   53397 fi
   53398 
   53399 $at_traceon
   53400 
   53401 
   53402 # Exercise error messages with EOF: work on an empty file.
   53403 $at_traceoff
   53404 echo "calc.at:653: \$PREPARSER ./calc /dev/null"
   53405 echo calc.at:653 >$at_check_line_file
   53406 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   53407 at_status=$?
   53408 grep '^ *+' $at_stder1 >&2
   53409 grep -v '^ *+' $at_stder1 >$at_stderr
   53410 at_failed=false
   53411 echo stderr:; tee stderr <$at_stderr
   53412 $at_diff $at_devnull $at_stdout || at_failed=:
   53413 case $at_status in
   53414    77) echo 77 > $at_status_file
   53415             exit 77;;
   53416    1) ;;
   53417    *) echo "calc.at:653: exit code was $at_status, expected 1"
   53418       at_failed=:;;
   53419 esac
   53420 if $at_failed; then
   53421 
   53422   echo 1 > $at_status_file
   53423   exit 1
   53424 fi
   53425 
   53426 $at_traceon
   53427 
   53428 
   53429 # Normalize the observed and expected error messages, depending upon the
   53430 # options.
   53431 # 1. Remove the traces from observed.
   53432 sed '/^Starting/d
   53433 /^Entering/d
   53434 /^Stack/d
   53435 /^Reading/d
   53436 /^Reducing/d
   53437 /^Shifting/d
   53438 /^state/d
   53439 /^Cleanup:/d
   53440 /^Error:/d
   53441 /^Next/d
   53442 /^Discarding/d
   53443 / \$[0-9$]* = /d
   53444 /^yydestructor:/d' stderr >at-stderr
   53445 mv at-stderr stderr
   53446 # 2. Create the reference error message.
   53447 cat >expout <<'_ATEOF'
   53448 1.0: syntax error, unexpected end of input
   53449 _ATEOF
   53450 
   53451 # 3. If locations are not used, remove them.
   53452 
   53453 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   53454 
   53455 # 5. Check
   53456 $at_traceoff
   53457 echo "calc.at:653: cat stderr"
   53458 echo calc.at:653 >$at_check_line_file
   53459 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   53460 at_status=$?
   53461 grep '^ *+' $at_stder1 >&2
   53462 grep -v '^ *+' $at_stder1 >$at_stderr
   53463 at_failed=false
   53464 $at_diff $at_devnull $at_stderr || at_failed=:
   53465 $at_diff expout $at_stdout || at_failed=:
   53466 case $at_status in
   53467    77) echo 77 > $at_status_file
   53468             exit 77;;
   53469    0) ;;
   53470    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53471       at_failed=:;;
   53472 esac
   53473 if $at_failed; then
   53474 
   53475   echo 1 > $at_status_file
   53476   exit 1
   53477 fi
   53478 
   53479 $at_traceon
   53480 
   53481 
   53482 
   53483 # Exercise the error token: without it, we die at the first error,
   53484 # hence be sure to
   53485 #
   53486 # - have several errors which exercise different shift/discardings
   53487 #   - (): nothing to pop, nothing to discard
   53488 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   53489 #   - (* * *): nothing to pop, a lot to discard
   53490 #   - (1 + 2 * *): some to pop and discard
   53491 #
   53492 # - test the action associated to `error'
   53493 #
   53494 # - check the look-ahead that triggers an error is not discarded
   53495 #   when we enter error recovery.  Below, the look-ahead causing the
   53496 #   first error is ")", which is needed to recover from the error and
   53497 #   produce the "0" that triggers the "0 != 1" error.
   53498 #
   53499 cat >input <<'_ATEOF'
   53500 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   53501 _ATEOF
   53502 
   53503 $at_traceoff
   53504 echo "calc.at:653: \$PREPARSER ./calc input"
   53505 echo calc.at:653 >$at_check_line_file
   53506 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   53507 at_status=$?
   53508 grep '^ *+' $at_stder1 >&2
   53509 grep -v '^ *+' $at_stder1 >$at_stderr
   53510 at_failed=false
   53511 echo stderr:; tee stderr <$at_stderr
   53512 $at_diff $at_devnull $at_stdout || at_failed=:
   53513 case $at_status in
   53514    77) echo 77 > $at_status_file
   53515             exit 77;;
   53516    0) ;;
   53517    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53518       at_failed=:;;
   53519 esac
   53520 if $at_failed; then
   53521 
   53522   echo 1 > $at_status_file
   53523   exit 1
   53524 fi
   53525 
   53526 $at_traceon
   53527 
   53528 
   53529 # Normalize the observed and expected error messages, depending upon the
   53530 # options.
   53531 # 1. Remove the traces from observed.
   53532 sed '/^Starting/d
   53533 /^Entering/d
   53534 /^Stack/d
   53535 /^Reading/d
   53536 /^Reducing/d
   53537 /^Shifting/d
   53538 /^state/d
   53539 /^Cleanup:/d
   53540 /^Error:/d
   53541 /^Next/d
   53542 /^Discarding/d
   53543 / \$[0-9$]* = /d
   53544 /^yydestructor:/d' stderr >at-stderr
   53545 mv at-stderr stderr
   53546 # 2. Create the reference error message.
   53547 cat >expout <<'_ATEOF'
   53548 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   53549 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   53550 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   53551 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   53552 calc: error: 4444 != 1
   53553 _ATEOF
   53554 
   53555 # 3. If locations are not used, remove them.
   53556 
   53557 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   53558 
   53559 # 5. Check
   53560 $at_traceoff
   53561 echo "calc.at:653: cat stderr"
   53562 echo calc.at:653 >$at_check_line_file
   53563 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   53564 at_status=$?
   53565 grep '^ *+' $at_stder1 >&2
   53566 grep -v '^ *+' $at_stder1 >$at_stderr
   53567 at_failed=false
   53568 $at_diff $at_devnull $at_stderr || at_failed=:
   53569 $at_diff expout $at_stdout || at_failed=:
   53570 case $at_status in
   53571    77) echo 77 > $at_status_file
   53572             exit 77;;
   53573    0) ;;
   53574    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53575       at_failed=:;;
   53576 esac
   53577 if $at_failed; then
   53578 
   53579   echo 1 > $at_status_file
   53580   exit 1
   53581 fi
   53582 
   53583 $at_traceon
   53584 
   53585 
   53586 
   53587 # The same, but this time exercising explicitly triggered syntax errors.
   53588 # POSIX says the look-ahead causing the error should not be discarded.
   53589 cat >input <<'_ATEOF'
   53590 (!) + (0 0) = 1
   53591 _ATEOF
   53592 
   53593 $at_traceoff
   53594 echo "calc.at:653: \$PREPARSER ./calc input"
   53595 echo calc.at:653 >$at_check_line_file
   53596 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   53597 at_status=$?
   53598 grep '^ *+' $at_stder1 >&2
   53599 grep -v '^ *+' $at_stder1 >$at_stderr
   53600 at_failed=false
   53601 echo stderr:; tee stderr <$at_stderr
   53602 $at_diff $at_devnull $at_stdout || at_failed=:
   53603 case $at_status in
   53604    77) echo 77 > $at_status_file
   53605             exit 77;;
   53606    0) ;;
   53607    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53608       at_failed=:;;
   53609 esac
   53610 if $at_failed; then
   53611 
   53612   echo 1 > $at_status_file
   53613   exit 1
   53614 fi
   53615 
   53616 $at_traceon
   53617 
   53618 
   53619 # Normalize the observed and expected error messages, depending upon the
   53620 # options.
   53621 # 1. Remove the traces from observed.
   53622 sed '/^Starting/d
   53623 /^Entering/d
   53624 /^Stack/d
   53625 /^Reading/d
   53626 /^Reducing/d
   53627 /^Shifting/d
   53628 /^state/d
   53629 /^Cleanup:/d
   53630 /^Error:/d
   53631 /^Next/d
   53632 /^Discarding/d
   53633 / \$[0-9$]* = /d
   53634 /^yydestructor:/d' stderr >at-stderr
   53635 mv at-stderr stderr
   53636 # 2. Create the reference error message.
   53637 cat >expout <<'_ATEOF'
   53638 1.9: syntax error, unexpected number
   53639 calc: error: 2222 != 1
   53640 _ATEOF
   53641 
   53642 # 3. If locations are not used, remove them.
   53643 
   53644 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   53645 
   53646 # 5. Check
   53647 $at_traceoff
   53648 echo "calc.at:653: cat stderr"
   53649 echo calc.at:653 >$at_check_line_file
   53650 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   53651 at_status=$?
   53652 grep '^ *+' $at_stder1 >&2
   53653 grep -v '^ *+' $at_stder1 >$at_stderr
   53654 at_failed=false
   53655 $at_diff $at_devnull $at_stderr || at_failed=:
   53656 $at_diff expout $at_stdout || at_failed=:
   53657 case $at_status in
   53658    77) echo 77 > $at_status_file
   53659             exit 77;;
   53660    0) ;;
   53661    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53662       at_failed=:;;
   53663 esac
   53664 if $at_failed; then
   53665 
   53666   echo 1 > $at_status_file
   53667   exit 1
   53668 fi
   53669 
   53670 $at_traceon
   53671 
   53672 
   53673 cat >input <<'_ATEOF'
   53674 (- *) + (0 0) = 1
   53675 _ATEOF
   53676 
   53677 $at_traceoff
   53678 echo "calc.at:653: \$PREPARSER ./calc input"
   53679 echo calc.at:653 >$at_check_line_file
   53680 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   53681 at_status=$?
   53682 grep '^ *+' $at_stder1 >&2
   53683 grep -v '^ *+' $at_stder1 >$at_stderr
   53684 at_failed=false
   53685 echo stderr:; tee stderr <$at_stderr
   53686 $at_diff $at_devnull $at_stdout || at_failed=:
   53687 case $at_status in
   53688    77) echo 77 > $at_status_file
   53689             exit 77;;
   53690    0) ;;
   53691    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53692       at_failed=:;;
   53693 esac
   53694 if $at_failed; then
   53695 
   53696   echo 1 > $at_status_file
   53697   exit 1
   53698 fi
   53699 
   53700 $at_traceon
   53701 
   53702 
   53703 # Normalize the observed and expected error messages, depending upon the
   53704 # options.
   53705 # 1. Remove the traces from observed.
   53706 sed '/^Starting/d
   53707 /^Entering/d
   53708 /^Stack/d
   53709 /^Reading/d
   53710 /^Reducing/d
   53711 /^Shifting/d
   53712 /^state/d
   53713 /^Cleanup:/d
   53714 /^Error:/d
   53715 /^Next/d
   53716 /^Discarding/d
   53717 / \$[0-9$]* = /d
   53718 /^yydestructor:/d' stderr >at-stderr
   53719 mv at-stderr stderr
   53720 # 2. Create the reference error message.
   53721 cat >expout <<'_ATEOF'
   53722 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   53723 1.11: syntax error, unexpected number
   53724 calc: error: 2222 != 1
   53725 _ATEOF
   53726 
   53727 # 3. If locations are not used, remove them.
   53728 
   53729 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   53730 
   53731 # 5. Check
   53732 $at_traceoff
   53733 echo "calc.at:653: cat stderr"
   53734 echo calc.at:653 >$at_check_line_file
   53735 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   53736 at_status=$?
   53737 grep '^ *+' $at_stder1 >&2
   53738 grep -v '^ *+' $at_stder1 >$at_stderr
   53739 at_failed=false
   53740 $at_diff $at_devnull $at_stderr || at_failed=:
   53741 $at_diff expout $at_stdout || at_failed=:
   53742 case $at_status in
   53743    77) echo 77 > $at_status_file
   53744             exit 77;;
   53745    0) ;;
   53746    *) echo "calc.at:653: exit code was $at_status, expected 0"
   53747       at_failed=:;;
   53748 esac
   53749 if $at_failed; then
   53750 
   53751   echo 1 > $at_status_file
   53752   exit 1
   53753 fi
   53754 
   53755 $at_traceon
   53756 
   53757 
   53758 
   53759 
   53760 
   53761 
   53762 
   53763 
   53764 
   53765 
   53766 
   53767 
   53768 
   53769 
   53770 
   53771 
   53772 
   53773 
   53774 
   53775 
   53776 
   53777 
   53778 
   53779 
   53780       $at_traceoff
   53781       $at_times_p && times >$at_times_file
   53782     ) 5>&1 2>&1 | eval $at_tee_pipe
   53783     at_status=`cat $at_status_file`
   53784     ;;
   53785 
   53786 
   53787   banner-13 ) # Banner 13. torture.at:19
   53788     cat <<\_ATEOF
   53789 
   53790 Torture Tests.
   53791 
   53792 _ATEOF
   53793     ;;
   53794 
   53795   105 ) # 105. torture.at:140: Big triangle
   53796     at_setup_line='torture.at:140'
   53797     at_desc='Big triangle'
   53798     $at_quiet $ECHO_N "105: Big triangle                                 $ECHO_C"
   53799     at_xfail=no
   53800     (
   53801       echo "105. torture.at:140: testing ..."
   53802       $at_traceon
   53803 
   53804 
   53805 # I have been able to go up to 2000 on my machine.
   53806 # I tried 3000, a 29Mb grammar file, but then my system killed bison.
   53807 # With 500 and the new parser, which consume far too much memory,
   53808 # it gets killed too.  Of course the parser is to be cleaned.
   53809 cat >gengram.pl <<'_ATEOF'
   53810 #! /usr/bin/perl -w
   53811 
   53812 use strict;
   53813 my $max = $ARGV[0] || 10;
   53814 
   53815 print <<EOF;
   53816 %{
   53817 #ifdef HAVE_CONFIG_H
   53818 # include <config.h>
   53819   /* We don't need perfect functions for these tests. */
   53820 # undef malloc
   53821 # undef memcmp
   53822 # undef realloc
   53823 #endif
   53824 %}
   53825 
   53826 %error-verbose
   53827 %debug
   53828 %{
   53829 #include <stdio.h>
   53830 #include <stdlib.h>
   53831 
   53832 static int yylex (void);
   53833 static void yyerror (const char *msg);
   53834 %}
   53835 %union
   53836 {
   53837   int val;
   53838 };
   53839 
   53840 %token END "end"
   53841 %type <val> exp input
   53842 EOF
   53843 
   53844 for my $size (1 .. $max)
   53845   {
   53846     print "%token t$size $size \"$size\"\n";
   53847   };
   53848 
   53849 print <<EOF;
   53850 %%
   53851 input:
   53852   exp        { if (\$1 != 0) abort (); \$\$ = \$1; }
   53853 | input exp  { if (\$2 != \$1 + 1) abort (); \$\$ = \$2; }
   53854 ;
   53855 
   53856 exp:
   53857   END
   53858     { \$\$ = 0; }
   53859 EOF
   53860 
   53861 for my $size (1 .. $max)
   53862   {
   53863     use Text::Wrap;
   53864     print wrap ("| ", "   ",
   53865 		(map { "\"$_\"" } (1 .. $size)),
   53866 		" END \n"),
   53867 		  "    { \$\$ = $size; }\n";
   53868   };
   53869 print ";\n";
   53870 
   53871 print <<EOF;
   53872 %%
   53873 static int
   53874 yylex (void)
   53875 {
   53876   static int inner = 1;
   53877   static int outer = 0;
   53878   if (outer > $max)
   53879     return 0;
   53880   else if (inner > outer)
   53881     {
   53882       inner = 1;
   53883       ++outer;
   53884       return END;
   53885     }
   53886   return inner++;
   53887 }
   53888 
   53889 static void
   53890 yyerror (const char *msg)
   53891 {
   53892   fprintf (stderr, "%s\\n", msg);
   53893 }
   53894 
   53895 int
   53896 main (void)
   53897 {
   53898   yydebug = !!getenv ("YYDEBUG");
   53899   return yyparse ();
   53900 }
   53901 EOF
   53902 _ATEOF
   53903 
   53904 
   53905 $at_traceoff
   53906 echo "torture.at:146: perl -w ./gengram.pl 200 || exit 77"
   53907 echo torture.at:146 >$at_check_line_file
   53908 ( $at_traceon; perl -w ./gengram.pl 200 || exit 77 ) >$at_stdout 2>$at_stder1
   53909 at_status=$?
   53910 grep '^ *+' $at_stder1 >&2
   53911 grep -v '^ *+' $at_stder1 >$at_stderr
   53912 at_failed=false
   53913 $at_diff $at_devnull $at_stderr || at_failed=:
   53914 echo stdout:; tee stdout <$at_stdout
   53915 case $at_status in
   53916    77) echo 77 > $at_status_file
   53917             exit 77;;
   53918    0) ;;
   53919    *) echo "torture.at:146: exit code was $at_status, expected 0"
   53920       at_failed=:;;
   53921 esac
   53922 if $at_failed; then
   53923 
   53924   echo 1 > $at_status_file
   53925   exit 1
   53926 fi
   53927 
   53928 $at_traceon
   53929 
   53930 mv stdout input.y
   53931 
   53932 $at_traceoff
   53933 echo "torture.at:147: bison -v -o input.c input.y"
   53934 echo torture.at:147 >$at_check_line_file
   53935 ( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   53936 at_status=$?
   53937 grep '^ *+' $at_stder1 >&2
   53938 grep -v '^ *+' $at_stder1 >$at_stderr
   53939 at_failed=false
   53940 $at_diff $at_devnull $at_stderr || at_failed=:
   53941 $at_diff $at_devnull $at_stdout || at_failed=:
   53942 case $at_status in
   53943    77) echo 77 > $at_status_file
   53944             exit 77;;
   53945    0) ;;
   53946    *) echo "torture.at:147: exit code was $at_status, expected 0"
   53947       at_failed=:;;
   53948 esac
   53949 if $at_failed; then
   53950 
   53951   echo 1 > $at_status_file
   53952   exit 1
   53953 fi
   53954 
   53955 $at_traceon
   53956 
   53957 $at_traceoff
   53958 echo "torture.at:148: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   53959 echo torture.at:148 >$at_check_line_file
   53960 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   53961 at_status=$?
   53962 grep '^ *+' $at_stder1 >&2
   53963 grep -v '^ *+' $at_stder1 >$at_stderr
   53964 at_failed=false
   53965 echo stderr:; cat $at_stderr
   53966 echo stdout:; cat $at_stdout
   53967 case $at_status in
   53968    77) echo 77 > $at_status_file
   53969             exit 77;;
   53970    0) ;;
   53971    *) echo "torture.at:148: exit code was $at_status, expected 0"
   53972       at_failed=:;;
   53973 esac
   53974 if $at_failed; then
   53975 
   53976   echo 1 > $at_status_file
   53977   exit 1
   53978 fi
   53979 
   53980 $at_traceon
   53981 
   53982 $at_traceoff
   53983 echo "torture.at:149: \$PREPARSER ./input"
   53984 echo torture.at:149 >$at_check_line_file
   53985 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   53986 at_status=$?
   53987 grep '^ *+' $at_stder1 >&2
   53988 grep -v '^ *+' $at_stder1 >$at_stderr
   53989 at_failed=false
   53990 $at_diff $at_devnull $at_stderr || at_failed=:
   53991 $at_diff $at_devnull $at_stdout || at_failed=:
   53992 case $at_status in
   53993    77) echo 77 > $at_status_file
   53994             exit 77;;
   53995    0) ;;
   53996    *) echo "torture.at:149: exit code was $at_status, expected 0"
   53997       at_failed=:;;
   53998 esac
   53999 if $at_failed; then
   54000 
   54001   echo 1 > $at_status_file
   54002   exit 1
   54003 fi
   54004 
   54005 $at_traceon
   54006 
   54007 
   54008       $at_traceoff
   54009       $at_times_p && times >$at_times_file
   54010     ) 5>&1 2>&1 | eval $at_tee_pipe
   54011     at_status=`cat $at_status_file`
   54012     ;;
   54013 
   54014   106 ) # 106. torture.at:232: Big horizontal
   54015     at_setup_line='torture.at:232'
   54016     at_desc='Big horizontal'
   54017     $at_quiet $ECHO_N "106: Big horizontal                               $ECHO_C"
   54018     at_xfail=no
   54019     (
   54020       echo "106. torture.at:232: testing ..."
   54021       $at_traceon
   54022 
   54023 
   54024 # I have been able to go up to 10000 on my machine, but I had to
   54025 # increase the maximum stack size (* 100).  It gave:
   54026 #
   54027 # input.y      263k
   54028 # input.tab.c  1.3M
   54029 # input        453k
   54030 #
   54031 # gengram.pl 10000                 0.70s user 0.01s sys  99% cpu    0.711 total
   54032 # bison input.y                  730.56s user 0.53s sys  99% cpu 12:12.34 total
   54033 # gcc -Wall input.tab.c -o input   5.81s user 0.20s sys 100% cpu     6.01 total
   54034 # ./input                          0.00s user 0.01s sys 108% cpu     0.01 total
   54035 #
   54036 cat >gengram.pl <<'_ATEOF'
   54037 #! /usr/bin/perl -w
   54038 
   54039 use strict;
   54040 my $max = $ARGV[0] || 10;
   54041 
   54042 print <<EOF;
   54043 %{
   54044 #ifdef HAVE_CONFIG_H
   54045 # include <config.h>
   54046   /* We don't need perfect functions for these tests. */
   54047 # undef malloc
   54048 # undef memcmp
   54049 # undef realloc
   54050 #endif
   54051 %}
   54052 
   54053 %error-verbose
   54054 %debug
   54055 %{
   54056 #include <stdio.h>
   54057 #include <stdlib.h>
   54058 
   54059 static int yylex (void);
   54060 static void yyerror (const char *msg);
   54061 %}
   54062 
   54063 %token
   54064 EOF
   54065 for my $size (1 .. $max)
   54066   {
   54067     print "    t$size $size \"$size\"\n";
   54068   };
   54069 
   54070 print <<EOF;
   54071 
   54072 %%
   54073 EOF
   54074 
   54075 use Text::Wrap;
   54076 print
   54077   wrap ("exp: ", "  ",
   54078 	(map { "\"$_\"" } (1 .. $max)), ";"),
   54079   "\n";
   54080 
   54081 print <<EOF;
   54082 %%
   54083 static int
   54084 yylex (void)
   54085 {
   54086   static int counter = 1;
   54087   if (counter > $max)
   54088     return 0;
   54089   else
   54090   return counter++;
   54091 }
   54092 
   54093 static void
   54094 yyerror (const char *msg)
   54095 {
   54096   fprintf (stderr, "%s\\n", msg);
   54097 }
   54098 
   54099 int
   54100 main (void)
   54101 {
   54102   yydebug = !!getenv ("YYDEBUG");
   54103   return yyparse ();
   54104 }
   54105 EOF
   54106 _ATEOF
   54107 
   54108 
   54109 $at_traceoff
   54110 echo "torture.at:246: perl -w ./gengram.pl 1000 || exit 77"
   54111 echo torture.at:246 >$at_check_line_file
   54112 ( $at_traceon; perl -w ./gengram.pl 1000 || exit 77 ) >$at_stdout 2>$at_stder1
   54113 at_status=$?
   54114 grep '^ *+' $at_stder1 >&2
   54115 grep -v '^ *+' $at_stder1 >$at_stderr
   54116 at_failed=false
   54117 $at_diff $at_devnull $at_stderr || at_failed=:
   54118 echo stdout:; tee stdout <$at_stdout
   54119 case $at_status in
   54120    77) echo 77 > $at_status_file
   54121             exit 77;;
   54122    0) ;;
   54123    *) echo "torture.at:246: exit code was $at_status, expected 0"
   54124       at_failed=:;;
   54125 esac
   54126 if $at_failed; then
   54127 
   54128   echo 1 > $at_status_file
   54129   exit 1
   54130 fi
   54131 
   54132 $at_traceon
   54133 
   54134 mv stdout input.y
   54135 
   54136 
   54137 # GNU m4 requires about 70 MiB for this test on a 32-bit host.
   54138 # Ask for 200 MiB, which should be plenty even on a 64-bit host.
   54139 data_limit=`(ulimit -S -d) 2>/dev/null`
   54140 case $data_limit in
   54141 [0-9]*)
   54142   if test "$data_limit" -lt 204000; then
   54143     $at_traceoff
   54144 echo "torture.at:250: ulimit -S -d 204000 || exit 77"
   54145 echo torture.at:250 >$at_check_line_file
   54146 ( $at_traceon; ulimit -S -d 204000 || exit 77 ) >$at_stdout 2>$at_stder1
   54147 at_status=$?
   54148 grep '^ *+' $at_stder1 >&2
   54149 grep -v '^ *+' $at_stder1 >$at_stderr
   54150 at_failed=false
   54151 $at_diff $at_devnull $at_stderr || at_failed=:
   54152 $at_diff $at_devnull $at_stdout || at_failed=:
   54153 case $at_status in
   54154    77) echo 77 > $at_status_file
   54155             exit 77;;
   54156    0) ;;
   54157    *) echo "torture.at:250: exit code was $at_status, expected 0"
   54158       at_failed=:;;
   54159 esac
   54160 if $at_failed; then
   54161 
   54162   echo 1 > $at_status_file
   54163   exit 1
   54164 fi
   54165 
   54166 $at_traceon
   54167 
   54168     ulimit -S -d 204000
   54169   fi
   54170 esac
   54171 
   54172 $at_traceoff
   54173 echo "torture.at:252: bison -v -o input.c input.y"
   54174 echo torture.at:252 >$at_check_line_file
   54175 ( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   54176 at_status=$?
   54177 grep '^ *+' $at_stder1 >&2
   54178 grep -v '^ *+' $at_stder1 >$at_stderr
   54179 at_failed=false
   54180 $at_diff $at_devnull $at_stderr || at_failed=:
   54181 $at_diff $at_devnull $at_stdout || at_failed=:
   54182 case $at_status in
   54183    77) echo 77 > $at_status_file
   54184             exit 77;;
   54185    0) ;;
   54186    *) echo "torture.at:252: exit code was $at_status, expected 0"
   54187       at_failed=:;;
   54188 esac
   54189 if $at_failed; then
   54190 
   54191   echo 1 > $at_status_file
   54192   exit 1
   54193 fi
   54194 
   54195 $at_traceon
   54196 
   54197 $at_traceoff
   54198 echo "torture.at:253: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   54199 echo torture.at:253 >$at_check_line_file
   54200 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   54201 at_status=$?
   54202 grep '^ *+' $at_stder1 >&2
   54203 grep -v '^ *+' $at_stder1 >$at_stderr
   54204 at_failed=false
   54205 echo stderr:; cat $at_stderr
   54206 echo stdout:; cat $at_stdout
   54207 case $at_status in
   54208    77) echo 77 > $at_status_file
   54209             exit 77;;
   54210    0) ;;
   54211    *) echo "torture.at:253: exit code was $at_status, expected 0"
   54212       at_failed=:;;
   54213 esac
   54214 if $at_failed; then
   54215 
   54216   echo 1 > $at_status_file
   54217   exit 1
   54218 fi
   54219 
   54220 $at_traceon
   54221 
   54222 $at_traceoff
   54223 echo "torture.at:254: \$PREPARSER ./input"
   54224 echo torture.at:254 >$at_check_line_file
   54225 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   54226 at_status=$?
   54227 grep '^ *+' $at_stder1 >&2
   54228 grep -v '^ *+' $at_stder1 >$at_stderr
   54229 at_failed=false
   54230 $at_diff $at_devnull $at_stderr || at_failed=:
   54231 $at_diff $at_devnull $at_stdout || at_failed=:
   54232 case $at_status in
   54233    77) echo 77 > $at_status_file
   54234             exit 77;;
   54235    0) ;;
   54236    *) echo "torture.at:254: exit code was $at_status, expected 0"
   54237       at_failed=:;;
   54238 esac
   54239 if $at_failed; then
   54240 
   54241   echo 1 > $at_status_file
   54242   exit 1
   54243 fi
   54244 
   54245 $at_traceon
   54246 
   54247 
   54248       $at_traceoff
   54249       $at_times_p && times >$at_times_file
   54250     ) 5>&1 2>&1 | eval $at_tee_pipe
   54251     at_status=`cat $at_status_file`
   54252     ;;
   54253 
   54254   107 ) # 107. torture.at:368: Many look-ahead tokens
   54255     at_setup_line='torture.at:368'
   54256     at_desc='Many look-ahead tokens'
   54257     $at_quiet $ECHO_N "107: Many look-ahead tokens                       $ECHO_C"
   54258     at_xfail=no
   54259     (
   54260       echo "107. torture.at:368: testing ..."
   54261       $at_traceon
   54262 
   54263 
   54264 cat >gengram.pl <<'_ATEOF'
   54265 #! /usr/bin/perl -w
   54266 
   54267 use strict;
   54268 use Text::Wrap;
   54269 my $max = $ARGV[0] || 10;
   54270 
   54271 print <<EOF;
   54272 %error-verbose
   54273 %debug
   54274 %{
   54275 # include <stdio.h>
   54276 # include <stdlib.h>
   54277 # include <assert.h>
   54278 
   54279 static int yylex (void);
   54280 static void yyerror (const char *msg);
   54281 %}
   54282 %union
   54283 {
   54284   int val;
   54285 };
   54286 
   54287 %type <val> input exp
   54288 %token token
   54289 EOF
   54290 
   54291 print
   54292   wrap ("%type <val> ",
   54293 	"            ",
   54294 	map { "n$_" } (1 .. $max)),
   54295   "\n";
   54296 
   54297 print "%token\n";
   54298 for my $count (1 .. $max)
   54299   {
   54300     print "    t$count $count \"$count\"\n";
   54301   };
   54302 
   54303 print <<EOF;
   54304 %%
   54305 input:
   54306   exp        { assert (\$1 == 1); \$\$ = \$1; }
   54307 | input exp  { assert (\$2 == \$1 + 1); \$\$ = \$2; }
   54308 ;
   54309 
   54310 exp:
   54311   n1 "1" { assert (\$1 == 1); \$\$ = \$1; }
   54312 EOF
   54313 
   54314 for my $count (2 .. $max)
   54315   {
   54316     print "| n$count \"$count\" { assert (\$1 == $count); \$\$ = \$1; }\n";
   54317   };
   54318 print ";\n";
   54319 
   54320 for my $count (1 .. $max)
   54321   {
   54322     print "n$count: token { \$\$ = $count; };\n";
   54323   };
   54324 
   54325 print <<EOF;
   54326 %%
   54327 static int
   54328 yylex (void)
   54329 {
   54330   static int return_token = 1;
   54331   static int counter = 1;
   54332   if (counter > $max)
   54333     return 0;
   54334   if (return_token)
   54335     {
   54336       return_token = 0;
   54337       return token;
   54338     }
   54339   return_token = 1;
   54340   return counter++;
   54341 }
   54342 
   54343 static void
   54344 yyerror (const char *msg)
   54345 {
   54346   fprintf (stderr, "%s\\n", msg);
   54347 }
   54348 
   54349 int
   54350 main (void)
   54351 {
   54352   yydebug = !!getenv ("YYDEBUG");
   54353   return yyparse ();
   54354 }
   54355 EOF
   54356 _ATEOF
   54357 
   54358 
   54359 $at_traceoff
   54360 echo "torture.at:370: perl -w ./gengram.pl 1000 || exit 77"
   54361 echo torture.at:370 >$at_check_line_file
   54362 ( $at_traceon; perl -w ./gengram.pl 1000 || exit 77 ) >$at_stdout 2>$at_stder1
   54363 at_status=$?
   54364 grep '^ *+' $at_stder1 >&2
   54365 grep -v '^ *+' $at_stder1 >$at_stderr
   54366 at_failed=false
   54367 $at_diff $at_devnull $at_stderr || at_failed=:
   54368 echo stdout:; tee stdout <$at_stdout
   54369 case $at_status in
   54370    77) echo 77 > $at_status_file
   54371             exit 77;;
   54372    0) ;;
   54373    *) echo "torture.at:370: exit code was $at_status, expected 0"
   54374       at_failed=:;;
   54375 esac
   54376 if $at_failed; then
   54377 
   54378   echo 1 > $at_status_file
   54379   exit 1
   54380 fi
   54381 
   54382 $at_traceon
   54383 
   54384 mv stdout input.y
   54385 
   54386 
   54387 # GNU m4 requires about 70 MiB for this test on a 32-bit host.
   54388 # Ask for 200 MiB, which should be plenty even on a 64-bit host.
   54389 data_limit=`(ulimit -S -d) 2>/dev/null`
   54390 case $data_limit in
   54391 [0-9]*)
   54392   if test "$data_limit" -lt 204000; then
   54393     $at_traceoff
   54394 echo "torture.at:374: ulimit -S -d 204000 || exit 77"
   54395 echo torture.at:374 >$at_check_line_file
   54396 ( $at_traceon; ulimit -S -d 204000 || exit 77 ) >$at_stdout 2>$at_stder1
   54397 at_status=$?
   54398 grep '^ *+' $at_stder1 >&2
   54399 grep -v '^ *+' $at_stder1 >$at_stderr
   54400 at_failed=false
   54401 $at_diff $at_devnull $at_stderr || at_failed=:
   54402 $at_diff $at_devnull $at_stdout || at_failed=:
   54403 case $at_status in
   54404    77) echo 77 > $at_status_file
   54405             exit 77;;
   54406    0) ;;
   54407    *) echo "torture.at:374: exit code was $at_status, expected 0"
   54408       at_failed=:;;
   54409 esac
   54410 if $at_failed; then
   54411 
   54412   echo 1 > $at_status_file
   54413   exit 1
   54414 fi
   54415 
   54416 $at_traceon
   54417 
   54418     ulimit -S -d 204000
   54419   fi
   54420 esac
   54421 
   54422 $at_traceoff
   54423 echo "torture.at:376: bison -v -o input.c input.y"
   54424 echo torture.at:376 >$at_check_line_file
   54425 ( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   54426 at_status=$?
   54427 grep '^ *+' $at_stder1 >&2
   54428 grep -v '^ *+' $at_stder1 >$at_stderr
   54429 at_failed=false
   54430 $at_diff $at_devnull $at_stderr || at_failed=:
   54431 $at_diff $at_devnull $at_stdout || at_failed=:
   54432 case $at_status in
   54433    77) echo 77 > $at_status_file
   54434             exit 77;;
   54435    0) ;;
   54436    *) echo "torture.at:376: exit code was $at_status, expected 0"
   54437       at_failed=:;;
   54438 esac
   54439 if $at_failed; then
   54440 
   54441   echo 1 > $at_status_file
   54442   exit 1
   54443 fi
   54444 
   54445 $at_traceon
   54446 
   54447 $at_traceoff
   54448 echo "torture.at:377: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   54449 echo torture.at:377 >$at_check_line_file
   54450 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   54451 at_status=$?
   54452 grep '^ *+' $at_stder1 >&2
   54453 grep -v '^ *+' $at_stder1 >$at_stderr
   54454 at_failed=false
   54455 echo stderr:; cat $at_stderr
   54456 echo stdout:; cat $at_stdout
   54457 case $at_status in
   54458    77) echo 77 > $at_status_file
   54459             exit 77;;
   54460    0) ;;
   54461    *) echo "torture.at:377: exit code was $at_status, expected 0"
   54462       at_failed=:;;
   54463 esac
   54464 if $at_failed; then
   54465 
   54466   echo 1 > $at_status_file
   54467   exit 1
   54468 fi
   54469 
   54470 $at_traceon
   54471 
   54472 $at_traceoff
   54473 echo "torture.at:378: \$PREPARSER ./input"
   54474 echo torture.at:378 >$at_check_line_file
   54475 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   54476 at_status=$?
   54477 grep '^ *+' $at_stder1 >&2
   54478 grep -v '^ *+' $at_stder1 >$at_stderr
   54479 at_failed=false
   54480 $at_diff $at_devnull $at_stderr || at_failed=:
   54481 $at_diff $at_devnull $at_stdout || at_failed=:
   54482 case $at_status in
   54483    77) echo 77 > $at_status_file
   54484             exit 77;;
   54485    0) ;;
   54486    *) echo "torture.at:378: exit code was $at_status, expected 0"
   54487       at_failed=:;;
   54488 esac
   54489 if $at_failed; then
   54490 
   54491   echo 1 > $at_status_file
   54492   exit 1
   54493 fi
   54494 
   54495 $at_traceon
   54496 
   54497 
   54498       $at_traceoff
   54499       $at_times_p && times >$at_times_file
   54500     ) 5>&1 2>&1 | eval $at_tee_pipe
   54501     at_status=`cat $at_status_file`
   54502     ;;
   54503 
   54504   108 ) # 108. torture.at:445: Exploding the Stack Size with Alloca
   54505     at_setup_line='torture.at:445'
   54506     at_desc='Exploding the Stack Size with Alloca'
   54507     $at_quiet $ECHO_N "108: Exploding the Stack Size with Alloca         $ECHO_C"
   54508     at_xfail=no
   54509     (
   54510       echo "108. torture.at:445: testing ..."
   54511       $at_traceon
   54512 
   54513 
   54514 # A grammar of parens growing the stack thanks to right recursion.
   54515 # exp:
   54516 cat >input.y <<'_ATEOF'
   54517 %{
   54518 #include <errno.h>
   54519 #include <limits.h>
   54520 #include <stdio.h>
   54521 #include <stdlib.h>
   54522 
   54523 #if (defined __GNUC__ || defined __BUILTIN_VA_ARG_INCR \
   54524      || defined _AIX || defined _MSC_VER || defined _ALLOCA_H)
   54525 # define YYSTACK_USE_ALLOCA 1
   54526 #endif
   54527 
   54528   static int yylex (void);
   54529   static void yyerror (const char *msg);
   54530 %}
   54531 %error-verbose
   54532 %debug
   54533 %token WAIT_FOR_EOF
   54534 %%
   54535 exp: WAIT_FOR_EOF exp | ;
   54536 %%
   54537 static void
   54538 yyerror (const char *msg)
   54539 {
   54540   fprintf (stderr, "%s\n", msg);
   54541 }
   54542 
   54543 static int
   54544 yylex (void)
   54545 {
   54546   if (yylval--)
   54547     return WAIT_FOR_EOF;
   54548   else
   54549     return EOF;
   54550 }
   54551 
   54552 int
   54553 main (int argc, const char **argv)
   54554 {
   54555   char *endp;
   54556   if (argc != 2)
   54557     abort ();
   54558   yylval = strtol (argv[1], &endp, 10);
   54559   if (! (argv[1] != endp
   54560 	 && 0 <= yylval && yylval <= INT_MAX
   54561 	 && errno != ERANGE))
   54562     abort ();
   54563   yydebug = 1;
   54564   return yyparse ();
   54565 }
   54566 _ATEOF
   54567 
   54568 $at_traceoff
   54569 echo "torture.at:452: bison -o input.c input.y"
   54570 echo torture.at:452 >$at_check_line_file
   54571 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   54572 at_status=$?
   54573 grep '^ *+' $at_stder1 >&2
   54574 grep -v '^ *+' $at_stder1 >$at_stderr
   54575 at_failed=false
   54576 $at_diff $at_devnull $at_stderr || at_failed=:
   54577 $at_diff $at_devnull $at_stdout || at_failed=:
   54578 case $at_status in
   54579    77) echo 77 > $at_status_file
   54580             exit 77;;
   54581    0) ;;
   54582    *) echo "torture.at:452: exit code was $at_status, expected 0"
   54583       at_failed=:;;
   54584 esac
   54585 if $at_failed; then
   54586 
   54587   echo 1 > $at_status_file
   54588   exit 1
   54589 fi
   54590 
   54591 $at_traceon
   54592 
   54593 $at_traceoff
   54594 echo "torture.at:452: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   54595 echo torture.at:452 >$at_check_line_file
   54596 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   54597 at_status=$?
   54598 grep '^ *+' $at_stder1 >&2
   54599 grep -v '^ *+' $at_stder1 >$at_stderr
   54600 at_failed=false
   54601 echo stderr:; cat $at_stderr
   54602 echo stdout:; cat $at_stdout
   54603 case $at_status in
   54604    77) echo 77 > $at_status_file
   54605             exit 77;;
   54606    0) ;;
   54607    *) echo "torture.at:452: exit code was $at_status, expected 0"
   54608       at_failed=:;;
   54609 esac
   54610 if $at_failed; then
   54611 
   54612   echo 1 > $at_status_file
   54613   exit 1
   54614 fi
   54615 
   54616 $at_traceon
   54617 
   54618 
   54619 
   54620 # Below the limit of 200.
   54621 $at_traceoff
   54622 echo "torture.at:455: \$PREPARSER ./input 20"
   54623 echo torture.at:455 >$at_check_line_file
   54624 ( $at_traceon; $PREPARSER ./input 20 ) >$at_stdout 2>$at_stder1
   54625 at_status=$?
   54626 grep '^ *+' $at_stder1 >&2
   54627 grep -v '^ *+' $at_stder1 >$at_stderr
   54628 at_failed=false
   54629 echo stderr:; cat $at_stderr
   54630 $at_diff $at_devnull $at_stdout || at_failed=:
   54631 case $at_status in
   54632    77) echo 77 > $at_status_file
   54633             exit 77;;
   54634    0) ;;
   54635    *) echo "torture.at:455: exit code was $at_status, expected 0"
   54636       at_failed=:;;
   54637 esac
   54638 if $at_failed; then
   54639 
   54640   echo 1 > $at_status_file
   54641   exit 1
   54642 fi
   54643 
   54644 $at_traceon
   54645 
   54646 # Two enlargements: 2 * 2 * 200.
   54647 $at_traceoff
   54648 echo "torture.at:457: \$PREPARSER ./input 900"
   54649 echo torture.at:457 >$at_check_line_file
   54650 ( $at_traceon; $PREPARSER ./input 900 ) >$at_stdout 2>$at_stder1
   54651 at_status=$?
   54652 grep '^ *+' $at_stder1 >&2
   54653 grep -v '^ *+' $at_stder1 >$at_stderr
   54654 at_failed=false
   54655 echo stderr:; cat $at_stderr
   54656 $at_diff $at_devnull $at_stdout || at_failed=:
   54657 case $at_status in
   54658    77) echo 77 > $at_status_file
   54659             exit 77;;
   54660    0) ;;
   54661    *) echo "torture.at:457: exit code was $at_status, expected 0"
   54662       at_failed=:;;
   54663 esac
   54664 if $at_failed; then
   54665 
   54666   echo 1 > $at_status_file
   54667   exit 1
   54668 fi
   54669 
   54670 $at_traceon
   54671 
   54672 # Fails: beyond the limit of 10,000 (which we don't reach anyway since we
   54673 # multiply by two starting at 200 => 5120 is the last possible).
   54674 $at_traceoff
   54675 echo "torture.at:460: \$PREPARSER ./input 10000"
   54676 echo torture.at:460 >$at_check_line_file
   54677 ( $at_traceon; $PREPARSER ./input 10000 ) >$at_stdout 2>$at_stder1
   54678 at_status=$?
   54679 grep '^ *+' $at_stder1 >&2
   54680 grep -v '^ *+' $at_stder1 >$at_stderr
   54681 at_failed=false
   54682 echo stderr:; cat $at_stderr
   54683 $at_diff $at_devnull $at_stdout || at_failed=:
   54684 case $at_status in
   54685    77) echo 77 > $at_status_file
   54686             exit 77;;
   54687    2) ;;
   54688    *) echo "torture.at:460: exit code was $at_status, expected 2"
   54689       at_failed=:;;
   54690 esac
   54691 if $at_failed; then
   54692 
   54693   echo 1 > $at_status_file
   54694   exit 1
   54695 fi
   54696 
   54697 $at_traceon
   54698 
   54699 
   54700       $at_traceoff
   54701       $at_times_p && times >$at_times_file
   54702     ) 5>&1 2>&1 | eval $at_tee_pipe
   54703     at_status=`cat $at_status_file`
   54704     ;;
   54705 
   54706   109 ) # 109. torture.at:471: Exploding the Stack Size with Malloc
   54707     at_setup_line='torture.at:471'
   54708     at_desc='Exploding the Stack Size with Malloc'
   54709     $at_quiet $ECHO_N "109: Exploding the Stack Size with Malloc         $ECHO_C"
   54710     at_xfail=no
   54711     (
   54712       echo "109. torture.at:471: testing ..."
   54713       $at_traceon
   54714 
   54715 
   54716 # A grammar of parens growing the stack thanks to right recursion.
   54717 # exp:
   54718 cat >input.y <<'_ATEOF'
   54719 %{
   54720 #include <errno.h>
   54721 #include <limits.h>
   54722 #include <stdio.h>
   54723 #include <stdlib.h>
   54724 #define YYSTACK_USE_ALLOCA 0
   54725   static int yylex (void);
   54726   static void yyerror (const char *msg);
   54727 %}
   54728 %error-verbose
   54729 %debug
   54730 %token WAIT_FOR_EOF
   54731 %%
   54732 exp: WAIT_FOR_EOF exp | ;
   54733 %%
   54734 static void
   54735 yyerror (const char *msg)
   54736 {
   54737   fprintf (stderr, "%s\n", msg);
   54738 }
   54739 
   54740 static int
   54741 yylex (void)
   54742 {
   54743   if (yylval--)
   54744     return WAIT_FOR_EOF;
   54745   else
   54746     return EOF;
   54747 }
   54748 
   54749 int
   54750 main (int argc, const char **argv)
   54751 {
   54752   char *endp;
   54753   if (argc != 2)
   54754     abort ();
   54755   yylval = strtol (argv[1], &endp, 10);
   54756   if (! (argv[1] != endp
   54757 	 && 0 <= yylval && yylval <= INT_MAX
   54758 	 && errno != ERANGE))
   54759     abort ();
   54760   yydebug = 1;
   54761   return yyparse ();
   54762 }
   54763 _ATEOF
   54764 
   54765 $at_traceoff
   54766 echo "torture.at:473: bison -o input.c input.y"
   54767 echo torture.at:473 >$at_check_line_file
   54768 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   54769 at_status=$?
   54770 grep '^ *+' $at_stder1 >&2
   54771 grep -v '^ *+' $at_stder1 >$at_stderr
   54772 at_failed=false
   54773 $at_diff $at_devnull $at_stderr || at_failed=:
   54774 $at_diff $at_devnull $at_stdout || at_failed=:
   54775 case $at_status in
   54776    77) echo 77 > $at_status_file
   54777             exit 77;;
   54778    0) ;;
   54779    *) echo "torture.at:473: exit code was $at_status, expected 0"
   54780       at_failed=:;;
   54781 esac
   54782 if $at_failed; then
   54783 
   54784   echo 1 > $at_status_file
   54785   exit 1
   54786 fi
   54787 
   54788 $at_traceon
   54789 
   54790 $at_traceoff
   54791 echo "torture.at:473: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   54792 echo torture.at:473 >$at_check_line_file
   54793 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   54794 at_status=$?
   54795 grep '^ *+' $at_stder1 >&2
   54796 grep -v '^ *+' $at_stder1 >$at_stderr
   54797 at_failed=false
   54798 echo stderr:; cat $at_stderr
   54799 echo stdout:; cat $at_stdout
   54800 case $at_status in
   54801    77) echo 77 > $at_status_file
   54802             exit 77;;
   54803    0) ;;
   54804    *) echo "torture.at:473: exit code was $at_status, expected 0"
   54805       at_failed=:;;
   54806 esac
   54807 if $at_failed; then
   54808 
   54809   echo 1 > $at_status_file
   54810   exit 1
   54811 fi
   54812 
   54813 $at_traceon
   54814 
   54815 
   54816 
   54817 # Below the limit of 200.
   54818 $at_traceoff
   54819 echo "torture.at:476: \$PREPARSER ./input 20"
   54820 echo torture.at:476 >$at_check_line_file
   54821 ( $at_traceon; $PREPARSER ./input 20 ) >$at_stdout 2>$at_stder1
   54822 at_status=$?
   54823 grep '^ *+' $at_stder1 >&2
   54824 grep -v '^ *+' $at_stder1 >$at_stderr
   54825 at_failed=false
   54826 echo stderr:; cat $at_stderr
   54827 $at_diff $at_devnull $at_stdout || at_failed=:
   54828 case $at_status in
   54829    77) echo 77 > $at_status_file
   54830             exit 77;;
   54831    0) ;;
   54832    *) echo "torture.at:476: exit code was $at_status, expected 0"
   54833       at_failed=:;;
   54834 esac
   54835 if $at_failed; then
   54836 
   54837   echo 1 > $at_status_file
   54838   exit 1
   54839 fi
   54840 
   54841 $at_traceon
   54842 
   54843 # Two enlargements: 2 * 2 * 200.
   54844 $at_traceoff
   54845 echo "torture.at:478: \$PREPARSER ./input 900"
   54846 echo torture.at:478 >$at_check_line_file
   54847 ( $at_traceon; $PREPARSER ./input 900 ) >$at_stdout 2>$at_stder1
   54848 at_status=$?
   54849 grep '^ *+' $at_stder1 >&2
   54850 grep -v '^ *+' $at_stder1 >$at_stderr
   54851 at_failed=false
   54852 echo stderr:; cat $at_stderr
   54853 $at_diff $at_devnull $at_stdout || at_failed=:
   54854 case $at_status in
   54855    77) echo 77 > $at_status_file
   54856             exit 77;;
   54857    0) ;;
   54858    *) echo "torture.at:478: exit code was $at_status, expected 0"
   54859       at_failed=:;;
   54860 esac
   54861 if $at_failed; then
   54862 
   54863   echo 1 > $at_status_file
   54864   exit 1
   54865 fi
   54866 
   54867 $at_traceon
   54868 
   54869 # Fails: beyond the limit of 10,000 (which we don't reach anyway since we
   54870 # multiply by two starting at 200 => 5120 is the possible).
   54871 $at_traceoff
   54872 echo "torture.at:481: \$PREPARSER ./input 10000"
   54873 echo torture.at:481 >$at_check_line_file
   54874 ( $at_traceon; $PREPARSER ./input 10000 ) >$at_stdout 2>$at_stder1
   54875 at_status=$?
   54876 grep '^ *+' $at_stder1 >&2
   54877 grep -v '^ *+' $at_stder1 >$at_stderr
   54878 at_failed=false
   54879 echo stderr:; cat $at_stderr
   54880 $at_diff $at_devnull $at_stdout || at_failed=:
   54881 case $at_status in
   54882    77) echo 77 > $at_status_file
   54883             exit 77;;
   54884    2) ;;
   54885    *) echo "torture.at:481: exit code was $at_status, expected 2"
   54886       at_failed=:;;
   54887 esac
   54888 if $at_failed; then
   54889 
   54890   echo 1 > $at_status_file
   54891   exit 1
   54892 fi
   54893 
   54894 $at_traceon
   54895 
   54896 
   54897       $at_traceoff
   54898       $at_times_p && times >$at_times_file
   54899     ) 5>&1 2>&1 | eval $at_tee_pipe
   54900     at_status=`cat $at_status_file`
   54901     ;;
   54902 
   54903 
   54904   banner-14 ) # Banner 14. existing.at:21
   54905     cat <<\_ATEOF
   54906 
   54907 Existing Grammars.
   54908 
   54909 _ATEOF
   54910     ;;
   54911 
   54912   110 ) # 110. existing.at:26: GNU AWK Grammar
   54913     at_setup_line='existing.at:26'
   54914     at_desc='GNU AWK Grammar'
   54915     $at_quiet $ECHO_N "110: GNU AWK Grammar                              $ECHO_C"
   54916     at_xfail=no
   54917     (
   54918       echo "110. existing.at:26: testing ..."
   54919       $at_traceon
   54920 
   54921 
   54922 # We have been careful to strip all the actions excepts the
   54923 # mid-rule actions.  We rely on %expect to check that there are
   54924 # indeed 65 SR conflicts.
   54925 #
   54926 # Bison was once wrong, due to an incorrect computation of nullable.
   54927 # It reported 485 SR conflicts!
   54928 
   54929 cat >input.y <<'_ATEOF'
   54930 %expect 65
   54931 
   54932 %token FUNC_CALL NAME REGEXP
   54933 %token ERROR
   54934 %token YNUMBER YSTRING
   54935 %token RELOP APPEND_OP
   54936 %token ASSIGNOP MATCHOP NEWLINE CONCAT_OP
   54937 %token LEX_BEGIN LEX_END LEX_IF LEX_ELSE LEX_RETURN LEX_DELETE
   54938 %token LEX_WHILE LEX_DO LEX_FOR LEX_BREAK LEX_CONTINUE
   54939 %token LEX_PRINT LEX_PRINTF LEX_NEXT LEX_EXIT LEX_FUNCTION
   54940 %token LEX_GETLINE LEX_NEXTFILE
   54941 %token LEX_IN
   54942 %token LEX_AND LEX_OR INCREMENT DECREMENT
   54943 %token LEX_BUILTIN LEX_LENGTH
   54944 
   54945 /* Lowest to highest */
   54946 %right ASSIGNOP
   54947 %right '?' ':'
   54948 %left LEX_OR
   54949 %left LEX_AND
   54950 %left LEX_GETLINE
   54951 %nonassoc LEX_IN
   54952 %left FUNC_CALL LEX_BUILTIN LEX_LENGTH
   54953 %nonassoc ','
   54954 %nonassoc MATCHOP
   54955 %nonassoc RELOP '<' '>' '|' APPEND_OP TWOWAYIO
   54956 %left CONCAT_OP
   54957 %left YSTRING YNUMBER
   54958 %left '+' '-'
   54959 %left '*' '/' '%'
   54960 %right '!' UNARY
   54961 %right '^'
   54962 %left INCREMENT DECREMENT
   54963 %left '$'
   54964 %left '(' ')'
   54965 %%
   54966 
   54967 start
   54968 	: opt_nls program opt_nls
   54969 	;
   54970 
   54971 program
   54972 	: rule
   54973 	| program rule
   54974 	| error
   54975 	| program error
   54976 	| /* empty */
   54977 	;
   54978 
   54979 rule
   54980 	: LEX_BEGIN {} action
   54981 	| LEX_END {}   action
   54982 	| LEX_BEGIN statement_term
   54983 	| LEX_END statement_term
   54984 	| pattern action
   54985 	| action
   54986 	| pattern statement_term
   54987 	| function_prologue function_body
   54988 	;
   54989 
   54990 func_name
   54991 	: NAME
   54992 	| FUNC_CALL
   54993 	| lex_builtin
   54994 	;
   54995 
   54996 lex_builtin
   54997 	: LEX_BUILTIN
   54998 	| LEX_LENGTH
   54999 	;
   55000 
   55001 function_prologue
   55002 	: LEX_FUNCTION {} func_name '(' opt_param_list r_paren opt_nls
   55003 	;
   55004 
   55005 function_body
   55006 	: l_brace statements r_brace opt_semi opt_nls
   55007 	| l_brace r_brace opt_semi opt_nls
   55008 	;
   55009 
   55010 pattern
   55011 	: exp
   55012 	| exp ',' exp
   55013 	;
   55014 
   55015 regexp
   55016 	/*
   55017 	 * In this rule, want_regexp tells yylex that the next thing
   55018 	 * is a regexp so it should read up to the closing slash.
   55019 	 */
   55020 	: '/' {} REGEXP '/'
   55021 	;
   55022 
   55023 action
   55024 	: l_brace statements r_brace opt_semi opt_nls
   55025 	| l_brace r_brace opt_semi opt_nls
   55026 	;
   55027 
   55028 statements
   55029 	: statement
   55030 	| statements statement
   55031 	| error
   55032 	| statements error
   55033 	;
   55034 
   55035 statement_term
   55036 	: nls
   55037 	| semi opt_nls
   55038 	;
   55039 
   55040 statement
   55041 	: semi opt_nls
   55042 	| l_brace r_brace
   55043 	| l_brace statements r_brace
   55044 	| if_statement
   55045 	| LEX_WHILE '(' exp r_paren opt_nls statement
   55046 	| LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls
   55047 	| LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement
   55048 	| LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement
   55049 	| LEX_FOR '(' opt_exp semi opt_nls semi opt_nls opt_exp r_paren opt_nls statement
   55050 	| LEX_BREAK statement_term
   55051 	| LEX_CONTINUE statement_term
   55052 	| print '(' expression_list r_paren output_redir statement_term
   55053 	| print opt_rexpression_list output_redir statement_term
   55054 	| LEX_NEXT statement_term
   55055 	| LEX_NEXTFILE statement_term
   55056 	| LEX_EXIT opt_exp statement_term
   55057 	| LEX_RETURN {} opt_exp statement_term
   55058 	| LEX_DELETE NAME '[' expression_list ']' statement_term
   55059 	| LEX_DELETE NAME  statement_term
   55060 	| exp statement_term
   55061 	;
   55062 
   55063 print
   55064 	: LEX_PRINT
   55065 	| LEX_PRINTF
   55066 	;
   55067 
   55068 if_statement
   55069 	: LEX_IF '(' exp r_paren opt_nls statement
   55070 	| LEX_IF '(' exp r_paren opt_nls statement
   55071 	     LEX_ELSE opt_nls statement
   55072 	;
   55073 
   55074 nls
   55075 	: NEWLINE
   55076 	| nls NEWLINE
   55077 	;
   55078 
   55079 opt_nls
   55080 	: /* empty */
   55081 	| nls
   55082 	;
   55083 
   55084 input_redir
   55085 	: /* empty */
   55086 	| '<' simp_exp
   55087 	;
   55088 
   55089 output_redir
   55090 	: /* empty */
   55091 	| '>' exp
   55092 	| APPEND_OP exp
   55093 	| '|' exp
   55094 	| TWOWAYIO exp
   55095 	;
   55096 
   55097 opt_param_list
   55098 	: /* empty */
   55099 	| param_list
   55100 	;
   55101 
   55102 param_list
   55103 	: NAME
   55104 	| param_list comma NAME
   55105 	| error
   55106 	| param_list error
   55107 	| param_list comma error
   55108 	;
   55109 
   55110 /* optional expression, as in for loop */
   55111 opt_exp
   55112 	: /* empty */
   55113 	| exp
   55114 	;
   55115 
   55116 opt_rexpression_list
   55117 	: /* empty */
   55118 	| rexpression_list
   55119 	;
   55120 
   55121 rexpression_list
   55122 	: rexp
   55123 	| rexpression_list comma rexp
   55124 	| error
   55125 	| rexpression_list error
   55126 	| rexpression_list error rexp
   55127 	| rexpression_list comma error
   55128 	;
   55129 
   55130 opt_expression_list
   55131 	: /* empty */
   55132 	| expression_list
   55133 	;
   55134 
   55135 expression_list
   55136 	: exp
   55137 	| expression_list comma exp
   55138 	| error
   55139 	| expression_list error
   55140 	| expression_list error exp
   55141 	| expression_list comma error
   55142 	;
   55143 
   55144 /* Expressions, not including the comma operator.  */
   55145 exp	: variable ASSIGNOP {} exp
   55146 	| '(' expression_list r_paren LEX_IN NAME
   55147 	| exp '|' LEX_GETLINE opt_variable
   55148 	| exp TWOWAYIO LEX_GETLINE opt_variable
   55149 	| LEX_GETLINE opt_variable input_redir
   55150 	| exp LEX_AND exp
   55151 	| exp LEX_OR exp
   55152 	| exp MATCHOP exp
   55153 	| regexp
   55154 	| '!' regexp %prec UNARY
   55155 	| exp LEX_IN NAME
   55156 	| exp RELOP exp
   55157 	| exp '<' exp
   55158 	| exp '>' exp
   55159 	| exp '?' exp ':' exp
   55160 	| simp_exp
   55161 	| exp simp_exp %prec CONCAT_OP
   55162 	;
   55163 
   55164 rexp
   55165 	: variable ASSIGNOP {} rexp
   55166 	| rexp LEX_AND rexp
   55167 	| rexp LEX_OR rexp
   55168 	| LEX_GETLINE opt_variable input_redir
   55169 	| regexp
   55170 	| '!' regexp %prec UNARY
   55171 	| rexp MATCHOP rexp
   55172 	| rexp LEX_IN NAME
   55173 	| rexp RELOP rexp
   55174 	| rexp '?' rexp ':' rexp
   55175 	| simp_exp
   55176 	| rexp simp_exp %prec CONCAT_OP
   55177 	;
   55178 
   55179 simp_exp
   55180 	: non_post_simp_exp
   55181 	/* Binary operators in order of decreasing precedence.  */
   55182 	| simp_exp '^' simp_exp
   55183 	| simp_exp '*' simp_exp
   55184 	| simp_exp '/' simp_exp
   55185 	| simp_exp '%' simp_exp
   55186 	| simp_exp '+' simp_exp
   55187 	| simp_exp '-' simp_exp
   55188 	| variable INCREMENT
   55189 	| variable DECREMENT
   55190 	;
   55191 
   55192 non_post_simp_exp
   55193 	: '!' simp_exp %prec UNARY
   55194 	| '(' exp r_paren
   55195 	| LEX_BUILTIN
   55196 	  '(' opt_expression_list r_paren
   55197 	| LEX_LENGTH '(' opt_expression_list r_paren
   55198 	| LEX_LENGTH
   55199 	| FUNC_CALL '(' opt_expression_list r_paren
   55200 	| variable
   55201 	| INCREMENT variable
   55202 	| DECREMENT variable
   55203 	| YNUMBER
   55204 	| YSTRING
   55205 	| '-' simp_exp    %prec UNARY
   55206 	| '+' simp_exp    %prec UNARY
   55207 	;
   55208 
   55209 opt_variable
   55210 	: /* empty */
   55211 	| variable
   55212 	;
   55213 
   55214 variable
   55215 	: NAME
   55216 	| NAME '[' expression_list ']'
   55217 	| '$' non_post_simp_exp
   55218 	;
   55219 
   55220 l_brace
   55221 	: '{' opt_nls
   55222 	;
   55223 
   55224 r_brace
   55225 	: '}' opt_nls
   55226 	;
   55227 
   55228 r_paren
   55229 	: ')'
   55230 	;
   55231 
   55232 opt_semi
   55233 	: /* empty */
   55234 	| semi
   55235 	;
   55236 
   55237 semi
   55238 	: ';'
   55239 	;
   55240 
   55241 comma	: ',' opt_nls
   55242 	;
   55243 
   55244 %%
   55245 _ATEOF
   55246 
   55247 
   55248 # Pass plenty of options, to exercise plenty of code, even if we
   55249 # don't actually check the output.  But SEGV is watching us, and
   55250 # so might do dmalloc.
   55251 $at_traceoff
   55252 echo "existing.at:356: bison --verbose --defines input.y"
   55253 echo existing.at:356 >$at_check_line_file
   55254 ( $at_traceon; bison --verbose --defines input.y ) >$at_stdout 2>$at_stder1
   55255 at_status=$?
   55256 grep '^ *+' $at_stder1 >&2
   55257 grep -v '^ *+' $at_stder1 >$at_stderr
   55258 at_failed=false
   55259 $at_diff $at_devnull $at_stderr || at_failed=:
   55260 $at_diff $at_devnull $at_stdout || at_failed=:
   55261 case $at_status in
   55262    77) echo 77 > $at_status_file
   55263             exit 77;;
   55264    0) ;;
   55265    *) echo "existing.at:356: exit code was $at_status, expected 0"
   55266       at_failed=:;;
   55267 esac
   55268 if $at_failed; then
   55269 
   55270   echo 1 > $at_status_file
   55271   exit 1
   55272 fi
   55273 
   55274 $at_traceon
   55275 
   55276 
   55277       $at_traceoff
   55278       $at_times_p && times >$at_times_file
   55279     ) 5>&1 2>&1 | eval $at_tee_pipe
   55280     at_status=`cat $at_status_file`
   55281     ;;
   55282 
   55283   111 ) # 111. existing.at:364: GNU Cim Grammar
   55284     at_setup_line='existing.at:364'
   55285     at_desc='GNU Cim Grammar'
   55286     $at_quiet $ECHO_N "111: GNU Cim Grammar                              $ECHO_C"
   55287     at_xfail=no
   55288     (
   55289       echo "111. existing.at:364: testing ..."
   55290       $at_traceon
   55291 
   55292 
   55293 # GNU Cim, the GNU Simula 87 Compiler.
   55294 
   55295 # Bison was once wrong, due to an incorrect computation of the RR conflicts.
   55296 # It reported 80 SR && 99 RR conflicts instead of 78/10!!!
   55297 
   55298 cat >input.y <<'_ATEOF'
   55299 %union {}
   55300 
   55301 %token
   55302 	HACTIVATE HAFTER /*HAND*/ HARRAY HAT
   55303 	HBEFORE HBEGIN HBOOLEAN
   55304 	HCHARACTER HCLASS /*HCOMMENT*/ HCONC
   55305 	HDELAY HDO
   55306 	HELSE HEND HEQ /*HEQV*/ HEXTERNAL
   55307 	HFOR
   55308 	HGE HGO HGOTO HGT
   55309 	HHIDDEN
   55310 	HIF /*HIMP*/ HIN HINNER HINSPECT HINTEGER HIS
   55311 	HLABEL HLE HLONG HLT
   55312 	HNAME HNE HNEW HNONE /*HNOT*/ HNOTEXT
   55313 	/*HOR*/ HOTHERWISE
   55314 	HPRIOR HPROCEDURE HPROTECTED
   55315 	HQUA
   55316 	HREACTIVATE HREAL HREF
   55317 	HSHORT HSTEP HSWITCH
   55318 	HTEXT HTHEN HTHIS HTO
   55319 	HUNTIL
   55320 	HVALUE HVAR HVIRTUAL
   55321 	HWHEN HWHILE
   55322 
   55323 	HASSIGNVALUE HASSIGNREF
   55324 	/*HDOT*/ HPAREXPSEPARATOR HLABELSEPARATOR HSTATEMENTSEPARATOR
   55325 	HBEGPAR HENDPAR
   55326 	HEQR HNER
   55327 	HADD HSUB HMUL HDIV HINTDIV HEXP
   55328 	HDOTDOTDOT
   55329 
   55330 %token HIDENTIFIER
   55331 %token HBOOLEANKONST HINTEGERKONST HCHARACTERKONST
   55332 %token HREALKONST
   55333 %token HTEXTKONST
   55334 
   55335 
   55336 %right HASSIGN
   55337 %left   HORELSE
   55338 %left   HANDTHEN
   55339 %left   HEQV
   55340 %left   HIMP
   55341 %left   HOR
   55342 %left   HAND
   55343 
   55344 %left   HNOT
   55345 
   55346 %left HVALRELOPERATOR HREFRELOPERATOR HOBJRELOPERATOR
   55347 
   55348 %left	HCONC
   55349 
   55350 %left HTERMOPERATOR
   55351 %left UNEAR
   55352 %left HFACTOROPERATOR
   55353 %left         HPRIMARYOPERATOR
   55354 
   55355 %left   HQUA
   55356 
   55357 %left   HDOT
   55358 
   55359 %start  MAIN_MODULE
   55360 %%
   55361 /* GRAMATIKK FOR PROGRAM MODULES */
   55362 MAIN_MODULE     :       {}
   55363 			MODULS
   55364 		|	error HSTATEMENTSEPARATOR MBEE_DECLSTMS
   55365 		;
   55366 EXT_DECLARATION	:	HEXTERNAL
   55367 			MBEE_TYPE
   55368 			HPROCEDURE
   55369 				{}
   55370 			EXT_LIST
   55371 		|
   55372 			HEXTERNAL
   55373 			HIDENTIFIER
   55374 			HPROCEDURE
   55375 				{}
   55376 			HIDENTIFIER {}
   55377 			EXTERNAL_KIND_ITEM
   55378 		|	HEXTERNAL
   55379 			HCLASS
   55380 				{}
   55381 			EXT_LIST
   55382 
   55383 		;
   55384 EXTERNAL_KIND_ITEM:	EXT_IDENT
   55385 			HOBJRELOPERATOR
   55386 				{}
   55387 			MBEE_TYPE HPROCEDURE
   55388 			HIDENTIFIER
   55389 				{}
   55390 			HEADING EMPTY_BLOCK
   55391 				{}
   55392 /*		|
   55393 			EXT_IDENT
   55394 				{}
   55395 			MBEE_REST_EXT_LIST
   55396 		;
   55397 MBEE_REST_EXT_LIST:	/* EMPTY
   55398 		|	HPAREXPSEPARATOR EXT_KIND_LIST
   55399 		;
   55400 EXT_KIND_LIST	:	EXT_KIND_ITEM
   55401 		|	EXT_KIND_LIST HPAREXPSEPARATOR EXT_KIND_ITEM
   55402 		;
   55403 EXT_KIND_ITEM	:	HIDENTIFIER
   55404 			EXT_IDENT
   55405 				{}*/
   55406 		;
   55407 EMPTY_BLOCK	:	/*EMPT*/
   55408 		|	HBEGIN HEND
   55409 		;
   55410 EXT_LIST	:	EXT_ITEM
   55411 		|	EXT_LIST HPAREXPSEPARATOR EXT_ITEM
   55412 		;
   55413 EXT_ITEM	:	HIDENTIFIER
   55414 			EXT_IDENT
   55415 		;
   55416 EXT_IDENT	:	/* EMPTY */
   55417 		|	HVALRELOPERATOR {}
   55418 			HTEXTKONST
   55419 		;
   55420 /* GRAMATIKK FOR TYPER */
   55421 NO_TYPE         :       /*EMPT*/
   55422 		;
   55423 MBEE_TYPE       :       NO_TYPE
   55424 		|       TYPE
   55425 		;
   55426 TYPE            :       HREF HBEGPAR
   55427 			HIDENTIFIER
   55428 				{}
   55429 			HENDPAR
   55430 		|       HTEXT
   55431 		|       HBOOLEAN
   55432 		|       HCHARACTER
   55433 		|       HSHORT HINTEGER
   55434 		|       HINTEGER
   55435 		|       HREAL
   55436 		|       HLONG HREAL
   55437 		;
   55438 
   55439 /* GRAMATIKK FOR DEL AV SETNINGER */
   55440 MBEE_ELSE_PART  :       /*EMPT*/
   55441 /*		|	HELSE
   55442 			HIF
   55443 			EXPRESSION
   55444 			HTHEN   {}
   55445 			BLOCK   {}
   55446 			MBEE_ELSE_PART          {}*/
   55447 		|       HELSE   {}
   55448 			BLOCK
   55449 		;
   55450 FOR_LIST        :       FOR_LIST_ELEMENT
   55451 		|       FOR_LIST_ELEMENT
   55452 			HPAREXPSEPARATOR
   55453 			FOR_LIST
   55454 		;
   55455 FOR_LIST_ELEMENT:       EXPRESSION
   55456 			MBEE_F_L_EL_R_PT
   55457 		;
   55458 MBEE_F_L_EL_R_PT:       /*EMPT*/
   55459 		|       HWHILE
   55460 			EXPRESSION
   55461 		|       HSTEP
   55462 			EXPRESSION
   55463 			HUNTIL
   55464 			EXPRESSION
   55465 		;
   55466 GOTO            :       HGO
   55467 			HTO
   55468 		|       HGOTO
   55469 		;
   55470 CONN_STATE_R_PT :       WHEN_CLAUSE_LIST
   55471 		|       HDO   {}
   55472 			BLOCK
   55473 		;
   55474 WHEN_CLAUSE_LIST:       HWHEN
   55475 			HIDENTIFIER
   55476 			HDO    {}
   55477 			BLOCK
   55478 		|       WHEN_CLAUSE_LIST
   55479 			HWHEN
   55480 			HIDENTIFIER
   55481 			HDO    {}
   55482 			BLOCK
   55483 		;
   55484 MBEE_OTWI_CLAUS :       /*EMPT*/
   55485 		|       HOTHERWISE {}
   55486 
   55487 			BLOCK
   55488 		;
   55489 ACTIVATOR	:	HACTIVATE
   55490 		|	HREACTIVATE
   55491 		;
   55492 SCHEDULE	:	/*EMPT*/
   55493 		|	ATDELAY EXPRESSION	{}
   55494 			PRIOR
   55495 		|	BEFOREAFTER		{}
   55496 			EXPRESSION
   55497 		;
   55498 ATDELAY		:	HAT
   55499 		|	HDELAY
   55500 		;
   55501 BEFOREAFTER	:	HBEFORE
   55502 		|	HAFTER
   55503 		;
   55504 PRIOR		:	/*EMPT*/
   55505 		|	HPRIOR
   55506 		;
   55507 /* GRAMATIKK FOR SETNINGER OG DEKLARASJONER */
   55508 MODULSTATEMENT  :       HWHILE
   55509 			EXPRESSION
   55510 			HDO     {}
   55511 			BLOCK
   55512 		|       HIF
   55513 			EXPRESSION
   55514 			HTHEN   {}
   55515 			BLOCK   {}
   55516 			MBEE_ELSE_PART
   55517 		|       HFOR
   55518 			HIDENTIFIER
   55519 			HASSIGN {}
   55520 			FOR_LIST
   55521 			HDO     {}
   55522 			BLOCK
   55523 		|       GOTO
   55524 			EXPRESSION
   55525 		|       HINSPECT
   55526 			EXPRESSION              {}
   55527 			CONN_STATE_R_PT
   55528 				{}
   55529 			MBEE_OTWI_CLAUS
   55530 		|       HINNER
   55531 		|       HIDENTIFIER
   55532 			HLABELSEPARATOR
   55533 				{}
   55534 			DECLSTATEMENT
   55535 		|       EXPRESSION_SIMP
   55536 			HBEGIN
   55537 				{}
   55538 			IMPORT_SPEC_MODULE
   55539 				{}
   55540 			MBEE_DECLSTMS
   55541 			HEND
   55542 		|	EXPRESSION_SIMP HBEGIN error HSTATEMENTSEPARATOR
   55543 			MBEE_DECLSTMS HEND
   55544 		|	EXPRESSION_SIMP HBEGIN error HEND
   55545 		|       EXPRESSION_SIMP
   55546 		|	ACTIVATOR EXPRESSION SCHEDULE
   55547 		|       HBEGIN
   55548 				{}
   55549 			MBEE_DECLSTMS
   55550 			HEND
   55551 		|       MBEE_TYPE HPROCEDURE
   55552 			HIDENTIFIER
   55553 				{}
   55554 			HEADING BLOCK
   55555 		|       HIDENTIFIER
   55556 			HCLASS
   55557 			NO_TYPE
   55558 				{}
   55559 			IMPORT_SPEC_MODULE
   55560 			HIDENTIFIER
   55561 				{}
   55562 			HEADING
   55563 			BLOCK
   55564 		|       HCLASS
   55565 			NO_TYPE
   55566 			HIDENTIFIER
   55567 				{}
   55568 			HEADING
   55569 			BLOCK
   55570 		|       EXT_DECLARATION
   55571 		|       /*EMPT*/
   55572 		;
   55573 IMPORT_SPEC_MODULE:
   55574 		;
   55575 DECLSTATEMENT	:	MODULSTATEMENT
   55576 		|       TYPE
   55577 			HIDENTIFIER
   55578 			MBEE_CONSTANT
   55579 			HPAREXPSEPARATOR
   55580 				{}
   55581 			IDENTIFIER_LISTC
   55582 		|       TYPE
   55583 			HIDENTIFIER
   55584 			MBEE_CONSTANT
   55585 		|       MBEE_TYPE
   55586 			HARRAY  {}
   55587 			ARR_SEGMENT_LIST
   55588 		|       HSWITCH
   55589 			HIDENTIFIER
   55590 			HASSIGN {}
   55591 			SWITCH_LIST
   55592 		;
   55593 BLOCK           :       DECLSTATEMENT
   55594 		|       HBEGIN MBEE_DECLSTMS HEND
   55595 		|	HBEGIN error HSTATEMENTSEPARATOR MBEE_DECLSTMS HEND
   55596 		|	HBEGIN error HEND
   55597 		;
   55598 MBEE_DECLSTMS   :       MBEE_DECLSTMSU
   55599 		;
   55600 MBEE_DECLSTMSU  :       DECLSTATEMENT
   55601 		|       MBEE_DECLSTMSU
   55602 			HSTATEMENTSEPARATOR
   55603 			DECLSTATEMENT
   55604 		;
   55605 MODULS		:	MODULSTATEMENT
   55606 		|	MODULS HSTATEMENTSEPARATOR MODULSTATEMENT
   55607 		;
   55608 /* GRAMATIKK FOR DEL AV DEKLARASJONER */
   55609 ARR_SEGMENT_LIST:       ARR_SEGMENT
   55610 		|       ARR_SEGMENT_LIST
   55611 			HPAREXPSEPARATOR
   55612 			ARR_SEGMENT
   55613 		;
   55614 ARR_SEGMENT	:       ARRAY_SEGMENT
   55615 			HBEGPAR
   55616 			BAUND_PAIR_LIST HENDPAR
   55617 		;
   55618 ARRAY_SEGMENT   :       ARRAY_SEGMENT_EL        {}
   55619 
   55620 		|       ARRAY_SEGMENT_EL
   55621 			HPAREXPSEPARATOR
   55622 			ARRAY_SEGMENT
   55623 		;
   55624 ARRAY_SEGMENT_EL:       HIDENTIFIER
   55625 		;
   55626 BAUND_PAIR_LIST :       BAUND_PAIR
   55627 		|       BAUND_PAIR
   55628 			HPAREXPSEPARATOR
   55629 			BAUND_PAIR_LIST
   55630 		;
   55631 BAUND_PAIR      :       EXPRESSION
   55632 			HLABELSEPARATOR
   55633 			EXPRESSION
   55634 		;
   55635 SWITCH_LIST     :       EXPRESSION
   55636 		|       EXPRESSION
   55637 			HPAREXPSEPARATOR
   55638 			SWITCH_LIST
   55639 		;
   55640 HEADING         :       MBEE_FMAL_PAR_P HSTATEMENTSEPARATOR {}
   55641 			MBEE_MODE_PART  {}
   55642 			MBEE_SPEC_PART  {}
   55643 			MBEE_PROT_PART  {}
   55644 			MBEE_VIRT_PART
   55645 		;
   55646 MBEE_FMAL_PAR_P :       /*EMPT*/
   55647 		|       FMAL_PAR_PART
   55648 		;
   55649 FMAL_PAR_PART   :       HBEGPAR NO_TYPE
   55650 			MBEE_LISTV HENDPAR
   55651 		;
   55652 MBEE_LISTV      :       /*EMPT*/
   55653 		|       LISTV
   55654 		;
   55655 LISTV           :       HIDENTIFIER
   55656 		|	FPP_CATEG HDOTDOTDOT
   55657 		|       HIDENTIFIER     {}
   55658 			HPAREXPSEPARATOR LISTV
   55659 		|       FPP_SPEC
   55660 		|       FPP_SPEC
   55661 			HPAREXPSEPARATOR LISTV
   55662 		;
   55663 FPP_HEADING     :       HBEGPAR NO_TYPE
   55664 			FPP_MBEE_LISTV HENDPAR
   55665 		;
   55666 FPP_MBEE_LISTV  :       /*EMPT*/
   55667 		|       FPP_LISTV
   55668 		;
   55669 FPP_LISTV       :	FPP_CATEG HDOTDOTDOT
   55670 		|       FPP_SPEC
   55671 		|       FPP_SPEC
   55672 			HPAREXPSEPARATOR LISTV
   55673 		;
   55674 FPP_SPEC        :       FPP_CATEG SPECIFIER HIDENTIFIER
   55675 		|	FPP_CATEG FPP_PROC_DECL_IN_SPEC
   55676 		;
   55677 FPP_CATEG       :       HNAME HLABELSEPARATOR
   55678 		|       HVALUE HLABELSEPARATOR
   55679 		|       HVAR HLABELSEPARATOR
   55680 		|       /*EMPT*/
   55681 		;
   55682 FPP_PROC_DECL_IN_SPEC:	MBEE_TYPE HPROCEDURE
   55683 			HIDENTIFIER
   55684 					{}
   55685 			FPP_HEADING {} { /* Yes, two "final" actions. */ }
   55686 		;
   55687 IDENTIFIER_LISTV:       HIDENTIFIER
   55688 		|	HDOTDOTDOT
   55689 		|       HIDENTIFIER     {}
   55690 			HPAREXPSEPARATOR IDENTIFIER_LISTV
   55691 		;
   55692 MBEE_MODE_PART  :       /*EMPT*/
   55693 		|       MODE_PART
   55694 		;
   55695 MODE_PART       :       NAME_PART
   55696 		|       VALUE_PART
   55697 		|       VAR_PART
   55698 		|       NAME_PART VALUE_PART
   55699 		|       VALUE_PART NAME_PART
   55700 		|       NAME_PART VAR_PART
   55701 		|       VAR_PART NAME_PART
   55702 		|       VALUE_PART VAR_PART
   55703 		|       VAR_PART VALUE_PART
   55704 		|       VAR_PART NAME_PART VALUE_PART
   55705 		|       NAME_PART VAR_PART VALUE_PART
   55706 		|       NAME_PART VALUE_PART VAR_PART
   55707 		|       VAR_PART VALUE_PART NAME_PART
   55708 		|       VALUE_PART VAR_PART NAME_PART
   55709 		|       VALUE_PART NAME_PART VAR_PART
   55710 		;
   55711 NAME_PART       :       HNAME           {}
   55712 			IDENTIFIER_LISTV
   55713 			HSTATEMENTSEPARATOR
   55714 		;
   55715 VAR_PART        :       HVAR            {}
   55716 			IDENTIFIER_LISTV
   55717 			HSTATEMENTSEPARATOR
   55718 		;
   55719 VALUE_PART      :       HVALUE          {}
   55720 			IDENTIFIER_LISTV HSTATEMENTSEPARATOR
   55721 		;
   55722 MBEE_SPEC_PART  :       /*EMPT*/
   55723 		|       SPEC_PART
   55724 		;
   55725 SPEC_PART       :       ONE_SPEC
   55726 		|       SPEC_PART ONE_SPEC
   55727 		;
   55728 ONE_SPEC	:	SPECIFIER IDENTIFIER_LIST HSTATEMENTSEPARATOR
   55729 		|	NO_TYPE HPROCEDURE HIDENTIFIER HOBJRELOPERATOR
   55730 			  {}
   55731 			PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR
   55732 		|       FPP_PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR
   55733 		|       MBEE_TYPE HPROCEDURE HIDENTIFIER HSTATEMENTSEPARATOR
   55734 		|       MBEE_TYPE HPROCEDURE HIDENTIFIER HPAREXPSEPARATOR
   55735 			IDENTIFIER_LIST HSTATEMENTSEPARATOR
   55736 		;
   55737 SPECIFIER       :       TYPE
   55738 		|       MBEE_TYPE
   55739 			HARRAY
   55740 		|       HLABEL
   55741 		|       HSWITCH
   55742 		;
   55743 PROC_DECL_IN_SPEC:	MBEE_TYPE HPROCEDURE
   55744 			HIDENTIFIER
   55745 					{}
   55746 			HEADING
   55747 					{}
   55748 			MBEE_BEGIN_END
   55749 		;
   55750 MBEE_BEGIN_END	:	/* EMPTY */
   55751 		|	HBEGIN HEND
   55752 		;
   55753 MBEE_PROT_PART  :       /*EMPT*/
   55754 		|       PROTECTION_PART
   55755 		;
   55756 PROTECTION_PART :       PROT_SPECIFIER IDENTIFIER_LIST
   55757 			HSTATEMENTSEPARATOR
   55758 		|       PROTECTION_PART  PROT_SPECIFIER
   55759 			IDENTIFIER_LIST HSTATEMENTSEPARATOR
   55760 		;
   55761 PROT_SPECIFIER  :       HHIDDEN
   55762 		|       HPROTECTED
   55763 		|       HHIDDEN
   55764 			HPROTECTED
   55765 		|       HPROTECTED
   55766 			HHIDDEN
   55767 		;
   55768 MBEE_VIRT_PART  :       /*EMPT*/
   55769 		|       VIRTUAL_PART
   55770 		;
   55771 VIRTUAL_PART    :       HVIRTUAL
   55772 			HLABELSEPARATOR
   55773 			MBEE_SPEC_PART
   55774 		;
   55775 IDENTIFIER_LIST :       HIDENTIFIER
   55776 		|       IDENTIFIER_LIST HPAREXPSEPARATOR
   55777 			HIDENTIFIER
   55778 		;
   55779 IDENTIFIER_LISTC:       HIDENTIFIER
   55780 			MBEE_CONSTANT
   55781 		|       IDENTIFIER_LISTC HPAREXPSEPARATOR
   55782 			HIDENTIFIER
   55783 			MBEE_CONSTANT
   55784 		;
   55785 MBEE_CONSTANT	:	/* EMPTY */
   55786 		|	HVALRELOPERATOR
   55787 				{}
   55788 			EXPRESSION
   55789 		;
   55790 
   55791 /* GRAMATIKK FOR UTTRYKK */
   55792 EXPRESSION      :       EXPRESSION_SIMP
   55793 		|       HIF
   55794 			EXPRESSION
   55795 			HTHEN
   55796 			EXPRESSION
   55797 			HELSE
   55798 			EXPRESSION
   55799 		;
   55800 EXPRESSION_SIMP :	EXPRESSION_SIMP
   55801 			HASSIGN
   55802 			EXPRESSION
   55803 		|
   55804 
   55805 			EXPRESSION_SIMP
   55806 			HCONC
   55807 			EXPRESSION_SIMP
   55808 		|       EXPRESSION_SIMP HOR
   55809 			HELSE
   55810 			EXPRESSION_SIMP
   55811 			%prec HORELSE
   55812 		|       EXPRESSION_SIMP HAND
   55813 			HTHEN
   55814 			EXPRESSION_SIMP
   55815 			%prec HANDTHEN
   55816 		|       EXPRESSION_SIMP
   55817 			HEQV EXPRESSION_SIMP
   55818 		|       EXPRESSION_SIMP
   55819 			HIMP EXPRESSION_SIMP
   55820 		|       EXPRESSION_SIMP
   55821 			HOR EXPRESSION_SIMP
   55822 		|       EXPRESSION_SIMP
   55823 			HAND EXPRESSION_SIMP
   55824 		|       HNOT EXPRESSION_SIMP
   55825 		|       EXPRESSION_SIMP
   55826 			HVALRELOPERATOR
   55827 			EXPRESSION_SIMP
   55828 		|       EXPRESSION_SIMP
   55829 			HREFRELOPERATOR
   55830 			EXPRESSION_SIMP
   55831 		|       EXPRESSION_SIMP
   55832 			HOBJRELOPERATOR
   55833 			EXPRESSION_SIMP
   55834 		|       HTERMOPERATOR
   55835 			EXPRESSION_SIMP %prec UNEAR
   55836 		|       EXPRESSION_SIMP
   55837 			HTERMOPERATOR
   55838 			EXPRESSION_SIMP
   55839 		|       EXPRESSION_SIMP
   55840 			HFACTOROPERATOR
   55841 			EXPRESSION_SIMP
   55842 		|       EXPRESSION_SIMP
   55843 			HPRIMARYOPERATOR
   55844 			EXPRESSION_SIMP
   55845 		|       HBEGPAR
   55846 			EXPRESSION HENDPAR
   55847 		|       HTEXTKONST
   55848 		|       HCHARACTERKONST
   55849 		|       HREALKONST
   55850 		|       HINTEGERKONST
   55851 		|       HBOOLEANKONST
   55852 		|       HNONE
   55853 		|       HIDENTIFIER
   55854 				{}
   55855 			MBEE_ARG_R_PT
   55856 		|       HTHIS HIDENTIFIER
   55857 		|       HNEW
   55858 			HIDENTIFIER
   55859 			ARG_R_PT
   55860 		|       EXPRESSION_SIMP
   55861 			HDOT
   55862 			EXPRESSION_SIMP
   55863 		|       EXPRESSION_SIMP
   55864 			HQUA HIDENTIFIER
   55865 		;
   55866 ARG_R_PT        :       /*EMPTY*/
   55867 		|       HBEGPAR
   55868 			ARGUMENT_LIST HENDPAR
   55869 		;
   55870 MBEE_ARG_R_PT   :       /*EMPTY*/
   55871 		|       HBEGPAR
   55872 			ARGUMENT_LIST HENDPAR
   55873 		;
   55874 ARGUMENT_LIST   :       EXPRESSION
   55875 		|       EXPRESSION
   55876 			HPAREXPSEPARATOR
   55877 			ARGUMENT_LIST
   55878 		;
   55879 %%
   55880 _ATEOF
   55881 
   55882 
   55883 # Pass plenty of options, to exercise plenty of code, even if we
   55884 # don't actually check the output.  But SEGV is watching us, and
   55885 # so might do dmalloc.
   55886 $at_traceoff
   55887 echo "existing.at:960: bison --verbose --defines input.y"
   55888 echo existing.at:960 >$at_check_line_file
   55889 ( $at_traceon; bison --verbose --defines input.y ) >$at_stdout 2>$at_stder1
   55890 at_status=$?
   55891 grep '^ *+' $at_stder1 >&2
   55892 grep -v '^ *+' $at_stder1 >$at_stderr
   55893 at_failed=false
   55894 echo >>$at_stderr; echo "input.y: conflicts: 78 shift/reduce, 10 reduce/reduce
   55895 " | $at_diff - $at_stderr || at_failed=:
   55896 $at_diff $at_devnull $at_stdout || at_failed=:
   55897 case $at_status in
   55898    77) echo 77 > $at_status_file
   55899             exit 77;;
   55900    0) ;;
   55901    *) echo "existing.at:960: exit code was $at_status, expected 0"
   55902       at_failed=:;;
   55903 esac
   55904 if $at_failed; then
   55905 
   55906   echo 1 > $at_status_file
   55907   exit 1
   55908 fi
   55909 
   55910 $at_traceon
   55911 
   55912 
   55913 $at_traceoff
   55914 echo "existing.at:972: grep '^State.*conflicts:' input.output"
   55915 echo existing.at:972 >$at_check_line_file
   55916 ( $at_traceon; grep '^State.*conflicts:' input.output ) >$at_stdout 2>$at_stder1
   55917 at_status=$?
   55918 grep '^ *+' $at_stder1 >&2
   55919 grep -v '^ *+' $at_stder1 >$at_stderr
   55920 at_failed=false
   55921 $at_diff $at_devnull $at_stderr || at_failed=:
   55922 echo >>$at_stdout; echo "State 64 conflicts: 14 shift/reduce
   55923 State 164 conflicts: 1 shift/reduce
   55924 State 201 conflicts: 33 shift/reduce, 4 reduce/reduce
   55925 State 206 conflicts: 1 shift/reduce
   55926 State 240 conflicts: 1 shift/reduce
   55927 State 335 conflicts: 9 shift/reduce, 2 reduce/reduce
   55928 State 356 conflicts: 1 shift/reduce
   55929 State 360 conflicts: 9 shift/reduce, 2 reduce/reduce
   55930 State 427 conflicts: 9 shift/reduce, 2 reduce/reduce
   55931 " | $at_diff - $at_stdout || at_failed=:
   55932 case $at_status in
   55933    77) echo 77 > $at_status_file
   55934             exit 77;;
   55935    0) ;;
   55936    *) echo "existing.at:972: exit code was $at_status, expected 0"
   55937       at_failed=:;;
   55938 esac
   55939 if $at_failed; then
   55940 
   55941   echo 1 > $at_status_file
   55942   exit 1
   55943 fi
   55944 
   55945 $at_traceon
   55946 
   55947 
   55948       $at_traceoff
   55949       $at_times_p && times >$at_times_file
   55950     ) 5>&1 2>&1 | eval $at_tee_pipe
   55951     at_status=`cat $at_status_file`
   55952     ;;
   55953 
   55954   112 ) # 112. existing.at:980: GNU pic Grammar
   55955     at_setup_line='existing.at:980'
   55956     at_desc='GNU pic Grammar'
   55957     $at_quiet $ECHO_N "112: GNU pic Grammar                              $ECHO_C"
   55958     at_xfail=no
   55959     (
   55960       echo "112. existing.at:980: testing ..."
   55961       $at_traceon
   55962 
   55963 
   55964 # GNU pic, part of groff.
   55965 
   55966 # Bison once reported shift/reduce conflicts that it shouldn't have.
   55967 
   55968 cat >input.y <<'_ATEOF'
   55969 %union {}
   55970 
   55971 %token LABEL
   55972 %token VARIABLE
   55973 %token NUMBER
   55974 %token TEXT
   55975 %token COMMAND_LINE
   55976 %token DELIMITED
   55977 %token ORDINAL
   55978 %token TH
   55979 %token LEFT_ARROW_HEAD
   55980 %token RIGHT_ARROW_HEAD
   55981 %token DOUBLE_ARROW_HEAD
   55982 %token LAST
   55983 %token UP
   55984 %token DOWN
   55985 %token LEFT
   55986 %token RIGHT
   55987 %token BOX
   55988 %token CIRCLE
   55989 %token ELLIPSE
   55990 %token ARC
   55991 %token LINE
   55992 %token ARROW
   55993 %token MOVE
   55994 %token SPLINE
   55995 %token HEIGHT
   55996 %token RADIUS
   55997 %token WIDTH
   55998 %token DIAMETER
   55999 %token FROM
   56000 %token TO
   56001 %token AT
   56002 %token WITH
   56003 %token BY
   56004 %token THEN
   56005 %token SOLID
   56006 %token DOTTED
   56007 %token DASHED
   56008 %token CHOP
   56009 %token SAME
   56010 %token INVISIBLE
   56011 %token LJUST
   56012 %token RJUST
   56013 %token ABOVE
   56014 %token BELOW
   56015 %token OF
   56016 %token THE
   56017 %token WAY
   56018 %token BETWEEN
   56019 %token AND
   56020 %token HERE
   56021 %token DOT_N
   56022 %token DOT_E
   56023 %token DOT_W
   56024 %token DOT_S
   56025 %token DOT_NE
   56026 %token DOT_SE
   56027 %token DOT_NW
   56028 %token DOT_SW
   56029 %token DOT_C
   56030 %token DOT_START
   56031 %token DOT_END
   56032 %token DOT_X
   56033 %token DOT_Y
   56034 %token DOT_HT
   56035 %token DOT_WID
   56036 %token DOT_RAD
   56037 %token SIN
   56038 %token COS
   56039 %token ATAN2
   56040 %token LOG
   56041 %token EXP
   56042 %token SQRT
   56043 %token K_MAX
   56044 %token K_MIN
   56045 %token INT
   56046 %token RAND
   56047 %token SRAND
   56048 %token COPY
   56049 %token THRU
   56050 %token TOP
   56051 %token BOTTOM
   56052 %token UPPER
   56053 %token LOWER
   56054 %token SH
   56055 %token PRINT
   56056 %token CW
   56057 %token CCW
   56058 %token FOR
   56059 %token DO
   56060 %token IF
   56061 %token ELSE
   56062 %token ANDAND
   56063 %token OROR
   56064 %token NOTEQUAL
   56065 %token EQUALEQUAL
   56066 %token LESSEQUAL
   56067 %token GREATEREQUAL
   56068 %token LEFT_CORNER
   56069 %token RIGHT_CORNER
   56070 %token NORTH
   56071 %token SOUTH
   56072 %token EAST
   56073 %token WEST
   56074 %token CENTER
   56075 %token END
   56076 %token START
   56077 %token RESET
   56078 %token UNTIL
   56079 %token PLOT
   56080 %token THICKNESS
   56081 %token FILL
   56082 %token COLORED
   56083 %token OUTLINED
   56084 %token SHADED
   56085 %token ALIGNED
   56086 %token SPRINTF
   56087 %token COMMAND
   56088 
   56089 %left '.'
   56090 
   56091 /* this ensures that plot 17 "%g" parses as (plot 17 "%g") */
   56092 %left PLOT
   56093 %left TEXT SPRINTF
   56094 
   56095 /* give text adjustments higher precedence than TEXT, so that
   56096 box "foo" above ljust == box ("foo" above ljust)
   56097 */
   56098 
   56099 %left LJUST RJUST ABOVE BELOW
   56100 
   56101 %left LEFT RIGHT
   56102 /* Give attributes that take an optional expression a higher
   56103 precedence than left and right, so that eg `line chop left'
   56104 parses properly. */
   56105 %left CHOP SOLID DASHED DOTTED UP DOWN FILL COLORED OUTLINED
   56106 %left LABEL
   56107 
   56108 %left VARIABLE NUMBER '(' SIN COS ATAN2 LOG EXP SQRT K_MAX K_MIN INT RAND SRAND LAST
   56109 %left ORDINAL HERE '`'
   56110 
   56111 %left BOX CIRCLE ELLIPSE ARC LINE ARROW SPLINE '[' /* ] */
   56112 
   56113 /* these need to be lower than '-' */
   56114 %left HEIGHT RADIUS WIDTH DIAMETER FROM TO AT THICKNESS
   56115 
   56116 /* these must have higher precedence than CHOP so that `label %prec CHOP'
   56117 works */
   56118 %left DOT_N DOT_E DOT_W DOT_S DOT_NE DOT_SE DOT_NW DOT_SW DOT_C
   56119 %left DOT_START DOT_END TOP BOTTOM LEFT_CORNER RIGHT_CORNER
   56120 %left UPPER LOWER NORTH SOUTH EAST WEST CENTER START END
   56121 
   56122 %left ','
   56123 %left OROR
   56124 %left ANDAND
   56125 %left EQUALEQUAL NOTEQUAL
   56126 %left '<' '>' LESSEQUAL GREATEREQUAL
   56127 
   56128 %left BETWEEN OF
   56129 %left AND
   56130 
   56131 %left '+' '-'
   56132 %left '*' '/' '%'
   56133 %right '!'
   56134 %right '^'
   56135 
   56136 %%
   56137 
   56138 top:
   56139 	optional_separator
   56140 	| element_list
   56141 	;
   56142 
   56143 element_list:
   56144 	optional_separator middle_element_list optional_separator
   56145 	;
   56146 
   56147 middle_element_list:
   56148 	element
   56149 	| middle_element_list separator element
   56150 	;
   56151 
   56152 optional_separator:
   56153 	/* empty */
   56154 	| separator
   56155 	;
   56156 
   56157 separator:
   56158 	';'
   56159 	| separator ';'
   56160 	;
   56161 
   56162 placeless_element:
   56163 	VARIABLE '=' any_expr
   56164 	| VARIABLE ':' '=' any_expr
   56165 	| UP
   56166 	| DOWN
   56167 	| LEFT
   56168 	| RIGHT
   56169 	| COMMAND_LINE
   56170 	| COMMAND print_args
   56171 	| PRINT print_args
   56172 	| SH
   56173 		{}
   56174 	  DELIMITED
   56175 	| COPY TEXT
   56176 	| COPY TEXT THRU
   56177 		{}
   56178 	  DELIMITED
   56179 		{}
   56180 	  until
   56181 	| COPY THRU
   56182 		{}
   56183 	  DELIMITED
   56184 		{}
   56185 	  until
   56186 	| FOR VARIABLE '=' expr TO expr optional_by DO
   56187 		{}
   56188 	  DELIMITED
   56189 	| simple_if
   56190 	| simple_if ELSE
   56191 		{}
   56192 	  DELIMITED
   56193 	| reset_variables
   56194 	| RESET
   56195 	;
   56196 
   56197 reset_variables:
   56198 	RESET VARIABLE
   56199 	| reset_variables VARIABLE
   56200 	| reset_variables ',' VARIABLE
   56201 	;
   56202 
   56203 print_args:
   56204 	print_arg
   56205 	| print_args print_arg
   56206 	;
   56207 
   56208 print_arg:
   56209 	expr							%prec ','
   56210 	| text
   56211 	| position						%prec ','
   56212 	;
   56213 
   56214 simple_if:
   56215 	IF any_expr THEN
   56216 		{}
   56217 	DELIMITED
   56218 	;
   56219 
   56220 until:
   56221 	/* empty */
   56222 	| UNTIL TEXT
   56223 	;
   56224 
   56225 any_expr:
   56226 	expr
   56227 	| text_expr
   56228 	;
   56229 
   56230 text_expr:
   56231 	text EQUALEQUAL text
   56232 	| text NOTEQUAL text
   56233 	| text_expr ANDAND text_expr
   56234 	| text_expr ANDAND expr
   56235 	| expr ANDAND text_expr
   56236 	| text_expr OROR text_expr
   56237 	| text_expr OROR expr
   56238 	| expr OROR text_expr
   56239 	| '!' text_expr
   56240 	;
   56241 
   56242 optional_by:
   56243 	/* empty */
   56244 	| BY expr
   56245 	| BY '*' expr
   56246 	;
   56247 
   56248 element:
   56249 	object_spec
   56250 	| LABEL ':' optional_separator element
   56251 	| LABEL ':' optional_separator position_not_place
   56252 	| LABEL ':' optional_separator place
   56253 	| '{}'
   56254 		{}
   56255 	  optional_element
   56256 	| placeless_element
   56257 	;
   56258 
   56259 optional_element:
   56260 	/* empty */
   56261 	| element
   56262 	;
   56263 
   56264 object_spec:
   56265 	BOX
   56266 	| CIRCLE
   56267 	| ELLIPSE
   56268 	| ARC
   56269 	| LINE
   56270 	| ARROW
   56271 	| MOVE
   56272 	| SPLINE
   56273 	| text							%prec TEXT
   56274 	| PLOT expr
   56275 	| PLOT expr text
   56276 	| '['
   56277 		{}
   56278 	  element_list ']'
   56279 	| object_spec HEIGHT expr
   56280 	| object_spec RADIUS expr
   56281 	| object_spec WIDTH expr
   56282 	| object_spec DIAMETER expr
   56283 	| object_spec expr					%prec HEIGHT
   56284 	| object_spec UP
   56285 	| object_spec UP expr
   56286 	| object_spec DOWN
   56287 	| object_spec DOWN expr
   56288 	| object_spec RIGHT
   56289 	| object_spec RIGHT expr
   56290 	| object_spec LEFT
   56291 	| object_spec LEFT expr
   56292 	| object_spec FROM position
   56293 	| object_spec TO position
   56294 	| object_spec AT position
   56295 	| object_spec WITH path
   56296 	| object_spec WITH position				%prec ','
   56297 	| object_spec BY expr_pair
   56298 	| object_spec THEN
   56299 	| object_spec SOLID
   56300 	| object_spec DOTTED
   56301 	| object_spec DOTTED expr
   56302 	| object_spec DASHED
   56303 	| object_spec DASHED expr
   56304 	| object_spec FILL
   56305 	| object_spec FILL expr
   56306 	| object_spec SHADED text
   56307 	| object_spec COLORED text
   56308 	| object_spec OUTLINED text
   56309 	| object_spec CHOP
   56310 	| object_spec CHOP expr
   56311 	| object_spec SAME
   56312 	| object_spec INVISIBLE
   56313 	| object_spec LEFT_ARROW_HEAD
   56314 	| object_spec RIGHT_ARROW_HEAD
   56315 	| object_spec DOUBLE_ARROW_HEAD
   56316 	| object_spec CW
   56317 	| object_spec CCW
   56318 	| object_spec text					%prec TEXT
   56319 	| object_spec LJUST
   56320 	| object_spec RJUST
   56321 	| object_spec ABOVE
   56322 	| object_spec BELOW
   56323 	| object_spec THICKNESS expr
   56324 	| object_spec ALIGNED
   56325 	;
   56326 
   56327 text:
   56328 	TEXT
   56329 	| SPRINTF '(' TEXT sprintf_args ')'
   56330 	;
   56331 
   56332 sprintf_args:
   56333 	/* empty */
   56334 	| sprintf_args ',' expr
   56335 	;
   56336 
   56337 position:
   56338 	position_not_place
   56339 	| place
   56340 	;
   56341 
   56342 position_not_place:
   56343 	expr_pair
   56344 	| position '+' expr_pair
   56345 	| position '-' expr_pair
   56346 	| '(' position ',' position ')'
   56347 	| expr between position AND position
   56348 	| expr '<' position ',' position '>'
   56349 	;
   56350 
   56351 between:
   56352 	BETWEEN
   56353 	| OF THE WAY BETWEEN
   56354 	;
   56355 
   56356 expr_pair:
   56357 	expr ',' expr
   56358 	| '(' expr_pair ')'
   56359 	;
   56360 
   56361 place:
   56362 	/* line at A left == line (at A) left */
   56363 	label							%prec CHOP
   56364 	| label corner
   56365 	| corner label
   56366 	| corner OF label
   56367 	| HERE
   56368 	;
   56369 
   56370 label:
   56371 	LABEL
   56372 	| nth_primitive
   56373 	| label '.' LABEL
   56374 	;
   56375 
   56376 ordinal:
   56377 	ORDINAL
   56378 	| '`' any_expr TH
   56379 	;
   56380 
   56381 optional_ordinal_last:
   56382 	LAST
   56383 	| ordinal LAST
   56384 	;
   56385 
   56386 nth_primitive:
   56387 	ordinal object_type
   56388 	| optional_ordinal_last object_type
   56389 	;
   56390 
   56391 object_type:
   56392 	BOX
   56393 	| CIRCLE
   56394 	| ELLIPSE
   56395 	| ARC
   56396 	| LINE
   56397 	| ARROW
   56398 	| SPLINE
   56399 	| '[' ']'
   56400 	| TEXT
   56401 	;
   56402 
   56403 label_path:
   56404 	'.' LABEL
   56405 	| label_path '.' LABEL
   56406 	;
   56407 
   56408 relative_path:
   56409 	corner							%prec CHOP
   56410 	/* give this a lower precedence than LEFT and RIGHT so that
   56411 	   [A: box] with .A left == [A: box] with (.A left) */
   56412 	| label_path						%prec TEXT
   56413 	| label_path corner
   56414 	;
   56415 
   56416 path:
   56417 	relative_path
   56418 	| '(' relative_path ',' relative_path ')'
   56419 		{}
   56420 	/* The rest of these rules are a compatibility sop. */
   56421 	| ORDINAL LAST object_type relative_path
   56422 	| LAST object_type relative_path
   56423 	| ORDINAL object_type relative_path
   56424 	| LABEL relative_path
   56425 	;
   56426 
   56427 corner:
   56428 	DOT_N
   56429 	| DOT_E
   56430 	| DOT_W
   56431 	| DOT_S
   56432 	| DOT_NE
   56433 	| DOT_SE
   56434 	| DOT_NW
   56435 	| DOT_SW
   56436 	| DOT_C
   56437 	| DOT_START
   56438 	| DOT_END
   56439 	| TOP
   56440 	| BOTTOM
   56441 	| LEFT
   56442 	| RIGHT
   56443 	| UPPER LEFT
   56444 	| LOWER LEFT
   56445 	| UPPER RIGHT
   56446 	| LOWER RIGHT
   56447 	| LEFT_CORNER
   56448 	| RIGHT_CORNER
   56449 	| UPPER LEFT_CORNER
   56450 	| LOWER LEFT_CORNER
   56451 	| UPPER RIGHT_CORNER
   56452 	| LOWER RIGHT_CORNER
   56453 	| NORTH
   56454 	| SOUTH
   56455 	| EAST
   56456 	| WEST
   56457 	| CENTER
   56458 	| START
   56459 	| END
   56460 	;
   56461 
   56462 expr:
   56463 	VARIABLE
   56464 	| NUMBER
   56465 	| place DOT_X
   56466 	| place DOT_Y
   56467 	| place DOT_HT
   56468 	| place DOT_WID
   56469 	| place DOT_RAD
   56470 	| expr '+' expr
   56471 	| expr '-' expr
   56472 	| expr '*' expr
   56473 	| expr '/' expr
   56474 	| expr '%' expr
   56475 	| expr '^' expr
   56476 	| '-' expr						%prec '!'
   56477 	| '(' any_expr ')'
   56478 	| SIN '(' any_expr ')'
   56479 	| COS '(' any_expr ')'
   56480 	| ATAN2 '(' any_expr ',' any_expr ')'
   56481 	| LOG '(' any_expr ')'
   56482 	| EXP '(' any_expr ')'
   56483 	| SQRT '(' any_expr ')'
   56484 	| K_MAX '(' any_expr ',' any_expr ')'
   56485 	| K_MIN '(' any_expr ',' any_expr ')'
   56486 	| INT '(' any_expr ')'
   56487 	| RAND '(' any_expr ')'
   56488 	| RAND '(' ')'
   56489 	| SRAND '(' any_expr ')'
   56490 	| expr '<' expr
   56491 	| expr LESSEQUAL expr
   56492 	| expr '>' expr
   56493 	| expr GREATEREQUAL expr
   56494 	| expr EQUALEQUAL expr
   56495 	| expr NOTEQUAL expr
   56496 	| expr ANDAND expr
   56497 	| expr OROR expr
   56498 	| '!' expr
   56499 	;
   56500 _ATEOF
   56501 
   56502 
   56503 # Pass plenty of options, to exercise plenty of code, even if we
   56504 # don't actually check the output.  But SEGV is watching us, and
   56505 # so might do dmalloc.
   56506 $at_traceoff
   56507 echo "existing.at:1523: bison --verbose --defines input.y"
   56508 echo existing.at:1523 >$at_check_line_file
   56509 ( $at_traceon; bison --verbose --defines input.y ) >$at_stdout 2>$at_stder1
   56510 at_status=$?
   56511 grep '^ *+' $at_stder1 >&2
   56512 grep -v '^ *+' $at_stder1 >$at_stderr
   56513 at_failed=false
   56514 $at_diff $at_devnull $at_stderr || at_failed=:
   56515 $at_diff $at_devnull $at_stdout || at_failed=:
   56516 case $at_status in
   56517    77) echo 77 > $at_status_file
   56518             exit 77;;
   56519    0) ;;
   56520    *) echo "existing.at:1523: exit code was $at_status, expected 0"
   56521       at_failed=:;;
   56522 esac
   56523 if $at_failed; then
   56524 
   56525   echo 1 > $at_status_file
   56526   exit 1
   56527 fi
   56528 
   56529 $at_traceon
   56530 
   56531 
   56532       $at_traceoff
   56533       $at_times_p && times >$at_times_file
   56534     ) 5>&1 2>&1 | eval $at_tee_pipe
   56535     at_status=`cat $at_status_file`
   56536     ;;
   56537 
   56538 
   56539   banner-15 ) # Banner 15. regression.at:21
   56540     cat <<\_ATEOF
   56541 
   56542 Regression tests.
   56543 
   56544 _ATEOF
   56545     ;;
   56546 
   56547   113 ) # 113. regression.at:28: Trivial grammars
   56548     at_setup_line='regression.at:28'
   56549     at_desc='Trivial grammars'
   56550     $at_quiet $ECHO_N "113: Trivial grammars                             $ECHO_C"
   56551     at_xfail=no
   56552     (
   56553       echo "113. regression.at:28: testing ..."
   56554       $at_traceon
   56555 
   56556 
   56557 cat >input.y <<'_ATEOF'
   56558 %{
   56559 #ifdef HAVE_CONFIG_H
   56560 # include <config.h>
   56561   /* We don't need perfect functions for these tests. */
   56562 # undef malloc
   56563 # undef memcmp
   56564 # undef realloc
   56565 #endif
   56566 %}
   56567 
   56568 %{
   56569 void yyerror (char const *);
   56570 int yylex (void);
   56571 #define YYSTYPE int *
   56572 %}
   56573 
   56574 %error-verbose
   56575 
   56576 %%
   56577 
   56578 program: 'x';
   56579 _ATEOF
   56580 
   56581 
   56582 
   56583 $at_traceoff
   56584 echo "regression.at:44: bison -o input.c input.y"
   56585 echo regression.at:44 >$at_check_line_file
   56586 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   56587 at_status=$?
   56588 grep '^ *+' $at_stder1 >&2
   56589 grep -v '^ *+' $at_stder1 >$at_stderr
   56590 at_failed=false
   56591 $at_diff $at_devnull $at_stderr || at_failed=:
   56592 $at_diff $at_devnull $at_stdout || at_failed=:
   56593 case $at_status in
   56594    77) echo 77 > $at_status_file
   56595             exit 77;;
   56596    0) ;;
   56597    *) echo "regression.at:44: exit code was $at_status, expected 0"
   56598       at_failed=:;;
   56599 esac
   56600 if $at_failed; then
   56601 
   56602   echo 1 > $at_status_file
   56603   exit 1
   56604 fi
   56605 
   56606 $at_traceon
   56607 
   56608 $at_traceoff
   56609 echo "regression.at:45: \$CC \$CFLAGS \$CPPFLAGS -o input.o -c input.c"
   56610 echo regression.at:45 >$at_check_line_file
   56611 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -c input.c ) >$at_stdout 2>$at_stder1
   56612 at_status=$?
   56613 grep '^ *+' $at_stder1 >&2
   56614 grep -v '^ *+' $at_stder1 >$at_stderr
   56615 at_failed=false
   56616 echo stderr:; cat $at_stderr
   56617 echo stdout:; cat $at_stdout
   56618 case $at_status in
   56619    77) echo 77 > $at_status_file
   56620             exit 77;;
   56621    0) ;;
   56622    *) echo "regression.at:45: exit code was $at_status, expected 0"
   56623       at_failed=:;;
   56624 esac
   56625 if $at_failed; then
   56626 
   56627   echo 1 > $at_status_file
   56628   exit 1
   56629 fi
   56630 
   56631 $at_traceon
   56632 
   56633 $at_traceoff
   56634 echo "regression.at:46: \$CC \$CFLAGS \$CPPFLAGS -o input.o -DYYDEBUG -c input.c"
   56635 echo regression.at:46 >$at_check_line_file
   56636 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -DYYDEBUG -c input.c ) >$at_stdout 2>$at_stder1
   56637 at_status=$?
   56638 grep '^ *+' $at_stder1 >&2
   56639 grep -v '^ *+' $at_stder1 >$at_stderr
   56640 at_failed=false
   56641 echo stderr:; cat $at_stderr
   56642 echo stdout:; cat $at_stdout
   56643 case $at_status in
   56644    77) echo 77 > $at_status_file
   56645             exit 77;;
   56646    0) ;;
   56647    *) echo "regression.at:46: exit code was $at_status, expected 0"
   56648       at_failed=:;;
   56649 esac
   56650 if $at_failed; then
   56651 
   56652   echo 1 > $at_status_file
   56653   exit 1
   56654 fi
   56655 
   56656 $at_traceon
   56657 
   56658 
   56659       $at_traceoff
   56660       $at_times_p && times >$at_times_file
   56661     ) 5>&1 2>&1 | eval $at_tee_pipe
   56662     at_status=`cat $at_status_file`
   56663     ;;
   56664 
   56665   114 ) # 114. regression.at:57: Early token definitions
   56666     at_setup_line='regression.at:57'
   56667     at_desc='Early token definitions'
   56668     $at_quiet $ECHO_N "114: Early token definitions                      $ECHO_C"
   56669     at_xfail=no
   56670     (
   56671       echo "114. regression.at:57: testing ..."
   56672       $at_traceon
   56673 
   56674 
   56675 # Found in GCJ: they expect the tokens to be defined before the user
   56676 # prologue, so that they can use the token definitions in it.
   56677 
   56678 cat >input.y <<'_ATEOF'
   56679 %{
   56680 #ifdef HAVE_CONFIG_H
   56681 # include <config.h>
   56682   /* We don't need perfect functions for these tests. */
   56683 # undef malloc
   56684 # undef memcmp
   56685 # undef realloc
   56686 #endif
   56687 %}
   56688 
   56689 %{
   56690 void yyerror (const char *s);
   56691 int yylex (void);
   56692 %}
   56693 
   56694 %union
   56695 {
   56696   int val;
   56697 };
   56698 %{
   56699 #ifndef MY_TOKEN
   56700 # error "MY_TOKEN not defined."
   56701 #endif
   56702 %}
   56703 %token MY_TOKEN
   56704 %%
   56705 exp: MY_TOKEN;
   56706 %%
   56707 _ATEOF
   56708 
   56709 
   56710 
   56711 $at_traceoff
   56712 echo "regression.at:83: bison -o input.c input.y"
   56713 echo regression.at:83 >$at_check_line_file
   56714 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   56715 at_status=$?
   56716 grep '^ *+' $at_stder1 >&2
   56717 grep -v '^ *+' $at_stder1 >$at_stderr
   56718 at_failed=false
   56719 $at_diff $at_devnull $at_stderr || at_failed=:
   56720 $at_diff $at_devnull $at_stdout || at_failed=:
   56721 case $at_status in
   56722    77) echo 77 > $at_status_file
   56723             exit 77;;
   56724    0) ;;
   56725    *) echo "regression.at:83: exit code was $at_status, expected 0"
   56726       at_failed=:;;
   56727 esac
   56728 if $at_failed; then
   56729 
   56730   echo 1 > $at_status_file
   56731   exit 1
   56732 fi
   56733 
   56734 $at_traceon
   56735 
   56736 $at_traceoff
   56737 echo "regression.at:84: \$CC \$CFLAGS \$CPPFLAGS -o input.o -c input.c"
   56738 echo regression.at:84 >$at_check_line_file
   56739 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -c input.c ) >$at_stdout 2>$at_stder1
   56740 at_status=$?
   56741 grep '^ *+' $at_stder1 >&2
   56742 grep -v '^ *+' $at_stder1 >$at_stderr
   56743 at_failed=false
   56744 echo stderr:; cat $at_stderr
   56745 echo stdout:; cat $at_stdout
   56746 case $at_status in
   56747    77) echo 77 > $at_status_file
   56748             exit 77;;
   56749    0) ;;
   56750    *) echo "regression.at:84: exit code was $at_status, expected 0"
   56751       at_failed=:;;
   56752 esac
   56753 if $at_failed; then
   56754 
   56755   echo 1 > $at_status_file
   56756   exit 1
   56757 fi
   56758 
   56759 $at_traceon
   56760 
   56761 
   56762       $at_traceoff
   56763       $at_times_p && times >$at_times_file
   56764     ) 5>&1 2>&1 | eval $at_tee_pipe
   56765     at_status=`cat $at_status_file`
   56766     ;;
   56767 
   56768   115 ) # 115. regression.at:95: Braces parsing
   56769     at_setup_line='regression.at:95'
   56770     at_desc='Braces parsing'
   56771     $at_quiet $ECHO_N "115: Braces parsing                               $ECHO_C"
   56772     at_xfail=no
   56773     (
   56774       echo "115. regression.at:95: testing ..."
   56775       $at_traceon
   56776 
   56777 
   56778 cat >input.y <<'_ATEOF'
   56779 /* Bison used to swallow the character after `}'. */
   56780 
   56781 %%
   56782 exp: { tests = {{{{{{{{{{}}}}}}}}}}; };
   56783 %%
   56784 _ATEOF
   56785 
   56786 
   56787 $at_traceoff
   56788 echo "regression.at:105: bison -v -o input.c input.y"
   56789 echo regression.at:105 >$at_check_line_file
   56790 ( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   56791 at_status=$?
   56792 grep '^ *+' $at_stder1 >&2
   56793 grep -v '^ *+' $at_stder1 >$at_stderr
   56794 at_failed=false
   56795 $at_diff $at_devnull $at_stderr || at_failed=:
   56796 $at_diff $at_devnull $at_stdout || at_failed=:
   56797 case $at_status in
   56798    77) echo 77 > $at_status_file
   56799             exit 77;;
   56800    0) ;;
   56801    *) echo "regression.at:105: exit code was $at_status, expected 0"
   56802       at_failed=:;;
   56803 esac
   56804 if $at_failed; then
   56805 
   56806   echo 1 > $at_status_file
   56807   exit 1
   56808 fi
   56809 
   56810 $at_traceon
   56811 
   56812 
   56813 $at_traceoff
   56814 echo "regression.at:107: grep 'tests = {{{{{{{{{{}}}}}}}}}};' input.c"
   56815 echo regression.at:107 >$at_check_line_file
   56816 ( $at_traceon; grep 'tests = {{{{{{{{{{}}}}}}}}}};' input.c ) >$at_stdout 2>$at_stder1
   56817 at_status=$?
   56818 grep '^ *+' $at_stder1 >&2
   56819 grep -v '^ *+' $at_stder1 >$at_stderr
   56820 at_failed=false
   56821 $at_diff $at_devnull $at_stderr || at_failed=:
   56822 echo stdout:; cat $at_stdout
   56823 case $at_status in
   56824    77) echo 77 > $at_status_file
   56825             exit 77;;
   56826    0) ;;
   56827    *) echo "regression.at:107: exit code was $at_status, expected 0"
   56828       at_failed=:;;
   56829 esac
   56830 if $at_failed; then
   56831 
   56832   echo 1 > $at_status_file
   56833   exit 1
   56834 fi
   56835 
   56836 $at_traceon
   56837 
   56838 
   56839       $at_traceoff
   56840       $at_times_p && times >$at_times_file
   56841     ) 5>&1 2>&1 | eval $at_tee_pipe
   56842     at_status=`cat $at_status_file`
   56843     ;;
   56844 
   56845   116 ) # 116. regression.at:117: Duplicate string
   56846     at_setup_line='regression.at:117'
   56847     at_desc='Duplicate string'
   56848     $at_quiet $ECHO_N "116: Duplicate string                             $ECHO_C"
   56849     at_xfail=no
   56850     (
   56851       echo "116. regression.at:117: testing ..."
   56852       $at_traceon
   56853 
   56854 
   56855 cat >input.y <<'_ATEOF'
   56856 /* `Bison -v' used to dump core when two tokens are defined with the same
   56857    string, as LE and GE below. */
   56858 
   56859 %token NUM
   56860 %token LE "<="
   56861 %token GE "<="
   56862 
   56863 %%
   56864 exp: '(' exp ')' | NUM ;
   56865 %%
   56866 _ATEOF
   56867 
   56868 
   56869 $at_traceoff
   56870 echo "regression.at:134: bison -v -o input.c input.y"
   56871 echo regression.at:134 >$at_check_line_file
   56872 ( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   56873 at_status=$?
   56874 grep '^ *+' $at_stder1 >&2
   56875 grep -v '^ *+' $at_stder1 >$at_stderr
   56876 at_failed=false
   56877 echo >>$at_stderr; echo "input.y:6.8-14: warning: symbol \`\"<=\"' used more than once as a literal string
   56878 " | $at_diff - $at_stderr || at_failed=:
   56879 $at_diff $at_devnull $at_stdout || at_failed=:
   56880 case $at_status in
   56881    77) echo 77 > $at_status_file
   56882             exit 77;;
   56883    0) ;;
   56884    *) echo "regression.at:134: exit code was $at_status, expected 0"
   56885       at_failed=:;;
   56886 esac
   56887 if $at_failed; then
   56888 
   56889   echo 1 > $at_status_file
   56890   exit 1
   56891 fi
   56892 
   56893 $at_traceon
   56894 
   56895 
   56896       $at_traceoff
   56897       $at_times_p && times >$at_times_file
   56898     ) 5>&1 2>&1 | eval $at_tee_pipe
   56899     at_status=`cat $at_status_file`
   56900     ;;
   56901 
   56902   117 ) # 117. regression.at:143: Rule Line Numbers
   56903     at_setup_line='regression.at:143'
   56904     at_desc='Rule Line Numbers'
   56905     $at_quiet $ECHO_N "117: Rule Line Numbers                            $ECHO_C"
   56906     at_xfail=no
   56907     (
   56908       echo "117. regression.at:143: testing ..."
   56909       $at_traceon
   56910 
   56911 
   56912 
   56913 
   56914 cat >input.y <<'_ATEOF'
   56915 %%
   56916 expr:
   56917 'a'
   56918 
   56919 {
   56920 
   56921 }
   56922 
   56923 'b'
   56924 
   56925 {
   56926 
   56927 }
   56928 
   56929 |
   56930 
   56931 
   56932 {
   56933 
   56934 
   56935 }
   56936 
   56937 'c'
   56938 
   56939 {
   56940 
   56941 };
   56942 _ATEOF
   56943 
   56944 
   56945 $at_traceoff
   56946 echo "regression.at:177: bison -o input.c -v input.y"
   56947 echo regression.at:177 >$at_check_line_file
   56948 ( $at_traceon; bison -o input.c -v input.y ) >$at_stdout 2>$at_stder1
   56949 at_status=$?
   56950 grep '^ *+' $at_stder1 >&2
   56951 grep -v '^ *+' $at_stder1 >$at_stderr
   56952 at_failed=false
   56953 $at_diff $at_devnull $at_stderr || at_failed=:
   56954 $at_diff $at_devnull $at_stdout || at_failed=:
   56955 case $at_status in
   56956    77) echo 77 > $at_status_file
   56957             exit 77;;
   56958    0) ;;
   56959    *) echo "regression.at:177: exit code was $at_status, expected 0"
   56960       at_failed=:;;
   56961 esac
   56962 if $at_failed; then
   56963 
   56964   echo 1 > $at_status_file
   56965   exit 1
   56966 fi
   56967 
   56968 $at_traceon
   56969 
   56970 
   56971 # Check the contents of the report.
   56972 $at_traceoff
   56973 echo "regression.at:276: cat input.output"
   56974 echo regression.at:276 >$at_check_line_file
   56975 ( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
   56976 at_status=$?
   56977 grep '^ *+' $at_stder1 >&2
   56978 grep -v '^ *+' $at_stder1 >$at_stderr
   56979 at_failed=false
   56980 $at_diff $at_devnull $at_stderr || at_failed=:
   56981 echo >>$at_stdout; echo "Grammar
   56982 
   56983     0 \$accept: expr \$end
   56984 
   56985     1 @1: /* empty */
   56986 
   56987     2 expr: 'a' @1 'b'
   56988 
   56989     3 @2: /* empty */
   56990 
   56991     4 expr: @2 'c'
   56992 
   56993 
   56994 Terminals, with rules where they appear
   56995 
   56996 \$end (0) 0
   56997 'a' (97) 2
   56998 'b' (98) 2
   56999 'c' (99) 4
   57000 error (256)
   57001 
   57002 
   57003 Nonterminals, with rules where they appear
   57004 
   57005 \$accept (6)
   57006     on left: 0
   57007 expr (7)
   57008     on left: 2 4, on right: 0
   57009 @1 (8)
   57010     on left: 1, on right: 2
   57011 @2 (9)
   57012     on left: 3, on right: 4
   57013 
   57014 
   57015 state 0
   57016 
   57017     0 \$accept: . expr \$end
   57018 
   57019     'a'  shift, and go to state 1
   57020 
   57021     \$default  reduce using rule 3 (@2)
   57022 
   57023     expr  go to state 2
   57024     @2    go to state 3
   57025 
   57026 
   57027 state 1
   57028 
   57029     2 expr: 'a' . @1 'b'
   57030 
   57031     \$default  reduce using rule 1 (@1)
   57032 
   57033     @1  go to state 4
   57034 
   57035 
   57036 state 2
   57037 
   57038     0 \$accept: expr . \$end
   57039 
   57040     \$end  shift, and go to state 5
   57041 
   57042 
   57043 state 3
   57044 
   57045     4 expr: @2 . 'c'
   57046 
   57047     'c'  shift, and go to state 6
   57048 
   57049 
   57050 state 4
   57051 
   57052     2 expr: 'a' @1 . 'b'
   57053 
   57054     'b'  shift, and go to state 7
   57055 
   57056 
   57057 state 5
   57058 
   57059     0 \$accept: expr \$end .
   57060 
   57061     \$default  accept
   57062 
   57063 
   57064 state 6
   57065 
   57066     4 expr: @2 'c' .
   57067 
   57068     \$default  reduce using rule 4 (expr)
   57069 
   57070 
   57071 state 7
   57072 
   57073     2 expr: 'a' @1 'b' .
   57074 
   57075     \$default  reduce using rule 2 (expr)
   57076 " | $at_diff - $at_stdout || at_failed=:
   57077 case $at_status in
   57078    77) echo 77 > $at_status_file
   57079             exit 77;;
   57080    0) ;;
   57081    *) echo "regression.at:276: exit code was $at_status, expected 0"
   57082       at_failed=:;;
   57083 esac
   57084 if $at_failed; then
   57085 
   57086   echo 1 > $at_status_file
   57087   exit 1
   57088 fi
   57089 
   57090 $at_traceon
   57091 
   57092 
   57093       $at_traceoff
   57094       $at_times_p && times >$at_times_file
   57095     ) 5>&1 2>&1 | eval $at_tee_pipe
   57096     at_status=`cat $at_status_file`
   57097     ;;
   57098 
   57099   118 ) # 118. regression.at:287: Mixing %token styles
   57100     at_setup_line='regression.at:287'
   57101     at_desc='Mixing %token styles'
   57102     $at_quiet $ECHO_N "118: Mixing %token styles                         $ECHO_C"
   57103     at_xfail=no
   57104     (
   57105       echo "118. regression.at:287: testing ..."
   57106       $at_traceon
   57107 
   57108 
   57109 # Taken from the documentation.
   57110 cat >input.y <<'_ATEOF'
   57111 %token  <operator>  OR      "||"
   57112 %token  <operator>  LE 134  "<="
   57113 %left  OR  "<="
   57114 %%
   57115 exp: ;
   57116 %%
   57117 _ATEOF
   57118 
   57119 
   57120 $at_traceoff
   57121 echo "regression.at:299: bison -v -o input.c input.y"
   57122 echo regression.at:299 >$at_check_line_file
   57123 ( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   57124 at_status=$?
   57125 grep '^ *+' $at_stder1 >&2
   57126 grep -v '^ *+' $at_stder1 >$at_stderr
   57127 at_failed=false
   57128 $at_diff $at_devnull $at_stderr || at_failed=:
   57129 $at_diff $at_devnull $at_stdout || at_failed=:
   57130 case $at_status in
   57131    77) echo 77 > $at_status_file
   57132             exit 77;;
   57133    0) ;;
   57134    *) echo "regression.at:299: exit code was $at_status, expected 0"
   57135       at_failed=:;;
   57136 esac
   57137 if $at_failed; then
   57138 
   57139   echo 1 > $at_status_file
   57140   exit 1
   57141 fi
   57142 
   57143 $at_traceon
   57144 
   57145 
   57146       $at_traceoff
   57147       $at_times_p && times >$at_times_file
   57148     ) 5>&1 2>&1 | eval $at_tee_pipe
   57149     at_status=`cat $at_status_file`
   57150     ;;
   57151 
   57152   119 ) # 119. regression.at:310: Invalid inputs
   57153     at_setup_line='regression.at:310'
   57154     at_desc='Invalid inputs'
   57155     $at_quiet $ECHO_N "119: Invalid inputs                               $ECHO_C"
   57156     at_xfail=no
   57157     (
   57158       echo "119. regression.at:310: testing ..."
   57159       $at_traceon
   57160 
   57161 
   57162 cat >input.y <<'_ATEOF'
   57163 %%
   57164 ?
   57165 default: 'a' }
   57166 %&
   57167 %a-does-not-exist
   57168 %-
   57169 %{
   57170 _ATEOF
   57171 
   57172 
   57173 $at_traceoff
   57174 echo "regression.at:331: bison input.y"
   57175 echo regression.at:331 >$at_check_line_file
   57176 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   57177 at_status=$?
   57178 grep '^ *+' $at_stder1 >&2
   57179 grep -v '^ *+' $at_stder1 >$at_stderr
   57180 at_failed=false
   57181 echo >>$at_stderr; echo "input.y:2.1: invalid character: \`?'
   57182 input.y:3.14: invalid character: \`}'
   57183 input.y:4.1: invalid character: \`%'
   57184 input.y:4.2: invalid character: \`&'
   57185 input.y:5.1-17: invalid directive: \`%a-does-not-exist'
   57186 input.y:6.1: invalid character: \`%'
   57187 input.y:6.2: invalid character: \`-'
   57188 input.y:7.1-8.0: missing \`%}' at end of file
   57189 " | $at_diff - $at_stderr || at_failed=:
   57190 $at_diff $at_devnull $at_stdout || at_failed=:
   57191 case $at_status in
   57192    77) echo 77 > $at_status_file
   57193             exit 77;;
   57194    1) ;;
   57195    *) echo "regression.at:331: exit code was $at_status, expected 1"
   57196       at_failed=:;;
   57197 esac
   57198 if $at_failed; then
   57199 
   57200   echo 1 > $at_status_file
   57201   exit 1
   57202 fi
   57203 
   57204 $at_traceon
   57205 
   57206 
   57207       $at_traceoff
   57208       $at_times_p && times >$at_times_file
   57209     ) 5>&1 2>&1 | eval $at_tee_pipe
   57210     at_status=`cat $at_status_file`
   57211     ;;
   57212 
   57213   120 ) # 120. regression.at:336: Invalid inputs with {}
   57214     at_setup_line='regression.at:336'
   57215     at_desc='Invalid inputs with {}'
   57216     $at_quiet $ECHO_N "120: Invalid inputs with {}                       $ECHO_C"
   57217     at_xfail=no
   57218     (
   57219       echo "120. regression.at:336: testing ..."
   57220       $at_traceon
   57221 
   57222 
   57223 cat >input.y <<'_ATEOF'
   57224 
   57225 %destructor
   57226 %initial-action
   57227 %lex-param
   57228 %parse-param
   57229 %printer
   57230 %union
   57231 _ATEOF
   57232 
   57233 
   57234 $at_traceoff
   57235 echo "regression.at:352: bison input.y"
   57236 echo regression.at:352 >$at_check_line_file
   57237 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   57238 at_status=$?
   57239 grep '^ *+' $at_stder1 >&2
   57240 grep -v '^ *+' $at_stder1 >$at_stderr
   57241 at_failed=false
   57242 echo >>$at_stderr; echo "input.y:3.1: missing \`{' in \"%destructor {...}\"
   57243 input.y:4.1: missing \`{' in \"%initial-action {...}\"
   57244 input.y:4.1: syntax error, unexpected %initial-action {...}, expecting string or identifier
   57245 " | $at_diff - $at_stderr || at_failed=:
   57246 $at_diff $at_devnull $at_stdout || at_failed=:
   57247 case $at_status in
   57248    77) echo 77 > $at_status_file
   57249             exit 77;;
   57250    1) ;;
   57251    *) echo "regression.at:352: exit code was $at_status, expected 1"
   57252       at_failed=:;;
   57253 esac
   57254 if $at_failed; then
   57255 
   57256   echo 1 > $at_status_file
   57257   exit 1
   57258 fi
   57259 
   57260 $at_traceon
   57261 
   57262 
   57263       $at_traceoff
   57264       $at_times_p && times >$at_times_file
   57265     ) 5>&1 2>&1 | eval $at_tee_pipe
   57266     at_status=`cat $at_status_file`
   57267     ;;
   57268 
   57269   121 ) # 121. regression.at:363: Token definitions
   57270     at_setup_line='regression.at:363'
   57271     at_desc='Token definitions'
   57272     $at_quiet $ECHO_N "121: Token definitions                            $ECHO_C"
   57273     at_xfail=no
   57274     (
   57275       echo "121. regression.at:363: testing ..."
   57276       $at_traceon
   57277 
   57278 
   57279 # Bison managed, when fed with `%token 'f' "f"' to #define 'f'!
   57280 cat >input.y <<'_ATEOF'
   57281 %{
   57282 #ifdef HAVE_CONFIG_H
   57283 # include <config.h>
   57284   /* We don't need perfect functions for these tests. */
   57285 # undef malloc
   57286 # undef memcmp
   57287 # undef realloc
   57288 #endif
   57289 %}
   57290 
   57291 %{
   57292 #include <stdio.h>
   57293 void yyerror (const char *s);
   57294 int yylex (void);
   57295 %}
   57296 %error-verbose
   57297 %token MYEOF 0 "end of file"
   57298 %token 'a' "a"
   57299 %token B_TOKEN "b"
   57300 %token C_TOKEN 'c'
   57301 %token 'd' D_TOKEN
   57302 %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
   57303 %%
   57304 exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
   57305 %%
   57306 void
   57307 yyerror (char const *s)
   57308 {
   57309   fprintf (stderr, "%s\n", s);
   57310 }
   57311 
   57312 int
   57313 yylex (void)
   57314 {
   57315   return SPECIAL;
   57316 }
   57317 
   57318 int
   57319 main (void)
   57320 {
   57321   return yyparse ();
   57322 }
   57323 _ATEOF
   57324 
   57325 
   57326 
   57327 $at_traceoff
   57328 echo "regression.at:401: bison -o input.c input.y"
   57329 echo regression.at:401 >$at_check_line_file
   57330 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   57331 at_status=$?
   57332 grep '^ *+' $at_stder1 >&2
   57333 grep -v '^ *+' $at_stder1 >$at_stderr
   57334 at_failed=false
   57335 $at_diff $at_devnull $at_stderr || at_failed=:
   57336 $at_diff $at_devnull $at_stdout || at_failed=:
   57337 case $at_status in
   57338    77) echo 77 > $at_status_file
   57339             exit 77;;
   57340    0) ;;
   57341    *) echo "regression.at:401: exit code was $at_status, expected 0"
   57342       at_failed=:;;
   57343 esac
   57344 if $at_failed; then
   57345 
   57346   echo 1 > $at_status_file
   57347   exit 1
   57348 fi
   57349 
   57350 $at_traceon
   57351 
   57352 $at_traceoff
   57353 echo "regression.at:402: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   57354 echo regression.at:402 >$at_check_line_file
   57355 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   57356 at_status=$?
   57357 grep '^ *+' $at_stder1 >&2
   57358 grep -v '^ *+' $at_stder1 >$at_stderr
   57359 at_failed=false
   57360 echo stderr:; cat $at_stderr
   57361 echo stdout:; cat $at_stdout
   57362 case $at_status in
   57363    77) echo 77 > $at_status_file
   57364             exit 77;;
   57365    0) ;;
   57366    *) echo "regression.at:402: exit code was $at_status, expected 0"
   57367       at_failed=:;;
   57368 esac
   57369 if $at_failed; then
   57370 
   57371   echo 1 > $at_status_file
   57372   exit 1
   57373 fi
   57374 
   57375 $at_traceon
   57376 
   57377 cat >experr <<'_ATEOF'
   57378 syntax error, unexpected "\\'?\"\a\b\f\n\r\t\v\001\201\001\201?\?!", expecting a
   57379 _ATEOF
   57380 
   57381 $at_traceoff
   57382 echo "regression.at:406: \$PREPARSER ./input"
   57383 echo regression.at:406 >$at_check_line_file
   57384 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   57385 at_status=$?
   57386 grep '^ *+' $at_stder1 >&2
   57387 grep -v '^ *+' $at_stder1 >$at_stderr
   57388 at_failed=false
   57389 $at_diff experr $at_stderr || at_failed=:
   57390 $at_diff $at_devnull $at_stdout || at_failed=:
   57391 case $at_status in
   57392    77) echo 77 > $at_status_file
   57393             exit 77;;
   57394    1) ;;
   57395    *) echo "regression.at:406: exit code was $at_status, expected 1"
   57396       at_failed=:;;
   57397 esac
   57398 if $at_failed; then
   57399 
   57400   echo 1 > $at_status_file
   57401   exit 1
   57402 fi
   57403 
   57404 $at_traceon
   57405 
   57406       $at_traceoff
   57407       $at_times_p && times >$at_times_file
   57408     ) 5>&1 2>&1 | eval $at_tee_pipe
   57409     at_status=`cat $at_status_file`
   57410     ;;
   57411 
   57412   122 ) # 122. regression.at:416: Characters Escapes
   57413     at_setup_line='regression.at:416'
   57414     at_desc='Characters Escapes'
   57415     $at_quiet $ECHO_N "122: Characters Escapes                           $ECHO_C"
   57416     at_xfail=no
   57417     (
   57418       echo "122. regression.at:416: testing ..."
   57419       $at_traceon
   57420 
   57421 
   57422 cat >input.y <<'_ATEOF'
   57423 %{
   57424 #ifdef HAVE_CONFIG_H
   57425 # include <config.h>
   57426   /* We don't need perfect functions for these tests. */
   57427 # undef malloc
   57428 # undef memcmp
   57429 # undef realloc
   57430 #endif
   57431 %}
   57432 
   57433 %{
   57434 void yyerror (const char *s);
   57435 int yylex (void);
   57436 %}
   57437 %%
   57438 exp:
   57439   '\'' "\'"
   57440 | '\"' "\""
   57441 | '"'  "'"
   57442 ;
   57443 _ATEOF
   57444 
   57445 
   57446 # Pacify font-lock-mode: "
   57447 
   57448 $at_traceoff
   57449 echo "regression.at:432: bison -o input.c input.y"
   57450 echo regression.at:432 >$at_check_line_file
   57451 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   57452 at_status=$?
   57453 grep '^ *+' $at_stder1 >&2
   57454 grep -v '^ *+' $at_stder1 >$at_stderr
   57455 at_failed=false
   57456 $at_diff $at_devnull $at_stderr || at_failed=:
   57457 $at_diff $at_devnull $at_stdout || at_failed=:
   57458 case $at_status in
   57459    77) echo 77 > $at_status_file
   57460             exit 77;;
   57461    0) ;;
   57462    *) echo "regression.at:432: exit code was $at_status, expected 0"
   57463       at_failed=:;;
   57464 esac
   57465 if $at_failed; then
   57466 
   57467   echo 1 > $at_status_file
   57468   exit 1
   57469 fi
   57470 
   57471 $at_traceon
   57472 
   57473 $at_traceoff
   57474 echo "regression.at:433: \$CC \$CFLAGS \$CPPFLAGS -o input.o -c input.c"
   57475 echo regression.at:433 >$at_check_line_file
   57476 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -c input.c ) >$at_stdout 2>$at_stder1
   57477 at_status=$?
   57478 grep '^ *+' $at_stder1 >&2
   57479 grep -v '^ *+' $at_stder1 >$at_stderr
   57480 at_failed=false
   57481 echo stderr:; cat $at_stderr
   57482 echo stdout:; cat $at_stdout
   57483 case $at_status in
   57484    77) echo 77 > $at_status_file
   57485             exit 77;;
   57486    0) ;;
   57487    *) echo "regression.at:433: exit code was $at_status, expected 0"
   57488       at_failed=:;;
   57489 esac
   57490 if $at_failed; then
   57491 
   57492   echo 1 > $at_status_file
   57493   exit 1
   57494 fi
   57495 
   57496 $at_traceon
   57497 
   57498       $at_traceoff
   57499       $at_times_p && times >$at_times_file
   57500     ) 5>&1 2>&1 | eval $at_tee_pipe
   57501     at_status=`cat $at_status_file`
   57502     ;;
   57503 
   57504   123 ) # 123. regression.at:447: Web2c Report
   57505     at_setup_line='regression.at:447'
   57506     at_desc='Web2c Report'
   57507     $at_quiet $ECHO_N "123: Web2c Report                                 $ECHO_C"
   57508     at_xfail=no
   57509     (
   57510       echo "123. regression.at:447: testing ..."
   57511       $at_traceon
   57512 
   57513 
   57514 
   57515 
   57516 cat >input.y <<'_ATEOF'
   57517 %token	undef_id_tok const_id_tok
   57518 
   57519 %start CONST_DEC_PART
   57520 
   57521 %%
   57522 CONST_DEC_PART:
   57523          CONST_DEC_LIST
   57524         ;
   57525 
   57526 CONST_DEC_LIST:
   57527 	  CONST_DEC
   57528         | CONST_DEC_LIST CONST_DEC
   57529         ;
   57530 
   57531 CONST_DEC:
   57532 	  { } undef_id_tok '=' const_id_tok ';'
   57533         ;
   57534 %%
   57535 _ATEOF
   57536 
   57537 
   57538 $at_traceoff
   57539 echo "regression.at:472: bison -v input.y"
   57540 echo regression.at:472 >$at_check_line_file
   57541 ( $at_traceon; bison -v input.y ) >$at_stdout 2>$at_stder1
   57542 at_status=$?
   57543 grep '^ *+' $at_stder1 >&2
   57544 grep -v '^ *+' $at_stder1 >$at_stderr
   57545 at_failed=false
   57546 $at_diff $at_devnull $at_stderr || at_failed=:
   57547 $at_diff $at_devnull $at_stdout || at_failed=:
   57548 case $at_status in
   57549    77) echo 77 > $at_status_file
   57550             exit 77;;
   57551    0) ;;
   57552    *) echo "regression.at:472: exit code was $at_status, expected 0"
   57553       at_failed=:;;
   57554 esac
   57555 if $at_failed; then
   57556 
   57557   echo 1 > $at_status_file
   57558   exit 1
   57559 fi
   57560 
   57561 $at_traceon
   57562 
   57563 $at_traceoff
   57564 echo "regression.at:597: cat input.output"
   57565 echo regression.at:597 >$at_check_line_file
   57566 ( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
   57567 at_status=$?
   57568 grep '^ *+' $at_stder1 >&2
   57569 grep -v '^ *+' $at_stder1 >$at_stderr
   57570 at_failed=false
   57571 $at_diff $at_devnull $at_stderr || at_failed=:
   57572 echo >>$at_stdout; echo "Grammar
   57573 
   57574     0 \$accept: CONST_DEC_PART \$end
   57575 
   57576     1 CONST_DEC_PART: CONST_DEC_LIST
   57577 
   57578     2 CONST_DEC_LIST: CONST_DEC
   57579     3               | CONST_DEC_LIST CONST_DEC
   57580 
   57581     4 @1: /* empty */
   57582 
   57583     5 CONST_DEC: @1 undef_id_tok '=' const_id_tok ';'
   57584 
   57585 
   57586 Terminals, with rules where they appear
   57587 
   57588 \$end (0) 0
   57589 ';' (59) 5
   57590 '=' (61) 5
   57591 error (256)
   57592 undef_id_tok (258) 5
   57593 const_id_tok (259) 5
   57594 
   57595 
   57596 Nonterminals, with rules where they appear
   57597 
   57598 \$accept (7)
   57599     on left: 0
   57600 CONST_DEC_PART (8)
   57601     on left: 1, on right: 0
   57602 CONST_DEC_LIST (9)
   57603     on left: 2 3, on right: 1 3
   57604 CONST_DEC (10)
   57605     on left: 5, on right: 2 3
   57606 @1 (11)
   57607     on left: 4, on right: 5
   57608 
   57609 
   57610 state 0
   57611 
   57612     0 \$accept: . CONST_DEC_PART \$end
   57613 
   57614     \$default  reduce using rule 4 (@1)
   57615 
   57616     CONST_DEC_PART  go to state 1
   57617     CONST_DEC_LIST  go to state 2
   57618     CONST_DEC       go to state 3
   57619     @1              go to state 4
   57620 
   57621 
   57622 state 1
   57623 
   57624     0 \$accept: CONST_DEC_PART . \$end
   57625 
   57626     \$end  shift, and go to state 5
   57627 
   57628 
   57629 state 2
   57630 
   57631     1 CONST_DEC_PART: CONST_DEC_LIST .
   57632     3 CONST_DEC_LIST: CONST_DEC_LIST . CONST_DEC
   57633 
   57634     undef_id_tok  reduce using rule 4 (@1)
   57635     \$default      reduce using rule 1 (CONST_DEC_PART)
   57636 
   57637     CONST_DEC  go to state 6
   57638     @1         go to state 4
   57639 
   57640 
   57641 state 3
   57642 
   57643     2 CONST_DEC_LIST: CONST_DEC .
   57644 
   57645     \$default  reduce using rule 2 (CONST_DEC_LIST)
   57646 
   57647 
   57648 state 4
   57649 
   57650     5 CONST_DEC: @1 . undef_id_tok '=' const_id_tok ';'
   57651 
   57652     undef_id_tok  shift, and go to state 7
   57653 
   57654 
   57655 state 5
   57656 
   57657     0 \$accept: CONST_DEC_PART \$end .
   57658 
   57659     \$default  accept
   57660 
   57661 
   57662 state 6
   57663 
   57664     3 CONST_DEC_LIST: CONST_DEC_LIST CONST_DEC .
   57665 
   57666     \$default  reduce using rule 3 (CONST_DEC_LIST)
   57667 
   57668 
   57669 state 7
   57670 
   57671     5 CONST_DEC: @1 undef_id_tok . '=' const_id_tok ';'
   57672 
   57673     '='  shift, and go to state 8
   57674 
   57675 
   57676 state 8
   57677 
   57678     5 CONST_DEC: @1 undef_id_tok '=' . const_id_tok ';'
   57679 
   57680     const_id_tok  shift, and go to state 9
   57681 
   57682 
   57683 state 9
   57684 
   57685     5 CONST_DEC: @1 undef_id_tok '=' const_id_tok . ';'
   57686 
   57687     ';'  shift, and go to state 10
   57688 
   57689 
   57690 state 10
   57691 
   57692     5 CONST_DEC: @1 undef_id_tok '=' const_id_tok ';' .
   57693 
   57694     \$default  reduce using rule 5 (CONST_DEC)
   57695 " | $at_diff - $at_stdout || at_failed=:
   57696 case $at_status in
   57697    77) echo 77 > $at_status_file
   57698             exit 77;;
   57699    0) ;;
   57700    *) echo "regression.at:597: exit code was $at_status, expected 0"
   57701       at_failed=:;;
   57702 esac
   57703 if $at_failed; then
   57704 
   57705   echo 1 > $at_status_file
   57706   exit 1
   57707 fi
   57708 
   57709 $at_traceon
   57710 
   57711 
   57712       $at_traceoff
   57713       $at_times_p && times >$at_times_file
   57714     ) 5>&1 2>&1 | eval $at_tee_pipe
   57715     at_status=`cat $at_status_file`
   57716     ;;
   57717 
   57718   124 ) # 124. regression.at:624: Web2c Actions
   57719     at_setup_line='regression.at:624'
   57720     at_desc='Web2c Actions'
   57721     $at_quiet $ECHO_N "124: Web2c Actions                                $ECHO_C"
   57722     at_xfail=no
   57723     (
   57724       echo "124. regression.at:624: testing ..."
   57725       $at_traceon
   57726 
   57727 
   57728 
   57729 
   57730 cat >input.y <<'_ATEOF'
   57731 %%
   57732 statement:  struct_stat;
   57733 struct_stat:  /* empty. */ | if else;
   57734 if: "if" "const" "then" statement;
   57735 else: "else" statement;
   57736 %%
   57737 _ATEOF
   57738 
   57739 
   57740 $at_traceoff
   57741 echo "regression.at:637: bison -v -o input.c input.y"
   57742 echo regression.at:637 >$at_check_line_file
   57743 ( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   57744 at_status=$?
   57745 grep '^ *+' $at_stder1 >&2
   57746 grep -v '^ *+' $at_stder1 >$at_stderr
   57747 at_failed=false
   57748 $at_diff $at_devnull $at_stderr || at_failed=:
   57749 $at_diff $at_devnull $at_stdout || at_failed=:
   57750 case $at_status in
   57751    77) echo 77 > $at_status_file
   57752             exit 77;;
   57753    0) ;;
   57754    *) echo "regression.at:637: exit code was $at_status, expected 0"
   57755       at_failed=:;;
   57756 esac
   57757 if $at_failed; then
   57758 
   57759   echo 1 > $at_status_file
   57760   exit 1
   57761 fi
   57762 
   57763 $at_traceon
   57764 
   57765 
   57766 # Check only the tables.  We don't use --no-parser, because it is
   57767 # still to be implemented in the experimental branch of Bison.
   57768 sed -n 's/  *$//;/^static const.*\[\] =/,/^}/p' input.c >tables.c
   57769 
   57770 $at_traceoff
   57771 echo "regression.at:735: cat tables.c"
   57772 echo regression.at:735 >$at_check_line_file
   57773 ( $at_traceon; cat tables.c ) >$at_stdout 2>$at_stder1
   57774 at_status=$?
   57775 grep '^ *+' $at_stder1 >&2
   57776 grep -v '^ *+' $at_stder1 >$at_stderr
   57777 at_failed=false
   57778 $at_diff $at_devnull $at_stderr || at_failed=:
   57779 echo >>$at_stdout; echo "static const yytype_uint8 yytranslate[] =
   57780 {
   57781        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57782        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57783        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57784        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57785        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57786        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57787        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57788        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57789        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57790        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57791        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57792        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57793        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57794        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57795        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57796        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57797        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57798        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57799        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57800        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57801        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57802        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57803        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57804        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57805        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   57806        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
   57807        5,     6
   57808 };
   57809 static const yytype_uint8 yyprhs[] =
   57810 {
   57811        0,     0,     3,     5,     6,     9,    14
   57812 };
   57813 static const yytype_int8 yyrhs[] =
   57814 {
   57815        8,     0,    -1,     9,    -1,    -1,    10,    11,    -1,     3,
   57816        4,     5,     8,    -1,     6,     8,    -1
   57817 };
   57818 static const yytype_uint8 yyrline[] =
   57819 {
   57820        0,     2,     2,     3,     3,     4,     5
   57821 };
   57822 static const char *const yytname[] =
   57823 {
   57824   \"\$end\", \"error\", \"\$undefined\", \"\\\"if\\\"\", \"\\\"const\\\"\", \"\\\"then\\\"\",
   57825   \"\\\"else\\\"\", \"\$accept\", \"statement\", \"struct_stat\", \"if\", \"else\", 0
   57826 };
   57827 static const yytype_uint16 yytoknum[] =
   57828 {
   57829        0,   256,   257,   258,   259,   260,   261
   57830 };
   57831 static const yytype_uint8 yyr1[] =
   57832 {
   57833        0,     7,     8,     9,     9,    10,    11
   57834 };
   57835 static const yytype_uint8 yyr2[] =
   57836 {
   57837        0,     2,     1,     0,     2,     4,     2
   57838 };
   57839 static const yytype_uint8 yydefact[] =
   57840 {
   57841        3,     0,     0,     2,     0,     0,     1,     3,     4,     3,
   57842        6,     5
   57843 };
   57844 static const yytype_int8 yydefgoto[] =
   57845 {
   57846       -1,     2,     3,     4,     8
   57847 };
   57848 static const yytype_int8 yypact[] =
   57849 {
   57850       -2,    -1,     4,    -8,     0,     2,    -8,    -2,    -8,    -2,
   57851       -8,    -8
   57852 };
   57853 static const yytype_int8 yypgoto[] =
   57854 {
   57855       -8,    -7,    -8,    -8,    -8
   57856 };
   57857 static const yytype_uint8 yytable[] =
   57858 {
   57859       10,     1,    11,     5,     6,     0,     7,     9
   57860 };
   57861 static const yytype_int8 yycheck[] =
   57862 {
   57863        7,     3,     9,     4,     0,    -1,     6,     5
   57864 };
   57865 static const yytype_uint8 yystos[] =
   57866 {
   57867        0,     3,     8,     9,    10,     4,     0,     6,    11,     5,
   57868        8,     8
   57869 };
   57870 " | $at_diff - $at_stdout || at_failed=:
   57871 case $at_status in
   57872    77) echo 77 > $at_status_file
   57873             exit 77;;
   57874    0) ;;
   57875    *) echo "regression.at:735: exit code was $at_status, expected 0"
   57876       at_failed=:;;
   57877 esac
   57878 if $at_failed; then
   57879 
   57880   echo 1 > $at_status_file
   57881   exit 1
   57882 fi
   57883 
   57884 $at_traceon
   57885 
   57886 
   57887       $at_traceoff
   57888       $at_times_p && times >$at_times_file
   57889     ) 5>&1 2>&1 | eval $at_tee_pipe
   57890     at_status=`cat $at_status_file`
   57891     ;;
   57892 
   57893   125 ) # 125. regression.at:866: Dancer
   57894     at_setup_line='regression.at:866'
   57895     at_desc='Dancer '
   57896     $at_quiet $ECHO_N "125: Dancer                                       $ECHO_C"
   57897     at_xfail=no
   57898     (
   57899       echo "125. regression.at:866: testing ..."
   57900       $at_traceon
   57901 
   57902 
   57903 
   57904 
   57905 
   57906 # Using yacc.c?
   57907 
   57908 
   57909 
   57910 
   57911 
   57912 
   57913 
   57914 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   57915 
   57916 # yyerror always sees the locations (when activated), except if
   57917 # yacc & pure & !param.
   57918 
   57919 
   57920 # The interface is pure: either because %pure-parser, or because we
   57921 # are using the C++ parsers.
   57922 
   57923 
   57924 
   57925 
   57926 
   57927 
   57928 
   57929 
   57930 
   57931 
   57932 
   57933 cat >dancer.y <<'_ATEOF'
   57934 %{
   57935 #ifdef HAVE_CONFIG_H
   57936 # include <config.h>
   57937   /* We don't need perfect functions for these tests. */
   57938 # undef malloc
   57939 # undef memcmp
   57940 # undef realloc
   57941 #endif
   57942 %}
   57943 
   57944 %{
   57945 static int yylex (void);
   57946 #include <stdio.h>
   57947 static void yyerror (const char *);
   57948 %}
   57949 
   57950 %token ARROW INVALID NUMBER STRING DATA
   57951 %defines
   57952 %verbose
   57953 %error-verbose
   57954 /* Grammar follows */
   57955 %%
   57956 line: header body
   57957    ;
   57958 
   57959 header: '<' from ARROW to '>' type ':'
   57960    | '<' ARROW to '>' type ':'
   57961    | ARROW to type ':'
   57962    | type ':'
   57963    | '<' '>'
   57964    ;
   57965 
   57966 from: DATA
   57967    | STRING
   57968    | INVALID
   57969    ;
   57970 
   57971 to: DATA
   57972    | STRING
   57973    | INVALID
   57974    ;
   57975 
   57976 type: DATA
   57977    | STRING
   57978    | INVALID
   57979    ;
   57980 
   57981 body: /* empty */
   57982    | body member
   57983    ;
   57984 
   57985 member: STRING
   57986    | DATA
   57987    | '+' NUMBER
   57988    | '-' NUMBER
   57989    | NUMBER
   57990    | INVALID
   57991    ;
   57992 %%
   57993 static void
   57994 yyerror (const char *s)
   57995 {
   57996   fprintf (stderr, "%s\n", s);
   57997 }
   57998 
   57999 static int
   58000 yylex (void)
   58001 {
   58002   static int toknum = 0;
   58003   static int tokens[] =
   58004     {
   58005       ':', -1
   58006     };
   58007 
   58008   return tokens[toknum++];
   58009 }
   58010 
   58011 int
   58012 main (void)
   58013 {
   58014   return yyparse ();
   58015 }
   58016 _ATEOF
   58017 
   58018 
   58019 
   58020 $at_traceoff
   58021 echo "regression.at:866: bison -o dancer.c dancer.y"
   58022 echo regression.at:866 >$at_check_line_file
   58023 ( $at_traceon; bison -o dancer.c dancer.y ) >$at_stdout 2>$at_stder1
   58024 at_status=$?
   58025 grep '^ *+' $at_stder1 >&2
   58026 grep -v '^ *+' $at_stder1 >$at_stderr
   58027 at_failed=false
   58028 $at_diff $at_devnull $at_stderr || at_failed=:
   58029 $at_diff $at_devnull $at_stdout || at_failed=:
   58030 case $at_status in
   58031    77) echo 77 > $at_status_file
   58032             exit 77;;
   58033    0) ;;
   58034    *) echo "regression.at:866: exit code was $at_status, expected 0"
   58035       at_failed=:;;
   58036 esac
   58037 if $at_failed; then
   58038 
   58039   echo 1 > $at_status_file
   58040   exit 1
   58041 fi
   58042 
   58043 $at_traceon
   58044 
   58045 $at_traceoff
   58046 echo "regression.at:866: bison -o dancer.c dancer.y"
   58047 echo regression.at:866 >$at_check_line_file
   58048 ( $at_traceon; bison -o dancer.c dancer.y ) >$at_stdout 2>$at_stder1
   58049 at_status=$?
   58050 grep '^ *+' $at_stder1 >&2
   58051 grep -v '^ *+' $at_stder1 >$at_stderr
   58052 at_failed=false
   58053 $at_diff $at_devnull $at_stderr || at_failed=:
   58054 $at_diff $at_devnull $at_stdout || at_failed=:
   58055 case $at_status in
   58056    77) echo 77 > $at_status_file
   58057             exit 77;;
   58058    0) ;;
   58059    *) echo "regression.at:866: exit code was $at_status, expected 0"
   58060       at_failed=:;;
   58061 esac
   58062 if $at_failed; then
   58063 
   58064   echo 1 > $at_status_file
   58065   exit 1
   58066 fi
   58067 
   58068 $at_traceon
   58069 
   58070    $at_traceoff
   58071 echo "regression.at:866: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o dancer dancer.c \$LIBS"
   58072 echo regression.at:866 >$at_check_line_file
   58073 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o dancer dancer.c $LIBS ) >$at_stdout 2>$at_stder1
   58074 at_status=$?
   58075 grep '^ *+' $at_stder1 >&2
   58076 grep -v '^ *+' $at_stder1 >$at_stderr
   58077 at_failed=false
   58078 echo stderr:; cat $at_stderr
   58079 echo stdout:; cat $at_stdout
   58080 case $at_status in
   58081    77) echo 77 > $at_status_file
   58082             exit 77;;
   58083    0) ;;
   58084    *) echo "regression.at:866: exit code was $at_status, expected 0"
   58085       at_failed=:;;
   58086 esac
   58087 if $at_failed; then
   58088 
   58089   echo 1 > $at_status_file
   58090   exit 1
   58091 fi
   58092 
   58093 $at_traceon
   58094 
   58095 $at_traceoff
   58096 echo "regression.at:866: \$PREPARSER ./dancer"
   58097 echo regression.at:866 >$at_check_line_file
   58098 ( $at_traceon; $PREPARSER ./dancer ) >$at_stdout 2>$at_stder1
   58099 at_status=$?
   58100 grep '^ *+' $at_stder1 >&2
   58101 grep -v '^ *+' $at_stder1 >$at_stderr
   58102 at_failed=false
   58103 echo >>$at_stderr; echo "syntax error, unexpected ':'
   58104 " | $at_diff - $at_stderr || at_failed=:
   58105 $at_diff $at_devnull $at_stdout || at_failed=:
   58106 case $at_status in
   58107    77) echo 77 > $at_status_file
   58108             exit 77;;
   58109    1) ;;
   58110    *) echo "regression.at:866: exit code was $at_status, expected 1"
   58111       at_failed=:;;
   58112 esac
   58113 if $at_failed; then
   58114 
   58115   echo 1 > $at_status_file
   58116   exit 1
   58117 fi
   58118 
   58119 $at_traceon
   58120 
   58121 
   58122 
   58123 
   58124 
   58125 
   58126 
   58127 
   58128 
   58129 
   58130 
   58131 
   58132 
   58133 
   58134 
   58135 
   58136 
   58137 
   58138 
   58139 
   58140 
   58141 
   58142       $at_traceoff
   58143       $at_times_p && times >$at_times_file
   58144     ) 5>&1 2>&1 | eval $at_tee_pipe
   58145     at_status=`cat $at_status_file`
   58146     ;;
   58147 
   58148   126 ) # 126. regression.at:867: Dancer %glr-parser
   58149     at_setup_line='regression.at:867'
   58150     at_desc='Dancer %glr-parser'
   58151     $at_quiet $ECHO_N "126: Dancer %glr-parser                           $ECHO_C"
   58152     at_xfail=no
   58153     (
   58154       echo "126. regression.at:867: testing ..."
   58155       $at_traceon
   58156 
   58157 
   58158 
   58159 
   58160 
   58161 # Using yacc.c?
   58162 
   58163 
   58164 
   58165 
   58166 
   58167 
   58168 
   58169 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   58170 
   58171 # yyerror always sees the locations (when activated), except if
   58172 # yacc & pure & !param.
   58173 
   58174 
   58175 # The interface is pure: either because %pure-parser, or because we
   58176 # are using the C++ parsers.
   58177 
   58178 
   58179 
   58180 
   58181 
   58182 
   58183 
   58184 
   58185 
   58186 
   58187 
   58188 cat >dancer.y <<'_ATEOF'
   58189 %{
   58190 #ifdef HAVE_CONFIG_H
   58191 # include <config.h>
   58192   /* We don't need perfect functions for these tests. */
   58193 # undef malloc
   58194 # undef memcmp
   58195 # undef realloc
   58196 #endif
   58197 %}
   58198 
   58199 %{
   58200 static int yylex (void);
   58201 #include <stdio.h>
   58202 static void yyerror (const char *);
   58203 %}
   58204 %glr-parser
   58205 %token ARROW INVALID NUMBER STRING DATA
   58206 %defines
   58207 %verbose
   58208 %error-verbose
   58209 /* Grammar follows */
   58210 %%
   58211 line: header body
   58212    ;
   58213 
   58214 header: '<' from ARROW to '>' type ':'
   58215    | '<' ARROW to '>' type ':'
   58216    | ARROW to type ':'
   58217    | type ':'
   58218    | '<' '>'
   58219    ;
   58220 
   58221 from: DATA
   58222    | STRING
   58223    | INVALID
   58224    ;
   58225 
   58226 to: DATA
   58227    | STRING
   58228    | INVALID
   58229    ;
   58230 
   58231 type: DATA
   58232    | STRING
   58233    | INVALID
   58234    ;
   58235 
   58236 body: /* empty */
   58237    | body member
   58238    ;
   58239 
   58240 member: STRING
   58241    | DATA
   58242    | '+' NUMBER
   58243    | '-' NUMBER
   58244    | NUMBER
   58245    | INVALID
   58246    ;
   58247 %%
   58248 static void
   58249 yyerror (const char *s)
   58250 {
   58251   fprintf (stderr, "%s\n", s);
   58252 }
   58253 
   58254 static int
   58255 yylex (void)
   58256 {
   58257   static int toknum = 0;
   58258   static int tokens[] =
   58259     {
   58260       ':', -1
   58261     };
   58262 
   58263   return tokens[toknum++];
   58264 }
   58265 
   58266 int
   58267 main (void)
   58268 {
   58269   return yyparse ();
   58270 }
   58271 _ATEOF
   58272 
   58273 
   58274 
   58275 $at_traceoff
   58276 echo "regression.at:867: bison -o dancer.c dancer.y"
   58277 echo regression.at:867 >$at_check_line_file
   58278 ( $at_traceon; bison -o dancer.c dancer.y ) >$at_stdout 2>$at_stder1
   58279 at_status=$?
   58280 grep '^ *+' $at_stder1 >&2
   58281 grep -v '^ *+' $at_stder1 >$at_stderr
   58282 at_failed=false
   58283 $at_diff $at_devnull $at_stderr || at_failed=:
   58284 $at_diff $at_devnull $at_stdout || at_failed=:
   58285 case $at_status in
   58286    77) echo 77 > $at_status_file
   58287             exit 77;;
   58288    0) ;;
   58289    *) echo "regression.at:867: exit code was $at_status, expected 0"
   58290       at_failed=:;;
   58291 esac
   58292 if $at_failed; then
   58293 
   58294   echo 1 > $at_status_file
   58295   exit 1
   58296 fi
   58297 
   58298 $at_traceon
   58299 
   58300 $at_traceoff
   58301 echo "regression.at:867: bison -o dancer.c dancer.y"
   58302 echo regression.at:867 >$at_check_line_file
   58303 ( $at_traceon; bison -o dancer.c dancer.y ) >$at_stdout 2>$at_stder1
   58304 at_status=$?
   58305 grep '^ *+' $at_stder1 >&2
   58306 grep -v '^ *+' $at_stder1 >$at_stderr
   58307 at_failed=false
   58308 $at_diff $at_devnull $at_stderr || at_failed=:
   58309 $at_diff $at_devnull $at_stdout || at_failed=:
   58310 case $at_status in
   58311    77) echo 77 > $at_status_file
   58312             exit 77;;
   58313    0) ;;
   58314    *) echo "regression.at:867: exit code was $at_status, expected 0"
   58315       at_failed=:;;
   58316 esac
   58317 if $at_failed; then
   58318 
   58319   echo 1 > $at_status_file
   58320   exit 1
   58321 fi
   58322 
   58323 $at_traceon
   58324 
   58325    $at_traceoff
   58326 echo "regression.at:867: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o dancer dancer.c \$LIBS"
   58327 echo regression.at:867 >$at_check_line_file
   58328 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o dancer dancer.c $LIBS ) >$at_stdout 2>$at_stder1
   58329 at_status=$?
   58330 grep '^ *+' $at_stder1 >&2
   58331 grep -v '^ *+' $at_stder1 >$at_stderr
   58332 at_failed=false
   58333 echo stderr:; cat $at_stderr
   58334 echo stdout:; cat $at_stdout
   58335 case $at_status in
   58336    77) echo 77 > $at_status_file
   58337             exit 77;;
   58338    0) ;;
   58339    *) echo "regression.at:867: exit code was $at_status, expected 0"
   58340       at_failed=:;;
   58341 esac
   58342 if $at_failed; then
   58343 
   58344   echo 1 > $at_status_file
   58345   exit 1
   58346 fi
   58347 
   58348 $at_traceon
   58349 
   58350 $at_traceoff
   58351 echo "regression.at:867: \$PREPARSER ./dancer"
   58352 echo regression.at:867 >$at_check_line_file
   58353 ( $at_traceon; $PREPARSER ./dancer ) >$at_stdout 2>$at_stder1
   58354 at_status=$?
   58355 grep '^ *+' $at_stder1 >&2
   58356 grep -v '^ *+' $at_stder1 >$at_stderr
   58357 at_failed=false
   58358 echo >>$at_stderr; echo "syntax error, unexpected ':'
   58359 " | $at_diff - $at_stderr || at_failed=:
   58360 $at_diff $at_devnull $at_stdout || at_failed=:
   58361 case $at_status in
   58362    77) echo 77 > $at_status_file
   58363             exit 77;;
   58364    1) ;;
   58365    *) echo "regression.at:867: exit code was $at_status, expected 1"
   58366       at_failed=:;;
   58367 esac
   58368 if $at_failed; then
   58369 
   58370   echo 1 > $at_status_file
   58371   exit 1
   58372 fi
   58373 
   58374 $at_traceon
   58375 
   58376 
   58377 
   58378 
   58379 
   58380 
   58381 
   58382 
   58383 
   58384 
   58385 
   58386 
   58387 
   58388 
   58389 
   58390 
   58391 
   58392 
   58393 
   58394 
   58395 
   58396 
   58397       $at_traceoff
   58398       $at_times_p && times >$at_times_file
   58399     ) 5>&1 2>&1 | eval $at_tee_pipe
   58400     at_status=`cat $at_status_file`
   58401     ;;
   58402 
   58403   127 ) # 127. regression.at:868: Dancer %skeleton "lalr1.cc"
   58404     at_setup_line='regression.at:868'
   58405     at_desc='Dancer %skeleton "lalr1.cc"'
   58406     $at_quiet $ECHO_N "127: Dancer %skeleton "lalr1.cc"                  $ECHO_C"
   58407     at_xfail=no
   58408     (
   58409       echo "127. regression.at:868: testing ..."
   58410       $at_traceon
   58411 
   58412 
   58413 
   58414 
   58415 
   58416 # Using yacc.c?
   58417 
   58418 
   58419 
   58420 
   58421 
   58422 
   58423 
   58424 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   58425 
   58426 # yyerror always sees the locations (when activated), except if
   58427 # yacc & pure & !param.
   58428 
   58429 
   58430 # The interface is pure: either because %pure-parser, or because we
   58431 # are using the C++ parsers.
   58432 
   58433 
   58434 
   58435 
   58436 
   58437 
   58438 
   58439 
   58440 
   58441 
   58442 
   58443 cat >dancer.y <<'_ATEOF'
   58444 %{
   58445 #ifdef HAVE_CONFIG_H
   58446 # include <config.h>
   58447   /* We don't need perfect functions for these tests. */
   58448 # undef malloc
   58449 # undef memcmp
   58450 # undef realloc
   58451 #endif
   58452 %}
   58453 
   58454 %{
   58455 static int yylex (int *);
   58456 
   58457 %}
   58458 %skeleton "lalr1.cc"
   58459 %token ARROW INVALID NUMBER STRING DATA
   58460 %defines
   58461 %verbose
   58462 %error-verbose
   58463 /* Grammar follows */
   58464 %%
   58465 line: header body
   58466    ;
   58467 
   58468 header: '<' from ARROW to '>' type ':'
   58469    | '<' ARROW to '>' type ':'
   58470    | ARROW to type ':'
   58471    | type ':'
   58472    | '<' '>'
   58473    ;
   58474 
   58475 from: DATA
   58476    | STRING
   58477    | INVALID
   58478    ;
   58479 
   58480 to: DATA
   58481    | STRING
   58482    | INVALID
   58483    ;
   58484 
   58485 type: DATA
   58486    | STRING
   58487    | INVALID
   58488    ;
   58489 
   58490 body: /* empty */
   58491    | body member
   58492    ;
   58493 
   58494 member: STRING
   58495    | DATA
   58496    | '+' NUMBER
   58497    | '-' NUMBER
   58498    | NUMBER
   58499    | INVALID
   58500    ;
   58501 %%
   58502 /* A C++ error reporting function. */
   58503 void
   58504 yy::parser::error (const location&, const std::string& m)
   58505 {
   58506   std::cerr << m << std::endl;
   58507 }
   58508 
   58509 int
   58510 yyparse ()
   58511 {
   58512   yy::parser parser;
   58513   parser.set_debug_level (!!YYDEBUG);
   58514   return parser.parse ();
   58515 }
   58516 
   58517 
   58518 static int
   58519 yylex (int *lval)
   58520 {
   58521   static int toknum = 0;
   58522   static int tokens[] =
   58523     {
   58524       ':', -1
   58525     };
   58526   *lval = 0; /* Pacify GCC.  */
   58527   return tokens[toknum++];
   58528 }
   58529 
   58530 int
   58531 main (void)
   58532 {
   58533   return yyparse ();
   58534 }
   58535 _ATEOF
   58536 
   58537 
   58538 
   58539 $at_traceoff
   58540 echo "regression.at:868: bison -o dancer.c dancer.y"
   58541 echo regression.at:868 >$at_check_line_file
   58542 ( $at_traceon; bison -o dancer.c dancer.y ) >$at_stdout 2>$at_stder1
   58543 at_status=$?
   58544 grep '^ *+' $at_stder1 >&2
   58545 grep -v '^ *+' $at_stder1 >$at_stderr
   58546 at_failed=false
   58547 $at_diff $at_devnull $at_stderr || at_failed=:
   58548 $at_diff $at_devnull $at_stdout || at_failed=:
   58549 case $at_status in
   58550    77) echo 77 > $at_status_file
   58551             exit 77;;
   58552    0) ;;
   58553    *) echo "regression.at:868: exit code was $at_status, expected 0"
   58554       at_failed=:;;
   58555 esac
   58556 if $at_failed; then
   58557 
   58558   echo 1 > $at_status_file
   58559   exit 1
   58560 fi
   58561 
   58562 $at_traceon
   58563 
   58564 $at_traceoff
   58565 echo "regression.at:868: bison -o dancer.cc dancer.y"
   58566 echo regression.at:868 >$at_check_line_file
   58567 ( $at_traceon; bison -o dancer.cc dancer.y ) >$at_stdout 2>$at_stder1
   58568 at_status=$?
   58569 grep '^ *+' $at_stder1 >&2
   58570 grep -v '^ *+' $at_stder1 >$at_stderr
   58571 at_failed=false
   58572 $at_diff $at_devnull $at_stderr || at_failed=:
   58573 $at_diff $at_devnull $at_stdout || at_failed=:
   58574 case $at_status in
   58575    77) echo 77 > $at_status_file
   58576             exit 77;;
   58577    0) ;;
   58578    *) echo "regression.at:868: exit code was $at_status, expected 0"
   58579       at_failed=:;;
   58580 esac
   58581 if $at_failed; then
   58582 
   58583   echo 1 > $at_status_file
   58584   exit 1
   58585 fi
   58586 
   58587 $at_traceon
   58588 
   58589 
   58590 $at_traceoff
   58591 echo "regression.at:868: \$BISON_CXX_WORKS"
   58592 echo regression.at:868 >$at_check_line_file
   58593 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   58594 at_status=$?
   58595 grep '^ *+' $at_stder1 >&2
   58596 grep -v '^ *+' $at_stder1 >$at_stderr
   58597 at_failed=false
   58598 echo stderr:; cat $at_stderr
   58599 echo stdout:; cat $at_stdout
   58600 case $at_status in
   58601    77) echo 77 > $at_status_file
   58602             exit 77;;
   58603    0) ;;
   58604    *) echo "regression.at:868: exit code was $at_status, expected 0"
   58605       at_failed=:;;
   58606 esac
   58607 if $at_failed; then
   58608 
   58609   echo 1 > $at_status_file
   58610   exit 1
   58611 fi
   58612 
   58613 $at_traceon
   58614 
   58615 $at_traceoff
   58616 echo "regression.at:868: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o dancer dancer.cc \$LIBS"
   58617 echo regression.at:868 >$at_check_line_file
   58618 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o dancer dancer.cc $LIBS ) >$at_stdout 2>$at_stder1
   58619 at_status=$?
   58620 grep '^ *+' $at_stder1 >&2
   58621 grep -v '^ *+' $at_stder1 >$at_stderr
   58622 at_failed=false
   58623 echo stderr:; cat $at_stderr
   58624 echo stdout:; cat $at_stdout
   58625 case $at_status in
   58626    77) echo 77 > $at_status_file
   58627             exit 77;;
   58628    0) ;;
   58629    *) echo "regression.at:868: exit code was $at_status, expected 0"
   58630       at_failed=:;;
   58631 esac
   58632 if $at_failed; then
   58633 
   58634   echo 1 > $at_status_file
   58635   exit 1
   58636 fi
   58637 
   58638 $at_traceon
   58639 
   58640 $at_traceoff
   58641 echo "regression.at:868: \$PREPARSER ./dancer"
   58642 echo regression.at:868 >$at_check_line_file
   58643 ( $at_traceon; $PREPARSER ./dancer ) >$at_stdout 2>$at_stder1
   58644 at_status=$?
   58645 grep '^ *+' $at_stder1 >&2
   58646 grep -v '^ *+' $at_stder1 >$at_stderr
   58647 at_failed=false
   58648 echo >>$at_stderr; echo "syntax error, unexpected ':'
   58649 " | $at_diff - $at_stderr || at_failed=:
   58650 $at_diff $at_devnull $at_stdout || at_failed=:
   58651 case $at_status in
   58652    77) echo 77 > $at_status_file
   58653             exit 77;;
   58654    1) ;;
   58655    *) echo "regression.at:868: exit code was $at_status, expected 1"
   58656       at_failed=:;;
   58657 esac
   58658 if $at_failed; then
   58659 
   58660   echo 1 > $at_status_file
   58661   exit 1
   58662 fi
   58663 
   58664 $at_traceon
   58665 
   58666 
   58667 
   58668 
   58669 
   58670 
   58671 
   58672 
   58673 
   58674 
   58675 
   58676 
   58677 
   58678 
   58679 
   58680 
   58681 
   58682 
   58683 
   58684 
   58685 
   58686 
   58687       $at_traceoff
   58688       $at_times_p && times >$at_times_file
   58689     ) 5>&1 2>&1 | eval $at_tee_pipe
   58690     at_status=`cat $at_status_file`
   58691     ;;
   58692 
   58693   128 ) # 128. regression.at:963: Expecting two tokens
   58694     at_setup_line='regression.at:963'
   58695     at_desc='Expecting two tokens '
   58696     $at_quiet $ECHO_N "128: Expecting two tokens                         $ECHO_C"
   58697     at_xfail=no
   58698     (
   58699       echo "128. regression.at:963: testing ..."
   58700       $at_traceon
   58701 
   58702 
   58703 
   58704 
   58705 
   58706 # Using yacc.c?
   58707 
   58708 
   58709 
   58710 
   58711 
   58712 
   58713 
   58714 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   58715 
   58716 # yyerror always sees the locations (when activated), except if
   58717 # yacc & pure & !param.
   58718 
   58719 
   58720 # The interface is pure: either because %pure-parser, or because we
   58721 # are using the C++ parsers.
   58722 
   58723 
   58724 
   58725 
   58726 
   58727 
   58728 
   58729 
   58730 
   58731 
   58732 
   58733 cat >expect2.y <<'_ATEOF'
   58734 %{
   58735 #ifdef HAVE_CONFIG_H
   58736 # include <config.h>
   58737   /* We don't need perfect functions for these tests. */
   58738 # undef malloc
   58739 # undef memcmp
   58740 # undef realloc
   58741 #endif
   58742 %}
   58743 
   58744 %{
   58745 static int yylex (void);
   58746 #include <stdio.h>
   58747 static void yyerror (const char *);
   58748 %}
   58749 
   58750 %defines
   58751 %error-verbose
   58752 %token A 1000
   58753 %token B
   58754 
   58755 %%
   58756 program: /* empty */
   58757  | program e ';'
   58758  | program error ';';
   58759 
   58760 e: e '+' t | t;
   58761 t: A | B;
   58762 
   58763 %%
   58764 static void
   58765 yyerror (const char *s)
   58766 {
   58767   fprintf (stderr, "%s\n", s);
   58768 }
   58769 
   58770 static int
   58771 yylex (void)
   58772 {
   58773   static int toknum = 0;
   58774   static int tokens[] =
   58775     {
   58776       1000, '+', '+', -1
   58777     };
   58778 
   58779   return tokens[toknum++];
   58780 }
   58781 
   58782 int
   58783 main (void)
   58784 {
   58785   return yyparse ();
   58786 }
   58787 _ATEOF
   58788 
   58789 
   58790 
   58791 $at_traceoff
   58792 echo "regression.at:963: bison -o expect2.c expect2.y"
   58793 echo regression.at:963 >$at_check_line_file
   58794 ( $at_traceon; bison -o expect2.c expect2.y ) >$at_stdout 2>$at_stder1
   58795 at_status=$?
   58796 grep '^ *+' $at_stder1 >&2
   58797 grep -v '^ *+' $at_stder1 >$at_stderr
   58798 at_failed=false
   58799 $at_diff $at_devnull $at_stderr || at_failed=:
   58800 $at_diff $at_devnull $at_stdout || at_failed=:
   58801 case $at_status in
   58802    77) echo 77 > $at_status_file
   58803             exit 77;;
   58804    0) ;;
   58805    *) echo "regression.at:963: exit code was $at_status, expected 0"
   58806       at_failed=:;;
   58807 esac
   58808 if $at_failed; then
   58809 
   58810   echo 1 > $at_status_file
   58811   exit 1
   58812 fi
   58813 
   58814 $at_traceon
   58815 
   58816 $at_traceoff
   58817 echo "regression.at:963: bison -o expect2.c expect2.y"
   58818 echo regression.at:963 >$at_check_line_file
   58819 ( $at_traceon; bison -o expect2.c expect2.y ) >$at_stdout 2>$at_stder1
   58820 at_status=$?
   58821 grep '^ *+' $at_stder1 >&2
   58822 grep -v '^ *+' $at_stder1 >$at_stderr
   58823 at_failed=false
   58824 $at_diff $at_devnull $at_stderr || at_failed=:
   58825 $at_diff $at_devnull $at_stdout || at_failed=:
   58826 case $at_status in
   58827    77) echo 77 > $at_status_file
   58828             exit 77;;
   58829    0) ;;
   58830    *) echo "regression.at:963: exit code was $at_status, expected 0"
   58831       at_failed=:;;
   58832 esac
   58833 if $at_failed; then
   58834 
   58835   echo 1 > $at_status_file
   58836   exit 1
   58837 fi
   58838 
   58839 $at_traceon
   58840 
   58841    $at_traceoff
   58842 echo "regression.at:963: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o expect2 expect2.c \$LIBS"
   58843 echo regression.at:963 >$at_check_line_file
   58844 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o expect2 expect2.c $LIBS ) >$at_stdout 2>$at_stder1
   58845 at_status=$?
   58846 grep '^ *+' $at_stder1 >&2
   58847 grep -v '^ *+' $at_stder1 >$at_stderr
   58848 at_failed=false
   58849 echo stderr:; cat $at_stderr
   58850 echo stdout:; cat $at_stdout
   58851 case $at_status in
   58852    77) echo 77 > $at_status_file
   58853             exit 77;;
   58854    0) ;;
   58855    *) echo "regression.at:963: exit code was $at_status, expected 0"
   58856       at_failed=:;;
   58857 esac
   58858 if $at_failed; then
   58859 
   58860   echo 1 > $at_status_file
   58861   exit 1
   58862 fi
   58863 
   58864 $at_traceon
   58865 
   58866 $at_traceoff
   58867 echo "regression.at:963: \$PREPARSER ./expect2"
   58868 echo regression.at:963 >$at_check_line_file
   58869 ( $at_traceon; $PREPARSER ./expect2 ) >$at_stdout 2>$at_stder1
   58870 at_status=$?
   58871 grep '^ *+' $at_stder1 >&2
   58872 grep -v '^ *+' $at_stder1 >$at_stderr
   58873 at_failed=false
   58874 echo >>$at_stderr; echo "syntax error, unexpected '+', expecting A or B
   58875 " | $at_diff - $at_stderr || at_failed=:
   58876 $at_diff $at_devnull $at_stdout || at_failed=:
   58877 case $at_status in
   58878    77) echo 77 > $at_status_file
   58879             exit 77;;
   58880    1) ;;
   58881    *) echo "regression.at:963: exit code was $at_status, expected 1"
   58882       at_failed=:;;
   58883 esac
   58884 if $at_failed; then
   58885 
   58886   echo 1 > $at_status_file
   58887   exit 1
   58888 fi
   58889 
   58890 $at_traceon
   58891 
   58892 
   58893 
   58894 
   58895 
   58896 
   58897 
   58898 
   58899 
   58900 
   58901 
   58902 
   58903 
   58904 
   58905 
   58906 
   58907 
   58908 
   58909 
   58910 
   58911 
   58912 
   58913       $at_traceoff
   58914       $at_times_p && times >$at_times_file
   58915     ) 5>&1 2>&1 | eval $at_tee_pipe
   58916     at_status=`cat $at_status_file`
   58917     ;;
   58918 
   58919   129 ) # 129. regression.at:964: Expecting two tokens %glr-parser
   58920     at_setup_line='regression.at:964'
   58921     at_desc='Expecting two tokens %glr-parser'
   58922     $at_quiet $ECHO_N "129: Expecting two tokens %glr-parser             $ECHO_C"
   58923     at_xfail=no
   58924     (
   58925       echo "129. regression.at:964: testing ..."
   58926       $at_traceon
   58927 
   58928 
   58929 
   58930 
   58931 
   58932 # Using yacc.c?
   58933 
   58934 
   58935 
   58936 
   58937 
   58938 
   58939 
   58940 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   58941 
   58942 # yyerror always sees the locations (when activated), except if
   58943 # yacc & pure & !param.
   58944 
   58945 
   58946 # The interface is pure: either because %pure-parser, or because we
   58947 # are using the C++ parsers.
   58948 
   58949 
   58950 
   58951 
   58952 
   58953 
   58954 
   58955 
   58956 
   58957 
   58958 
   58959 cat >expect2.y <<'_ATEOF'
   58960 %{
   58961 #ifdef HAVE_CONFIG_H
   58962 # include <config.h>
   58963   /* We don't need perfect functions for these tests. */
   58964 # undef malloc
   58965 # undef memcmp
   58966 # undef realloc
   58967 #endif
   58968 %}
   58969 
   58970 %{
   58971 static int yylex (void);
   58972 #include <stdio.h>
   58973 static void yyerror (const char *);
   58974 %}
   58975 %glr-parser
   58976 %defines
   58977 %error-verbose
   58978 %token A 1000
   58979 %token B
   58980 
   58981 %%
   58982 program: /* empty */
   58983  | program e ';'
   58984  | program error ';';
   58985 
   58986 e: e '+' t | t;
   58987 t: A | B;
   58988 
   58989 %%
   58990 static void
   58991 yyerror (const char *s)
   58992 {
   58993   fprintf (stderr, "%s\n", s);
   58994 }
   58995 
   58996 static int
   58997 yylex (void)
   58998 {
   58999   static int toknum = 0;
   59000   static int tokens[] =
   59001     {
   59002       1000, '+', '+', -1
   59003     };
   59004 
   59005   return tokens[toknum++];
   59006 }
   59007 
   59008 int
   59009 main (void)
   59010 {
   59011   return yyparse ();
   59012 }
   59013 _ATEOF
   59014 
   59015 
   59016 
   59017 $at_traceoff
   59018 echo "regression.at:964: bison -o expect2.c expect2.y"
   59019 echo regression.at:964 >$at_check_line_file
   59020 ( $at_traceon; bison -o expect2.c expect2.y ) >$at_stdout 2>$at_stder1
   59021 at_status=$?
   59022 grep '^ *+' $at_stder1 >&2
   59023 grep -v '^ *+' $at_stder1 >$at_stderr
   59024 at_failed=false
   59025 $at_diff $at_devnull $at_stderr || at_failed=:
   59026 $at_diff $at_devnull $at_stdout || at_failed=:
   59027 case $at_status in
   59028    77) echo 77 > $at_status_file
   59029             exit 77;;
   59030    0) ;;
   59031    *) echo "regression.at:964: exit code was $at_status, expected 0"
   59032       at_failed=:;;
   59033 esac
   59034 if $at_failed; then
   59035 
   59036   echo 1 > $at_status_file
   59037   exit 1
   59038 fi
   59039 
   59040 $at_traceon
   59041 
   59042 $at_traceoff
   59043 echo "regression.at:964: bison -o expect2.c expect2.y"
   59044 echo regression.at:964 >$at_check_line_file
   59045 ( $at_traceon; bison -o expect2.c expect2.y ) >$at_stdout 2>$at_stder1
   59046 at_status=$?
   59047 grep '^ *+' $at_stder1 >&2
   59048 grep -v '^ *+' $at_stder1 >$at_stderr
   59049 at_failed=false
   59050 $at_diff $at_devnull $at_stderr || at_failed=:
   59051 $at_diff $at_devnull $at_stdout || at_failed=:
   59052 case $at_status in
   59053    77) echo 77 > $at_status_file
   59054             exit 77;;
   59055    0) ;;
   59056    *) echo "regression.at:964: exit code was $at_status, expected 0"
   59057       at_failed=:;;
   59058 esac
   59059 if $at_failed; then
   59060 
   59061   echo 1 > $at_status_file
   59062   exit 1
   59063 fi
   59064 
   59065 $at_traceon
   59066 
   59067    $at_traceoff
   59068 echo "regression.at:964: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o expect2 expect2.c \$LIBS"
   59069 echo regression.at:964 >$at_check_line_file
   59070 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o expect2 expect2.c $LIBS ) >$at_stdout 2>$at_stder1
   59071 at_status=$?
   59072 grep '^ *+' $at_stder1 >&2
   59073 grep -v '^ *+' $at_stder1 >$at_stderr
   59074 at_failed=false
   59075 echo stderr:; cat $at_stderr
   59076 echo stdout:; cat $at_stdout
   59077 case $at_status in
   59078    77) echo 77 > $at_status_file
   59079             exit 77;;
   59080    0) ;;
   59081    *) echo "regression.at:964: exit code was $at_status, expected 0"
   59082       at_failed=:;;
   59083 esac
   59084 if $at_failed; then
   59085 
   59086   echo 1 > $at_status_file
   59087   exit 1
   59088 fi
   59089 
   59090 $at_traceon
   59091 
   59092 $at_traceoff
   59093 echo "regression.at:964: \$PREPARSER ./expect2"
   59094 echo regression.at:964 >$at_check_line_file
   59095 ( $at_traceon; $PREPARSER ./expect2 ) >$at_stdout 2>$at_stder1
   59096 at_status=$?
   59097 grep '^ *+' $at_stder1 >&2
   59098 grep -v '^ *+' $at_stder1 >$at_stderr
   59099 at_failed=false
   59100 echo >>$at_stderr; echo "syntax error, unexpected '+', expecting A or B
   59101 " | $at_diff - $at_stderr || at_failed=:
   59102 $at_diff $at_devnull $at_stdout || at_failed=:
   59103 case $at_status in
   59104    77) echo 77 > $at_status_file
   59105             exit 77;;
   59106    1) ;;
   59107    *) echo "regression.at:964: exit code was $at_status, expected 1"
   59108       at_failed=:;;
   59109 esac
   59110 if $at_failed; then
   59111 
   59112   echo 1 > $at_status_file
   59113   exit 1
   59114 fi
   59115 
   59116 $at_traceon
   59117 
   59118 
   59119 
   59120 
   59121 
   59122 
   59123 
   59124 
   59125 
   59126 
   59127 
   59128 
   59129 
   59130 
   59131 
   59132 
   59133 
   59134 
   59135 
   59136 
   59137 
   59138 
   59139       $at_traceoff
   59140       $at_times_p && times >$at_times_file
   59141     ) 5>&1 2>&1 | eval $at_tee_pipe
   59142     at_status=`cat $at_status_file`
   59143     ;;
   59144 
   59145   130 ) # 130. regression.at:965: Expecting two tokens %skeleton "lalr1.cc"
   59146     at_setup_line='regression.at:965'
   59147     at_desc='Expecting two tokens %skeleton "lalr1.cc"'
   59148     $at_quiet $ECHO_N "130: Expecting two tokens %skeleton "lalr1.cc"    $ECHO_C"
   59149     at_xfail=no
   59150     (
   59151       echo "130. regression.at:965: testing ..."
   59152       $at_traceon
   59153 
   59154 
   59155 
   59156 
   59157 
   59158 # Using yacc.c?
   59159 
   59160 
   59161 
   59162 
   59163 
   59164 
   59165 
   59166 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   59167 
   59168 # yyerror always sees the locations (when activated), except if
   59169 # yacc & pure & !param.
   59170 
   59171 
   59172 # The interface is pure: either because %pure-parser, or because we
   59173 # are using the C++ parsers.
   59174 
   59175 
   59176 
   59177 
   59178 
   59179 
   59180 
   59181 
   59182 
   59183 
   59184 
   59185 cat >expect2.y <<'_ATEOF'
   59186 %{
   59187 #ifdef HAVE_CONFIG_H
   59188 # include <config.h>
   59189   /* We don't need perfect functions for these tests. */
   59190 # undef malloc
   59191 # undef memcmp
   59192 # undef realloc
   59193 #endif
   59194 %}
   59195 
   59196 %{
   59197 static int yylex (int *);
   59198 
   59199 %}
   59200 %skeleton "lalr1.cc"
   59201 %defines
   59202 %error-verbose
   59203 %token A 1000
   59204 %token B
   59205 
   59206 %%
   59207 program: /* empty */
   59208  | program e ';'
   59209  | program error ';';
   59210 
   59211 e: e '+' t | t;
   59212 t: A | B;
   59213 
   59214 %%
   59215 /* A C++ error reporting function. */
   59216 void
   59217 yy::parser::error (const location&, const std::string& m)
   59218 {
   59219   std::cerr << m << std::endl;
   59220 }
   59221 
   59222 int
   59223 yyparse ()
   59224 {
   59225   yy::parser parser;
   59226   return parser.parse ();
   59227 }
   59228 
   59229 
   59230 static int
   59231 yylex (int *lval)
   59232 {
   59233   static int toknum = 0;
   59234   static int tokens[] =
   59235     {
   59236       1000, '+', '+', -1
   59237     };
   59238   *lval = 0; /* Pacify GCC.  */
   59239   return tokens[toknum++];
   59240 }
   59241 
   59242 int
   59243 main (void)
   59244 {
   59245   return yyparse ();
   59246 }
   59247 _ATEOF
   59248 
   59249 
   59250 
   59251 $at_traceoff
   59252 echo "regression.at:965: bison -o expect2.c expect2.y"
   59253 echo regression.at:965 >$at_check_line_file
   59254 ( $at_traceon; bison -o expect2.c expect2.y ) >$at_stdout 2>$at_stder1
   59255 at_status=$?
   59256 grep '^ *+' $at_stder1 >&2
   59257 grep -v '^ *+' $at_stder1 >$at_stderr
   59258 at_failed=false
   59259 $at_diff $at_devnull $at_stderr || at_failed=:
   59260 $at_diff $at_devnull $at_stdout || at_failed=:
   59261 case $at_status in
   59262    77) echo 77 > $at_status_file
   59263             exit 77;;
   59264    0) ;;
   59265    *) echo "regression.at:965: exit code was $at_status, expected 0"
   59266       at_failed=:;;
   59267 esac
   59268 if $at_failed; then
   59269 
   59270   echo 1 > $at_status_file
   59271   exit 1
   59272 fi
   59273 
   59274 $at_traceon
   59275 
   59276 $at_traceoff
   59277 echo "regression.at:965: bison -o expect2.cc expect2.y"
   59278 echo regression.at:965 >$at_check_line_file
   59279 ( $at_traceon; bison -o expect2.cc expect2.y ) >$at_stdout 2>$at_stder1
   59280 at_status=$?
   59281 grep '^ *+' $at_stder1 >&2
   59282 grep -v '^ *+' $at_stder1 >$at_stderr
   59283 at_failed=false
   59284 $at_diff $at_devnull $at_stderr || at_failed=:
   59285 $at_diff $at_devnull $at_stdout || at_failed=:
   59286 case $at_status in
   59287    77) echo 77 > $at_status_file
   59288             exit 77;;
   59289    0) ;;
   59290    *) echo "regression.at:965: exit code was $at_status, expected 0"
   59291       at_failed=:;;
   59292 esac
   59293 if $at_failed; then
   59294 
   59295   echo 1 > $at_status_file
   59296   exit 1
   59297 fi
   59298 
   59299 $at_traceon
   59300 
   59301 
   59302 $at_traceoff
   59303 echo "regression.at:965: \$BISON_CXX_WORKS"
   59304 echo regression.at:965 >$at_check_line_file
   59305 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   59306 at_status=$?
   59307 grep '^ *+' $at_stder1 >&2
   59308 grep -v '^ *+' $at_stder1 >$at_stderr
   59309 at_failed=false
   59310 echo stderr:; cat $at_stderr
   59311 echo stdout:; cat $at_stdout
   59312 case $at_status in
   59313    77) echo 77 > $at_status_file
   59314             exit 77;;
   59315    0) ;;
   59316    *) echo "regression.at:965: exit code was $at_status, expected 0"
   59317       at_failed=:;;
   59318 esac
   59319 if $at_failed; then
   59320 
   59321   echo 1 > $at_status_file
   59322   exit 1
   59323 fi
   59324 
   59325 $at_traceon
   59326 
   59327 $at_traceoff
   59328 echo "regression.at:965: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o expect2 expect2.cc \$LIBS"
   59329 echo regression.at:965 >$at_check_line_file
   59330 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o expect2 expect2.cc $LIBS ) >$at_stdout 2>$at_stder1
   59331 at_status=$?
   59332 grep '^ *+' $at_stder1 >&2
   59333 grep -v '^ *+' $at_stder1 >$at_stderr
   59334 at_failed=false
   59335 echo stderr:; cat $at_stderr
   59336 echo stdout:; cat $at_stdout
   59337 case $at_status in
   59338    77) echo 77 > $at_status_file
   59339             exit 77;;
   59340    0) ;;
   59341    *) echo "regression.at:965: exit code was $at_status, expected 0"
   59342       at_failed=:;;
   59343 esac
   59344 if $at_failed; then
   59345 
   59346   echo 1 > $at_status_file
   59347   exit 1
   59348 fi
   59349 
   59350 $at_traceon
   59351 
   59352 $at_traceoff
   59353 echo "regression.at:965: \$PREPARSER ./expect2"
   59354 echo regression.at:965 >$at_check_line_file
   59355 ( $at_traceon; $PREPARSER ./expect2 ) >$at_stdout 2>$at_stder1
   59356 at_status=$?
   59357 grep '^ *+' $at_stder1 >&2
   59358 grep -v '^ *+' $at_stder1 >$at_stderr
   59359 at_failed=false
   59360 echo >>$at_stderr; echo "syntax error, unexpected '+', expecting A or B
   59361 " | $at_diff - $at_stderr || at_failed=:
   59362 $at_diff $at_devnull $at_stdout || at_failed=:
   59363 case $at_status in
   59364    77) echo 77 > $at_status_file
   59365             exit 77;;
   59366    1) ;;
   59367    *) echo "regression.at:965: exit code was $at_status, expected 1"
   59368       at_failed=:;;
   59369 esac
   59370 if $at_failed; then
   59371 
   59372   echo 1 > $at_status_file
   59373   exit 1
   59374 fi
   59375 
   59376 $at_traceon
   59377 
   59378 
   59379 
   59380 
   59381 
   59382 
   59383 
   59384 
   59385 
   59386 
   59387 
   59388 
   59389 
   59390 
   59391 
   59392 
   59393 
   59394 
   59395 
   59396 
   59397 
   59398 
   59399       $at_traceoff
   59400       $at_times_p && times >$at_times_file
   59401     ) 5>&1 2>&1 | eval $at_tee_pipe
   59402     at_status=`cat $at_status_file`
   59403     ;;
   59404 
   59405 
   59406   banner-16 ) # Banner 16. c++.at:19
   59407     cat <<\_ATEOF
   59408 
   59409 C++ Features.
   59410 
   59411 _ATEOF
   59412     ;;
   59413 
   59414   131 ) # 131. c++.at:102: Doxygen Public Documentation
   59415     at_setup_line='c++.at:102'
   59416     at_desc='Doxygen Public Documentation'
   59417     $at_quiet $ECHO_N "131: Doxygen Public Documentation                 $ECHO_C"
   59418     at_xfail=no
   59419     (
   59420       echo "131. c++.at:102: testing ..."
   59421       $at_traceon
   59422 
   59423 
   59424 cat >input.yy <<'_ATEOF'
   59425 %skeleton "lalr1.cc"
   59426 %locations
   59427 %debug
   59428 %defines
   59429 %%
   59430 exp:;
   59431 %%
   59432 yy::parser::error (const location& l, const std::string& m)
   59433 {
   59434   std::cerr << l << s << std::endl;
   59435 }
   59436 _ATEOF
   59437 
   59438 
   59439 $at_traceoff
   59440 echo "c++.at:102: bison -o input.cc input.yy"
   59441 echo c++.at:102 >$at_check_line_file
   59442 ( $at_traceon; bison -o input.cc input.yy ) >$at_stdout 2>$at_stder1
   59443 at_status=$?
   59444 grep '^ *+' $at_stder1 >&2
   59445 grep -v '^ *+' $at_stder1 >$at_stderr
   59446 at_failed=false
   59447 $at_diff $at_devnull $at_stderr || at_failed=:
   59448 $at_diff $at_devnull $at_stdout || at_failed=:
   59449 case $at_status in
   59450    77) echo 77 > $at_status_file
   59451             exit 77;;
   59452    0) ;;
   59453    *) echo "c++.at:102: exit code was $at_status, expected 0"
   59454       at_failed=:;;
   59455 esac
   59456 if $at_failed; then
   59457 
   59458   echo 1 > $at_status_file
   59459   exit 1
   59460 fi
   59461 
   59462 $at_traceon
   59463 
   59464 
   59465 cat >Doxyfile <<'_ATEOF'
   59466 # The PROJECT_NAME tag is a single word (or a sequence of words
   59467 # surrounded by quotes) that should identify the project.
   59468 PROJECT_NAME = "Bison C++ Parser"
   59469 
   59470 # The QUIET tag can be used to turn on/off the messages that are
   59471 # generated by doxygen. Possible values are YES and NO. If left blank
   59472 # NO is used.
   59473 QUIET = YES
   59474 
   59475 # The WARNINGS tag can be used to turn on/off the warning messages
   59476 # that are generated by doxygen. Possible values are YES and NO. If
   59477 # left blank NO is used.
   59478 WARNINGS     = YES
   59479 # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate
   59480 # warnings for undocumented members. If EXTRACT_ALL is set to YES then
   59481 # this flag will automatically be disabled.
   59482 WARN_IF_UNDOCUMENTED   = YES
   59483 # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings
   59484 # for potential errors in the documentation, such as not documenting
   59485 # some parameters in a documented function, or documenting parameters
   59486 # that don't exist or using markup commands wrongly.
   59487 WARN_IF_DOC_ERROR      = YES
   59488 # The WARN_FORMAT tag determines the format of the warning messages
   59489 # that doxygen can produce. The string should contain the $file,
   59490 # $line, and $text tags, which will be replaced by the file and line
   59491 # number from which the warning originated and the warning text.
   59492 WARN_FORMAT            = "$file:$line: $text"
   59493 
   59494 # If the EXTRACT_ALL tag is set to YES doxygen will assume all
   59495 # entities in documentation are documented, even if no documentation
   59496 # was available.  Private class members and static file members will
   59497 # be hidden unless the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set
   59498 # to YES
   59499 EXTRACT_ALL            = YES
   59500 
   59501 # If the EXTRACT_PRIVATE tag is set to YES all private members of a
   59502 # class will be included in the documentation.
   59503 EXTRACT_PRIVATE        = NO
   59504 
   59505 # If the EXTRACT_STATIC tag is set to YES all static members of a file
   59506 # will be included in the documentation.
   59507 EXTRACT_STATIC         = NO
   59508 _ATEOF
   59509 
   59510 
   59511 $at_traceoff
   59512 echo "c++.at:102: doxygen --version || exit 77"
   59513 echo c++.at:102 >$at_check_line_file
   59514 ( $at_traceon; doxygen --version || exit 77 ) >$at_stdout 2>$at_stder1
   59515 at_status=$?
   59516 grep '^ *+' $at_stder1 >&2
   59517 grep -v '^ *+' $at_stder1 >$at_stderr
   59518 at_failed=false
   59519 $at_diff $at_devnull $at_stderr || at_failed=:
   59520 echo stdout:; cat $at_stdout
   59521 case $at_status in
   59522    77) echo 77 > $at_status_file
   59523             exit 77;;
   59524    0) ;;
   59525    *) echo "c++.at:102: exit code was $at_status, expected 0"
   59526       at_failed=:;;
   59527 esac
   59528 if $at_failed; then
   59529 
   59530   echo 1 > $at_status_file
   59531   exit 1
   59532 fi
   59533 
   59534 $at_traceon
   59535 
   59536 $at_traceoff
   59537 echo "c++.at:102: doxygen"
   59538 echo c++.at:102 >$at_check_line_file
   59539 ( $at_traceon; doxygen ) >$at_stdout 2>$at_stder1
   59540 at_status=$?
   59541 grep '^ *+' $at_stder1 >&2
   59542 grep -v '^ *+' $at_stder1 >$at_stderr
   59543 at_failed=false
   59544 echo stderr:; cat $at_stderr
   59545 $at_diff $at_devnull $at_stdout || at_failed=:
   59546 case $at_status in
   59547    77) echo 77 > $at_status_file
   59548             exit 77;;
   59549    0) ;;
   59550    *) echo "c++.at:102: exit code was $at_status, expected 0"
   59551       at_failed=:;;
   59552 esac
   59553 if $at_failed; then
   59554 
   59555   echo 1 > $at_status_file
   59556   exit 1
   59557 fi
   59558 
   59559 $at_traceon
   59560 
   59561 
   59562       $at_traceoff
   59563       $at_times_p && times >$at_times_file
   59564     ) 5>&1 2>&1 | eval $at_tee_pipe
   59565     at_status=`cat $at_status_file`
   59566     ;;
   59567 
   59568   132 ) # 132. c++.at:103: Doxygen Private Documentation
   59569     at_setup_line='c++.at:103'
   59570     at_desc='Doxygen Private Documentation'
   59571     $at_quiet $ECHO_N "132: Doxygen Private Documentation                $ECHO_C"
   59572     at_xfail=no
   59573     (
   59574       echo "132. c++.at:103: testing ..."
   59575       $at_traceon
   59576 
   59577 
   59578 cat >input.yy <<'_ATEOF'
   59579 %skeleton "lalr1.cc"
   59580 %locations
   59581 %debug
   59582 %defines
   59583 %%
   59584 exp:;
   59585 %%
   59586 yy::parser::error (const location& l, const std::string& m)
   59587 {
   59588   std::cerr << l << s << std::endl;
   59589 }
   59590 _ATEOF
   59591 
   59592 
   59593 $at_traceoff
   59594 echo "c++.at:103: bison -o input.cc input.yy"
   59595 echo c++.at:103 >$at_check_line_file
   59596 ( $at_traceon; bison -o input.cc input.yy ) >$at_stdout 2>$at_stder1
   59597 at_status=$?
   59598 grep '^ *+' $at_stder1 >&2
   59599 grep -v '^ *+' $at_stder1 >$at_stderr
   59600 at_failed=false
   59601 $at_diff $at_devnull $at_stderr || at_failed=:
   59602 $at_diff $at_devnull $at_stdout || at_failed=:
   59603 case $at_status in
   59604    77) echo 77 > $at_status_file
   59605             exit 77;;
   59606    0) ;;
   59607    *) echo "c++.at:103: exit code was $at_status, expected 0"
   59608       at_failed=:;;
   59609 esac
   59610 if $at_failed; then
   59611 
   59612   echo 1 > $at_status_file
   59613   exit 1
   59614 fi
   59615 
   59616 $at_traceon
   59617 
   59618 
   59619 cat >Doxyfile <<'_ATEOF'
   59620 # The PROJECT_NAME tag is a single word (or a sequence of words
   59621 # surrounded by quotes) that should identify the project.
   59622 PROJECT_NAME = "Bison C++ Parser"
   59623 
   59624 # The QUIET tag can be used to turn on/off the messages that are
   59625 # generated by doxygen. Possible values are YES and NO. If left blank
   59626 # NO is used.
   59627 QUIET = YES
   59628 
   59629 # The WARNINGS tag can be used to turn on/off the warning messages
   59630 # that are generated by doxygen. Possible values are YES and NO. If
   59631 # left blank NO is used.
   59632 WARNINGS     = YES
   59633 # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate
   59634 # warnings for undocumented members. If EXTRACT_ALL is set to YES then
   59635 # this flag will automatically be disabled.
   59636 WARN_IF_UNDOCUMENTED   = YES
   59637 # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings
   59638 # for potential errors in the documentation, such as not documenting
   59639 # some parameters in a documented function, or documenting parameters
   59640 # that don't exist or using markup commands wrongly.
   59641 WARN_IF_DOC_ERROR      = YES
   59642 # The WARN_FORMAT tag determines the format of the warning messages
   59643 # that doxygen can produce. The string should contain the $file,
   59644 # $line, and $text tags, which will be replaced by the file and line
   59645 # number from which the warning originated and the warning text.
   59646 WARN_FORMAT            = "$file:$line: $text"
   59647 
   59648 # If the EXTRACT_ALL tag is set to YES doxygen will assume all
   59649 # entities in documentation are documented, even if no documentation
   59650 # was available.  Private class members and static file members will
   59651 # be hidden unless the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set
   59652 # to YES
   59653 EXTRACT_ALL            = YES
   59654 
   59655 # If the EXTRACT_PRIVATE tag is set to YES all private members of a
   59656 # class will be included in the documentation.
   59657 EXTRACT_PRIVATE        = YES
   59658 
   59659 # If the EXTRACT_STATIC tag is set to YES all static members of a file
   59660 # will be included in the documentation.
   59661 EXTRACT_STATIC         = YES
   59662 _ATEOF
   59663 
   59664 
   59665 $at_traceoff
   59666 echo "c++.at:103: doxygen --version || exit 77"
   59667 echo c++.at:103 >$at_check_line_file
   59668 ( $at_traceon; doxygen --version || exit 77 ) >$at_stdout 2>$at_stder1
   59669 at_status=$?
   59670 grep '^ *+' $at_stder1 >&2
   59671 grep -v '^ *+' $at_stder1 >$at_stderr
   59672 at_failed=false
   59673 $at_diff $at_devnull $at_stderr || at_failed=:
   59674 echo stdout:; cat $at_stdout
   59675 case $at_status in
   59676    77) echo 77 > $at_status_file
   59677             exit 77;;
   59678    0) ;;
   59679    *) echo "c++.at:103: exit code was $at_status, expected 0"
   59680       at_failed=:;;
   59681 esac
   59682 if $at_failed; then
   59683 
   59684   echo 1 > $at_status_file
   59685   exit 1
   59686 fi
   59687 
   59688 $at_traceon
   59689 
   59690 $at_traceoff
   59691 echo "c++.at:103: doxygen"
   59692 echo c++.at:103 >$at_check_line_file
   59693 ( $at_traceon; doxygen ) >$at_stdout 2>$at_stder1
   59694 at_status=$?
   59695 grep '^ *+' $at_stder1 >&2
   59696 grep -v '^ *+' $at_stder1 >$at_stderr
   59697 at_failed=false
   59698 echo stderr:; cat $at_stderr
   59699 $at_diff $at_devnull $at_stdout || at_failed=:
   59700 case $at_status in
   59701    77) echo 77 > $at_status_file
   59702             exit 77;;
   59703    0) ;;
   59704    *) echo "c++.at:103: exit code was $at_status, expected 0"
   59705       at_failed=:;;
   59706 esac
   59707 if $at_failed; then
   59708 
   59709   echo 1 > $at_status_file
   59710   exit 1
   59711 fi
   59712 
   59713 $at_traceon
   59714 
   59715 
   59716       $at_traceoff
   59717       $at_times_p && times >$at_times_file
   59718     ) 5>&1 2>&1 | eval $at_tee_pipe
   59719     at_status=`cat $at_status_file`
   59720     ;;
   59721 
   59722 
   59723   banner-17 ) # Banner 17. cxx-type.at:19
   59724     cat <<\_ATEOF
   59725 
   59726 C++ Type Syntax (GLR).
   59727 
   59728 _ATEOF
   59729     ;;
   59730 
   59731   133 ) # 133. cxx-type.at:412: GLR: Resolve ambiguity, impure, no locations
   59732     at_setup_line='cxx-type.at:412'
   59733     at_desc='GLR: Resolve ambiguity, impure, no locations'
   59734     $at_quiet $ECHO_N "133: GLR: Resolve ambiguity, impure, no locations $ECHO_C"
   59735     at_xfail=no
   59736     (
   59737       echo "133. cxx-type.at:412: testing ..."
   59738       $at_traceon
   59739 
   59740 
   59741 
   59742 
   59743 
   59744 
   59745 # Using yacc.c?
   59746 
   59747 
   59748 
   59749 
   59750 
   59751 
   59752 
   59753 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   59754 
   59755 # yyerror always sees the locations (when activated), except if
   59756 # yacc & pure & !param.
   59757 
   59758 
   59759 # The interface is pure: either because %pure-parser, or because we
   59760 # are using the C++ parsers.
   59761 
   59762 
   59763 
   59764 
   59765 
   59766 
   59767 
   59768 
   59769 
   59770 
   59771 
   59772 
   59773 cat >types.y <<'_ATEOF'
   59774 %{
   59775 #ifdef HAVE_CONFIG_H
   59776 # include <config.h>
   59777   /* We don't need perfect functions for these tests. */
   59778 # undef malloc
   59779 # undef memcmp
   59780 # undef realloc
   59781 #endif
   59782 %}
   59783 
   59784 /* Simplified C++ Type and Expression Grammar.  */
   59785 
   59786 
   59787 
   59788 %{
   59789   #include <stdio.h>
   59790   union Node {
   59791     struct {
   59792       int isNterm;
   59793       int parents;
   59794     } nodeInfo;
   59795     struct {
   59796       int isNterm; /* 1 */
   59797       int parents;
   59798       char const *form;
   59799       union Node *children[3];
   59800     } nterm;
   59801     struct {
   59802       int isNterm; /* 0 */
   59803       int parents;
   59804       char *text;
   59805     } term;
   59806   };
   59807   typedef union Node Node;
   59808   static Node *new_nterm (char const *, Node *, Node *, Node *);
   59809   static Node *new_term (char *);
   59810   static void free_node (Node *);
   59811   static char *node_to_string (Node *);
   59812   #define YYSTYPE Node *
   59813 
   59814   #define YYINITDEPTH 10
   59815   #define YYSTACKEXPANDABLE 1
   59816   struct YYLTYPE;
   59817 #if YYPURE
   59818 # if YYLSP_NEEDED
   59819 #  define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
   59820 #  define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
   59821 # else
   59822 #  define LEX_PARAMETERS YYSTYPE *lvalp
   59823 # endif
   59824 #endif
   59825 #ifndef LEX_PARAMETERS
   59826 # define LEX_PARAMETERS void
   59827 #endif
   59828 #ifndef ERROR_PARAMETERS
   59829 # define ERROR_PARAMETERS char const *s
   59830 #endif
   59831   int yylex (LEX_PARAMETERS);
   59832   void yyerror (ERROR_PARAMETERS);
   59833 %}
   59834 
   59835 %token TYPENAME ID
   59836 
   59837 %right '='
   59838 %left '+'
   59839 
   59840 %glr-parser
   59841 
   59842 %destructor { free_node ($$); } stmt expr decl declarator TYPENAME ID
   59843 
   59844 %%
   59845 
   59846 prog :
   59847      | prog stmt   {
   59848 			char *output;
   59849 			output = node_to_string ($2);
   59850 			printf ("%s\n", output);
   59851 			free (output);
   59852 			free_node ($2);
   59853 		   }
   59854      ;
   59855 
   59856 stmt : expr ';'  %dprec 1	{ $$ = $1; }
   59857      | decl      %dprec 2
   59858      | error ';'	{ $$ = new_nterm ("<error>", 0, 0, 0); }
   59859      | '@'		{ YYACCEPT; }
   59860      ;
   59861 
   59862 expr : ID
   59863      | TYPENAME '(' expr ')'
   59864 			{ $$ = new_nterm ("<cast>(%s,%s)", $3, $1, 0); }
   59865      | expr '+' expr	{ $$ = new_nterm ("+(%s,%s)", $1, $3, 0); }
   59866      | expr '=' expr    { $$ = new_nterm ("=(%s,%s)", $1, $3, 0); }
   59867      ;
   59868 
   59869 decl : TYPENAME declarator ';'
   59870 			{ $$ = new_nterm ("<declare>(%s,%s)", $1, $2, 0); }
   59871      | TYPENAME declarator '=' expr ';'
   59872 			{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
   59873 					  $2, $4); }
   59874      ;
   59875 
   59876 declarator : ID
   59877      | '(' declarator ')' { $$ = $2; }
   59878      ;
   59879 
   59880 %%
   59881 
   59882 #include <ctype.h>
   59883 #include <stdlib.h>
   59884 #include <string.h>
   59885 #include <stdarg.h>
   59886 
   59887 int
   59888 main (int argc, char **argv)
   59889 {
   59890   if (argc != 2)
   59891     abort ();
   59892   if (!freopen (argv[1], "r", stdin))
   59893     return 3;
   59894   return yyparse ();
   59895 }
   59896 
   59897 int
   59898 yylex (LEX_PARAMETERS)
   59899 {
   59900   char buffer[256];
   59901   int c;
   59902   unsigned int i;
   59903   static int lineNum = 1;
   59904   static int colNum = 0;
   59905 
   59906 #if YYPURE
   59907 # undef yylloc
   59908 # define yylloc (*llocp)
   59909 # undef yylval
   59910 # define yylval (*lvalp)
   59911 #endif
   59912 
   59913   while (1)
   59914     {
   59915       c = getchar ();
   59916       switch (c)
   59917 	{
   59918 	case EOF:
   59919 	  return 0;
   59920 	case '\t':
   59921 	  colNum = (colNum + 7) & ~7;
   59922 	  break;
   59923 	case ' ': case '\f':
   59924 	  colNum += 1;
   59925 	  break;
   59926 	case '\n':
   59927 	  lineNum += 1;
   59928 	  colNum = 0;
   59929 	  break;
   59930 	default:
   59931 	  {
   59932 	    int tok;
   59933 #if YYLSP_NEEDED
   59934 	    yylloc.first_line = yylloc.last_line = lineNum;
   59935 	    yylloc.first_column = colNum;
   59936 #endif
   59937 	    if (isalpha (c))
   59938 	      {
   59939 		i = 0;
   59940 
   59941 		do
   59942 		  {
   59943 		    buffer[i++] = c;
   59944 		    colNum += 1;
   59945 		    if (i == sizeof buffer - 1)
   59946 		      abort ();
   59947 		    c = getchar ();
   59948 		  }
   59949 		while (isalnum (c) || c == '_');
   59950 
   59951 		ungetc (c, stdin);
   59952 		buffer[i++] = 0;
   59953 		tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
   59954 		yylval = new_term (strcpy ((char *) malloc (i), buffer));
   59955 	      }
   59956 	    else
   59957 	      {
   59958 		colNum += 1;
   59959 		tok = c;
   59960 		yylval = 0;
   59961 	      }
   59962 #if YYLSP_NEEDED
   59963 	    yylloc.last_column = colNum-1;
   59964 #endif
   59965 	    return tok;
   59966 	  }
   59967 	}
   59968     }
   59969 }
   59970 
   59971 void
   59972 yyerror (ERROR_PARAMETERS)
   59973 {
   59974 #if YYPURE && YYLSP_NEEDED
   59975   /* Pacify GCC by using llocp.  */
   59976   if (! llocp)
   59977     abort ();
   59978 #endif
   59979   fprintf (stderr, "%s\n", s);
   59980 }
   59981 
   59982 static Node *
   59983 new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
   59984 {
   59985   Node *node = (Node *) malloc (sizeof (Node));
   59986   node->nterm.isNterm = 1;
   59987   node->nterm.parents = 0;
   59988   node->nterm.form = form;
   59989   node->nterm.children[0] = child0;
   59990   if (child0)
   59991     child0->nodeInfo.parents += 1;
   59992   node->nterm.children[1] = child1;
   59993   if (child1)
   59994     child1->nodeInfo.parents += 1;
   59995   node->nterm.children[2] = child2;
   59996   if (child2)
   59997     child2->nodeInfo.parents += 1;
   59998   return node;
   59999 }
   60000 
   60001 static Node *
   60002 new_term (char *text)
   60003 {
   60004   Node *node = (Node *) malloc (sizeof (Node));
   60005   node->term.isNterm = 0;
   60006   node->term.parents = 0;
   60007   node->term.text = text;
   60008   return node;
   60009 }
   60010 
   60011 static void
   60012 free_node (Node *node)
   60013 {
   60014   if (!node)
   60015     return;
   60016   node->nodeInfo.parents -= 1;
   60017   /* Free only if 0 (last parent) or -1 (no parents).  */
   60018   if (node->nodeInfo.parents > 0)
   60019     return;
   60020   if (node->nodeInfo.isNterm == 1)
   60021     {
   60022       free_node (node->nterm.children[0]);
   60023       free_node (node->nterm.children[1]);
   60024       free_node (node->nterm.children[2]);
   60025     }
   60026   else
   60027     free (node->term.text);
   60028   free (node);
   60029 }
   60030 
   60031 static char *
   60032 node_to_string (Node *node)
   60033 {
   60034   char *child0;
   60035   char *child1;
   60036   char *child2;
   60037   char *buffer;
   60038   if (!node)
   60039     {
   60040       buffer = (char *) malloc (1);
   60041       buffer[0] = 0;
   60042     }
   60043   else if (node->nodeInfo.isNterm == 1)
   60044     {
   60045       child0 = node_to_string (node->nterm.children[0]);
   60046       child1 = node_to_string (node->nterm.children[1]);
   60047       child2 = node_to_string (node->nterm.children[2]);
   60048       buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
   60049 				+ strlen (child1) + strlen (child2) + 1);
   60050       sprintf (buffer, node->nterm.form, child0, child1, child2);
   60051       free (child0);
   60052       free (child1);
   60053       free (child2);
   60054     }
   60055   else
   60056     buffer = strdup (node->term.text);
   60057   return buffer;
   60058 }
   60059 
   60060 
   60061 
   60062 _ATEOF
   60063 
   60064 
   60065 
   60066 cat >test-input <<'_ATEOF'
   60067 
   60068 
   60069 z + q;
   60070 
   60071 T x;
   60072 
   60073 T x = y;
   60074 
   60075 x = y;
   60076 
   60077 T (x) + y;
   60078 
   60079 T (x);
   60080 
   60081 T (y) = z + q;
   60082 
   60083 T (y y) = z + q;
   60084 
   60085 z + q;
   60086 
   60087 @
   60088 
   60089 This is total garbage, but it should be ignored.
   60090 _ATEOF
   60091 
   60092 
   60093 $at_traceoff
   60094 echo "cxx-type.at:414: bison -o types.c types.y"
   60095 echo cxx-type.at:414 >$at_check_line_file
   60096 ( $at_traceon; bison -o types.c types.y ) >$at_stdout 2>$at_stder1
   60097 at_status=$?
   60098 grep '^ *+' $at_stder1 >&2
   60099 grep -v '^ *+' $at_stder1 >$at_stderr
   60100 at_failed=false
   60101 echo stderr:; cat $at_stderr
   60102 $at_diff $at_devnull $at_stdout || at_failed=:
   60103 case $at_status in
   60104    77) echo 77 > $at_status_file
   60105             exit 77;;
   60106    0) ;;
   60107    *) echo "cxx-type.at:414: exit code was $at_status, expected 0"
   60108       at_failed=:;;
   60109 esac
   60110 if $at_failed; then
   60111 
   60112   echo 1 > $at_status_file
   60113   exit 1
   60114 fi
   60115 
   60116 $at_traceon
   60117 
   60118 $at_traceoff
   60119 echo "cxx-type.at:414: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o types types.c \$LIBS"
   60120 echo cxx-type.at:414 >$at_check_line_file
   60121 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o types types.c $LIBS ) >$at_stdout 2>$at_stder1
   60122 at_status=$?
   60123 grep '^ *+' $at_stder1 >&2
   60124 grep -v '^ *+' $at_stder1 >$at_stderr
   60125 at_failed=false
   60126 echo stderr:; cat $at_stderr
   60127 echo stdout:; cat $at_stdout
   60128 case $at_status in
   60129    77) echo 77 > $at_status_file
   60130             exit 77;;
   60131    0) ;;
   60132    *) echo "cxx-type.at:414: exit code was $at_status, expected 0"
   60133       at_failed=:;;
   60134 esac
   60135 if $at_failed; then
   60136 
   60137   echo 1 > $at_status_file
   60138   exit 1
   60139 fi
   60140 
   60141 $at_traceon
   60142 
   60143 
   60144 
   60145 
   60146 
   60147 
   60148 
   60149 
   60150 
   60151 
   60152 
   60153 
   60154 
   60155 
   60156 
   60157 
   60158 
   60159 
   60160 
   60161 
   60162 
   60163 
   60164 
   60165 $at_traceoff
   60166 echo "cxx-type.at:416: \$PREPARSER ./types test-input"
   60167 echo cxx-type.at:416 >$at_check_line_file
   60168 ( $at_traceon; $PREPARSER ./types test-input ) >$at_stdout 2>$at_stder1
   60169 at_status=$?
   60170 grep '^ *+' $at_stder1 >&2
   60171 grep -v '^ *+' $at_stder1 >$at_stderr
   60172 at_failed=false
   60173 echo >>$at_stderr; echo "syntax error
   60174 " | $at_diff - $at_stderr || at_failed=:
   60175 echo >>$at_stdout; echo "+(z,q)
   60176 <declare>(T,x)
   60177 <init-declare>(T,x,y)
   60178 =(x,y)
   60179 +(<cast>(x,T),y)
   60180 <declare>(T,x)
   60181 <init-declare>(T,y,+(z,q))
   60182 <error>
   60183 +(z,q)
   60184 " | $at_diff - $at_stdout || at_failed=:
   60185 case $at_status in
   60186    77) echo 77 > $at_status_file
   60187             exit 77;;
   60188    0) ;;
   60189    *) echo "cxx-type.at:416: exit code was $at_status, expected 0"
   60190       at_failed=:;;
   60191 esac
   60192 if $at_failed; then
   60193 
   60194   echo 1 > $at_status_file
   60195   exit 1
   60196 fi
   60197 
   60198 $at_traceon
   60199 
   60200       $at_traceoff
   60201       $at_times_p && times >$at_times_file
   60202     ) 5>&1 2>&1 | eval $at_tee_pipe
   60203     at_status=`cat $at_status_file`
   60204     ;;
   60205 
   60206   134 ) # 134. cxx-type.at:419: GLR: Resolve ambiguity, impure, locations
   60207     at_setup_line='cxx-type.at:419'
   60208     at_desc='GLR: Resolve ambiguity, impure, locations'
   60209     $at_quiet $ECHO_N "134: GLR: Resolve ambiguity, impure, locations    $ECHO_C"
   60210     at_xfail=no
   60211     (
   60212       echo "134. cxx-type.at:419: testing ..."
   60213       $at_traceon
   60214 
   60215 
   60216 
   60217 
   60218 
   60219 
   60220 # Using yacc.c?
   60221 
   60222 
   60223 
   60224 
   60225 
   60226 
   60227 
   60228 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   60229 
   60230 # yyerror always sees the locations (when activated), except if
   60231 # yacc & pure & !param.
   60232 
   60233 
   60234 # The interface is pure: either because %pure-parser, or because we
   60235 # are using the C++ parsers.
   60236 
   60237 
   60238 
   60239 
   60240 
   60241 
   60242 
   60243 
   60244 
   60245 
   60246 
   60247 
   60248 cat >types.y <<'_ATEOF'
   60249 %{
   60250 #ifdef HAVE_CONFIG_H
   60251 # include <config.h>
   60252   /* We don't need perfect functions for these tests. */
   60253 # undef malloc
   60254 # undef memcmp
   60255 # undef realloc
   60256 #endif
   60257 %}
   60258 
   60259 /* Simplified C++ Type and Expression Grammar.  */
   60260 
   60261 %locations
   60262 
   60263 %{
   60264   #include <stdio.h>
   60265   union Node {
   60266     struct {
   60267       int isNterm;
   60268       int parents;
   60269     } nodeInfo;
   60270     struct {
   60271       int isNterm; /* 1 */
   60272       int parents;
   60273       char const *form;
   60274       union Node *children[3];
   60275     } nterm;
   60276     struct {
   60277       int isNterm; /* 0 */
   60278       int parents;
   60279       char *text;
   60280     } term;
   60281   };
   60282   typedef union Node Node;
   60283   static Node *new_nterm (char const *, Node *, Node *, Node *);
   60284   static Node *new_term (char *);
   60285   static void free_node (Node *);
   60286   static char *node_to_string (Node *);
   60287   #define YYSTYPE Node *
   60288 
   60289   #define YYINITDEPTH 10
   60290   #define YYSTACKEXPANDABLE 1
   60291   struct YYLTYPE;
   60292 #if YYPURE
   60293 # if YYLSP_NEEDED
   60294 #  define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
   60295 #  define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
   60296 # else
   60297 #  define LEX_PARAMETERS YYSTYPE *lvalp
   60298 # endif
   60299 #endif
   60300 #ifndef LEX_PARAMETERS
   60301 # define LEX_PARAMETERS void
   60302 #endif
   60303 #ifndef ERROR_PARAMETERS
   60304 # define ERROR_PARAMETERS char const *s
   60305 #endif
   60306   int yylex (LEX_PARAMETERS);
   60307   void yyerror (ERROR_PARAMETERS);
   60308 %}
   60309 
   60310 %token TYPENAME ID
   60311 
   60312 %right '='
   60313 %left '+'
   60314 
   60315 %glr-parser
   60316 
   60317 %destructor { free_node ($$); } stmt expr decl declarator TYPENAME ID
   60318 
   60319 %%
   60320 
   60321 prog :
   60322      | prog stmt   {
   60323 			char *output;
   60324 			printf ("%d.%d-%d.%d: ",
   60325 			     @2.first_line, @2.first_column,
   60326 			     @2.last_line, @2.last_column);
   60327 			output = node_to_string ($2);
   60328 			printf ("%s\n", output);
   60329 			free (output);
   60330 			free_node ($2);
   60331 		   }
   60332      ;
   60333 
   60334 stmt : expr ';'  %dprec 1	{ $$ = $1; }
   60335      | decl      %dprec 2
   60336      | error ';'	{ $$ = new_nterm ("<error>", 0, 0, 0); }
   60337      | '@'		{ YYACCEPT; }
   60338      ;
   60339 
   60340 expr : ID
   60341      | TYPENAME '(' expr ')'
   60342 			{ $$ = new_nterm ("<cast>(%s,%s)", $3, $1, 0); }
   60343      | expr '+' expr	{ $$ = new_nterm ("+(%s,%s)", $1, $3, 0); }
   60344      | expr '=' expr    { $$ = new_nterm ("=(%s,%s)", $1, $3, 0); }
   60345      ;
   60346 
   60347 decl : TYPENAME declarator ';'
   60348 			{ $$ = new_nterm ("<declare>(%s,%s)", $1, $2, 0); }
   60349      | TYPENAME declarator '=' expr ';'
   60350 			{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
   60351 					  $2, $4); }
   60352      ;
   60353 
   60354 declarator : ID
   60355      | '(' declarator ')' { $$ = $2; }
   60356      ;
   60357 
   60358 %%
   60359 
   60360 #include <ctype.h>
   60361 #include <stdlib.h>
   60362 #include <string.h>
   60363 #include <stdarg.h>
   60364 
   60365 int
   60366 main (int argc, char **argv)
   60367 {
   60368   if (argc != 2)
   60369     abort ();
   60370   if (!freopen (argv[1], "r", stdin))
   60371     return 3;
   60372   return yyparse ();
   60373 }
   60374 
   60375 int
   60376 yylex (LEX_PARAMETERS)
   60377 {
   60378   char buffer[256];
   60379   int c;
   60380   unsigned int i;
   60381   static int lineNum = 1;
   60382   static int colNum = 0;
   60383 
   60384 #if YYPURE
   60385 # undef yylloc
   60386 # define yylloc (*llocp)
   60387 # undef yylval
   60388 # define yylval (*lvalp)
   60389 #endif
   60390 
   60391   while (1)
   60392     {
   60393       c = getchar ();
   60394       switch (c)
   60395 	{
   60396 	case EOF:
   60397 	  return 0;
   60398 	case '\t':
   60399 	  colNum = (colNum + 7) & ~7;
   60400 	  break;
   60401 	case ' ': case '\f':
   60402 	  colNum += 1;
   60403 	  break;
   60404 	case '\n':
   60405 	  lineNum += 1;
   60406 	  colNum = 0;
   60407 	  break;
   60408 	default:
   60409 	  {
   60410 	    int tok;
   60411 #if YYLSP_NEEDED
   60412 	    yylloc.first_line = yylloc.last_line = lineNum;
   60413 	    yylloc.first_column = colNum;
   60414 #endif
   60415 	    if (isalpha (c))
   60416 	      {
   60417 		i = 0;
   60418 
   60419 		do
   60420 		  {
   60421 		    buffer[i++] = c;
   60422 		    colNum += 1;
   60423 		    if (i == sizeof buffer - 1)
   60424 		      abort ();
   60425 		    c = getchar ();
   60426 		  }
   60427 		while (isalnum (c) || c == '_');
   60428 
   60429 		ungetc (c, stdin);
   60430 		buffer[i++] = 0;
   60431 		tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
   60432 		yylval = new_term (strcpy ((char *) malloc (i), buffer));
   60433 	      }
   60434 	    else
   60435 	      {
   60436 		colNum += 1;
   60437 		tok = c;
   60438 		yylval = 0;
   60439 	      }
   60440 #if YYLSP_NEEDED
   60441 	    yylloc.last_column = colNum-1;
   60442 #endif
   60443 	    return tok;
   60444 	  }
   60445 	}
   60446     }
   60447 }
   60448 
   60449 void
   60450 yyerror (ERROR_PARAMETERS)
   60451 {
   60452 #if YYPURE && YYLSP_NEEDED
   60453   /* Pacify GCC by using llocp.  */
   60454   if (! llocp)
   60455     abort ();
   60456 #endif
   60457   fprintf (stderr, "%s\n", s);
   60458 }
   60459 
   60460 static Node *
   60461 new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
   60462 {
   60463   Node *node = (Node *) malloc (sizeof (Node));
   60464   node->nterm.isNterm = 1;
   60465   node->nterm.parents = 0;
   60466   node->nterm.form = form;
   60467   node->nterm.children[0] = child0;
   60468   if (child0)
   60469     child0->nodeInfo.parents += 1;
   60470   node->nterm.children[1] = child1;
   60471   if (child1)
   60472     child1->nodeInfo.parents += 1;
   60473   node->nterm.children[2] = child2;
   60474   if (child2)
   60475     child2->nodeInfo.parents += 1;
   60476   return node;
   60477 }
   60478 
   60479 static Node *
   60480 new_term (char *text)
   60481 {
   60482   Node *node = (Node *) malloc (sizeof (Node));
   60483   node->term.isNterm = 0;
   60484   node->term.parents = 0;
   60485   node->term.text = text;
   60486   return node;
   60487 }
   60488 
   60489 static void
   60490 free_node (Node *node)
   60491 {
   60492   if (!node)
   60493     return;
   60494   node->nodeInfo.parents -= 1;
   60495   /* Free only if 0 (last parent) or -1 (no parents).  */
   60496   if (node->nodeInfo.parents > 0)
   60497     return;
   60498   if (node->nodeInfo.isNterm == 1)
   60499     {
   60500       free_node (node->nterm.children[0]);
   60501       free_node (node->nterm.children[1]);
   60502       free_node (node->nterm.children[2]);
   60503     }
   60504   else
   60505     free (node->term.text);
   60506   free (node);
   60507 }
   60508 
   60509 static char *
   60510 node_to_string (Node *node)
   60511 {
   60512   char *child0;
   60513   char *child1;
   60514   char *child2;
   60515   char *buffer;
   60516   if (!node)
   60517     {
   60518       buffer = (char *) malloc (1);
   60519       buffer[0] = 0;
   60520     }
   60521   else if (node->nodeInfo.isNterm == 1)
   60522     {
   60523       child0 = node_to_string (node->nterm.children[0]);
   60524       child1 = node_to_string (node->nterm.children[1]);
   60525       child2 = node_to_string (node->nterm.children[2]);
   60526       buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
   60527 				+ strlen (child1) + strlen (child2) + 1);
   60528       sprintf (buffer, node->nterm.form, child0, child1, child2);
   60529       free (child0);
   60530       free (child1);
   60531       free (child2);
   60532     }
   60533   else
   60534     buffer = strdup (node->term.text);
   60535   return buffer;
   60536 }
   60537 
   60538 
   60539 
   60540 _ATEOF
   60541 
   60542 
   60543 
   60544 cat >test-input <<'_ATEOF'
   60545 
   60546 
   60547 z + q;
   60548 
   60549 T x;
   60550 
   60551 T x = y;
   60552 
   60553 x = y;
   60554 
   60555 T (x) + y;
   60556 
   60557 T (x);
   60558 
   60559 T (y) = z + q;
   60560 
   60561 T (y y) = z + q;
   60562 
   60563 z + q;
   60564 
   60565 @
   60566 
   60567 This is total garbage, but it should be ignored.
   60568 _ATEOF
   60569 
   60570 
   60571 $at_traceoff
   60572 echo "cxx-type.at:420: bison -o types.c types.y"
   60573 echo cxx-type.at:420 >$at_check_line_file
   60574 ( $at_traceon; bison -o types.c types.y ) >$at_stdout 2>$at_stder1
   60575 at_status=$?
   60576 grep '^ *+' $at_stder1 >&2
   60577 grep -v '^ *+' $at_stder1 >$at_stderr
   60578 at_failed=false
   60579 echo stderr:; cat $at_stderr
   60580 $at_diff $at_devnull $at_stdout || at_failed=:
   60581 case $at_status in
   60582    77) echo 77 > $at_status_file
   60583             exit 77;;
   60584    0) ;;
   60585    *) echo "cxx-type.at:420: exit code was $at_status, expected 0"
   60586       at_failed=:;;
   60587 esac
   60588 if $at_failed; then
   60589 
   60590   echo 1 > $at_status_file
   60591   exit 1
   60592 fi
   60593 
   60594 $at_traceon
   60595 
   60596 $at_traceoff
   60597 echo "cxx-type.at:420: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o types types.c \$LIBS"
   60598 echo cxx-type.at:420 >$at_check_line_file
   60599 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o types types.c $LIBS ) >$at_stdout 2>$at_stder1
   60600 at_status=$?
   60601 grep '^ *+' $at_stder1 >&2
   60602 grep -v '^ *+' $at_stder1 >$at_stderr
   60603 at_failed=false
   60604 echo stderr:; cat $at_stderr
   60605 echo stdout:; cat $at_stdout
   60606 case $at_status in
   60607    77) echo 77 > $at_status_file
   60608             exit 77;;
   60609    0) ;;
   60610    *) echo "cxx-type.at:420: exit code was $at_status, expected 0"
   60611       at_failed=:;;
   60612 esac
   60613 if $at_failed; then
   60614 
   60615   echo 1 > $at_status_file
   60616   exit 1
   60617 fi
   60618 
   60619 $at_traceon
   60620 
   60621 
   60622 
   60623 
   60624 
   60625 
   60626 
   60627 
   60628 
   60629 
   60630 
   60631 
   60632 
   60633 
   60634 
   60635 
   60636 
   60637 
   60638 
   60639 
   60640 
   60641 
   60642 
   60643 $at_traceoff
   60644 echo "cxx-type.at:422: \$PREPARSER ./types test-input"
   60645 echo cxx-type.at:422 >$at_check_line_file
   60646 ( $at_traceon; $PREPARSER ./types test-input ) >$at_stdout 2>$at_stder1
   60647 at_status=$?
   60648 grep '^ *+' $at_stder1 >&2
   60649 grep -v '^ *+' $at_stder1 >$at_stderr
   60650 at_failed=false
   60651 echo >>$at_stderr; echo "syntax error
   60652 " | $at_diff - $at_stderr || at_failed=:
   60653 echo >>$at_stdout; echo "3.0-3.5: +(z,q)
   60654 5.0-5.3: <declare>(T,x)
   60655 7.0-7.7: <init-declare>(T,x,y)
   60656 9.0-9.5: =(x,y)
   60657 11.0-11.9: +(<cast>(x,T),y)
   60658 13.0-13.5: <declare>(T,x)
   60659 15.0-15.13: <init-declare>(T,y,+(z,q))
   60660 17.0-17.15: <error>
   60661 19.0-19.5: +(z,q)
   60662 " | $at_diff - $at_stdout || at_failed=:
   60663 case $at_status in
   60664    77) echo 77 > $at_status_file
   60665             exit 77;;
   60666    0) ;;
   60667    *) echo "cxx-type.at:422: exit code was $at_status, expected 0"
   60668       at_failed=:;;
   60669 esac
   60670 if $at_failed; then
   60671 
   60672   echo 1 > $at_status_file
   60673   exit 1
   60674 fi
   60675 
   60676 $at_traceon
   60677 
   60678       $at_traceoff
   60679       $at_times_p && times >$at_times_file
   60680     ) 5>&1 2>&1 | eval $at_tee_pipe
   60681     at_status=`cat $at_status_file`
   60682     ;;
   60683 
   60684   135 ) # 135. cxx-type.at:425: GLR: Resolve ambiguity, pure, no locations
   60685     at_setup_line='cxx-type.at:425'
   60686     at_desc='GLR: Resolve ambiguity, pure, no locations'
   60687     $at_quiet $ECHO_N "135: GLR: Resolve ambiguity, pure, no locations   $ECHO_C"
   60688     at_xfail=no
   60689     (
   60690       echo "135. cxx-type.at:425: testing ..."
   60691       $at_traceon
   60692 
   60693 
   60694 
   60695 
   60696 
   60697 
   60698 # Using yacc.c?
   60699 
   60700 
   60701 
   60702 
   60703 
   60704 
   60705 
   60706 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   60707 
   60708 # yyerror always sees the locations (when activated), except if
   60709 # yacc & pure & !param.
   60710 
   60711 
   60712 # The interface is pure: either because %pure-parser, or because we
   60713 # are using the C++ parsers.
   60714 
   60715 
   60716 
   60717 
   60718 
   60719 
   60720 
   60721 
   60722 
   60723 
   60724 
   60725 
   60726 cat >types.y <<'_ATEOF'
   60727 %{
   60728 #ifdef HAVE_CONFIG_H
   60729 # include <config.h>
   60730   /* We don't need perfect functions for these tests. */
   60731 # undef malloc
   60732 # undef memcmp
   60733 # undef realloc
   60734 #endif
   60735 %}
   60736 
   60737 /* Simplified C++ Type and Expression Grammar.  */
   60738 
   60739 %pure-parser
   60740 
   60741 %{
   60742   #include <stdio.h>
   60743   union Node {
   60744     struct {
   60745       int isNterm;
   60746       int parents;
   60747     } nodeInfo;
   60748     struct {
   60749       int isNterm; /* 1 */
   60750       int parents;
   60751       char const *form;
   60752       union Node *children[3];
   60753     } nterm;
   60754     struct {
   60755       int isNterm; /* 0 */
   60756       int parents;
   60757       char *text;
   60758     } term;
   60759   };
   60760   typedef union Node Node;
   60761   static Node *new_nterm (char const *, Node *, Node *, Node *);
   60762   static Node *new_term (char *);
   60763   static void free_node (Node *);
   60764   static char *node_to_string (Node *);
   60765   #define YYSTYPE Node *
   60766 
   60767   #define YYINITDEPTH 10
   60768   #define YYSTACKEXPANDABLE 1
   60769   struct YYLTYPE;
   60770 #if YYPURE
   60771 # if YYLSP_NEEDED
   60772 #  define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
   60773 #  define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
   60774 # else
   60775 #  define LEX_PARAMETERS YYSTYPE *lvalp
   60776 # endif
   60777 #endif
   60778 #ifndef LEX_PARAMETERS
   60779 # define LEX_PARAMETERS void
   60780 #endif
   60781 #ifndef ERROR_PARAMETERS
   60782 # define ERROR_PARAMETERS char const *s
   60783 #endif
   60784   int yylex (LEX_PARAMETERS);
   60785   void yyerror (ERROR_PARAMETERS);
   60786 %}
   60787 
   60788 %token TYPENAME ID
   60789 
   60790 %right '='
   60791 %left '+'
   60792 
   60793 %glr-parser
   60794 
   60795 %destructor { free_node ($$); } stmt expr decl declarator TYPENAME ID
   60796 
   60797 %%
   60798 
   60799 prog :
   60800      | prog stmt   {
   60801 			char *output;
   60802 			output = node_to_string ($2);
   60803 			printf ("%s\n", output);
   60804 			free (output);
   60805 			free_node ($2);
   60806 		   }
   60807      ;
   60808 
   60809 stmt : expr ';'  %dprec 1	{ $$ = $1; }
   60810      | decl      %dprec 2
   60811      | error ';'	{ $$ = new_nterm ("<error>", 0, 0, 0); }
   60812      | '@'		{ YYACCEPT; }
   60813      ;
   60814 
   60815 expr : ID
   60816      | TYPENAME '(' expr ')'
   60817 			{ $$ = new_nterm ("<cast>(%s,%s)", $3, $1, 0); }
   60818      | expr '+' expr	{ $$ = new_nterm ("+(%s,%s)", $1, $3, 0); }
   60819      | expr '=' expr    { $$ = new_nterm ("=(%s,%s)", $1, $3, 0); }
   60820      ;
   60821 
   60822 decl : TYPENAME declarator ';'
   60823 			{ $$ = new_nterm ("<declare>(%s,%s)", $1, $2, 0); }
   60824      | TYPENAME declarator '=' expr ';'
   60825 			{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
   60826 					  $2, $4); }
   60827      ;
   60828 
   60829 declarator : ID
   60830      | '(' declarator ')' { $$ = $2; }
   60831      ;
   60832 
   60833 %%
   60834 
   60835 #include <ctype.h>
   60836 #include <stdlib.h>
   60837 #include <string.h>
   60838 #include <stdarg.h>
   60839 
   60840 int
   60841 main (int argc, char **argv)
   60842 {
   60843   if (argc != 2)
   60844     abort ();
   60845   if (!freopen (argv[1], "r", stdin))
   60846     return 3;
   60847   return yyparse ();
   60848 }
   60849 
   60850 int
   60851 yylex (LEX_PARAMETERS)
   60852 {
   60853   char buffer[256];
   60854   int c;
   60855   unsigned int i;
   60856   static int lineNum = 1;
   60857   static int colNum = 0;
   60858 
   60859 #if YYPURE
   60860 # undef yylloc
   60861 # define yylloc (*llocp)
   60862 # undef yylval
   60863 # define yylval (*lvalp)
   60864 #endif
   60865 
   60866   while (1)
   60867     {
   60868       c = getchar ();
   60869       switch (c)
   60870 	{
   60871 	case EOF:
   60872 	  return 0;
   60873 	case '\t':
   60874 	  colNum = (colNum + 7) & ~7;
   60875 	  break;
   60876 	case ' ': case '\f':
   60877 	  colNum += 1;
   60878 	  break;
   60879 	case '\n':
   60880 	  lineNum += 1;
   60881 	  colNum = 0;
   60882 	  break;
   60883 	default:
   60884 	  {
   60885 	    int tok;
   60886 #if YYLSP_NEEDED
   60887 	    yylloc.first_line = yylloc.last_line = lineNum;
   60888 	    yylloc.first_column = colNum;
   60889 #endif
   60890 	    if (isalpha (c))
   60891 	      {
   60892 		i = 0;
   60893 
   60894 		do
   60895 		  {
   60896 		    buffer[i++] = c;
   60897 		    colNum += 1;
   60898 		    if (i == sizeof buffer - 1)
   60899 		      abort ();
   60900 		    c = getchar ();
   60901 		  }
   60902 		while (isalnum (c) || c == '_');
   60903 
   60904 		ungetc (c, stdin);
   60905 		buffer[i++] = 0;
   60906 		tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
   60907 		yylval = new_term (strcpy ((char *) malloc (i), buffer));
   60908 	      }
   60909 	    else
   60910 	      {
   60911 		colNum += 1;
   60912 		tok = c;
   60913 		yylval = 0;
   60914 	      }
   60915 #if YYLSP_NEEDED
   60916 	    yylloc.last_column = colNum-1;
   60917 #endif
   60918 	    return tok;
   60919 	  }
   60920 	}
   60921     }
   60922 }
   60923 
   60924 void
   60925 yyerror (ERROR_PARAMETERS)
   60926 {
   60927 #if YYPURE && YYLSP_NEEDED
   60928   /* Pacify GCC by using llocp.  */
   60929   if (! llocp)
   60930     abort ();
   60931 #endif
   60932   fprintf (stderr, "%s\n", s);
   60933 }
   60934 
   60935 static Node *
   60936 new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
   60937 {
   60938   Node *node = (Node *) malloc (sizeof (Node));
   60939   node->nterm.isNterm = 1;
   60940   node->nterm.parents = 0;
   60941   node->nterm.form = form;
   60942   node->nterm.children[0] = child0;
   60943   if (child0)
   60944     child0->nodeInfo.parents += 1;
   60945   node->nterm.children[1] = child1;
   60946   if (child1)
   60947     child1->nodeInfo.parents += 1;
   60948   node->nterm.children[2] = child2;
   60949   if (child2)
   60950     child2->nodeInfo.parents += 1;
   60951   return node;
   60952 }
   60953 
   60954 static Node *
   60955 new_term (char *text)
   60956 {
   60957   Node *node = (Node *) malloc (sizeof (Node));
   60958   node->term.isNterm = 0;
   60959   node->term.parents = 0;
   60960   node->term.text = text;
   60961   return node;
   60962 }
   60963 
   60964 static void
   60965 free_node (Node *node)
   60966 {
   60967   if (!node)
   60968     return;
   60969   node->nodeInfo.parents -= 1;
   60970   /* Free only if 0 (last parent) or -1 (no parents).  */
   60971   if (node->nodeInfo.parents > 0)
   60972     return;
   60973   if (node->nodeInfo.isNterm == 1)
   60974     {
   60975       free_node (node->nterm.children[0]);
   60976       free_node (node->nterm.children[1]);
   60977       free_node (node->nterm.children[2]);
   60978     }
   60979   else
   60980     free (node->term.text);
   60981   free (node);
   60982 }
   60983 
   60984 static char *
   60985 node_to_string (Node *node)
   60986 {
   60987   char *child0;
   60988   char *child1;
   60989   char *child2;
   60990   char *buffer;
   60991   if (!node)
   60992     {
   60993       buffer = (char *) malloc (1);
   60994       buffer[0] = 0;
   60995     }
   60996   else if (node->nodeInfo.isNterm == 1)
   60997     {
   60998       child0 = node_to_string (node->nterm.children[0]);
   60999       child1 = node_to_string (node->nterm.children[1]);
   61000       child2 = node_to_string (node->nterm.children[2]);
   61001       buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
   61002 				+ strlen (child1) + strlen (child2) + 1);
   61003       sprintf (buffer, node->nterm.form, child0, child1, child2);
   61004       free (child0);
   61005       free (child1);
   61006       free (child2);
   61007     }
   61008   else
   61009     buffer = strdup (node->term.text);
   61010   return buffer;
   61011 }
   61012 
   61013 
   61014 
   61015 _ATEOF
   61016 
   61017 
   61018 
   61019 cat >test-input <<'_ATEOF'
   61020 
   61021 
   61022 z + q;
   61023 
   61024 T x;
   61025 
   61026 T x = y;
   61027 
   61028 x = y;
   61029 
   61030 T (x) + y;
   61031 
   61032 T (x);
   61033 
   61034 T (y) = z + q;
   61035 
   61036 T (y y) = z + q;
   61037 
   61038 z + q;
   61039 
   61040 @
   61041 
   61042 This is total garbage, but it should be ignored.
   61043 _ATEOF
   61044 
   61045 
   61046 $at_traceoff
   61047 echo "cxx-type.at:427: bison -o types.c types.y"
   61048 echo cxx-type.at:427 >$at_check_line_file
   61049 ( $at_traceon; bison -o types.c types.y ) >$at_stdout 2>$at_stder1
   61050 at_status=$?
   61051 grep '^ *+' $at_stder1 >&2
   61052 grep -v '^ *+' $at_stder1 >$at_stderr
   61053 at_failed=false
   61054 echo stderr:; cat $at_stderr
   61055 $at_diff $at_devnull $at_stdout || at_failed=:
   61056 case $at_status in
   61057    77) echo 77 > $at_status_file
   61058             exit 77;;
   61059    0) ;;
   61060    *) echo "cxx-type.at:427: exit code was $at_status, expected 0"
   61061       at_failed=:;;
   61062 esac
   61063 if $at_failed; then
   61064 
   61065   echo 1 > $at_status_file
   61066   exit 1
   61067 fi
   61068 
   61069 $at_traceon
   61070 
   61071 $at_traceoff
   61072 echo "cxx-type.at:427: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o types types.c \$LIBS"
   61073 echo cxx-type.at:427 >$at_check_line_file
   61074 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o types types.c $LIBS ) >$at_stdout 2>$at_stder1
   61075 at_status=$?
   61076 grep '^ *+' $at_stder1 >&2
   61077 grep -v '^ *+' $at_stder1 >$at_stderr
   61078 at_failed=false
   61079 echo stderr:; cat $at_stderr
   61080 echo stdout:; cat $at_stdout
   61081 case $at_status in
   61082    77) echo 77 > $at_status_file
   61083             exit 77;;
   61084    0) ;;
   61085    *) echo "cxx-type.at:427: exit code was $at_status, expected 0"
   61086       at_failed=:;;
   61087 esac
   61088 if $at_failed; then
   61089 
   61090   echo 1 > $at_status_file
   61091   exit 1
   61092 fi
   61093 
   61094 $at_traceon
   61095 
   61096 
   61097 
   61098 
   61099 
   61100 
   61101 
   61102 
   61103 
   61104 
   61105 
   61106 
   61107 
   61108 
   61109 
   61110 
   61111 
   61112 
   61113 
   61114 
   61115 
   61116 
   61117 
   61118 $at_traceoff
   61119 echo "cxx-type.at:429: \$PREPARSER ./types test-input"
   61120 echo cxx-type.at:429 >$at_check_line_file
   61121 ( $at_traceon; $PREPARSER ./types test-input ) >$at_stdout 2>$at_stder1
   61122 at_status=$?
   61123 grep '^ *+' $at_stder1 >&2
   61124 grep -v '^ *+' $at_stder1 >$at_stderr
   61125 at_failed=false
   61126 echo >>$at_stderr; echo "syntax error
   61127 " | $at_diff - $at_stderr || at_failed=:
   61128 echo >>$at_stdout; echo "+(z,q)
   61129 <declare>(T,x)
   61130 <init-declare>(T,x,y)
   61131 =(x,y)
   61132 +(<cast>(x,T),y)
   61133 <declare>(T,x)
   61134 <init-declare>(T,y,+(z,q))
   61135 <error>
   61136 +(z,q)
   61137 " | $at_diff - $at_stdout || at_failed=:
   61138 case $at_status in
   61139    77) echo 77 > $at_status_file
   61140             exit 77;;
   61141    0) ;;
   61142    *) echo "cxx-type.at:429: exit code was $at_status, expected 0"
   61143       at_failed=:;;
   61144 esac
   61145 if $at_failed; then
   61146 
   61147   echo 1 > $at_status_file
   61148   exit 1
   61149 fi
   61150 
   61151 $at_traceon
   61152 
   61153       $at_traceoff
   61154       $at_times_p && times >$at_times_file
   61155     ) 5>&1 2>&1 | eval $at_tee_pipe
   61156     at_status=`cat $at_status_file`
   61157     ;;
   61158 
   61159   136 ) # 136. cxx-type.at:432: GLR: Resolve ambiguity, pure, locations
   61160     at_setup_line='cxx-type.at:432'
   61161     at_desc='GLR: Resolve ambiguity, pure, locations'
   61162     $at_quiet $ECHO_N "136: GLR: Resolve ambiguity, pure, locations      $ECHO_C"
   61163     at_xfail=no
   61164     (
   61165       echo "136. cxx-type.at:432: testing ..."
   61166       $at_traceon
   61167 
   61168 
   61169 
   61170 
   61171 
   61172 
   61173 # Using yacc.c?
   61174 
   61175 
   61176 
   61177 
   61178 
   61179 
   61180 
   61181 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   61182 
   61183 # yyerror always sees the locations (when activated), except if
   61184 # yacc & pure & !param.
   61185 
   61186 
   61187 # The interface is pure: either because %pure-parser, or because we
   61188 # are using the C++ parsers.
   61189 
   61190 
   61191 
   61192 
   61193 
   61194 
   61195 
   61196 
   61197 
   61198 
   61199 
   61200 
   61201 cat >types.y <<'_ATEOF'
   61202 %{
   61203 #ifdef HAVE_CONFIG_H
   61204 # include <config.h>
   61205   /* We don't need perfect functions for these tests. */
   61206 # undef malloc
   61207 # undef memcmp
   61208 # undef realloc
   61209 #endif
   61210 %}
   61211 
   61212 /* Simplified C++ Type and Expression Grammar.  */
   61213 
   61214 %pure-parser %locations
   61215 
   61216 %{
   61217   #include <stdio.h>
   61218   union Node {
   61219     struct {
   61220       int isNterm;
   61221       int parents;
   61222     } nodeInfo;
   61223     struct {
   61224       int isNterm; /* 1 */
   61225       int parents;
   61226       char const *form;
   61227       union Node *children[3];
   61228     } nterm;
   61229     struct {
   61230       int isNterm; /* 0 */
   61231       int parents;
   61232       char *text;
   61233     } term;
   61234   };
   61235   typedef union Node Node;
   61236   static Node *new_nterm (char const *, Node *, Node *, Node *);
   61237   static Node *new_term (char *);
   61238   static void free_node (Node *);
   61239   static char *node_to_string (Node *);
   61240   #define YYSTYPE Node *
   61241 
   61242   #define YYINITDEPTH 10
   61243   #define YYSTACKEXPANDABLE 1
   61244   struct YYLTYPE;
   61245 #if YYPURE
   61246 # if YYLSP_NEEDED
   61247 #  define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
   61248 #  define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
   61249 # else
   61250 #  define LEX_PARAMETERS YYSTYPE *lvalp
   61251 # endif
   61252 #endif
   61253 #ifndef LEX_PARAMETERS
   61254 # define LEX_PARAMETERS void
   61255 #endif
   61256 #ifndef ERROR_PARAMETERS
   61257 # define ERROR_PARAMETERS char const *s
   61258 #endif
   61259   int yylex (LEX_PARAMETERS);
   61260   void yyerror (ERROR_PARAMETERS);
   61261 %}
   61262 
   61263 %token TYPENAME ID
   61264 
   61265 %right '='
   61266 %left '+'
   61267 
   61268 %glr-parser
   61269 
   61270 %destructor { free_node ($$); } stmt expr decl declarator TYPENAME ID
   61271 
   61272 %%
   61273 
   61274 prog :
   61275      | prog stmt   {
   61276 			char *output;
   61277 			printf ("%d.%d-%d.%d: ",
   61278 			     @2.first_line, @2.first_column,
   61279 			     @2.last_line, @2.last_column);
   61280 			output = node_to_string ($2);
   61281 			printf ("%s\n", output);
   61282 			free (output);
   61283 			free_node ($2);
   61284 		   }
   61285      ;
   61286 
   61287 stmt : expr ';'  %dprec 1	{ $$ = $1; }
   61288      | decl      %dprec 2
   61289      | error ';'	{ $$ = new_nterm ("<error>", 0, 0, 0); }
   61290      | '@'		{ YYACCEPT; }
   61291      ;
   61292 
   61293 expr : ID
   61294      | TYPENAME '(' expr ')'
   61295 			{ $$ = new_nterm ("<cast>(%s,%s)", $3, $1, 0); }
   61296      | expr '+' expr	{ $$ = new_nterm ("+(%s,%s)", $1, $3, 0); }
   61297      | expr '=' expr    { $$ = new_nterm ("=(%s,%s)", $1, $3, 0); }
   61298      ;
   61299 
   61300 decl : TYPENAME declarator ';'
   61301 			{ $$ = new_nterm ("<declare>(%s,%s)", $1, $2, 0); }
   61302      | TYPENAME declarator '=' expr ';'
   61303 			{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
   61304 					  $2, $4); }
   61305      ;
   61306 
   61307 declarator : ID
   61308      | '(' declarator ')' { $$ = $2; }
   61309      ;
   61310 
   61311 %%
   61312 
   61313 #include <ctype.h>
   61314 #include <stdlib.h>
   61315 #include <string.h>
   61316 #include <stdarg.h>
   61317 
   61318 int
   61319 main (int argc, char **argv)
   61320 {
   61321   if (argc != 2)
   61322     abort ();
   61323   if (!freopen (argv[1], "r", stdin))
   61324     return 3;
   61325   return yyparse ();
   61326 }
   61327 
   61328 int
   61329 yylex (LEX_PARAMETERS)
   61330 {
   61331   char buffer[256];
   61332   int c;
   61333   unsigned int i;
   61334   static int lineNum = 1;
   61335   static int colNum = 0;
   61336 
   61337 #if YYPURE
   61338 # undef yylloc
   61339 # define yylloc (*llocp)
   61340 # undef yylval
   61341 # define yylval (*lvalp)
   61342 #endif
   61343 
   61344   while (1)
   61345     {
   61346       c = getchar ();
   61347       switch (c)
   61348 	{
   61349 	case EOF:
   61350 	  return 0;
   61351 	case '\t':
   61352 	  colNum = (colNum + 7) & ~7;
   61353 	  break;
   61354 	case ' ': case '\f':
   61355 	  colNum += 1;
   61356 	  break;
   61357 	case '\n':
   61358 	  lineNum += 1;
   61359 	  colNum = 0;
   61360 	  break;
   61361 	default:
   61362 	  {
   61363 	    int tok;
   61364 #if YYLSP_NEEDED
   61365 	    yylloc.first_line = yylloc.last_line = lineNum;
   61366 	    yylloc.first_column = colNum;
   61367 #endif
   61368 	    if (isalpha (c))
   61369 	      {
   61370 		i = 0;
   61371 
   61372 		do
   61373 		  {
   61374 		    buffer[i++] = c;
   61375 		    colNum += 1;
   61376 		    if (i == sizeof buffer - 1)
   61377 		      abort ();
   61378 		    c = getchar ();
   61379 		  }
   61380 		while (isalnum (c) || c == '_');
   61381 
   61382 		ungetc (c, stdin);
   61383 		buffer[i++] = 0;
   61384 		tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
   61385 		yylval = new_term (strcpy ((char *) malloc (i), buffer));
   61386 	      }
   61387 	    else
   61388 	      {
   61389 		colNum += 1;
   61390 		tok = c;
   61391 		yylval = 0;
   61392 	      }
   61393 #if YYLSP_NEEDED
   61394 	    yylloc.last_column = colNum-1;
   61395 #endif
   61396 	    return tok;
   61397 	  }
   61398 	}
   61399     }
   61400 }
   61401 
   61402 void
   61403 yyerror (ERROR_PARAMETERS)
   61404 {
   61405 #if YYPURE && YYLSP_NEEDED
   61406   /* Pacify GCC by using llocp.  */
   61407   if (! llocp)
   61408     abort ();
   61409 #endif
   61410   fprintf (stderr, "%s\n", s);
   61411 }
   61412 
   61413 static Node *
   61414 new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
   61415 {
   61416   Node *node = (Node *) malloc (sizeof (Node));
   61417   node->nterm.isNterm = 1;
   61418   node->nterm.parents = 0;
   61419   node->nterm.form = form;
   61420   node->nterm.children[0] = child0;
   61421   if (child0)
   61422     child0->nodeInfo.parents += 1;
   61423   node->nterm.children[1] = child1;
   61424   if (child1)
   61425     child1->nodeInfo.parents += 1;
   61426   node->nterm.children[2] = child2;
   61427   if (child2)
   61428     child2->nodeInfo.parents += 1;
   61429   return node;
   61430 }
   61431 
   61432 static Node *
   61433 new_term (char *text)
   61434 {
   61435   Node *node = (Node *) malloc (sizeof (Node));
   61436   node->term.isNterm = 0;
   61437   node->term.parents = 0;
   61438   node->term.text = text;
   61439   return node;
   61440 }
   61441 
   61442 static void
   61443 free_node (Node *node)
   61444 {
   61445   if (!node)
   61446     return;
   61447   node->nodeInfo.parents -= 1;
   61448   /* Free only if 0 (last parent) or -1 (no parents).  */
   61449   if (node->nodeInfo.parents > 0)
   61450     return;
   61451   if (node->nodeInfo.isNterm == 1)
   61452     {
   61453       free_node (node->nterm.children[0]);
   61454       free_node (node->nterm.children[1]);
   61455       free_node (node->nterm.children[2]);
   61456     }
   61457   else
   61458     free (node->term.text);
   61459   free (node);
   61460 }
   61461 
   61462 static char *
   61463 node_to_string (Node *node)
   61464 {
   61465   char *child0;
   61466   char *child1;
   61467   char *child2;
   61468   char *buffer;
   61469   if (!node)
   61470     {
   61471       buffer = (char *) malloc (1);
   61472       buffer[0] = 0;
   61473     }
   61474   else if (node->nodeInfo.isNterm == 1)
   61475     {
   61476       child0 = node_to_string (node->nterm.children[0]);
   61477       child1 = node_to_string (node->nterm.children[1]);
   61478       child2 = node_to_string (node->nterm.children[2]);
   61479       buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
   61480 				+ strlen (child1) + strlen (child2) + 1);
   61481       sprintf (buffer, node->nterm.form, child0, child1, child2);
   61482       free (child0);
   61483       free (child1);
   61484       free (child2);
   61485     }
   61486   else
   61487     buffer = strdup (node->term.text);
   61488   return buffer;
   61489 }
   61490 
   61491 
   61492 
   61493 _ATEOF
   61494 
   61495 
   61496 
   61497 cat >test-input <<'_ATEOF'
   61498 
   61499 
   61500 z + q;
   61501 
   61502 T x;
   61503 
   61504 T x = y;
   61505 
   61506 x = y;
   61507 
   61508 T (x) + y;
   61509 
   61510 T (x);
   61511 
   61512 T (y) = z + q;
   61513 
   61514 T (y y) = z + q;
   61515 
   61516 z + q;
   61517 
   61518 @
   61519 
   61520 This is total garbage, but it should be ignored.
   61521 _ATEOF
   61522 
   61523 
   61524 $at_traceoff
   61525 echo "cxx-type.at:434: bison -o types.c types.y"
   61526 echo cxx-type.at:434 >$at_check_line_file
   61527 ( $at_traceon; bison -o types.c types.y ) >$at_stdout 2>$at_stder1
   61528 at_status=$?
   61529 grep '^ *+' $at_stder1 >&2
   61530 grep -v '^ *+' $at_stder1 >$at_stderr
   61531 at_failed=false
   61532 echo stderr:; cat $at_stderr
   61533 $at_diff $at_devnull $at_stdout || at_failed=:
   61534 case $at_status in
   61535    77) echo 77 > $at_status_file
   61536             exit 77;;
   61537    0) ;;
   61538    *) echo "cxx-type.at:434: exit code was $at_status, expected 0"
   61539       at_failed=:;;
   61540 esac
   61541 if $at_failed; then
   61542 
   61543   echo 1 > $at_status_file
   61544   exit 1
   61545 fi
   61546 
   61547 $at_traceon
   61548 
   61549 $at_traceoff
   61550 echo "cxx-type.at:434: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o types types.c \$LIBS"
   61551 echo cxx-type.at:434 >$at_check_line_file
   61552 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o types types.c $LIBS ) >$at_stdout 2>$at_stder1
   61553 at_status=$?
   61554 grep '^ *+' $at_stder1 >&2
   61555 grep -v '^ *+' $at_stder1 >$at_stderr
   61556 at_failed=false
   61557 echo stderr:; cat $at_stderr
   61558 echo stdout:; cat $at_stdout
   61559 case $at_status in
   61560    77) echo 77 > $at_status_file
   61561             exit 77;;
   61562    0) ;;
   61563    *) echo "cxx-type.at:434: exit code was $at_status, expected 0"
   61564       at_failed=:;;
   61565 esac
   61566 if $at_failed; then
   61567 
   61568   echo 1 > $at_status_file
   61569   exit 1
   61570 fi
   61571 
   61572 $at_traceon
   61573 
   61574 
   61575 
   61576 
   61577 
   61578 
   61579 
   61580 
   61581 
   61582 
   61583 
   61584 
   61585 
   61586 
   61587 
   61588 
   61589 
   61590 
   61591 
   61592 
   61593 
   61594 
   61595 
   61596 $at_traceoff
   61597 echo "cxx-type.at:436: \$PREPARSER ./types test-input"
   61598 echo cxx-type.at:436 >$at_check_line_file
   61599 ( $at_traceon; $PREPARSER ./types test-input ) >$at_stdout 2>$at_stder1
   61600 at_status=$?
   61601 grep '^ *+' $at_stder1 >&2
   61602 grep -v '^ *+' $at_stder1 >$at_stderr
   61603 at_failed=false
   61604 echo >>$at_stderr; echo "syntax error
   61605 " | $at_diff - $at_stderr || at_failed=:
   61606 echo >>$at_stdout; echo "3.0-3.5: +(z,q)
   61607 5.0-5.3: <declare>(T,x)
   61608 7.0-7.7: <init-declare>(T,x,y)
   61609 9.0-9.5: =(x,y)
   61610 11.0-11.9: +(<cast>(x,T),y)
   61611 13.0-13.5: <declare>(T,x)
   61612 15.0-15.13: <init-declare>(T,y,+(z,q))
   61613 17.0-17.15: <error>
   61614 19.0-19.5: +(z,q)
   61615 " | $at_diff - $at_stdout || at_failed=:
   61616 case $at_status in
   61617    77) echo 77 > $at_status_file
   61618             exit 77;;
   61619    0) ;;
   61620    *) echo "cxx-type.at:436: exit code was $at_status, expected 0"
   61621       at_failed=:;;
   61622 esac
   61623 if $at_failed; then
   61624 
   61625   echo 1 > $at_status_file
   61626   exit 1
   61627 fi
   61628 
   61629 $at_traceon
   61630 
   61631       $at_traceoff
   61632       $at_times_p && times >$at_times_file
   61633     ) 5>&1 2>&1 | eval $at_tee_pipe
   61634     at_status=`cat $at_status_file`
   61635     ;;
   61636 
   61637   137 ) # 137. cxx-type.at:439: GLR: Merge conflicting parses, impure, no locations
   61638     at_setup_line='cxx-type.at:439'
   61639     at_desc='GLR: Merge conflicting parses, impure, no locations'
   61640     $at_quiet $ECHO_N "137: GLR: Merge conflicting parses, impure, no locations$ECHO_C"
   61641     at_xfail=no
   61642     (
   61643       echo "137. cxx-type.at:439: testing ..."
   61644       $at_traceon
   61645 
   61646 
   61647 
   61648 
   61649 
   61650 
   61651 # Using yacc.c?
   61652 
   61653 
   61654 
   61655 
   61656 
   61657 
   61658 
   61659 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   61660 
   61661 # yyerror always sees the locations (when activated), except if
   61662 # yacc & pure & !param.
   61663 
   61664 
   61665 # The interface is pure: either because %pure-parser, or because we
   61666 # are using the C++ parsers.
   61667 
   61668 
   61669 
   61670 
   61671 
   61672 
   61673 
   61674 
   61675 
   61676 
   61677 
   61678 
   61679 cat >types.y <<'_ATEOF'
   61680 %{
   61681 #ifdef HAVE_CONFIG_H
   61682 # include <config.h>
   61683   /* We don't need perfect functions for these tests. */
   61684 # undef malloc
   61685 # undef memcmp
   61686 # undef realloc
   61687 #endif
   61688 %}
   61689 
   61690 /* Simplified C++ Type and Expression Grammar.  */
   61691 
   61692 
   61693 
   61694 %{
   61695   #include <stdio.h>
   61696   union Node {
   61697     struct {
   61698       int isNterm;
   61699       int parents;
   61700     } nodeInfo;
   61701     struct {
   61702       int isNterm; /* 1 */
   61703       int parents;
   61704       char const *form;
   61705       union Node *children[3];
   61706     } nterm;
   61707     struct {
   61708       int isNterm; /* 0 */
   61709       int parents;
   61710       char *text;
   61711     } term;
   61712   };
   61713   typedef union Node Node;
   61714   static Node *new_nterm (char const *, Node *, Node *, Node *);
   61715   static Node *new_term (char *);
   61716   static void free_node (Node *);
   61717   static char *node_to_string (Node *);
   61718   #define YYSTYPE Node *
   61719  static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
   61720   #define YYINITDEPTH 10
   61721   #define YYSTACKEXPANDABLE 1
   61722   struct YYLTYPE;
   61723 #if YYPURE
   61724 # if YYLSP_NEEDED
   61725 #  define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
   61726 #  define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
   61727 # else
   61728 #  define LEX_PARAMETERS YYSTYPE *lvalp
   61729 # endif
   61730 #endif
   61731 #ifndef LEX_PARAMETERS
   61732 # define LEX_PARAMETERS void
   61733 #endif
   61734 #ifndef ERROR_PARAMETERS
   61735 # define ERROR_PARAMETERS char const *s
   61736 #endif
   61737   int yylex (LEX_PARAMETERS);
   61738   void yyerror (ERROR_PARAMETERS);
   61739 %}
   61740 
   61741 %token TYPENAME ID
   61742 
   61743 %right '='
   61744 %left '+'
   61745 
   61746 %glr-parser
   61747 
   61748 %destructor { free_node ($$); } stmt expr decl declarator TYPENAME ID
   61749 
   61750 %%
   61751 
   61752 prog :
   61753      | prog stmt   {
   61754 			char *output;
   61755 			output = node_to_string ($2);
   61756 			printf ("%s\n", output);
   61757 			free (output);
   61758 			free_node ($2);
   61759 		   }
   61760      ;
   61761 
   61762 stmt : expr ';'  %merge <stmtMerge>	{ $$ = $1; }
   61763      | decl      %merge <stmtMerge>
   61764      | error ';'	{ $$ = new_nterm ("<error>", 0, 0, 0); }
   61765      | '@'		{ YYACCEPT; }
   61766      ;
   61767 
   61768 expr : ID
   61769      | TYPENAME '(' expr ')'
   61770 			{ $$ = new_nterm ("<cast>(%s,%s)", $3, $1, 0); }
   61771      | expr '+' expr	{ $$ = new_nterm ("+(%s,%s)", $1, $3, 0); }
   61772      | expr '=' expr    { $$ = new_nterm ("=(%s,%s)", $1, $3, 0); }
   61773      ;
   61774 
   61775 decl : TYPENAME declarator ';'
   61776 			{ $$ = new_nterm ("<declare>(%s,%s)", $1, $2, 0); }
   61777      | TYPENAME declarator '=' expr ';'
   61778 			{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
   61779 					  $2, $4); }
   61780      ;
   61781 
   61782 declarator : ID
   61783      | '(' declarator ')' { $$ = $2; }
   61784      ;
   61785 
   61786 %%
   61787 
   61788 #include <ctype.h>
   61789 #include <stdlib.h>
   61790 #include <string.h>
   61791 #include <stdarg.h>
   61792 
   61793 int
   61794 main (int argc, char **argv)
   61795 {
   61796   if (argc != 2)
   61797     abort ();
   61798   if (!freopen (argv[1], "r", stdin))
   61799     return 3;
   61800   return yyparse ();
   61801 }
   61802 
   61803 int
   61804 yylex (LEX_PARAMETERS)
   61805 {
   61806   char buffer[256];
   61807   int c;
   61808   unsigned int i;
   61809   static int lineNum = 1;
   61810   static int colNum = 0;
   61811 
   61812 #if YYPURE
   61813 # undef yylloc
   61814 # define yylloc (*llocp)
   61815 # undef yylval
   61816 # define yylval (*lvalp)
   61817 #endif
   61818 
   61819   while (1)
   61820     {
   61821       c = getchar ();
   61822       switch (c)
   61823 	{
   61824 	case EOF:
   61825 	  return 0;
   61826 	case '\t':
   61827 	  colNum = (colNum + 7) & ~7;
   61828 	  break;
   61829 	case ' ': case '\f':
   61830 	  colNum += 1;
   61831 	  break;
   61832 	case '\n':
   61833 	  lineNum += 1;
   61834 	  colNum = 0;
   61835 	  break;
   61836 	default:
   61837 	  {
   61838 	    int tok;
   61839 #if YYLSP_NEEDED
   61840 	    yylloc.first_line = yylloc.last_line = lineNum;
   61841 	    yylloc.first_column = colNum;
   61842 #endif
   61843 	    if (isalpha (c))
   61844 	      {
   61845 		i = 0;
   61846 
   61847 		do
   61848 		  {
   61849 		    buffer[i++] = c;
   61850 		    colNum += 1;
   61851 		    if (i == sizeof buffer - 1)
   61852 		      abort ();
   61853 		    c = getchar ();
   61854 		  }
   61855 		while (isalnum (c) || c == '_');
   61856 
   61857 		ungetc (c, stdin);
   61858 		buffer[i++] = 0;
   61859 		tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
   61860 		yylval = new_term (strcpy ((char *) malloc (i), buffer));
   61861 	      }
   61862 	    else
   61863 	      {
   61864 		colNum += 1;
   61865 		tok = c;
   61866 		yylval = 0;
   61867 	      }
   61868 #if YYLSP_NEEDED
   61869 	    yylloc.last_column = colNum-1;
   61870 #endif
   61871 	    return tok;
   61872 	  }
   61873 	}
   61874     }
   61875 }
   61876 
   61877 void
   61878 yyerror (ERROR_PARAMETERS)
   61879 {
   61880 #if YYPURE && YYLSP_NEEDED
   61881   /* Pacify GCC by using llocp.  */
   61882   if (! llocp)
   61883     abort ();
   61884 #endif
   61885   fprintf (stderr, "%s\n", s);
   61886 }
   61887 
   61888 static Node *
   61889 new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
   61890 {
   61891   Node *node = (Node *) malloc (sizeof (Node));
   61892   node->nterm.isNterm = 1;
   61893   node->nterm.parents = 0;
   61894   node->nterm.form = form;
   61895   node->nterm.children[0] = child0;
   61896   if (child0)
   61897     child0->nodeInfo.parents += 1;
   61898   node->nterm.children[1] = child1;
   61899   if (child1)
   61900     child1->nodeInfo.parents += 1;
   61901   node->nterm.children[2] = child2;
   61902   if (child2)
   61903     child2->nodeInfo.parents += 1;
   61904   return node;
   61905 }
   61906 
   61907 static Node *
   61908 new_term (char *text)
   61909 {
   61910   Node *node = (Node *) malloc (sizeof (Node));
   61911   node->term.isNterm = 0;
   61912   node->term.parents = 0;
   61913   node->term.text = text;
   61914   return node;
   61915 }
   61916 
   61917 static void
   61918 free_node (Node *node)
   61919 {
   61920   if (!node)
   61921     return;
   61922   node->nodeInfo.parents -= 1;
   61923   /* Free only if 0 (last parent) or -1 (no parents).  */
   61924   if (node->nodeInfo.parents > 0)
   61925     return;
   61926   if (node->nodeInfo.isNterm == 1)
   61927     {
   61928       free_node (node->nterm.children[0]);
   61929       free_node (node->nterm.children[1]);
   61930       free_node (node->nterm.children[2]);
   61931     }
   61932   else
   61933     free (node->term.text);
   61934   free (node);
   61935 }
   61936 
   61937 static char *
   61938 node_to_string (Node *node)
   61939 {
   61940   char *child0;
   61941   char *child1;
   61942   char *child2;
   61943   char *buffer;
   61944   if (!node)
   61945     {
   61946       buffer = (char *) malloc (1);
   61947       buffer[0] = 0;
   61948     }
   61949   else if (node->nodeInfo.isNterm == 1)
   61950     {
   61951       child0 = node_to_string (node->nterm.children[0]);
   61952       child1 = node_to_string (node->nterm.children[1]);
   61953       child2 = node_to_string (node->nterm.children[2]);
   61954       buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
   61955 				+ strlen (child1) + strlen (child2) + 1);
   61956       sprintf (buffer, node->nterm.form, child0, child1, child2);
   61957       free (child0);
   61958       free (child1);
   61959       free (child2);
   61960     }
   61961   else
   61962     buffer = strdup (node->term.text);
   61963   return buffer;
   61964 }
   61965 
   61966 
   61967 static YYSTYPE
   61968 stmtMerge (YYSTYPE x0, YYSTYPE x1)
   61969 {
   61970   return new_nterm ("<OR>(%s,%s)", x0, x1, 0);
   61971 }
   61972 
   61973 _ATEOF
   61974 
   61975 
   61976 
   61977 cat >test-input <<'_ATEOF'
   61978 
   61979 
   61980 z + q;
   61981 
   61982 T x;
   61983 
   61984 T x = y;
   61985 
   61986 x = y;
   61987 
   61988 T (x) + y;
   61989 
   61990 T (x);
   61991 
   61992 T (y) = z + q;
   61993 
   61994 T (y y) = z + q;
   61995 
   61996 z + q;
   61997 
   61998 @
   61999 
   62000 This is total garbage, but it should be ignored.
   62001 _ATEOF
   62002 
   62003 
   62004 $at_traceoff
   62005 echo "cxx-type.at:441: bison -o types.c types.y"
   62006 echo cxx-type.at:441 >$at_check_line_file
   62007 ( $at_traceon; bison -o types.c types.y ) >$at_stdout 2>$at_stder1
   62008 at_status=$?
   62009 grep '^ *+' $at_stder1 >&2
   62010 grep -v '^ *+' $at_stder1 >$at_stderr
   62011 at_failed=false
   62012 echo stderr:; cat $at_stderr
   62013 $at_diff $at_devnull $at_stdout || at_failed=:
   62014 case $at_status in
   62015    77) echo 77 > $at_status_file
   62016             exit 77;;
   62017    0) ;;
   62018    *) echo "cxx-type.at:441: exit code was $at_status, expected 0"
   62019       at_failed=:;;
   62020 esac
   62021 if $at_failed; then
   62022 
   62023   echo 1 > $at_status_file
   62024   exit 1
   62025 fi
   62026 
   62027 $at_traceon
   62028 
   62029 $at_traceoff
   62030 echo "cxx-type.at:441: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o types types.c \$LIBS"
   62031 echo cxx-type.at:441 >$at_check_line_file
   62032 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o types types.c $LIBS ) >$at_stdout 2>$at_stder1
   62033 at_status=$?
   62034 grep '^ *+' $at_stder1 >&2
   62035 grep -v '^ *+' $at_stder1 >$at_stderr
   62036 at_failed=false
   62037 echo stderr:; cat $at_stderr
   62038 echo stdout:; cat $at_stdout
   62039 case $at_status in
   62040    77) echo 77 > $at_status_file
   62041             exit 77;;
   62042    0) ;;
   62043    *) echo "cxx-type.at:441: exit code was $at_status, expected 0"
   62044       at_failed=:;;
   62045 esac
   62046 if $at_failed; then
   62047 
   62048   echo 1 > $at_status_file
   62049   exit 1
   62050 fi
   62051 
   62052 $at_traceon
   62053 
   62054 
   62055 
   62056 
   62057 
   62058 
   62059 
   62060 
   62061 
   62062 
   62063 
   62064 
   62065 
   62066 
   62067 
   62068 
   62069 
   62070 
   62071 
   62072 
   62073 
   62074 
   62075 
   62076 $at_traceoff
   62077 echo "cxx-type.at:443: \$PREPARSER ./types test-input"
   62078 echo cxx-type.at:443 >$at_check_line_file
   62079 ( $at_traceon; $PREPARSER ./types test-input ) >$at_stdout 2>$at_stder1
   62080 at_status=$?
   62081 grep '^ *+' $at_stder1 >&2
   62082 grep -v '^ *+' $at_stder1 >$at_stderr
   62083 at_failed=false
   62084 echo >>$at_stderr; echo "syntax error
   62085 " | $at_diff - $at_stderr || at_failed=:
   62086 echo >>$at_stdout; echo "+(z,q)
   62087 <declare>(T,x)
   62088 <init-declare>(T,x,y)
   62089 =(x,y)
   62090 +(<cast>(x,T),y)
   62091 <OR>(<declare>(T,x),<cast>(x,T))
   62092 <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
   62093 <error>
   62094 +(z,q)
   62095 " | $at_diff - $at_stdout || at_failed=:
   62096 case $at_status in
   62097    77) echo 77 > $at_status_file
   62098             exit 77;;
   62099    0) ;;
   62100    *) echo "cxx-type.at:443: exit code was $at_status, expected 0"
   62101       at_failed=:;;
   62102 esac
   62103 if $at_failed; then
   62104 
   62105   echo 1 > $at_status_file
   62106   exit 1
   62107 fi
   62108 
   62109 $at_traceon
   62110 
   62111       $at_traceoff
   62112       $at_times_p && times >$at_times_file
   62113     ) 5>&1 2>&1 | eval $at_tee_pipe
   62114     at_status=`cat $at_status_file`
   62115     ;;
   62116 
   62117   138 ) # 138. cxx-type.at:446: GLR: Merge conflicting parses, impure, locations
   62118     at_setup_line='cxx-type.at:446'
   62119     at_desc='GLR: Merge conflicting parses, impure, locations'
   62120     $at_quiet $ECHO_N "138: GLR: Merge conflicting parses, impure, locations$ECHO_C"
   62121     at_xfail=no
   62122     (
   62123       echo "138. cxx-type.at:446: testing ..."
   62124       $at_traceon
   62125 
   62126 
   62127 
   62128 
   62129 
   62130 
   62131 # Using yacc.c?
   62132 
   62133 
   62134 
   62135 
   62136 
   62137 
   62138 
   62139 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   62140 
   62141 # yyerror always sees the locations (when activated), except if
   62142 # yacc & pure & !param.
   62143 
   62144 
   62145 # The interface is pure: either because %pure-parser, or because we
   62146 # are using the C++ parsers.
   62147 
   62148 
   62149 
   62150 
   62151 
   62152 
   62153 
   62154 
   62155 
   62156 
   62157 
   62158 
   62159 cat >types.y <<'_ATEOF'
   62160 %{
   62161 #ifdef HAVE_CONFIG_H
   62162 # include <config.h>
   62163   /* We don't need perfect functions for these tests. */
   62164 # undef malloc
   62165 # undef memcmp
   62166 # undef realloc
   62167 #endif
   62168 %}
   62169 
   62170 /* Simplified C++ Type and Expression Grammar.  */
   62171 
   62172 %locations
   62173 
   62174 %{
   62175   #include <stdio.h>
   62176   union Node {
   62177     struct {
   62178       int isNterm;
   62179       int parents;
   62180     } nodeInfo;
   62181     struct {
   62182       int isNterm; /* 1 */
   62183       int parents;
   62184       char const *form;
   62185       union Node *children[3];
   62186     } nterm;
   62187     struct {
   62188       int isNterm; /* 0 */
   62189       int parents;
   62190       char *text;
   62191     } term;
   62192   };
   62193   typedef union Node Node;
   62194   static Node *new_nterm (char const *, Node *, Node *, Node *);
   62195   static Node *new_term (char *);
   62196   static void free_node (Node *);
   62197   static char *node_to_string (Node *);
   62198   #define YYSTYPE Node *
   62199  static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
   62200   #define YYINITDEPTH 10
   62201   #define YYSTACKEXPANDABLE 1
   62202   struct YYLTYPE;
   62203 #if YYPURE
   62204 # if YYLSP_NEEDED
   62205 #  define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
   62206 #  define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
   62207 # else
   62208 #  define LEX_PARAMETERS YYSTYPE *lvalp
   62209 # endif
   62210 #endif
   62211 #ifndef LEX_PARAMETERS
   62212 # define LEX_PARAMETERS void
   62213 #endif
   62214 #ifndef ERROR_PARAMETERS
   62215 # define ERROR_PARAMETERS char const *s
   62216 #endif
   62217   int yylex (LEX_PARAMETERS);
   62218   void yyerror (ERROR_PARAMETERS);
   62219 %}
   62220 
   62221 %token TYPENAME ID
   62222 
   62223 %right '='
   62224 %left '+'
   62225 
   62226 %glr-parser
   62227 
   62228 %destructor { free_node ($$); } stmt expr decl declarator TYPENAME ID
   62229 
   62230 %%
   62231 
   62232 prog :
   62233      | prog stmt   {
   62234 			char *output;
   62235 			printf ("%d.%d-%d.%d: ",
   62236 			     @2.first_line, @2.first_column,
   62237 			     @2.last_line, @2.last_column);
   62238 			output = node_to_string ($2);
   62239 			printf ("%s\n", output);
   62240 			free (output);
   62241 			free_node ($2);
   62242 		   }
   62243      ;
   62244 
   62245 stmt : expr ';'  %merge <stmtMerge>	{ $$ = $1; }
   62246      | decl      %merge <stmtMerge>
   62247      | error ';'	{ $$ = new_nterm ("<error>", 0, 0, 0); }
   62248      | '@'		{ YYACCEPT; }
   62249      ;
   62250 
   62251 expr : ID
   62252      | TYPENAME '(' expr ')'
   62253 			{ $$ = new_nterm ("<cast>(%s,%s)", $3, $1, 0); }
   62254      | expr '+' expr	{ $$ = new_nterm ("+(%s,%s)", $1, $3, 0); }
   62255      | expr '=' expr    { $$ = new_nterm ("=(%s,%s)", $1, $3, 0); }
   62256      ;
   62257 
   62258 decl : TYPENAME declarator ';'
   62259 			{ $$ = new_nterm ("<declare>(%s,%s)", $1, $2, 0); }
   62260      | TYPENAME declarator '=' expr ';'
   62261 			{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
   62262 					  $2, $4); }
   62263      ;
   62264 
   62265 declarator : ID
   62266      | '(' declarator ')' { $$ = $2; }
   62267      ;
   62268 
   62269 %%
   62270 
   62271 #include <ctype.h>
   62272 #include <stdlib.h>
   62273 #include <string.h>
   62274 #include <stdarg.h>
   62275 
   62276 int
   62277 main (int argc, char **argv)
   62278 {
   62279   if (argc != 2)
   62280     abort ();
   62281   if (!freopen (argv[1], "r", stdin))
   62282     return 3;
   62283   return yyparse ();
   62284 }
   62285 
   62286 int
   62287 yylex (LEX_PARAMETERS)
   62288 {
   62289   char buffer[256];
   62290   int c;
   62291   unsigned int i;
   62292   static int lineNum = 1;
   62293   static int colNum = 0;
   62294 
   62295 #if YYPURE
   62296 # undef yylloc
   62297 # define yylloc (*llocp)
   62298 # undef yylval
   62299 # define yylval (*lvalp)
   62300 #endif
   62301 
   62302   while (1)
   62303     {
   62304       c = getchar ();
   62305       switch (c)
   62306 	{
   62307 	case EOF:
   62308 	  return 0;
   62309 	case '\t':
   62310 	  colNum = (colNum + 7) & ~7;
   62311 	  break;
   62312 	case ' ': case '\f':
   62313 	  colNum += 1;
   62314 	  break;
   62315 	case '\n':
   62316 	  lineNum += 1;
   62317 	  colNum = 0;
   62318 	  break;
   62319 	default:
   62320 	  {
   62321 	    int tok;
   62322 #if YYLSP_NEEDED
   62323 	    yylloc.first_line = yylloc.last_line = lineNum;
   62324 	    yylloc.first_column = colNum;
   62325 #endif
   62326 	    if (isalpha (c))
   62327 	      {
   62328 		i = 0;
   62329 
   62330 		do
   62331 		  {
   62332 		    buffer[i++] = c;
   62333 		    colNum += 1;
   62334 		    if (i == sizeof buffer - 1)
   62335 		      abort ();
   62336 		    c = getchar ();
   62337 		  }
   62338 		while (isalnum (c) || c == '_');
   62339 
   62340 		ungetc (c, stdin);
   62341 		buffer[i++] = 0;
   62342 		tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
   62343 		yylval = new_term (strcpy ((char *) malloc (i), buffer));
   62344 	      }
   62345 	    else
   62346 	      {
   62347 		colNum += 1;
   62348 		tok = c;
   62349 		yylval = 0;
   62350 	      }
   62351 #if YYLSP_NEEDED
   62352 	    yylloc.last_column = colNum-1;
   62353 #endif
   62354 	    return tok;
   62355 	  }
   62356 	}
   62357     }
   62358 }
   62359 
   62360 void
   62361 yyerror (ERROR_PARAMETERS)
   62362 {
   62363 #if YYPURE && YYLSP_NEEDED
   62364   /* Pacify GCC by using llocp.  */
   62365   if (! llocp)
   62366     abort ();
   62367 #endif
   62368   fprintf (stderr, "%s\n", s);
   62369 }
   62370 
   62371 static Node *
   62372 new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
   62373 {
   62374   Node *node = (Node *) malloc (sizeof (Node));
   62375   node->nterm.isNterm = 1;
   62376   node->nterm.parents = 0;
   62377   node->nterm.form = form;
   62378   node->nterm.children[0] = child0;
   62379   if (child0)
   62380     child0->nodeInfo.parents += 1;
   62381   node->nterm.children[1] = child1;
   62382   if (child1)
   62383     child1->nodeInfo.parents += 1;
   62384   node->nterm.children[2] = child2;
   62385   if (child2)
   62386     child2->nodeInfo.parents += 1;
   62387   return node;
   62388 }
   62389 
   62390 static Node *
   62391 new_term (char *text)
   62392 {
   62393   Node *node = (Node *) malloc (sizeof (Node));
   62394   node->term.isNterm = 0;
   62395   node->term.parents = 0;
   62396   node->term.text = text;
   62397   return node;
   62398 }
   62399 
   62400 static void
   62401 free_node (Node *node)
   62402 {
   62403   if (!node)
   62404     return;
   62405   node->nodeInfo.parents -= 1;
   62406   /* Free only if 0 (last parent) or -1 (no parents).  */
   62407   if (node->nodeInfo.parents > 0)
   62408     return;
   62409   if (node->nodeInfo.isNterm == 1)
   62410     {
   62411       free_node (node->nterm.children[0]);
   62412       free_node (node->nterm.children[1]);
   62413       free_node (node->nterm.children[2]);
   62414     }
   62415   else
   62416     free (node->term.text);
   62417   free (node);
   62418 }
   62419 
   62420 static char *
   62421 node_to_string (Node *node)
   62422 {
   62423   char *child0;
   62424   char *child1;
   62425   char *child2;
   62426   char *buffer;
   62427   if (!node)
   62428     {
   62429       buffer = (char *) malloc (1);
   62430       buffer[0] = 0;
   62431     }
   62432   else if (node->nodeInfo.isNterm == 1)
   62433     {
   62434       child0 = node_to_string (node->nterm.children[0]);
   62435       child1 = node_to_string (node->nterm.children[1]);
   62436       child2 = node_to_string (node->nterm.children[2]);
   62437       buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
   62438 				+ strlen (child1) + strlen (child2) + 1);
   62439       sprintf (buffer, node->nterm.form, child0, child1, child2);
   62440       free (child0);
   62441       free (child1);
   62442       free (child2);
   62443     }
   62444   else
   62445     buffer = strdup (node->term.text);
   62446   return buffer;
   62447 }
   62448 
   62449 
   62450 static YYSTYPE
   62451 stmtMerge (YYSTYPE x0, YYSTYPE x1)
   62452 {
   62453   return new_nterm ("<OR>(%s,%s)", x0, x1, 0);
   62454 }
   62455 
   62456 _ATEOF
   62457 
   62458 
   62459 
   62460 cat >test-input <<'_ATEOF'
   62461 
   62462 
   62463 z + q;
   62464 
   62465 T x;
   62466 
   62467 T x = y;
   62468 
   62469 x = y;
   62470 
   62471 T (x) + y;
   62472 
   62473 T (x);
   62474 
   62475 T (y) = z + q;
   62476 
   62477 T (y y) = z + q;
   62478 
   62479 z + q;
   62480 
   62481 @
   62482 
   62483 This is total garbage, but it should be ignored.
   62484 _ATEOF
   62485 
   62486 
   62487 $at_traceoff
   62488 echo "cxx-type.at:448: bison -o types.c types.y"
   62489 echo cxx-type.at:448 >$at_check_line_file
   62490 ( $at_traceon; bison -o types.c types.y ) >$at_stdout 2>$at_stder1
   62491 at_status=$?
   62492 grep '^ *+' $at_stder1 >&2
   62493 grep -v '^ *+' $at_stder1 >$at_stderr
   62494 at_failed=false
   62495 echo stderr:; cat $at_stderr
   62496 $at_diff $at_devnull $at_stdout || at_failed=:
   62497 case $at_status in
   62498    77) echo 77 > $at_status_file
   62499             exit 77;;
   62500    0) ;;
   62501    *) echo "cxx-type.at:448: exit code was $at_status, expected 0"
   62502       at_failed=:;;
   62503 esac
   62504 if $at_failed; then
   62505 
   62506   echo 1 > $at_status_file
   62507   exit 1
   62508 fi
   62509 
   62510 $at_traceon
   62511 
   62512 $at_traceoff
   62513 echo "cxx-type.at:448: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o types types.c \$LIBS"
   62514 echo cxx-type.at:448 >$at_check_line_file
   62515 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o types types.c $LIBS ) >$at_stdout 2>$at_stder1
   62516 at_status=$?
   62517 grep '^ *+' $at_stder1 >&2
   62518 grep -v '^ *+' $at_stder1 >$at_stderr
   62519 at_failed=false
   62520 echo stderr:; cat $at_stderr
   62521 echo stdout:; cat $at_stdout
   62522 case $at_status in
   62523    77) echo 77 > $at_status_file
   62524             exit 77;;
   62525    0) ;;
   62526    *) echo "cxx-type.at:448: exit code was $at_status, expected 0"
   62527       at_failed=:;;
   62528 esac
   62529 if $at_failed; then
   62530 
   62531   echo 1 > $at_status_file
   62532   exit 1
   62533 fi
   62534 
   62535 $at_traceon
   62536 
   62537 
   62538 
   62539 
   62540 
   62541 
   62542 
   62543 
   62544 
   62545 
   62546 
   62547 
   62548 
   62549 
   62550 
   62551 
   62552 
   62553 
   62554 
   62555 
   62556 
   62557 
   62558 
   62559 $at_traceoff
   62560 echo "cxx-type.at:450: \$PREPARSER ./types test-input"
   62561 echo cxx-type.at:450 >$at_check_line_file
   62562 ( $at_traceon; $PREPARSER ./types test-input ) >$at_stdout 2>$at_stder1
   62563 at_status=$?
   62564 grep '^ *+' $at_stder1 >&2
   62565 grep -v '^ *+' $at_stder1 >$at_stderr
   62566 at_failed=false
   62567 echo >>$at_stderr; echo "syntax error
   62568 " | $at_diff - $at_stderr || at_failed=:
   62569 echo >>$at_stdout; echo "3.0-3.5: +(z,q)
   62570 5.0-5.3: <declare>(T,x)
   62571 7.0-7.7: <init-declare>(T,x,y)
   62572 9.0-9.5: =(x,y)
   62573 11.0-11.9: +(<cast>(x,T),y)
   62574 13.0-13.5: <OR>(<declare>(T,x),<cast>(x,T))
   62575 15.0-15.13: <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
   62576 17.0-17.15: <error>
   62577 19.0-19.5: +(z,q)
   62578 " | $at_diff - $at_stdout || at_failed=:
   62579 case $at_status in
   62580    77) echo 77 > $at_status_file
   62581             exit 77;;
   62582    0) ;;
   62583    *) echo "cxx-type.at:450: exit code was $at_status, expected 0"
   62584       at_failed=:;;
   62585 esac
   62586 if $at_failed; then
   62587 
   62588   echo 1 > $at_status_file
   62589   exit 1
   62590 fi
   62591 
   62592 $at_traceon
   62593 
   62594       $at_traceoff
   62595       $at_times_p && times >$at_times_file
   62596     ) 5>&1 2>&1 | eval $at_tee_pipe
   62597     at_status=`cat $at_status_file`
   62598     ;;
   62599 
   62600   139 ) # 139. cxx-type.at:453: GLR: Merge conflicting parses, pure, no locations
   62601     at_setup_line='cxx-type.at:453'
   62602     at_desc='GLR: Merge conflicting parses, pure, no locations'
   62603     $at_quiet $ECHO_N "139: GLR: Merge conflicting parses, pure, no locations$ECHO_C"
   62604     at_xfail=no
   62605     (
   62606       echo "139. cxx-type.at:453: testing ..."
   62607       $at_traceon
   62608 
   62609 
   62610 
   62611 
   62612 
   62613 
   62614 # Using yacc.c?
   62615 
   62616 
   62617 
   62618 
   62619 
   62620 
   62621 
   62622 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   62623 
   62624 # yyerror always sees the locations (when activated), except if
   62625 # yacc & pure & !param.
   62626 
   62627 
   62628 # The interface is pure: either because %pure-parser, or because we
   62629 # are using the C++ parsers.
   62630 
   62631 
   62632 
   62633 
   62634 
   62635 
   62636 
   62637 
   62638 
   62639 
   62640 
   62641 
   62642 cat >types.y <<'_ATEOF'
   62643 %{
   62644 #ifdef HAVE_CONFIG_H
   62645 # include <config.h>
   62646   /* We don't need perfect functions for these tests. */
   62647 # undef malloc
   62648 # undef memcmp
   62649 # undef realloc
   62650 #endif
   62651 %}
   62652 
   62653 /* Simplified C++ Type and Expression Grammar.  */
   62654 
   62655 %pure-parser
   62656 
   62657 %{
   62658   #include <stdio.h>
   62659   union Node {
   62660     struct {
   62661       int isNterm;
   62662       int parents;
   62663     } nodeInfo;
   62664     struct {
   62665       int isNterm; /* 1 */
   62666       int parents;
   62667       char const *form;
   62668       union Node *children[3];
   62669     } nterm;
   62670     struct {
   62671       int isNterm; /* 0 */
   62672       int parents;
   62673       char *text;
   62674     } term;
   62675   };
   62676   typedef union Node Node;
   62677   static Node *new_nterm (char const *, Node *, Node *, Node *);
   62678   static Node *new_term (char *);
   62679   static void free_node (Node *);
   62680   static char *node_to_string (Node *);
   62681   #define YYSTYPE Node *
   62682  static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
   62683   #define YYINITDEPTH 10
   62684   #define YYSTACKEXPANDABLE 1
   62685   struct YYLTYPE;
   62686 #if YYPURE
   62687 # if YYLSP_NEEDED
   62688 #  define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
   62689 #  define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
   62690 # else
   62691 #  define LEX_PARAMETERS YYSTYPE *lvalp
   62692 # endif
   62693 #endif
   62694 #ifndef LEX_PARAMETERS
   62695 # define LEX_PARAMETERS void
   62696 #endif
   62697 #ifndef ERROR_PARAMETERS
   62698 # define ERROR_PARAMETERS char const *s
   62699 #endif
   62700   int yylex (LEX_PARAMETERS);
   62701   void yyerror (ERROR_PARAMETERS);
   62702 %}
   62703 
   62704 %token TYPENAME ID
   62705 
   62706 %right '='
   62707 %left '+'
   62708 
   62709 %glr-parser
   62710 
   62711 %destructor { free_node ($$); } stmt expr decl declarator TYPENAME ID
   62712 
   62713 %%
   62714 
   62715 prog :
   62716      | prog stmt   {
   62717 			char *output;
   62718 			output = node_to_string ($2);
   62719 			printf ("%s\n", output);
   62720 			free (output);
   62721 			free_node ($2);
   62722 		   }
   62723      ;
   62724 
   62725 stmt : expr ';'  %merge <stmtMerge>	{ $$ = $1; }
   62726      | decl      %merge <stmtMerge>
   62727      | error ';'	{ $$ = new_nterm ("<error>", 0, 0, 0); }
   62728      | '@'		{ YYACCEPT; }
   62729      ;
   62730 
   62731 expr : ID
   62732      | TYPENAME '(' expr ')'
   62733 			{ $$ = new_nterm ("<cast>(%s,%s)", $3, $1, 0); }
   62734      | expr '+' expr	{ $$ = new_nterm ("+(%s,%s)", $1, $3, 0); }
   62735      | expr '=' expr    { $$ = new_nterm ("=(%s,%s)", $1, $3, 0); }
   62736      ;
   62737 
   62738 decl : TYPENAME declarator ';'
   62739 			{ $$ = new_nterm ("<declare>(%s,%s)", $1, $2, 0); }
   62740      | TYPENAME declarator '=' expr ';'
   62741 			{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
   62742 					  $2, $4); }
   62743      ;
   62744 
   62745 declarator : ID
   62746      | '(' declarator ')' { $$ = $2; }
   62747      ;
   62748 
   62749 %%
   62750 
   62751 #include <ctype.h>
   62752 #include <stdlib.h>
   62753 #include <string.h>
   62754 #include <stdarg.h>
   62755 
   62756 int
   62757 main (int argc, char **argv)
   62758 {
   62759   if (argc != 2)
   62760     abort ();
   62761   if (!freopen (argv[1], "r", stdin))
   62762     return 3;
   62763   return yyparse ();
   62764 }
   62765 
   62766 int
   62767 yylex (LEX_PARAMETERS)
   62768 {
   62769   char buffer[256];
   62770   int c;
   62771   unsigned int i;
   62772   static int lineNum = 1;
   62773   static int colNum = 0;
   62774 
   62775 #if YYPURE
   62776 # undef yylloc
   62777 # define yylloc (*llocp)
   62778 # undef yylval
   62779 # define yylval (*lvalp)
   62780 #endif
   62781 
   62782   while (1)
   62783     {
   62784       c = getchar ();
   62785       switch (c)
   62786 	{
   62787 	case EOF:
   62788 	  return 0;
   62789 	case '\t':
   62790 	  colNum = (colNum + 7) & ~7;
   62791 	  break;
   62792 	case ' ': case '\f':
   62793 	  colNum += 1;
   62794 	  break;
   62795 	case '\n':
   62796 	  lineNum += 1;
   62797 	  colNum = 0;
   62798 	  break;
   62799 	default:
   62800 	  {
   62801 	    int tok;
   62802 #if YYLSP_NEEDED
   62803 	    yylloc.first_line = yylloc.last_line = lineNum;
   62804 	    yylloc.first_column = colNum;
   62805 #endif
   62806 	    if (isalpha (c))
   62807 	      {
   62808 		i = 0;
   62809 
   62810 		do
   62811 		  {
   62812 		    buffer[i++] = c;
   62813 		    colNum += 1;
   62814 		    if (i == sizeof buffer - 1)
   62815 		      abort ();
   62816 		    c = getchar ();
   62817 		  }
   62818 		while (isalnum (c) || c == '_');
   62819 
   62820 		ungetc (c, stdin);
   62821 		buffer[i++] = 0;
   62822 		tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
   62823 		yylval = new_term (strcpy ((char *) malloc (i), buffer));
   62824 	      }
   62825 	    else
   62826 	      {
   62827 		colNum += 1;
   62828 		tok = c;
   62829 		yylval = 0;
   62830 	      }
   62831 #if YYLSP_NEEDED
   62832 	    yylloc.last_column = colNum-1;
   62833 #endif
   62834 	    return tok;
   62835 	  }
   62836 	}
   62837     }
   62838 }
   62839 
   62840 void
   62841 yyerror (ERROR_PARAMETERS)
   62842 {
   62843 #if YYPURE && YYLSP_NEEDED
   62844   /* Pacify GCC by using llocp.  */
   62845   if (! llocp)
   62846     abort ();
   62847 #endif
   62848   fprintf (stderr, "%s\n", s);
   62849 }
   62850 
   62851 static Node *
   62852 new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
   62853 {
   62854   Node *node = (Node *) malloc (sizeof (Node));
   62855   node->nterm.isNterm = 1;
   62856   node->nterm.parents = 0;
   62857   node->nterm.form = form;
   62858   node->nterm.children[0] = child0;
   62859   if (child0)
   62860     child0->nodeInfo.parents += 1;
   62861   node->nterm.children[1] = child1;
   62862   if (child1)
   62863     child1->nodeInfo.parents += 1;
   62864   node->nterm.children[2] = child2;
   62865   if (child2)
   62866     child2->nodeInfo.parents += 1;
   62867   return node;
   62868 }
   62869 
   62870 static Node *
   62871 new_term (char *text)
   62872 {
   62873   Node *node = (Node *) malloc (sizeof (Node));
   62874   node->term.isNterm = 0;
   62875   node->term.parents = 0;
   62876   node->term.text = text;
   62877   return node;
   62878 }
   62879 
   62880 static void
   62881 free_node (Node *node)
   62882 {
   62883   if (!node)
   62884     return;
   62885   node->nodeInfo.parents -= 1;
   62886   /* Free only if 0 (last parent) or -1 (no parents).  */
   62887   if (node->nodeInfo.parents > 0)
   62888     return;
   62889   if (node->nodeInfo.isNterm == 1)
   62890     {
   62891       free_node (node->nterm.children[0]);
   62892       free_node (node->nterm.children[1]);
   62893       free_node (node->nterm.children[2]);
   62894     }
   62895   else
   62896     free (node->term.text);
   62897   free (node);
   62898 }
   62899 
   62900 static char *
   62901 node_to_string (Node *node)
   62902 {
   62903   char *child0;
   62904   char *child1;
   62905   char *child2;
   62906   char *buffer;
   62907   if (!node)
   62908     {
   62909       buffer = (char *) malloc (1);
   62910       buffer[0] = 0;
   62911     }
   62912   else if (node->nodeInfo.isNterm == 1)
   62913     {
   62914       child0 = node_to_string (node->nterm.children[0]);
   62915       child1 = node_to_string (node->nterm.children[1]);
   62916       child2 = node_to_string (node->nterm.children[2]);
   62917       buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
   62918 				+ strlen (child1) + strlen (child2) + 1);
   62919       sprintf (buffer, node->nterm.form, child0, child1, child2);
   62920       free (child0);
   62921       free (child1);
   62922       free (child2);
   62923     }
   62924   else
   62925     buffer = strdup (node->term.text);
   62926   return buffer;
   62927 }
   62928 
   62929 
   62930 static YYSTYPE
   62931 stmtMerge (YYSTYPE x0, YYSTYPE x1)
   62932 {
   62933   return new_nterm ("<OR>(%s,%s)", x0, x1, 0);
   62934 }
   62935 
   62936 _ATEOF
   62937 
   62938 
   62939 
   62940 cat >test-input <<'_ATEOF'
   62941 
   62942 
   62943 z + q;
   62944 
   62945 T x;
   62946 
   62947 T x = y;
   62948 
   62949 x = y;
   62950 
   62951 T (x) + y;
   62952 
   62953 T (x);
   62954 
   62955 T (y) = z + q;
   62956 
   62957 T (y y) = z + q;
   62958 
   62959 z + q;
   62960 
   62961 @
   62962 
   62963 This is total garbage, but it should be ignored.
   62964 _ATEOF
   62965 
   62966 
   62967 $at_traceoff
   62968 echo "cxx-type.at:455: bison -o types.c types.y"
   62969 echo cxx-type.at:455 >$at_check_line_file
   62970 ( $at_traceon; bison -o types.c types.y ) >$at_stdout 2>$at_stder1
   62971 at_status=$?
   62972 grep '^ *+' $at_stder1 >&2
   62973 grep -v '^ *+' $at_stder1 >$at_stderr
   62974 at_failed=false
   62975 echo stderr:; cat $at_stderr
   62976 $at_diff $at_devnull $at_stdout || at_failed=:
   62977 case $at_status in
   62978    77) echo 77 > $at_status_file
   62979             exit 77;;
   62980    0) ;;
   62981    *) echo "cxx-type.at:455: exit code was $at_status, expected 0"
   62982       at_failed=:;;
   62983 esac
   62984 if $at_failed; then
   62985 
   62986   echo 1 > $at_status_file
   62987   exit 1
   62988 fi
   62989 
   62990 $at_traceon
   62991 
   62992 $at_traceoff
   62993 echo "cxx-type.at:455: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o types types.c \$LIBS"
   62994 echo cxx-type.at:455 >$at_check_line_file
   62995 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o types types.c $LIBS ) >$at_stdout 2>$at_stder1
   62996 at_status=$?
   62997 grep '^ *+' $at_stder1 >&2
   62998 grep -v '^ *+' $at_stder1 >$at_stderr
   62999 at_failed=false
   63000 echo stderr:; cat $at_stderr
   63001 echo stdout:; cat $at_stdout
   63002 case $at_status in
   63003    77) echo 77 > $at_status_file
   63004             exit 77;;
   63005    0) ;;
   63006    *) echo "cxx-type.at:455: exit code was $at_status, expected 0"
   63007       at_failed=:;;
   63008 esac
   63009 if $at_failed; then
   63010 
   63011   echo 1 > $at_status_file
   63012   exit 1
   63013 fi
   63014 
   63015 $at_traceon
   63016 
   63017 
   63018 
   63019 
   63020 
   63021 
   63022 
   63023 
   63024 
   63025 
   63026 
   63027 
   63028 
   63029 
   63030 
   63031 
   63032 
   63033 
   63034 
   63035 
   63036 
   63037 
   63038 
   63039 $at_traceoff
   63040 echo "cxx-type.at:457: \$PREPARSER ./types test-input"
   63041 echo cxx-type.at:457 >$at_check_line_file
   63042 ( $at_traceon; $PREPARSER ./types test-input ) >$at_stdout 2>$at_stder1
   63043 at_status=$?
   63044 grep '^ *+' $at_stder1 >&2
   63045 grep -v '^ *+' $at_stder1 >$at_stderr
   63046 at_failed=false
   63047 echo >>$at_stderr; echo "syntax error
   63048 " | $at_diff - $at_stderr || at_failed=:
   63049 echo >>$at_stdout; echo "+(z,q)
   63050 <declare>(T,x)
   63051 <init-declare>(T,x,y)
   63052 =(x,y)
   63053 +(<cast>(x,T),y)
   63054 <OR>(<declare>(T,x),<cast>(x,T))
   63055 <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
   63056 <error>
   63057 +(z,q)
   63058 " | $at_diff - $at_stdout || at_failed=:
   63059 case $at_status in
   63060    77) echo 77 > $at_status_file
   63061             exit 77;;
   63062    0) ;;
   63063    *) echo "cxx-type.at:457: exit code was $at_status, expected 0"
   63064       at_failed=:;;
   63065 esac
   63066 if $at_failed; then
   63067 
   63068   echo 1 > $at_status_file
   63069   exit 1
   63070 fi
   63071 
   63072 $at_traceon
   63073 
   63074       $at_traceoff
   63075       $at_times_p && times >$at_times_file
   63076     ) 5>&1 2>&1 | eval $at_tee_pipe
   63077     at_status=`cat $at_status_file`
   63078     ;;
   63079 
   63080   140 ) # 140. cxx-type.at:459: GLR: Merge conflicting parses, pure, locations
   63081     at_setup_line='cxx-type.at:459'
   63082     at_desc='GLR: Merge conflicting parses, pure, locations'
   63083     $at_quiet $ECHO_N "140: GLR: Merge conflicting parses, pure, locations$ECHO_C"
   63084     at_xfail=no
   63085     (
   63086       echo "140. cxx-type.at:459: testing ..."
   63087       $at_traceon
   63088 
   63089 
   63090 
   63091 
   63092 
   63093 
   63094 # Using yacc.c?
   63095 
   63096 
   63097 
   63098 
   63099 
   63100 
   63101 
   63102 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   63103 
   63104 # yyerror always sees the locations (when activated), except if
   63105 # yacc & pure & !param.
   63106 
   63107 
   63108 # The interface is pure: either because %pure-parser, or because we
   63109 # are using the C++ parsers.
   63110 
   63111 
   63112 
   63113 
   63114 
   63115 
   63116 
   63117 
   63118 
   63119 
   63120 
   63121 
   63122 cat >types.y <<'_ATEOF'
   63123 %{
   63124 #ifdef HAVE_CONFIG_H
   63125 # include <config.h>
   63126   /* We don't need perfect functions for these tests. */
   63127 # undef malloc
   63128 # undef memcmp
   63129 # undef realloc
   63130 #endif
   63131 %}
   63132 
   63133 /* Simplified C++ Type and Expression Grammar.  */
   63134 
   63135 %pure-parser %locations
   63136 
   63137 %{
   63138   #include <stdio.h>
   63139   union Node {
   63140     struct {
   63141       int isNterm;
   63142       int parents;
   63143     } nodeInfo;
   63144     struct {
   63145       int isNterm; /* 1 */
   63146       int parents;
   63147       char const *form;
   63148       union Node *children[3];
   63149     } nterm;
   63150     struct {
   63151       int isNterm; /* 0 */
   63152       int parents;
   63153       char *text;
   63154     } term;
   63155   };
   63156   typedef union Node Node;
   63157   static Node *new_nterm (char const *, Node *, Node *, Node *);
   63158   static Node *new_term (char *);
   63159   static void free_node (Node *);
   63160   static char *node_to_string (Node *);
   63161   #define YYSTYPE Node *
   63162  static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
   63163   #define YYINITDEPTH 10
   63164   #define YYSTACKEXPANDABLE 1
   63165   struct YYLTYPE;
   63166 #if YYPURE
   63167 # if YYLSP_NEEDED
   63168 #  define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
   63169 #  define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
   63170 # else
   63171 #  define LEX_PARAMETERS YYSTYPE *lvalp
   63172 # endif
   63173 #endif
   63174 #ifndef LEX_PARAMETERS
   63175 # define LEX_PARAMETERS void
   63176 #endif
   63177 #ifndef ERROR_PARAMETERS
   63178 # define ERROR_PARAMETERS char const *s
   63179 #endif
   63180   int yylex (LEX_PARAMETERS);
   63181   void yyerror (ERROR_PARAMETERS);
   63182 %}
   63183 
   63184 %token TYPENAME ID
   63185 
   63186 %right '='
   63187 %left '+'
   63188 
   63189 %glr-parser
   63190 
   63191 %destructor { free_node ($$); } stmt expr decl declarator TYPENAME ID
   63192 
   63193 %%
   63194 
   63195 prog :
   63196      | prog stmt   {
   63197 			char *output;
   63198 			printf ("%d.%d-%d.%d: ",
   63199 			     @2.first_line, @2.first_column,
   63200 			     @2.last_line, @2.last_column);
   63201 			output = node_to_string ($2);
   63202 			printf ("%s\n", output);
   63203 			free (output);
   63204 			free_node ($2);
   63205 		   }
   63206      ;
   63207 
   63208 stmt : expr ';'  %merge <stmtMerge>	{ $$ = $1; }
   63209      | decl      %merge <stmtMerge>
   63210      | error ';'	{ $$ = new_nterm ("<error>", 0, 0, 0); }
   63211      | '@'		{ YYACCEPT; }
   63212      ;
   63213 
   63214 expr : ID
   63215      | TYPENAME '(' expr ')'
   63216 			{ $$ = new_nterm ("<cast>(%s,%s)", $3, $1, 0); }
   63217      | expr '+' expr	{ $$ = new_nterm ("+(%s,%s)", $1, $3, 0); }
   63218      | expr '=' expr    { $$ = new_nterm ("=(%s,%s)", $1, $3, 0); }
   63219      ;
   63220 
   63221 decl : TYPENAME declarator ';'
   63222 			{ $$ = new_nterm ("<declare>(%s,%s)", $1, $2, 0); }
   63223      | TYPENAME declarator '=' expr ';'
   63224 			{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
   63225 					  $2, $4); }
   63226      ;
   63227 
   63228 declarator : ID
   63229      | '(' declarator ')' { $$ = $2; }
   63230      ;
   63231 
   63232 %%
   63233 
   63234 #include <ctype.h>
   63235 #include <stdlib.h>
   63236 #include <string.h>
   63237 #include <stdarg.h>
   63238 
   63239 int
   63240 main (int argc, char **argv)
   63241 {
   63242   if (argc != 2)
   63243     abort ();
   63244   if (!freopen (argv[1], "r", stdin))
   63245     return 3;
   63246   return yyparse ();
   63247 }
   63248 
   63249 int
   63250 yylex (LEX_PARAMETERS)
   63251 {
   63252   char buffer[256];
   63253   int c;
   63254   unsigned int i;
   63255   static int lineNum = 1;
   63256   static int colNum = 0;
   63257 
   63258 #if YYPURE
   63259 # undef yylloc
   63260 # define yylloc (*llocp)
   63261 # undef yylval
   63262 # define yylval (*lvalp)
   63263 #endif
   63264 
   63265   while (1)
   63266     {
   63267       c = getchar ();
   63268       switch (c)
   63269 	{
   63270 	case EOF:
   63271 	  return 0;
   63272 	case '\t':
   63273 	  colNum = (colNum + 7) & ~7;
   63274 	  break;
   63275 	case ' ': case '\f':
   63276 	  colNum += 1;
   63277 	  break;
   63278 	case '\n':
   63279 	  lineNum += 1;
   63280 	  colNum = 0;
   63281 	  break;
   63282 	default:
   63283 	  {
   63284 	    int tok;
   63285 #if YYLSP_NEEDED
   63286 	    yylloc.first_line = yylloc.last_line = lineNum;
   63287 	    yylloc.first_column = colNum;
   63288 #endif
   63289 	    if (isalpha (c))
   63290 	      {
   63291 		i = 0;
   63292 
   63293 		do
   63294 		  {
   63295 		    buffer[i++] = c;
   63296 		    colNum += 1;
   63297 		    if (i == sizeof buffer - 1)
   63298 		      abort ();
   63299 		    c = getchar ();
   63300 		  }
   63301 		while (isalnum (c) || c == '_');
   63302 
   63303 		ungetc (c, stdin);
   63304 		buffer[i++] = 0;
   63305 		tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
   63306 		yylval = new_term (strcpy ((char *) malloc (i), buffer));
   63307 	      }
   63308 	    else
   63309 	      {
   63310 		colNum += 1;
   63311 		tok = c;
   63312 		yylval = 0;
   63313 	      }
   63314 #if YYLSP_NEEDED
   63315 	    yylloc.last_column = colNum-1;
   63316 #endif
   63317 	    return tok;
   63318 	  }
   63319 	}
   63320     }
   63321 }
   63322 
   63323 void
   63324 yyerror (ERROR_PARAMETERS)
   63325 {
   63326 #if YYPURE && YYLSP_NEEDED
   63327   /* Pacify GCC by using llocp.  */
   63328   if (! llocp)
   63329     abort ();
   63330 #endif
   63331   fprintf (stderr, "%s\n", s);
   63332 }
   63333 
   63334 static Node *
   63335 new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
   63336 {
   63337   Node *node = (Node *) malloc (sizeof (Node));
   63338   node->nterm.isNterm = 1;
   63339   node->nterm.parents = 0;
   63340   node->nterm.form = form;
   63341   node->nterm.children[0] = child0;
   63342   if (child0)
   63343     child0->nodeInfo.parents += 1;
   63344   node->nterm.children[1] = child1;
   63345   if (child1)
   63346     child1->nodeInfo.parents += 1;
   63347   node->nterm.children[2] = child2;
   63348   if (child2)
   63349     child2->nodeInfo.parents += 1;
   63350   return node;
   63351 }
   63352 
   63353 static Node *
   63354 new_term (char *text)
   63355 {
   63356   Node *node = (Node *) malloc (sizeof (Node));
   63357   node->term.isNterm = 0;
   63358   node->term.parents = 0;
   63359   node->term.text = text;
   63360   return node;
   63361 }
   63362 
   63363 static void
   63364 free_node (Node *node)
   63365 {
   63366   if (!node)
   63367     return;
   63368   node->nodeInfo.parents -= 1;
   63369   /* Free only if 0 (last parent) or -1 (no parents).  */
   63370   if (node->nodeInfo.parents > 0)
   63371     return;
   63372   if (node->nodeInfo.isNterm == 1)
   63373     {
   63374       free_node (node->nterm.children[0]);
   63375       free_node (node->nterm.children[1]);
   63376       free_node (node->nterm.children[2]);
   63377     }
   63378   else
   63379     free (node->term.text);
   63380   free (node);
   63381 }
   63382 
   63383 static char *
   63384 node_to_string (Node *node)
   63385 {
   63386   char *child0;
   63387   char *child1;
   63388   char *child2;
   63389   char *buffer;
   63390   if (!node)
   63391     {
   63392       buffer = (char *) malloc (1);
   63393       buffer[0] = 0;
   63394     }
   63395   else if (node->nodeInfo.isNterm == 1)
   63396     {
   63397       child0 = node_to_string (node->nterm.children[0]);
   63398       child1 = node_to_string (node->nterm.children[1]);
   63399       child2 = node_to_string (node->nterm.children[2]);
   63400       buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
   63401 				+ strlen (child1) + strlen (child2) + 1);
   63402       sprintf (buffer, node->nterm.form, child0, child1, child2);
   63403       free (child0);
   63404       free (child1);
   63405       free (child2);
   63406     }
   63407   else
   63408     buffer = strdup (node->term.text);
   63409   return buffer;
   63410 }
   63411 
   63412 
   63413 static YYSTYPE
   63414 stmtMerge (YYSTYPE x0, YYSTYPE x1)
   63415 {
   63416   return new_nterm ("<OR>(%s,%s)", x0, x1, 0);
   63417 }
   63418 
   63419 _ATEOF
   63420 
   63421 
   63422 
   63423 cat >test-input <<'_ATEOF'
   63424 
   63425 
   63426 z + q;
   63427 
   63428 T x;
   63429 
   63430 T x = y;
   63431 
   63432 x = y;
   63433 
   63434 T (x) + y;
   63435 
   63436 T (x);
   63437 
   63438 T (y) = z + q;
   63439 
   63440 T (y y) = z + q;
   63441 
   63442 z + q;
   63443 
   63444 @
   63445 
   63446 This is total garbage, but it should be ignored.
   63447 _ATEOF
   63448 
   63449 
   63450 $at_traceoff
   63451 echo "cxx-type.at:461: bison -o types.c types.y"
   63452 echo cxx-type.at:461 >$at_check_line_file
   63453 ( $at_traceon; bison -o types.c types.y ) >$at_stdout 2>$at_stder1
   63454 at_status=$?
   63455 grep '^ *+' $at_stder1 >&2
   63456 grep -v '^ *+' $at_stder1 >$at_stderr
   63457 at_failed=false
   63458 echo stderr:; cat $at_stderr
   63459 $at_diff $at_devnull $at_stdout || at_failed=:
   63460 case $at_status in
   63461    77) echo 77 > $at_status_file
   63462             exit 77;;
   63463    0) ;;
   63464    *) echo "cxx-type.at:461: exit code was $at_status, expected 0"
   63465       at_failed=:;;
   63466 esac
   63467 if $at_failed; then
   63468 
   63469   echo 1 > $at_status_file
   63470   exit 1
   63471 fi
   63472 
   63473 $at_traceon
   63474 
   63475 $at_traceoff
   63476 echo "cxx-type.at:461: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o types types.c \$LIBS"
   63477 echo cxx-type.at:461 >$at_check_line_file
   63478 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o types types.c $LIBS ) >$at_stdout 2>$at_stder1
   63479 at_status=$?
   63480 grep '^ *+' $at_stder1 >&2
   63481 grep -v '^ *+' $at_stder1 >$at_stderr
   63482 at_failed=false
   63483 echo stderr:; cat $at_stderr
   63484 echo stdout:; cat $at_stdout
   63485 case $at_status in
   63486    77) echo 77 > $at_status_file
   63487             exit 77;;
   63488    0) ;;
   63489    *) echo "cxx-type.at:461: exit code was $at_status, expected 0"
   63490       at_failed=:;;
   63491 esac
   63492 if $at_failed; then
   63493 
   63494   echo 1 > $at_status_file
   63495   exit 1
   63496 fi
   63497 
   63498 $at_traceon
   63499 
   63500 
   63501 
   63502 
   63503 
   63504 
   63505 
   63506 
   63507 
   63508 
   63509 
   63510 
   63511 
   63512 
   63513 
   63514 
   63515 
   63516 
   63517 
   63518 
   63519 
   63520 
   63521 
   63522 $at_traceoff
   63523 echo "cxx-type.at:463: \$PREPARSER ./types test-input"
   63524 echo cxx-type.at:463 >$at_check_line_file
   63525 ( $at_traceon; $PREPARSER ./types test-input ) >$at_stdout 2>$at_stder1
   63526 at_status=$?
   63527 grep '^ *+' $at_stder1 >&2
   63528 grep -v '^ *+' $at_stder1 >$at_stderr
   63529 at_failed=false
   63530 echo >>$at_stderr; echo "syntax error
   63531 " | $at_diff - $at_stderr || at_failed=:
   63532 echo >>$at_stdout; echo "3.0-3.5: +(z,q)
   63533 5.0-5.3: <declare>(T,x)
   63534 7.0-7.7: <init-declare>(T,x,y)
   63535 9.0-9.5: =(x,y)
   63536 11.0-11.9: +(<cast>(x,T),y)
   63537 13.0-13.5: <OR>(<declare>(T,x),<cast>(x,T))
   63538 15.0-15.13: <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
   63539 17.0-17.15: <error>
   63540 19.0-19.5: +(z,q)
   63541 " | $at_diff - $at_stdout || at_failed=:
   63542 case $at_status in
   63543    77) echo 77 > $at_status_file
   63544             exit 77;;
   63545    0) ;;
   63546    *) echo "cxx-type.at:463: exit code was $at_status, expected 0"
   63547       at_failed=:;;
   63548 esac
   63549 if $at_failed; then
   63550 
   63551   echo 1 > $at_status_file
   63552   exit 1
   63553 fi
   63554 
   63555 $at_traceon
   63556 
   63557       $at_traceoff
   63558       $at_times_p && times >$at_times_file
   63559     ) 5>&1 2>&1 | eval $at_tee_pipe
   63560     at_status=`cat $at_status_file`
   63561     ;;
   63562 
   63563   141 ) # 141. cxx-type.at:466: GLR: Verbose messages, resolve ambiguity, impure, no locations
   63564     at_setup_line='cxx-type.at:466'
   63565     at_desc='GLR: Verbose messages, resolve ambiguity, impure, no locations'
   63566     $at_quiet $ECHO_N "141: GLR: Verbose messages, resolve ambiguity, impure, no locations$ECHO_C"
   63567     at_xfail=no
   63568     (
   63569       echo "141. cxx-type.at:466: testing ..."
   63570       $at_traceon
   63571 
   63572 
   63573 
   63574 
   63575 
   63576 
   63577 # Using yacc.c?
   63578 
   63579 
   63580 
   63581 
   63582 
   63583 
   63584 
   63585 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   63586 
   63587 # yyerror always sees the locations (when activated), except if
   63588 # yacc & pure & !param.
   63589 
   63590 
   63591 # The interface is pure: either because %pure-parser, or because we
   63592 # are using the C++ parsers.
   63593 
   63594 
   63595 
   63596 
   63597 
   63598 
   63599 
   63600 
   63601 
   63602 
   63603 
   63604 
   63605 cat >types.y <<'_ATEOF'
   63606 %{
   63607 #ifdef HAVE_CONFIG_H
   63608 # include <config.h>
   63609   /* We don't need perfect functions for these tests. */
   63610 # undef malloc
   63611 # undef memcmp
   63612 # undef realloc
   63613 #endif
   63614 %}
   63615 
   63616 /* Simplified C++ Type and Expression Grammar.  */
   63617 
   63618 %error-verbose
   63619 
   63620 %{
   63621   #include <stdio.h>
   63622   union Node {
   63623     struct {
   63624       int isNterm;
   63625       int parents;
   63626     } nodeInfo;
   63627     struct {
   63628       int isNterm; /* 1 */
   63629       int parents;
   63630       char const *form;
   63631       union Node *children[3];
   63632     } nterm;
   63633     struct {
   63634       int isNterm; /* 0 */
   63635       int parents;
   63636       char *text;
   63637     } term;
   63638   };
   63639   typedef union Node Node;
   63640   static Node *new_nterm (char const *, Node *, Node *, Node *);
   63641   static Node *new_term (char *);
   63642   static void free_node (Node *);
   63643   static char *node_to_string (Node *);
   63644   #define YYSTYPE Node *
   63645  static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
   63646   #define YYINITDEPTH 10
   63647   #define YYSTACKEXPANDABLE 1
   63648   struct YYLTYPE;
   63649 #if YYPURE
   63650 # if YYLSP_NEEDED
   63651 #  define LEX_PARAMETERS YYSTYPE *lvalp, struct YYLTYPE *llocp
   63652 #  define ERROR_PARAMETERS struct YYLTYPE *llocp, char const *s
   63653 # else
   63654 #  define LEX_PARAMETERS YYSTYPE *lvalp
   63655 # endif
   63656 #endif
   63657 #ifndef LEX_PARAMETERS
   63658 # define LEX_PARAMETERS void
   63659 #endif
   63660 #ifndef ERROR_PARAMETERS
   63661 # define ERROR_PARAMETERS char const *s
   63662 #endif
   63663   int yylex (LEX_PARAMETERS);
   63664   void yyerror (ERROR_PARAMETERS);
   63665 %}
   63666 
   63667 %token TYPENAME ID
   63668 
   63669 %right '='
   63670 %left '+'
   63671 
   63672 %glr-parser
   63673 
   63674 %destructor { free_node ($$); } stmt expr decl declarator TYPENAME ID
   63675 
   63676 %%
   63677 
   63678 prog :
   63679      | prog stmt   {
   63680 			char *output;
   63681 			output = node_to_string ($2);
   63682 			printf ("%s\n", output);
   63683 			free (output);
   63684 			free_node ($2);
   63685 		   }
   63686      ;
   63687 
   63688 stmt : expr ';'  %merge <stmtMerge>	{ $$ = $1; }
   63689      | decl      %merge <stmtMerge>
   63690      | error ';'	{ $$ = new_nterm ("<error>", 0, 0, 0); }
   63691      | '@'		{ YYACCEPT; }
   63692      ;
   63693 
   63694 expr : ID
   63695      | TYPENAME '(' expr ')'
   63696 			{ $$ = new_nterm ("<cast>(%s,%s)", $3, $1, 0); }
   63697      | expr '+' expr	{ $$ = new_nterm ("+(%s,%s)", $1, $3, 0); }
   63698      | expr '=' expr    { $$ = new_nterm ("=(%s,%s)", $1, $3, 0); }
   63699      ;
   63700 
   63701 decl : TYPENAME declarator ';'
   63702 			{ $$ = new_nterm ("<declare>(%s,%s)", $1, $2, 0); }
   63703      | TYPENAME declarator '=' expr ';'
   63704 			{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
   63705 					  $2, $4); }
   63706      ;
   63707 
   63708 declarator : ID
   63709      | '(' declarator ')' { $$ = $2; }
   63710      ;
   63711 
   63712 %%
   63713 
   63714 #include <ctype.h>
   63715 #include <stdlib.h>
   63716 #include <string.h>
   63717 #include <stdarg.h>
   63718 
   63719 int
   63720 main (int argc, char **argv)
   63721 {
   63722   if (argc != 2)
   63723     abort ();
   63724   if (!freopen (argv[1], "r", stdin))
   63725     return 3;
   63726   return yyparse ();
   63727 }
   63728 
   63729 int
   63730 yylex (LEX_PARAMETERS)
   63731 {
   63732   char buffer[256];
   63733   int c;
   63734   unsigned int i;
   63735   static int lineNum = 1;
   63736   static int colNum = 0;
   63737 
   63738 #if YYPURE
   63739 # undef yylloc
   63740 # define yylloc (*llocp)
   63741 # undef yylval
   63742 # define yylval (*lvalp)
   63743 #endif
   63744 
   63745   while (1)
   63746     {
   63747       c = getchar ();
   63748       switch (c)
   63749 	{
   63750 	case EOF:
   63751 	  return 0;
   63752 	case '\t':
   63753 	  colNum = (colNum + 7) & ~7;
   63754 	  break;
   63755 	case ' ': case '\f':
   63756 	  colNum += 1;
   63757 	  break;
   63758 	case '\n':
   63759 	  lineNum += 1;
   63760 	  colNum = 0;
   63761 	  break;
   63762 	default:
   63763 	  {
   63764 	    int tok;
   63765 #if YYLSP_NEEDED
   63766 	    yylloc.first_line = yylloc.last_line = lineNum;
   63767 	    yylloc.first_column = colNum;
   63768 #endif
   63769 	    if (isalpha (c))
   63770 	      {
   63771 		i = 0;
   63772 
   63773 		do
   63774 		  {
   63775 		    buffer[i++] = c;
   63776 		    colNum += 1;
   63777 		    if (i == sizeof buffer - 1)
   63778 		      abort ();
   63779 		    c = getchar ();
   63780 		  }
   63781 		while (isalnum (c) || c == '_');
   63782 
   63783 		ungetc (c, stdin);
   63784 		buffer[i++] = 0;
   63785 		tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
   63786 		yylval = new_term (strcpy ((char *) malloc (i), buffer));
   63787 	      }
   63788 	    else
   63789 	      {
   63790 		colNum += 1;
   63791 		tok = c;
   63792 		yylval = 0;
   63793 	      }
   63794 #if YYLSP_NEEDED
   63795 	    yylloc.last_column = colNum-1;
   63796 #endif
   63797 	    return tok;
   63798 	  }
   63799 	}
   63800     }
   63801 }
   63802 
   63803 void
   63804 yyerror (ERROR_PARAMETERS)
   63805 {
   63806 #if YYPURE && YYLSP_NEEDED
   63807   /* Pacify GCC by using llocp.  */
   63808   if (! llocp)
   63809     abort ();
   63810 #endif
   63811   fprintf (stderr, "%s\n", s);
   63812 }
   63813 
   63814 static Node *
   63815 new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
   63816 {
   63817   Node *node = (Node *) malloc (sizeof (Node));
   63818   node->nterm.isNterm = 1;
   63819   node->nterm.parents = 0;
   63820   node->nterm.form = form;
   63821   node->nterm.children[0] = child0;
   63822   if (child0)
   63823     child0->nodeInfo.parents += 1;
   63824   node->nterm.children[1] = child1;
   63825   if (child1)
   63826     child1->nodeInfo.parents += 1;
   63827   node->nterm.children[2] = child2;
   63828   if (child2)
   63829     child2->nodeInfo.parents += 1;
   63830   return node;
   63831 }
   63832 
   63833 static Node *
   63834 new_term (char *text)
   63835 {
   63836   Node *node = (Node *) malloc (sizeof (Node));
   63837   node->term.isNterm = 0;
   63838   node->term.parents = 0;
   63839   node->term.text = text;
   63840   return node;
   63841 }
   63842 
   63843 static void
   63844 free_node (Node *node)
   63845 {
   63846   if (!node)
   63847     return;
   63848   node->nodeInfo.parents -= 1;
   63849   /* Free only if 0 (last parent) or -1 (no parents).  */
   63850   if (node->nodeInfo.parents > 0)
   63851     return;
   63852   if (node->nodeInfo.isNterm == 1)
   63853     {
   63854       free_node (node->nterm.children[0]);
   63855       free_node (node->nterm.children[1]);
   63856       free_node (node->nterm.children[2]);
   63857     }
   63858   else
   63859     free (node->term.text);
   63860   free (node);
   63861 }
   63862 
   63863 static char *
   63864 node_to_string (Node *node)
   63865 {
   63866   char *child0;
   63867   char *child1;
   63868   char *child2;
   63869   char *buffer;
   63870   if (!node)
   63871     {
   63872       buffer = (char *) malloc (1);
   63873       buffer[0] = 0;
   63874     }
   63875   else if (node->nodeInfo.isNterm == 1)
   63876     {
   63877       child0 = node_to_string (node->nterm.children[0]);
   63878       child1 = node_to_string (node->nterm.children[1]);
   63879       child2 = node_to_string (node->nterm.children[2]);
   63880       buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
   63881 				+ strlen (child1) + strlen (child2) + 1);
   63882       sprintf (buffer, node->nterm.form, child0, child1, child2);
   63883       free (child0);
   63884       free (child1);
   63885       free (child2);
   63886     }
   63887   else
   63888     buffer = strdup (node->term.text);
   63889   return buffer;
   63890 }
   63891 
   63892 
   63893 static YYSTYPE
   63894 stmtMerge (YYSTYPE x0, YYSTYPE x1)
   63895 {
   63896   return new_nterm ("<OR>(%s,%s)", x0, x1, 0);
   63897 }
   63898 
   63899 _ATEOF
   63900 
   63901 
   63902 
   63903 cat >test-input <<'_ATEOF'
   63904 
   63905 
   63906 z + q;
   63907 
   63908 T x;
   63909 
   63910 T x = y;
   63911 
   63912 x = y;
   63913 
   63914 T (x) + y;
   63915 
   63916 T (x);
   63917 
   63918 T (y) = z + q;
   63919 
   63920 T (y y) = z + q;
   63921 
   63922 z + q;
   63923 
   63924 @
   63925 
   63926 This is total garbage, but it should be ignored.
   63927 _ATEOF
   63928 
   63929 
   63930 $at_traceoff
   63931 echo "cxx-type.at:468: bison -o types.c types.y"
   63932 echo cxx-type.at:468 >$at_check_line_file
   63933 ( $at_traceon; bison -o types.c types.y ) >$at_stdout 2>$at_stder1
   63934 at_status=$?
   63935 grep '^ *+' $at_stder1 >&2
   63936 grep -v '^ *+' $at_stder1 >$at_stderr
   63937 at_failed=false
   63938 echo stderr:; cat $at_stderr
   63939 $at_diff $at_devnull $at_stdout || at_failed=:
   63940 case $at_status in
   63941    77) echo 77 > $at_status_file
   63942             exit 77;;
   63943    0) ;;
   63944    *) echo "cxx-type.at:468: exit code was $at_status, expected 0"
   63945       at_failed=:;;
   63946 esac
   63947 if $at_failed; then
   63948 
   63949   echo 1 > $at_status_file
   63950   exit 1
   63951 fi
   63952 
   63953 $at_traceon
   63954 
   63955 $at_traceoff
   63956 echo "cxx-type.at:468: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o types types.c \$LIBS"
   63957 echo cxx-type.at:468 >$at_check_line_file
   63958 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o types types.c $LIBS ) >$at_stdout 2>$at_stder1
   63959 at_status=$?
   63960 grep '^ *+' $at_stder1 >&2
   63961 grep -v '^ *+' $at_stder1 >$at_stderr
   63962 at_failed=false
   63963 echo stderr:; cat $at_stderr
   63964 echo stdout:; cat $at_stdout
   63965 case $at_status in
   63966    77) echo 77 > $at_status_file
   63967             exit 77;;
   63968    0) ;;
   63969    *) echo "cxx-type.at:468: exit code was $at_status, expected 0"
   63970       at_failed=:;;
   63971 esac
   63972 if $at_failed; then
   63973 
   63974   echo 1 > $at_status_file
   63975   exit 1
   63976 fi
   63977 
   63978 $at_traceon
   63979 
   63980 
   63981 
   63982 
   63983 
   63984 
   63985 
   63986 
   63987 
   63988 
   63989 
   63990 
   63991 
   63992 
   63993 
   63994 
   63995 
   63996 
   63997 
   63998 
   63999 
   64000 
   64001 
   64002 $at_traceoff
   64003 echo "cxx-type.at:470: \$PREPARSER ./types test-input"
   64004 echo cxx-type.at:470 >$at_check_line_file
   64005 ( $at_traceon; $PREPARSER ./types test-input ) >$at_stdout 2>$at_stder1
   64006 at_status=$?
   64007 grep '^ *+' $at_stder1 >&2
   64008 grep -v '^ *+' $at_stder1 >$at_stderr
   64009 at_failed=false
   64010 echo >>$at_stderr; echo "syntax error, unexpected ID, expecting '=' or '+' or ')'
   64011 " | $at_diff - $at_stderr || at_failed=:
   64012 echo >>$at_stdout; echo "+(z,q)
   64013 <declare>(T,x)
   64014 <init-declare>(T,x,y)
   64015 =(x,y)
   64016 +(<cast>(x,T),y)
   64017 <OR>(<declare>(T,x),<cast>(x,T))
   64018 <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
   64019 <error>
   64020 +(z,q)
   64021 " | $at_diff - $at_stdout || at_failed=:
   64022 case $at_status in
   64023    77) echo 77 > $at_status_file
   64024             exit 77;;
   64025    0) ;;
   64026    *) echo "cxx-type.at:470: exit code was $at_status, expected 0"
   64027       at_failed=:;;
   64028 esac
   64029 if $at_failed; then
   64030 
   64031   echo 1 > $at_status_file
   64032   exit 1
   64033 fi
   64034 
   64035 $at_traceon
   64036 
   64037       $at_traceoff
   64038       $at_times_p && times >$at_times_file
   64039     ) 5>&1 2>&1 | eval $at_tee_pipe
   64040     at_status=`cat $at_status_file`
   64041     ;;
   64042 
   64043 
   64044   banner-18 ) # Banner 18. glr-regression.at:19
   64045     cat <<\_ATEOF
   64046 
   64047 GLR Regression Tests
   64048 
   64049 _ATEOF
   64050     ;;
   64051 
   64052   142 ) # 142. glr-regression.at:25: Badly Collapsed GLR States
   64053     at_setup_line='glr-regression.at:25'
   64054     at_desc='Badly Collapsed GLR States'
   64055     $at_quiet $ECHO_N "142: Badly Collapsed GLR States                   $ECHO_C"
   64056     at_xfail=no
   64057     (
   64058       echo "142. glr-regression.at:25: testing ..."
   64059       $at_traceon
   64060 
   64061 
   64062 cat >glr-regr1.y <<'_ATEOF'
   64063 %{
   64064 #ifdef HAVE_CONFIG_H
   64065 # include <config.h>
   64066   /* We don't need perfect functions for these tests. */
   64067 # undef malloc
   64068 # undef memcmp
   64069 # undef realloc
   64070 #endif
   64071 %}
   64072 
   64073 /* Regression Test: Improper state compression */
   64074 /* Reported by Scott McPeak */
   64075 
   64076 %{
   64077 #include <stdio.h>
   64078 
   64079 #define YYSTYPE int
   64080 static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
   64081 int yylex (void);
   64082 void yyerror (char const *msg);
   64083 %}
   64084 
   64085 
   64086 %glr-parser
   64087 
   64088 
   64089 /* -------- productions ------ */
   64090 %%
   64091 
   64092 StartSymbol: E  { $$=0; }                   %merge <exprMerge>
   64093            ;
   64094 
   64095 E: E 'P' E { $$=1; printf("E -> E 'P' E\n"); }  %merge <exprMerge>
   64096  | 'B'     { $$=2; printf("E -> 'B'\n"); }      %merge <exprMerge>
   64097  ;
   64098 
   64099 
   64100 
   64101 /* ---------- C code ----------- */
   64102 %%
   64103 
   64104 static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1)
   64105 {
   64106   (void) x0;
   64107   (void) x1;
   64108   printf ("<OR>\n");
   64109   return 0;
   64110 }
   64111 
   64112 int
   64113 main (void)
   64114 {
   64115   return yyparse ();
   64116 }
   64117 
   64118 void
   64119 yyerror (char const *msg)
   64120 {
   64121   fprintf (stderr, "%s\n", msg);
   64122 }
   64123 
   64124 
   64125 int
   64126 yylex (void)
   64127 {
   64128   for (;;)
   64129     {
   64130       int ch = getchar ();
   64131       if (ch == EOF)
   64132 	return 0;
   64133       else if (ch == 'B' || ch == 'P')
   64134 	return ch;
   64135     }
   64136 }
   64137 _ATEOF
   64138 
   64139 
   64140 
   64141 $at_traceoff
   64142 echo "glr-regression.at:96: bison -o glr-regr1.c glr-regr1.y"
   64143 echo glr-regression.at:96 >$at_check_line_file
   64144 ( $at_traceon; bison -o glr-regr1.c glr-regr1.y ) >$at_stdout 2>$at_stder1
   64145 at_status=$?
   64146 grep '^ *+' $at_stder1 >&2
   64147 grep -v '^ *+' $at_stder1 >$at_stderr
   64148 at_failed=false
   64149 echo >>$at_stderr; echo "glr-regr1.y: conflicts: 1 shift/reduce
   64150 " | $at_diff - $at_stderr || at_failed=:
   64151 $at_diff $at_devnull $at_stdout || at_failed=:
   64152 case $at_status in
   64153    77) echo 77 > $at_status_file
   64154             exit 77;;
   64155    0) ;;
   64156    *) echo "glr-regression.at:96: exit code was $at_status, expected 0"
   64157       at_failed=:;;
   64158 esac
   64159 if $at_failed; then
   64160 
   64161   echo 1 > $at_status_file
   64162   exit 1
   64163 fi
   64164 
   64165 $at_traceon
   64166 
   64167 $at_traceoff
   64168 echo "glr-regression.at:97: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr1 glr-regr1.c \$LIBS"
   64169 echo glr-regression.at:97 >$at_check_line_file
   64170 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr1 glr-regr1.c $LIBS ) >$at_stdout 2>$at_stder1
   64171 at_status=$?
   64172 grep '^ *+' $at_stder1 >&2
   64173 grep -v '^ *+' $at_stder1 >$at_stderr
   64174 at_failed=false
   64175 echo stderr:; cat $at_stderr
   64176 echo stdout:; cat $at_stdout
   64177 case $at_status in
   64178    77) echo 77 > $at_status_file
   64179             exit 77;;
   64180    0) ;;
   64181    *) echo "glr-regression.at:97: exit code was $at_status, expected 0"
   64182       at_failed=:;;
   64183 esac
   64184 if $at_failed; then
   64185 
   64186   echo 1 > $at_status_file
   64187   exit 1
   64188 fi
   64189 
   64190 $at_traceon
   64191 
   64192 $at_traceoff
   64193 echo "glr-regression.at:108: echo BPBPB | ./glr-regr1"
   64194 echo glr-regression.at:108 >$at_check_line_file
   64195 ( $at_traceon; echo BPBPB | ./glr-regr1 ) >$at_stdout 2>$at_stder1
   64196 at_status=$?
   64197 grep '^ *+' $at_stder1 >&2
   64198 grep -v '^ *+' $at_stder1 >$at_stderr
   64199 at_failed=false
   64200 $at_diff $at_devnull $at_stderr || at_failed=:
   64201 echo >>$at_stdout; echo "E -> 'B'
   64202 E -> 'B'
   64203 E -> E 'P' E
   64204 E -> 'B'
   64205 E -> E 'P' E
   64206 E -> 'B'
   64207 E -> E 'P' E
   64208 E -> E 'P' E
   64209 <OR>
   64210 " | $at_diff - $at_stdout || at_failed=:
   64211 case $at_status in
   64212    77) echo 77 > $at_status_file
   64213             exit 77;;
   64214    0) ;;
   64215    *) echo "glr-regression.at:108: exit code was $at_status, expected 0"
   64216       at_failed=:;;
   64217 esac
   64218 if $at_failed; then
   64219 
   64220   echo 1 > $at_status_file
   64221   exit 1
   64222 fi
   64223 
   64224 $at_traceon
   64225 
   64226 
   64227       $at_traceoff
   64228       $at_times_p && times >$at_times_file
   64229     ) 5>&1 2>&1 | eval $at_tee_pipe
   64230     at_status=`cat $at_status_file`
   64231     ;;
   64232 
   64233   143 ) # 143. glr-regression.at:116: Improper handling of embedded actions and dollar(-N) in GLR parsers
   64234     at_setup_line='glr-regression.at:116'
   64235     at_desc='Improper handling of embedded actions and dollar(-N) in GLR parsers'
   64236     $at_quiet $ECHO_N "143: Improper handling of embedded actions and dollar(-N) in GLR parsers$ECHO_C"
   64237     at_xfail=no
   64238     (
   64239       echo "143. glr-regression.at:116: testing ..."
   64240       $at_traceon
   64241 
   64242 
   64243 cat >glr-regr2a.y <<'_ATEOF'
   64244 %{
   64245 #ifdef HAVE_CONFIG_H
   64246 # include <config.h>
   64247   /* We don't need perfect functions for these tests. */
   64248 # undef malloc
   64249 # undef memcmp
   64250 # undef realloc
   64251 #endif
   64252 %}
   64253 
   64254 /* Regression Test: Improper handling of embedded actions and $-N  */
   64255 /* Reported by S. Eken */
   64256 
   64257 %{
   64258   #define YYSTYPE char *
   64259 
   64260   #include <ctype.h>
   64261   #include <stdio.h>
   64262   #include <stdlib.h>
   64263   #include <string.h>
   64264   int yylex (void);
   64265   void yyerror (char const *);
   64266 %}
   64267 
   64268 %glr-parser
   64269 
   64270 %%
   64271 
   64272 command:
   64273     's' var 't'
   64274        { printf ("Variable: '%s'\n", $2); }
   64275     'v' 'x' 'q'
   64276        { free ($2); }
   64277   | 's' var_list 't' 'e'
   64278        { printf ("Varlist: '%s'\n", $2); free ($2); }
   64279   | 's' var 't' var_printer 'x'
   64280        { free ($2); }
   64281   ;
   64282 
   64283 var:
   64284   'V'
   64285      { $$ = $1; }
   64286   ;
   64287 
   64288 var_list:
   64289   var
   64290     { $$ = $1; }
   64291   | var ',' var_list
   64292     {
   64293       char *s = (char *) realloc ($1, strlen ($1) + 1 + strlen ($3) + 1);
   64294       strcat (s, ",");
   64295       strcat (s, $3);
   64296       free ($3);
   64297       $$ = s;
   64298     }
   64299   ;
   64300 
   64301 var_printer: 'v'
   64302    { printf ("Variable: '%s'\n", $-1); }
   64303 
   64304 %%
   64305 
   64306 FILE *input = NULL;
   64307 
   64308 int
   64309 yylex (void)
   64310 {
   64311   char buf[50];
   64312   char *s;
   64313   switch (fscanf (input, " %1[a-z,]", buf)) {
   64314   case 1:
   64315     return buf[0];
   64316   case EOF:
   64317     return 0;
   64318   default:
   64319     break;
   64320   }
   64321   if (fscanf (input, "%49s", buf) != 1)
   64322     return 0;
   64323   if (sizeof buf - 1 <= strlen (buf))
   64324     abort ();
   64325   s = (char *) malloc (strlen (buf) + 1);
   64326   strcpy (s, buf);
   64327   yylval = s;
   64328   return 'V';
   64329 }
   64330 
   64331 void
   64332 yyerror (char const *s)
   64333 { printf ("%s\n", s);
   64334 }
   64335 
   64336 int
   64337 main (int argc, char **argv)
   64338 {
   64339   input = stdin;
   64340   if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
   64341   return yyparse ();
   64342 }
   64343 _ATEOF
   64344 
   64345 
   64346 
   64347 $at_traceoff
   64348 echo "glr-regression.at:212: bison -o glr-regr2a.c glr-regr2a.y"
   64349 echo glr-regression.at:212 >$at_check_line_file
   64350 ( $at_traceon; bison -o glr-regr2a.c glr-regr2a.y ) >$at_stdout 2>$at_stder1
   64351 at_status=$?
   64352 grep '^ *+' $at_stder1 >&2
   64353 grep -v '^ *+' $at_stder1 >$at_stderr
   64354 at_failed=false
   64355 echo >>$at_stderr; echo "glr-regr2a.y: conflicts: 2 shift/reduce
   64356 " | $at_diff - $at_stderr || at_failed=:
   64357 $at_diff $at_devnull $at_stdout || at_failed=:
   64358 case $at_status in
   64359    77) echo 77 > $at_status_file
   64360             exit 77;;
   64361    0) ;;
   64362    *) echo "glr-regression.at:212: exit code was $at_status, expected 0"
   64363       at_failed=:;;
   64364 esac
   64365 if $at_failed; then
   64366 
   64367   echo 1 > $at_status_file
   64368   exit 1
   64369 fi
   64370 
   64371 $at_traceon
   64372 
   64373 $at_traceoff
   64374 echo "glr-regression.at:213: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr2a glr-regr2a.c \$LIBS"
   64375 echo glr-regression.at:213 >$at_check_line_file
   64376 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr2a glr-regr2a.c $LIBS ) >$at_stdout 2>$at_stder1
   64377 at_status=$?
   64378 grep '^ *+' $at_stder1 >&2
   64379 grep -v '^ *+' $at_stder1 >$at_stderr
   64380 at_failed=false
   64381 echo stderr:; cat $at_stderr
   64382 echo stdout:; cat $at_stdout
   64383 case $at_status in
   64384    77) echo 77 > $at_status_file
   64385             exit 77;;
   64386    0) ;;
   64387    *) echo "glr-regression.at:213: exit code was $at_status, expected 0"
   64388       at_failed=:;;
   64389 esac
   64390 if $at_failed; then
   64391 
   64392   echo 1 > $at_status_file
   64393   exit 1
   64394 fi
   64395 
   64396 $at_traceon
   64397 
   64398 
   64399 $at_traceoff
   64400 echo "glr-regression.at:217: echo s VARIABLE_1 t v x q | ./glr-regr2a"
   64401 echo glr-regression.at:217 >$at_check_line_file
   64402 ( $at_traceon; echo s VARIABLE_1 t v x q | ./glr-regr2a ) >$at_stdout 2>$at_stder1
   64403 at_status=$?
   64404 grep '^ *+' $at_stder1 >&2
   64405 grep -v '^ *+' $at_stder1 >$at_stderr
   64406 at_failed=false
   64407 $at_diff $at_devnull $at_stderr || at_failed=:
   64408 echo >>$at_stdout; echo "Variable: 'VARIABLE_1'
   64409 " | $at_diff - $at_stdout || at_failed=:
   64410 case $at_status in
   64411    77) echo 77 > $at_status_file
   64412             exit 77;;
   64413    0) ;;
   64414    *) echo "glr-regression.at:217: exit code was $at_status, expected 0"
   64415       at_failed=:;;
   64416 esac
   64417 if $at_failed; then
   64418 
   64419   echo 1 > $at_status_file
   64420   exit 1
   64421 fi
   64422 
   64423 $at_traceon
   64424 
   64425 $at_traceoff
   64426 echo "glr-regression.at:220: echo s VARIABLE_1 , ANOTHER_VARIABLE_2 t e | ./glr-regr2a"
   64427 echo glr-regression.at:220 >$at_check_line_file
   64428 ( $at_traceon; echo s VARIABLE_1 , ANOTHER_VARIABLE_2 t e | ./glr-regr2a ) >$at_stdout 2>$at_stder1
   64429 at_status=$?
   64430 grep '^ *+' $at_stder1 >&2
   64431 grep -v '^ *+' $at_stder1 >$at_stderr
   64432 at_failed=false
   64433 $at_diff $at_devnull $at_stderr || at_failed=:
   64434 echo >>$at_stdout; echo "Varlist: 'VARIABLE_1,ANOTHER_VARIABLE_2'
   64435 " | $at_diff - $at_stdout || at_failed=:
   64436 case $at_status in
   64437    77) echo 77 > $at_status_file
   64438             exit 77;;
   64439    0) ;;
   64440    *) echo "glr-regression.at:220: exit code was $at_status, expected 0"
   64441       at_failed=:;;
   64442 esac
   64443 if $at_failed; then
   64444 
   64445   echo 1 > $at_status_file
   64446   exit 1
   64447 fi
   64448 
   64449 $at_traceon
   64450 
   64451 $at_traceoff
   64452 echo "glr-regression.at:223: echo s VARIABLE_3 t v x | ./glr-regr2a"
   64453 echo glr-regression.at:223 >$at_check_line_file
   64454 ( $at_traceon; echo s VARIABLE_3 t v x | ./glr-regr2a ) >$at_stdout 2>$at_stder1
   64455 at_status=$?
   64456 grep '^ *+' $at_stder1 >&2
   64457 grep -v '^ *+' $at_stder1 >$at_stderr
   64458 at_failed=false
   64459 $at_diff $at_devnull $at_stderr || at_failed=:
   64460 echo >>$at_stdout; echo "Variable: 'VARIABLE_3'
   64461 " | $at_diff - $at_stdout || at_failed=:
   64462 case $at_status in
   64463    77) echo 77 > $at_status_file
   64464             exit 77;;
   64465    0) ;;
   64466    *) echo "glr-regression.at:223: exit code was $at_status, expected 0"
   64467       at_failed=:;;
   64468 esac
   64469 if $at_failed; then
   64470 
   64471   echo 1 > $at_status_file
   64472   exit 1
   64473 fi
   64474 
   64475 $at_traceon
   64476 
   64477 
   64478 
   64479       $at_traceoff
   64480       $at_times_p && times >$at_times_file
   64481     ) 5>&1 2>&1 | eval $at_tee_pipe
   64482     at_status=`cat $at_status_file`
   64483     ;;
   64484 
   64485   144 ) # 144. glr-regression.at:232: Improper merging of GLR delayed action sets
   64486     at_setup_line='glr-regression.at:232'
   64487     at_desc='Improper merging of GLR delayed action sets'
   64488     $at_quiet $ECHO_N "144: Improper merging of GLR delayed action sets  $ECHO_C"
   64489     at_xfail=no
   64490     (
   64491       echo "144. glr-regression.at:232: testing ..."
   64492       $at_traceon
   64493 
   64494 
   64495 cat >glr-regr3.y <<'_ATEOF'
   64496 %{
   64497 #ifdef HAVE_CONFIG_H
   64498 # include <config.h>
   64499   /* We don't need perfect functions for these tests. */
   64500 # undef malloc
   64501 # undef memcmp
   64502 # undef realloc
   64503 #endif
   64504 %}
   64505 
   64506 /* Regression Test: Improper merging of GLR delayed action sets.  */
   64507 /* Reported by M. Rosien */
   64508 
   64509 %{
   64510 #include <stdio.h>
   64511 #include <stdarg.h>
   64512 
   64513 static int MergeRule (int x0, int x1);
   64514 static void yyerror (char const * s);
   64515 int yylex (void);
   64516 
   64517 #define RULE(x) (1 << (x))
   64518 
   64519 %}
   64520 
   64521 %glr-parser
   64522 
   64523 %token BAD_CHAR
   64524 %token P1 P2 T1 T2 T3 T4 O1 O2
   64525 
   64526 %%
   64527 
   64528 S : P1 T4 O2 NT6 P2  { printf ("Result: %x\n", $4); }
   64529 ;
   64530 
   64531 NT1 : P1 T1 O1 T2 P2 { $$ = RULE(2); }  %merge<MergeRule>
   64532 ;
   64533 
   64534 NT2 : NT1             { $$ = RULE(3); } %merge<MergeRule>
   64535     | P1 NT1 O1 T3 P2 { $$ = RULE(4); } %merge<MergeRule>
   64536 ;
   64537 
   64538 NT3 : T3              { $$ = RULE(5); } %merge<MergeRule>
   64539     | P1 NT1 O1 T3 P2 { $$ = RULE(6); } %merge<MergeRule>
   64540 ;
   64541 
   64542 NT4 : NT3              { $$ = RULE(7); } %merge<MergeRule>
   64543     | NT2              { $$ = RULE(8); } %merge<MergeRule>
   64544     | P1 NT2 O1 NT3 P2 { $$ = RULE(9); } %merge<MergeRule>
   64545 ;
   64546 
   64547 NT5 : NT4              { $$ = RULE(10); } %merge<MergeRule>
   64548 ;
   64549 
   64550 NT6 : P1 NT1 O1 T3 P2  { $$ = RULE(11) | $2; } %merge<MergeRule>
   64551     | NT5              { $$ = RULE(12) | $1; } %merge<MergeRule>
   64552 ;
   64553 
   64554 %%
   64555 
   64556 static int MergeRule (int x0, int x1) {
   64557   return x0 | x1;
   64558 }
   64559 
   64560 static void yyerror(char const * s) {
   64561   fprintf(stderr,"error: %s\n",s);
   64562 }
   64563 
   64564 FILE *input = NULL;
   64565 
   64566 int P[] = { P1, P2 };
   64567 int O[] = { O1, O2 };
   64568 int T[] = { T1, T2, T3, T4 };
   64569 
   64570 int yylex (void)
   64571 {
   64572   char inp[3];
   64573   if (fscanf (input, "%2s", inp) == EOF)
   64574     return 0;
   64575   switch (inp[0])
   64576     {
   64577     case 'p': return P[inp[1] - '1'];
   64578     case 't': return T[inp[1] - '1'];
   64579     case 'o': return O[inp[1] - '1'];
   64580     }
   64581   return BAD_CHAR;
   64582 }
   64583 
   64584 int main(int argc, char* argv[]) {
   64585   input = stdin;
   64586   if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
   64587   return yyparse ();
   64588 }
   64589 _ATEOF
   64590 
   64591 
   64592 
   64593 $at_traceoff
   64594 echo "glr-regression.at:322: bison -o glr-regr3.c glr-regr3.y"
   64595 echo glr-regression.at:322 >$at_check_line_file
   64596 ( $at_traceon; bison -o glr-regr3.c glr-regr3.y ) >$at_stdout 2>$at_stder1
   64597 at_status=$?
   64598 grep '^ *+' $at_stder1 >&2
   64599 grep -v '^ *+' $at_stder1 >$at_stderr
   64600 at_failed=false
   64601 echo >>$at_stderr; echo "glr-regr3.y: conflicts: 1 shift/reduce, 1 reduce/reduce
   64602 " | $at_diff - $at_stderr || at_failed=:
   64603 $at_diff $at_devnull $at_stdout || at_failed=:
   64604 case $at_status in
   64605    77) echo 77 > $at_status_file
   64606             exit 77;;
   64607    0) ;;
   64608    *) echo "glr-regression.at:322: exit code was $at_status, expected 0"
   64609       at_failed=:;;
   64610 esac
   64611 if $at_failed; then
   64612 
   64613   echo 1 > $at_status_file
   64614   exit 1
   64615 fi
   64616 
   64617 $at_traceon
   64618 
   64619 $at_traceoff
   64620 echo "glr-regression.at:323: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr3 glr-regr3.c \$LIBS"
   64621 echo glr-regression.at:323 >$at_check_line_file
   64622 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr3 glr-regr3.c $LIBS ) >$at_stdout 2>$at_stder1
   64623 at_status=$?
   64624 grep '^ *+' $at_stder1 >&2
   64625 grep -v '^ *+' $at_stder1 >$at_stderr
   64626 at_failed=false
   64627 echo stderr:; cat $at_stderr
   64628 echo stdout:; cat $at_stdout
   64629 case $at_status in
   64630    77) echo 77 > $at_status_file
   64631             exit 77;;
   64632    0) ;;
   64633    *) echo "glr-regression.at:323: exit code was $at_status, expected 0"
   64634       at_failed=:;;
   64635 esac
   64636 if $at_failed; then
   64637 
   64638   echo 1 > $at_status_file
   64639   exit 1
   64640 fi
   64641 
   64642 $at_traceon
   64643 
   64644 
   64645 $at_traceoff
   64646 echo "glr-regression.at:327: echo p1 t4 o2 p1 p1 t1 o1 t2 p2 o1 t3 p2 p2 | ./glr-regr3"
   64647 echo glr-regression.at:327 >$at_check_line_file
   64648 ( $at_traceon; echo p1 t4 o2 p1 p1 t1 o1 t2 p2 o1 t3 p2 p2 | ./glr-regr3 ) >$at_stdout 2>$at_stder1
   64649 at_status=$?
   64650 grep '^ *+' $at_stder1 >&2
   64651 grep -v '^ *+' $at_stder1 >$at_stderr
   64652 at_failed=false
   64653 $at_diff $at_devnull $at_stderr || at_failed=:
   64654 echo >>$at_stdout; echo "Result: 1c04
   64655 " | $at_diff - $at_stdout || at_failed=:
   64656 case $at_status in
   64657    77) echo 77 > $at_status_file
   64658             exit 77;;
   64659    0) ;;
   64660    *) echo "glr-regression.at:327: exit code was $at_status, expected 0"
   64661       at_failed=:;;
   64662 esac
   64663 if $at_failed; then
   64664 
   64665   echo 1 > $at_status_file
   64666   exit 1
   64667 fi
   64668 
   64669 $at_traceon
   64670 
   64671 
   64672       $at_traceoff
   64673       $at_times_p && times >$at_times_file
   64674     ) 5>&1 2>&1 | eval $at_tee_pipe
   64675     at_status=`cat $at_status_file`
   64676     ;;
   64677 
   64678   145 ) # 145. glr-regression.at:337: Duplicate representation of merged trees
   64679     at_setup_line='glr-regression.at:337'
   64680     at_desc='Duplicate representation of merged trees'
   64681     $at_quiet $ECHO_N "145: Duplicate representation of merged trees     $ECHO_C"
   64682     at_xfail=no
   64683     (
   64684       echo "145. glr-regression.at:337: testing ..."
   64685       $at_traceon
   64686 
   64687 
   64688 cat >glr-regr4.y <<'_ATEOF'
   64689 %{
   64690 #ifdef HAVE_CONFIG_H
   64691 # include <config.h>
   64692   /* We don't need perfect functions for these tests. */
   64693 # undef malloc
   64694 # undef memcmp
   64695 # undef realloc
   64696 #endif
   64697 %}
   64698 
   64699 
   64700 %union { char *ptr; }
   64701 %type <ptr> S A A1 A2 B
   64702 %glr-parser
   64703 
   64704 %{
   64705   #include <stdio.h>
   64706   #include <stdlib.h>
   64707   #include <string.h>
   64708   static char *merge (YYSTYPE, YYSTYPE);
   64709   static char *make_value (char const *, char const *);
   64710   static void yyerror (char const *);
   64711   static int yylex (void);
   64712 %}
   64713 
   64714 %%
   64715 
   64716 tree: S { printf ("%s\n", $1); } ;
   64717 
   64718 S:
   64719   A   %merge<merge> { $$ = make_value ("S", $1); }
   64720   | B %merge<merge> { $$ = make_value ("S", $1); }
   64721   ;
   64722 
   64723 A:
   64724   A1   %merge<merge> { $$ = make_value ("A", $1); }
   64725   | A2 %merge<merge> { $$ = make_value ("A", $1); }
   64726   ;
   64727 
   64728 A1: 'a' { $$ = make_value ("A1", "'a'"); } ;
   64729 A2: 'a' { $$ = make_value ("A2", "'a'"); } ;
   64730 B:  'a' { $$ = make_value ("B", "'a'");  } ;
   64731 
   64732 %%
   64733 
   64734 static int
   64735 yylex (void)
   64736 {
   64737   static char const *input = "a";
   64738   return *input++;
   64739 }
   64740 
   64741 int
   64742 main (void)
   64743 {
   64744   return yyparse ();
   64745 }
   64746 
   64747 static char *
   64748 make_value (char const *parent, char const *child)
   64749 {
   64750   char const format[] = "%s <- %s";
   64751   char *value =
   64752     (char *) malloc (strlen (parent) + strlen (child) + sizeof format);
   64753   sprintf (value, format, parent, child);
   64754   return value;
   64755 }
   64756 
   64757 static char *
   64758 merge (YYSTYPE s1, YYSTYPE s2)
   64759 {
   64760   char const format[] = "merge{ %s and %s }";
   64761   char *value =
   64762     (char *) malloc (strlen (s1.ptr) + strlen (s2.ptr) + sizeof format);
   64763   sprintf (value, format, s1.ptr, s2.ptr);
   64764   return value;
   64765 }
   64766 
   64767 static void
   64768 yyerror (char const *msg)
   64769 {
   64770   fprintf (stderr, "%s\n", msg);
   64771 }
   64772 _ATEOF
   64773 
   64774 
   64775 
   64776 $at_traceoff
   64777 echo "glr-regression.at:417: bison -o glr-regr4.c glr-regr4.y"
   64778 echo glr-regression.at:417 >$at_check_line_file
   64779 ( $at_traceon; bison -o glr-regr4.c glr-regr4.y ) >$at_stdout 2>$at_stder1
   64780 at_status=$?
   64781 grep '^ *+' $at_stder1 >&2
   64782 grep -v '^ *+' $at_stder1 >$at_stderr
   64783 at_failed=false
   64784 echo >>$at_stderr; echo "glr-regr4.y: conflicts: 1 reduce/reduce
   64785 " | $at_diff - $at_stderr || at_failed=:
   64786 $at_diff $at_devnull $at_stdout || at_failed=:
   64787 case $at_status in
   64788    77) echo 77 > $at_status_file
   64789             exit 77;;
   64790    0) ;;
   64791    *) echo "glr-regression.at:417: exit code was $at_status, expected 0"
   64792       at_failed=:;;
   64793 esac
   64794 if $at_failed; then
   64795 
   64796   echo 1 > $at_status_file
   64797   exit 1
   64798 fi
   64799 
   64800 $at_traceon
   64801 
   64802 $at_traceoff
   64803 echo "glr-regression.at:418: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr4 glr-regr4.c \$LIBS"
   64804 echo glr-regression.at:418 >$at_check_line_file
   64805 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr4 glr-regr4.c $LIBS ) >$at_stdout 2>$at_stder1
   64806 at_status=$?
   64807 grep '^ *+' $at_stder1 >&2
   64808 grep -v '^ *+' $at_stder1 >$at_stderr
   64809 at_failed=false
   64810 echo stderr:; cat $at_stderr
   64811 echo stdout:; cat $at_stdout
   64812 case $at_status in
   64813    77) echo 77 > $at_status_file
   64814             exit 77;;
   64815    0) ;;
   64816    *) echo "glr-regression.at:418: exit code was $at_status, expected 0"
   64817       at_failed=:;;
   64818 esac
   64819 if $at_failed; then
   64820 
   64821   echo 1 > $at_status_file
   64822   exit 1
   64823 fi
   64824 
   64825 $at_traceon
   64826 
   64827 
   64828 $at_traceoff
   64829 echo "glr-regression.at:422: ./glr-regr4"
   64830 echo glr-regression.at:422 >$at_check_line_file
   64831 ( $at_traceon; ./glr-regr4 ) >$at_stdout 2>$at_stder1
   64832 at_status=$?
   64833 grep '^ *+' $at_stder1 >&2
   64834 grep -v '^ *+' $at_stder1 >$at_stderr
   64835 at_failed=false
   64836 $at_diff $at_devnull $at_stderr || at_failed=:
   64837 echo >>$at_stdout; echo "merge{ S <- merge{ A <- A1 <- 'a' and A <- A2 <- 'a' } and S <- B <- 'a' }
   64838 " | $at_diff - $at_stdout || at_failed=:
   64839 case $at_status in
   64840    77) echo 77 > $at_status_file
   64841             exit 77;;
   64842    0) ;;
   64843    *) echo "glr-regression.at:422: exit code was $at_status, expected 0"
   64844       at_failed=:;;
   64845 esac
   64846 if $at_failed; then
   64847 
   64848   echo 1 > $at_status_file
   64849   exit 1
   64850 fi
   64851 
   64852 $at_traceon
   64853 
   64854 
   64855       $at_traceoff
   64856       $at_times_p && times >$at_times_file
   64857     ) 5>&1 2>&1 | eval $at_tee_pipe
   64858     at_status=`cat $at_status_file`
   64859     ;;
   64860 
   64861   146 ) # 146. glr-regression.at:432: User destructor for unresolved GLR semantic value
   64862     at_setup_line='glr-regression.at:432'
   64863     at_desc='User destructor for unresolved GLR semantic value'
   64864     $at_quiet $ECHO_N "146: User destructor for unresolved GLR semantic value$ECHO_C"
   64865     at_xfail=no
   64866     (
   64867       echo "146. glr-regression.at:432: testing ..."
   64868       $at_traceon
   64869 
   64870 
   64871 cat >glr-regr5.y <<'_ATEOF'
   64872 %{
   64873 #ifdef HAVE_CONFIG_H
   64874 # include <config.h>
   64875   /* We don't need perfect functions for these tests. */
   64876 # undef malloc
   64877 # undef memcmp
   64878 # undef realloc
   64879 #endif
   64880 %}
   64881 
   64882 
   64883 %{
   64884   #include <stdio.h>
   64885   #include <stdlib.h>
   64886   static void yyerror (char const *);
   64887   static int yylex (void);
   64888   enum { MAGIC_VALUE = -1057808125 }; /* originally chosen at random */
   64889 %}
   64890 
   64891 %glr-parser
   64892 %union { int value; }
   64893 %type <value> start
   64894 
   64895 %destructor {
   64896   if ($$ != MAGIC_VALUE)
   64897     {
   64898       fprintf (stderr, "Bad destructor call.\n");
   64899       exit (EXIT_FAILURE);
   64900     }
   64901 } start
   64902 
   64903 %%
   64904 
   64905 start:
   64906    'a' { $$ = MAGIC_VALUE; }
   64907    | 'a' { $$ = MAGIC_VALUE; }
   64908    ;
   64909 
   64910 %%
   64911 
   64912 static int
   64913 yylex (void)
   64914 {
   64915   static char const *input = "a";
   64916   return *input++;
   64917 }
   64918 
   64919 static void
   64920 yyerror (char const *msg)
   64921 {
   64922   fprintf (stderr, "%s\n", msg);
   64923 }
   64924 
   64925 int
   64926 main (void)
   64927 {
   64928   return yyparse () != 1;
   64929 }
   64930 _ATEOF
   64931 
   64932 
   64933 
   64934 $at_traceoff
   64935 echo "glr-regression.at:487: bison -o glr-regr5.c glr-regr5.y"
   64936 echo glr-regression.at:487 >$at_check_line_file
   64937 ( $at_traceon; bison -o glr-regr5.c glr-regr5.y ) >$at_stdout 2>$at_stder1
   64938 at_status=$?
   64939 grep '^ *+' $at_stder1 >&2
   64940 grep -v '^ *+' $at_stder1 >$at_stderr
   64941 at_failed=false
   64942 echo >>$at_stderr; echo "glr-regr5.y: conflicts: 1 reduce/reduce
   64943 " | $at_diff - $at_stderr || at_failed=:
   64944 $at_diff $at_devnull $at_stdout || at_failed=:
   64945 case $at_status in
   64946    77) echo 77 > $at_status_file
   64947             exit 77;;
   64948    0) ;;
   64949    *) echo "glr-regression.at:487: exit code was $at_status, expected 0"
   64950       at_failed=:;;
   64951 esac
   64952 if $at_failed; then
   64953 
   64954   echo 1 > $at_status_file
   64955   exit 1
   64956 fi
   64957 
   64958 $at_traceon
   64959 
   64960 $at_traceoff
   64961 echo "glr-regression.at:488: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr5 glr-regr5.c \$LIBS"
   64962 echo glr-regression.at:488 >$at_check_line_file
   64963 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr5 glr-regr5.c $LIBS ) >$at_stdout 2>$at_stder1
   64964 at_status=$?
   64965 grep '^ *+' $at_stder1 >&2
   64966 grep -v '^ *+' $at_stder1 >$at_stderr
   64967 at_failed=false
   64968 echo stderr:; cat $at_stderr
   64969 echo stdout:; cat $at_stdout
   64970 case $at_status in
   64971    77) echo 77 > $at_status_file
   64972             exit 77;;
   64973    0) ;;
   64974    *) echo "glr-regression.at:488: exit code was $at_status, expected 0"
   64975       at_failed=:;;
   64976 esac
   64977 if $at_failed; then
   64978 
   64979   echo 1 > $at_status_file
   64980   exit 1
   64981 fi
   64982 
   64983 $at_traceon
   64984 
   64985 
   64986 $at_traceoff
   64987 echo "glr-regression.at:492: ./glr-regr5"
   64988 echo glr-regression.at:492 >$at_check_line_file
   64989 ( $at_traceon; ./glr-regr5 ) >$at_stdout 2>$at_stder1
   64990 at_status=$?
   64991 grep '^ *+' $at_stder1 >&2
   64992 grep -v '^ *+' $at_stder1 >$at_stderr
   64993 at_failed=false
   64994 echo >>$at_stderr; echo "syntax is ambiguous
   64995 " | $at_diff - $at_stderr || at_failed=:
   64996 $at_diff $at_devnull $at_stdout || at_failed=:
   64997 case $at_status in
   64998    77) echo 77 > $at_status_file
   64999             exit 77;;
   65000    0) ;;
   65001    *) echo "glr-regression.at:492: exit code was $at_status, expected 0"
   65002       at_failed=:;;
   65003 esac
   65004 if $at_failed; then
   65005 
   65006   echo 1 > $at_status_file
   65007   exit 1
   65008 fi
   65009 
   65010 $at_traceon
   65011 
   65012 
   65013       $at_traceoff
   65014       $at_times_p && times >$at_times_file
   65015     ) 5>&1 2>&1 | eval $at_tee_pipe
   65016     at_status=`cat $at_status_file`
   65017     ;;
   65018 
   65019   147 ) # 147. glr-regression.at:502: User destructor after an error during a split parse
   65020     at_setup_line='glr-regression.at:502'
   65021     at_desc='User destructor after an error during a split parse'
   65022     $at_quiet $ECHO_N "147: User destructor after an error during a split parse$ECHO_C"
   65023     at_xfail=no
   65024     (
   65025       echo "147. glr-regression.at:502: testing ..."
   65026       $at_traceon
   65027 
   65028 
   65029 cat >glr-regr6.y <<'_ATEOF'
   65030 %{
   65031 #ifdef HAVE_CONFIG_H
   65032 # include <config.h>
   65033   /* We don't need perfect functions for these tests. */
   65034 # undef malloc
   65035 # undef memcmp
   65036 # undef realloc
   65037 #endif
   65038 %}
   65039 
   65040 
   65041 %{
   65042   #include <stdio.h>
   65043   #include <stdlib.h>
   65044   static void yyerror (char const *);
   65045   static int yylex (void);
   65046 %}
   65047 
   65048 %glr-parser
   65049 %union { int value; }
   65050 %type <value> 'a'
   65051 
   65052 %destructor {
   65053   printf ("Destructor called.\n");
   65054 } 'a'
   65055 
   65056 %%
   65057 
   65058 start: 'a' | 'a' ;
   65059 
   65060 %%
   65061 
   65062 static int
   65063 yylex (void)
   65064 {
   65065   static char const *input = "a";
   65066   return *input++;
   65067 }
   65068 
   65069 static void
   65070 yyerror (char const *msg)
   65071 {
   65072   fprintf (stderr, "%s\n", msg);
   65073 }
   65074 
   65075 int
   65076 main (void)
   65077 {
   65078   return yyparse () != 1;
   65079 }
   65080 _ATEOF
   65081 
   65082 
   65083 
   65084 $at_traceoff
   65085 echo "glr-regression.at:549: bison -o glr-regr6.c glr-regr6.y"
   65086 echo glr-regression.at:549 >$at_check_line_file
   65087 ( $at_traceon; bison -o glr-regr6.c glr-regr6.y ) >$at_stdout 2>$at_stder1
   65088 at_status=$?
   65089 grep '^ *+' $at_stder1 >&2
   65090 grep -v '^ *+' $at_stder1 >$at_stderr
   65091 at_failed=false
   65092 echo >>$at_stderr; echo "glr-regr6.y: conflicts: 1 reduce/reduce
   65093 " | $at_diff - $at_stderr || at_failed=:
   65094 $at_diff $at_devnull $at_stdout || at_failed=:
   65095 case $at_status in
   65096    77) echo 77 > $at_status_file
   65097             exit 77;;
   65098    0) ;;
   65099    *) echo "glr-regression.at:549: exit code was $at_status, expected 0"
   65100       at_failed=:;;
   65101 esac
   65102 if $at_failed; then
   65103 
   65104   echo 1 > $at_status_file
   65105   exit 1
   65106 fi
   65107 
   65108 $at_traceon
   65109 
   65110 $at_traceoff
   65111 echo "glr-regression.at:550: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr6 glr-regr6.c \$LIBS"
   65112 echo glr-regression.at:550 >$at_check_line_file
   65113 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr6 glr-regr6.c $LIBS ) >$at_stdout 2>$at_stder1
   65114 at_status=$?
   65115 grep '^ *+' $at_stder1 >&2
   65116 grep -v '^ *+' $at_stder1 >$at_stderr
   65117 at_failed=false
   65118 echo stderr:; cat $at_stderr
   65119 echo stdout:; cat $at_stdout
   65120 case $at_status in
   65121    77) echo 77 > $at_status_file
   65122             exit 77;;
   65123    0) ;;
   65124    *) echo "glr-regression.at:550: exit code was $at_status, expected 0"
   65125       at_failed=:;;
   65126 esac
   65127 if $at_failed; then
   65128 
   65129   echo 1 > $at_status_file
   65130   exit 1
   65131 fi
   65132 
   65133 $at_traceon
   65134 
   65135 
   65136 $at_traceoff
   65137 echo "glr-regression.at:556: ./glr-regr6"
   65138 echo glr-regression.at:556 >$at_check_line_file
   65139 ( $at_traceon; ./glr-regr6 ) >$at_stdout 2>$at_stder1
   65140 at_status=$?
   65141 grep '^ *+' $at_stder1 >&2
   65142 grep -v '^ *+' $at_stder1 >$at_stderr
   65143 at_failed=false
   65144 echo >>$at_stderr; echo "syntax is ambiguous
   65145 " | $at_diff - $at_stderr || at_failed=:
   65146 echo >>$at_stdout; echo "Destructor called.
   65147 " | $at_diff - $at_stdout || at_failed=:
   65148 case $at_status in
   65149    77) echo 77 > $at_status_file
   65150             exit 77;;
   65151    0) ;;
   65152    *) echo "glr-regression.at:556: exit code was $at_status, expected 0"
   65153       at_failed=:;;
   65154 esac
   65155 if $at_failed; then
   65156 
   65157   echo 1 > $at_status_file
   65158   exit 1
   65159 fi
   65160 
   65161 $at_traceon
   65162 
   65163 
   65164       $at_traceoff
   65165       $at_times_p && times >$at_times_file
   65166     ) 5>&1 2>&1 | eval $at_tee_pipe
   65167     at_status=`cat $at_status_file`
   65168     ;;
   65169 
   65170   148 ) # 148. glr-regression.at:566: Duplicated user destructor for lookahead
   65171     at_setup_line='glr-regression.at:566'
   65172     at_desc='Duplicated user destructor for lookahead'
   65173     $at_quiet $ECHO_N "148: Duplicated user destructor for lookahead     $ECHO_C"
   65174     at_xfail=no
   65175     (
   65176       echo "148. glr-regression.at:566: testing ..."
   65177       $at_traceon
   65178 
   65179 
   65180 cat >glr-regr7.y <<'_ATEOF'
   65181 %{
   65182 #ifdef HAVE_CONFIG_H
   65183 # include <config.h>
   65184   /* We don't need perfect functions for these tests. */
   65185 # undef malloc
   65186 # undef memcmp
   65187 # undef realloc
   65188 #endif
   65189 %}
   65190 
   65191 
   65192 %{
   65193   #include <stdio.h>
   65194   #include <stdlib.h>
   65195   static void yyerror (char const *);
   65196   static int yylex (void);
   65197   #define YYSTACKEXPANDABLE 0
   65198 %}
   65199 
   65200 %glr-parser
   65201 %union { int *count; }
   65202 %type <count> 'a'
   65203 
   65204 %destructor {
   65205   if ((*$$)++)
   65206     fprintf (stderr, "Destructor called on same value twice.\n");
   65207 } 'a'
   65208 
   65209 %%
   65210 
   65211 start:
   65212     stack1 start
   65213   | stack2 start
   65214   | /* empty */
   65215   ;
   65216 stack1: 'a' ;
   65217 stack2: 'a' ;
   65218 
   65219 %%
   65220 
   65221 static int
   65222 yylex (void)
   65223 {
   65224   yylval.count = (int *) malloc (sizeof (int));
   65225   if (!yylval.count)
   65226     {
   65227       fprintf (stderr, "Test inconclusive.\n");
   65228       exit (EXIT_FAILURE);
   65229     }
   65230   *yylval.count = 0;
   65231   return 'a';
   65232 }
   65233 
   65234 static void
   65235 yyerror (char const *msg)
   65236 {
   65237   fprintf (stderr, "%s\n", msg);
   65238 }
   65239 
   65240 int
   65241 main (void)
   65242 {
   65243   return yyparse ();
   65244 }
   65245 _ATEOF
   65246 
   65247 
   65248 
   65249 $at_traceoff
   65250 echo "glr-regression.at:627: bison -o glr-regr7.c glr-regr7.y"
   65251 echo glr-regression.at:627 >$at_check_line_file
   65252 ( $at_traceon; bison -o glr-regr7.c glr-regr7.y ) >$at_stdout 2>$at_stder1
   65253 at_status=$?
   65254 grep '^ *+' $at_stder1 >&2
   65255 grep -v '^ *+' $at_stder1 >$at_stderr
   65256 at_failed=false
   65257 echo >>$at_stderr; echo "glr-regr7.y: conflicts: 2 reduce/reduce
   65258 " | $at_diff - $at_stderr || at_failed=:
   65259 $at_diff $at_devnull $at_stdout || at_failed=:
   65260 case $at_status in
   65261    77) echo 77 > $at_status_file
   65262             exit 77;;
   65263    0) ;;
   65264    *) echo "glr-regression.at:627: exit code was $at_status, expected 0"
   65265       at_failed=:;;
   65266 esac
   65267 if $at_failed; then
   65268 
   65269   echo 1 > $at_status_file
   65270   exit 1
   65271 fi
   65272 
   65273 $at_traceon
   65274 
   65275 $at_traceoff
   65276 echo "glr-regression.at:628: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr7 glr-regr7.c \$LIBS"
   65277 echo glr-regression.at:628 >$at_check_line_file
   65278 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr7 glr-regr7.c $LIBS ) >$at_stdout 2>$at_stder1
   65279 at_status=$?
   65280 grep '^ *+' $at_stder1 >&2
   65281 grep -v '^ *+' $at_stder1 >$at_stderr
   65282 at_failed=false
   65283 echo stderr:; cat $at_stderr
   65284 echo stdout:; cat $at_stdout
   65285 case $at_status in
   65286    77) echo 77 > $at_status_file
   65287             exit 77;;
   65288    0) ;;
   65289    *) echo "glr-regression.at:628: exit code was $at_status, expected 0"
   65290       at_failed=:;;
   65291 esac
   65292 if $at_failed; then
   65293 
   65294   echo 1 > $at_status_file
   65295   exit 1
   65296 fi
   65297 
   65298 $at_traceon
   65299 
   65300 
   65301 $at_traceoff
   65302 echo "glr-regression.at:632: ./glr-regr7"
   65303 echo glr-regression.at:632 >$at_check_line_file
   65304 ( $at_traceon; ./glr-regr7 ) >$at_stdout 2>$at_stder1
   65305 at_status=$?
   65306 grep '^ *+' $at_stder1 >&2
   65307 grep -v '^ *+' $at_stder1 >$at_stderr
   65308 at_failed=false
   65309 echo >>$at_stderr; echo "memory exhausted
   65310 " | $at_diff - $at_stderr || at_failed=:
   65311 $at_diff $at_devnull $at_stdout || at_failed=:
   65312 case $at_status in
   65313    77) echo 77 > $at_status_file
   65314             exit 77;;
   65315    2) ;;
   65316    *) echo "glr-regression.at:632: exit code was $at_status, expected 2"
   65317       at_failed=:;;
   65318 esac
   65319 if $at_failed; then
   65320 
   65321   echo 1 > $at_status_file
   65322   exit 1
   65323 fi
   65324 
   65325 $at_traceon
   65326 
   65327 
   65328       $at_traceoff
   65329       $at_times_p && times >$at_times_file
   65330     ) 5>&1 2>&1 | eval $at_tee_pipe
   65331     at_status=`cat $at_status_file`
   65332     ;;
   65333 
   65334   149 ) # 149. glr-regression.at:644: Incorrectly initialized location for empty right-hand side in GLR
   65335     at_setup_line='glr-regression.at:644'
   65336     at_desc='Incorrectly initialized location for empty right-hand side in GLR'
   65337     $at_quiet $ECHO_N "149: Incorrectly initialized location for empty right-hand side in GLR$ECHO_C"
   65338     at_xfail=no
   65339     (
   65340       echo "149. glr-regression.at:644: testing ..."
   65341       $at_traceon
   65342 
   65343 
   65344 cat >glr-regr8.y <<'_ATEOF'
   65345 %{
   65346 #ifdef HAVE_CONFIG_H
   65347 # include <config.h>
   65348   /* We don't need perfect functions for these tests. */
   65349 # undef malloc
   65350 # undef memcmp
   65351 # undef realloc
   65352 #endif
   65353 %}
   65354 
   65355 
   65356 %{
   65357   #include <stdio.h>
   65358   #include <stdlib.h>
   65359   static void yyerror (char const *);
   65360   static int yylex (void);
   65361   static void yyerror (char const *msg);
   65362 %}
   65363 
   65364 %token T_CONSTANT
   65365 %token T_PORT
   65366 %token T_SIGNAL
   65367 
   65368 %glr-parser
   65369 
   65370 %%
   65371 
   65372 
   65373 PortClause	: T_PORT InterfaceDeclaration T_PORT
   65374 		{ printf("%d/%d - %d/%d - %d/%d\n",
   65375 			 @1.first_column, @1.last_column,
   65376 			 @2.first_column, @2.last_column,
   65377 			 @3.first_column, @3.last_column); }
   65378 	;
   65379 
   65380 InterfaceDeclaration	: OptConstantWord	%dprec 1
   65381 	| OptSignalWord	%dprec 2
   65382 	;
   65383 
   65384 OptConstantWord	: /* empty */
   65385 	| T_CONSTANT
   65386 	;
   65387 
   65388 OptSignalWord	: /* empty */
   65389 		{ printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
   65390 	| T_SIGNAL
   65391 	;
   65392 
   65393 %%
   65394 
   65395 void
   65396 yyerror (char const *msg)
   65397 {
   65398   fprintf (stderr, "%s\n", msg);
   65399 }
   65400 
   65401 static int lexIndex;
   65402 
   65403 int yylex (void)
   65404 {
   65405   lexIndex += 1;
   65406   switch (lexIndex)
   65407     {
   65408     case 1:
   65409       yylloc.first_column = 1;
   65410       yylloc.last_column = 9;
   65411       return T_PORT;
   65412     case 2:
   65413       yylloc.first_column = 13;
   65414       yylloc.last_column = 17;
   65415       return T_PORT;
   65416     default:
   65417       return 0;
   65418     }
   65419 }
   65420 
   65421 int
   65422 main (void)
   65423 {
   65424   yyparse();
   65425   return 0;
   65426 }
   65427 _ATEOF
   65428 
   65429 
   65430 
   65431 $at_traceoff
   65432 echo "glr-regression.at:723: bison -o glr-regr8.c glr-regr8.y"
   65433 echo glr-regression.at:723 >$at_check_line_file
   65434 ( $at_traceon; bison -o glr-regr8.c glr-regr8.y ) >$at_stdout 2>$at_stder1
   65435 at_status=$?
   65436 grep '^ *+' $at_stder1 >&2
   65437 grep -v '^ *+' $at_stder1 >$at_stderr
   65438 at_failed=false
   65439 echo >>$at_stderr; echo "glr-regr8.y: conflicts: 1 reduce/reduce
   65440 " | $at_diff - $at_stderr || at_failed=:
   65441 $at_diff $at_devnull $at_stdout || at_failed=:
   65442 case $at_status in
   65443    77) echo 77 > $at_status_file
   65444             exit 77;;
   65445    0) ;;
   65446    *) echo "glr-regression.at:723: exit code was $at_status, expected 0"
   65447       at_failed=:;;
   65448 esac
   65449 if $at_failed; then
   65450 
   65451   echo 1 > $at_status_file
   65452   exit 1
   65453 fi
   65454 
   65455 $at_traceon
   65456 
   65457 $at_traceoff
   65458 echo "glr-regression.at:724: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr8 glr-regr8.c \$LIBS"
   65459 echo glr-regression.at:724 >$at_check_line_file
   65460 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr8 glr-regr8.c $LIBS ) >$at_stdout 2>$at_stder1
   65461 at_status=$?
   65462 grep '^ *+' $at_stder1 >&2
   65463 grep -v '^ *+' $at_stder1 >$at_stderr
   65464 at_failed=false
   65465 echo stderr:; cat $at_stderr
   65466 echo stdout:; cat $at_stdout
   65467 case $at_status in
   65468    77) echo 77 > $at_status_file
   65469             exit 77;;
   65470    0) ;;
   65471    *) echo "glr-regression.at:724: exit code was $at_status, expected 0"
   65472       at_failed=:;;
   65473 esac
   65474 if $at_failed; then
   65475 
   65476   echo 1 > $at_status_file
   65477   exit 1
   65478 fi
   65479 
   65480 $at_traceon
   65481 
   65482 
   65483 $at_traceoff
   65484 echo "glr-regression.at:730: ./glr-regr8"
   65485 echo glr-regression.at:730 >$at_check_line_file
   65486 ( $at_traceon; ./glr-regr8 ) >$at_stdout 2>$at_stder1
   65487 at_status=$?
   65488 grep '^ *+' $at_stder1 >&2
   65489 grep -v '^ *+' $at_stder1 >$at_stderr
   65490 at_failed=false
   65491 $at_diff $at_devnull $at_stderr || at_failed=:
   65492 echo >>$at_stdout; echo "empty: 9/9
   65493 1/9 - 9/9 - 13/17
   65494 " | $at_diff - $at_stdout || at_failed=:
   65495 case $at_status in
   65496    77) echo 77 > $at_status_file
   65497             exit 77;;
   65498    0) ;;
   65499    *) echo "glr-regression.at:730: exit code was $at_status, expected 0"
   65500       at_failed=:;;
   65501 esac
   65502 if $at_failed; then
   65503 
   65504   echo 1 > $at_status_file
   65505   exit 1
   65506 fi
   65507 
   65508 $at_traceon
   65509 
   65510 
   65511       $at_traceoff
   65512       $at_times_p && times >$at_times_file
   65513     ) 5>&1 2>&1 | eval $at_tee_pipe
   65514     at_status=`cat $at_status_file`
   65515     ;;
   65516 
   65517   150 ) # 150. glr-regression.at:740: No users destructors if stack 0 deleted
   65518     at_setup_line='glr-regression.at:740'
   65519     at_desc='No users destructors if stack 0 deleted'
   65520     $at_quiet $ECHO_N "150: No users destructors if stack 0 deleted      $ECHO_C"
   65521     at_xfail=no
   65522     (
   65523       echo "150. glr-regression.at:740: testing ..."
   65524       $at_traceon
   65525 
   65526 
   65527 cat >glr-regr9.y <<'_ATEOF'
   65528 %{
   65529 #ifdef HAVE_CONFIG_H
   65530 # include <config.h>
   65531   /* We don't need perfect functions for these tests. */
   65532 # undef malloc
   65533 # undef memcmp
   65534 # undef realloc
   65535 #endif
   65536 %}
   65537 
   65538 
   65539 %{
   65540 # include <stdio.h>
   65541 # include <stdlib.h>
   65542   static void yyerror (char const *);
   65543   static int yylex (void);
   65544 # define YYSTACKEXPANDABLE 0
   65545   static int tokens = 0;
   65546   static int destructors = 0;
   65547 # define USE(Var)
   65548 %}
   65549 
   65550 %glr-parser
   65551 %union { int dummy; }
   65552 %type <dummy> 'a'
   65553 
   65554 %destructor {
   65555   destructors += 1;
   65556 } 'a'
   65557 
   65558 %%
   65559 
   65560 start:
   65561     ambig0 'a'   { destructors += 2; USE ($2); }
   65562   | ambig1 start { destructors += 1; }
   65563   | ambig2 start { destructors += 1; }
   65564   ;
   65565 
   65566 ambig0: 'a' ;
   65567 ambig1: 'a' ;
   65568 ambig2: 'a' ;
   65569 
   65570 %%
   65571 
   65572 static int
   65573 yylex (void)
   65574 {
   65575   tokens += 1;
   65576   return 'a';
   65577 }
   65578 
   65579 static void
   65580 yyerror (char const *msg)
   65581 {
   65582   fprintf (stderr, "%s\n", msg);
   65583 }
   65584 
   65585 int
   65586 main (void)
   65587 {
   65588   int exit_status;
   65589   exit_status = yyparse ();
   65590   if (tokens != destructors)
   65591     {
   65592       fprintf (stderr, "Tokens = %d, Destructors = %d\n", tokens, destructors);
   65593       return 1;
   65594     }
   65595   return !exit_status;
   65596 }
   65597 _ATEOF
   65598 
   65599 
   65600 
   65601 $at_traceoff
   65602 echo "glr-regression.at:806: bison -o glr-regr9.c glr-regr9.y"
   65603 echo glr-regression.at:806 >$at_check_line_file
   65604 ( $at_traceon; bison -o glr-regr9.c glr-regr9.y ) >$at_stdout 2>$at_stder1
   65605 at_status=$?
   65606 grep '^ *+' $at_stder1 >&2
   65607 grep -v '^ *+' $at_stder1 >$at_stderr
   65608 at_failed=false
   65609 echo >>$at_stderr; echo "glr-regr9.y: conflicts: 1 reduce/reduce
   65610 " | $at_diff - $at_stderr || at_failed=:
   65611 $at_diff $at_devnull $at_stdout || at_failed=:
   65612 case $at_status in
   65613    77) echo 77 > $at_status_file
   65614             exit 77;;
   65615    0) ;;
   65616    *) echo "glr-regression.at:806: exit code was $at_status, expected 0"
   65617       at_failed=:;;
   65618 esac
   65619 if $at_failed; then
   65620 
   65621   echo 1 > $at_status_file
   65622   exit 1
   65623 fi
   65624 
   65625 $at_traceon
   65626 
   65627 $at_traceoff
   65628 echo "glr-regression.at:807: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr9 glr-regr9.c \$LIBS"
   65629 echo glr-regression.at:807 >$at_check_line_file
   65630 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr9 glr-regr9.c $LIBS ) >$at_stdout 2>$at_stder1
   65631 at_status=$?
   65632 grep '^ *+' $at_stder1 >&2
   65633 grep -v '^ *+' $at_stder1 >$at_stderr
   65634 at_failed=false
   65635 echo stderr:; cat $at_stderr
   65636 echo stdout:; cat $at_stdout
   65637 case $at_status in
   65638    77) echo 77 > $at_status_file
   65639             exit 77;;
   65640    0) ;;
   65641    *) echo "glr-regression.at:807: exit code was $at_status, expected 0"
   65642       at_failed=:;;
   65643 esac
   65644 if $at_failed; then
   65645 
   65646   echo 1 > $at_status_file
   65647   exit 1
   65648 fi
   65649 
   65650 $at_traceon
   65651 
   65652 
   65653 $at_traceoff
   65654 echo "glr-regression.at:811: ./glr-regr9"
   65655 echo glr-regression.at:811 >$at_check_line_file
   65656 ( $at_traceon; ./glr-regr9 ) >$at_stdout 2>$at_stder1
   65657 at_status=$?
   65658 grep '^ *+' $at_stder1 >&2
   65659 grep -v '^ *+' $at_stder1 >$at_stderr
   65660 at_failed=false
   65661 echo >>$at_stderr; echo "memory exhausted
   65662 " | $at_diff - $at_stderr || at_failed=:
   65663 $at_diff $at_devnull $at_stdout || at_failed=:
   65664 case $at_status in
   65665    77) echo 77 > $at_status_file
   65666             exit 77;;
   65667    0) ;;
   65668    *) echo "glr-regression.at:811: exit code was $at_status, expected 0"
   65669       at_failed=:;;
   65670 esac
   65671 if $at_failed; then
   65672 
   65673   echo 1 > $at_status_file
   65674   exit 1
   65675 fi
   65676 
   65677 $at_traceon
   65678 
   65679 
   65680       $at_traceoff
   65681       $at_times_p && times >$at_times_file
   65682     ) 5>&1 2>&1 | eval $at_tee_pipe
   65683     at_status=`cat $at_status_file`
   65684     ;;
   65685 
   65686   151 ) # 151. glr-regression.at:820: Corrupted semantic options if user action cuts parse
   65687     at_setup_line='glr-regression.at:820'
   65688     at_desc='Corrupted semantic options if user action cuts parse'
   65689     $at_quiet $ECHO_N "151: Corrupted semantic options if user action cuts parse$ECHO_C"
   65690     at_xfail=no
   65691     (
   65692       echo "151. glr-regression.at:820: testing ..."
   65693       $at_traceon
   65694 
   65695 
   65696 cat >glr-regr10.y <<'_ATEOF'
   65697 %{
   65698 #ifdef HAVE_CONFIG_H
   65699 # include <config.h>
   65700   /* We don't need perfect functions for these tests. */
   65701 # undef malloc
   65702 # undef memcmp
   65703 # undef realloc
   65704 #endif
   65705 %}
   65706 
   65707 
   65708 %{
   65709 # include <stdio.h>
   65710   static void yyerror (char const *);
   65711   static int yylex (void);
   65712   #define GARBAGE_SIZE 50
   65713   static char garbage[GARBAGE_SIZE];
   65714 %}
   65715 
   65716 %glr-parser
   65717 %union { char *ptr; }
   65718 %type <ptr> start
   65719 
   65720 %%
   65721 
   65722 start:
   65723     %dprec 2 { $$ = garbage; YYACCEPT; }
   65724   | %dprec 1 { $$ = garbage; YYACCEPT; }
   65725   ;
   65726 
   65727 %%
   65728 
   65729 static void
   65730 yyerror (char const *msg)
   65731 {
   65732   fprintf (stderr, "%s\n", msg);
   65733 }
   65734 
   65735 static int
   65736 yylex (void)
   65737 {
   65738   return 0;
   65739 }
   65740 
   65741 int
   65742 main (void)
   65743 {
   65744   int i;
   65745   for (i = 0; i < GARBAGE_SIZE; i+=1)
   65746     garbage[i] = 108;
   65747   return yyparse ();
   65748 }
   65749 _ATEOF
   65750 
   65751 
   65752 
   65753 $at_traceoff
   65754 echo "glr-regression.at:869: bison -o glr-regr10.c glr-regr10.y"
   65755 echo glr-regression.at:869 >$at_check_line_file
   65756 ( $at_traceon; bison -o glr-regr10.c glr-regr10.y ) >$at_stdout 2>$at_stder1
   65757 at_status=$?
   65758 grep '^ *+' $at_stder1 >&2
   65759 grep -v '^ *+' $at_stder1 >$at_stderr
   65760 at_failed=false
   65761 echo >>$at_stderr; echo "glr-regr10.y: conflicts: 1 reduce/reduce
   65762 " | $at_diff - $at_stderr || at_failed=:
   65763 $at_diff $at_devnull $at_stdout || at_failed=:
   65764 case $at_status in
   65765    77) echo 77 > $at_status_file
   65766             exit 77;;
   65767    0) ;;
   65768    *) echo "glr-regression.at:869: exit code was $at_status, expected 0"
   65769       at_failed=:;;
   65770 esac
   65771 if $at_failed; then
   65772 
   65773   echo 1 > $at_status_file
   65774   exit 1
   65775 fi
   65776 
   65777 $at_traceon
   65778 
   65779 $at_traceoff
   65780 echo "glr-regression.at:870: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr10 glr-regr10.c \$LIBS"
   65781 echo glr-regression.at:870 >$at_check_line_file
   65782 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr10 glr-regr10.c $LIBS ) >$at_stdout 2>$at_stder1
   65783 at_status=$?
   65784 grep '^ *+' $at_stder1 >&2
   65785 grep -v '^ *+' $at_stder1 >$at_stderr
   65786 at_failed=false
   65787 echo stderr:; cat $at_stderr
   65788 echo stdout:; cat $at_stdout
   65789 case $at_status in
   65790    77) echo 77 > $at_status_file
   65791             exit 77;;
   65792    0) ;;
   65793    *) echo "glr-regression.at:870: exit code was $at_status, expected 0"
   65794       at_failed=:;;
   65795 esac
   65796 if $at_failed; then
   65797 
   65798   echo 1 > $at_status_file
   65799   exit 1
   65800 fi
   65801 
   65802 $at_traceon
   65803 
   65804 
   65805 $at_traceoff
   65806 echo "glr-regression.at:872: ./glr-regr10"
   65807 echo glr-regression.at:872 >$at_check_line_file
   65808 ( $at_traceon; ./glr-regr10 ) >$at_stdout 2>$at_stder1
   65809 at_status=$?
   65810 grep '^ *+' $at_stder1 >&2
   65811 grep -v '^ *+' $at_stder1 >$at_stderr
   65812 at_failed=false
   65813 $at_diff $at_devnull $at_stderr || at_failed=:
   65814 $at_diff $at_devnull $at_stdout || at_failed=:
   65815 case $at_status in
   65816    77) echo 77 > $at_status_file
   65817             exit 77;;
   65818    0) ;;
   65819    *) echo "glr-regression.at:872: exit code was $at_status, expected 0"
   65820       at_failed=:;;
   65821 esac
   65822 if $at_failed; then
   65823 
   65824   echo 1 > $at_status_file
   65825   exit 1
   65826 fi
   65827 
   65828 $at_traceon
   65829 
   65830 
   65831       $at_traceoff
   65832       $at_times_p && times >$at_times_file
   65833     ) 5>&1 2>&1 | eval $at_tee_pipe
   65834     at_status=`cat $at_status_file`
   65835     ;;
   65836 
   65837   152 ) # 152. glr-regression.at:881: Undesirable destructors if user action cuts parse
   65838     at_setup_line='glr-regression.at:881'
   65839     at_desc='Undesirable destructors if user action cuts parse'
   65840     $at_quiet $ECHO_N "152: Undesirable destructors if user action cuts parse$ECHO_C"
   65841     at_xfail=no
   65842     (
   65843       echo "152. glr-regression.at:881: testing ..."
   65844       $at_traceon
   65845 
   65846 
   65847 cat >glr-regr11.y <<'_ATEOF'
   65848 %{
   65849 #ifdef HAVE_CONFIG_H
   65850 # include <config.h>
   65851   /* We don't need perfect functions for these tests. */
   65852 # undef malloc
   65853 # undef memcmp
   65854 # undef realloc
   65855 #endif
   65856 %}
   65857 
   65858 
   65859 %{
   65860 # include <stdlib.h>
   65861   static void yyerror (char const *);
   65862   static int yylex (void);
   65863   static int destructors = 0;
   65864 # define USE(val)
   65865 %}
   65866 
   65867 %glr-parser
   65868 %union { int dummy; }
   65869 %type <int> 'a'
   65870 %destructor { destructors += 1; } 'a'
   65871 
   65872 %%
   65873 
   65874 start:
   65875     'a' %dprec 2 { USE ($1); destructors += 1; YYACCEPT; }
   65876   | 'a' %dprec 1 { USE ($1); destructors += 1; YYACCEPT; }
   65877   ;
   65878 
   65879 %%
   65880 
   65881 static void
   65882 yyerror (char const *msg)
   65883 {
   65884   fprintf (stderr, "%s\n", msg);
   65885 }
   65886 
   65887 static int
   65888 yylex (void)
   65889 {
   65890   static char const *input = "a";
   65891   return *input++;
   65892 }
   65893 
   65894 int
   65895 main (void)
   65896 {
   65897   int exit_status = yyparse ();
   65898   if (destructors != 1)
   65899     {
   65900       fprintf (stderr, "Destructor calls: %d\n", destructors);
   65901       return 1;
   65902     }
   65903   return exit_status;
   65904 }
   65905 _ATEOF
   65906 
   65907 
   65908 
   65909 $at_traceoff
   65910 echo "glr-regression.at:935: bison -o glr-regr11.c glr-regr11.y"
   65911 echo glr-regression.at:935 >$at_check_line_file
   65912 ( $at_traceon; bison -o glr-regr11.c glr-regr11.y ) >$at_stdout 2>$at_stder1
   65913 at_status=$?
   65914 grep '^ *+' $at_stder1 >&2
   65915 grep -v '^ *+' $at_stder1 >$at_stderr
   65916 at_failed=false
   65917 echo >>$at_stderr; echo "glr-regr11.y: conflicts: 1 reduce/reduce
   65918 " | $at_diff - $at_stderr || at_failed=:
   65919 $at_diff $at_devnull $at_stdout || at_failed=:
   65920 case $at_status in
   65921    77) echo 77 > $at_status_file
   65922             exit 77;;
   65923    0) ;;
   65924    *) echo "glr-regression.at:935: exit code was $at_status, expected 0"
   65925       at_failed=:;;
   65926 esac
   65927 if $at_failed; then
   65928 
   65929   echo 1 > $at_status_file
   65930   exit 1
   65931 fi
   65932 
   65933 $at_traceon
   65934 
   65935 $at_traceoff
   65936 echo "glr-regression.at:936: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr11 glr-regr11.c \$LIBS"
   65937 echo glr-regression.at:936 >$at_check_line_file
   65938 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr11 glr-regr11.c $LIBS ) >$at_stdout 2>$at_stder1
   65939 at_status=$?
   65940 grep '^ *+' $at_stder1 >&2
   65941 grep -v '^ *+' $at_stder1 >$at_stderr
   65942 at_failed=false
   65943 echo stderr:; cat $at_stderr
   65944 echo stdout:; cat $at_stdout
   65945 case $at_status in
   65946    77) echo 77 > $at_status_file
   65947             exit 77;;
   65948    0) ;;
   65949    *) echo "glr-regression.at:936: exit code was $at_status, expected 0"
   65950       at_failed=:;;
   65951 esac
   65952 if $at_failed; then
   65953 
   65954   echo 1 > $at_status_file
   65955   exit 1
   65956 fi
   65957 
   65958 $at_traceon
   65959 
   65960 
   65961 $at_traceoff
   65962 echo "glr-regression.at:938: ./glr-regr11"
   65963 echo glr-regression.at:938 >$at_check_line_file
   65964 ( $at_traceon; ./glr-regr11 ) >$at_stdout 2>$at_stder1
   65965 at_status=$?
   65966 grep '^ *+' $at_stder1 >&2
   65967 grep -v '^ *+' $at_stder1 >$at_stderr
   65968 at_failed=false
   65969 $at_diff $at_devnull $at_stderr || at_failed=:
   65970 $at_diff $at_devnull $at_stdout || at_failed=:
   65971 case $at_status in
   65972    77) echo 77 > $at_status_file
   65973             exit 77;;
   65974    0) ;;
   65975    *) echo "glr-regression.at:938: exit code was $at_status, expected 0"
   65976       at_failed=:;;
   65977 esac
   65978 if $at_failed; then
   65979 
   65980   echo 1 > $at_status_file
   65981   exit 1
   65982 fi
   65983 
   65984 $at_traceon
   65985 
   65986 
   65987       $at_traceoff
   65988       $at_times_p && times >$at_times_file
   65989     ) 5>&1 2>&1 | eval $at_tee_pipe
   65990     at_status=`cat $at_status_file`
   65991     ;;
   65992 
   65993   153 ) # 153. glr-regression.at:947: Leaked semantic values if user action cuts parse
   65994     at_setup_line='glr-regression.at:947'
   65995     at_desc='Leaked semantic values if user action cuts parse'
   65996     $at_quiet $ECHO_N "153: Leaked semantic values if user action cuts parse$ECHO_C"
   65997     at_xfail=no
   65998     (
   65999       echo "153. glr-regression.at:947: testing ..."
   66000       $at_traceon
   66001 
   66002 
   66003 cat >glr-regr12.y <<'_ATEOF'
   66004 %{
   66005 #ifdef HAVE_CONFIG_H
   66006 # include <config.h>
   66007   /* We don't need perfect functions for these tests. */
   66008 # undef malloc
   66009 # undef memcmp
   66010 # undef realloc
   66011 #endif
   66012 %}
   66013 
   66014 
   66015 %glr-parser
   66016 %union { int dummy; }
   66017 %token PARENT_RHS_AFTER
   66018 %type <dummy> parent_rhs_before merged PARENT_RHS_AFTER
   66019 %destructor { parent_rhs_before_value = 0; } parent_rhs_before
   66020 %destructor { merged_value = 0; } merged
   66021 %destructor { parent_rhs_after_value = 0; } PARENT_RHS_AFTER
   66022 
   66023 %{
   66024 # include <stdlib.h>
   66025   static int merge (YYSTYPE, YYSTYPE);
   66026   static void yyerror (char const *);
   66027   static int yylex (void);
   66028   static int parent_rhs_before_value = 0;
   66029   static int merged_value = 0;
   66030   static int parent_rhs_after_value = 0;
   66031 # define USE(val)
   66032 %}
   66033 
   66034 %%
   66035 
   66036 start:
   66037   alt1 %dprec 1
   66038   | alt2 %dprec 2
   66039   ;
   66040 
   66041 alt1:
   66042   PARENT_RHS_AFTER {
   66043     USE ($1);
   66044     parent_rhs_after_value = 0;
   66045   }
   66046   ;
   66047 
   66048 alt2:
   66049   parent_rhs_before merged PARENT_RHS_AFTER {
   66050     USE (($1, $2, $3));
   66051     parent_rhs_before_value = 0;
   66052     merged_value = 0;
   66053     parent_rhs_after_value = 0;
   66054   }
   66055   ;
   66056 
   66057 parent_rhs_before:
   66058   {
   66059     USE ($$);
   66060     parent_rhs_before_value = 1;
   66061   }
   66062   ;
   66063 
   66064 merged:
   66065   %merge<merge> {
   66066     USE ($$);
   66067     merged_value = 1;
   66068   }
   66069   | cut %merge<merge> {
   66070     USE ($$);
   66071     merged_value = 1;
   66072   }
   66073   ;
   66074 
   66075 cut: { YYACCEPT; } ;
   66076 
   66077 %%
   66078 
   66079 static int
   66080 merge (YYSTYPE s1, YYSTYPE s2)
   66081 {
   66082   /* Not invoked. */
   66083   char dummy = s1.dummy + s2.dummy;
   66084   return dummy;
   66085 }
   66086 
   66087 static void
   66088 yyerror (char const *msg)
   66089 {
   66090   fprintf (stderr, "%s\n", msg);
   66091 }
   66092 
   66093 static int
   66094 yylex (void)
   66095 {
   66096   static int const input[] = { PARENT_RHS_AFTER, 0 };
   66097   static const int *inputp = input;
   66098   if (*inputp == PARENT_RHS_AFTER)
   66099     parent_rhs_after_value = 1;
   66100   return *inputp++;
   66101 }
   66102 
   66103 int
   66104 main (void)
   66105 {
   66106   int exit_status = yyparse ();
   66107   if (parent_rhs_before_value)
   66108     {
   66109       fprintf (stderr, "`parent_rhs_before' destructor not called.\n");
   66110       exit_status = 1;
   66111     }
   66112   if (merged_value)
   66113     {
   66114       fprintf (stderr, "`merged' destructor not called.\n");
   66115       exit_status = 1;
   66116     }
   66117   if (parent_rhs_after_value)
   66118     {
   66119       fprintf (stderr, "`PARENT_RHS_AFTER' destructor not called.\n");
   66120       exit_status = 1;
   66121     }
   66122   return exit_status;
   66123 }
   66124 _ATEOF
   66125 
   66126 
   66127 
   66128 $at_traceoff
   66129 echo "glr-regression.at:1064: bison -o glr-regr12.c glr-regr12.y"
   66130 echo glr-regression.at:1064 >$at_check_line_file
   66131 ( $at_traceon; bison -o glr-regr12.c glr-regr12.y ) >$at_stdout 2>$at_stder1
   66132 at_status=$?
   66133 grep '^ *+' $at_stder1 >&2
   66134 grep -v '^ *+' $at_stder1 >$at_stderr
   66135 at_failed=false
   66136 echo >>$at_stderr; echo "glr-regr12.y: conflicts: 1 shift/reduce, 1 reduce/reduce
   66137 " | $at_diff - $at_stderr || at_failed=:
   66138 $at_diff $at_devnull $at_stdout || at_failed=:
   66139 case $at_status in
   66140    77) echo 77 > $at_status_file
   66141             exit 77;;
   66142    0) ;;
   66143    *) echo "glr-regression.at:1064: exit code was $at_status, expected 0"
   66144       at_failed=:;;
   66145 esac
   66146 if $at_failed; then
   66147 
   66148   echo 1 > $at_status_file
   66149   exit 1
   66150 fi
   66151 
   66152 $at_traceon
   66153 
   66154 $at_traceoff
   66155 echo "glr-regression.at:1065: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr12 glr-regr12.c \$LIBS"
   66156 echo glr-regression.at:1065 >$at_check_line_file
   66157 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr12 glr-regr12.c $LIBS ) >$at_stdout 2>$at_stder1
   66158 at_status=$?
   66159 grep '^ *+' $at_stder1 >&2
   66160 grep -v '^ *+' $at_stder1 >$at_stderr
   66161 at_failed=false
   66162 echo stderr:; cat $at_stderr
   66163 echo stdout:; cat $at_stdout
   66164 case $at_status in
   66165    77) echo 77 > $at_status_file
   66166             exit 77;;
   66167    0) ;;
   66168    *) echo "glr-regression.at:1065: exit code was $at_status, expected 0"
   66169       at_failed=:;;
   66170 esac
   66171 if $at_failed; then
   66172 
   66173   echo 1 > $at_status_file
   66174   exit 1
   66175 fi
   66176 
   66177 $at_traceon
   66178 
   66179 
   66180 $at_traceoff
   66181 echo "glr-regression.at:1067: ./glr-regr12"
   66182 echo glr-regression.at:1067 >$at_check_line_file
   66183 ( $at_traceon; ./glr-regr12 ) >$at_stdout 2>$at_stder1
   66184 at_status=$?
   66185 grep '^ *+' $at_stder1 >&2
   66186 grep -v '^ *+' $at_stder1 >$at_stderr
   66187 at_failed=false
   66188 $at_diff $at_devnull $at_stderr || at_failed=:
   66189 $at_diff $at_devnull $at_stdout || at_failed=:
   66190 case $at_status in
   66191    77) echo 77 > $at_status_file
   66192             exit 77;;
   66193    0) ;;
   66194    *) echo "glr-regression.at:1067: exit code was $at_status, expected 0"
   66195       at_failed=:;;
   66196 esac
   66197 if $at_failed; then
   66198 
   66199   echo 1 > $at_status_file
   66200   exit 1
   66201 fi
   66202 
   66203 $at_traceon
   66204 
   66205 
   66206       $at_traceoff
   66207       $at_times_p && times >$at_times_file
   66208     ) 5>&1 2>&1 | eval $at_tee_pipe
   66209     at_status=`cat $at_status_file`
   66210     ;;
   66211 
   66212   154 ) # 154. glr-regression.at:1078: Incorrect lookahead during deterministic GLR
   66213     at_setup_line='glr-regression.at:1078'
   66214     at_desc='Incorrect lookahead during deterministic GLR'
   66215     $at_quiet $ECHO_N "154: Incorrect lookahead during deterministic GLR $ECHO_C"
   66216     at_xfail=no
   66217     (
   66218       echo "154. glr-regression.at:1078: testing ..."
   66219       $at_traceon
   66220 
   66221 
   66222 cat >glr-regr13.y <<'_ATEOF'
   66223 %{
   66224 #ifdef HAVE_CONFIG_H
   66225 # include <config.h>
   66226   /* We don't need perfect functions for these tests. */
   66227 # undef malloc
   66228 # undef memcmp
   66229 # undef realloc
   66230 #endif
   66231 %}
   66232 
   66233 
   66234 /* Tests:
   66235      - Defaulted state with initial yychar: yychar == YYEMPTY.
   66236      - Nondefaulted state: yychar != YYEMPTY.
   66237      - Defaulted state after lookahead: yychar != YYEMPTY.
   66238      - Defaulted state after shift: yychar == YYEMPTY.
   66239      - User action changing the lookahead.  */
   66240 
   66241 %{
   66242   #include <stdio.h>
   66243   static void yyerror (char const *);
   66244   static int yylex (void);
   66245   static void print_look_ahead (char const *);
   66246   #define USE(value)
   66247 %}
   66248 
   66249 %union { char value; }
   66250 %type <value> 'a' 'b'
   66251 %glr-parser
   66252 %locations
   66253 
   66254 %%
   66255 
   66256 start:
   66257   defstate_init defstate_shift 'b' change_lookahead 'a' {
   66258     USE ($3);
   66259     print_look_ahead ("start <- defstate_init defstate_shift 'b'");
   66260   }
   66261   ;
   66262 defstate_init:
   66263   {
   66264     print_look_ahead ("defstate_init <- empty string");
   66265   }
   66266   ;
   66267 defstate_shift:
   66268   nondefstate defstate_look 'a' {
   66269     USE ($3);
   66270     print_look_ahead ("defstate_shift <- nondefstate defstate_look 'a'");
   66271   }
   66272   ;
   66273 defstate_look:
   66274   {
   66275     print_look_ahead ("defstate_look <- empty string");
   66276   }
   66277   ;
   66278 nondefstate:
   66279   {
   66280     print_look_ahead ("nondefstate <- empty string");
   66281   }
   66282   | 'b' {
   66283     USE ($1);
   66284     print_look_ahead ("nondefstate <- 'b'");
   66285   }
   66286   ;
   66287 change_lookahead:
   66288   {
   66289     yychar = 'a';
   66290   }
   66291   ;
   66292 
   66293 %%
   66294 
   66295 static void
   66296 yyerror (char const *msg)
   66297 {
   66298   fprintf (stderr, "%s\n", msg);
   66299 }
   66300 
   66301 static int
   66302 yylex (void)
   66303 {
   66304   static char const *input = "ab";
   66305   static int i = 0;
   66306   yylloc.first_line = yylloc.last_line = 1;
   66307   yylloc.first_column = yylloc.last_column = i + 1;
   66308   yylval.value = input[i] + 'A' - 'a';
   66309   return input[i++];
   66310 }
   66311 
   66312 static void
   66313 print_look_ahead (char const *reduction)
   66314 {
   66315   printf ("%s:\n  yychar=", reduction);
   66316   if (yychar == YYEMPTY)
   66317     printf ("YYEMPTY");
   66318   else if (yychar == YYEOF)
   66319     printf ("YYEOF");
   66320   else
   66321     {
   66322       printf ("'%c', yylval='", yychar);
   66323       if (yylval.value > ' ')
   66324 	printf ("%c", yylval.value);
   66325       printf ("', yylloc=(%d,%d),(%d,%d)",
   66326 	      yylloc.first_line, yylloc.first_column,
   66327 	      yylloc.last_line, yylloc.last_column);
   66328     }
   66329   printf ("\n");
   66330 }
   66331 
   66332 int
   66333 main (void)
   66334 {
   66335   yychar = '#'; /* Not a token in the grammar.  */
   66336   yylval.value = '!';
   66337   return yyparse ();
   66338 }
   66339 _ATEOF
   66340 
   66341 
   66342 
   66343 $at_traceoff
   66344 echo "glr-regression.at:1189: bison -o glr-regr13.c glr-regr13.y"
   66345 echo glr-regression.at:1189 >$at_check_line_file
   66346 ( $at_traceon; bison -o glr-regr13.c glr-regr13.y ) >$at_stdout 2>$at_stder1
   66347 at_status=$?
   66348 grep '^ *+' $at_stder1 >&2
   66349 grep -v '^ *+' $at_stder1 >$at_stderr
   66350 at_failed=false
   66351 $at_diff $at_devnull $at_stderr || at_failed=:
   66352 $at_diff $at_devnull $at_stdout || at_failed=:
   66353 case $at_status in
   66354    77) echo 77 > $at_status_file
   66355             exit 77;;
   66356    0) ;;
   66357    *) echo "glr-regression.at:1189: exit code was $at_status, expected 0"
   66358       at_failed=:;;
   66359 esac
   66360 if $at_failed; then
   66361 
   66362   echo 1 > $at_status_file
   66363   exit 1
   66364 fi
   66365 
   66366 $at_traceon
   66367 
   66368 $at_traceoff
   66369 echo "glr-regression.at:1190: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr13 glr-regr13.c \$LIBS"
   66370 echo glr-regression.at:1190 >$at_check_line_file
   66371 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr13 glr-regr13.c $LIBS ) >$at_stdout 2>$at_stder1
   66372 at_status=$?
   66373 grep '^ *+' $at_stder1 >&2
   66374 grep -v '^ *+' $at_stder1 >$at_stderr
   66375 at_failed=false
   66376 echo stderr:; cat $at_stderr
   66377 echo stdout:; cat $at_stdout
   66378 case $at_status in
   66379    77) echo 77 > $at_status_file
   66380             exit 77;;
   66381    0) ;;
   66382    *) echo "glr-regression.at:1190: exit code was $at_status, expected 0"
   66383       at_failed=:;;
   66384 esac
   66385 if $at_failed; then
   66386 
   66387   echo 1 > $at_status_file
   66388   exit 1
   66389 fi
   66390 
   66391 $at_traceon
   66392 
   66393 
   66394 $at_traceoff
   66395 echo "glr-regression.at:1203: ./glr-regr13"
   66396 echo glr-regression.at:1203 >$at_check_line_file
   66397 ( $at_traceon; ./glr-regr13 ) >$at_stdout 2>$at_stder1
   66398 at_status=$?
   66399 grep '^ *+' $at_stder1 >&2
   66400 grep -v '^ *+' $at_stder1 >$at_stderr
   66401 at_failed=false
   66402 $at_diff $at_devnull $at_stderr || at_failed=:
   66403 echo >>$at_stdout; echo "defstate_init <- empty string:
   66404   yychar=YYEMPTY
   66405 nondefstate <- empty string:
   66406   yychar='a', yylval='A', yylloc=(1,1),(1,1)
   66407 defstate_look <- empty string:
   66408   yychar='a', yylval='A', yylloc=(1,1),(1,1)
   66409 defstate_shift <- nondefstate defstate_look 'a':
   66410   yychar=YYEMPTY
   66411 start <- defstate_init defstate_shift 'b':
   66412   yychar=YYEMPTY
   66413 " | $at_diff - $at_stdout || at_failed=:
   66414 case $at_status in
   66415    77) echo 77 > $at_status_file
   66416             exit 77;;
   66417    0) ;;
   66418    *) echo "glr-regression.at:1203: exit code was $at_status, expected 0"
   66419       at_failed=:;;
   66420 esac
   66421 if $at_failed; then
   66422 
   66423   echo 1 > $at_status_file
   66424   exit 1
   66425 fi
   66426 
   66427 $at_traceon
   66428 
   66429 
   66430       $at_traceoff
   66431       $at_times_p && times >$at_times_file
   66432     ) 5>&1 2>&1 | eval $at_tee_pipe
   66433     at_status=`cat $at_status_file`
   66434     ;;
   66435 
   66436   155 ) # 155. glr-regression.at:1212: Incorrect lookahead during nondeterministic GLR
   66437     at_setup_line='glr-regression.at:1212'
   66438     at_desc='Incorrect lookahead during nondeterministic GLR'
   66439     $at_quiet $ECHO_N "155: Incorrect lookahead during nondeterministic GLR$ECHO_C"
   66440     at_xfail=no
   66441     (
   66442       echo "155. glr-regression.at:1212: testing ..."
   66443       $at_traceon
   66444 
   66445 
   66446 cat >glr-regr14.y <<'_ATEOF'
   66447 %{
   66448 #ifdef HAVE_CONFIG_H
   66449 # include <config.h>
   66450   /* We don't need perfect functions for these tests. */
   66451 # undef malloc
   66452 # undef memcmp
   66453 # undef realloc
   66454 #endif
   66455 %}
   66456 
   66457 
   66458 /* Tests:
   66459      - Conflicting actions (split-off parse, which copies lookahead need,
   66460        which is necessarily yytrue) and nonconflicting actions (non-split-off
   66461        parse) for nondefaulted state: yychar != YYEMPTY.
   66462      - Merged deferred actions (lookahead need and RHS from different stack
   66463        than the target state) and nonmerged deferred actions (same stack).
   66464      - Defaulted state after lookahead: yychar != YYEMPTY.
   66465      - Defaulted state after shift: yychar == YYEMPTY.
   66466      - yychar != YYEMPTY but lookahead need is yyfalse (a previous stack has
   66467        seen the lookahead but current stack has not).
   66468      - Exceeding stack capacity (stack explosion), and thus reallocating
   66469        lookahead need array.
   66470    Note that it does not seem possible to see the initial yychar value during
   66471    nondeterministic operation since:
   66472      - In order to preserve the initial yychar, only defaulted states may be
   66473        entered.
   66474      - If only defaulted states are entered, there are no conflicts, so
   66475        nondeterministic operation does not start.  */
   66476 
   66477 %union { char value; }
   66478 
   66479 %{
   66480   #include <stdio.h>
   66481   static void yyerror (char const *);
   66482   static int yylex (void);
   66483   static void print_look_ahead (char const *);
   66484   static char merge (union YYSTYPE, union YYSTYPE);
   66485   #define USE(value)
   66486 %}
   66487 
   66488 %type <value> 'a' 'b' 'c' 'd' stack_explosion
   66489 %glr-parser
   66490 %locations
   66491 
   66492 %%
   66493 
   66494 start:
   66495   merge 'c' stack_explosion {
   66496     USE ($2); USE ($3);
   66497     print_look_ahead ("start <- merge 'c' stack_explosion");
   66498   }
   66499   ;
   66500 
   66501 /* When merging the 2 deferred actions, the lookahead needs are different.  */
   66502 merge:
   66503   nonconflict1 'a' 'b' nonconflict2 %dprec 1 {
   66504     USE ($2); USE ($3);
   66505     print_look_ahead ("merge <- nonconflict1 'a' 'b' nonconflict2");
   66506   }
   66507   | conflict defstate_look 'a' nonconflict2 'b' defstate_shift %dprec 2 {
   66508     USE ($3); USE ($5);
   66509     print_look_ahead ("merge <- conflict defstate_look 'a' nonconflict2 'b'"
   66510 		      " defstate_shift");
   66511   }
   66512   ;
   66513 
   66514 nonconflict1:
   66515   {
   66516     print_look_ahead ("nonconflict1 <- empty string");
   66517   }
   66518   ;
   66519 nonconflict2:
   66520   {
   66521     print_look_ahead ("nonconflict2 <- empty string");
   66522   }
   66523   | 'a' {
   66524     USE ($1);
   66525     print_look_ahead ("nonconflict2 <- 'a'");
   66526   }
   66527   ;
   66528 conflict:
   66529   {
   66530     print_look_ahead ("conflict <- empty string");
   66531   }
   66532   ;
   66533 defstate_look:
   66534   {
   66535     print_look_ahead ("defstate_look <- empty string");
   66536   }
   66537   ;
   66538 
   66539 /* yychar != YYEMPTY but lookahead need is yyfalse.  */
   66540 defstate_shift:
   66541   {
   66542     print_look_ahead ("defstate_shift <- empty string");
   66543   }
   66544   ;
   66545 
   66546 stack_explosion:
   66547   { $$ = '\0'; }
   66548   | alt1 stack_explosion %merge<merge> { $$ = $2; }
   66549   | alt2 stack_explosion %merge<merge> { $$ = $2; }
   66550   | alt3 stack_explosion %merge<merge> { $$ = $2; }
   66551   ;
   66552 alt1:
   66553   'd' no_look {
   66554     USE ($1);
   66555     if (yychar != 'd' && yychar != YYEOF)
   66556       {
   66557 	fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
   66558       }
   66559   }
   66560   ;
   66561 alt2:
   66562   'd' no_look {
   66563     USE ($1);
   66564     if (yychar != 'd' && yychar != YYEOF)
   66565       {
   66566 	fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
   66567       }
   66568   }
   66569   ;
   66570 alt3:
   66571   'd' no_look {
   66572     USE ($1);
   66573     if (yychar != 'd' && yychar != YYEOF)
   66574       {
   66575 	fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
   66576       }
   66577   }
   66578   ;
   66579 no_look:
   66580   {
   66581     if (yychar != YYEMPTY)
   66582       {
   66583 	fprintf (stderr,
   66584 		 "Found lookahead where shouldn't during stack explosion.\n");
   66585       }
   66586   }
   66587   ;
   66588 
   66589 %%
   66590 
   66591 static void
   66592 yyerror (char const *msg)
   66593 {
   66594   fprintf (stderr, "%s\n", msg);
   66595 }
   66596 
   66597 static int
   66598 yylex (void)
   66599 {
   66600   static char const *input = "abcdddd";
   66601   static int i = 0;
   66602   yylloc.first_line = yylloc.last_line = 1;
   66603   yylloc.first_column = yylloc.last_column = i + 1;
   66604   yylval.value = input[i] + 'A' - 'a';
   66605   return input[i++];
   66606 }
   66607 
   66608 static void
   66609 print_look_ahead (char const *reduction)
   66610 {
   66611   printf ("%s:\n  yychar=", reduction);
   66612   if (yychar == YYEMPTY)
   66613     printf ("YYEMPTY");
   66614   else if (yychar == YYEOF)
   66615     printf ("YYEOF");
   66616   else
   66617     {
   66618       printf ("'%c', yylval='", yychar);
   66619       if (yylval.value > ' ')
   66620 	printf ("%c", yylval.value);
   66621       printf ("', yylloc=(%d,%d),(%d,%d)",
   66622 	      yylloc.first_line, yylloc.first_column,
   66623 	      yylloc.last_line, yylloc.last_column);
   66624     }
   66625   printf ("\n");
   66626 }
   66627 
   66628 static char
   66629 merge (union YYSTYPE s1, union YYSTYPE s2)
   66630 {
   66631   char dummy = s1.value + s2.value;
   66632   return dummy;
   66633 }
   66634 
   66635 int
   66636 main (void)
   66637 {
   66638   yychar = '#'; /* Not a token in the grammar.  */
   66639   yylval.value = '!';
   66640   return yyparse ();
   66641 }
   66642 _ATEOF
   66643 
   66644 
   66645 
   66646 $at_traceoff
   66647 echo "glr-regression.at:1404: bison -o glr-regr14.c glr-regr14.y"
   66648 echo glr-regression.at:1404 >$at_check_line_file
   66649 ( $at_traceon; bison -o glr-regr14.c glr-regr14.y ) >$at_stdout 2>$at_stder1
   66650 at_status=$?
   66651 grep '^ *+' $at_stder1 >&2
   66652 grep -v '^ *+' $at_stder1 >$at_stderr
   66653 at_failed=false
   66654 echo >>$at_stderr; echo "glr-regr14.y: conflicts: 3 reduce/reduce
   66655 " | $at_diff - $at_stderr || at_failed=:
   66656 $at_diff $at_devnull $at_stdout || at_failed=:
   66657 case $at_status in
   66658    77) echo 77 > $at_status_file
   66659             exit 77;;
   66660    0) ;;
   66661    *) echo "glr-regression.at:1404: exit code was $at_status, expected 0"
   66662       at_failed=:;;
   66663 esac
   66664 if $at_failed; then
   66665 
   66666   echo 1 > $at_status_file
   66667   exit 1
   66668 fi
   66669 
   66670 $at_traceon
   66671 
   66672 $at_traceoff
   66673 echo "glr-regression.at:1405: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr14 glr-regr14.c \$LIBS"
   66674 echo glr-regression.at:1405 >$at_check_line_file
   66675 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr14 glr-regr14.c $LIBS ) >$at_stdout 2>$at_stder1
   66676 at_status=$?
   66677 grep '^ *+' $at_stder1 >&2
   66678 grep -v '^ *+' $at_stder1 >$at_stderr
   66679 at_failed=false
   66680 echo stderr:; cat $at_stderr
   66681 echo stdout:; cat $at_stdout
   66682 case $at_status in
   66683    77) echo 77 > $at_status_file
   66684             exit 77;;
   66685    0) ;;
   66686    *) echo "glr-regression.at:1405: exit code was $at_status, expected 0"
   66687       at_failed=:;;
   66688 esac
   66689 if $at_failed; then
   66690 
   66691   echo 1 > $at_status_file
   66692   exit 1
   66693 fi
   66694 
   66695 $at_traceon
   66696 
   66697 
   66698 $at_traceoff
   66699 echo "glr-regression.at:1420: ./glr-regr14"
   66700 echo glr-regression.at:1420 >$at_check_line_file
   66701 ( $at_traceon; ./glr-regr14 ) >$at_stdout 2>$at_stder1
   66702 at_status=$?
   66703 grep '^ *+' $at_stder1 >&2
   66704 grep -v '^ *+' $at_stder1 >$at_stderr
   66705 at_failed=false
   66706 $at_diff $at_devnull $at_stderr || at_failed=:
   66707 echo >>$at_stdout; echo "conflict <- empty string:
   66708   yychar='a', yylval='A', yylloc=(1,1),(1,1)
   66709 defstate_look <- empty string:
   66710   yychar='a', yylval='A', yylloc=(1,1),(1,1)
   66711 nonconflict2 <- empty string:
   66712   yychar='b', yylval='B', yylloc=(1,2),(1,2)
   66713 defstate_shift <- empty string:
   66714   yychar=YYEMPTY
   66715 merge <- conflict defstate_look 'a' nonconflict2 'b' defstate_shift:
   66716   yychar=YYEMPTY
   66717 start <- merge 'c' stack_explosion:
   66718   yychar=YYEOF
   66719 " | $at_diff - $at_stdout || at_failed=:
   66720 case $at_status in
   66721    77) echo 77 > $at_status_file
   66722             exit 77;;
   66723    0) ;;
   66724    *) echo "glr-regression.at:1420: exit code was $at_status, expected 0"
   66725       at_failed=:;;
   66726 esac
   66727 if $at_failed; then
   66728 
   66729   echo 1 > $at_status_file
   66730   exit 1
   66731 fi
   66732 
   66733 $at_traceon
   66734 
   66735 
   66736       $at_traceoff
   66737       $at_times_p && times >$at_times_file
   66738     ) 5>&1 2>&1 | eval $at_tee_pipe
   66739     at_status=`cat $at_status_file`
   66740     ;;
   66741 
   66742   156 ) # 156. glr-regression.at:1429: Leaked semantic values when reporting ambiguity
   66743     at_setup_line='glr-regression.at:1429'
   66744     at_desc='Leaked semantic values when reporting ambiguity'
   66745     $at_quiet $ECHO_N "156: Leaked semantic values when reporting ambiguity$ECHO_C"
   66746     at_xfail=no
   66747     (
   66748       echo "156. glr-regression.at:1429: testing ..."
   66749       $at_traceon
   66750 
   66751 
   66752 cat >glr-regr15.y <<'_ATEOF'
   66753 %{
   66754 #ifdef HAVE_CONFIG_H
   66755 # include <config.h>
   66756   /* We don't need perfect functions for these tests. */
   66757 # undef malloc
   66758 # undef memcmp
   66759 # undef realloc
   66760 #endif
   66761 %}
   66762 
   66763 
   66764 %glr-parser
   66765 %destructor { parent_rhs_before_value = 0; } parent_rhs_before
   66766 
   66767 %{
   66768 # include <stdlib.h>
   66769   static void yyerror (char const *);
   66770   static int yylex (void);
   66771   static int parent_rhs_before_value = 0;
   66772 # define USE(val)
   66773 %}
   66774 
   66775 %%
   66776 
   66777 start:
   66778   alt1 %dprec 1
   66779   | alt2 %dprec 2
   66780   ;
   66781 
   66782 /* This stack must be merged into the other stacks *last* (added at the
   66783    beginning of the semantic options list) so that yyparse will choose to clean
   66784    it up rather than the tree for which some semantic actions have been
   66785    performed.  Thus, if yyreportAmbiguity longjmp's to yyparse, the values from
   66786    those other trees are not cleaned up.  */
   66787 alt1: ;
   66788 
   66789 alt2:
   66790   parent_rhs_before ambiguity {
   66791     USE ($1);
   66792     parent_rhs_before_value = 0;
   66793   }
   66794   ;
   66795 
   66796 parent_rhs_before:
   66797   {
   66798     USE ($$);
   66799     parent_rhs_before_value = 1;
   66800   }
   66801   ;
   66802 
   66803 ambiguity: ambiguity1 | ambiguity2 ;
   66804 ambiguity1: ;
   66805 ambiguity2: ;
   66806 
   66807 %%
   66808 
   66809 static void
   66810 yyerror (char const *msg)
   66811 {
   66812   fprintf (stderr, "%s\n", msg);
   66813 }
   66814 
   66815 static int
   66816 yylex (void)
   66817 {
   66818   return 0;
   66819 }
   66820 
   66821 int
   66822 main (void)
   66823 {
   66824   int exit_status = yyparse () != 1;
   66825   if (parent_rhs_before_value)
   66826     {
   66827       fprintf (stderr, "`parent_rhs_before' destructor not called.\n");
   66828       exit_status = 1;
   66829     }
   66830   return exit_status;
   66831 }
   66832 _ATEOF
   66833 
   66834 
   66835 
   66836 $at_traceoff
   66837 echo "glr-regression.at:1505: bison -o glr-regr15.c glr-regr15.y"
   66838 echo glr-regression.at:1505 >$at_check_line_file
   66839 ( $at_traceon; bison -o glr-regr15.c glr-regr15.y ) >$at_stdout 2>$at_stder1
   66840 at_status=$?
   66841 grep '^ *+' $at_stder1 >&2
   66842 grep -v '^ *+' $at_stder1 >$at_stderr
   66843 at_failed=false
   66844 echo >>$at_stderr; echo "glr-regr15.y: conflicts: 2 reduce/reduce
   66845 " | $at_diff - $at_stderr || at_failed=:
   66846 $at_diff $at_devnull $at_stdout || at_failed=:
   66847 case $at_status in
   66848    77) echo 77 > $at_status_file
   66849             exit 77;;
   66850    0) ;;
   66851    *) echo "glr-regression.at:1505: exit code was $at_status, expected 0"
   66852       at_failed=:;;
   66853 esac
   66854 if $at_failed; then
   66855 
   66856   echo 1 > $at_status_file
   66857   exit 1
   66858 fi
   66859 
   66860 $at_traceon
   66861 
   66862 $at_traceoff
   66863 echo "glr-regression.at:1506: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr15 glr-regr15.c \$LIBS"
   66864 echo glr-regression.at:1506 >$at_check_line_file
   66865 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr15 glr-regr15.c $LIBS ) >$at_stdout 2>$at_stder1
   66866 at_status=$?
   66867 grep '^ *+' $at_stder1 >&2
   66868 grep -v '^ *+' $at_stder1 >$at_stderr
   66869 at_failed=false
   66870 echo stderr:; cat $at_stderr
   66871 echo stdout:; cat $at_stdout
   66872 case $at_status in
   66873    77) echo 77 > $at_status_file
   66874             exit 77;;
   66875    0) ;;
   66876    *) echo "glr-regression.at:1506: exit code was $at_status, expected 0"
   66877       at_failed=:;;
   66878 esac
   66879 if $at_failed; then
   66880 
   66881   echo 1 > $at_status_file
   66882   exit 1
   66883 fi
   66884 
   66885 $at_traceon
   66886 
   66887 
   66888 $at_traceoff
   66889 echo "glr-regression.at:1510: ./glr-regr15"
   66890 echo glr-regression.at:1510 >$at_check_line_file
   66891 ( $at_traceon; ./glr-regr15 ) >$at_stdout 2>$at_stder1
   66892 at_status=$?
   66893 grep '^ *+' $at_stder1 >&2
   66894 grep -v '^ *+' $at_stder1 >$at_stderr
   66895 at_failed=false
   66896 echo >>$at_stderr; echo "syntax is ambiguous
   66897 " | $at_diff - $at_stderr || at_failed=:
   66898 $at_diff $at_devnull $at_stdout || at_failed=:
   66899 case $at_status in
   66900    77) echo 77 > $at_status_file
   66901             exit 77;;
   66902    0) ;;
   66903    *) echo "glr-regression.at:1510: exit code was $at_status, expected 0"
   66904       at_failed=:;;
   66905 esac
   66906 if $at_failed; then
   66907 
   66908   echo 1 > $at_status_file
   66909   exit 1
   66910 fi
   66911 
   66912 $at_traceon
   66913 
   66914 
   66915       $at_traceoff
   66916       $at_times_p && times >$at_times_file
   66917     ) 5>&1 2>&1 | eval $at_tee_pipe
   66918     at_status=`cat $at_status_file`
   66919     ;;
   66920 
   66921   157 ) # 157. glr-regression.at:1519: Leaked lookahead after nondeterministic parse syntax error
   66922     at_setup_line='glr-regression.at:1519'
   66923     at_desc='Leaked lookahead after nondeterministic parse syntax error'
   66924     $at_quiet $ECHO_N "157: Leaked lookahead after nondeterministic parse syntax error$ECHO_C"
   66925     at_xfail=no
   66926     (
   66927       echo "157. glr-regression.at:1519: testing ..."
   66928       $at_traceon
   66929 
   66930 cat >glr-regr16.y <<'_ATEOF'
   66931 %{
   66932 #ifdef HAVE_CONFIG_H
   66933 # include <config.h>
   66934   /* We don't need perfect functions for these tests. */
   66935 # undef malloc
   66936 # undef memcmp
   66937 # undef realloc
   66938 #endif
   66939 %}
   66940 
   66941 
   66942 %glr-parser
   66943 %destructor { lookahead_value = 0; } 'b'
   66944 
   66945 %{
   66946 # include <stdlib.h>
   66947   static void yyerror (char const *);
   66948   static int yylex (void);
   66949   static int lookahead_value = 0;
   66950 # define USE(val)
   66951 %}
   66952 
   66953 %%
   66954 
   66955 start: alt1 'a' | alt2 'a' ;
   66956 alt1: ;
   66957 alt2: ;
   66958 
   66959 %%
   66960 
   66961 static void
   66962 yyerror (char const *msg)
   66963 {
   66964   fprintf (stderr, "%s\n", msg);
   66965 }
   66966 
   66967 static int
   66968 yylex (void)
   66969 {
   66970   static char const *input = "ab";
   66971   if (*input == 'b')
   66972     lookahead_value = 1;
   66973   return *input++;
   66974 }
   66975 
   66976 int
   66977 main (void)
   66978 {
   66979   int exit_status = yyparse () != 1;
   66980   if (lookahead_value)
   66981     {
   66982       fprintf (stderr, "Lookahead destructor not called.\n");
   66983       exit_status = 1;
   66984     }
   66985   return exit_status;
   66986 }
   66987 _ATEOF
   66988 
   66989 
   66990 
   66991 $at_traceoff
   66992 echo "glr-regression.at:1571: bison -o glr-regr16.c glr-regr16.y"
   66993 echo glr-regression.at:1571 >$at_check_line_file
   66994 ( $at_traceon; bison -o glr-regr16.c glr-regr16.y ) >$at_stdout 2>$at_stder1
   66995 at_status=$?
   66996 grep '^ *+' $at_stder1 >&2
   66997 grep -v '^ *+' $at_stder1 >$at_stderr
   66998 at_failed=false
   66999 echo >>$at_stderr; echo "glr-regr16.y: conflicts: 1 reduce/reduce
   67000 " | $at_diff - $at_stderr || at_failed=:
   67001 $at_diff $at_devnull $at_stdout || at_failed=:
   67002 case $at_status in
   67003    77) echo 77 > $at_status_file
   67004             exit 77;;
   67005    0) ;;
   67006    *) echo "glr-regression.at:1571: exit code was $at_status, expected 0"
   67007       at_failed=:;;
   67008 esac
   67009 if $at_failed; then
   67010 
   67011   echo 1 > $at_status_file
   67012   exit 1
   67013 fi
   67014 
   67015 $at_traceon
   67016 
   67017 $at_traceoff
   67018 echo "glr-regression.at:1572: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr16 glr-regr16.c \$LIBS"
   67019 echo glr-regression.at:1572 >$at_check_line_file
   67020 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr16 glr-regr16.c $LIBS ) >$at_stdout 2>$at_stder1
   67021 at_status=$?
   67022 grep '^ *+' $at_stder1 >&2
   67023 grep -v '^ *+' $at_stder1 >$at_stderr
   67024 at_failed=false
   67025 echo stderr:; cat $at_stderr
   67026 echo stdout:; cat $at_stdout
   67027 case $at_status in
   67028    77) echo 77 > $at_status_file
   67029             exit 77;;
   67030    0) ;;
   67031    *) echo "glr-regression.at:1572: exit code was $at_status, expected 0"
   67032       at_failed=:;;
   67033 esac
   67034 if $at_failed; then
   67035 
   67036   echo 1 > $at_status_file
   67037   exit 1
   67038 fi
   67039 
   67040 $at_traceon
   67041 
   67042 
   67043 $at_traceoff
   67044 echo "glr-regression.at:1576: ./glr-regr16"
   67045 echo glr-regression.at:1576 >$at_check_line_file
   67046 ( $at_traceon; ./glr-regr16 ) >$at_stdout 2>$at_stder1
   67047 at_status=$?
   67048 grep '^ *+' $at_stder1 >&2
   67049 grep -v '^ *+' $at_stder1 >$at_stderr
   67050 at_failed=false
   67051 echo >>$at_stderr; echo "syntax error
   67052 " | $at_diff - $at_stderr || at_failed=:
   67053 $at_diff $at_devnull $at_stdout || at_failed=:
   67054 case $at_status in
   67055    77) echo 77 > $at_status_file
   67056             exit 77;;
   67057    0) ;;
   67058    *) echo "glr-regression.at:1576: exit code was $at_status, expected 0"
   67059       at_failed=:;;
   67060 esac
   67061 if $at_failed; then
   67062 
   67063   echo 1 > $at_status_file
   67064   exit 1
   67065 fi
   67066 
   67067 $at_traceon
   67068 
   67069 
   67070       $at_traceoff
   67071       $at_times_p && times >$at_times_file
   67072     ) 5>&1 2>&1 | eval $at_tee_pipe
   67073     at_status=`cat $at_status_file`
   67074     ;;
   67075 
   67076   158 ) # 158. glr-regression.at:1585: Uninitialized location when reporting ambiguity
   67077     at_setup_line='glr-regression.at:1585'
   67078     at_desc='Uninitialized location when reporting ambiguity'
   67079     $at_quiet $ECHO_N "158: Uninitialized location when reporting ambiguity$ECHO_C"
   67080     at_xfail=no
   67081     (
   67082       echo "158. glr-regression.at:1585: testing ..."
   67083       $at_traceon
   67084 
   67085 cat >glr-regr17.y <<'_ATEOF'
   67086 %{
   67087 #ifdef HAVE_CONFIG_H
   67088 # include <config.h>
   67089   /* We don't need perfect functions for these tests. */
   67090 # undef malloc
   67091 # undef memcmp
   67092 # undef realloc
   67093 #endif
   67094 %}
   67095 
   67096 
   67097 %glr-parser
   67098 %locations
   67099 %pure-parser
   67100 %error-verbose
   67101 
   67102 %union { int dummy; }
   67103 
   67104 %{
   67105   static void yyerror (YYLTYPE *, char const *);
   67106   static int yylex (YYSTYPE *, YYLTYPE *);
   67107 %}
   67108 
   67109 %initial-action {
   67110   @$.first_line = 1;
   67111   @$.first_column = 1;
   67112   @$.last_line = 1;
   67113   @$.last_column = 1;
   67114 }
   67115 
   67116 %%
   67117 
   67118 /* Tests the case of an empty RHS that has inherited the location of the
   67119    previous nonterminal, which is unresolved.  That location is reported as the
   67120    last position of the ambiguity.  */
   67121 start: ambig1 empty1 | ambig2 empty2 ;
   67122 
   67123 /* Tests multiple levels of yyresolveLocations recursion.  */
   67124 ambig1: sub_ambig1 | sub_ambig2 ;
   67125 ambig2: sub_ambig1 | sub_ambig2 ;
   67126 
   67127 /* Tests the case of a non-empty RHS as well as the case of an empty RHS that
   67128    has inherited the initial location.  The empty RHS's location is reported as
   67129    the first position in the ambiguity.  */
   67130 sub_ambig1: empty1 'a' 'b' ;
   67131 sub_ambig2: empty2 'a' 'b' ;
   67132 empty1: ;
   67133 empty2: ;
   67134 
   67135 %%
   67136 
   67137 static void
   67138 yyerror (YYLTYPE *locp, char const *msg)
   67139 {
   67140   fprintf (stderr, "Error at %d.%d-%d.%d: %s.\n", locp->first_line,
   67141 	   locp->first_column, locp->last_line, locp->last_column, msg);
   67142 }
   67143 
   67144 static int
   67145 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   67146 {
   67147   static char const input[] = "ab";
   67148   static char const *inputp = input;
   67149   lvalp->dummy = 0;
   67150   llocp->first_line = llocp->last_line = 2;
   67151   llocp->first_column = inputp - input + 1;
   67152   llocp->last_column = llocp->first_column + 1;
   67153   return *inputp++;
   67154 }
   67155 
   67156 int
   67157 main (void)
   67158 {
   67159   return yyparse () != 1;
   67160 }
   67161 _ATEOF
   67162 
   67163 
   67164 
   67165 $at_traceoff
   67166 echo "glr-regression.at:1656: bison -o glr-regr17.c glr-regr17.y"
   67167 echo glr-regression.at:1656 >$at_check_line_file
   67168 ( $at_traceon; bison -o glr-regr17.c glr-regr17.y ) >$at_stdout 2>$at_stder1
   67169 at_status=$?
   67170 grep '^ *+' $at_stder1 >&2
   67171 grep -v '^ *+' $at_stder1 >$at_stderr
   67172 at_failed=false
   67173 echo >>$at_stderr; echo "glr-regr17.y: conflicts: 3 reduce/reduce
   67174 " | $at_diff - $at_stderr || at_failed=:
   67175 $at_diff $at_devnull $at_stdout || at_failed=:
   67176 case $at_status in
   67177    77) echo 77 > $at_status_file
   67178             exit 77;;
   67179    0) ;;
   67180    *) echo "glr-regression.at:1656: exit code was $at_status, expected 0"
   67181       at_failed=:;;
   67182 esac
   67183 if $at_failed; then
   67184 
   67185   echo 1 > $at_status_file
   67186   exit 1
   67187 fi
   67188 
   67189 $at_traceon
   67190 
   67191 $at_traceoff
   67192 echo "glr-regression.at:1657: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o glr-regr17 glr-regr17.c \$LIBS"
   67193 echo glr-regression.at:1657 >$at_check_line_file
   67194 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o glr-regr17 glr-regr17.c $LIBS ) >$at_stdout 2>$at_stder1
   67195 at_status=$?
   67196 grep '^ *+' $at_stder1 >&2
   67197 grep -v '^ *+' $at_stder1 >$at_stderr
   67198 at_failed=false
   67199 echo stderr:; cat $at_stderr
   67200 echo stdout:; cat $at_stdout
   67201 case $at_status in
   67202    77) echo 77 > $at_status_file
   67203             exit 77;;
   67204    0) ;;
   67205    *) echo "glr-regression.at:1657: exit code was $at_status, expected 0"
   67206       at_failed=:;;
   67207 esac
   67208 if $at_failed; then
   67209 
   67210   echo 1 > $at_status_file
   67211   exit 1
   67212 fi
   67213 
   67214 $at_traceon
   67215 
   67216 
   67217 $at_traceoff
   67218 echo "glr-regression.at:1661: ./glr-regr17"
   67219 echo glr-regression.at:1661 >$at_check_line_file
   67220 ( $at_traceon; ./glr-regr17 ) >$at_stdout 2>$at_stder1
   67221 at_status=$?
   67222 grep '^ *+' $at_stder1 >&2
   67223 grep -v '^ *+' $at_stder1 >$at_stderr
   67224 at_failed=false
   67225 echo >>$at_stderr; echo "Error at 1.1-2.3: syntax is ambiguous.
   67226 " | $at_diff - $at_stderr || at_failed=:
   67227 $at_diff $at_devnull $at_stdout || at_failed=:
   67228 case $at_status in
   67229    77) echo 77 > $at_status_file
   67230             exit 77;;
   67231    0) ;;
   67232    *) echo "glr-regression.at:1661: exit code was $at_status, expected 0"
   67233       at_failed=:;;
   67234 esac
   67235 if $at_failed; then
   67236 
   67237   echo 1 > $at_status_file
   67238   exit 1
   67239 fi
   67240 
   67241 $at_traceon
   67242 
   67243 
   67244       $at_traceoff
   67245       $at_times_p && times >$at_times_file
   67246     ) 5>&1 2>&1 | eval $at_tee_pipe
   67247     at_status=`cat $at_status_file`
   67248     ;;
   67249 
   67250 
   67251   * )
   67252     echo "$as_me: no such test group: $at_group" >&2
   67253     continue
   67254     ;;
   67255   esac
   67256 
   67257   # Be sure to come back to the suite directory, in particular
   67258   # since below we might `rm' the group directory we are in currently.
   67259   cd $at_suite_dir
   67260 
   67261   case $at_group in
   67262     banner-*) ;;
   67263     *)
   67264       if test ! -f $at_check_line_file; then
   67265 	sed "s/^ */$as_me: warning: /" <<_ATEOF
   67266 	A failure happened in a test group before any test could be
   67267 	run. This means that test suite is improperly designed.  Please
   67268 	report this failure to <bug-bison@gnu.org>.
   67269 _ATEOF
   67270     	echo "$at_setup_line" >$at_check_line_file
   67271       fi
   67272       at_group_count=`expr 1 + $at_group_count`
   67273       $at_verbose $ECHO_N "$at_group. $at_setup_line: $ECHO_C"
   67274       echo $ECHO_N "$at_group. $at_setup_line: $ECHO_C" >> $at_group_log
   67275       case $at_xfail:$at_status in
   67276 	yes:0)
   67277 	    at_msg="UNEXPECTED PASS"
   67278 	    at_xpass_list="$at_xpass_list $at_group"
   67279 	    at_errexit=$at_errexit_p
   67280 	    ;;
   67281 	no:0)
   67282 	    at_msg="ok"
   67283 	    at_pass_list="$at_pass_list $at_group"
   67284 	    at_errexit=false
   67285 	    ;;
   67286 	*:77)
   67287 	    at_msg="skipped (`cat $at_check_line_file`)"
   67288 	    at_skip_list="$at_skip_list $at_group"
   67289 	    at_errexit=false
   67290 	    ;;
   67291 	yes:*)
   67292 	    at_msg="expected failure (`cat $at_check_line_file`)"
   67293 	    at_xfail_list="$at_xfail_list $at_group"
   67294 	    at_errexit=false
   67295 	    ;;
   67296 	no:*)
   67297 	    at_msg="FAILED (`cat $at_check_line_file`)"
   67298 	    at_fail_list="$at_fail_list $at_group"
   67299 	    at_errexit=$at_errexit_p
   67300 	    ;;
   67301       esac
   67302       echo $at_msg
   67303       at_log_msg="$at_group. $at_desc ($at_setup_line): $at_msg"
   67304       case $at_status in
   67305 	0|77)
   67306 	  # $at_times_file is only available if the group succeeded.
   67307 	  # We're not including the group log, so the success message
   67308 	  # is written in the global log separately.  But we also
   67309 	  # write to the group log in case they're using -d.
   67310 	  if test -f $at_times_file; then
   67311 	    at_log_msg="$at_log_msg	(`sed 1d $at_times_file`)"
   67312 	    rm -f $at_times_file
   67313           fi
   67314 	  echo "$at_log_msg" >> $at_group_log
   67315 	  echo "$at_log_msg" >&5
   67316 
   67317 	  # Cleanup the group directory, unless the user wants the files.
   67318 	  $at_debug_p || rm -rf $at_group_dir
   67319 	  ;;
   67320 	*)
   67321 	  # Upon failure, include the log into the testsuite's global
   67322 	  # log.  The failure message is written in the group log.  It
   67323 	  # is later included in the global log.
   67324 	  echo "$at_log_msg" >> $at_group_log
   67325 
   67326 	  # Upon failure, keep the group directory for autopsy, and
   67327 	  # create the debugging script.
   67328 	  {
   67329 	    echo "#! /bin/sh"
   67330 	    echo 'test "${ZSH_VERSION+set}" = set && alias -g '\''${1+"$@"}'\''='\''"$@"'\'''
   67331 	    echo "cd $at_dir"
   67332 	    echo 'exec ${CONFIG_SHELL-'"$SHELL"'}' "$0" \
   67333 	         '-v -d' "$at_debug_args" "$at_group" '${1+"$@"}'
   67334 	    echo 'exit 1'
   67335 	  } >$at_group_dir/run
   67336 	  chmod +x $at_group_dir/run
   67337 	  $at_errexit && break
   67338 	  ;;
   67339       esac
   67340       ;;
   67341   esac
   67342 done
   67343 
   67344 # Back to the top directory.
   67345 cd $at_dir
   67346 
   67347 # Compute the duration of the suite.
   67348 at_stop_date=`date`
   67349 at_stop_time=`(date +%s) 2>/dev/null`
   67350 echo "$as_me: ending at: $at_stop_date" >&5
   67351 at_duration_s=`(expr $at_stop_time - $at_start_time) 2>/dev/null`
   67352 at_duration_m=`(expr $at_duration_s / 60) 2>/dev/null`
   67353 at_duration_h=`(expr $at_duration_m / 60) 2>/dev/null`
   67354 at_duration_s=`(expr $at_duration_s % 60) 2>/dev/null`
   67355 at_duration_m=`(expr $at_duration_m % 60) 2>/dev/null`
   67356 at_duration="${at_duration_h}h ${at_duration_m}m ${at_duration_s}s"
   67357 if test "$at_duration" != "h m s"; then
   67358   echo "$as_me: test suite duration: $at_duration" >&5
   67359 fi
   67360 
   67361 # Wrap up the test suite with summary statistics.
   67362 at_skip_count=`set dummy $at_skip_list; shift; echo $#`
   67363 at_fail_count=`set dummy $at_fail_list; shift; echo $#`
   67364 at_xpass_count=`set dummy $at_xpass_list; shift; echo $#`
   67365 at_xfail_count=`set dummy $at_xfail_list; shift; echo $#`
   67366 
   67367 at_run_count=`expr $at_group_count - $at_skip_count`
   67368 at_unexpected_count=`expr $at_xpass_count + $at_fail_count`
   67369 at_total_fail_count=`expr $at_xfail_count + $at_fail_count`
   67370 
   67371 echo
   67372 cat <<\_ASBOX
   67373 ## ------------- ##
   67374 ## Test results. ##
   67375 ## ------------- ##
   67376 _ASBOX
   67377 echo
   67378 {
   67379   echo
   67380   cat <<\_ASBOX
   67381 ## ------------- ##
   67382 ## Test results. ##
   67383 ## ------------- ##
   67384 _ASBOX
   67385   echo
   67386 } >&5
   67387 
   67388 if test $at_run_count = 1; then
   67389   at_result="1 test"
   67390   at_were=was
   67391 else
   67392   at_result="$at_run_count tests"
   67393   at_were=were
   67394 fi
   67395 if $at_errexit_p && test $at_unexpected_count != 0; then
   67396   if test $at_xpass_count = 1; then
   67397     at_result="$at_result $at_were run, one passed"
   67398   else
   67399     at_result="$at_result $at_were run, one failed"
   67400   fi
   67401   at_result="$at_result unexpectedly and inhibited subsequent tests."
   67402 else
   67403   # Don't you just love exponential explosion of the number of cases?
   67404   case $at_xpass_count:$at_fail_count:$at_xfail_count in
   67405     # So far, so good.
   67406     0:0:0) at_result="$at_result $at_were successful." ;;
   67407     0:0:*) at_result="$at_result behaved as expected." ;;
   67408 
   67409     # Some unexpected failures
   67410     0:*:0) at_result="$at_result $at_were run,
   67411 $at_fail_count failed unexpectedly." ;;
   67412 
   67413     # Some failures, both expected and unexpected
   67414     0:*:1) at_result="$at_result $at_were run,
   67415 $at_total_fail_count failed ($at_xfail_count expected failure)." ;;
   67416     0:*:*) at_result="$at_result $at_were run,
   67417 $at_total_fail_count failed ($at_xfail_count expected failures)." ;;
   67418 
   67419     # No unexpected failures, but some xpasses
   67420     *:0:*) at_result="$at_result $at_were run,
   67421 $at_xpass_count passed unexpectedly." ;;
   67422 
   67423     # No expected failures, but failures and xpasses
   67424     *:1:0) at_result="$at_result $at_were run,
   67425 $at_unexpected_count did not behave as expected ($at_fail_count unexpected failure)." ;;
   67426     *:*:0) at_result="$at_result $at_were run,
   67427 $at_unexpected_count did not behave as expected ($at_fail_count unexpected failures)." ;;
   67428 
   67429     # All of them.
   67430     *:*:1) at_result="$at_result $at_were run,
   67431 $at_xpass_count passed unexpectedly,
   67432 $at_total_fail_count failed ($at_xfail_count expected failure)." ;;
   67433     *:*:*) at_result="$at_result $at_were run,
   67434 $at_xpass_count passed unexpectedly,
   67435 $at_total_fail_count failed ($at_xfail_count expected failures)." ;;
   67436   esac
   67437 
   67438   if test $at_skip_count = 0 && test $at_run_count -gt 1; then
   67439     at_result="All $at_result"
   67440   fi
   67441 fi
   67442 
   67443 # Now put skips in the mix.
   67444 case $at_skip_count in
   67445   0) ;;
   67446   1) at_result="$at_result
   67447 1 test was skipped." ;;
   67448   *) at_result="$at_result
   67449 $at_skip_count tests were skipped." ;;
   67450 esac
   67451 
   67452 if test $at_unexpected_count = 0; then
   67453   echo "$at_result"
   67454   echo "$at_result" >&5
   67455 else
   67456   echo "ERROR: $at_result" >&2
   67457   echo "ERROR: $at_result" >&5
   67458   {
   67459     echo
   67460     cat <<\_ASBOX
   67461 ## ------------------------ ##
   67462 ## Summary of the failures. ##
   67463 ## ------------------------ ##
   67464 _ASBOX
   67465 
   67466     # Summary of failed and skipped tests.
   67467     if test $at_fail_count != 0; then
   67468       echo "Failed tests:"
   67469       $SHELL $0 $at_fail_list --list
   67470       echo
   67471     fi
   67472     if test $at_skip_count != 0; then
   67473       echo "Skipped tests:"
   67474       $SHELL $0 $at_skip_list --list
   67475       echo
   67476     fi
   67477     if test $at_xpass_count != 0; then
   67478       echo "Unexpected passes:"
   67479       $SHELL $0 $at_xpass_list --list
   67480       echo
   67481     fi
   67482     if test $at_fail_count != 0; then
   67483       cat <<\_ASBOX
   67484 ## ---------------------- ##
   67485 ## Detailed failed tests. ##
   67486 ## ---------------------- ##
   67487 _ASBOX
   67488       echo
   67489       for at_group in $at_fail_list
   67490       do
   67491         # Normalize the test group number.
   67492         at_group_normalized=`expr "00000$at_group" : ".*\($at_format\)"`
   67493         # Create a fresh directory for the next test group, and enter.
   67494         at_group_dir=$at_suite_dir/$at_group_normalized
   67495         at_group_log=$at_group_dir/$as_me.log
   67496         cat $at_group_log
   67497         echo
   67498       done
   67499       echo
   67500     fi
   67501     if test -n "$at_top_srcdir"; then
   67502       sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
   67503 ## $at_top_builddir/config.log ##
   67504 _ASBOX
   67505       sed 's/^/| /' $at_top_builddir/config.log
   67506       echo
   67507     fi
   67508   } >&5
   67509 
   67510   sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
   67511 ## $as_me.log was created. ##
   67512 _ASBOX
   67513 
   67514   echo
   67515   echo "Please send \`$as_me.log' and all information you think might help:"
   67516   echo
   67517   echo "   To: <bug-bison (at] gnu.org>"
   67518   echo "   Subject: [GNU Bison 2.3] $as_me:$at_fail_list${at_fail_list:+ failed${at_xpass_list:+,}}$at_xpass_list${at_xpass_list:+ passed unexpectedly}"
   67519   echo
   67520   if test $at_debug_p = false; then
   67521     echo
   67522     echo 'You may investigate any problem if you feel able to do so, in which'
   67523     echo 'case the test suite provides a good starting point.'
   67524     echo
   67525   fi
   67526     exit 1
   67527 fi
   67528 
   67529 exit 0
   67530 
   67531 
   67532