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