1 # Exercising Bison Grammar Sets. -*- Autotest -*-
3 # Copyright (C) 2001-2002, 2005, 2007, 2009-2014 Free Software
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # AT_EXTRACT_SETS(INPUT, OUTPUT)
21 # ------------------------------
22 # Extract the information about the grammar sets from a bison
23 # trace output (INPUT), and save it in OUTPUT.
24 # And remember, there is no alternation in portable sed.
25 m4_define([AT_EXTRACT_SETS],
26 [AT_DATA([extract.sed],
53 AT_CHECK([sed -f extract.sed $1], 0, [stdout])
54 AT_CHECK([mv stdout $2])
59 AT_BANNER([[Grammar Sets (Firsts etc.).]])
68 # At some point, nullable had been smoking grass, and managed to say:
70 # Entering set_nullable
78 e: 'e' | /* Nothing */;
81 AT_BISON_CHECK([[--trace=sets input.y]], [], [], [stderr])
82 AT_EXTRACT_SETS([stderr], [sets])
83 AT_CHECK([[cat sets]], [],
112 ## ---------------- ##
113 ## Broken Closure. ##
114 ## ---------------- ##
116 # TC was once broken during a massive 'simplification' of the code.
117 # It resulted in bison dumping core on the following grammar (the
118 # computation of FIRSTS uses TC). It managed to produce a pretty
149 # instead of that below.
151 AT_SETUP([Broken Closure])
165 AT_BISON_CHECK([[--trace=sets input.y]], [], [], [stderr])
167 AT_CHECK([[sed -n 's/[ ]*$//;/^RTC: Firsts Output BEGIN/,/^RTC: Firsts Output END/p' stderr]], [],
168 [[RTC: Firsts Output BEGIN
182 RTC: Firsts Output END
211 AT_BISON_CHECK([[--trace=sets input.y]], [], [], [stderr])
212 AT_EXTRACT_SETS([stderr], [sets])
213 AT_CHECK([[cat sets]], [],
263 # In some weird cases Bison could compute an incorrect final state
264 # number. This happens only if the $end token is used in the user
265 # grammar, which is a very suspicious accidental feature introduced as
266 # a side effect of allowing the user to name $end using '%token END 0
281 AT_BISON_CHECK([[-v -o input.c input.y]])
283 # Get the final state in the parser.
284 AT_CHECK([[sed -n 's/.*define YYFINAL *\([0-9][0-9]*\)/final state \1/p' input.c]],
288 # Get the final state in the report, from the "accept" action..