]> git.saurik.com Git - bison.git/blob - tests/sets.at
Regen.
[bison.git] / tests / sets.at
1 # Exercising Bison Grammar Sets. -*- Autotest -*-
2 # Copyright 2001 Free Software Foundation, Inc.
3
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)
7 # any later version.
8
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.
13
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
17 # 02111-1307, USA.
18
19 AT_BANNER([[Grammar Sets (Firsts etc.).]])
20
21
22 ## ---------- ##
23 ## Nullable. ##
24 ## ---------- ##
25
26 AT_SETUP([Nullable])
27
28 # At some point, nullable had been smoking grass, and managed to say:
29 #
30 # Entering set_nullable
31 # NULLABLE
32 # 'e': yes
33 # (null): no
34 # ...
35
36 AT_DATA([[input.y]],
37 [[%%
38 e: 'e' | /* Nothing */;
39 ]])
40
41 AT_CHECK([[bison --trace input.y]], [], [],
42 [[RITEM
43 'e' (rule 1)
44 (rule 2)
45
46
47 DERIVES
48 e derives
49 1: 'e' (rule 1)
50 2: (rule 2)
51
52
53 Entering set_nullable
54 NULLABLE
55 e: yes
56
57
58 TC: Input BEGIN
59 @&t@
60 0
61 .-.
62 0| |
63 `-'
64 TC: Input END
65
66 TC: Output BEGIN
67 @&t@
68 0
69 .-.
70 0| |
71 `-'
72 TC: Output END
73
74 FIRSTS
75 e firsts
76 4 (e)
77
78
79 FDERIVES
80 e derives
81 1: 'e'
82 2:
83
84
85 Processing state 0 (reached by $)
86 Closure: input
87
88
89 Closure: output
90 0: . 'e' (rule 1)
91 2: . (rule 2)
92
93
94 Entering new_itemsets, state = 0
95 Entering append_states, state = 0
96 Entering get_state, state = 0, symbol = 3 ('e')
97 Entering new_state, state = 0, symbol = 3 ('e')
98 Exiting get_state => 1
99 Processing state 1 (reached by 'e')
100 Closure: input
101 1: . (rule 1)
102
103
104 Closure: output
105 1: . (rule 1)
106
107
108 Entering new_itemsets, state = 1
109 Entering append_states, state = 1
110 transpose: input
111 0: @&t@
112
113 transpose: output
114 0: @&t@
115
116 ]])
117
118 AT_CLEANUP
119
120
121 ## ---------------- ##
122 ## Broken Closure. ##
123 ## ---------------- ##
124
125 # TC was once broken during a massive `simplification' of the code.
126 # It resulted in bison dumping core on the following grammar (the
127 # computation of FIRSTS uses TC). It managed to produce a pretty
128 # exotic closure:
129 #
130 # TC: Input
131 #
132 # 01234567
133 # +--------+
134 # 0| 1 |
135 # 1| 1 |
136 # 2| 1 |
137 # 3| 1 |
138 # 4| 1 |
139 # 5| 1 |
140 # 6| 1|
141 # 7| |
142 # +--------+
143 #
144 # TC: Output
145 #
146 # 01234567
147 # +--------+
148 # 0| 1 |
149 # 1| 111 |
150 # 2| 111 |
151 # 3| 1111 |
152 # 4| 111 1 |
153 # 5| 111 1 |
154 # 6| 111 1|
155 # 7| 111 |
156 # +--------+
157 #
158 # instead of that below.
159
160 AT_SETUP([Broken Closure])
161
162 AT_DATA([input.y],
163 [[%%
164 a: b
165 b: c
166 c: d
167 d: e
168 e: f
169 f: g
170 g: h
171 h: 'h'
172 ]])
173
174 AT_CHECK([bison --trace input.y 2>&1 |
175 sed -n '/^TC: Output BEGIN/,/^TC: Output END/p'],
176 [0],
177 [[TC: Output BEGIN
178 @&t@
179 01234567
180 .--------.
181 0| 1111111|
182 1| 111111|
183 2| 11111|
184 3| 1111|
185 4| 111|
186 5| 11|
187 6| 1|
188 7| |
189 `--------'
190 TC: Output END
191 ]])
192
193 AT_CLEANUP