1 # Bison Regressions. -*- Autotest -*-
2 # Copyright 2001 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 AT_BANNER([[Regression tests.]])
21 ## ------------------ ##
22 ## Duplicate string. ##
23 ## ------------------ ##
26 AT_SETUP([Duplicate string])
28 AT_DATA([duplicate.y],
29 [[/* `Bison -v' used to dump core when two tokens are defined with the same
30 string, as LE and GE below. */
37 exp: '(' exp ')' | NUM ;
41 AT_CHECK([bison -v duplicate.y -o duplicate.c], 0, ignore, ignore)
43 AT_CLEANUP([duplicate.*])
55 exp: exp OP exp | NUM;
58 AT_CHECK([bison input.y -o input.c -v], 0, [],
59 [input.y contains 1 shift/reduce conflict.
62 # Check the contents of the report.
63 AT_CHECK([cat input.output], [],
64 [[State 4 contains 1 shift/reduce conflict.
68 rule 1 exp -> exp OP exp
71 Terminals, with rules where they appear
78 Nonterminals, with rules where they appear
81 on left: 1 2, on right: 1
86 NUM shift, and go to state 1
96 $default reduce using rule 2 (exp)
102 exp -> exp . OP exp (rule 1)
105 OP shift, and go to state 3
111 exp -> exp OP . exp (rule 1)
113 NUM shift, and go to state 1
121 exp -> exp . OP exp (rule 1)
122 exp -> exp OP exp . (rule 1)
124 OP shift, and go to state 3
126 OP [reduce using rule 1 (exp)]
127 $default reduce using rule 1 (exp)
142 AT_CLEANUP(input.c input.output)
145 ## ---------------------- ##
146 ## Mixing %token styles. ##
147 ## ---------------------- ##
150 AT_SETUP([Mixing %token styles])
152 # Taken from the documentation.
154 [[%token <operator> OR "||"
155 %token <operator> LE 134 "<="
162 AT_CHECK([bison -v input.y -o input.c], 0, ignore, ignore)
164 AT_CLEANUP([input.*])
168 ## ---------------------- ##
169 ## %union and --defines. ##
170 ## ---------------------- ##
173 AT_SETUP([%union and --defines])
185 AT_CHECK([bison --defines union.y])
187 AT_CLEANUP([union.*])
190 ## --------------------------------------- ##
191 ## Duplicate '/' in C comments in %union ##
192 ## --------------------------------------- ##
195 AT_SETUP([%union and C comments])
197 AT_DATA([union-comment.y],
200 /* The int. */ int integer;
201 /* The string. */ char *string ;
207 AT_CHECK([bison union-comment.y])
208 AT_CHECK([fgrep '//*' union-comment.tab.c], [1], [])
210 AT_CLEANUP([union-comment.*])
213 ## ----------------- ##
214 ## Invalid input 1. ##
215 ## ----------------- ##
218 AT_SETUP([Invalid input: 1])
225 AT_CHECK([bison input.y], [1], [],
226 [input.y:2: invalid input: `?'
227 input.y:3: fatal error: no rules in the input grammar
233 ## ----------------- ##
234 ## Invalid input 2. ##
235 ## ----------------- ##
238 AT_SETUP([Invalid input: 2])
245 AT_CHECK([bison input.y], [1], [],
246 [input.y:2: invalid input: `}'
253 ## --------------------- ##
254 ## Invalid CPP headers. ##
255 ## --------------------- ##
257 # AT_TEST_CPP_GUARD_H([INPUT-FILE-BASE)
258 # -------------------------------------
259 m4_define([AT_TEST_CPP_GUARD_H],
260 [AT_SETUP([Invalid CPP guards: $1])
262 # possibly create and nuke inner directories.
263 m4_bmatch([$1], [[/]],
264 [dirname=`AS_DIRNAME([$1])`
265 AS_MKDIR_P([$dirname])
266 AT_CLEANUP_FILES([$dirname])])
273 AT_CHECK([bison --defines=$1.h $1.y])
275 # CPP should be happy with it.
276 AT_CHECK([$CC -E $1.h], 0, [ignore])
281 AT_TEST_CPP_GUARD_H([input/input])
282 AT_TEST_CPP_GUARD_H([9foo])