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