#! /bin/sh


## --------------------- ##
## M4sh Initialization.  ##
## --------------------- ##

# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  emulate sh
  NULLCMD=:
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
  set -o posix
fi

# Name of the executable.
as_me=`echo "$0" |sed 's,\(.*[\\/]\+\)\?\([^\\/]\+\)[\\/]*,\2,'`

# Rewrite early, but we need PATH_SEPARATOR.
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
  echo "#! $SHELL" >conftest.sh
  echo  "exit 0"   >>conftest.sh
  chmod +x conftest.sh
  if (PATH=".;."; conftest.sh) >/dev/null 2>&1; then
    PATH_SEPARATOR=';'
  else
    PATH_SEPARATOR=:
  fi
  rm -f conftest.sh
fi

as_command='
  as_lineno_1=$LINENO
  as_lineno_2=$LINENO
  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
  test "x$as_lineno_1" != "x$as_lineno_2" &&
  test "x$as_lineno_3"  = "x$as_lineno_2"
'
if eval "$as_command"; then
  :
else
  # Find who we are.  Look in the path if we contain no path at all
  # relative or not.
  case $0 in
    *[\\/]* ) as_myself=$0 ;;
    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done

       ;;
  esac
  # We did not find ourselves, most probably we were run as `sh COMMAND'
  # in which case we are not to be found in the path.
  if test "x$as_myself" = x; then
    as_myself=$0
  fi
  if test ! -f "$as_myself"; then
    { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
   { (exit 1); exit 1; }; }
  fi
  case $CONFIG_SHELL in
  '')
    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in /bin:/usr/bin:$PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
  for as_base in sh bash ksh sh5; do
	 case $as_dir in
	 /*)
	   if ("$as_dir/$as_base" -c "$as_command") 2>/dev/null; then
	     CONFIG_SHELL=$as_dir/$as_base
	     export CONFIG_SHELL
	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
	   fi;;
	 esac
       done
done
;;
  esac
  if test ! -f "$as_me.lineno" ||
     test x`ls -1dt "$as_me.lineno" "$as_myself" 2>/dev/null | sed 1q` \
                != x"$as_me.lineno"; then
     # Be sure to write the pattern so that it doesn't replace itself:
     # it must not match itself.
     awk <$as_myself '
           /[$]LINENO/ { printf "%d:", NR }
                         { print }
         ' |
       sed '/[$]LINENO/s/^\([0-9][0-9]*\):\(.*\)[$]LINENO/\2\1/' \
         >$as_me.lineno
    chmod +x $as_me.lineno
  fi

  # Don't try to exec as it changes $[0], causing all sort of problems
  # (the dirname of $[0] is not the place where we might find the
  # original and so on.  Autoconf is especially sensible to this).
  . ./$as_me.lineno
  # Exit status is that of the last command.
  exit
fi


# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits

case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
  *c*,-n*) ECHO_N= ECHO_C='
' ECHO_T='	' ;;
  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
esac

if expr a : '\(a\)' >/dev/null 2>&1; then
  as_expr=expr
else
  as_expr=false
fi

rm -f conf$$ conf$$.exe conf$$.file
echo >conf$$.file
if ln -s conf$$.file conf$$ 2>/dev/null; then
  # We could just check for DJGPP; but this test a) works b) is more generic
  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
  if test -f conf$$.exe; then
    # Don't use ln at all; we don't have any links
    as_ln_s='cp -p'
  else
    as_ln_s='ln -s'
  fi
elif ln conf$$.file conf$$ 2>/dev/null; then
  as_ln_s=ln
else
  as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.file

as_executable_p="test -f"

# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"

# Sed expression to map a string onto a valid variable name.
as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"

# Support unset when possible.
if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
  as_unset=unset
else
  as_unset=false
fi


# NLS nuisances.
$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }

# IFS
# We need space, tab and new line, in precisely that order.
as_nl='
'
IFS=" 	$as_nl"

# CDPATH.
$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=$PATH_SEPARATOR; export CDPATH; }

SHELL=${CONFIG_SHELL-/bin/sh}

# How were we run?
at_cli_args=${1+"$@"}

# Load the config file.
for at_file in atconfig atlocal
do
  test -r $at_file || continue
  . ./$at_file || { echo "$as_me: error: invalid content: $at_file" >&2
   { (exit 1); exit 1; }; }
done

AUTOTEST_PATH=`echo $AUTOTEST_PATH | tr ':' $PATH_SEPARATOR`

# Not all shells have the 'times' builtin; the subshell is needed to make
# sure we discard the 'times: not found' message from the shell.
at_times=:
(times) >/dev/null 2>&1 && at_times=times

# CLI Arguments to pass to the debugging scripts.
at_debug_args=
# -e sets to true
at_errexit_p=false
# Shall we be verbose?
at_verbose=:
at_quiet=echo
# Shall we keep the debug scripts?  Must be `:' when test suite is
# run by a debug script, so that the script doesn't remove itself.
at_debug_p=false
# Display help message?
at_help_p=false
# List tests?
at_list_p=false
# Tests to run
at_tests=
# List of the tested programs.
at_tested='bison'
# List of the tests.
at_tests_all=' banner-1 1 2 3 4 5 6 7 8 9 10 11 12 banner-2 13 14 15 16 17 18 19 20 21 22 23 banner-3 24 25 26 27 28'
# Number of the last test.
at_last_test=28
# Description of all the tests.
at_help_all='1;output.at:38;Output files:  & -dv.;
2;output.at:40;Output files:  & -dv -o foo.c.;
3;output.at:42;Output files:  & -dv -o foo.tab.c.;
4;output.at:44;Output files:  & -dv -y.;
5;output.at:46;Output files:  & -dv -b bar.;
6;output.at:48;Output files:  & -dv -g -o foo.c.;
7;output.at:52;Output files: %defines %verbose & .;
8;output.at:54;Output files: %defines %verbose %yacc & .;
9;output.at:59;Output files: %defines %verbose & .;
10;output.at:62;Output files: %defines %verbose  & -o foo.c.;
11;output.at:66;Output files:  & --defines=foo.hpp -o foo.c++.;
12;output.at:70;Output files:  & -o foo.c++ --graph=foo.gph.;
13;calc.at:389;Calculator ;
14;calc.at:391;Calculator --defines;
15;calc.at:392;Calculator --locations;
16;calc.at:393;Calculator --name-prefix=calc;
17;calc.at:394;Calculator --verbose;
18;calc.at:395;Calculator --yacc;
19;calc.at:396;Calculator --yyerror-verbose;
20;calc.at:398;Calculator --locations --yyerror-verbose;
21;calc.at:400;Calculator --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose;
22;calc.at:402;Calculator --debug;
23;calc.at:403;Calculator --debug --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose;
24;regression.at:26;Duplicate string;
25;regression.at:52;%union and --defines;
26;regression.at:74;%union and C comments;
27;regression.at:97;Invalid input;
28;regression.at:116;Invalid CPP headers;
'
# List of the output files.
at_data_files='stdout expout at-* stderr experr foo.y foo.output foo.tab.c foo.tab.h foo.c foo.h y.output y.tab.c y.tab.h bar.output bar.tab.c bar.tab.h foo.vcg foo.yy foo.tab.cc foo.tab.hh foo.c++ foo.hpp foo.gph calc.y input calc calc.c calc.h calc.output duplicate.y duplicate.* union.y union.* union-comment.y union-comment.* input.y input/input.y'


while test $# -gt 0; do
  case $1 in
    --help | -h )
        at_help_p=:
        ;;

    --list | -l )
        at_list_p=:
        ;;

    --version | -V )
        echo "$as_me (GNU Bison 1.29e)"
        exit 0
        ;;

    --clean | -c )
        rm -rf $at_data_files \
               $as_me.[0-9] $as_me.[0-9][0-9] $as_me.[0-9][0-9][0-9] \
               $as_me.log devnull
        exit 0
        ;;

    --debug | -d )
        at_debug_p=:
        ;;

    --errexit | -e )
        at_debug_p=:
        at_errexit_p=:
        ;;

    --verbose | -v )
        at_verbose=echo; at_quiet=:
        ;;

    --trace | -x )
        at_traceon='set -vx'; at_traceoff='set +vx'
        ;;

    [0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9])
        at_tests="$at_tests$1 "
        ;;

    # Ranges
    [0-9]- | [0-9][0-9]- | [0-9][0-9][0-9]- | [0-9][0-9][0-9][0-9]-)
        at_range_start=`echo $1 |tr -d '-'`
        at_range=`echo " $at_tests_all " | \
          sed -e 's,^.* '$at_range_start' ,'$at_range_start' ,'`
        at_tests="$at_tests$at_range "
        ;;

    -[0-9] | -[0-9][0-9] | -[0-9][0-9][0-9] | -[0-9][0-9][0-9][0-9])
        at_range_end=`echo $1 |tr -d '-'`
        at_range=`echo " $at_tests_all " | \
          sed -e 's, '$at_range_end' .*$, '$at_range_end','`
        at_tests="$at_tests$at_range "
        ;;

    [0-9]-[0-9] | [0-9]-[0-9][0-9] | [0-9]-[0-9][0-9][0-9] | \
    [0-9]-[0-9][0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9] | \
    [0-9][0-9]-[0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9][0-9][0-9] | \
    [0-9][0-9][0-9]-[0-9][0-9][0-9] | \
    [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9] | \
    [0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9] )
        at_range_start=`echo $1 |sed 's,-.*,,'`
        at_range_end=`echo $1 |sed 's,.*-,,'`
        # Maybe test to make sure start <= end?
        at_range=`echo " $at_tests_all " | \
          sed -e 's,^.* '$at_range_start' ,'$at_range_start' ,' \
              -e 's, '$at_range_end' .*$, '$at_range_end','`
        at_tests="$at_tests$at_range "
        ;;

    # Keywords.
    --keywords | -k )
        shift
        at_tests_selected=$at_help_all
        for at_keyword in `IFS=,; set X $1; shift; echo ${1+$@}`
        do
          # It is on purpose that we match the test group titles too.
          at_tests_selected=`echo "$at_tests_selected" |
                             egrep -i "^[^;]*;[^;]*;.*$at_keyword"`
        done
        at_tests_selected=`echo "$at_tests_selected" | sed 's/;.*//'`
        at_tests="$at_tests$at_tests_selected "
        ;;

    *=*)
  	at_envvar=`expr "x$1" : 'x\([^=]*\)='`
  	# Reject names that are not valid shell variable names.
  	expr "x$at_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
  	  { echo "$as_me: error: invalid variable name: $at_envvar" >&2
   { (exit 1); exit 1; }; }
  	at_value=`expr "x$1" : 'x[^=]*=\(.*\)'`
  	at_value=`echo "$at_value" | sed "s/'/'\\\\\\\\''/g"`
  	eval "$at_envvar='$at_value'"
  	export $at_envvar
	# Propagate to debug scripts.
  	at_debug_args="$at_debug_args $1"
  	;;

     *) echo "$as_me: invalid option: $1" >&2
        echo "Try \`$0 --help' for more information." >&2
        exit 1
        ;;
  esac
  shift
done

# Selected tests.
test -z "$at_tests" && at_tests=$at_tests_all

# Help message.
if $at_help_p; then
  cat <<_ATEOF
Usage: $0 [OPTION]... [VARIABLE=VALUE]... [TESTS]

Run all the tests, or the selected TESTS, and save a detailed log file.
Upon failure, create debugging scripts.

You should not change environment variables unless explicitly passed
as command line arguments.  Set \`AUTOTEST_PATH' to select the executables
to exercise.  Each relative directory is expanded as build and source
directories relatively to the top level of this distribution.  E.g.,

  $ $0 AUTOTEST_PATH=bin

possibly amounts into

  PATH=/tmp/foo-1.0/bin:/src/foo-1.0/bin:\$PATH

Operation modes:
  -h, --help     print the help message, then exit
  -V, --version  print version number, then exit
  -c, --clean    remove all the files this test suite might create and exit
  -l, --list     describes all the tests, or the selected TESTS

Execution tuning:
  -k, --keywords=KEYWORDS
                 select the tests matching all the comma separated KEYWORDS
                 accumulates
  -e, --errexit  abort as soon as a test fails; implies --debug
  -v, --verbose  force more detailed output
                 default for debugging scripts
  -d, --debug    inhibit clean up and debug script creation
                 default for debugging scripts
  -x, --trace    enable tests shell tracing

Report bugs to <bug-bison@gnu.org>.
_ATEOF
  exit 0
fi

# List of tests.
if $at_list_p; then
  cat <<_ATEOF
GNU Bison 1.29e test suite tests:

 NUM: FILENAME:LINE      TEST-GROUP-NAME
      KEYWORDS

_ATEOF
  # "  1 42  45 " => "^(1|42|45);"
  at_tests_pattern=`echo "$at_tests" | sed 's/^  *//;s/  *$//;s/  */|/g'`
  at_tests_pattern="^(${at_tests_pattern});"
  echo "$at_help_all" |
    egrep -e "$at_tests_pattern" |
    awk 'BEGIN { FS = ";" }
         { if ($1) printf " %3d: %-18s %s\n", $1, $2, $3
           if ($4) printf "      %s\n", $4 } '
  exit 0
fi

# Don't take risks: use only absolute directories in PATH.
#
# For stand-alone test suites, AUTOTEST_PATH is relative to `.'.
#
# For embedded test suites, AUTOTEST_PATH is relative to the top level
# of the package.  Then expand it into build/src parts, since users
# may create executables in both places.
#
# There might be directories that don't exist, but don't redirect
# builtins' (eg., cd) stderr directly: Ultrix's sh hates that.
at_path=
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $AUTOTEST_PATH $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
  case $as_dir in
  [\\/]* | ?:[\\/]* )
    at_path=$at_path$PATH_SEPARATOR$as_dir
    ;;
  * )
    if test -z "$top_builddir"; then
      # Stand-alone test suite.
      at_path=$at_path$PATH_SEPARATOR$as_dir
    else
      # Embedded test suite.
      at_path=$at_path$PATH_SEPARATOR$top_builddir/$as_dir
      at_path=$at_path$PATH_SEPARATOR$top_srcdir/$as_dir
    fi
    ;;
esac
done


# Now build and simplify PATH.
at_sep=
PATH=
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $at_path
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
  as_dir=`(cd "$as_dir" && pwd) 2>/dev/null`
test -d "$as_dir" || continue
case $PATH in
                  $as_dir                 | \
                  $as_dir$PATH_SEPARATOR* | \
  *$PATH_SEPARATOR$as_dir                 | \
  *$PATH_SEPARATOR$as_dir$PATH_SEPARATOR* ) ;;
  *) PATH=$PATH$at_sep$as_dir
     at_sep=$PATH_SEPARATOR;;
esac
done

export PATH

# Can we diff with `/dev/null'?  DU 5.0 refuses.
if diff /dev/null /dev/null >/dev/null 2>&1; then
  at_devnull=/dev/null
else
  at_devnull=devnull
  cp /dev/null $at_devnull
fi

# Use `diff -u' when possible.
if diff -u $at_devnull $at_devnull >/dev/null 2>&1; then
  at_diff='diff -u'
else
  at_diff=diff
fi

# Setting up the FDs.
# 5 is stdout conditioned by verbosity.
if test $at_verbose = echo; then
  exec 5>&1
else
  exec 5>/dev/null
fi

# 6 is the log file.  To be preserved if `-d'.

if $at_debug_p; then
  exec 6>/dev/null
else
  exec 6>$as_me.log
fi

# Banners and logs.
cat <<\_ASBOX
## --------------------------- ##
## GNU Bison 1.29e test suite. ##
## --------------------------- ##
_ASBOX
{
  cat <<\_ASBOX
## --------------------------- ##
## GNU Bison 1.29e test suite. ##
## --------------------------- ##
_ASBOX
  echo

  echo "$as_me: command line was:"
  echo "  $ $0 $at_cli_args"
  echo

  # Try to find a few ChangeLogs in case it might help determining the
  # exact version.  Use the relative dir: if the top dir is a symlink,
  # find will not follow it (and options to follow the links are not
  # portable), which would result in no output here.
  if test -n "$top_srcdir"; then
    cat <<\_ASBOX
## ----------- ##
## ChangeLogs. ##
## ----------- ##
_ASBOX
    echo
    for at_file in `find "$top_srcdir" -name ChangeLog -print`
    do
      echo "$as_me: $at_file:"
      sed 's/^/| /;10q' $at_file
      echo
    done

    {
cat <<_ASUNAME
## --------- ##
## Platform. ##
## --------- ##

hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`

/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`

/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`

_ASUNAME

as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
  echo "PATH: $as_dir"
done

}
    echo
  fi

  # Contents of the config files.
  for at_file in atconfig atlocal
  do
    test -r $at_file || continue
    echo "$as_me: $at_file:"
    sed 's/^/| /' $at_file
    echo
  done

  cat <<\_ASBOX
## ---------------- ##
## Tested programs. ##
## ---------------- ##
_ASBOX
  echo
} >&6

# Report what programs are being tested.
for at_program in : $at_tested
do
  test "$at_program" = : && continue
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
  test -f $as_dir/$at_program && break
done

  if test -f $as_dir/$at_program; then
    {
      echo "testsuite.at:24: $as_dir/$at_program --version"
      $as_dir/$at_program --version
      echo
    } >&6 2>&1
  else
    { { echo "$as_me:$LINENO: error: cannot find $at_program" >&6
echo "$as_me: error: cannot find $at_program" >&2;}
   { (exit 1); exit 1; }; }
  fi
done

{
  cat <<\_ASBOX
## --------------------------- ##
## Silently running the tests. ##
## --------------------------- ##
_ASBOX
} >&6

at_start_date=`date`
at_start_time=`(date +%s) 2>/dev/null`
echo "$as_me: starting at: $at_start_date" >&6
at_pass_list=
at_fail_list=
at_skip_list=
at_test_count=0

for at_test in $at_tests
do
  at_status=0
  rm -rf $at_data_files
  # Skip tests we already run (using --keywords makes it easy to get
  # duplication).
  case " $at_pass_test $at_skip_test $at_fail_test " in
    *" $at_test "* ) continue;;
  esac
  # Clearly separate the tests when verbose.
  test $at_test_count != 0 && $at_verbose
  case $at_test in

  banner-1 ) # Banner 1. output.at:19
    cat <<\_ATEOF

Output file names.

_ATEOF
    ;;

  1 ) # 1. output.at:38: Output files:  & -dv.
    at_setup_line='output.at:38'
    $at_verbose "1. output.at:38: testing Output files:  & -dv...."
    $at_quiet $ECHO_N "  1: output.at:38      $ECHO_C"
    (
      $at_traceon

cat >foo.y <<'_ATEOF'

%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:38: bison -dv foo.y"
echo output.at:38 >at-check-line
( $at_traceon; bison -dv foo.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:38: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:38: ls foo.output foo.tab.c foo.tab.h"
echo output.at:38 >at-check-line
( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:38: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  2 ) # 2. output.at:40: Output files:  & -dv -o foo.c.
    at_setup_line='output.at:40'
    $at_verbose "2. output.at:40: testing Output files:  & -dv -o foo.c...."
    $at_quiet $ECHO_N "  2: output.at:40      $ECHO_C"
    (
      $at_traceon

cat >foo.y <<'_ATEOF'

%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:40: bison -dv -o foo.c foo.y"
echo output.at:40 >at-check-line
( $at_traceon; bison -dv -o foo.c foo.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:40: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:40: ls foo.c foo.h foo.output"
echo output.at:40 >at-check-line
( $at_traceon; ls foo.c foo.h foo.output ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:40: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  3 ) # 3. output.at:42: Output files:  & -dv -o foo.tab.c.
    at_setup_line='output.at:42'
    $at_verbose "3. output.at:42: testing Output files:  & -dv -o foo.tab.c...."
    $at_quiet $ECHO_N "  3: output.at:42      $ECHO_C"
    (
      $at_traceon

cat >foo.y <<'_ATEOF'

%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:42: bison -dv -o foo.tab.c foo.y"
echo output.at:42 >at-check-line
( $at_traceon; bison -dv -o foo.tab.c foo.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:42: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:42: ls foo.output foo.tab.c foo.tab.h"
echo output.at:42 >at-check-line
( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:42: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  4 ) # 4. output.at:44: Output files:  & -dv -y.
    at_setup_line='output.at:44'
    $at_verbose "4. output.at:44: testing Output files:  & -dv -y...."
    $at_quiet $ECHO_N "  4: output.at:44      $ECHO_C"
    (
      $at_traceon

cat >foo.y <<'_ATEOF'

%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:44: bison -dv -y foo.y"
echo output.at:44 >at-check-line
( $at_traceon; bison -dv -y foo.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:44: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:44: ls y.output y.tab.c y.tab.h"
echo output.at:44 >at-check-line
( $at_traceon; ls y.output y.tab.c y.tab.h ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:44: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  5 ) # 5. output.at:46: Output files:  & -dv -b bar.
    at_setup_line='output.at:46'
    $at_verbose "5. output.at:46: testing Output files:  & -dv -b bar...."
    $at_quiet $ECHO_N "  5: output.at:46      $ECHO_C"
    (
      $at_traceon

cat >foo.y <<'_ATEOF'

%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:46: bison -dv -b bar foo.y"
echo output.at:46 >at-check-line
( $at_traceon; bison -dv -b bar foo.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:46: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:46: ls bar.output bar.tab.c bar.tab.h"
echo output.at:46 >at-check-line
( $at_traceon; ls bar.output bar.tab.c bar.tab.h ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:46: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  6 ) # 6. output.at:48: Output files:  & -dv -g -o foo.c.
    at_setup_line='output.at:48'
    $at_verbose "6. output.at:48: testing Output files:  & -dv -g -o foo.c...."
    $at_quiet $ECHO_N "  6: output.at:48      $ECHO_C"
    (
      $at_traceon

cat >foo.y <<'_ATEOF'

%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:48: bison -dv -g -o foo.c foo.y"
echo output.at:48 >at-check-line
( $at_traceon; bison -dv -g -o foo.c foo.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:48: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:48: ls foo.c foo.h foo.output foo.vcg"
echo output.at:48 >at-check-line
( $at_traceon; ls foo.c foo.h foo.output foo.vcg ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:48: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  7 ) # 7. output.at:52: Output files: %defines %verbose & .
    at_setup_line='output.at:52'
    $at_verbose "7. output.at:52: testing Output files: %defines %verbose & ...."
    $at_quiet $ECHO_N "  7: output.at:52      $ECHO_C"
    (
      $at_traceon

cat >foo.y <<'_ATEOF'
%defines %verbose
%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:52: bison  foo.y"
echo output.at:52 >at-check-line
( $at_traceon; bison  foo.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:52: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:52: ls foo.output foo.tab.c foo.tab.h"
echo output.at:52 >at-check-line
( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:52: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  8 ) # 8. output.at:54: Output files: %defines %verbose %yacc & .
    at_setup_line='output.at:54'
    $at_verbose "8. output.at:54: testing Output files: %defines %verbose %yacc & ...."
    $at_quiet $ECHO_N "  8: output.at:54      $ECHO_C"
    (
      $at_traceon

cat >foo.y <<'_ATEOF'
%defines %verbose %yacc
%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:54: bison  foo.y"
echo output.at:54 >at-check-line
( $at_traceon; bison  foo.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:54: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:54: ls y.output y.tab.c y.tab.h"
echo output.at:54 >at-check-line
( $at_traceon; ls y.output y.tab.c y.tab.h ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:54: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  9 ) # 9. output.at:59: Output files: %defines %verbose & .
    at_setup_line='output.at:59'
    $at_verbose "9. output.at:59: testing Output files: %defines %verbose & ...."
    $at_quiet $ECHO_N "  9: output.at:59      $ECHO_C"
    (
      $at_traceon

cat >foo.yy <<'_ATEOF'
%defines %verbose
%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:59: bison  foo.yy"
echo output.at:59 >at-check-line
( $at_traceon; bison  foo.yy ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:59: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:59: ls foo.output foo.tab.cc foo.tab.hh"
echo output.at:59 >at-check-line
( $at_traceon; ls foo.output foo.tab.cc foo.tab.hh ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:59: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  10 ) # 10. output.at:62: Output files: %defines %verbose  & -o foo.c.
    at_setup_line='output.at:62'
    $at_verbose "10. output.at:62: testing Output files: %defines %verbose  & -o foo.c...."
    $at_quiet $ECHO_N " 10: output.at:62      $ECHO_C"
    (
      $at_traceon

cat >foo.yy <<'_ATEOF'
%defines %verbose
%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:62: bison -o foo.c foo.yy"
echo output.at:62 >at-check-line
( $at_traceon; bison -o foo.c foo.yy ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:62: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:62: ls foo.c foo.h foo.output"
echo output.at:62 >at-check-line
( $at_traceon; ls foo.c foo.h foo.output ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:62: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  11 ) # 11. output.at:66: Output files:  & --defines=foo.hpp -o foo.c++.
    at_setup_line='output.at:66'
    $at_verbose "11. output.at:66: testing Output files:  & --defines=foo.hpp -o foo.c++...."
    $at_quiet $ECHO_N " 11: output.at:66      $ECHO_C"
    (
      $at_traceon

cat >foo.yy <<'_ATEOF'

%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:66: bison --defines=foo.hpp -o foo.c++ foo.yy"
echo output.at:66 >at-check-line
( $at_traceon; bison --defines=foo.hpp -o foo.c++ foo.yy ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:66: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:66: ls foo.c++ foo.hpp"
echo output.at:66 >at-check-line
( $at_traceon; ls foo.c++ foo.hpp ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:66: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;

  12 ) # 12. output.at:70: Output files:  & -o foo.c++ --graph=foo.gph.
    at_setup_line='output.at:70'
    $at_verbose "12. output.at:70: testing Output files:  & -o foo.c++ --graph=foo.gph...."
    $at_quiet $ECHO_N " 12: output.at:70      $ECHO_C"
    (
      $at_traceon

cat >foo.yy <<'_ATEOF'

%%
foo: {}
_ATEOF


$at_traceoff
$at_verbose "output.at:70: bison -o foo.c++ --graph=foo.gph foo.yy"
echo output.at:70 >at-check-line
( $at_traceon; bison -o foo.c++ --graph=foo.gph foo.yy ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:70: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "output.at:70: ls foo.c++ foo.gph"
echo output.at:70 >at-check-line
( $at_traceon; ls foo.c++ foo.gph ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "output.at:70: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

    $at_times >at-times
    )
    at_status=$?
    ;;


  banner-2 ) # Banner 2. calc.at:19
    cat <<\_ATEOF

Simple Calculator.

_ATEOF
    ;;

  13 ) # 13. calc.at:389: Calculator
    at_setup_line='calc.at:389'
    $at_verbose "13. calc.at:389: testing Calculator ..."
    $at_quiet $ECHO_N " 13: calc.at:389       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>


static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:389: bison calc.y -o calc.c "
echo calc.at:389 >at-check-line
( $at_traceon; bison calc.y -o calc.c  ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:389: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:389 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:389: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:389 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:389: calc input"
echo calc.at:389 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:389: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:389 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "0
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:389: calc input"
echo calc.at:389 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:389: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:389 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:389: cat stderr"
echo calc.at:389 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:389: calc input"
echo calc.at:389 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:389: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:389 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:389: cat stderr"
echo calc.at:389 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:389: calc input"
echo calc.at:389 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:389: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:389 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:389: cat stderr"
echo calc.at:389 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:389: calc input"
echo calc.at:389 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:389: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:389 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:389: cat stderr"
echo calc.at:389 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:389: calc input"
echo calc.at:389 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:389: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:389 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:389: cat stderr"
echo calc.at:389 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:389: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  14 ) # 14. calc.at:391: Calculator --defines
    at_setup_line='calc.at:391'
    $at_verbose "14. calc.at:391: testing Calculator --defines..."
    $at_quiet $ECHO_N " 14: calc.at:391       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>


static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:391: bison calc.y -o calc.c --defines"
echo calc.at:391 >at-check-line
( $at_traceon; bison calc.y -o calc.c --defines ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:391: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:391 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:391: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:391 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:391: calc input"
echo calc.at:391 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:391: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:391 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "0
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:391: calc input"
echo calc.at:391 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:391: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:391 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:391: cat stderr"
echo calc.at:391 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:391: calc input"
echo calc.at:391 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:391: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:391 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:391: cat stderr"
echo calc.at:391 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:391: calc input"
echo calc.at:391 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:391: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:391 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:391: cat stderr"
echo calc.at:391 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:391: calc input"
echo calc.at:391 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:391: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:391 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:391: cat stderr"
echo calc.at:391 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:391: calc input"
echo calc.at:391 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:391: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:391 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:391: cat stderr"
echo calc.at:391 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:391: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  15 ) # 15. calc.at:392: Calculator --locations
    at_setup_line='calc.at:392'
    $at_verbose "15. calc.at:392: testing Calculator --locations..."
    $at_quiet $ECHO_N " 15: calc.at:392       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>


static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:392: bison calc.y -o calc.c --locations"
echo calc.at:392 >at-check-line
( $at_traceon; bison calc.y -o calc.c --locations ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:392: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:392 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:392: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:392 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:392: calc input"
echo calc.at:392 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:392: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:392 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "0
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:392: calc input"
echo calc.at:392 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:392: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:392 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:392: cat stderr"
echo calc.at:392 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.0:1.1: parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:392: calc input"
echo calc.at:392 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:392: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:392 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:392: cat stderr"
echo calc.at:392 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.2:1.3: parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:392: calc input"
echo calc.at:392 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:392: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:392 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:392: cat stderr"
echo calc.at:392 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.0:1.1: parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:392: calc input"
echo calc.at:392 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:392: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:392 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:392: cat stderr"
echo calc.at:392 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.6:1.7: parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:392: calc input"
echo calc.at:392 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:392: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:392 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:392: cat stderr"
echo calc.at:392 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "2.0:2.1: parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:392: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  16 ) # 16. calc.at:393: Calculator --name-prefix=calc
    at_setup_line='calc.at:393'
    $at_verbose "16. calc.at:393: testing Calculator --name-prefix=calc..."
    $at_quiet $ECHO_N " 16: calc.at:393       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>


static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:393: bison calc.y -o calc.c --name-prefix=calc"
echo calc.at:393 >at-check-line
( $at_traceon; bison calc.y -o calc.c --name-prefix=calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:393: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:393 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:393: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:393 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:393: calc input"
echo calc.at:393 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:393: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:393 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "0
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:393: calc input"
echo calc.at:393 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:393: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:393 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:393: cat stderr"
echo calc.at:393 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:393: calc input"
echo calc.at:393 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:393: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:393 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:393: cat stderr"
echo calc.at:393 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:393: calc input"
echo calc.at:393 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:393: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:393 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:393: cat stderr"
echo calc.at:393 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:393: calc input"
echo calc.at:393 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:393: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:393 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:393: cat stderr"
echo calc.at:393 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:393: calc input"
echo calc.at:393 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:393: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:393 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:393: cat stderr"
echo calc.at:393 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:393: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  17 ) # 17. calc.at:394: Calculator --verbose
    at_setup_line='calc.at:394'
    $at_verbose "17. calc.at:394: testing Calculator --verbose..."
    $at_quiet $ECHO_N " 17: calc.at:394       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>


static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:394: bison calc.y -o calc.c --verbose"
echo calc.at:394 >at-check-line
( $at_traceon; bison calc.y -o calc.c --verbose ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:394: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:394 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:394: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:394 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:394: calc input"
echo calc.at:394 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:394: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:394 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "0
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:394: calc input"
echo calc.at:394 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:394: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:394 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:394: cat stderr"
echo calc.at:394 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:394: calc input"
echo calc.at:394 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:394: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:394 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:394: cat stderr"
echo calc.at:394 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:394: calc input"
echo calc.at:394 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:394: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:394 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:394: cat stderr"
echo calc.at:394 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:394: calc input"
echo calc.at:394 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:394: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:394 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:394: cat stderr"
echo calc.at:394 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:394: calc input"
echo calc.at:394 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:394: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:394 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:394: cat stderr"
echo calc.at:394 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:394: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  18 ) # 18. calc.at:395: Calculator --yacc
    at_setup_line='calc.at:395'
    $at_verbose "18. calc.at:395: testing Calculator --yacc..."
    $at_quiet $ECHO_N " 18: calc.at:395       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>


static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:395: bison calc.y -o calc.c --yacc"
echo calc.at:395 >at-check-line
( $at_traceon; bison calc.y -o calc.c --yacc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:395: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:395 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:395: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:395 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:395: calc input"
echo calc.at:395 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:395: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:395 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "0
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:395: calc input"
echo calc.at:395 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:395: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:395 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:395: cat stderr"
echo calc.at:395 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:395: calc input"
echo calc.at:395 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:395: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:395 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:395: cat stderr"
echo calc.at:395 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:395: calc input"
echo calc.at:395 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:395: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:395 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:395: cat stderr"
echo calc.at:395 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:395: calc input"
echo calc.at:395 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:395: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:395 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:395: cat stderr"
echo calc.at:395 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:395: calc input"
echo calc.at:395 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:395: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:395 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:395: cat stderr"
echo calc.at:395 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:395: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  19 ) # 19. calc.at:396: Calculator --yyerror-verbose
    at_setup_line='calc.at:396'
    $at_verbose "19. calc.at:396: testing Calculator --yyerror-verbose..."
    $at_quiet $ECHO_N " 19: calc.at:396       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>
#define YYERROR_VERBOSE

static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:396: bison calc.y -o calc.c "
echo calc.at:396 >at-check-line
( $at_traceon; bison calc.y -o calc.c  ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:396: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:396 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:396: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:396 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:396: calc input"
echo calc.at:396 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:396: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:396 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "0
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:396: calc input"
echo calc.at:396 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:396: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:396 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:396: cat stderr"
echo calc.at:396 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error, unexpected \`'+''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:396: calc input"
echo calc.at:396 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:396: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:396 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:396: cat stderr"
echo calc.at:396 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error, unexpected \`'/'', expecting \`NUM' or \`'-'' or \`'(''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:396: calc input"
echo calc.at:396 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:396: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:396 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:396: cat stderr"
echo calc.at:396 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error, unexpected \`\$undefined.'
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:396: calc input"
echo calc.at:396 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:396: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:396 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:396: cat stderr"
echo calc.at:396 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error, unexpected \`'=''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:396: calc input"
echo calc.at:396 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:396: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:396 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:396: cat stderr"
echo calc.at:396 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error, unexpected \`'+''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:396: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  20 ) # 20. calc.at:398: Calculator --locations --yyerror-verbose
    at_setup_line='calc.at:398'
    $at_verbose "20. calc.at:398: testing Calculator --locations --yyerror-verbose..."
    $at_quiet $ECHO_N " 20: calc.at:398       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>
#define YYERROR_VERBOSE

static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:398: bison calc.y -o calc.c --locations "
echo calc.at:398 >at-check-line
( $at_traceon; bison calc.y -o calc.c --locations  ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:398: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:398 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:398: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:398 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:398: calc input"
echo calc.at:398 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:398: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:398 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "0
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:398: calc input"
echo calc.at:398 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:398: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:398 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:398: cat stderr"
echo calc.at:398 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.0:1.1: parse error, unexpected \`'+''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:398: calc input"
echo calc.at:398 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:398: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:398 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:398: cat stderr"
echo calc.at:398 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.2:1.3: parse error, unexpected \`'/'', expecting \`NUM' or \`'-'' or \`'(''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:398: calc input"
echo calc.at:398 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:398: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:398 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:398: cat stderr"
echo calc.at:398 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.0:1.1: parse error, unexpected \`\$undefined.'
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:398: calc input"
echo calc.at:398 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:398: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:398 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:398: cat stderr"
echo calc.at:398 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.6:1.7: parse error, unexpected \`'=''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:398: calc input"
echo calc.at:398 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:398: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:398 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:398: cat stderr"
echo calc.at:398 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "2.0:2.1: parse error, unexpected \`'+''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:398: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  21 ) # 21. calc.at:400: Calculator --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose
    at_setup_line='calc.at:400'
    $at_verbose "21. calc.at:400: testing Calculator --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose..."
    $at_quiet $ECHO_N " 21: calc.at:400       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>
#define YYERROR_VERBOSE

static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:400: bison calc.y -o calc.c --defines --locations --name-prefix=calc --verbose --yacc "
echo calc.at:400 >at-check-line
( $at_traceon; bison calc.y -o calc.c --defines --locations --name-prefix=calc --verbose --yacc  ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:400: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:400 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:400: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:400 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:400: calc input"
echo calc.at:400 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:400: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:400 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "0
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:400: calc input"
echo calc.at:400 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:400: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:400 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:400: cat stderr"
echo calc.at:400 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.0:1.1: parse error, unexpected \`'+''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:400: calc input"
echo calc.at:400 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:400: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:400 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:400: cat stderr"
echo calc.at:400 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.2:1.3: parse error, unexpected \`'/'', expecting \`NUM' or \`'-'' or \`'(''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:400: calc input"
echo calc.at:400 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:400: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:400 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:400: cat stderr"
echo calc.at:400 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.0:1.1: parse error, unexpected \`\$undefined.'
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:400: calc input"
echo calc.at:400 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:400: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:400 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:400: cat stderr"
echo calc.at:400 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.6:1.7: parse error, unexpected \`'=''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:400: calc input"
echo calc.at:400 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:400: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:400 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:400: cat stderr"
echo calc.at:400 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "2.0:2.1: parse error, unexpected \`'+''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:400: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  22 ) # 22. calc.at:402: Calculator --debug
    at_setup_line='calc.at:402'
    $at_verbose "22. calc.at:402: testing Calculator --debug..."
    $at_quiet $ECHO_N " 22: calc.at:402       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>


static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:402: bison calc.y -o calc.c --debug"
echo calc.at:402 >at-check-line
( $at_traceon; bison calc.y -o calc.c --debug ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:402: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:402 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:402: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:402 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:402: calc input"
echo calc.at:402 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:402: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:402 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "491
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:402: calc input"
echo calc.at:402 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:402: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:402 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "8
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:402: cat stderr"
echo calc.at:402 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:402: calc input"
echo calc.at:402 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:402: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:402 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "17
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:402: cat stderr"
echo calc.at:402 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:402: calc input"
echo calc.at:402 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:402: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:402 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "8
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:402: cat stderr"
echo calc.at:402 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:402: calc input"
echo calc.at:402 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:402: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:402 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "23
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:402: cat stderr"
echo calc.at:402 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:402: calc input"
echo calc.at:402 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:402: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:402 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "16
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:402: cat stderr"
echo calc.at:402 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "parse error
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:402: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;

  23 ) # 23. calc.at:403: Calculator --debug --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose
    at_setup_line='calc.at:403'
    $at_verbose "23. calc.at:403: testing Calculator --debug --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose..."
    $at_quiet $ECHO_N " 23: calc.at:403       $ECHO_C"
    (
      $at_traceon


cat >calc.y <<'_ATEOF'
/* Infix notation calculator--calc */

%{
#include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h>

#if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#else
char *strcat(char *dest, const char *src);
#endif
#include <ctype.h>
#define YYERROR_VERBOSE

static int power (int base, int exponent);
static void yyerror (const char *s);
static int yylex (void);
static int yygetc (void);
static void yyungetc (int c);

extern void perror (const char *s);
%}

/* BISON Declarations */
%token NUM

%nonassoc '=' /* comparison	       */
%left '-' '+'
%left '*' '/'
%left NEG     /* negation--unary minus */
%right '^'    /* exponentiation        */

/* Grammar follows */
%%
input:
  /* empty string */
| input line
;

line:
  '\n'
| exp '\n'
;

exp:
  NUM                { $$ = $1;             }
| exp '=' exp
  {
     if ($1 != $3)
       printf ("calc: error: %d != %d\n", $1, $3);
     $$ = $1 == $3;
  }
| exp '+' exp        { $$ = $1 + $3;        }
| exp '-' exp        { $$ = $1 - $3;        }
| exp '*' exp        { $$ = $1 * $3;        }
| exp '/' exp        { $$ = $1 / $3;        }
| '-' exp  %prec NEG { $$ = -$2;            }
| exp '^' exp        { $$ = power ($1, $3); }
| '(' exp ')'        { $$ = $2;             }
;
%%
/* The input. */
FILE *yyin;

static void
yyerror (const char *s)
{
#if YYLSP_NEEDED
  fprintf (stderr, "%d.%d:%d.%d: ",
	   yylloc.first_line, yylloc.first_column,
	   yylloc.last_line, yylloc.last_column);
#endif
  fprintf (stderr, "%s\n", s);
}

static int
yygetc (void)
{
  int res = getc (yyin);
#if YYLSP_NEEDED
  if (res == '\n')
    {
      yylloc.last_line++;
      yylloc.last_column = 0;
    }
  else
    yylloc.last_column++;
#endif
  return res;
}


static void
yyungetc (int c)
{
#if YYLSP_NEEDED
  /* Wrong when C == `\n'. */
  yylloc.last_column--;
#endif
  ungetc (c, yyin);
}

static int
read_signed_integer (void)
{
  int c = yygetc ();
  int sign = 1;
  int n = 0;

  if (c == '-')
    {
      c = yygetc ();
      sign = -1;
    }

  while (isdigit (c))
    {
      n = 10 * n + (c - '0');
      c = yygetc ();
    }

  yyungetc (c);

  return sign * n;
}



/*---------------------------------------------------------------.
| Lexical analyzer returns an integer on the stack and the token |
| NUM, or the ASCII character read if not a number.  Skips all   |
| blanks and tabs, returns 0 for EOF.                            |
`---------------------------------------------------------------*/

static int
yylex (void)
{
  int c;

#if YYLSP_NEEDED
  yylloc.first_column = yylloc.last_column;
  yylloc.first_line = yylloc.last_line;
#endif

  /* Skip white space.  */
  while ((c = yygetc ()) == ' ' || c == '\t')
    {
#if YYLSP_NEEDED
      yylloc.first_column = yylloc.last_column;
      yylloc.first_line = yylloc.last_line;
#endif
    }

  /* process numbers   */
  if (c == '.' || isdigit (c))
    {
      yyungetc (c);
      yylval = read_signed_integer ();
      return NUM;
    }

  /* Return end-of-file.  */
  if (c == EOF)
    return 0;

  /* Return single chars. */
  return c;
}

static int
power (int base, int exponent)
{
  int res = 1;
  if (exponent < 0)
    exit (1);
  for (/* Niente */; exponent; --exponent)
    res *= base;
  return res;
}

int
main (int argc, const char **argv)
{
  yyin = NULL;

  if (argc == 2)
    yyin = fopen (argv[1], "r");
  else
    yyin = stdin;

  if (!yyin)
    {
      perror (argv[1]);
      exit (1);
    }

#if YYDEBUG
  yydebug = 1;
#endif
#if YYLSP_NEEDED
  yylloc.last_column = 0;
  yylloc.last_line = 1;
#endif
  yyparse ();
  return 0;
}
_ATEOF



# Specify the output files to avoid problems on different file systems.
$at_traceoff
$at_verbose "calc.at:403: bison calc.y -o calc.c --debug --defines --locations --name-prefix=calc --verbose --yacc "
echo calc.at:403 >at-check-line
( $at_traceon; bison calc.y -o calc.c --debug --defines --locations --name-prefix=calc --verbose --yacc  ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Some compilers issue warnings we don't want to hear about.
# Maybe some day we will have proper Autoconf macros to disable these
# warnings, but this place is not the right one for that.
# So let's keep only GCC warnings, which we know are sane.
$at_traceoff
$at_verbose "calc.at:403: \$CC \$CFLAGS \$CPPFLAGS calc.c -o calc"
echo calc.at:403 >at-check-line
( $at_traceon; $CC $CFLAGS $CPPFLAGS calc.c -o calc ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "calc.at:403: if test \"\$GCC\" = yes; then cat stderr; else true; fi"
echo calc.at:403 >at-check-line
( $at_traceon; if test "$GCC" = yes; then cat stderr; else true; fi ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


# Test the priorities.
cat >input <<'_ATEOF'
1 + 2 * 3 = 7
1 + 2 * -3 = -5

-1^2 = -1
(-1)^2 = 1

---1 = -1

1 - 2 - 3 = -4
1 - (2 - 3) = 2

2^2^3 = 256
(2^2)^3 = 64
_ATEOF

$at_traceoff
$at_verbose "calc.at:403: calc input"
echo calc.at:403 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon
$at_traceoff
$at_verbose "calc.at:403: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:403 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "491
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



# Some parse errors.
cat >input <<'_ATEOF'
+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:403: calc input"
echo calc.at:403 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:403: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:403 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "8
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:403: cat stderr"
echo calc.at:403 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.0:1.1: parse error, unexpected \`'+''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1//2
_ATEOF


$at_traceoff
$at_verbose "calc.at:403: calc input"
echo calc.at:403 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:403: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:403 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "17
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:403: cat stderr"
echo calc.at:403 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.2:1.3: parse error, unexpected \`'/'', expecting \`NUM' or \`'-'' or \`'(''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
error
_ATEOF


$at_traceoff
$at_verbose "calc.at:403: calc input"
echo calc.at:403 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:403: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:403 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "8
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:403: cat stderr"
echo calc.at:403 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.0:1.1: parse error, unexpected \`\$undefined.'
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF


$at_traceoff
$at_verbose "calc.at:403: calc input"
echo calc.at:403 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:403: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:403 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "23
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:403: cat stderr"
echo calc.at:403 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "1.6:1.7: parse error, unexpected \`'=''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



cat >input <<'_ATEOF'

+1
_ATEOF


$at_traceoff
$at_verbose "calc.at:403: calc input"
echo calc.at:403 >at-check-line
( $at_traceon; calc input ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; tee stderr <at-stderr) >&5
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon



$at_traceoff
$at_verbose "calc.at:403: wc -l <stderr | sed 's/[^0-9]//g'"
echo calc.at:403 >at-check-line
( $at_traceon; wc -l <stderr | sed 's/[^0-9]//g' ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "16
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr

$at_traceoff
$at_verbose "calc.at:403: cat stderr"
echo calc.at:403 >at-check-line
( $at_traceon; cat stderr ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "2.0:2.1: parse error, unexpected \`'+''
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "calc.at:403: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon




    $at_times >at-times
    )
    at_status=$?
    ;;


  banner-3 ) # Banner 3. regression.at:19
    cat <<\_ATEOF

Regression tests.

_ATEOF
    ;;

  24 ) # 24. regression.at:26: Duplicate string
    at_setup_line='regression.at:26'
    $at_verbose "24. regression.at:26: testing Duplicate string..."
    $at_quiet $ECHO_N " 24: regression.at:26  $ECHO_C"
    (
      $at_traceon


cat >duplicate.y <<'_ATEOF'
/* `Bison -v' used to dump core when two tokens are defined with the same
   string, as LE and GE below. */

%token NUM
%token LE "<="
%token GE "<="

%%
exp: '(' exp ')' | NUM ;
%%
_ATEOF


$at_traceoff
$at_verbose "regression.at:41: bison -v duplicate.y -o duplicate.c"
echo regression.at:41 >at-check-line
( $at_traceon; bison -v duplicate.y -o duplicate.c ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
(echo stderr:; cat at-stderr) >&5
(echo stdout:; cat at-stdout) >&5
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "regression.at:41: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


    $at_times >at-times
    )
    at_status=$?
    ;;

  25 ) # 25. regression.at:52: %union and --defines
    at_setup_line='regression.at:52'
    $at_verbose "25. regression.at:52: testing %union and --defines..."
    $at_quiet $ECHO_N " 25: regression.at:52  $ECHO_C"
    (
      $at_traceon


cat >union.y <<'_ATEOF'
%union
{
  int   integer;
  char *string ;
}
%%
exp: {};
_ATEOF


$at_traceoff
$at_verbose "regression.at:64: bison --defines union.y"
echo regression.at:64 >at-check-line
( $at_traceon; bison --defines union.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "regression.at:64: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


    $at_times >at-times
    )
    at_status=$?
    ;;

  26 ) # 26. regression.at:74: %union and C comments
    at_setup_line='regression.at:74'
    $at_verbose "26. regression.at:74: testing %union and C comments..."
    $at_quiet $ECHO_N " 26: regression.at:74  $ECHO_C"
    (
      $at_traceon


cat >union-comment.y <<'_ATEOF'
%union
{
  /* The int.  */	int   integer;
  /* The string.  */	char *string ;
}
%%
exp: {};
_ATEOF


$at_traceoff
$at_verbose "regression.at:86: bison union-comment.y"
echo regression.at:86 >at-check-line
( $at_traceon; bison union-comment.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "regression.at:86: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon

$at_traceoff
$at_verbose "regression.at:87: fgrep '//*' union-comment.tab.c"
echo regression.at:87 >at-check-line
( $at_traceon; fgrep '//*' union-comment.tab.c ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   1) ;;
   *) $at_verbose "regression.at:87: exit code was $at_status, expected 1" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


    $at_times >at-times
    )
    at_status=$?
    ;;

  27 ) # 27. regression.at:97: Invalid input
    at_setup_line='regression.at:97'
    $at_verbose "27. regression.at:97: testing Invalid input..."
    $at_quiet $ECHO_N " 27: regression.at:97  $ECHO_C"
    (
      $at_traceon


cat >input.y <<'_ATEOF'
%%
?
_ATEOF


$at_traceoff
$at_verbose "regression.at:107: bison input.y"
echo regression.at:107 >at-check-line
( $at_traceon; bison input.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
echo >>at-stderr; echo "input.y:2: invalid input: \`?'
input.y:3: fatal error: no rules in the input grammar
" | $at_diff - at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   1) ;;
   *) $at_verbose "regression.at:107: exit code was $at_status, expected 1" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


    $at_times >at-times
    )
    at_status=$?
    ;;

  28 ) # 28. regression.at:116: Invalid CPP headers
    at_setup_line='regression.at:116'
    $at_verbose "28. regression.at:116: testing Invalid CPP headers..."
    $at_quiet $ECHO_N " 28: regression.at:116 $ECHO_C"
    (
      $at_traceon


mkdir input

cat >input/input.y <<'_ATEOF'
%%
dummy:
_ATEOF


$at_traceoff
$at_verbose "regression.at:125: bison --defines input/input.y"
echo regression.at:125 >at-check-line
( $at_traceon; bison --defines input/input.y ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
$at_diff $at_devnull  at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "regression.at:125: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


$at_traceoff
$at_verbose "regression.at:129: sed 1q input/input.tab.h"
echo regression.at:129 >at-check-line
( $at_traceon; sed 1q input/input.tab.h ) >at-stdout 2>at-stder1
at_status=$?
egrep '^ *\+' at-stder1 >&2
egrep -v '^ *\+' at-stder1 >at-stderr
at_failed=false
$at_diff $at_devnull  at-stderr >&5 || at_failed=:
echo >>at-stdout; echo "#ifndef INPUT_INPUT_TAB_H
" | $at_diff - at-stdout >&5 || at_failed=:
case $at_status in
   77) exit 77;;
   0) ;;
   *) $at_verbose "regression.at:129: exit code was $at_status, expected 0" >&2
      at_failed=:;;
esac

$at_failed && exit 1
$at_traceon


    $at_times >at-times
    )
    at_status=$?
    ;;


  * )
    echo "$as_me: no such test: $at_test" >&2
    continue
    ;;
  esac
  case $at_test in
    banner-*) ;;
    *)
      if test ! -f at-check-line; then
        sed "s/^ */$as_me: warning: /" <<_ATEOF
        A failure happened in a test group before any test could be
        run. This means that test suite is improperly designed.  Please
        report this failure to <bug-bison@gnu.org>.
_ATEOF
    	echo "$at_setup_line" >at-check-line
      fi
      at_test_count=`expr 1 + $at_test_count`
      $at_verbose $ECHO_N "$at_test. $at_setup_line: $ECHO_C"
      case $at_status in
        0)  at_msg="ok"
            at_pass_list="$at_pass_list $at_test"
            ;;
        77) at_msg="ok (skipped near \``cat at-check-line`')"
            at_skip_list="$at_skip_list $at_test"
            ;;
        *)  at_msg="FAILED near \``cat at-check-line`'"
            at_fail_list="$at_fail_list $at_test"
            ;;
      esac
      echo $at_msg
      at_log_msg="$at_test. $at_setup_line: $at_msg"
      # If the test failed, at-times is not available.
      test -f at-times && at_log_msg="$at_log_msg	(`sed 1d at-times`)"
      echo "$at_log_msg" >&6
      $at_errexit_p && test -n "$at_fail_list" && break
      ;;
  esac
done

at_stop_date=`date`
at_stop_time=`(date +%s) 2>/dev/null`
echo "$as_me: ending at: $at_stop_date" >&6
at_duration_s=`(expr $at_stop_time - $at_start_time) 2>/dev/null`
at_duration_m=`(expr $at_duration_s / 60) 2>/dev/null`
at_duration_h=`(expr $at_duration_m / 60) 2>/dev/null`
at_duration_s=`(expr $at_duration_s % 60) 2>/dev/null`
at_duration_m=`(expr $at_duration_m % 60) 2>/dev/null`
at_duration="${at_duration_h}h ${at_duration_m}m ${at_duration_s}s"
if test "$at_duration" != "h m s"; then
  echo "$as_me: test suite duration: $at_duration" >&6
fi

# Cleanup everything unless the user wants the files.
$at_debug_p || rm -rf $at_data_files

# Wrap up the test suite with summary statistics.
at_skip_count=`set dummy $at_skip_list; shift; echo $#`
at_fail_count=`set dummy $at_fail_list; shift; echo $#`
if test $at_fail_count = 0; then
  if test $at_skip_count = 0; then
    sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## All $at_test_count tests were successful. ##
_ASBOX
  else
    sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## All $at_test_count tests were successful ($at_skip_count skipped). ##
_ASBOX
  fi
elif test $at_debug_p = false; then
  if $at_errexit_p; then
    cat <<\_ASBOX
## ------------------------------------------------------------ ##
## ERROR: One of the tests failed, inhibiting subsequent tests. ##
## ------------------------------------------------------------ ##
_ASBOX
  else
    sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## ERROR: Suite unsuccessful, $at_fail_count of $at_test_count tests failed. ##
_ASBOX
  fi

  # Remove any debugging script resulting from a previous run.
  rm -f $as_me.[0-9] $as_me.[0-9][0-9] $as_me.[0-9][0-9][0-9]

  # Normalize the names so that `ls' lists them in order.
  at_format=`echo $at_last_test | sed 's/././g'`
  at_NNN=`expr "NNN$at_group" : ".*\($at_format\)"`
  echo
  echo $ECHO_N "Writing \`$as_me.$at_NNN' scripts, with $at_NNN =$ECHO_C"
  for at_group in $at_fail_list
  do
    at_number=`expr "000$at_group" : ".*\($at_format\)"`
    echo $ECHO_N " $at_number$ECHO_C"
    {
      echo "#! /bin/sh"
      echo 'exec ${CONFIG_SHELL-'"$SHELL"'}' "$0" \
           '-v -d' "$at_debug_args" "$at_group" '${1+"$@"}'
      echo 'exit 1'
    } >$as_me.$at_number
    chmod +x $as_me.$at_number
  done
  echo ', done.'
  echo
  echo 'You may investigate any problem if you feel able to do so, in which'
  echo 'case the test suite provides a good starting point.'
  echo
  echo 'Now, failed tests will be executed again, verbosely, and logged'
  echo 'in the file '$as_me'.log.'

  {
    echo
    echo
    cat <<\_ASBOX
## ------------------------ ##
## Summary of the failures. ##
## ------------------------ ##
_ASBOX

    # Summary of failed and skipped tests.
    if test $at_fail_count != 0; then
      echo "Failed tests:"
      $SHELL $0 $at_fail_list --list
      echo
    fi
    if test $at_skip_count != 0; then
      echo "Skipped tests:"
      $SHELL $0 $at_skip_list --list
      echo
    fi
    echo

    cat <<\_ASBOX
## --------------------------------------- ##
## Verbosely re-running the failing tests. ##
## --------------------------------------- ##
_ASBOX
    echo
  } >&6

  exec 6>/dev/null
  $SHELL $0 -v -d $at_debug_args $at_fail_list 2>&1 | tee -a $as_me.log
  exec 6>>$as_me.log

  {
    echo
    if test -n "$top_srcdir"; then
      cat <<\_ASBOX
## ------------------- ##
## Configuration logs. ##
## ------------------- ##
_ASBOX
      echo
      for at_file in `find "$top_srcdir" -name config.log -print`
      do
  	echo "$as_me: $at_file:"
  	sed 's/^/| /' $at_file
  	echo
      done
    fi
  } >&6


  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## $as_me.log is created. ##
_ASBOX

  echo
  echo "Please send \`$as_me.log' to <bug-bison@gnu.org>,"
  echo "along with all information you think might help."
  exit 1
fi

exit 0





# Checking the output filenames.                    -*- Autotest -*-
# Copyright 2000, 2001 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.






# AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES)
# ------------------------------------------------------------------






























































# Check priorities of extension control.
































# Checking the output filenames.                         -*- Autotest -*-
# Copyright 2000, 2001 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.





## ---------------------------------------------------- ##
## Compile the grammar described in the documentation.  ##
## ---------------------------------------------------- ##


# ------------------------- #
# Helping Autotest macros.  #
# ------------------------- #


# _AT_DATA_CALC_Y($1, $2, $3, [CPP-DIRECTIVES])
# ---------------------------------------------
# Produce `calc.y'.  Don't call this macro directly, because it contains
# some occurrences of `$1' etc. which will be interpreted by m4.  So
# you should call it with $1, $2, and $3 as arguments, which is what
# AT_DATA_CALC_Y does.
# _AT_DATA_CALC_Y


# AT_DATA_CALC_Y([BISON-OPTIONS])
# -------------------------------
# Produce `calc.y'.




# _AT_CHECK_CALC(BISON-OPTIONS, INPUT, [NUM-STDERR-LINES = 0])
# ------------------------------------------------------------
# Run `calc' on INPUT and expect no STDOUT nor STDERR.
#
# If BISON-OPTIONS contains `--debug', then NUM-STDERR-LINES is the number
# of expected lines on stderr.



# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, INPUT, [NUM-DEBUG-LINES],
#                      [ERROR-LOCATION], [IF-YYERROR-VERBOSE])
# ------------------------------------------------------------
# Run `calc' on INPUT, and expect a `parse error' message.
#
# If BISON-OPTIONS contains `--location', then make sure the ERROR-LOCATION
# is correctly output on stderr.
#
# If BISON-OPTIONS contains `--yyerror-verbose', then make sure the
# IF-YYERROR-VERBOSE message is properly output after `parse error, '
# on STDERR.
#
# If BISON-OPTIONS contains `--debug', then NUM-STDERR-LINES is the number
# of expected lines on stderr.



# AT_CHECK_CALC([BISON-OPTIONS], [PARSER-EXPECTED-STDERR])
# --------------------------------------------------------
# Start a testing chunk which compiles `calc' grammar with
# BISON-OPTIONS, and performs several tests over the parser.
# AT_CHECK_CALC




# ------------------ #
# Test the parsers.  #
# ------------------ #

# We use integers to avoid dependencies upon the precision of doubles.








# We use integers to avoid dependencies upon the precision of doubles.







# We use integers to avoid dependencies upon the precision of doubles.







# We use integers to avoid dependencies upon the precision of doubles.







# We use integers to avoid dependencies upon the precision of doubles.







# We use integers to avoid dependencies upon the precision of doubles.







# We use integers to avoid dependencies upon the precision of doubles.








# We use integers to avoid dependencies upon the precision of doubles.








# We use integers to avoid dependencies upon the precision of doubles.








# We use integers to avoid dependencies upon the precision of doubles.







# We use integers to avoid dependencies upon the precision of doubles.








# Bison Regressions.                               -*- Autotest -*-
# Copyright 2001 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.





## ------------------ ##
## Duplicate string.  ##
## ------------------ ##











## ---------------------- ##
## %union and --defines.  ##
## ---------------------- ##










## --------------------------------------- ##
## Duplicate '/' in C comments in %union   ##
## --------------------------------------- ##










## --------------- ##
## invalid input.  ##
## --------------- ##










## --------------------- ##
## Invalid CPP headers.  ##
## --------------------- ##








