]> git.saurik.com Git - bison.git/blame_incremental - tests/sets.at
Typo.
[bison.git] / tests / sets.at
... / ...
CommitLineData
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
19AT_BANNER([[Grammar Sets (Firsts etc.).]])
20
21
22## ---------- ##
23## Nullable. ##
24## ---------- ##
25
26AT_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
36AT_DATA([[input.y]],
37[[%%
38e: 'e' | /* Nothing */;
39]])
40
41AT_CHECK([[bison --trace input.y]], [], [],
42[[RITEM
43 'e' (rule 1)
44 (rule 2)
45
46
47DERIVES
48 e derives
49 1: 'e' (rule 1)
50 2: (rule 2)
51
52
53Entering set_nullable
54NULLABLE
55 e: yes
56
57
58TC: Input BEGIN
59 @&t@
60 0
61 .-.
62 0| |
63 `-'
64TC: Input END
65
66TC: Output BEGIN
67 @&t@
68 0
69 .-.
70 0| |
71 `-'
72TC: Output END
73
74FIRSTS
75 e firsts
76 4 (e)
77
78
79FDERIVES
80 e derives
81 1: 'e'
82 2:
83
84
85Processing state 0 (reached by $)
86Closure: input
87
88
89Closure: output
90 0: . 'e' (rule 1)
91 2: . (rule 2)
92
93
94Entering new_itemsets, state = 0
95Entering append_states, state = 0
96Entering get_state, state = 0, symbol = 3 ('e')
97Entering new_state, state = 0, symbol = 3 ('e')
98Exiting get_state => 1
99Processing state 1 (reached by 'e')
100Closure: input
101 1: . (rule 1)
102
103
104Closure: output
105 1: . (rule 1)
106
107
108Entering new_itemsets, state = 1
109Entering append_states, state = 1
110transpose: input
111 0: @&t@
112
113transpose: output
114 0: @&t@
115
116]])
117
118AT_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
160AT_SETUP([Broken Closure])
161
162AT_DATA([input.y],
163[[%%
164a: b
165b: c
166c: d
167d: e
168e: f
169f: g
170g: h
171h: 'h'
172]])
173
174AT_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 `--------'
190TC: Output END
191]])
192
193AT_CLEANUP