1 # Exercising Bison Grammar Sets. -*- Autotest -*-
2 # Copyright (C) 2001, 2002, 2005 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 3 of the License, or
7 # (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
18 # AT_EXTRACT_SETS(INPUT, OUTPUT)
19 # ------------------------------
20 # Extract the information about the grammar sets from a bison
21 # trace output (INPUT), and save it in OUTPUT.
22 # And remember, there is no alternation in portable sed.
23 m4_define([AT_EXTRACT_SETS],
24 [AT_DATA([extract.sed],
51 AT_CHECK([sed -f extract.sed $1], 0, [stdout])
52 AT_CHECK([mv stdout $2])
57 AT_BANNER([[Grammar Sets (Firsts etc.).]])
66 # At some point, nullable had been smoking grass, and managed to say:
68 # Entering set_nullable
76 e: 'e' | /* Nothing */;
79 AT_CHECK([[bison --trace=sets input.y]], [], [], [stderr])
80 AT_EXTRACT_SETS([stderr], [sets])
81 AT_CHECK([[cat sets]], [],
110 ## ---------------- ##
111 ## Broken Closure. ##
112 ## ---------------- ##
114 # TC was once broken during a massive `simplification' of the code.
115 # It resulted in bison dumping core on the following grammar (the
116 # computation of FIRSTS uses TC). It managed to produce a pretty
147 # instead of that below.
149 AT_SETUP([Broken Closure])
163 AT_CHECK([[bison --trace=sets input.y]], [], [], [stderr])
165 AT_CHECK([[sed -n 's/[ ]*$//;/^RTC: Firsts Output BEGIN/,/^RTC: Firsts Output END/p' stderr]], [],
166 [[RTC: Firsts Output BEGIN
180 RTC: Firsts Output END
209 AT_CHECK([[bison --trace=sets input.y]], [], [], [stderr])
210 AT_EXTRACT_SETS([stderr], [sets])
211 AT_CHECK([[cat sets]], [],
261 # In some weird cases Bison could compute an incorrect final state
262 # number. This happens only if the $end token is used in the user
263 # grammar, which is a very suspicious accidental feature introduced as
264 # a side effect of allowing the user to name $end using `%token END 0
279 AT_CHECK([[bison -v -o input.c input.y]])
281 # Get the final state in the parser.
282 AT_CHECK([[sed -n 's/.*define YYFINAL *\([0-9][0-9]*\)/final state \1/p' input.c]],
286 # Get the final state in the report, from the "accept" action..