1 # Exercising Bison Grammar Sets. -*- Autotest -*-
2 # Copyright (C) 2001-2002, 2005, 2007, 2009-2010 Free Software
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 <http://www.gnu.org/licenses/>.
19 # AT_EXTRACT_SETS(INPUT, OUTPUT)
20 # ------------------------------
21 # Extract the information about the grammar sets from a bison
22 # trace output (INPUT), and save it in OUTPUT.
23 # And remember, there is no alternation in portable sed.
24 m4_define([AT_EXTRACT_SETS],
25 [AT_DATA([extract.sed],
52 AT_CHECK([sed -f extract.sed $1], 0, [stdout])
53 AT_CHECK([mv stdout $2])
58 AT_BANNER([[Grammar Sets (Firsts etc.).]])
67 # At some point, nullable had been smoking grass, and managed to say:
69 # Entering set_nullable
77 e: 'e' | /* Nothing */;
80 AT_BISON_CHECK([[--trace=sets input.y]], [], [], [stderr])
81 AT_EXTRACT_SETS([stderr], [sets])
82 AT_CHECK([[cat sets]], [],
111 ## ---------------- ##
112 ## Broken Closure. ##
113 ## ---------------- ##
115 # TC was once broken during a massive `simplification' of the code.
116 # It resulted in bison dumping core on the following grammar (the
117 # computation of FIRSTS uses TC). It managed to produce a pretty
148 # instead of that below.
150 AT_SETUP([Broken Closure])
164 AT_BISON_CHECK([[--trace=sets input.y]], [], [], [stderr])
166 AT_CHECK([[sed -n 's/[ ]*$//;/^RTC: Firsts Output BEGIN/,/^RTC: Firsts Output END/p' stderr]], [],
167 [[RTC: Firsts Output BEGIN
181 RTC: Firsts Output END
210 AT_BISON_CHECK([[--trace=sets input.y]], [], [], [stderr])
211 AT_EXTRACT_SETS([stderr], [sets])
212 AT_CHECK([[cat sets]], [],
262 # In some weird cases Bison could compute an incorrect final state
263 # number. This happens only if the $end token is used in the user
264 # grammar, which is a very suspicious accidental feature introduced as
265 # a side effect of allowing the user to name $end using `%token END 0
280 AT_BISON_CHECK([[-v -o input.c input.y]])
282 # Get the final state in the parser.
283 AT_CHECK([[sed -n 's/.*define YYFINAL *\([0-9][0-9]*\)/final state \1/p' input.c]],
287 # Get the final state in the report, from the "accept" action..