]> git.saurik.com Git - bison.git/blob - tests/output.at
tests: enable -Wsign-compare and fix corresponding warnings
[bison.git] / tests / output.at
1 # Checking the output filenames. -*- Autotest -*-
2
3 # Copyright (C) 2000-2002, 2005-2013 Free Software Foundation, Inc.
4
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.
9 #
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.
14 #
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/>.
17
18 AT_BANNER([[Output file names.]])
19
20
21 # AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES, [SHELLIO],
22 # [ADDITIONAL-TESTS], [PRE-TESTS])
23 # -----------------------------------------------------------------------------
24 m4_define([AT_CHECK_OUTPUT],
25 [AT_SETUP([[Output files: ]$2 $3 $5])[
26 ]$7[
27 for file in ]$1 $4[; do
28 case $file in
29 */*) mkdir -p `echo "$file" | sed 's,/[^/]*,,'`;;
30 esac
31 done
32 ]AT_DATA([$1],
33 [$2[
34 %%
35 foo: {};
36 ]])[
37
38 ]AT_BISON_CHECK([$3 $1 $5], 0)[
39 # Ignore the files non-generated files
40 ]AT_CHECK([find . -type f -and -not -path './$1' -and -not -path './testsuite.log' |
41 sed 's,\./,,' |
42 sort |
43 xargs echo],
44 [], [$4
45 ])[
46 ]$6[
47 ]AT_CLEANUP[
48 ]])
49
50 AT_CHECK_OUTPUT([foo.y], [], [-dv],
51 [foo.output foo.tab.c foo.tab.h])
52
53 # Some versions of Valgrind (at least valgrind-3.6.0.SVN-Debian) report
54 # "fgrep: write error: Bad file descriptor" when stdout is closed, so we
55 # skip this test group during maintainer-check-valgrind.
56 AT_CHECK_OUTPUT([foo.y], [], [-dv],
57 [foo.output foo.tab.c foo.tab.h],
58 [>&-], [],
59 [AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])])
60
61 AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
62 [foo.c foo.h foo.output])
63 AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
64 [foo.output foo.tab.c foo.tab.h])
65
66 AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml -y],
67 [y.dot y.output y.tab.c y.tab.h y.xml])
68 # With '-o y.tab.c', we expect 'y.output' etc. (for compatility with Yacc).
69 AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml -o y.tab.c],
70 [y.dot y.output y.tab.c y.tab.h y.xml])
71
72 AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
73 [bar.output bar.tab.c bar.tab.h])
74 AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
75 [foo.c foo.dot foo.h foo.output])
76
77
78 AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [],
79 [foo.output foo.tab.c foo.tab.h])
80 AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[],
81 [y.output y.tab.c y.tab.h])
82
83 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[],
84 [y.output y.tab.c y.tab.h])
85
86 # Exercise %output and %file-prefix including deprecated '='
87 AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
88 [bar.output bar.tab.c bar.tab.h])
89 AT_CHECK_OUTPUT([foo.y], [%output "bar.c" %defines %verbose %yacc],[],
90 [bar.c bar.h bar.output])
91 AT_CHECK_OUTPUT([foo.y],
92 [%file-prefix "baz" %output "bar.c" %defines %verbose %yacc],
93 [],
94 [bar.c bar.h bar.output])
95
96
97 # Check priorities of extension control.
98 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
99 [foo.output foo.tab.cc foo.tab.hh])
100
101 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
102 [foo.c foo.h foo.output])
103
104 AT_CHECK_OUTPUT([foo.yy], [],
105 [--defines=foo.hpp -o foo.c++],
106 [foo.c++ foo.hpp])
107
108 AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
109 [-o foo.c++],
110 [foo.c++ foo.hpp])
111
112 AT_CHECK_OUTPUT([foo.yy], [],
113 [-o foo.c++ --graph=foo.gph],
114 [foo.c++ foo.gph])
115
116
117 ## ------------ ##
118 ## C++ output. ##
119 ## ------------ ##
120
121 m4_define([AT_CHECK_NO_SUBDIR_PART],
122 [# Also make sure that the includes do not refer to the subdirectory.
123 AT_CHECK([grep 'include .subdir/' $1.cc], 1, [])
124 AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
125 ])
126
127 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose], [],
128 [foo.output foo.tab.cc])
129
130 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
131 [foo.output foo.tab.cc foo.tab.hh stack.hh])
132
133 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose %locations], [],
134 [foo.output foo.tab.cc])
135
136 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [],
137 [foo.output foo.tab.cc foo.tab.hh location.hh position.hh stack.hh])
138
139 AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
140 [foo.output foo.tab.cc foo.tab.hh stack.hh],
141 [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
142
143 AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations],
144 [-o subdir/foo.cc],
145 [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/position.hh subdir/stack.hh],
146 [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
147
148 AT_CHECK_OUTPUT([gram_dir/foo.yy],
149 [%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"],
150 [],
151 [output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/stack.hh])
152
153 AT_CHECK_OUTPUT([gram_dir/foo.yy],
154 [%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"],
155 [],
156 [output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/location.hh output_dir/position.hh output_dir/stack.hh])
157
158
159 # AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR,
160 # [EXIT-STATUS])
161 # ------------------------------------------------------------------
162 m4_define([AT_CHECK_CONFLICTING_OUTPUT],
163 [AT_SETUP([Conflicting output files: $2 $3])
164 case "$1" in
165 */*) mkdir `echo "$1" | sed 's,/.*,,'`;;
166 esac
167 AT_DATA([$1],
168 [[$2
169 %%
170 foo: {};
171 ]])
172
173 [cp ]$1[ expout]
174 # Because an output file name conflict is still a warning, Bison exits
175 # with status 0, so AT_BISON_CHECK does not realize that there may be no
176 # output file against which to check the XML. AT_BISON_CHECK_NO_XML
177 # avoids that problem.
178 AT_BISON_CHECK_NO_XML([$3 $1], $5, [], [$4])
179 AT_CHECK([[cat $1]], [[0]], [expout])
180 AT_CLEANUP
181 ])
182
183 AT_CHECK_CONFLICTING_OUTPUT([foo.y],
184 [], [--graph="foo.tab.c"],
185 [[foo.y: warning: conflicting outputs to file 'foo.tab.c' [-Wother]
186 ]])
187
188 AT_CHECK_CONFLICTING_OUTPUT([foo.y],
189 [%defines "foo.output"], [-v],
190 [[foo.y: warning: conflicting outputs to file 'foo.output' [-Wother]
191 ]])
192
193 AT_CHECK_CONFLICTING_OUTPUT([foo.y],
194 [%skeleton "lalr1.cc" %defines %locations], [--graph="location.hh"],
195 [[foo.y: warning: conflicting outputs to file 'location.hh' [-Wother]
196 ]])
197
198 AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
199 [[foo.y: error: refusing to overwrite the input file 'foo.y'
200 ]], 1)
201
202
203 # AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
204 # ---------------------------------------------------------------
205 m4_define([AT_CHECK_OUTPUT_FILE_NAME],
206 [AT_SETUP([Output file name: $1])
207
208 AT_BISON_OPTION_PUSHDEFS
209 # Skip if platform doesn't support file name. For example, Cygwin
210 # doesn't support file names containing ":" or "\".
211 AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
212
213 AT_DATA_GRAMMAR([glr.y],
214 [[%glr-parser
215 %code {
216 ]AT_YYERROR_DECLARE_EXTERN[
217 ]AT_YYLEX_DECLARE_EXTERN[
218 }
219 %%
220 start: {};
221 ]])
222 AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" glr.y])
223 AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
224 AT_COMPILE([glr.o], [-c "AS_ESCAPE([$1.c])"])
225 $2
226
227 AT_DATA_GRAMMAR([cxx.y],
228 [[%skeleton "lalr1.cc"
229 %code { int yylex (yy::parser::semantic_type*); }
230 %%
231 start: {};
232 ]])
233 AT_BISON_CHECK([-o "AS_ESCAPE([$1.cc])" --defines="AS_ESCAPE([$1.hh])" cxx.y])
234 AT_CHECK([ls "AS_ESCAPE([$1.cc])" "AS_ESCAPE([$1.hh])"], [], [ignore])
235 AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.cc])"])
236 $2
237
238 AT_BISON_OPTION_POPDEFS
239 AT_CLEANUP
240 ])
241
242 # Notice that the header file name here cannot contain
243 # '"' since FILENAME in '#include "FILENAME"' cannot.
244 AT_CHECK_OUTPUT_FILE_NAME([[`~!@#$%^&*()-=_+{}[]|\:;<>, .']])
245 dnl Work around a bug in m4_expand that broke AT_SETUP in autoconf 2.62,
246 dnl by using the definition from 2.63.
247 m4_version_prereq([2.63], [],
248 [m4_define([m4_expand], [_$0(-=<{($1)}>=-)])
249 m4_define([_m4_expand],
250 [m4_changequote([-=<{(], [)}>=-])$1m4_changequote([, ])])])
251 AT_CHECK_OUTPUT_FILE_NAME([[(]])
252 AT_CHECK_OUTPUT_FILE_NAME([[)]])
253 AT_CHECK_OUTPUT_FILE_NAME([[@%:@]])
254 AT_CHECK_OUTPUT_FILE_NAME([[@@]])
255 AT_CHECK_OUTPUT_FILE_NAME([[@{]])
256 AT_CHECK_OUTPUT_FILE_NAME([[@}]])
257 AT_CHECK_OUTPUT_FILE_NAME([[@<:@]])
258 AT_CHECK_OUTPUT_FILE_NAME([[@:>@]])
259
260
261 # AT_TEST(SETUP-NAME, GRAMMAR, DOT-BODY)
262 # --------------------------------------
263 # Check that the DOT graph for GRAMMAR is DOT-BODY.
264 m4_pushdef([AT_TEST],
265 [AT_SETUP([$1])
266 AT_KEYWORDS([[graph]])
267 AT_DATA([[input.y]], [$2])
268 AT_BISON_CHECK([[-rall --graph input.y]], [0], [[]], [[ignore]])
269 AT_CHECK([[grep -v // input.dot]], [0],
270 [[
271 digraph "input.y"
272 {
273 node [fontname = courier, shape = box, colorscheme = paired6]
274 edge [fontname = courier]
275 ]$3[}
276 ]])
277 AT_CLEANUP
278 ])
279
280
281 ## ------------------------ ##
282 ## Graph with no conflicts. ##
283 ## ------------------------ ##
284
285 AT_TEST([Graph with no conflicts],
286 [[%%
287 exp: a '?' b;
288 a: ;
289 b: 'b';
290 ]],
291 [[
292 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a '?' b\l 2 a: .\l"]
293 0 -> 1 [style=dashed label="exp"]
294 0 -> 2 [style=dashed label="a"]
295 0 -> "0R2" [style=solid]
296 "0R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
297 1 [label="State 1\n\l 0 $accept: exp . $end\l"]
298 1 -> 3 [style=solid label="$end"]
299 2 [label="State 2\n\l 1 exp: a . '?' b\l"]
300 2 -> 4 [style=solid label="'?'"]
301 3 [label="State 3\n\l 0 $accept: exp $end .\l"]
302 3 -> "3R0" [style=solid]
303 "3R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
304 4 [label="State 4\n\l 1 exp: a '?' . b\l 3 b: . 'b'\l"]
305 4 -> 5 [style=solid label="'b'"]
306 4 -> 6 [style=dashed label="b"]
307 5 [label="State 5\n\l 3 b: 'b' .\l"]
308 5 -> "5R3" [style=solid]
309 "5R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
310 6 [label="State 6\n\l 1 exp: a '?' b .\l"]
311 6 -> "6R1" [style=solid]
312 "6R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
313 ]])
314
315 ## ------------------------ ##
316 ## Graph with unsolved S/R. ##
317 ## ------------------------ ##
318
319 AT_TEST([Graph with unsolved S/R],
320 [[%%
321 start:
322 'a'
323 | empty_a 'a'
324 | 'b'
325 | empty_b 'b'
326 | 'c'
327 | empty_c 'c'
328 ;
329 empty_a: %prec 'a';
330 empty_b: %prec 'b';
331 empty_c: %prec 'c';
332 ]],
333 [[
334 0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . ['b']\l 9 empty_c: . ['c']\l"]
335 0 -> 1 [style=solid label="'a'"]
336 0 -> 2 [style=solid label="'b'"]
337 0 -> 3 [style=solid label="'c'"]
338 0 -> 4 [style=dashed label="start"]
339 0 -> 5 [style=dashed label="empty_a"]
340 0 -> 6 [style=dashed label="empty_b"]
341 0 -> 7 [style=dashed label="empty_c"]
342 0 -> "0R7d" [label="['a']", style=solid]
343 "0R7d" [label="R7", fillcolor=5, shape=diamond, style=filled]
344 0 -> "0R8d" [label="['b']", style=solid]
345 "0R8d" [label="R8", fillcolor=5, shape=diamond, style=filled]
346 0 -> "0R9d" [label="['c']", style=solid]
347 "0R9d" [label="R9", fillcolor=5, shape=diamond, style=filled]
348 1 [label="State 1\n\l 1 start: 'a' .\l"]
349 1 -> "1R1" [style=solid]
350 "1R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
351 2 [label="State 2\n\l 3 start: 'b' .\l"]
352 2 -> "2R3" [style=solid]
353 "2R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
354 3 [label="State 3\n\l 5 start: 'c' .\l"]
355 3 -> "3R5" [style=solid]
356 "3R5" [label="R5", fillcolor=3, shape=diamond, style=filled]
357 4 [label="State 4\n\l 0 $accept: start . $end\l"]
358 4 -> 8 [style=solid label="$end"]
359 5 [label="State 5\n\l 2 start: empty_a . 'a'\l"]
360 5 -> 9 [style=solid label="'a'"]
361 6 [label="State 6\n\l 4 start: empty_b . 'b'\l"]
362 6 -> 10 [style=solid label="'b'"]
363 7 [label="State 7\n\l 6 start: empty_c . 'c'\l"]
364 7 -> 11 [style=solid label="'c'"]
365 8 [label="State 8\n\l 0 $accept: start $end .\l"]
366 8 -> "8R0" [style=solid]
367 "8R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
368 9 [label="State 9\n\l 2 start: empty_a 'a' .\l"]
369 9 -> "9R2" [style=solid]
370 "9R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
371 10 [label="State 10\n\l 4 start: empty_b 'b' .\l"]
372 10 -> "10R4" [style=solid]
373 "10R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
374 11 [label="State 11\n\l 6 start: empty_c 'c' .\l"]
375 11 -> "11R6" [style=solid]
376 "11R6" [label="R6", fillcolor=3, shape=diamond, style=filled]
377 ]])
378
379 ## ---------------------- ##
380 ## Graph with solved S/R. ##
381 ## ---------------------- ##
382
383 AT_TEST([Graph with solved S/R],
384 [[%left 'a'
385 %right 'b'
386 %right 'c'
387 %%
388 start:
389 'a'
390 | empty_a 'a'
391 | 'b'
392 | empty_b 'b'
393 | 'c'
394 | empty_c 'c'
395 ;
396 empty_a: %prec 'a';
397 empty_b: %prec 'b';
398 empty_c: %prec 'c';
399 ]],
400 [[
401 0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . []\l 9 empty_c: . []\l"]
402 0 -> 1 [style=solid label="'b'"]
403 0 -> 2 [style=solid label="'c'"]
404 0 -> 3 [style=dashed label="start"]
405 0 -> 4 [style=dashed label="empty_a"]
406 0 -> 5 [style=dashed label="empty_b"]
407 0 -> 6 [style=dashed label="empty_c"]
408 0 -> "0R7" [style=solid]
409 "0R7" [label="R7", fillcolor=3, shape=diamond, style=filled]
410 1 [label="State 1\n\l 3 start: 'b' .\l"]
411 1 -> "1R3" [style=solid]
412 "1R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
413 2 [label="State 2\n\l 5 start: 'c' .\l"]
414 2 -> "2R5" [style=solid]
415 "2R5" [label="R5", fillcolor=3, shape=diamond, style=filled]
416 3 [label="State 3\n\l 0 $accept: start . $end\l"]
417 3 -> 7 [style=solid label="$end"]
418 4 [label="State 4\n\l 2 start: empty_a . 'a'\l"]
419 4 -> 8 [style=solid label="'a'"]
420 5 [label="State 5\n\l 4 start: empty_b . 'b'\l"]
421 5 -> 9 [style=solid label="'b'"]
422 6 [label="State 6\n\l 6 start: empty_c . 'c'\l"]
423 6 -> 10 [style=solid label="'c'"]
424 7 [label="State 7\n\l 0 $accept: start $end .\l"]
425 7 -> "7R0" [style=solid]
426 "7R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
427 8 [label="State 8\n\l 2 start: empty_a 'a' .\l"]
428 8 -> "8R2" [style=solid]
429 "8R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
430 9 [label="State 9\n\l 4 start: empty_b 'b' .\l"]
431 9 -> "9R4" [style=solid]
432 "9R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
433 10 [label="State 10\n\l 6 start: empty_c 'c' .\l"]
434 10 -> "10R6" [style=solid]
435 "10R6" [label="R6", fillcolor=3, shape=diamond, style=filled]
436 ]])
437
438 ## ---------------- ##
439 ## Graph with R/R. ##
440 ## ---------------- ##
441
442 AT_TEST([Graph with R/R],
443 [[%%
444 exp: a | b;
445 a: ;
446 b: ;
447 ]],
448 [[
449 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a\l 2 | . b\l 3 a: . [$end]\l 4 b: . [$end]\l"]
450 0 -> 1 [style=dashed label="exp"]
451 0 -> 2 [style=dashed label="a"]
452 0 -> 3 [style=dashed label="b"]
453 0 -> "0R3" [style=solid]
454 "0R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
455 0 -> "0R4d" [label="[$end]", style=solid]
456 "0R4d" [label="R4", fillcolor=5, shape=diamond, style=filled]
457 1 [label="State 1\n\l 0 $accept: exp . $end\l"]
458 1 -> 4 [style=solid label="$end"]
459 2 [label="State 2\n\l 1 exp: a .\l"]
460 2 -> "2R1" [style=solid]
461 "2R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
462 3 [label="State 3\n\l 2 exp: b .\l"]
463 3 -> "3R2" [style=solid]
464 "3R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
465 4 [label="State 4\n\l 0 $accept: exp $end .\l"]
466 4 -> "4R0" [style=solid]
467 "4R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
468 ]])
469
470 ## ---------------------------------------- ##
471 ## Graph with reductions with multiple LAT. ##
472 ## ---------------------------------------- ##
473
474 AT_TEST([Graph with reductions with multiple LAT],
475 [[%%
476 exp: a ';' | a ';' | a '.' | b '?' | b '!' | c '?' | c ';';
477 a: ;
478 b: ;
479 c: ;
480 ]],
481 [[
482 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a ';'\l 2 | . a ';'\l 3 | . a '.'\l 4 | . b '?'\l 5 | . b '!'\l 6 | . c '?'\l 7 | . c ';'\l 8 a: . [';', '.']\l 9 b: . ['?', '!']\l 10 c: . [';', '?']\l"]
483 0 -> 1 [style=dashed label="exp"]
484 0 -> 2 [style=dashed label="a"]
485 0 -> 3 [style=dashed label="b"]
486 0 -> 4 [style=dashed label="c"]
487 0 -> "0R8" [style=solid]
488 "0R8" [label="R8", fillcolor=3, shape=diamond, style=filled]
489 0 -> "0R9" [label="['?', '!']", style=solid]
490 "0R9" [label="R9", fillcolor=3, shape=diamond, style=filled]
491 0 -> "0R10d" [label="[';', '?']", style=solid]
492 "0R10d" [label="R10", fillcolor=5, shape=diamond, style=filled]
493 1 [label="State 1\n\l 0 $accept: exp . $end\l"]
494 1 -> 5 [style=solid label="$end"]
495 2 [label="State 2\n\l 1 exp: a . ';'\l 2 | a . ';'\l 3 | a . '.'\l"]
496 2 -> 6 [style=solid label="';'"]
497 2 -> 7 [style=solid label="'.'"]
498 3 [label="State 3\n\l 4 exp: b . '?'\l 5 | b . '!'\l"]
499 3 -> 8 [style=solid label="'?'"]
500 3 -> 9 [style=solid label="'!'"]
501 4 [label="State 4\n\l 6 exp: c . '?'\l 7 | c . ';'\l"]
502 4 -> 10 [style=solid label="';'"]
503 4 -> 11 [style=solid label="'?'"]
504 5 [label="State 5\n\l 0 $accept: exp $end .\l"]
505 5 -> "5R0" [style=solid]
506 "5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
507 6 [label="State 6\n\l 1 exp: a ';' . [$end]\l 2 | a ';' . [$end]\l"]
508 6 -> "6R1" [style=solid]
509 "6R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
510 6 -> "6R2d" [label="[$end]", style=solid]
511 "6R2d" [label="R2", fillcolor=5, shape=diamond, style=filled]
512 7 [label="State 7\n\l 3 exp: a '.' .\l"]
513 7 -> "7R3" [style=solid]
514 "7R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
515 8 [label="State 8\n\l 4 exp: b '?' .\l"]
516 8 -> "8R4" [style=solid]
517 "8R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
518 9 [label="State 9\n\l 5 exp: b '!' .\l"]
519 9 -> "9R5" [style=solid]
520 "9R5" [label="R5", fillcolor=3, shape=diamond, style=filled]
521 10 [label="State 10\n\l 7 exp: c ';' .\l"]
522 10 -> "10R7" [style=solid]
523 "10R7" [label="R7", fillcolor=3, shape=diamond, style=filled]
524 11 [label="State 11\n\l 6 exp: c '?' .\l"]
525 11 -> "11R6" [style=solid]
526 "11R6" [label="R6", fillcolor=3, shape=diamond, style=filled]
527 ]])
528
529 ## ------------------------------------------------------ ##
530 ## Graph with a reduction rule both enabled and disabled. ##
531 ## ------------------------------------------------------ ##
532
533 AT_TEST([Graph with a reduction rule both enabled and disabled],
534 [[%%
535 exp: ifexp | opexp | imm;
536 ifexp: "if" exp "then" exp elseexp;
537 elseexp: "else" exp | ;
538 opexp: exp '+' exp;
539 imm: '0';
540 ]],
541 [[
542 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"]
543 0 -> 1 [style=solid label="\"if\""]
544 0 -> 2 [style=solid label="'0'"]
545 0 -> 3 [style=dashed label="exp"]
546 0 -> 4 [style=dashed label="ifexp"]
547 0 -> 5 [style=dashed label="opexp"]
548 0 -> 6 [style=dashed label="imm"]
549 1 [label="State 1\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" . exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"]
550 1 -> 1 [style=solid label="\"if\""]
551 1 -> 2 [style=solid label="'0'"]
552 1 -> 7 [style=dashed label="exp"]
553 1 -> 4 [style=dashed label="ifexp"]
554 1 -> 5 [style=dashed label="opexp"]
555 1 -> 6 [style=dashed label="imm"]
556 2 [label="State 2\n\l 8 imm: '0' .\l"]
557 2 -> "2R8" [style=solid]
558 "2R8" [label="R8", fillcolor=3, shape=diamond, style=filled]
559 3 [label="State 3\n\l 0 $accept: exp . $end\l 7 opexp: exp . '+' exp\l"]
560 3 -> 8 [style=solid label="$end"]
561 3 -> 9 [style=solid label="'+'"]
562 4 [label="State 4\n\l 1 exp: ifexp .\l"]
563 4 -> "4R1" [style=solid]
564 "4R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
565 5 [label="State 5\n\l 2 exp: opexp .\l"]
566 5 -> "5R2" [style=solid]
567 "5R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
568 6 [label="State 6\n\l 3 exp: imm .\l"]
569 6 -> "6R3" [style=solid]
570 "6R3" [label="R3", fillcolor=3, shape=diamond, style=filled]
571 7 [label="State 7\n\l 4 ifexp: \"if\" exp . \"then\" exp elseexp\l 7 opexp: exp . '+' exp\l"]
572 7 -> 10 [style=solid label="\"then\""]
573 7 -> 9 [style=solid label="'+'"]
574 8 [label="State 8\n\l 0 $accept: exp $end .\l"]
575 8 -> "8R0" [style=solid]
576 "8R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
577 9 [label="State 9\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 7 | exp '+' . exp\l 8 imm: . '0'\l"]
578 9 -> 1 [style=solid label="\"if\""]
579 9 -> 2 [style=solid label="'0'"]
580 9 -> 11 [style=dashed label="exp"]
581 9 -> 4 [style=dashed label="ifexp"]
582 9 -> 5 [style=dashed label="opexp"]
583 9 -> 6 [style=dashed label="imm"]
584 10 [label="State 10\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" exp \"then\" . exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"]
585 10 -> 1 [style=solid label="\"if\""]
586 10 -> 2 [style=solid label="'0'"]
587 10 -> 12 [style=dashed label="exp"]
588 10 -> 4 [style=dashed label="ifexp"]
589 10 -> 5 [style=dashed label="opexp"]
590 10 -> 6 [style=dashed label="imm"]
591 11 [label="State 11\n\l 7 opexp: exp . '+' exp\l 7 | exp '+' exp . [$end, \"then\", \"else\", '+']\l"]
592 11 -> 9 [style=solid label="'+'"]
593 11 -> "11R7d" [label="['+']", style=solid]
594 "11R7d" [label="R7", fillcolor=5, shape=diamond, style=filled]
595 11 -> "11R7" [style=solid]
596 "11R7" [label="R7", fillcolor=3, shape=diamond, style=filled]
597 12 [label="State 12\n\l 4 ifexp: \"if\" exp \"then\" exp . elseexp\l 5 elseexp: . \"else\" exp\l 6 | . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"]
598 12 -> 13 [style=solid label="\"else\""]
599 12 -> 9 [style=solid label="'+'"]
600 12 -> 14 [style=dashed label="elseexp"]
601 12 -> "12R6d" [label="[\"else\", '+']", style=solid]
602 "12R6d" [label="R6", fillcolor=5, shape=diamond, style=filled]
603 12 -> "12R6" [style=solid]
604 "12R6" [label="R6", fillcolor=3, shape=diamond, style=filled]
605 13 [label="State 13\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 5 elseexp: \"else\" . exp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"]
606 13 -> 1 [style=solid label="\"if\""]
607 13 -> 2 [style=solid label="'0'"]
608 13 -> 15 [style=dashed label="exp"]
609 13 -> 4 [style=dashed label="ifexp"]
610 13 -> 5 [style=dashed label="opexp"]
611 13 -> 6 [style=dashed label="imm"]
612 14 [label="State 14\n\l 4 ifexp: \"if\" exp \"then\" exp elseexp .\l"]
613 14 -> "14R4" [style=solid]
614 "14R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
615 15 [label="State 15\n\l 5 elseexp: \"else\" exp . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"]
616 15 -> 9 [style=solid label="'+'"]
617 15 -> "15R5d" [label="['+']", style=solid]
618 "15R5d" [label="R5", fillcolor=5, shape=diamond, style=filled]
619 15 -> "15R5" [style=solid]
620 "15R5" [label="R5", fillcolor=3, shape=diamond, style=filled]
621 ]])
622
623 m4_popdef([AT_TEST])