#! /bin/sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
alias -g '${1+"$@"}'='"$@"'
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
set -o posix
fi
DUALCASE=1; export DUALCASE
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
$as_unset ENV MAIL MAILPATH
PS1='$ '
PS2='> '
PS4='+ '
for as_var in \
LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
LC_TELEPHONE LC_TIME
do
if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
eval $as_var=C; export $as_var
else
$as_unset $as_var
fi
done
if expr a : '\(a\)' >/dev/null 2>&1; then
as_expr=expr
else
as_expr=false
fi
if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
as_me=`$as_basename "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)$' \| \
. : '\(.\)' 2>/dev/null ||
echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
/^X\/\(\/\/\)$/{ s//\1/; q; }
/^X\/\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
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
if test "${PATH_SEPARATOR+set}" != set; then
echo "#! /bin/sh" >conf$$.sh
echo "exit 0" >>conf$$.sh
chmod +x conf$$.sh
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
PATH_SEPARATOR=';'
else
PATH_SEPARATOR=:
fi
rm -f conf$$.sh
fi
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" || {
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
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$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$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_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" ') 2>/dev/null; then
$as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
$as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
CONFIG_SHELL=$as_dir/$as_base
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$0" ${1+"$@"}
fi;;
esac
done
done
;;
esac
sed '=' <$as_myself |
sed '
N
s,$,-,
: loop
s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
t loop
s,-$,,
s,^['$as_cr_digits']*\n,,
' >$as_me.lineno &&
chmod +x $as_me.lineno ||
{ echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
{ (exit 1); exit 1; }; }
. ./$as_me.lineno
exit
}
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
if test -f conf$$.exe; then
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
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
as_executable_p="test -f"
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
as_nl='
'
IFS=" $as_nl"
$as_unset CDPATH
SHELL=${CONFIG_SHELL-/bin/sh}
at_cli_args="$@"
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
if test -n "$at_top_srcdir"; then
builddir=../..
for at_dir in srcdir top_srcdir top_builddir
do
at_val=`eval echo '${'at_$at_dir'}'`
eval "$at_dir=\$at_val/../.."
done
fi
at_times_p=false
(times) >/dev/null 2>&1 && at_times_p=:
at_debug_args=
at_errexit_p=false
at_verbose=:
at_quiet=echo
at_debug_p=false
at_help_p=false
at_list_p=false
at_groups=
at_dir=`pwd`
at_suite_dir=$at_dir/$as_me.dir
at_suite_log=$at_dir/$as_me.log
at_check_line_file=$at_suite_dir/at-check-line
at_status_file=$at_suite_dir/at-status
at_stdout=$at_suite_dir/at-stdout
at_stder1=$at_suite_dir/at-stder1
at_stderr=$at_suite_dir/at-stderr
at_times_file=$at_suite_dir/at-times
at_tested='bison'
at_groups_all=' banner-1 1 2 3 4 5 6 7 8 9 10 banner-2 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 banner-3 31 32 33 34 banner-4 35 36 37 38 39 40 banner-5 41 42 43 44 45 banner-6 46 47 48 49 banner-7 50 51 52 53 54 55 56 57 banner-8 58 59 60 61 62 63 64 65 66 67 68 69 banner-9 70 71 72 73 74 75 76 77 78 79 80 81 82 83 banner-10 84 85 86 87 88 89 90 91 92 93 94 95 96 97 banner-11 98 99 100 101 102 banner-12 103 104 banner-13 105 106 107 108 109 banner-14 110 111 112 banner-15 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 banner-16 131 132 banner-17 133 134 135 136 137 138 139 140 141 banner-18 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158'
at_format='...'
at_help_all='1;input.at:28;Invalid dollar-n;;
2;input.at:46;Invalid @n;;
3;input.at:64;Type Clashes;;
4;input.at:89;Unused values;;
5;input.at:157;Incompatible Aliases;;
6;input.at:198;Torturing the Scanner;;
7;input.at:357;Typed symbol aliases;;
8;input.at:393;Require 1.0;;
9;input.at:394;Require 2.3;;
10;input.at:396;Require 100.0;;
11;output.at:43;Output files: -dv ;;
12;output.at:46;Output files: -dv >&-;;
13;output.at:48;Output files: -dv -o foo.c ;;
14;output.at:50;Output files: -dv -o foo.tab.c ;;
15;output.at:52;Output files: -dv -y ;;
16;output.at:54;Output files: -dv -b bar ;;
17;output.at:56;Output files: -dv -g -o foo.c ;;
18;output.at:60;Output files: %defines %verbose ;;
19;output.at:62;Output files: %defines %verbose %yacc ;;
20;output.at:65;Output files: %defines %verbose %yacc ;;
21;output.at:69;Output files: %file-prefix="bar" %defines %verbose ;;
22;output.at:71;Output files: %output="bar.c" %defines %verbose %yacc ;;
23;output.at:75;Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc ;;
24;output.at:80;Output files: %defines %verbose ;;
25;output.at:83;Output files: %defines %verbose -o foo.c ;;
26;output.at:87;Output files: --defines=foo.hpp -o foo.c++ ;;
27;output.at:91;Output files: -o foo.c++ --graph=foo.gph ;;
28;output.at:105;Output files: %skeleton "lalr1.cc" %defines %verbose ;;
29;output.at:109;Output files: %skeleton "lalr1.cc" %defines %verbose ;;
30;output.at:114;Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc ;;
31;sets.at:66;Nullable;;
32;sets.at:151;Broken Closure;;
33;sets.at:193;Firsts;;
34;sets.at:269;Accept;;
35;reduce.at:26;Useless Terminals;;
36;reduce.at:70;Useless Nonterminals;;
37;reduce.at:125;Useless Rules;report;
38;reduce.at:212;Reduced Automaton;report;
39;reduce.at:301;Underivable Rules;report;
40;reduce.at:342;Empty Language;;
41;synclines.at:95;Prologue synch line;;
42;synclines.at:115;%union synch line;;
43;synclines.at:138;Postprologue synch line;;
44;synclines.at:157;Action synch line;;
45;synclines.at:175;Epilogue synch line;;
46;headers.at:27;%union and --defines;;
47;headers.at:77;Invalid CPP guards: input/input;;
48;headers.at:78;Invalid CPP guards: 9foo;;
49;headers.at:87;export YYLTYPE;;
50;actions.at:25;Mid-rule actions;;
51;actions.at:91;Exotic Dollars;;
52;actions.at:527;Printers and Destructors : ;;
53;actions.at:528;Printers and Destructors with union: ;;
54;actions.at:533;Printers and Destructors : %defines %skeleton "lalr1.cc";c++;
55;actions.at:534;Printers and Destructors with union: %defines %skeleton "lalr1.cc";c++;
56;actions.at:536;Printers and Destructors : %glr-parser;;
57;actions.at:537;Printers and Destructors with union: %glr-parser;;
58;conflicts.at:32;S/R in initial;;
59;conflicts.at:52;%nonassoc and eof;;
60;conflicts.at:128;Unresolved SR Conflicts;report;
61;conflicts.at:235;Resolved SR Conflicts;report;
62;conflicts.at:357;Defaulted Conflicted Reduction;report;
63;conflicts.at:476;%expect not enough;;
64;conflicts.at:496;%expect right;;
65;conflicts.at:513;%expect too much;;
66;conflicts.at:533;%expect with reduce conflicts;;
67;conflicts.at:553;%no-default-prec without %prec;;
68;conflicts.at:579;%no-default-prec with %prec;;
69;conflicts.at:603;%default-prec;;
70;calc.at:550;Calculator ;;
71;calc.at:552;Calculator %defines;;
72;calc.at:553;Calculator %locations;;
73;calc.at:554;Calculator %name-prefix="calc";;
74;calc.at:555;Calculator %verbose;;
75;calc.at:556;Calculator %yacc;;
76;calc.at:557;Calculator %error-verbose;;
77;calc.at:559;Calculator %pure-parser %locations;;
78;calc.at:560;Calculator %error-verbose %locations;;
79;calc.at:562;Calculator %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc;;
80;calc.at:564;Calculator %debug;;
81;calc.at:565;Calculator %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
82;calc.at:567;Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
83;calc.at:569;Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};;
84;calc.at:586;Calculator %glr-parser ;;
85;calc.at:588;Calculator %glr-parser %defines;;
86;calc.at:589;Calculator %glr-parser %locations;;
87;calc.at:590;Calculator %glr-parser %name-prefix="calc";;
88;calc.at:591;Calculator %glr-parser %verbose;;
89;calc.at:592;Calculator %glr-parser %yacc;;
90;calc.at:593;Calculator %glr-parser %error-verbose;;
91;calc.at:595;Calculator %glr-parser %pure-parser %locations;;
92;calc.at:596;Calculator %glr-parser %error-verbose %locations;;
93;calc.at:598;Calculator %glr-parser %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc;;
94;calc.at:600;Calculator %glr-parser %debug;;
95;calc.at:601;Calculator %glr-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
96;calc.at:603;Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
97;calc.at:605;Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};;
98;calc.at:621;Calculator %skeleton "lalr1.cc" %defines %locations ;c++;
99;calc.at:622;Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %name-prefix="calc" %verbose %yacc;c++;
100;calc.at:624;Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %debug %name-prefix="calc" %verbose %yacc;c++;
101;calc.at:626;Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc;c++;
102;calc.at:628;Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};c++;
103;calc.at:651;Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc;c++;
104;calc.at:653;Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};c++;
105;torture.at:140;Big triangle;;
106;torture.at:232;Big horizontal;;
107;torture.at:368;Many look-ahead tokens;;
108;torture.at:445;Exploding the Stack Size with Alloca;;
109;torture.at:471;Exploding the Stack Size with Malloc;;
110;existing.at:26;GNU AWK Grammar;;
111;existing.at:364;GNU Cim Grammar;;
112;existing.at:980;GNU pic Grammar;;
113;regression.at:28;Trivial grammars;;
114;regression.at:57;Early token definitions;;
115;regression.at:95;Braces parsing;;
116;regression.at:117;Duplicate string;;
117;regression.at:143;Rule Line Numbers;report;
118;regression.at:287;Mixing %token styles;;
119;regression.at:310;Invalid inputs;;
120;regression.at:336;Invalid inputs with {};;
121;regression.at:363;Token definitions;;
122;regression.at:416;Characters Escapes;;
123;regression.at:447;Web2c Report;report;
124;regression.at:624;Web2c Actions;report;
125;regression.at:866;Dancer ;;
126;regression.at:867;Dancer %glr-parser;;
127;regression.at:868;Dancer %skeleton "lalr1.cc";c++;
128;regression.at:963;Expecting two tokens ;;
129;regression.at:964;Expecting two tokens %glr-parser;;
130;regression.at:965;Expecting two tokens %skeleton "lalr1.cc";c++;
131;c++.at:102;Doxygen Public Documentation;;
132;c++.at:103;Doxygen Private Documentation;;
133;cxx-type.at:412;GLR: Resolve ambiguity, impure, no locations;;
134;cxx-type.at:419;GLR: Resolve ambiguity, impure, locations;;
135;cxx-type.at:425;GLR: Resolve ambiguity, pure, no locations;;
136;cxx-type.at:432;GLR: Resolve ambiguity, pure, locations;;
137;cxx-type.at:439;GLR: Merge conflicting parses, impure, no locations;;
138;cxx-type.at:446;GLR: Merge conflicting parses, impure, locations;;
139;cxx-type.at:453;GLR: Merge conflicting parses, pure, no locations;;
140;cxx-type.at:459;GLR: Merge conflicting parses, pure, locations;;
141;cxx-type.at:466;GLR: Verbose messages, resolve ambiguity, impure, no locations;;
142;glr-regression.at:25;Badly Collapsed GLR States;;
143;glr-regression.at:116;Improper handling of embedded actions and dollar(-N) in GLR parsers;;
144;glr-regression.at:232;Improper merging of GLR delayed action sets;;
145;glr-regression.at:337;Duplicate representation of merged trees;;
146;glr-regression.at:432;User destructor for unresolved GLR semantic value;;
147;glr-regression.at:502;User destructor after an error during a split parse;;
148;glr-regression.at:566;Duplicated user destructor for lookahead;;
149;glr-regression.at:644;Incorrectly initialized location for empty right-hand side in GLR;;
150;glr-regression.at:740;No users destructors if stack 0 deleted;;
151;glr-regression.at:820;Corrupted semantic options if user action cuts parse;;
152;glr-regression.at:881;Undesirable destructors if user action cuts parse;;
153;glr-regression.at:947;Leaked semantic values if user action cuts parse;;
154;glr-regression.at:1078;Incorrect lookahead during deterministic GLR;;
155;glr-regression.at:1212;Incorrect lookahead during nondeterministic GLR;;
156;glr-regression.at:1429;Leaked semantic values when reporting ambiguity;;
157;glr-regression.at:1519;Leaked lookahead after nondeterministic parse syntax error;;
158;glr-regression.at:1585;Uninitialized location when reporting ambiguity;;
'
at_keywords=
at_prev=
for at_option
do
if test -n "$at_prev"; then
at_option=$at_prev=$at_option
at_prev=
fi
at_optarg=`expr "x$at_option" : 'x[^=]*=\(.*\)'`
case $at_option in
--help | -h )
at_help_p=:
;;
--list | -l )
at_list_p=:
;;
--version | -V )
echo "$as_me (GNU Bison 2.3)"
exit 0
;;
--clean | -c )
rm -rf $at_suite_dir $at_suite_log
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_groups="$at_groups$at_option "
;;
[0-9]- | [0-9][0-9]- | [0-9][0-9][0-9]- | [0-9][0-9][0-9][0-9]-)
at_range_start=`echo $at_option |tr -d '-'`
at_range=`echo " $at_groups_all " | \
sed -e 's,^.* '$at_range_start' ,'$at_range_start' ,'`
at_groups="$at_groups$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 $at_option |tr -d '-'`
at_range=`echo " $at_groups_all " | \
sed -e 's, '$at_range_end' .*$, '$at_range_end','`
at_groups="$at_groups$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 $at_option |sed 's,-.*,,'`
at_range_end=`echo $at_option |sed 's,.*-,,'`
at_range=`echo " $at_groups_all " | \
sed -e 's,^.* '$at_range_start' ,'$at_range_start' ,' \
-e 's, '$at_range_end' .*$, '$at_range_end','`
at_groups="$at_groups$at_range "
;;
--keywords | -k )
at_prev=--keywords
;;
--keywords=* )
at_keywords="$at_keywords,$at_optarg"
;;
*=*)
at_envvar=`expr "x$at_option" : 'x\([^=]*\)='`
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=`echo "$at_optarg" | sed "s/'/'\\\\\\\\''/g"`
eval "$at_envvar='$at_value'"
export $at_envvar
at_debug_args="$at_debug_args $at_option"
;;
*) echo "$as_me: invalid option: $at_option" >&2
echo "Try \`$0 --help' for more information." >&2
exit 1
;;
esac
done
if test -n "$at_keywords"; then
at_groups_selected=$at_help_all
for at_keyword in `IFS=,; set X $at_keywords; shift; echo ${1+$@}`
do
at_groups_selected=`echo "$at_groups_selected" |
grep -i "^[^;]*;[^;]*.*[; ]$at_keyword[ ;]"`
done
at_groups_selected=`echo "$at_groups_selected" | sed 's/;.*//'`
at_groups_selected=`echo $at_groups_selected`
at_groups="$at_groups$at_groups_selected "
fi
test -z "$at_groups" && at_groups=$at_groups_all
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
_ATEOF
cat <<_ATEOF
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
_ATEOF
cat <<_ATEOF
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
_ATEOF
cat <<_ATEOF
Report bugs to <bug-bison@gnu.org>.
_ATEOF
exit 0
fi
if $at_list_p; then
cat <<_ATEOF
GNU Bison 2.3 test suite test groups:
NUM: FILENAME:LINE TEST-GROUP-NAME
KEYWORDS
_ATEOF
at_groups_pattern=`echo "$at_groups" | sed 's/^ *//;s/ *$//;s/ */|/g'`
echo "$at_help_all" |
awk 'BEGIN { FS = ";" }
{ if ($1 !~ /^('"$at_groups_pattern"')$/) next }
{ if ($1) printf " %3d: %-18s %s\n", $1, $2, $3
if ($4) printf " %s\n", $4 } '
exit 0
fi
AUTOTEST_PATH=`echo $AUTOTEST_PATH | tr ':' $PATH_SEPARATOR`
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 "$at_top_builddir"; then
at_path=$at_path$PATH_SEPARATOR$as_dir
else
at_path=$at_path$PATH_SEPARATOR$at_top_builddir/$as_dir
at_path=$at_path$PATH_SEPARATOR$at_top_srcdir/$as_dir
fi
;;
esac
done
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=$as_dir ;;
*) PATH=$PATH$PATH_SEPARATOR$as_dir ;;
esac
done
export PATH
$at_debug_p && at_suite_log=/dev/null
exec 5>$at_suite_log
cat <<\_ASBOX
_ASBOX
{
cat <<\_ASBOX
_ASBOX
echo
echo "$as_me: command line was:"
echo " $ $0 $at_cli_args"
echo
if test -n "$at_top_srcdir"; then
cat <<\_ASBOX
_ASBOX
echo
for at_file in `find "$at_top_srcdir" -name ChangeLog -print`
do
echo "$as_me: $at_file:"
sed 's/^/| /;10q' $at_file
echo
done
{
cat <<_ASUNAME
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
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
_ASBOX
echo
} >&5
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 "local.at:216: $as_dir/$at_program --version"
$as_dir/$at_program --version
echo
} >&5 2>&1
else
{ { echo "$as_me:$LINENO: error: cannot find $at_program" >&5
echo "$as_me: error: cannot find $at_program" >&2;}
{ (exit 1); exit 1; }; }
fi
done
{
cat <<\_ASBOX
_ASBOX
} >&5
at_start_date=`date`
at_start_time=`(date +%s) 2>/dev/null`
echo "$as_me: starting at: $at_start_date" >&5
at_xpass_list=
at_xfail_list=
at_pass_list=
at_fail_list=
at_skip_list=
at_group_count=0
test -d $at_suite_dir ||
mkdir $at_suite_dir ||
{ { echo "$as_me:$LINENO: error: cannot create $at_suite_dir" >&5
echo "$as_me: error: cannot create $at_suite_dir" >&2;}
{ (exit 1); exit 1; }; }
if diff /dev/null /dev/null >/dev/null 2>&1; then
at_devnull=/dev/null
else
at_devnull=$at_suite_dir/devnull
cp /dev/null $at_devnull
fi
if diff -u $at_devnull $at_devnull >/dev/null 2>&1; then
at_diff='diff -u'
else
at_diff=diff
fi
for at_group in $at_groups
do
cd $at_suite_dir
case $at_group in
banner-*)
at_group_log=$at_suite_log
;;
*)
case " $at_pass_test $at_skip_test $at_fail_test " in
*" $at_group "* ) continue;;
esac
at_group_normalized=`expr "00000$at_group" : ".*\($at_format\)"`
at_group_dir=$at_suite_dir/$at_group_normalized
at_group_log=$at_group_dir/$as_me.log
rm -rf $at_group_dir
mkdir $at_group_dir ||
{ { echo "$as_me:$LINENO: error: cannot create $at_group_dir" >&5
echo "$as_me: error: cannot create $at_group_dir" >&2;}
{ (exit 1); exit 1; }; }
cd $at_group_dir
;;
esac
echo 0 > $at_status_file
test $at_group_count != 0 && $at_verbose
if test $at_verbose = echo; then
at_tee_pipe="tee -a $at_group_log"
else
at_tee_pipe="cat >> $at_group_log"
fi
case $at_group in
banner-1 ) cat <<\_ATEOF
Input Processing.
_ATEOF
;;
1 ) at_setup_line='input.at:28'
at_desc='Invalid dollar-n'
$at_quiet $ECHO_N " 1: Invalid dollar-n $ECHO_C"
at_xfail=no
(
echo "1. input.at:28: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%%
exp: { $$ = $1 ; };
_ATEOF
$at_traceoff
echo "input.at:37: bison input.y"
echo input.at:37 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y:2.13-14: integer out of range: \`\$1'
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "input.at:37: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
2 ) at_setup_line='input.at:46'
at_desc='Invalid @n'
$at_quiet $ECHO_N " 2: Invalid @n $ECHO_C"
at_xfail=no
(
echo "2. input.at:46: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%%
exp: { @$ = @1 ; };
_ATEOF
$at_traceoff
echo "input.at:55: bison input.y"
echo input.at:55 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y:2.13-14: integer out of range: \`@1'
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "input.at:55: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
3 ) at_setup_line='input.at:64'
at_desc='Type Clashes'
$at_quiet $ECHO_N " 3: Type Clashes $ECHO_C"
at_xfail=no
(
echo "3. input.at:64: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%token foo
%type <bar> exp
%%
exp: foo {} foo
| foo
| /* Empty. */
;
_ATEOF
$at_traceoff
echo "input.at:80: bison input.y"
echo input.at:80 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y:4.6-15: warning: type clash on default action: <bar> != <>
input.y:5.6-8: warning: type clash on default action: <bar> != <>
input.y:6.5: warning: empty rule for typed nonterminal, and no action
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:80: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
4 ) at_setup_line='input.at:89'
at_desc='Unused values'
$at_quiet $ECHO_N " 4: Unused values $ECHO_C"
at_xfail=no
(
echo "4. input.at:89: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%token <integer> INT
%type <integer> a b c d e f g h i j k l
%destructor { destroy ($$); } INT a b c d e f g h i j k l
%%
start:
'a' a { $2 } | 'b' b { $2 } | 'c' c { $2 } | 'd' d { $2 } | 'e' e { $2 }
| 'f' f { $2 } | 'g' g { $2 } | 'h' h { $2 } | 'i' i { $2 } | 'j' j { $2 }
| 'k' k { $2 } | 'l' l { $2 }
;
a: INT | INT { } INT { } INT { };
b: INT | /* empty */;
c: INT | INT { $1 } INT { } INT { };
d: INT | INT { } INT { $1 } INT { };
e: INT | INT { } INT { } INT { $1 };
f: INT | INT { } INT { } INT { $$ = $1 + $3 + $5; };
g: INT | INT { $$ } INT { $$ } INT { };
h: INT | INT { $$ } INT { $$ = $2 } INT { };
i: INT | INT INT { } { $$ = $1 + $2; };
j: INT | INT INT { $<integer>$ = 1; } { $$ = $1 + $2; };
k: INT | INT INT { $$; } { $$ = $3; } { };
l: INT | INT { $$ = $1; } INT { $$ = $2 + $3; } INT { $$ = $4 + $5; };
_ATEOF
$at_traceoff
echo "input.at:148: bison input.y"
echo input.at:148 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y:11.10-32: warning: unset value: \$\$
input.y:11.10-32: warning: unused value: \$1
input.y:11.10-32: warning: unused value: \$3
input.y:11.10-32: warning: unused value: \$5
input.y:12.9: warning: empty rule for typed nonterminal, and no action
input.y:13.10-35: warning: unset value: \$\$
input.y:13.10-35: warning: unused value: \$3
input.y:13.10-35: warning: unused value: \$5
input.y:14.10-35: warning: unset value: \$\$
input.y:14.10-35: warning: unused value: \$3
input.y:14.10-35: warning: unused value: \$5
input.y:15.10-36: warning: unset value: \$\$
input.y:15.10-36: warning: unused value: \$3
input.y:15.10-36: warning: unused value: \$5
input.y:17.10-38: warning: unset value: \$\$
input.y:17.10-38: warning: unused value: \$1
input.y:17.10-38: warning: unused value: \$2
input.y:17.10-38: warning: unused value: \$3
input.y:17.10-38: warning: unused value: \$4
input.y:17.10-38: warning: unused value: \$5
input.y:18.10-43: warning: unset value: \$\$
input.y:18.10-43: warning: unused value: \$1
input.y:18.10-43: warning: unused value: \$3
input.y:18.10-43: warning: unused value: \$4
input.y:18.10-43: warning: unused value: \$5
input.y:20.10-55: warning: unused value: \$3
input.y:21.10-41: warning: unset value: \$\$
input.y:21.10-41: warning: unused value: \$1
input.y:21.10-41: warning: unused value: \$2
input.y:21.10-41: warning: unused value: \$4
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:148: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
5 ) at_setup_line='input.at:157'
at_desc='Incompatible Aliases'
$at_quiet $ECHO_N " 5: Incompatible Aliases $ECHO_C"
at_xfail=no
(
echo "5. input.at:157: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%token foo "foo"
%type <bar> foo
%printer {bar} foo
%destructor {bar} foo
%left foo
%type <baz> "foo"
%printer {baz} "foo"
%destructor {baz} "foo"
%left "foo"
%%
exp: foo;
_ATEOF
$at_traceoff
echo "input.at:185: bison input.y"
echo input.at:185 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y:8.7-11: %type redeclaration for foo
input.y:3.7-11: first declaration
input.y:10.13-17: %destructor redeclaration for foo
input.y:5.13-17: first declaration
input.y:9.10-14: %printer redeclaration for foo
input.y:10.13-17: first declaration
input.y:11.1-5: %left redeclaration for foo
input.y:6.1-5: first declaration
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "input.at:185: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
6 ) at_setup_line='input.at:198'
at_desc='Torturing the Scanner'
$at_quiet $ECHO_N " 6: Torturing the Scanner $ECHO_C"
at_xfail=no
(
echo "6. input.at:198: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
_ATEOF
$at_traceoff
echo "input.at:204: bison input.y"
echo input.at:204 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y:1.1: syntax error, unexpected end of file
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "input.at:204: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input.y <<'_ATEOF'
{}
_ATEOF
$at_traceoff
echo "input.at:212: bison input.y"
echo input.at:212 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y:1.1-2: syntax error, unexpected {...}
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "input.at:212: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
/* This is seen in GCC: a %{ and %} in middle of a comment. */
const char *foo = "So %{ and %} can be here too.";
/* These examples test Bison while not stressing C compilers too much.
Many C compilers mishandle backslash-newlines, so this part of the
test is inside "#if 0". The comment and string are written so that
the "#endif" will be seen regardless of the C compiler bugs that we
know about, namely:
HP C (as of late 2002) mishandles *\[newline]\[newline]/ within a
comment.
The Apple Darwin compiler (as of late 2002) mishandles
\\[newline]' within a character constant.
*/
/\
* A comment with backslash-newlines in it. %} *\
\
/
/* { Close the above comment, if the C compiler mishandled it. */
char str[] = "\\
" A string with backslash-newlines in it %{ %} \\
\
"";
char apostrophe = '\'';
%}
/* %{ and %} can be here too. */
%{
/* Exercise pre-prologue dependency to %union. */
typedef int value;
%}
/* Exercise M4 quoting: ']]', 0. */
/* Also exercise %union. */
%union
{
value ival; /* A comment to exercise an old bug. */
};
/* Exercise post-prologue dependency to %union. */
%{
static YYSTYPE value_as_yystype (value val);
/* Exercise quotes in declarations. */
char quote[] = "]],";
%}
%{
static void yyerror (const char *s);
static int yylex (void);
%}
%type <ival> '['
/* Exercise quotes in strings. */
%token FAKE "fake [] \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
%%
/* Exercise M4 quoting: ']]', [, 1. */
exp: '[' '\1' two '$' '@' '{' oline output.or.oline.opt
{
/* Exercise quotes in braces. */
char tmp[] = "[%c],\n";
printf (tmp, $1);
}
;
two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
output.or.oline.opt: ;|oline;;|output;;;
output: '%%
/* Exercise M4 quoting: ']]', [, 2. */
static YYSTYPE
value_as_yystype (value val)
{
YYSTYPE res;
res.ival = val;
return res;
}
static int
yylex (void)
{
static const char *input = "[\1\2$@{@oline@__oline__\
#output "; /* "
*/
yylval = value_as_yystype (*input);
return *input++;
}
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\n", msg);
}
_ATEOF
# Pacify Emacs'font-lock-mode: "
cat >main.c <<'_ATEOF'
typedef int value;
int yyparse (void);
int
main (void)
{
return yyparse ();
}
_ATEOF
$at_traceoff
echo "input.at:342: bison -d -v -o input.c input.y"
echo input.at:342 >$at_check_line_file
( $at_traceon; bison -d -v -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:342: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "input.at:343: \$CC \$CFLAGS \$CPPFLAGS -o input.o -c input.c"
echo input.at:343 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -c input.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:343: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "input.at:344: \$CC \$CFLAGS \$CPPFLAGS -o main.o -c main.c"
echo input.at:344 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -o main.o -c main.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:344: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "input.at:345: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.o main.o \$LIBS"
echo input.at:345 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.o main.o $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:345: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "input.at:348: \$PREPARSER ./input"
echo input.at:348 >$at_check_line_file
( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "[[],
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:348: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
7 ) at_setup_line='input.at:357'
at_desc='Typed symbol aliases'
$at_quiet $ECHO_N " 7: Typed symbol aliases $ECHO_C"
at_xfail=no
(
echo "7. input.at:357: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%union
{
int val;
};
%token <val> MY_TOKEN "MY TOKEN"
%type <val> exp
%%
exp: "MY TOKEN";
%%
_ATEOF
$at_traceoff
echo "input.at:373: bison -o input.c input.y"
echo input.at:373 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:373: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
8 ) at_setup_line='input.at:393'
at_desc='Require 1.0'
$at_quiet $ECHO_N " 8: Require 1.0 $ECHO_C"
at_xfail=no
(
echo "8. input.at:393: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%require "1.0";
%%
empty_file:;
_ATEOF
$at_traceoff
echo "input.at:393: bison -o input.c input.y"
echo input.at:393 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:393: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
9 ) at_setup_line='input.at:394'
at_desc='Require 2.3'
$at_quiet $ECHO_N " 9: Require 2.3 $ECHO_C"
at_xfail=no
(
echo "9. input.at:394: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%require "2.3";
%%
empty_file:;
_ATEOF
$at_traceoff
echo "input.at:394: bison -o input.c input.y"
echo input.at:394 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "input.at:394: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
10 ) at_setup_line='input.at:396'
at_desc='Require 100.0'
$at_quiet $ECHO_N " 10: Require 100.0 $ECHO_C"
at_xfail=no
(
echo "10. input.at:396: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%require "100.0";
%%
empty_file:;
_ATEOF
$at_traceoff
echo "input.at:396: bison -o input.c input.y"
echo input.at:396 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
63) ;;
*) echo "input.at:396: exit code was $at_status, expected 63"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
banner-2 ) cat <<\_ATEOF
Output file names.
_ATEOF
;;
11 ) at_setup_line='output.at:43'
at_desc='Output files: -dv '
$at_quiet $ECHO_N " 11: Output files: -dv $ECHO_C"
at_xfail=no
(
echo "11. output.at:43: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:43: bison -dv foo.y "
echo output.at:43 >$at_check_line_file
( $at_traceon; bison -dv foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:43: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:43: ls foo.output foo.tab.c foo.tab.h"
echo output.at:43 >$at_check_line_file
( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:43: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
12 ) at_setup_line='output.at:46'
at_desc='Output files: -dv >&-'
$at_quiet $ECHO_N " 12: Output files: -dv >&- $ECHO_C"
at_xfail=no
(
echo "12. output.at:46: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:46: bison -dv foo.y >&-"
echo output.at:46 >$at_check_line_file
( $at_traceon; bison -dv foo.y >&- ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:46: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:46: ls foo.output foo.tab.c foo.tab.h"
echo output.at:46 >$at_check_line_file
( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:46: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
13 ) at_setup_line='output.at:48'
at_desc='Output files: -dv -o foo.c '
$at_quiet $ECHO_N " 13: Output files: -dv -o foo.c $ECHO_C"
at_xfail=no
(
echo "13. output.at:48: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:48: bison -dv -o foo.c foo.y "
echo output.at:48 >$at_check_line_file
( $at_traceon; bison -dv -o foo.c foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:48: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:48: ls foo.c foo.h foo.output"
echo output.at:48 >$at_check_line_file
( $at_traceon; ls foo.c foo.h foo.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:48: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
14 ) at_setup_line='output.at:50'
at_desc='Output files: -dv -o foo.tab.c '
$at_quiet $ECHO_N " 14: Output files: -dv -o foo.tab.c $ECHO_C"
at_xfail=no
(
echo "14. output.at:50: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:50: bison -dv -o foo.tab.c foo.y "
echo output.at:50 >$at_check_line_file
( $at_traceon; bison -dv -o foo.tab.c foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:50: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:50: ls foo.output foo.tab.c foo.tab.h"
echo output.at:50 >$at_check_line_file
( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:50: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
15 ) at_setup_line='output.at:52'
at_desc='Output files: -dv -y '
$at_quiet $ECHO_N " 15: Output files: -dv -y $ECHO_C"
at_xfail=no
(
echo "15. output.at:52: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:52: bison -dv -y foo.y "
echo output.at:52 >$at_check_line_file
( $at_traceon; bison -dv -y foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:52: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:52: ls y.output y.tab.c y.tab.h"
echo output.at:52 >$at_check_line_file
( $at_traceon; ls y.output y.tab.c y.tab.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:52: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
16 ) at_setup_line='output.at:54'
at_desc='Output files: -dv -b bar '
$at_quiet $ECHO_N " 16: Output files: -dv -b bar $ECHO_C"
at_xfail=no
(
echo "16. output.at:54: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:54: bison -dv -b bar foo.y "
echo output.at:54 >$at_check_line_file
( $at_traceon; bison -dv -b bar foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:54: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:54: ls bar.output bar.tab.c bar.tab.h"
echo output.at:54 >$at_check_line_file
( $at_traceon; ls bar.output bar.tab.c bar.tab.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:54: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
17 ) at_setup_line='output.at:56'
at_desc='Output files: -dv -g -o foo.c '
$at_quiet $ECHO_N " 17: Output files: -dv -g -o foo.c $ECHO_C"
at_xfail=no
(
echo "17. output.at:56: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:56: bison -dv -g -o foo.c foo.y "
echo output.at:56 >$at_check_line_file
( $at_traceon; bison -dv -g -o foo.c foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:56: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:56: ls foo.c foo.h foo.output foo.vcg"
echo output.at:56 >$at_check_line_file
( $at_traceon; ls foo.c foo.h foo.output foo.vcg ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:56: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
18 ) at_setup_line='output.at:60'
at_desc='Output files: %defines %verbose '
$at_quiet $ECHO_N " 18: Output files: %defines %verbose $ECHO_C"
at_xfail=no
(
echo "18. output.at:60: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%defines %verbose
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:60: bison foo.y "
echo output.at:60 >$at_check_line_file
( $at_traceon; bison foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:60: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:60: ls foo.output foo.tab.c foo.tab.h"
echo output.at:60 >$at_check_line_file
( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:60: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
19 ) at_setup_line='output.at:62'
at_desc='Output files: %defines %verbose %yacc '
$at_quiet $ECHO_N " 19: Output files: %defines %verbose %yacc $ECHO_C"
at_xfail=no
(
echo "19. output.at:62: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%defines %verbose %yacc
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:62: bison foo.y "
echo output.at:62 >$at_check_line_file
( $at_traceon; bison foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:62: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:62: ls y.output y.tab.c y.tab.h"
echo output.at:62 >$at_check_line_file
( $at_traceon; ls y.output y.tab.c y.tab.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:62: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
20 ) at_setup_line='output.at:65'
at_desc='Output files: %defines %verbose %yacc '
$at_quiet $ECHO_N " 20: Output files: %defines %verbose %yacc $ECHO_C"
at_xfail=no
(
echo "20. output.at:65: testing ..."
$at_traceon
case "foo.yy" in
*/*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
esac
cat >foo.yy <<'_ATEOF'
%defines %verbose %yacc
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:65: bison foo.yy "
echo output.at:65 >$at_check_line_file
( $at_traceon; bison foo.yy ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:65: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:65: ls y.output y.tab.c y.tab.h"
echo output.at:65 >$at_check_line_file
( $at_traceon; ls y.output y.tab.c y.tab.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:65: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
21 ) at_setup_line='output.at:69'
at_desc='Output files: %file-prefix="bar" %defines %verbose '
$at_quiet $ECHO_N " 21: Output files: %file-prefix="bar" %defines %verbose $ECHO_C"
at_xfail=no
(
echo "21. output.at:69: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%file-prefix="bar" %defines %verbose
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:69: bison foo.y "
echo output.at:69 >$at_check_line_file
( $at_traceon; bison foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:69: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:69: ls bar.output bar.tab.c bar.tab.h"
echo output.at:69 >$at_check_line_file
( $at_traceon; ls bar.output bar.tab.c bar.tab.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:69: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
22 ) at_setup_line='output.at:71'
at_desc='Output files: %output="bar.c" %defines %verbose %yacc '
$at_quiet $ECHO_N " 22: Output files: %output="bar.c" %defines %verbose %yacc $ECHO_C"
at_xfail=no
(
echo "22. output.at:71: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%output="bar.c" %defines %verbose %yacc
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:71: bison foo.y "
echo output.at:71 >$at_check_line_file
( $at_traceon; bison foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:71: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:71: ls bar.output bar.c bar.h"
echo output.at:71 >$at_check_line_file
( $at_traceon; ls bar.output bar.c bar.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:71: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
23 ) at_setup_line='output.at:75'
at_desc='Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc '
$at_quiet $ECHO_N " 23: Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc $ECHO_C"
at_xfail=no
(
echo "23. output.at:75: testing ..."
$at_traceon
case "foo.y" in
*/*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
esac
cat >foo.y <<'_ATEOF'
%file-prefix="baz" %output="bar.c" %defines %verbose %yacc
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:75: bison foo.y "
echo output.at:75 >$at_check_line_file
( $at_traceon; bison foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:75: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:75: ls bar.output bar.c bar.h"
echo output.at:75 >$at_check_line_file
( $at_traceon; ls bar.output bar.c bar.h ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:75: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
24 ) at_setup_line='output.at:80'
at_desc='Output files: %defines %verbose '
$at_quiet $ECHO_N " 24: Output files: %defines %verbose $ECHO_C"
at_xfail=no
(
echo "24. output.at:80: testing ..."
$at_traceon
case "foo.yy" in
*/*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
esac
cat >foo.yy <<'_ATEOF'
%defines %verbose
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:80: bison foo.yy "
echo output.at:80 >$at_check_line_file
( $at_traceon; bison foo.yy ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:80: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:80: ls foo.output foo.tab.cc foo.tab.hh"
echo output.at:80 >$at_check_line_file
( $at_traceon; ls foo.output foo.tab.cc foo.tab.hh ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:80: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
25 ) at_setup_line='output.at:83'
at_desc='Output files: %defines %verbose -o foo.c '
$at_quiet $ECHO_N " 25: Output files: %defines %verbose -o foo.c $ECHO_C"
at_xfail=no
(
echo "25. output.at:83: testing ..."
$at_traceon
case "foo.yy" in
*/*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
esac
cat >foo.yy <<'_ATEOF'
%defines %verbose
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:83: bison -o foo.c foo.yy "
echo output.at:83 >$at_check_line_file
( $at_traceon; bison -o foo.c foo.yy ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:83: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:83: ls foo.c foo.h foo.output"
echo output.at:83 >$at_check_line_file
( $at_traceon; ls foo.c foo.h foo.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:83: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
26 ) at_setup_line='output.at:87'
at_desc='Output files: --defines=foo.hpp -o foo.c++ '
$at_quiet $ECHO_N " 26: Output files: --defines=foo.hpp -o foo.c++ $ECHO_C"
at_xfail=no
(
echo "26. output.at:87: testing ..."
$at_traceon
case "foo.yy" in
*/*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
esac
cat >foo.yy <<'_ATEOF'
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:87: bison --defines=foo.hpp -o foo.c++ foo.yy "
echo output.at:87 >$at_check_line_file
( $at_traceon; bison --defines=foo.hpp -o foo.c++ foo.yy ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:87: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:87: ls foo.c++ foo.hpp"
echo output.at:87 >$at_check_line_file
( $at_traceon; ls foo.c++ foo.hpp ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:87: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
27 ) at_setup_line='output.at:91'
at_desc='Output files: -o foo.c++ --graph=foo.gph '
$at_quiet $ECHO_N " 27: Output files: -o foo.c++ --graph=foo.gph $ECHO_C"
at_xfail=no
(
echo "27. output.at:91: testing ..."
$at_traceon
case "foo.yy" in
*/*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
esac
cat >foo.yy <<'_ATEOF'
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:91: bison -o foo.c++ --graph=foo.gph foo.yy "
echo output.at:91 >$at_check_line_file
( $at_traceon; bison -o foo.c++ --graph=foo.gph foo.yy ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:91: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:91: ls foo.c++ foo.gph"
echo output.at:91 >$at_check_line_file
( $at_traceon; ls foo.c++ foo.gph ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:91: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
28 ) at_setup_line='output.at:105'
at_desc='Output files: %skeleton "lalr1.cc" %defines %verbose '
$at_quiet $ECHO_N " 28: Output files: %skeleton "lalr1.cc" %defines %verbose $ECHO_C"
at_xfail=no
(
echo "28. output.at:105: testing ..."
$at_traceon
case "foo.yy" in
*/*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
esac
cat >foo.yy <<'_ATEOF'
%skeleton "lalr1.cc" %defines %verbose
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:105: bison foo.yy "
echo output.at:105 >$at_check_line_file
( $at_traceon; bison foo.yy ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:105: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:105: ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh"
echo output.at:105 >$at_check_line_file
( $at_traceon; ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:105: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
29 ) at_setup_line='output.at:109'
at_desc='Output files: %skeleton "lalr1.cc" %defines %verbose '
$at_quiet $ECHO_N " 29: Output files: %skeleton "lalr1.cc" %defines %verbose $ECHO_C"
at_xfail=no
(
echo "29. output.at:109: testing ..."
$at_traceon
case "subdir/foo.yy" in
*/*) mkdir `echo "subdir/foo.yy" | sed 's,/.*,,'`;;
esac
cat >subdir/foo.yy <<'_ATEOF'
%skeleton "lalr1.cc" %defines %verbose
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:109: bison subdir/foo.yy "
echo output.at:109 >$at_check_line_file
( $at_traceon; bison subdir/foo.yy ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:109: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:109: ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh"
echo output.at:109 >$at_check_line_file
( $at_traceon; ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:109: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:109: grep 'include .subdir/' foo.tab.cc"
echo output.at:109 >$at_check_line_file
( $at_traceon; grep 'include .subdir/' foo.tab.cc ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "output.at:109: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:109: grep 'include .subdir/' foo.tab.hh"
echo output.at:109 >$at_check_line_file
( $at_traceon; grep 'include .subdir/' foo.tab.hh ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "output.at:109: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
30 ) at_setup_line='output.at:114'
at_desc='Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc '
$at_quiet $ECHO_N " 30: Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc $ECHO_C"
at_xfail=no
(
echo "30. output.at:114: testing ..."
$at_traceon
case "subdir/foo.yy" in
*/*) mkdir `echo "subdir/foo.yy" | sed 's,/.*,,'`;;
esac
cat >subdir/foo.yy <<'_ATEOF'
%skeleton "lalr1.cc" %defines %verbose
%%
foo: {};
_ATEOF
$at_traceoff
echo "output.at:114: bison -o subdir/foo.cc subdir/foo.yy "
echo output.at:114 >$at_check_line_file
( $at_traceon; bison -o subdir/foo.cc subdir/foo.yy ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:114: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:114: ls subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh"
echo output.at:114 >$at_check_line_file
( $at_traceon; ls subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "output.at:114: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:114: grep 'include .subdir/' subdir/foo.cc"
echo output.at:114 >$at_check_line_file
( $at_traceon; grep 'include .subdir/' subdir/foo.cc ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "output.at:114: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "output.at:114: grep 'include .subdir/' subdir/foo.hh"
echo output.at:114 >$at_check_line_file
( $at_traceon; grep 'include .subdir/' subdir/foo.hh ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "output.at:114: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
banner-3 ) cat <<\_ATEOF
Grammar Sets (Firsts etc.).
_ATEOF
;;
31 ) at_setup_line='sets.at:66'
at_desc='Nullable'
$at_quiet $ECHO_N " 31: Nullable $ECHO_C"
at_xfail=no
(
echo "31. sets.at:66: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%%
e: 'e' | /* Nothing */;
_ATEOF
$at_traceoff
echo "sets.at:81: bison --trace=sets input.y"
echo sets.at:81 >$at_check_line_file
( $at_traceon; bison --trace=sets input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:81: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >extract.sed <<'_ATEOF'
/^NULLABLE$/ {
:null
p
n
/^[ ]*$/ !b null
}
/^FIRSTS$/ {
:firsts
p
n
/^[ ]*$/ !b firsts
}
/^FDERIVES$/ {
:fderiv
p
n
/^[ ]*$/ !b fderiv
}
/^DERIVES$/ {
:deriv
p
n
/^[ ]*$/ !b deriv
}
_ATEOF
$at_traceoff
echo "sets.at:82: sed -f extract.sed stderr"
echo sets.at:82 >$at_check_line_file
( $at_traceon; sed -f extract.sed stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:82: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "sets.at:82: mv stdout sets"
echo sets.at:82 >$at_check_line_file
( $at_traceon; mv stdout sets ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:82: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "sets.at:107: cat sets"
echo sets.at:107 >$at_check_line_file
( $at_traceon; cat sets ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "DERIVES
\$accept derives
0 e \$end
e derives
1 'e'
2 /* empty */
NULLABLE
\$accept: no
e: yes
FIRSTS
\$accept firsts
\$accept
e
e firsts
e
FDERIVES
\$accept derives
0 e \$end
1 'e'
2 /* empty */
e derives
1 'e'
2 /* empty */
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:107: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
32 ) at_setup_line='sets.at:151'
at_desc='Broken Closure'
$at_quiet $ECHO_N " 32: Broken Closure $ECHO_C"
at_xfail=no
(
echo "32. sets.at:151: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%%
a: b;
b: c;
c: d;
d: e;
e: f;
f: g;
g: h;
h: 'h';
_ATEOF
$at_traceoff
echo "sets.at:165: bison --trace=sets input.y"
echo sets.at:165 >$at_check_line_file
( $at_traceon; bison --trace=sets input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:165: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "sets.at:183: sed -n 's/[ ]*\$//;/^RTC: Firsts Output BEGIN/,/^RTC: Firsts Output END/p' stderr"
echo sets.at:183 >$at_check_line_file
( $at_traceon; sed -n 's/[ ]*$//;/^RTC: Firsts Output BEGIN/,/^RTC: Firsts Output END/p' stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "RTC: Firsts Output BEGIN
012345678
.---------.
0|111111111|
1| 11111111|
2| 1111111|
3| 111111|
4| 11111|
5| 1111|
6| 111|
7| 11|
8| 1|
\`---------'
RTC: Firsts Output END
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:183: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
33 ) at_setup_line='sets.at:193'
at_desc='Firsts'
$at_quiet $ECHO_N " 33: Firsts $ECHO_C"
at_xfail=no
(
echo "33. sets.at:193: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%nonassoc '<' '>'
%left '+' '-'
%right '^' '='
%%
exp:
exp '<' exp
| exp '>' exp
| exp '+' exp
| exp '-' exp
| exp '^' exp
| exp '=' exp
| "exp"
;
_ATEOF
$at_traceoff
echo "sets.at:211: bison --trace=sets input.y"
echo sets.at:211 >$at_check_line_file
( $at_traceon; bison --trace=sets input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:211: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >extract.sed <<'_ATEOF'
/^NULLABLE$/ {
:null
p
n
/^[ ]*$/ !b null
}
/^FIRSTS$/ {
:firsts
p
n
/^[ ]*$/ !b firsts
}
/^FDERIVES$/ {
:fderiv
p
n
/^[ ]*$/ !b fderiv
}
/^DERIVES$/ {
:deriv
p
n
/^[ ]*$/ !b deriv
}
_ATEOF
$at_traceoff
echo "sets.at:212: sed -f extract.sed stderr"
echo sets.at:212 >$at_check_line_file
( $at_traceon; sed -f extract.sed stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:212: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "sets.at:212: mv stdout sets"
echo sets.at:212 >$at_check_line_file
( $at_traceon; mv stdout sets ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:212: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "sets.at:252: cat sets"
echo sets.at:252 >$at_check_line_file
( $at_traceon; cat sets ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "DERIVES
\$accept derives
0 exp \$end
exp derives
1 exp '<' exp
2 exp '>' exp
3 exp '+' exp
4 exp '-' exp
5 exp '^' exp
6 exp '=' exp
7 \"exp\"
NULLABLE
\$accept: no
exp: no
FIRSTS
\$accept firsts
\$accept
exp
exp firsts
exp
FDERIVES
\$accept derives
0 exp \$end
1 exp '<' exp
2 exp '>' exp
3 exp '+' exp
4 exp '-' exp
5 exp '^' exp
6 exp '=' exp
7 \"exp\"
exp derives
1 exp '<' exp
2 exp '>' exp
3 exp '+' exp
4 exp '-' exp
5 exp '^' exp
6 exp '=' exp
7 \"exp\"
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:252: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
34 ) at_setup_line='sets.at:269'
at_desc='Accept'
$at_quiet $ECHO_N " 34: Accept $ECHO_C"
at_xfail=no
(
echo "34. sets.at:269: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%token END 0
%%
input:
'a'
| '(' input ')'
| '(' error END
;
_ATEOF
$at_traceoff
echo "sets.at:281: bison -v -o input.c input.y"
echo sets.at:281 >$at_check_line_file
( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:281: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "sets.at:285: sed -n 's/.*define YYFINAL *\\([0-9][0-9]*\\)/final state \\1/p' input.c"
echo sets.at:285 >$at_check_line_file
( $at_traceon; sed -n 's/.*define YYFINAL *\([0-9][0-9]*\)/final state \1/p' input.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:285: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
mv stdout expout
$at_traceoff
echo "sets.at:300: sed -n '
/^state \\(.*\\)/{
s//final state \\1/
x
}
/ accept/{
x
p
q
}
' input.output"
echo sets.at:300 >$at_check_line_file
( $at_traceon; sed -n '
/^state \(.*\)/{
s//final state \1/
x
}
/ accept/{
x
p
q
}
' input.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "sets.at:300: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
banner-4 ) cat <<\_ATEOF
Grammar Reduction.
_ATEOF
;;
35 ) at_setup_line='reduce.at:26'
at_desc='Useless Terminals'
$at_quiet $ECHO_N " 35: Useless Terminals $ECHO_C"
at_xfail=no
(
echo "35. reduce.at:26: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%verbose
%output="input.c"
%token useless1
%token useless2
%token useless3
%token useless4
%token useless5
%token useless6
%token useless7
%token useless8
%token useless9
%token useful
%%
exp: useful;
_ATEOF
$at_traceoff
echo "reduce.at:47: bison input.y"
echo reduce.at:47 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:47: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "reduce.at:60: sed -n '/^Grammar/q;/^\$/!p' input.output"
echo reduce.at:60 >$at_check_line_file
( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "Terminals which are not used
useless1
useless2
useless3
useless4
useless5
useless6
useless7
useless8
useless9
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:60: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
36 ) at_setup_line='reduce.at:70'
at_desc='Useless Nonterminals'
$at_quiet $ECHO_N " 36: Useless Nonterminals $ECHO_C"
at_xfail=no
(
echo "36. reduce.at:70: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%verbose
%output="input.c"
%nterm useless1
%nterm useless2
%nterm useless3
%nterm useless4
%nterm useless5
%nterm useless6
%nterm useless7
%nterm useless8
%nterm useless9
%token useful
%%
exp: useful;
_ATEOF
$at_traceoff
echo "reduce.at:102: bison input.y"
echo reduce.at:102 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: warning: 9 useless nonterminals
input.y:4.8-15: warning: useless nonterminal: useless1
input.y:5.8-15: warning: useless nonterminal: useless2
input.y:6.8-15: warning: useless nonterminal: useless3
input.y:7.8-15: warning: useless nonterminal: useless4
input.y:8.8-15: warning: useless nonterminal: useless5
input.y:9.8-15: warning: useless nonterminal: useless6
input.y:10.8-15: warning: useless nonterminal: useless7
input.y:11.8-15: warning: useless nonterminal: useless8
input.y:12.8-15: warning: useless nonterminal: useless9
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:102: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "reduce.at:115: sed -n '/^Grammar/q;/^\$/!p' input.output"
echo reduce.at:115 >$at_check_line_file
( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "Useless nonterminals
useless1
useless2
useless3
useless4
useless5
useless6
useless7
useless8
useless9
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:115: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
37 ) at_setup_line='reduce.at:125'
at_desc='Useless Rules'
$at_quiet $ECHO_N " 37: Useless Rules $ECHO_C"
at_xfail=no
(
echo "37. reduce.at:125: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%verbose
%output="input.c"
%token useful
%%
exp: useful;
useless1: '1';
useless2: '2';
useless3: '3';
useless4: '4';
useless5: '5';
useless6: '6';
useless7: '7';
useless8: '8';
useless9: '9';
_ATEOF
$at_traceoff
echo "reduce.at:166: bison input.y"
echo reduce.at:166 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: warning: 9 useless nonterminals and 9 useless rules
input.y:6.1-8: warning: useless nonterminal: useless1
input.y:7.1-8: warning: useless nonterminal: useless2
input.y:8.1-8: warning: useless nonterminal: useless3
input.y:9.1-8: warning: useless nonterminal: useless4
input.y:10.1-8: warning: useless nonterminal: useless5
input.y:11.1-8: warning: useless nonterminal: useless6
input.y:12.1-8: warning: useless nonterminal: useless7
input.y:13.1-8: warning: useless nonterminal: useless8
input.y:14.1-8: warning: useless nonterminal: useless9
input.y:6.11-13: warning: useless rule: useless1: '1'
input.y:7.11-13: warning: useless rule: useless2: '2'
input.y:8.11-13: warning: useless rule: useless3: '3'
input.y:9.11-13: warning: useless rule: useless4: '4'
input.y:10.11-13: warning: useless rule: useless5: '5'
input.y:11.11-13: warning: useless rule: useless6: '6'
input.y:12.11-13: warning: useless rule: useless7: '7'
input.y:13.11-13: warning: useless rule: useless8: '8'
input.y:14.11-13: warning: useless rule: useless9: '9'
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:166: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "reduce.at:199: sed -n '/^Grammar/q;/^\$/!p' input.output"
echo reduce.at:199 >$at_check_line_file
( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "Useless nonterminals
useless1
useless2
useless3
useless4
useless5
useless6
useless7
useless8
useless9
Terminals which are not used
'1'
'2'
'3'
'4'
'5'
'6'
'7'
'8'
'9'
Useless rules
2 useless1: '1'
3 useless2: '2'
4 useless3: '3'
5 useless4: '4'
6 useless5: '5'
7 useless6: '6'
8 useless7: '7'
9 useless8: '8'
10 useless9: '9'
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:199: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
38 ) at_setup_line='reduce.at:212'
at_desc='Reduced Automaton'
$at_quiet $ECHO_N " 38: Reduced Automaton $ECHO_C"
at_xfail=no
(
echo "38. reduce.at:212: testing ..."
$at_traceon
cat >not-reduced.y <<'_ATEOF'
/* A useless token. */
%token useless_token
/* A useful one. */
%token useful
%verbose
%output="not-reduced.c"
%%
exp: useful { /* A useful action. */ }
| non_productive { /* A non productive action. */ }
;
not_reachable: useful { /* A not reachable action. */ }
;
non_productive: non_productive useless_token
{ /* Another non productive action. */ }
;
%%
_ATEOF
$at_traceoff
echo "reduce.at:248: bison not-reduced.y"
echo reduce.at:248 >$at_check_line_file
( $at_traceon; bison not-reduced.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "not-reduced.y: warning: 2 useless nonterminals and 3 useless rules
not-reduced.y:14.1-13: warning: useless nonterminal: not_reachable
not-reduced.y:11.6-19: warning: useless nonterminal: non_productive
not-reduced.y:11.6-57: warning: useless rule: exp: non_productive
not-reduced.y:14.16-56: warning: useless rule: not_reachable: useful
not-reduced.y:17.17-18.63: warning: useless rule: non_productive: non_productive useless_token
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:248: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "reduce.at:260: sed -n '/^Grammar/q;/^\$/!p' not-reduced.output"
echo reduce.at:260 >$at_check_line_file
( $at_traceon; sed -n '/^Grammar/q;/^$/!p' not-reduced.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "Useless nonterminals
not_reachable
non_productive
Terminals which are not used
useless_token
Useless rules
2 exp: non_productive
3 not_reachable: useful
4 non_productive: non_productive useless_token
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:260: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >reduced.y <<'_ATEOF'
/* A useless token. */
%token useless_token
/* A useful one. */
%token useful
%verbose
%output="reduced.c"
%%
exp: useful { /* A useful action. */ }
// | non_productive { /* A non productive action. */ } */
;
//not_reachable: useful { /* A not reachable action. */ }
// ;
//non_productive: non_productive useless_token
// { /* Another non productive action. */ }
// ;
%%
_ATEOF
$at_traceoff
echo "reduce.at:287: bison reduced.y"
echo reduce.at:287 >$at_check_line_file
( $at_traceon; bison reduced.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:287: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cp reduced.c expout
$at_traceoff
echo "reduce.at:291: sed 's/not-reduced/reduced/g' not-reduced.c"
echo reduce.at:291 >$at_check_line_file
( $at_traceon; sed 's/not-reduced/reduced/g' not-reduced.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:291: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
39 ) at_setup_line='reduce.at:301'
at_desc='Underivable Rules'
$at_quiet $ECHO_N " 39: Underivable Rules $ECHO_C"
at_xfail=no
(
echo "39. reduce.at:301: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%verbose
%output="input.c"
%token useful
%%
exp: useful | underivable;
underivable: indirection;
indirection: underivable;
_ATEOF
$at_traceoff
echo "reduce.at:322: bison input.y"
echo reduce.at:322 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: warning: 2 useless nonterminals and 3 useless rules
input.y:5.15-25: warning: useless nonterminal: underivable
input.y:6.14-24: warning: useless nonterminal: indirection
input.y:5.15-25: warning: useless rule: exp: underivable
input.y:6.14-24: warning: useless rule: underivable: indirection
input.y:7.14-24: warning: useless rule: indirection: underivable
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:322: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "reduce.at:332: sed -n '/^Grammar/q;/^\$/!p' input.output"
echo reduce.at:332 >$at_check_line_file
( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "Useless nonterminals
underivable
indirection
Useless rules
2 exp: underivable
3 underivable: indirection
4 indirection: underivable
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "reduce.at:332: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
40 ) at_setup_line='reduce.at:342'
at_desc='Empty Language'
$at_quiet $ECHO_N " 40: Empty Language $ECHO_C"
at_xfail=no
(
echo "40. reduce.at:342: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%output="input.c"
%%
exp: exp;
_ATEOF
$at_traceoff
echo "reduce.at:353: bison input.y"
echo reduce.at:353 >$at_check_line_file
( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: warning: 2 useless nonterminals and 2 useless rules
input.y:3.1-3: fatal error: start symbol exp does not derive any sentence
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "reduce.at:353: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
banner-5 ) cat <<\_ATEOF
User Actions.
_ATEOF
;;
41 ) at_setup_line='synclines.at:95'
at_desc='Prologue synch line'
$at_quiet $ECHO_N " 41: Prologue synch line $ECHO_C"
at_xfail=no
(
echo "41. synclines.at:95: testing ..."
$at_traceon
cat >syncline.c <<'_ATEOF'
_ATEOF
$at_traceoff
echo "synclines.at:95: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
echo synclines.at:95 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:95: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:95 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:95: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:95: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
echo synclines.at:95 >$at_check_line_file
( $at_traceon; test "`cat stdout`" = 'syncline.c:1: at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:95: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input.y <<'_ATEOF'
%{
void yyerror (const char *s);
int yylex (void);
%}
%%
exp: '0';
_ATEOF
$at_traceoff
echo "synclines.at:95: bison -o input.c input.y"
echo synclines.at:95 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:95: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:95: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
echo synclines.at:95 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:95: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:95 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:95: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:95: cat stdout"
echo synclines.at:95 >$at_check_line_file
( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "input.y:2: #error \"2\"
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:95: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
42 ) at_setup_line='synclines.at:115'
at_desc='%union synch line'
$at_quiet $ECHO_N " 42: %union synch line $ECHO_C"
at_xfail=no
(
echo "42. synclines.at:115: testing ..."
$at_traceon
cat >syncline.c <<'_ATEOF'
_ATEOF
$at_traceoff
echo "synclines.at:115: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
echo synclines.at:115 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:115: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:115 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:115: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:115: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
echo synclines.at:115 >$at_check_line_file
( $at_traceon; test "`cat stdout`" = 'syncline.c:1: at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:115: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input.y <<'_ATEOF'
%union {
char dummy;
}
%{
void yyerror (const char *s);
int yylex (void);
%}
%%
exp: '0';
_ATEOF
$at_traceoff
echo "synclines.at:115: bison -o input.c input.y"
echo synclines.at:115 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:115: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:115: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
echo synclines.at:115 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:115: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:115 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:115: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:115: cat stdout"
echo synclines.at:115 >$at_check_line_file
( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "input.y:2: #error \"2\"
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:115: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
43 ) at_setup_line='synclines.at:138'
at_desc='Postprologue synch line'
$at_quiet $ECHO_N " 43: Postprologue synch line $ECHO_C"
at_xfail=no
(
echo "43. synclines.at:138: testing ..."
$at_traceon
cat >syncline.c <<'_ATEOF'
_ATEOF
$at_traceoff
echo "synclines.at:138: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
echo synclines.at:138 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:138: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:138 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:138: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:138: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
echo synclines.at:138 >$at_check_line_file
( $at_traceon; test "`cat stdout`" = 'syncline.c:1: at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:138: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input.y <<'_ATEOF'
%{
void yyerror (const char *s);
int yylex (void);
%}
%union
{
int ival;
}
%{
%}
%%
exp: '0';
_ATEOF
$at_traceoff
echo "synclines.at:138: bison -o input.c input.y"
echo synclines.at:138 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:138: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:138: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
echo synclines.at:138 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:138: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:138 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:138: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:138: cat stdout"
echo synclines.at:138 >$at_check_line_file
( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "input.y:10: #error \"10\"
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:138: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
44 ) at_setup_line='synclines.at:157'
at_desc='Action synch line'
$at_quiet $ECHO_N " 44: Action synch line $ECHO_C"
at_xfail=no
(
echo "44. synclines.at:157: testing ..."
$at_traceon
cat >syncline.c <<'_ATEOF'
_ATEOF
$at_traceoff
echo "synclines.at:157: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
echo synclines.at:157 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:157: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:157 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:157: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:157: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
echo synclines.at:157 >$at_check_line_file
( $at_traceon; test "`cat stdout`" = 'syncline.c:1: at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:157: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input.y <<'_ATEOF'
%{
void yyerror (const char *s);
int yylex (void);
%}
%%
exp:
{
};
_ATEOF
$at_traceoff
echo "synclines.at:157: bison -o input.c input.y"
echo synclines.at:157 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:157: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:157: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
echo synclines.at:157 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:157: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:157 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:157: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:157: cat stdout"
echo synclines.at:157 >$at_check_line_file
( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "input.y:8: #error \"8\"
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:157: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
45 ) at_setup_line='synclines.at:175'
at_desc='Epilogue synch line'
$at_quiet $ECHO_N " 45: Epilogue synch line $ECHO_C"
at_xfail=no
(
echo "45. synclines.at:175: testing ..."
$at_traceon
cat >syncline.c <<'_ATEOF'
_ATEOF
$at_traceoff
echo "synclines.at:175: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
echo synclines.at:175 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:175: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:175 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:175: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:175: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
echo synclines.at:175 >$at_check_line_file
( $at_traceon; test "`cat stdout`" = 'syncline.c:1: at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:175: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input.y <<'_ATEOF'
%{
void yyerror (const char *s);
int yylex (void);
%}
%%
exp: '0';
%%
_ATEOF
$at_traceoff
echo "synclines.at:175: bison -o input.c input.y"
echo synclines.at:175 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:175: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:175: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
echo synclines.at:175 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
*);;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:175: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
echo synclines.at:175 >$at_check_line_file
( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo stdout:; tee stdout <$at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:175: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "synclines.at:175: cat stdout"
echo synclines.at:175 >$at_check_line_file
( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "input.y:8: #error \"8\"
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "synclines.at:175: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
banner-6 ) cat <<\_ATEOF
Parser Headers.
_ATEOF
;;
46 ) at_setup_line='headers.at:27'
at_desc='%union and --defines'
$at_quiet $ECHO_N " 46: %union and --defines $ECHO_C"
at_xfail=no
(
echo "46. headers.at:27: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%union
{
int integer;
char *string ;
}
%%
exp: {};
_ATEOF
$at_traceoff
echo "headers.at:39: bison --defines input.y"
echo headers.at:39 >$at_check_line_file
( $at_traceon; bison --defines input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:39: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
47 ) at_setup_line='headers.at:77'
at_desc='Invalid CPP guards: input/input'
$at_quiet $ECHO_N " 47: Invalid CPP guards: input/input $ECHO_C"
at_xfail=no
(
echo "47. headers.at:77: testing ..."
$at_traceon
dirname=`(dirname input/input) 2>/dev/null ||
$as_expr Xinput/input : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
Xinput/input : 'X\(//\)[^/]' \| \
Xinput/input : 'X\(//\)$' \| \
Xinput/input : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo Xinput/input |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
{ if $as_mkdir_p; then
mkdir -p $dirname
else
as_dir=$dirname
as_dirs=
while test ! -d "$as_dir"; do
as_dirs="$as_dir $as_dirs"
as_dir=`(dirname "$as_dir") 2>/dev/null ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
done
test ! -n "$as_dirs" || mkdir $as_dirs
fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirname" >&5
echo "$as_me: error: cannot create directory $dirname" >&2;}
{ (exit 1); exit 1; }; }; }
cat >input/input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
void yyerror (const char *);
int yylex (void);
%}
%%
dummy:;
%%
_ATEOF
$at_traceoff
echo "headers.at:77: bison --defines=input/input.h --output=y.tab.c input/input.y"
echo headers.at:77 >$at_check_line_file
( $at_traceon; bison --defines=input/input.h --output=y.tab.c input/input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:77: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "headers.at:77: \$CC \$CFLAGS \$CPPFLAGS -o y.tab.o -I. -c y.tab.c"
echo headers.at:77 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -o y.tab.o -I. -c y.tab.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:77: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
48 ) at_setup_line='headers.at:78'
at_desc='Invalid CPP guards: 9foo'
$at_quiet $ECHO_N " 48: Invalid CPP guards: 9foo $ECHO_C"
at_xfail=no
(
echo "48. headers.at:78: testing ..."
$at_traceon
dirname=`(dirname 9foo) 2>/dev/null ||
$as_expr X9foo : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X9foo : 'X\(//\)[^/]' \| \
X9foo : 'X\(//\)$' \| \
X9foo : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X9foo |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
{ if $as_mkdir_p; then
mkdir -p $dirname
else
as_dir=$dirname
as_dirs=
while test ! -d "$as_dir"; do
as_dirs="$as_dir $as_dirs"
as_dir=`(dirname "$as_dir") 2>/dev/null ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
done
test ! -n "$as_dirs" || mkdir $as_dirs
fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirname" >&5
echo "$as_me: error: cannot create directory $dirname" >&2;}
{ (exit 1); exit 1; }; }; }
cat >9foo.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
void yyerror (const char *);
int yylex (void);
%}
%%
dummy:;
%%
_ATEOF
$at_traceoff
echo "headers.at:78: bison --defines=9foo.h --output=y.tab.c 9foo.y"
echo headers.at:78 >$at_check_line_file
( $at_traceon; bison --defines=9foo.h --output=y.tab.c 9foo.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:78: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "headers.at:78: \$CC \$CFLAGS \$CPPFLAGS -o y.tab.o -I. -c y.tab.c"
echo headers.at:78 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -o y.tab.o -I. -c y.tab.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:78: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
49 ) at_setup_line='headers.at:87'
at_desc='export YYLTYPE'
$at_quiet $ECHO_N " 49: export YYLTYPE $ECHO_C"
at_xfail=no
(
echo "49. headers.at:87: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%locations
%name-prefix="my_"
%{
static int
my_lex (void)
{
return EOF;
}
static void
my_error (const char *msg)
{
fprintf (stderr, "%s\n", msg);
}
%}
%%
exp:;
_ATEOF
$at_traceoff
echo "headers.at:114: bison --defines -o input.c input.y"
echo headers.at:114 >$at_check_line_file
( $at_traceon; bison --defines -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:114: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >caller.c <<'_ATEOF'
YYLTYPE *my_llocp = &my_lloc;
int my_parse (void);
int
main (void)
{
return my_parse ();
}
_ATEOF
$at_traceoff
echo "headers.at:132: \$CC \$CFLAGS \$CPPFLAGS -o caller.o -c caller.c"
echo headers.at:132 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -o caller.o -c caller.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:132: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "headers.at:133: \$CC \$CFLAGS \$CPPFLAGS -o input.o -c input.c"
echo headers.at:133 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -c input.c ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:133: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "headers.at:134: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o caller caller.o input.o \$LIBS"
echo headers.at:134 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o caller caller.o input.o $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:134: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "headers.at:135: \$PREPARSER ./caller"
echo headers.at:135 >$at_check_line_file
( $at_traceon; $PREPARSER ./caller ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "headers.at:135: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
banner-7 ) cat <<\_ATEOF
User Actions.
_ATEOF
;;
50 ) at_setup_line='actions.at:25'
at_desc='Mid-rule actions'
$at_quiet $ECHO_N " 50: Mid-rule actions $ECHO_C"
at_xfail=no
(
echo "50. actions.at:25: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%error-verbose
%debug
%{
static void yyerror (const char *msg);
static int yylex (void);
%}
%%
exp: { putchar ('0'); }
'1' { putchar ('1'); }
'2' { putchar ('2'); }
'3' { putchar ('3'); }
'4' { putchar ('4'); }
'5' { putchar ('5'); }
'6' { putchar ('6'); }
'7' { putchar ('7'); }
'8' { putchar ('8'); }
'9' { putchar ('9'); }
{ putchar ('\n'); }
;
%%
static int
yylex (void)
{
static const char *input = "123456789";
return *input++;
}
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
main (void)
{
return yyparse ();
}
_ATEOF
$at_traceoff
echo "actions.at:75: bison -d -v -o input.c input.y"
echo actions.at:75 >$at_check_line_file
( $at_traceon; bison -d -v -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:75: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:76: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
echo actions.at:76 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:76: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:79: \$PREPARSER ./input"
echo actions.at:79 >$at_check_line_file
( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "0123456789
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:79: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
51 ) at_setup_line='actions.at:91'
at_desc='Exotic Dollars'
$at_quiet $ECHO_N " 51: Exotic Dollars $ECHO_C"
at_xfail=no
(
echo "51. actions.at:91: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%error-verbose
%debug
%{
static void yyerror (const char *msg);
static int yylex (void);
%}
%union
{
int val;
};
%type <val> a_1 a_2 a_5
sum_of_the_five_previous_values
%%
exp: a_1 a_2 { $<val>$ = 3; } { $<val>$ = $<val>3 + 1; } a_5
sum_of_the_five_previous_values
{
USE (($1, $2, $<foo>3, $<foo>4, $5));
printf ("%d\n", $6);
}
;
a_1: { $$ = 1; };
a_2: { $$ = 2; };
a_5: { $$ = 5; };
sum_of_the_five_previous_values:
{
$$ = $<val>0 + $<val>-1 + $<val>-2 + $<val>-3 + $<val>-4;
}
;
%%
static int
yylex (void)
{
return EOF;
}
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\n", msg);
}
int
main (void)
{
return yyparse ();
}
_ATEOF
$at_traceoff
echo "actions.at:150: bison -d -v -o input.c input.y"
echo actions.at:150 >$at_check_line_file
( $at_traceon; bison -d -v -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:150: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:151: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
echo actions.at:151 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:151: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:154: \$PREPARSER ./input"
echo actions.at:154 >$at_check_line_file
( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "15
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:154: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
52 ) at_setup_line='actions.at:527'
at_desc='Printers and Destructors : '
$at_quiet $ECHO_N " 52: Printers and Destructors : $ECHO_C"
at_xfail=no
(
echo "52. actions.at:527: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
%}
%error-verbose
%debug
%verbose
%locations
%{
static int yylex (void);
static void yyerror (const char *msg);
%}
%printer
{
fprintf (yyoutput, "%d", $$);
}
input line thing 'x' 'y'
%destructor
{ printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
input
%destructor
{ printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
line
%destructor
{ printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
thing
%destructor
{ printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
'x'
%destructor
{ printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
'y'
%%
/*
This grammar is made to exercise error recovery.
"Lines" starting with `(' support error recovery, with
')' as synchronizing token. Lines starting with 'x' can never
be recovered from if in error.
*/
input:
/* Nothing. */
{
$$ = 0;
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
}
| line input /* Right recursive to load the stack so that popping at
EOF can be exercised. */
{
$$ = 2;
printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
}
;
line:
thing thing thing ';'
{
$$ = $1;
printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
}
| '(' error ')'
{
$$ = -1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
}
;
thing:
'x'
{
$$ = $1;
printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1));
}
;
%%
/* Alias to ARGV[1]. */
const char *source = 0;
static int
yylex (void)
{
static unsigned int counter = 0;
int c = (yylval) = counter++;
/* As in BASIC, line numbers go from 10 to 10. */
(yylloc).first_line = (yylloc).first_column = 10 * c;
(yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
if (source[c])
printf ("sending: '%c'", source[c]);
else
printf ("sending: EOF");
printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
return source[c];
}
static void
yyerror (const char *msg)
{
printf ("%d-%d: %s\n", RANGE (yylloc), msg);
}
int
main (int argc, const char *argv[])
{
int status;
yydebug = !!getenv ("YYDEBUG");
assert (argc == 2);
source = argv[1];
status = yyparse ();
switch (status)
{
case 0: printf ("Successful parse.\n"); break;
case 1: printf ("Parsing FAILED.\n"); break;
default: printf ("Parsing FAILED (status %d).\n", status); break;
}
return status;
}
_ATEOF
$at_traceoff
echo "actions.at:527: bison -o input.c input.y"
echo actions.at:527 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:527: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:527: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
echo actions.at:527 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:527: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:527: \$PREPARSER ./input '(x)'"
echo actions.at:527 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: ')' (2@20-29)
line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (0@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:527: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:527: \$PREPARSER ./input '(y)'"
echo actions.at:527 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'y' (1@10-19)
10-19: syntax error, unexpected 'y', expecting 'x'
Freeing token 'y' (1@10-19)
sending: ')' (2@20-29)
line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (-1@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:527: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:527: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
echo actions.at:527 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: 'x' (2@20-29)
thing (2@20-29): 'x' (2@20-29)
sending: 'x' (3@30-39)
30-39: syntax error, unexpected 'x', expecting ')'
Freeing nterm thing (2@20-29)
Freeing nterm thing (1@10-19)
Freeing token 'x' (3@30-39)
sending: 'x' (4@40-49)
Freeing token 'x' (4@40-49)
sending: 'x' (5@50-59)
Freeing token 'x' (5@50-59)
sending: ')' (6@60-69)
line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
sending: '(' (7@70-79)
sending: 'x' (8@80-89)
thing (8@80-89): 'x' (8@80-89)
sending: ')' (9@90-99)
line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
sending: '(' (10@100-109)
sending: 'x' (11@110-119)
thing (11@110-119): 'x' (11@110-119)
sending: ')' (12@120-129)
line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
sending: 'y' (13@130-139)
input (0@129-129): /* Nothing */
input (2@100-129): line (10@100-129) input (0@129-129)
input (2@70-129): line (7@70-99) input (2@100-129)
input (2@0-129): line (-1@0-69) input (2@70-129)
130-139: syntax error, unexpected 'y', expecting \$end
Freeing nterm input (2@0-129)
Freeing token 'y' (13@130-139)
Parsing FAILED.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "actions.at:527: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:527: \$PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)'"
echo actions.at:527 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: ')' (2@20-29)
line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
sending: '(' (3@30-39)
sending: 'x' (4@40-49)
thing (4@40-49): 'x' (4@40-49)
sending: ')' (5@50-59)
line (3@30-59): '(' (3@30-39) thing (4@40-49) ')' (5@50-59)
sending: '(' (6@60-69)
sending: 'x' (7@70-79)
thing (7@70-79): 'x' (7@70-79)
sending: ')' (8@80-89)
line (6@60-89): '(' (6@60-69) thing (7@70-79) ')' (8@80-89)
sending: '(' (9@90-99)
sending: 'x' (10@100-109)
thing (10@100-109): 'x' (10@100-109)
sending: ')' (11@110-119)
line (9@90-119): '(' (9@90-99) thing (10@100-109) ')' (11@110-119)
sending: '(' (12@120-129)
sending: 'x' (13@130-139)
thing (13@130-139): 'x' (13@130-139)
sending: ')' (14@140-149)
line (12@120-149): '(' (12@120-129) thing (13@130-139) ')' (14@140-149)
sending: '(' (15@150-159)
sending: 'x' (16@160-169)
thing (16@160-169): 'x' (16@160-169)
sending: ')' (17@170-179)
line (15@150-179): '(' (15@150-159) thing (16@160-169) ')' (17@170-179)
sending: '(' (18@180-189)
sending: 'x' (19@190-199)
thing (19@190-199): 'x' (19@190-199)
sending: ')' (20@200-209)
200-209: memory exhausted
Freeing nterm thing (19@190-199)
Freeing nterm line (15@150-179)
Freeing nterm line (12@120-149)
Freeing nterm line (9@90-119)
Freeing nterm line (6@60-89)
Freeing nterm line (3@30-59)
Freeing nterm line (0@0-29)
Parsing FAILED (status 2).
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
2) ;;
*) echo "actions.at:527: exit code was $at_status, expected 2"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
53 ) at_setup_line='actions.at:528'
at_desc='Printers and Destructors with union: '
$at_quiet $ECHO_N " 53: Printers and Destructors with union: $ECHO_C"
at_xfail=no
(
echo "53. actions.at:528: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
%}
%error-verbose
%debug
%verbose
%locations
%union
{
int ival;
}
%{
static int yylex (void);
static void yyerror (const char *msg);
%}
%type <ival> '(' 'x' 'y' ')' ';' thing line input
%printer
{
fprintf (yyoutput, "%d", $$);
}
input line thing 'x' 'y'
%destructor
{ printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
input
%destructor
{ printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
line
%destructor
{ printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
thing
%destructor
{ printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
'x'
%destructor
{ printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
'y'
%%
/*
This grammar is made to exercise error recovery.
"Lines" starting with `(' support error recovery, with
')' as synchronizing token. Lines starting with 'x' can never
be recovered from if in error.
*/
input:
/* Nothing. */
{
$$ = 0;
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
}
| line input /* Right recursive to load the stack so that popping at
EOF can be exercised. */
{
$$ = 2;
printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
}
;
line:
thing thing thing ';'
{
$$ = $1;
printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
}
| '(' error ')'
{
$$ = -1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
}
;
thing:
'x'
{
$$ = $1;
printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1));
}
;
%%
/* Alias to ARGV[1]. */
const char *source = 0;
static int
yylex (void)
{
static unsigned int counter = 0;
int c = (yylval).ival = counter++;
/* As in BASIC, line numbers go from 10 to 10. */
(yylloc).first_line = (yylloc).first_column = 10 * c;
(yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
if (source[c])
printf ("sending: '%c'", source[c]);
else
printf ("sending: EOF");
printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
return source[c];
}
static void
yyerror (const char *msg)
{
printf ("%d-%d: %s\n", RANGE (yylloc), msg);
}
int
main (int argc, const char *argv[])
{
int status;
yydebug = !!getenv ("YYDEBUG");
assert (argc == 2);
source = argv[1];
status = yyparse ();
switch (status)
{
case 0: printf ("Successful parse.\n"); break;
case 1: printf ("Parsing FAILED.\n"); break;
default: printf ("Parsing FAILED (status %d).\n", status); break;
}
return status;
}
_ATEOF
$at_traceoff
echo "actions.at:528: bison -o input.c input.y"
echo actions.at:528 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:528: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:528: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
echo actions.at:528 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:528: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:528: \$PREPARSER ./input '(x)'"
echo actions.at:528 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: ')' (2@20-29)
line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (0@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:528: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:528: \$PREPARSER ./input '(y)'"
echo actions.at:528 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'y' (1@10-19)
10-19: syntax error, unexpected 'y', expecting 'x'
Freeing token 'y' (1@10-19)
sending: ')' (2@20-29)
line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (-1@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:528: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:528: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
echo actions.at:528 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: 'x' (2@20-29)
thing (2@20-29): 'x' (2@20-29)
sending: 'x' (3@30-39)
30-39: syntax error, unexpected 'x', expecting ')'
Freeing nterm thing (2@20-29)
Freeing nterm thing (1@10-19)
Freeing token 'x' (3@30-39)
sending: 'x' (4@40-49)
Freeing token 'x' (4@40-49)
sending: 'x' (5@50-59)
Freeing token 'x' (5@50-59)
sending: ')' (6@60-69)
line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
sending: '(' (7@70-79)
sending: 'x' (8@80-89)
thing (8@80-89): 'x' (8@80-89)
sending: ')' (9@90-99)
line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
sending: '(' (10@100-109)
sending: 'x' (11@110-119)
thing (11@110-119): 'x' (11@110-119)
sending: ')' (12@120-129)
line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
sending: 'y' (13@130-139)
input (0@129-129): /* Nothing */
input (2@100-129): line (10@100-129) input (0@129-129)
input (2@70-129): line (7@70-99) input (2@100-129)
input (2@0-129): line (-1@0-69) input (2@70-129)
130-139: syntax error, unexpected 'y', expecting \$end
Freeing nterm input (2@0-129)
Freeing token 'y' (13@130-139)
Parsing FAILED.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "actions.at:528: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:528: \$PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)'"
echo actions.at:528 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: ')' (2@20-29)
line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
sending: '(' (3@30-39)
sending: 'x' (4@40-49)
thing (4@40-49): 'x' (4@40-49)
sending: ')' (5@50-59)
line (3@30-59): '(' (3@30-39) thing (4@40-49) ')' (5@50-59)
sending: '(' (6@60-69)
sending: 'x' (7@70-79)
thing (7@70-79): 'x' (7@70-79)
sending: ')' (8@80-89)
line (6@60-89): '(' (6@60-69) thing (7@70-79) ')' (8@80-89)
sending: '(' (9@90-99)
sending: 'x' (10@100-109)
thing (10@100-109): 'x' (10@100-109)
sending: ')' (11@110-119)
line (9@90-119): '(' (9@90-99) thing (10@100-109) ')' (11@110-119)
sending: '(' (12@120-129)
sending: 'x' (13@130-139)
thing (13@130-139): 'x' (13@130-139)
sending: ')' (14@140-149)
line (12@120-149): '(' (12@120-129) thing (13@130-139) ')' (14@140-149)
sending: '(' (15@150-159)
sending: 'x' (16@160-169)
thing (16@160-169): 'x' (16@160-169)
sending: ')' (17@170-179)
line (15@150-179): '(' (15@150-159) thing (16@160-169) ')' (17@170-179)
sending: '(' (18@180-189)
sending: 'x' (19@190-199)
thing (19@190-199): 'x' (19@190-199)
sending: ')' (20@200-209)
200-209: memory exhausted
Freeing nterm thing (19@190-199)
Freeing nterm line (15@150-179)
Freeing nterm line (12@120-149)
Freeing nterm line (9@90-119)
Freeing nterm line (6@60-89)
Freeing nterm line (3@30-59)
Freeing nterm line (0@0-29)
Parsing FAILED (status 2).
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
2) ;;
*) echo "actions.at:528: exit code was $at_status, expected 2"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
54 ) at_setup_line='actions.at:533'
at_desc='Printers and Destructors : %defines %skeleton "lalr1.cc"'
$at_quiet $ECHO_N " 54: Printers and Destructors : %defines %skeleton "lalr1.cc"$ECHO_C"
at_xfail=no
(
echo "54. actions.at:533: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
%}
%error-verbose
%debug
%verbose
%locations
%defines %skeleton "lalr1.cc"
%define "global_tokens_and_yystype"
%{
typedef yy::location YYLTYPE;
static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
%}
%printer
{
debug_stream () << $$;;
}
input line thing 'x' 'y'
%destructor
{ printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
input
%destructor
{ printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
line
%destructor
{ printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
thing
%destructor
{ printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
'x'
%destructor
{ printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
'y'
%%
/*
This grammar is made to exercise error recovery.
"Lines" starting with `(' support error recovery, with
')' as synchronizing token. Lines starting with 'x' can never
be recovered from if in error.
*/
input:
/* Nothing. */
{
$$ = 0;
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
}
| line input /* Right recursive to load the stack so that popping at
EOF can be exercised. */
{
$$ = 2;
printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
}
;
line:
thing thing thing ';'
{
$$ = $1;
printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
}
| '(' error ')'
{
$$ = -1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
}
;
thing:
'x'
{
$$ = $1;
printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1));
}
;
%%
/* Alias to ARGV[1]. */
const char *source = 0;
static int
yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
{
static unsigned int counter = 0;
int c = (*lvalp) = counter++;
/* As in BASIC, line numbers go from 10 to 10. */
(*llocp).begin.line = (*llocp).begin.column = 10 * c;
(*llocp).end.line = (*llocp).end.column = (*llocp).begin.line + 9;
if (source[c])
printf ("sending: '%c'", source[c]);
else
printf ("sending: EOF");
printf (" (%d@%d-%d)\n", c, RANGE ((*llocp)));
return source[c];
}
/* A C++ error reporting function. */
void
yy::parser::error (const location& l, const std::string& m)
{
printf ("%d-%d: %s\n", RANGE (l), m.c_str());
}
static bool yydebug;
int
yyparse ()
{
yy::parser parser;
parser.set_debug_level (yydebug);
return parser.parse ();
}
int
main (int argc, const char *argv[])
{
int status;
yydebug = !!getenv ("YYDEBUG");
assert (argc == 2);
source = argv[1];
status = yyparse ();
switch (status)
{
case 0: printf ("Successful parse.\n"); break;
case 1: printf ("Parsing FAILED.\n"); break;
default: printf ("Parsing FAILED (status %d).\n", status); break;
}
return status;
}
_ATEOF
$at_traceoff
echo "actions.at:533: bison -o input.cc input.y"
echo actions.at:533 >$at_check_line_file
( $at_traceon; bison -o input.cc input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:533: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:533: \$BISON_CXX_WORKS"
echo actions.at:533 >$at_check_line_file
( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:533: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:533: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o input input.cc \$LIBS"
echo actions.at:533 >$at_check_line_file
( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o input input.cc $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:533: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:533: \$PREPARSER ./input '(x)'"
echo actions.at:533 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: ')' (2@20-29)
line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (0@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:533: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:533: \$PREPARSER ./input '(y)'"
echo actions.at:533 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'y' (1@10-19)
10-19: syntax error, unexpected 'y', expecting 'x'
Freeing token 'y' (1@10-19)
sending: ')' (2@20-29)
line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (-1@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:533: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:533: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
echo actions.at:533 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: 'x' (2@20-29)
thing (2@20-29): 'x' (2@20-29)
sending: 'x' (3@30-39)
30-39: syntax error, unexpected 'x', expecting ')'
Freeing nterm thing (2@20-29)
Freeing nterm thing (1@10-19)
Freeing token 'x' (3@30-39)
sending: 'x' (4@40-49)
Freeing token 'x' (4@40-49)
sending: 'x' (5@50-59)
Freeing token 'x' (5@50-59)
sending: ')' (6@60-69)
line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
sending: '(' (7@70-79)
sending: 'x' (8@80-89)
thing (8@80-89): 'x' (8@80-89)
sending: ')' (9@90-99)
line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
sending: '(' (10@100-109)
sending: 'x' (11@110-119)
thing (11@110-119): 'x' (11@110-119)
sending: ')' (12@120-129)
line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
sending: 'y' (13@130-139)
input (0@129-129): /* Nothing */
input (2@100-129): line (10@100-129) input (0@129-129)
input (2@70-129): line (7@70-99) input (2@100-129)
input (2@0-129): line (-1@0-69) input (2@70-129)
130-139: syntax error, unexpected 'y', expecting \$end
Freeing nterm input (2@0-129)
Freeing token 'y' (13@130-139)
Parsing FAILED.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "actions.at:533: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
55 ) at_setup_line='actions.at:534'
at_desc='Printers and Destructors with union: %defines %skeleton "lalr1.cc"'
$at_quiet $ECHO_N " 55: Printers and Destructors with union: %defines %skeleton "lalr1.cc"$ECHO_C"
at_xfail=no
(
echo "55. actions.at:534: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
%}
%error-verbose
%debug
%verbose
%locations
%defines %skeleton "lalr1.cc"
%union
{
int ival;
}
%define "global_tokens_and_yystype"
%{
typedef yy::location YYLTYPE;
static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
%}
%type <ival> '(' 'x' 'y' ')' ';' thing line input
%printer
{
debug_stream () << $$;;
}
input line thing 'x' 'y'
%destructor
{ printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
input
%destructor
{ printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
line
%destructor
{ printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
thing
%destructor
{ printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
'x'
%destructor
{ printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
'y'
%%
/*
This grammar is made to exercise error recovery.
"Lines" starting with `(' support error recovery, with
')' as synchronizing token. Lines starting with 'x' can never
be recovered from if in error.
*/
input:
/* Nothing. */
{
$$ = 0;
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
}
| line input /* Right recursive to load the stack so that popping at
EOF can be exercised. */
{
$$ = 2;
printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
}
;
line:
thing thing thing ';'
{
$$ = $1;
printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
}
| '(' error ')'
{
$$ = -1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
}
;
thing:
'x'
{
$$ = $1;
printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1));
}
;
%%
/* Alias to ARGV[1]. */
const char *source = 0;
static int
yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
{
static unsigned int counter = 0;
int c = (*lvalp).ival = counter++;
/* As in BASIC, line numbers go from 10 to 10. */
(*llocp).begin.line = (*llocp).begin.column = 10 * c;
(*llocp).end.line = (*llocp).end.column = (*llocp).begin.line + 9;
if (source[c])
printf ("sending: '%c'", source[c]);
else
printf ("sending: EOF");
printf (" (%d@%d-%d)\n", c, RANGE ((*llocp)));
return source[c];
}
/* A C++ error reporting function. */
void
yy::parser::error (const location& l, const std::string& m)
{
printf ("%d-%d: %s\n", RANGE (l), m.c_str());
}
static bool yydebug;
int
yyparse ()
{
yy::parser parser;
parser.set_debug_level (yydebug);
return parser.parse ();
}
int
main (int argc, const char *argv[])
{
int status;
yydebug = !!getenv ("YYDEBUG");
assert (argc == 2);
source = argv[1];
status = yyparse ();
switch (status)
{
case 0: printf ("Successful parse.\n"); break;
case 1: printf ("Parsing FAILED.\n"); break;
default: printf ("Parsing FAILED (status %d).\n", status); break;
}
return status;
}
_ATEOF
$at_traceoff
echo "actions.at:534: bison -o input.cc input.y"
echo actions.at:534 >$at_check_line_file
( $at_traceon; bison -o input.cc input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:534: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:534: \$BISON_CXX_WORKS"
echo actions.at:534 >$at_check_line_file
( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:534: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:534: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o input input.cc \$LIBS"
echo actions.at:534 >$at_check_line_file
( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o input input.cc $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:534: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:534: \$PREPARSER ./input '(x)'"
echo actions.at:534 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: ')' (2@20-29)
line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (0@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:534: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:534: \$PREPARSER ./input '(y)'"
echo actions.at:534 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'y' (1@10-19)
10-19: syntax error, unexpected 'y', expecting 'x'
Freeing token 'y' (1@10-19)
sending: ')' (2@20-29)
line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (-1@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:534: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:534: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
echo actions.at:534 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: 'x' (2@20-29)
thing (2@20-29): 'x' (2@20-29)
sending: 'x' (3@30-39)
30-39: syntax error, unexpected 'x', expecting ')'
Freeing nterm thing (2@20-29)
Freeing nterm thing (1@10-19)
Freeing token 'x' (3@30-39)
sending: 'x' (4@40-49)
Freeing token 'x' (4@40-49)
sending: 'x' (5@50-59)
Freeing token 'x' (5@50-59)
sending: ')' (6@60-69)
line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
sending: '(' (7@70-79)
sending: 'x' (8@80-89)
thing (8@80-89): 'x' (8@80-89)
sending: ')' (9@90-99)
line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
sending: '(' (10@100-109)
sending: 'x' (11@110-119)
thing (11@110-119): 'x' (11@110-119)
sending: ')' (12@120-129)
line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
sending: 'y' (13@130-139)
input (0@129-129): /* Nothing */
input (2@100-129): line (10@100-129) input (0@129-129)
input (2@70-129): line (7@70-99) input (2@100-129)
input (2@0-129): line (-1@0-69) input (2@70-129)
130-139: syntax error, unexpected 'y', expecting \$end
Freeing nterm input (2@0-129)
Freeing token 'y' (13@130-139)
Parsing FAILED.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "actions.at:534: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
56 ) at_setup_line='actions.at:536'
at_desc='Printers and Destructors : %glr-parser'
$at_quiet $ECHO_N " 56: Printers and Destructors : %glr-parser $ECHO_C"
at_xfail=no
(
echo "56. actions.at:536: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
%}
%error-verbose
%debug
%verbose
%locations
%glr-parser
%{
static int yylex (void);
static void yyerror (const char *msg);
%}
%printer
{
fprintf (yyoutput, "%d", $$);
}
input line thing 'x' 'y'
%destructor
{ printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
input
%destructor
{ printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
line
%destructor
{ printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
thing
%destructor
{ printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
'x'
%destructor
{ printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
'y'
%%
/*
This grammar is made to exercise error recovery.
"Lines" starting with `(' support error recovery, with
')' as synchronizing token. Lines starting with 'x' can never
be recovered from if in error.
*/
input:
/* Nothing. */
{
$$ = 0;
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
}
| line input /* Right recursive to load the stack so that popping at
EOF can be exercised. */
{
$$ = 2;
printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
}
;
line:
thing thing thing ';'
{
$$ = $1;
printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
}
| '(' error ')'
{
$$ = -1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
}
;
thing:
'x'
{
$$ = $1;
printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1));
}
;
%%
/* Alias to ARGV[1]. */
const char *source = 0;
static int
yylex (void)
{
static unsigned int counter = 0;
int c = (yylval) = counter++;
/* As in BASIC, line numbers go from 10 to 10. */
(yylloc).first_line = (yylloc).first_column = 10 * c;
(yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
if (source[c])
printf ("sending: '%c'", source[c]);
else
printf ("sending: EOF");
printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
return source[c];
}
static void
yyerror (const char *msg)
{
printf ("%d-%d: %s\n", RANGE (yylloc), msg);
}
int
main (int argc, const char *argv[])
{
int status;
yydebug = !!getenv ("YYDEBUG");
assert (argc == 2);
source = argv[1];
status = yyparse ();
switch (status)
{
case 0: printf ("Successful parse.\n"); break;
case 1: printf ("Parsing FAILED.\n"); break;
default: printf ("Parsing FAILED (status %d).\n", status); break;
}
return status;
}
_ATEOF
$at_traceoff
echo "actions.at:536: bison -o input.c input.y"
echo actions.at:536 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:536: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:536: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
echo actions.at:536 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:536: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:536: \$PREPARSER ./input '(x)'"
echo actions.at:536 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: ')' (2@20-29)
line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (0@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:536: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:536: \$PREPARSER ./input '(y)'"
echo actions.at:536 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'y' (1@10-19)
10-19: syntax error, unexpected 'y', expecting 'x'
Freeing token 'y' (1@10-19)
sending: ')' (2@20-29)
line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (-1@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:536: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:536: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
echo actions.at:536 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: 'x' (2@20-29)
thing (2@20-29): 'x' (2@20-29)
sending: 'x' (3@30-39)
30-39: syntax error, unexpected 'x', expecting ')'
Freeing nterm thing (2@20-29)
Freeing nterm thing (1@10-19)
Freeing token 'x' (3@30-39)
sending: 'x' (4@40-49)
Freeing token 'x' (4@40-49)
sending: 'x' (5@50-59)
Freeing token 'x' (5@50-59)
sending: ')' (6@60-69)
line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
sending: '(' (7@70-79)
sending: 'x' (8@80-89)
thing (8@80-89): 'x' (8@80-89)
sending: ')' (9@90-99)
line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
sending: '(' (10@100-109)
sending: 'x' (11@110-119)
thing (11@110-119): 'x' (11@110-119)
sending: ')' (12@120-129)
line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
sending: 'y' (13@130-139)
input (0@129-129): /* Nothing */
input (2@100-129): line (10@100-129) input (0@129-129)
input (2@70-129): line (7@70-99) input (2@100-129)
input (2@0-129): line (-1@0-69) input (2@70-129)
130-139: syntax error, unexpected 'y', expecting \$end
Freeing nterm input (2@0-129)
Freeing token 'y' (13@130-139)
Parsing FAILED.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "actions.at:536: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
57 ) at_setup_line='actions.at:537'
at_desc='Printers and Destructors with union: %glr-parser'
$at_quiet $ECHO_N " 57: Printers and Destructors with union: %glr-parser$ECHO_C"
at_xfail=no
(
echo "57. actions.at:537: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
%}
%error-verbose
%debug
%verbose
%locations
%glr-parser
%union
{
int ival;
}
%{
static int yylex (void);
static void yyerror (const char *msg);
%}
%type <ival> '(' 'x' 'y' ')' ';' thing line input
%printer
{
fprintf (yyoutput, "%d", $$);
}
input line thing 'x' 'y'
%destructor
{ printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
input
%destructor
{ printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
line
%destructor
{ printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
thing
%destructor
{ printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
'x'
%destructor
{ printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
'y'
%%
/*
This grammar is made to exercise error recovery.
"Lines" starting with `(' support error recovery, with
')' as synchronizing token. Lines starting with 'x' can never
be recovered from if in error.
*/
input:
/* Nothing. */
{
$$ = 0;
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
}
| line input /* Right recursive to load the stack so that popping at
EOF can be exercised. */
{
$$ = 2;
printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
}
;
line:
thing thing thing ';'
{
$$ = $1;
printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
$3, RANGE (@3), $4, RANGE (@4));
}
| '(' thing ')'
{
$$ = $1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
}
| '(' error ')'
{
$$ = -1;
printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
}
;
thing:
'x'
{
$$ = $1;
printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1));
}
;
%%
/* Alias to ARGV[1]. */
const char *source = 0;
static int
yylex (void)
{
static unsigned int counter = 0;
int c = (yylval).ival = counter++;
/* As in BASIC, line numbers go from 10 to 10. */
(yylloc).first_line = (yylloc).first_column = 10 * c;
(yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
if (source[c])
printf ("sending: '%c'", source[c]);
else
printf ("sending: EOF");
printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
return source[c];
}
static void
yyerror (const char *msg)
{
printf ("%d-%d: %s\n", RANGE (yylloc), msg);
}
int
main (int argc, const char *argv[])
{
int status;
yydebug = !!getenv ("YYDEBUG");
assert (argc == 2);
source = argv[1];
status = yyparse ();
switch (status)
{
case 0: printf ("Successful parse.\n"); break;
case 1: printf ("Parsing FAILED.\n"); break;
default: printf ("Parsing FAILED (status %d).\n", status); break;
}
return status;
}
_ATEOF
$at_traceoff
echo "actions.at:537: bison -o input.c input.y"
echo actions.at:537 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:537: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:537: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
echo actions.at:537 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:537: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:537: \$PREPARSER ./input '(x)'"
echo actions.at:537 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: ')' (2@20-29)
line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (0@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:537: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:537: \$PREPARSER ./input '(y)'"
echo actions.at:537 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'y' (1@10-19)
10-19: syntax error, unexpected 'y', expecting 'x'
Freeing token 'y' (1@10-19)
sending: ')' (2@20-29)
line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
sending: EOF (3@30-39)
input (0@29-29): /* Nothing */
input (2@0-29): line (-1@0-29) input (0@29-29)
Freeing nterm input (2@0-29)
Successful parse.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "actions.at:537: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "actions.at:537: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
echo actions.at:537 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "sending: '(' (0@0-9)
sending: 'x' (1@10-19)
thing (1@10-19): 'x' (1@10-19)
sending: 'x' (2@20-29)
thing (2@20-29): 'x' (2@20-29)
sending: 'x' (3@30-39)
30-39: syntax error, unexpected 'x', expecting ')'
Freeing nterm thing (2@20-29)
Freeing nterm thing (1@10-19)
Freeing token 'x' (3@30-39)
sending: 'x' (4@40-49)
Freeing token 'x' (4@40-49)
sending: 'x' (5@50-59)
Freeing token 'x' (5@50-59)
sending: ')' (6@60-69)
line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
sending: '(' (7@70-79)
sending: 'x' (8@80-89)
thing (8@80-89): 'x' (8@80-89)
sending: ')' (9@90-99)
line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
sending: '(' (10@100-109)
sending: 'x' (11@110-119)
thing (11@110-119): 'x' (11@110-119)
sending: ')' (12@120-129)
line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
sending: 'y' (13@130-139)
input (0@129-129): /* Nothing */
input (2@100-129): line (10@100-129) input (0@129-129)
input (2@70-129): line (7@70-99) input (2@100-129)
input (2@0-129): line (-1@0-69) input (2@70-129)
130-139: syntax error, unexpected 'y', expecting \$end
Freeing nterm input (2@0-129)
Freeing token 'y' (13@130-139)
Parsing FAILED.
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "actions.at:537: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
banner-8 ) cat <<\_ATEOF
Conflicts.
_ATEOF
;;
58 ) at_setup_line='conflicts.at:32'
at_desc='S/R in initial'
$at_quiet $ECHO_N " 58: S/R in initial $ECHO_C"
at_xfail=no
(
echo "58. conflicts.at:32: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%expect 1
%%
exp: e 'e';
e: 'e' | /* Nothing. */;
_ATEOF
$at_traceoff
echo "conflicts.at:43: bison -o input.c input.y"
echo conflicts.at:43 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y:4.9: warning: rule never reduced because of conflicts: e: /* empty */
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:43: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
59 ) at_setup_line='conflicts.at:52'
at_desc='%nonassoc and eof'
$at_quiet $ECHO_N " 59: %nonassoc and eof $ECHO_C"
at_xfail=no
(
echo "59. conflicts.at:52: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
%{
static void
yyerror (const char *msg)
{
fprintf (stderr, "%s\n", msg);
}
/* The current argument. */
static const char *input = NULL;
static int
yylex (void)
{
/* No token stands for end of file. */
if (input && *input)
return *input++;
else
return 0;
}
%}
%nonassoc '<' '>'
%%
expr: expr '<' expr
| expr '>' expr
| '0'
;
%%
int
main (int argc, const char *argv[])
{
if (argc > 1)
input = argv[1];
return yyparse ();
}
_ATEOF
$at_traceoff
echo "conflicts.at:100: bison -o input.c input.y"
echo conflicts.at:100 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:100: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "conflicts.at:101: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
echo conflicts.at:101 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:101: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "conflicts.at:103: \$PREPARSER ./input '0<0'"
echo conflicts.at:103 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '0<0' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:103: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "conflicts.at:109: \$PREPARSER ./input '0<0<0'"
echo conflicts.at:109 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '0<0<0' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "syntax error, unexpected '<', expecting '<' or '>'
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "conflicts.at:109: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "conflicts.at:111: \$PREPARSER ./input '0>0'"
echo conflicts.at:111 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '0>0' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:111: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "conflicts.at:114: \$PREPARSER ./input '0>0>0'"
echo conflicts.at:114 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '0>0>0' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "syntax error, unexpected '>', expecting '<' or '>'
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "conflicts.at:114: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "conflicts.at:118: \$PREPARSER ./input '0<0>0'"
echo conflicts.at:118 >$at_check_line_file
( $at_traceon; $PREPARSER ./input '0<0>0' ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "syntax error, unexpected '>', expecting '<' or '>'
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "conflicts.at:118: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
60 ) at_setup_line='conflicts.at:128'
at_desc='Unresolved SR Conflicts'
$at_quiet $ECHO_N " 60: Unresolved SR Conflicts $ECHO_C"
at_xfail=no
(
echo "60. conflicts.at:128: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%token NUM OP
%%
exp: exp OP exp | NUM;
_ATEOF
$at_traceoff
echo "conflicts.at:140: bison -o input.c --report=all input.y"
echo conflicts.at:140 >$at_check_line_file
( $at_traceon; bison -o input.c --report=all input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: conflicts: 1 shift/reduce
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:140: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "conflicts.at:225: cat input.output"
echo conflicts.at:225 >$at_check_line_file
( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "State 5 conflicts: 1 shift/reduce
Grammar
0 \$accept: exp \$end
1 exp: exp OP exp
2 | NUM
Terminals, with rules where they appear
\$end (0) 0
error (256)
NUM (258) 2
OP (259) 1
Nonterminals, with rules where they appear
\$accept (5)
on left: 0
exp (6)
on left: 1 2, on right: 0 1
state 0
0 \$accept: . exp \$end
1 exp: . exp OP exp
2 | . NUM
NUM shift, and go to state 1
exp go to state 2
state 1
2 exp: NUM .
\$default reduce using rule 2 (exp)
state 2
0 \$accept: exp . \$end
1 exp: exp . OP exp
\$end shift, and go to state 3
OP shift, and go to state 4
state 3
0 \$accept: exp \$end .
\$default accept
state 4
1 exp: . exp OP exp
1 | exp OP . exp
2 | . NUM
NUM shift, and go to state 1
exp go to state 5
state 5
1 exp: exp . OP exp [\$end, OP]
1 | exp OP exp . [\$end, OP]
OP shift, and go to state 4
OP [reduce using rule 1 (exp)]
\$default reduce using rule 1 (exp)
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:225: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
61 ) at_setup_line='conflicts.at:235'
at_desc='Resolved SR Conflicts'
$at_quiet $ECHO_N " 61: Resolved SR Conflicts $ECHO_C"
at_xfail=no
(
echo "61. conflicts.at:235: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%token NUM OP
%left OP
%%
exp: exp OP exp | NUM;
_ATEOF
$at_traceoff
echo "conflicts.at:246: bison -o input.c --report=all input.y"
echo conflicts.at:246 >$at_check_line_file
( $at_traceon; bison -o input.c --report=all input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:246: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "conflicts.at:327: cat input.output"
echo conflicts.at:327 >$at_check_line_file
( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "Grammar
0 \$accept: exp \$end
1 exp: exp OP exp
2 | NUM
Terminals, with rules where they appear
\$end (0) 0
error (256)
NUM (258) 2
OP (259) 1
Nonterminals, with rules where they appear
\$accept (5)
on left: 0
exp (6)
on left: 1 2, on right: 0 1
state 0
0 \$accept: . exp \$end
1 exp: . exp OP exp
2 | . NUM
NUM shift, and go to state 1
exp go to state 2
state 1
2 exp: NUM .
\$default reduce using rule 2 (exp)
state 2
0 \$accept: exp . \$end
1 exp: exp . OP exp
\$end shift, and go to state 3
OP shift, and go to state 4
state 3
0 \$accept: exp \$end .
\$default accept
state 4
1 exp: . exp OP exp
1 | exp OP . exp
2 | . NUM
NUM shift, and go to state 1
exp go to state 5
state 5
1 exp: exp . OP exp [\$end, OP]
1 | exp OP exp . [\$end, OP]
\$default reduce using rule 1 (exp)
Conflict between rule 1 and token OP resolved as reduce (%left OP).
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:327: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
62 ) at_setup_line='conflicts.at:357'
at_desc='Defaulted Conflicted Reduction'
$at_quiet $ECHO_N " 62: Defaulted Conflicted Reduction $ECHO_C"
at_xfail=no
(
echo "62. conflicts.at:357: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%%
exp: num | id;
num: '0';
id : '0';
%%
_ATEOF
$at_traceoff
echo "conflicts.at:371: bison -o input.c --report=all input.y"
echo conflicts.at:371 >$at_check_line_file
( $at_traceon; bison -o input.c --report=all input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: conflicts: 1 reduce/reduce
input.y:4.6-8: warning: rule never reduced because of conflicts: id: '0'
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:371: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "conflicts.at:465: cat input.output"
echo conflicts.at:465 >$at_check_line_file
( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
echo >>$at_stdout; echo "Rules never reduced
4 id: '0'
State 1 conflicts: 1 reduce/reduce
Grammar
0 \$accept: exp \$end
1 exp: num
2 | id
3 num: '0'
4 id: '0'
Terminals, with rules where they appear
\$end (0) 0
'0' (48) 3 4
error (256)
Nonterminals, with rules where they appear
\$accept (4)
on left: 0
exp (5)
on left: 1 2, on right: 0
num (6)
on left: 3, on right: 1
id (7)
on left: 4, on right: 2
state 0
0 \$accept: . exp \$end
1 exp: . num
2 | . id
3 num: . '0'
4 id: . '0'
'0' shift, and go to state 1
exp go to state 2
num go to state 3
id go to state 4
state 1
3 num: '0' . [\$end]
4 id: '0' . [\$end]
\$end reduce using rule 3 (num)
\$end [reduce using rule 4 (id)]
\$default reduce using rule 3 (num)
state 2
0 \$accept: exp . \$end
\$end shift, and go to state 5
state 3
1 exp: num .
\$default reduce using rule 1 (exp)
state 4
2 exp: id .
\$default reduce using rule 2 (exp)
state 5
0 \$accept: exp \$end .
\$default accept
" | $at_diff - $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:465: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
63 ) at_setup_line='conflicts.at:476'
at_desc='%expect not enough'
$at_quiet $ECHO_N " 63: %expect not enough $ECHO_C"
at_xfail=no
(
echo "63. conflicts.at:476: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%token NUM OP
%expect 0
%%
exp: exp OP exp | NUM;
_ATEOF
$at_traceoff
echo "conflicts.at:488: bison -o input.c input.y"
echo conflicts.at:488 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: conflicts: 1 shift/reduce
input.y: expected 0 shift/reduce conflicts
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "conflicts.at:488: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
64 ) at_setup_line='conflicts.at:496'
at_desc='%expect right'
$at_quiet $ECHO_N " 64: %expect right $ECHO_C"
at_xfail=no
(
echo "64. conflicts.at:496: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%token NUM OP
%expect 1
%%
exp: exp OP exp | NUM;
_ATEOF
$at_traceoff
echo "conflicts.at:505: bison -o input.c input.y"
echo conflicts.at:505 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:505: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
65 ) at_setup_line='conflicts.at:513'
at_desc='%expect too much'
$at_quiet $ECHO_N " 65: %expect too much $ECHO_C"
at_xfail=no
(
echo "65. conflicts.at:513: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%token NUM OP
%expect 2
%%
exp: exp OP exp | NUM;
_ATEOF
$at_traceoff
echo "conflicts.at:525: bison -o input.c input.y"
echo conflicts.at:525 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: conflicts: 1 shift/reduce
input.y: expected 2 shift/reduce conflicts
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "conflicts.at:525: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
66 ) at_setup_line='conflicts.at:533'
at_desc='%expect with reduce conflicts'
$at_quiet $ECHO_N " 66: %expect with reduce conflicts $ECHO_C"
at_xfail=no
(
echo "66. conflicts.at:533: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%expect 0
%%
program: a 'a' | a a;
a: 'a';
_ATEOF
$at_traceoff
echo "conflicts.at:545: bison -o input.c input.y"
echo conflicts.at:545 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: conflicts: 1 reduce/reduce
input.y: expected 0 reduce/reduce conflicts
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "conflicts.at:545: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
67 ) at_setup_line='conflicts.at:553'
at_desc='%no-default-prec without %prec'
$at_quiet $ECHO_N " 67: %no-default-prec without %prec $ECHO_C"
at_xfail=no
(
echo "67. conflicts.at:553: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%left '+'
%left '*'
%%
%no-default-prec;
e: e '+' e
| e '*' e
| '0'
;
_ATEOF
$at_traceoff
echo "conflicts.at:571: bison -o input.c input.y"
echo conflicts.at:571 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo >>$at_stderr; echo "input.y: conflicts: 4 shift/reduce
" | $at_diff - $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:571: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
68 ) at_setup_line='conflicts.at:579'
at_desc='%no-default-prec with %prec'
$at_quiet $ECHO_N " 68: %no-default-prec with %prec $ECHO_C"
at_xfail=no
(
echo "68. conflicts.at:579: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%left '+'
%left '*'
%%
%no-default-prec;
e: e '+' e %prec '+'
| e '*' e %prec '*'
| '0'
;
_ATEOF
$at_traceoff
echo "conflicts.at:595: bison -o input.c input.y"
echo conflicts.at:595 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:595: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
69 ) at_setup_line='conflicts.at:603'
at_desc='%default-prec'
$at_quiet $ECHO_N " 69: %default-prec $ECHO_C"
at_xfail=no
(
echo "69. conflicts.at:603: testing ..."
$at_traceon
cat >input.y <<'_ATEOF'
%left '+'
%left '*'
%%
%default-prec;
e: e '+' e
| e '*' e
| '0'
;
_ATEOF
$at_traceoff
echo "conflicts.at:619: bison -o input.c input.y"
echo conflicts.at:619 >$at_check_line_file
( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "conflicts.at:619: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
banner-9 ) cat <<\_ATEOF
Simple LALR(1) Calculator.
_ATEOF
;;
70 ) at_setup_line='calc.at:550'
at_desc='Calculator '
$at_quiet $ECHO_N " 70: Calculator $ECHO_C"
at_xfail=no
(
echo "70. calc.at:550: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%s\n", s);
}
static int
get_char (void)
{
int res = getc (input);
;
return res;
}
static void
unget_char ( int c)
{
;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
}
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:550: bison -o calc.c calc.y"
echo calc.at:550 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:550: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:550: \$PREPARSER ./calc input"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:550: \$PREPARSER ./calc input"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:550: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:550: cat stderr"
echo calc.at:550 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:550: \$PREPARSER ./calc input"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:550: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:550: cat stderr"
echo calc.at:550 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:550: \$PREPARSER ./calc input"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:550: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:550: cat stderr"
echo calc.at:550 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:550: \$PREPARSER ./calc input"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:550: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:550: cat stderr"
echo calc.at:550 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:550: \$PREPARSER ./calc input"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:550: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:550: cat stderr"
echo calc.at:550 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:550: \$PREPARSER ./calc /dev/null"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:550: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:550: cat stderr"
echo calc.at:550 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:550: \$PREPARSER ./calc input"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:550: cat stderr"
echo calc.at:550 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:550: \$PREPARSER ./calc input"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:550: cat stderr"
echo calc.at:550 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:550: \$PREPARSER ./calc input"
echo calc.at:550 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:550: cat stderr"
echo calc.at:550 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:550: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
71 ) at_setup_line='calc.at:552'
at_desc='Calculator %defines'
$at_quiet $ECHO_N " 71: Calculator %defines $ECHO_C"
at_xfail=no
(
echo "71. calc.at:552: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%defines
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%s\n", s);
}
static int
get_char (void)
{
int res = getc (input);
;
return res;
}
static void
unget_char ( int c)
{
;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
}
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:552: bison -o calc.c calc.y"
echo calc.at:552 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:552: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:552: \$PREPARSER ./calc input"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:552: \$PREPARSER ./calc input"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:552: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:552: cat stderr"
echo calc.at:552 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:552: \$PREPARSER ./calc input"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:552: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:552: cat stderr"
echo calc.at:552 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:552: \$PREPARSER ./calc input"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:552: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:552: cat stderr"
echo calc.at:552 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:552: \$PREPARSER ./calc input"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:552: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:552: cat stderr"
echo calc.at:552 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:552: \$PREPARSER ./calc input"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:552: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:552: cat stderr"
echo calc.at:552 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:552: \$PREPARSER ./calc /dev/null"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:552: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:552: cat stderr"
echo calc.at:552 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:552: \$PREPARSER ./calc input"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:552: cat stderr"
echo calc.at:552 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:552: \$PREPARSER ./calc input"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:552: cat stderr"
echo calc.at:552 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:552: \$PREPARSER ./calc input"
echo calc.at:552 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:552: cat stderr"
echo calc.at:552 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:552: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
72 ) at_setup_line='calc.at:553'
at_desc='Calculator %locations'
$at_quiet $ECHO_N " 72: Calculator %locations $ECHO_C"
at_xfail=no
(
echo "72. calc.at:553: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%locations
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%d.%d",
(yylloc).first_line, (yylloc).first_column);
if ((yylloc).first_line != (yylloc).last_line)
fprintf (stderr, "-%d.%d",
(yylloc).last_line, (yylloc).last_column - 1);
else if ((yylloc).first_column != (yylloc).last_column - 1)
fprintf (stderr, "-%d",
(yylloc).last_column - 1);
fprintf (stderr, ": ");
fprintf (stderr, "%s\n", s);
}
static YYLTYPE last_yylloc;
static int
get_char (void)
{
int res = getc (input);
;
last_yylloc = (yylloc);
if (res == '\n')
{
(yylloc).last_line++;
(yylloc).last_column = 0;
}
else
(yylloc).last_column++;
return res;
}
static void
unget_char ( int c)
{
;
/* Wrong when C == `\n'. */
(yylloc) = last_yylloc;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
(yylloc).last_column = 0;
(yylloc).last_line = 1;
}
(yylloc).first_column = (yylloc).last_column;
(yylloc).first_line = (yylloc).last_line;
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
(yylloc).first_column = (yylloc).last_column;
(yylloc).first_line = (yylloc).last_line;
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:553: bison -o calc.c calc.y"
echo calc.at:553 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:553: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:553: \$PREPARSER ./calc input"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:553: \$PREPARSER ./calc input"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:553: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:553: cat stderr"
echo calc.at:553 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:553: \$PREPARSER ./calc input"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:553: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:553: cat stderr"
echo calc.at:553 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:553: \$PREPARSER ./calc input"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:553: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:553: cat stderr"
echo calc.at:553 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:553: \$PREPARSER ./calc input"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:553: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:553: cat stderr"
echo calc.at:553 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:553: \$PREPARSER ./calc input"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:553: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:553: cat stderr"
echo calc.at:553 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:553: \$PREPARSER ./calc /dev/null"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:553: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:553: cat stderr"
echo calc.at:553 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:553: \$PREPARSER ./calc input"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:553: cat stderr"
echo calc.at:553 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:553: \$PREPARSER ./calc input"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:553: cat stderr"
echo calc.at:553 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:553: \$PREPARSER ./calc input"
echo calc.at:553 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:553: cat stderr"
echo calc.at:553 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:553: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
73 ) at_setup_line='calc.at:554'
at_desc='Calculator %name-prefix="calc"'
$at_quiet $ECHO_N " 73: Calculator %name-prefix="calc" $ECHO_C"
at_xfail=no
(
echo "73. calc.at:554: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%name-prefix="calc"
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%s\n", s);
}
static int
get_char (void)
{
int res = getc (input);
;
return res;
}
static void
unget_char ( int c)
{
;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
}
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:554: bison -o calc.c calc.y"
echo calc.at:554 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:554: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:554: \$PREPARSER ./calc input"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:554: \$PREPARSER ./calc input"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:554: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:554: cat stderr"
echo calc.at:554 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:554: \$PREPARSER ./calc input"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:554: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:554: cat stderr"
echo calc.at:554 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:554: \$PREPARSER ./calc input"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:554: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:554: cat stderr"
echo calc.at:554 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:554: \$PREPARSER ./calc input"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:554: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:554: cat stderr"
echo calc.at:554 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:554: \$PREPARSER ./calc input"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:554: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:554: cat stderr"
echo calc.at:554 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:554: \$PREPARSER ./calc /dev/null"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:554: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:554: cat stderr"
echo calc.at:554 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:554: \$PREPARSER ./calc input"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:554: cat stderr"
echo calc.at:554 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:554: \$PREPARSER ./calc input"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:554: cat stderr"
echo calc.at:554 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:554: \$PREPARSER ./calc input"
echo calc.at:554 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:554: cat stderr"
echo calc.at:554 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:554: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
74 ) at_setup_line='calc.at:555'
at_desc='Calculator %verbose'
$at_quiet $ECHO_N " 74: Calculator %verbose $ECHO_C"
at_xfail=no
(
echo "74. calc.at:555: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%verbose
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%s\n", s);
}
static int
get_char (void)
{
int res = getc (input);
;
return res;
}
static void
unget_char ( int c)
{
;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
}
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:555: bison -o calc.c calc.y"
echo calc.at:555 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:555: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:555: \$PREPARSER ./calc input"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:555: \$PREPARSER ./calc input"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:555: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:555: cat stderr"
echo calc.at:555 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:555: \$PREPARSER ./calc input"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:555: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:555: cat stderr"
echo calc.at:555 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:555: \$PREPARSER ./calc input"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:555: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:555: cat stderr"
echo calc.at:555 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:555: \$PREPARSER ./calc input"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:555: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:555: cat stderr"
echo calc.at:555 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:555: \$PREPARSER ./calc input"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:555: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:555: cat stderr"
echo calc.at:555 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:555: \$PREPARSER ./calc /dev/null"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:555: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:555: cat stderr"
echo calc.at:555 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:555: \$PREPARSER ./calc input"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:555: cat stderr"
echo calc.at:555 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:555: \$PREPARSER ./calc input"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:555: cat stderr"
echo calc.at:555 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:555: \$PREPARSER ./calc input"
echo calc.at:555 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:555: cat stderr"
echo calc.at:555 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:555: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
75 ) at_setup_line='calc.at:556'
at_desc='Calculator %yacc'
$at_quiet $ECHO_N " 75: Calculator %yacc $ECHO_C"
at_xfail=no
(
echo "75. calc.at:556: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%yacc
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%s\n", s);
}
static int
get_char (void)
{
int res = getc (input);
;
return res;
}
static void
unget_char ( int c)
{
;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
}
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:556: bison -o calc.c calc.y"
echo calc.at:556 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:556: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:556: \$PREPARSER ./calc input"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:556: \$PREPARSER ./calc input"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:556: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:556: cat stderr"
echo calc.at:556 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:556: \$PREPARSER ./calc input"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:556: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:556: cat stderr"
echo calc.at:556 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:556: \$PREPARSER ./calc input"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:556: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:556: cat stderr"
echo calc.at:556 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:556: \$PREPARSER ./calc input"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:556: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:556: cat stderr"
echo calc.at:556 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:556: \$PREPARSER ./calc input"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:556: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:556: cat stderr"
echo calc.at:556 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:556: \$PREPARSER ./calc /dev/null"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:556: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:556: cat stderr"
echo calc.at:556 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:556: \$PREPARSER ./calc input"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:556: cat stderr"
echo calc.at:556 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:556: \$PREPARSER ./calc input"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:556: cat stderr"
echo calc.at:556 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:556: \$PREPARSER ./calc input"
echo calc.at:556 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:556: cat stderr"
echo calc.at:556 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:556: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
76 ) at_setup_line='calc.at:557'
at_desc='Calculator %error-verbose'
$at_quiet $ECHO_N " 76: Calculator %error-verbose $ECHO_C"
at_xfail=no
(
echo "76. calc.at:557: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%error-verbose
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%s\n", s);
}
static int
get_char (void)
{
int res = getc (input);
;
return res;
}
static void
unget_char ( int c)
{
;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
}
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:557: bison -o calc.c calc.y"
echo calc.at:557 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:557: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:557: \$PREPARSER ./calc input"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:557: \$PREPARSER ./calc input"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:557: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:557: cat stderr"
echo calc.at:557 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:557: \$PREPARSER ./calc input"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:557: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:557: cat stderr"
echo calc.at:557 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:557: \$PREPARSER ./calc input"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:557: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:557: cat stderr"
echo calc.at:557 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:557: \$PREPARSER ./calc input"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:557: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:557: cat stderr"
echo calc.at:557 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:557: \$PREPARSER ./calc input"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:557: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:557: cat stderr"
echo calc.at:557 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:557: \$PREPARSER ./calc /dev/null"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:557: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:557: cat stderr"
echo calc.at:557 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:557: \$PREPARSER ./calc input"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:557: cat stderr"
echo calc.at:557 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:557: \$PREPARSER ./calc input"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:557: cat stderr"
echo calc.at:557 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:557: \$PREPARSER ./calc input"
echo calc.at:557 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:557: cat stderr"
echo calc.at:557 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:557: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
77 ) at_setup_line='calc.at:559'
at_desc='Calculator %pure-parser %locations'
$at_quiet $ECHO_N " 77: Calculator %pure-parser %locations $ECHO_C"
at_xfail=no
(
echo "77. calc.at:559: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%pure-parser %locations
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp, int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%s\n", s);
}
static YYLTYPE last_yylloc;
static int
get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
{
int res = getc (input);
(void) lvalp;(void) llocp;
last_yylloc = (*llocp);
if (res == '\n')
{
(*llocp).last_line++;
(*llocp).last_column = 0;
}
else
(*llocp).last_column++;
return res;
}
static void
unget_char (YYSTYPE *lvalp, YYLTYPE *llocp, int c)
{
(void) lvalp;(void) llocp;
/* Wrong when C == `\n'. */
(*llocp) = last_yylloc;
ungetc (c, input);
}
static int
read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
{
int c = get_char (lvalp, llocp);
int sign = 1;
int n = 0;
(void) lvalp;(void) llocp;
if (c == '-')
{
c = get_char (lvalp, llocp);
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char (lvalp, llocp);
}
unget_char (lvalp, llocp, 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 (YYSTYPE *lvalp, YYLTYPE *llocp)
{
static int init = 1;
int c;
if (init)
{
init = 0;
(*llocp).last_column = 0;
(*llocp).last_line = 1;
}
(*llocp).first_column = (*llocp).last_column;
(*llocp).first_line = (*llocp).last_line;
/* Skip white space. */
while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
{
(*llocp).first_column = (*llocp).last_column;
(*llocp).first_line = (*llocp).last_line;
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char (lvalp, llocp, c);
(*lvalp).ival = read_signed_integer (lvalp, llocp);
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:559: bison -o calc.c calc.y"
echo calc.at:559 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:559: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:559: \$PREPARSER ./calc input"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:559: \$PREPARSER ./calc input"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:559: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:559: cat stderr"
echo calc.at:559 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:559: \$PREPARSER ./calc input"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:559: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:559: cat stderr"
echo calc.at:559 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:559: \$PREPARSER ./calc input"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:559: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:559: cat stderr"
echo calc.at:559 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:559: \$PREPARSER ./calc input"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:559: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:559: cat stderr"
echo calc.at:559 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:559: \$PREPARSER ./calc input"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:559: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:559: cat stderr"
echo calc.at:559 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:559: \$PREPARSER ./calc /dev/null"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:559: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:559: cat stderr"
echo calc.at:559 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:559: \$PREPARSER ./calc input"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:559: cat stderr"
echo calc.at:559 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:559: \$PREPARSER ./calc input"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:559: cat stderr"
echo calc.at:559 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:559: \$PREPARSER ./calc input"
echo calc.at:559 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:559: cat stderr"
echo calc.at:559 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:559: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
78 ) at_setup_line='calc.at:560'
at_desc='Calculator %error-verbose %locations'
$at_quiet $ECHO_N " 78: Calculator %error-verbose %locations $ECHO_C"
at_xfail=no
(
echo "78. calc.at:560: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%error-verbose %locations
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%d.%d",
(yylloc).first_line, (yylloc).first_column);
if ((yylloc).first_line != (yylloc).last_line)
fprintf (stderr, "-%d.%d",
(yylloc).last_line, (yylloc).last_column - 1);
else if ((yylloc).first_column != (yylloc).last_column - 1)
fprintf (stderr, "-%d",
(yylloc).last_column - 1);
fprintf (stderr, ": ");
fprintf (stderr, "%s\n", s);
}
static YYLTYPE last_yylloc;
static int
get_char (void)
{
int res = getc (input);
;
last_yylloc = (yylloc);
if (res == '\n')
{
(yylloc).last_line++;
(yylloc).last_column = 0;
}
else
(yylloc).last_column++;
return res;
}
static void
unget_char ( int c)
{
;
/* Wrong when C == `\n'. */
(yylloc) = last_yylloc;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
(yylloc).last_column = 0;
(yylloc).last_line = 1;
}
(yylloc).first_column = (yylloc).last_column;
(yylloc).first_line = (yylloc).last_line;
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
(yylloc).first_column = (yylloc).last_column;
(yylloc).first_line = (yylloc).last_line;
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:560: bison -o calc.c calc.y"
echo calc.at:560 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:560: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:560: \$PREPARSER ./calc input"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:560: \$PREPARSER ./calc input"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:560: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
$at_traceoff
echo "calc.at:560: cat stderr"
echo calc.at:560 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:560: \$PREPARSER ./calc input"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:560: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
$at_traceoff
echo "calc.at:560: cat stderr"
echo calc.at:560 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:560: \$PREPARSER ./calc input"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:560: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
$at_traceoff
echo "calc.at:560: cat stderr"
echo calc.at:560 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:560: \$PREPARSER ./calc input"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:560: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
$at_traceoff
echo "calc.at:560: cat stderr"
echo calc.at:560 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:560: \$PREPARSER ./calc input"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:560: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
$at_traceoff
echo "calc.at:560: cat stderr"
echo calc.at:560 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:560: \$PREPARSER ./calc /dev/null"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:560: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
$at_traceoff
echo "calc.at:560: cat stderr"
echo calc.at:560 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:560: \$PREPARSER ./calc input"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
$at_traceoff
echo "calc.at:560: cat stderr"
echo calc.at:560 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:560: \$PREPARSER ./calc input"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
$at_traceoff
echo "calc.at:560: cat stderr"
echo calc.at:560 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:560: \$PREPARSER ./calc input"
echo calc.at:560 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
$at_traceoff
echo "calc.at:560: cat stderr"
echo calc.at:560 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:560: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
79 ) at_setup_line='calc.at:562'
at_desc='Calculator %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc'
$at_quiet $ECHO_N " 79: Calculator %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc$ECHO_C"
at_xfail=no
(
echo "79. calc.at:562: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%error-verbose %locations %defines %name-prefix="calc" %verbose %yacc
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%d.%d",
(yylloc).first_line, (yylloc).first_column);
if ((yylloc).first_line != (yylloc).last_line)
fprintf (stderr, "-%d.%d",
(yylloc).last_line, (yylloc).last_column - 1);
else if ((yylloc).first_column != (yylloc).last_column - 1)
fprintf (stderr, "-%d",
(yylloc).last_column - 1);
fprintf (stderr, ": ");
fprintf (stderr, "%s\n", s);
}
static YYLTYPE last_yylloc;
static int
get_char (void)
{
int res = getc (input);
;
last_yylloc = (yylloc);
if (res == '\n')
{
(yylloc).last_line++;
(yylloc).last_column = 0;
}
else
(yylloc).last_column++;
return res;
}
static void
unget_char ( int c)
{
;
/* Wrong when C == `\n'. */
(yylloc) = last_yylloc;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
(yylloc).last_column = 0;
(yylloc).last_line = 1;
}
(yylloc).first_column = (yylloc).last_column;
(yylloc).first_line = (yylloc).last_line;
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
(yylloc).first_column = (yylloc).last_column;
(yylloc).first_line = (yylloc).last_line;
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:562: bison -o calc.c calc.y"
echo calc.at:562 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:562: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:562: \$PREPARSER ./calc input"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:562: \$PREPARSER ./calc input"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:562: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
$at_traceoff
echo "calc.at:562: cat stderr"
echo calc.at:562 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:562: \$PREPARSER ./calc input"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:562: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
$at_traceoff
echo "calc.at:562: cat stderr"
echo calc.at:562 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:562: \$PREPARSER ./calc input"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:562: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
$at_traceoff
echo "calc.at:562: cat stderr"
echo calc.at:562 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:562: \$PREPARSER ./calc input"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:562: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
$at_traceoff
echo "calc.at:562: cat stderr"
echo calc.at:562 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:562: \$PREPARSER ./calc input"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:562: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
$at_traceoff
echo "calc.at:562: cat stderr"
echo calc.at:562 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:562: \$PREPARSER ./calc /dev/null"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:562: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
$at_traceoff
echo "calc.at:562: cat stderr"
echo calc.at:562 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:562: \$PREPARSER ./calc input"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
$at_traceoff
echo "calc.at:562: cat stderr"
echo calc.at:562 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:562: \$PREPARSER ./calc input"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
$at_traceoff
echo "calc.at:562: cat stderr"
echo calc.at:562 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:562: \$PREPARSER ./calc input"
echo calc.at:562 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
$at_traceoff
echo "calc.at:562: cat stderr"
echo calc.at:562 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:562: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
80 ) at_setup_line='calc.at:564'
at_desc='Calculator %debug'
$at_quiet $ECHO_N " 80: Calculator %debug $ECHO_C"
at_xfail=no
(
echo "80. calc.at:564: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%debug
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%s\n", s);
}
static int
get_char (void)
{
int res = getc (input);
;
return res;
}
static void
unget_char ( int c)
{
;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
}
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
yydebug = 1;
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:564: bison -o calc.c calc.y"
echo calc.at:564 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:564: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:564: \$PREPARSER ./calc input"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:564: \$PREPARSER ./calc input"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:564: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:564: cat stderr"
echo calc.at:564 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:564: \$PREPARSER ./calc input"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:564: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:564: cat stderr"
echo calc.at:564 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:564: \$PREPARSER ./calc input"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:564: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:564: cat stderr"
echo calc.at:564 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:564: \$PREPARSER ./calc input"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:564: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:564: cat stderr"
echo calc.at:564 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:564: \$PREPARSER ./calc input"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:564: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:564: cat stderr"
echo calc.at:564 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:564: \$PREPARSER ./calc /dev/null"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:564: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:564: cat stderr"
echo calc.at:564 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:564: \$PREPARSER ./calc input"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:564: cat stderr"
echo calc.at:564 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:564: \$PREPARSER ./calc input"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:564: cat stderr"
echo calc.at:564 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:564: \$PREPARSER ./calc input"
echo calc.at:564 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:564: cat stderr"
echo calc.at:564 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:564: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
81 ) at_setup_line='calc.at:565'
at_desc='Calculator %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc'
$at_quiet $ECHO_N " 81: Calculator %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc$ECHO_C"
at_xfail=no
(
echo "81. calc.at:565: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (void);
static int get_char (void);
static void unget_char ( int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%d.%d",
(yylloc).first_line, (yylloc).first_column);
if ((yylloc).first_line != (yylloc).last_line)
fprintf (stderr, "-%d.%d",
(yylloc).last_line, (yylloc).last_column - 1);
else if ((yylloc).first_column != (yylloc).last_column - 1)
fprintf (stderr, "-%d",
(yylloc).last_column - 1);
fprintf (stderr, ": ");
fprintf (stderr, "%s\n", s);
}
static YYLTYPE last_yylloc;
static int
get_char (void)
{
int res = getc (input);
;
last_yylloc = (yylloc);
if (res == '\n')
{
(yylloc).last_line++;
(yylloc).last_column = 0;
}
else
(yylloc).last_column++;
return res;
}
static void
unget_char ( int c)
{
;
/* Wrong when C == `\n'. */
(yylloc) = last_yylloc;
ungetc (c, input);
}
static int
read_signed_integer (void)
{
int c = get_char ();
int sign = 1;
int n = 0;
;
if (c == '-')
{
c = get_char ();
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char ();
}
unget_char ( 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)
{
static int init = 1;
int c;
if (init)
{
init = 0;
(yylloc).last_column = 0;
(yylloc).last_line = 1;
}
(yylloc).first_column = (yylloc).last_column;
(yylloc).first_line = (yylloc).last_line;
/* Skip white space. */
while ((c = get_char ()) == ' ' || c == '\t')
{
(yylloc).first_column = (yylloc).last_column;
(yylloc).first_line = (yylloc).last_line;
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char ( c);
(yylval).ival = read_signed_integer ();
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
yydebug = 1;
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:565: bison -o calc.c calc.y"
echo calc.at:565 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:565: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:565: \$PREPARSER ./calc input"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:565: \$PREPARSER ./calc input"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:565: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
$at_traceoff
echo "calc.at:565: cat stderr"
echo calc.at:565 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:565: \$PREPARSER ./calc input"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:565: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
_ATEOF
$at_traceoff
echo "calc.at:565: cat stderr"
echo calc.at:565 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
error
_ATEOF
$at_traceoff
echo "calc.at:565: \$PREPARSER ./calc input"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:565: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected $undefined
_ATEOF
$at_traceoff
echo "calc.at:565: cat stderr"
echo calc.at:565 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1 = 2 = 3
_ATEOF
$at_traceoff
echo "calc.at:565: \$PREPARSER ./calc input"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:565: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.6: syntax error, unexpected '='
_ATEOF
$at_traceoff
echo "calc.at:565: cat stderr"
echo calc.at:565 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
+1
_ATEOF
$at_traceoff
echo "calc.at:565: \$PREPARSER ./calc input"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:565: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
2.0: syntax error, unexpected '+'
_ATEOF
$at_traceoff
echo "calc.at:565: cat stderr"
echo calc.at:565 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:565: \$PREPARSER ./calc /dev/null"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:565: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.0: syntax error, unexpected end of input
_ATEOF
$at_traceoff
echo "calc.at:565: cat stderr"
echo calc.at:565 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
() + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
_ATEOF
$at_traceoff
echo "calc.at:565: \$PREPARSER ./calc input"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
calc: error: 4444 != 1
_ATEOF
$at_traceoff
echo "calc.at:565: cat stderr"
echo calc.at:565 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(!) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:565: \$PREPARSER ./calc input"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.9: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
$at_traceoff
echo "calc.at:565: cat stderr"
echo calc.at:565 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
(- *) + (0 0) = 1
_ATEOF
$at_traceoff
echo "calc.at:565: \$PREPARSER ./calc input"
echo calc.at:565 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
1.11: syntax error, unexpected number
calc: error: 2222 != 1
_ATEOF
$at_traceoff
echo "calc.at:565: cat stderr"
echo calc.at:565 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:565: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
$at_times_p && times >$at_times_file
) 5>&1 2>&1 | eval $at_tee_pipe
at_status=`cat $at_status_file`
;;
82 ) at_setup_line='calc.at:567'
at_desc='Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc'
$at_quiet $ECHO_N " 82: Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc$ECHO_C"
at_xfail=no
(
echo "82. calc.at:567: testing ..."
$at_traceon
cat >calc.y <<'_ATEOF'
%{
/* We don't need perfect functions for these tests. */
%}
/* Infix notation calculator--calc */
%pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc
%{
/* Exercise pre-prologue dependency to %union. */
typedef int semantic_value;
static semantic_value global_result = 0;
static int global_count = 0;
%}
/* Exercise %union. */
%union
{
semantic_value ival;
};
%{
static int power (int base, int exponent);
/* yyerror receives the location if:
- %location & %pure & %glr
- %location & %pure & %yacc & %parse-param. */
static void yyerror (
const char *s
);
static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
static int get_char (YYSTYPE *lvalp, YYLTYPE *llocp);
static void unget_char (YYSTYPE *lvalp, YYLTYPE *llocp, int c);
%}
/* Bison Declarations */
%token CALC_EOF 0 "end of input"
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input:
line
| input line { }
;
line:
'\n'
| exp '\n' { USE ($1); }
;
exp:
NUM { $$ = $1; }
| exp '=' exp
{
if ($1 != $3)
fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
$$ = $1;
}
| 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; }
| '(' error ')' { $$ = 1111; }
| '!' { $$ = 0; YYERROR; }
| '-' error { $$ = 0; YYERROR; }
;
%%
/* The input. */
static FILE *input;
static void
yyerror (
const char *s)
{
fprintf (stderr, "%s\n", s);
}
static YYLTYPE last_yylloc;
static int
get_char (YYSTYPE *lvalp, YYLTYPE *llocp)
{
int res = getc (input);
(void) lvalp;(void) llocp;
last_yylloc = (*llocp);
if (res == '\n')
{
(*llocp).last_line++;
(*llocp).last_column = 0;
}
else
(*llocp).last_column++;
return res;
}
static void
unget_char (YYSTYPE *lvalp, YYLTYPE *llocp, int c)
{
(void) lvalp;(void) llocp;
/* Wrong when C == `\n'. */
(*llocp) = last_yylloc;
ungetc (c, input);
}
static int
read_signed_integer (YYSTYPE *lvalp, YYLTYPE *llocp)
{
int c = get_char (lvalp, llocp);
int sign = 1;
int n = 0;
(void) lvalp;(void) llocp;
if (c == '-')
{
c = get_char (lvalp, llocp);
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
c = get_char (lvalp, llocp);
}
unget_char (lvalp, llocp, 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 (YYSTYPE *lvalp, YYLTYPE *llocp)
{
static int init = 1;
int c;
if (init)
{
init = 0;
(*llocp).last_column = 0;
(*llocp).last_line = 1;
}
(*llocp).first_column = (*llocp).last_column;
(*llocp).first_line = (*llocp).last_line;
/* Skip white space. */
while ((c = get_char (lvalp, llocp)) == ' ' || c == '\t')
{
(*llocp).first_column = (*llocp).last_column;
(*llocp).first_line = (*llocp).last_line;
}
/* process numbers */
if (c == '.' || isdigit (c))
{
unget_char (lvalp, llocp, c);
(*lvalp).ival = read_signed_integer (lvalp, llocp);
return NUM;
}
/* Return end-of-file. */
if (c == EOF)
return CALC_EOF;
/* Return single chars. */
return c;
}
static int
power (int base, int exponent)
{
int res = 1;
if (exponent < 0)
exit (3);
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
}
int
main (int argc, const char **argv)
{
semantic_value result = 0;
int count = 0;
int status;
/* This used to be alarm (10), but that isn't enough time for
a July 1995 vintage DEC Alphastation 200 4/100 system,
according to Nelson H. F. Beebe. 100 seconds is enough. */
alarm (100);
if (argc == 2)
input = fopen (argv[1], "r");
else
input = stdin;
if (!input)
{
perror (argv[1]);
return 3;
}
yydebug = 1;
status = yyparse ();
if (global_result != result)
abort ();
if (global_count != count)
abort ();
return status;
}
_ATEOF
$at_traceoff
echo "calc.at:567: bison -o calc.c calc.y"
echo calc.at:567 >$at_check_line_file
( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:567: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
$at_traceoff
echo "calc.at:567: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
echo calc.at:567 >$at_check_line_file
( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; cat $at_stderr
echo stdout:; cat $at_stdout
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:567: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
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
echo "calc.at:567: \$PREPARSER ./calc input"
echo calc.at:567 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:567: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
0 0
_ATEOF
$at_traceoff
echo "calc.at:567: \$PREPARSER ./calc input"
echo calc.at:567 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:567: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
sed '/^Starting/d
/^Entering/d
/^Stack/d
/^Reading/d
/^Reducing/d
/^Shifting/d
/^state/d
/^Cleanup:/d
/^Error:/d
/^Next/d
/^Discarding/d
/ \$[0-9$]* = /d
/^yydestructor:/d' stderr >at-stderr
mv at-stderr stderr
cat >expout <<'_ATEOF'
1.2: syntax error, unexpected number
_ATEOF
sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout
$at_traceoff
echo "calc.at:567: cat stderr"
echo calc.at:567 >$at_check_line_file
( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
$at_diff $at_devnull $at_stderr || at_failed=:
$at_diff expout $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
0) ;;
*) echo "calc.at:567: exit code was $at_status, expected 0"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon
cat >input <<'_ATEOF'
1//2
_ATEOF
$at_traceoff
echo "calc.at:567: \$PREPARSER ./calc input"
echo calc.at:567 >$at_check_line_file
( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
at_status=$?
grep '^ *+' $at_stder1 >&2
grep -v '^ *+' $at_stder1 >$at_stderr
at_failed=false
echo stderr:; tee stderr <$at_stderr
$at_diff $at_devnull $at_stdout || at_failed=:
case $at_status in
77) echo 77 > $at_status_file
exit 77;;
1) ;;
*) echo "calc.at:567: exit code was $at_status, expected 1"
at_failed=:;;
esac
if $at_failed; then
echo 1 > $at_status_file
exit 1
fi
$at_traceon