glr2.cc: put glr_state_set and glr_stack_item in unnamed namespace
[bison.git] / examples / c / reccalc / reccalc.test
blob7d283280f611862e63b063272f7b4dda1ee6624a
1 #! /bin/sh
3 # Copyright (C) 2018-2021 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
18 (seq 0) >/dev/null 2>&1 || skip "gimme one seq"
20 cat >input <<EOF
21 1+2*3
22 EOF
23 run 0 '7'
25 cat >input <<EOF
26 (1+2) * 3
27 EOF
28 run 0 '9'
29 run -noerr 0 '9' -p
31 cat >input <<EOF
32 (((1)+(2))*((3)+(4)))
33 EOF
34 run 0 '21'
36 # Some really deep computation.
37 # for 4, gives 4 + (3 + (2 + (1 + (- (4 * (4 + 1)) / 2)))).
38 n=100
39 for i in $(seq 0 $n)
41 if [ "$i" -eq 0 ]; then
42 input="- ($n * ($n + 1)) / 2"
43 else
44 input="$i + ($input)"
46 done
47 echo "$input" > input
48 run 0 '0'
50 cat >input <<EOF
51 () + ()
52 EOF
53 run 1 'err: syntax error, unexpected end-of-file, expecting + or - or number or string'
55 cat >input <<EOF
56 1 + $
57 EOF
58 run 1 'err: syntax error, invalid character: $
59 err: syntax error, unexpected end-of-line, expecting + or - or number or string'