]> git.saurik.com Git - bison.git/blame - tests/output.at
muscle: factor conditionals on defined %define variables
[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
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[
342b8b6e
AD
48]])
49
342b8b6e 50AT_CHECK_OUTPUT([foo.y], [], [-dv],
e9690142 51 [foo.output foo.tab.c foo.tab.h])
b6ca79e8
JD
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.
f1bbfcce 56AT_CHECK_OUTPUT([foo.y], [], [-dv],
e9690142
JD
57 [foo.output foo.tab.c foo.tab.h],
58 [>&-], [],
59 [AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])])
b6ca79e8 60
342b8b6e 61AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
e9690142 62 [foo.c foo.h foo.output])
342b8b6e 63AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
e9690142 64 [foo.output foo.tab.c foo.tab.h])
1fa19a76
AD
65
66AT_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).
69AT_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
342b8b6e 72AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
e9690142 73 [bar.output bar.tab.c bar.tab.h])
342b8b6e 74AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
e9690142 75 [foo.c foo.dot foo.h foo.output])
342b8b6e
AD
76
77
78AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [],
e9690142 79 [foo.output foo.tab.c foo.tab.h])
342b8b6e 80AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[],
e9690142 81 [y.output y.tab.c y.tab.h])
342b8b6e 82
5e5d5415 83AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[],
e9690142 84 [y.output y.tab.c y.tab.h])
5e5d5415 85
ae93e4e4 86# Exercise %output and %file-prefix including deprecated '='
02975b9a 87AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
e9690142 88 [bar.output bar.tab.c bar.tab.h])
2062d72d 89AT_CHECK_OUTPUT([foo.y], [%output "bar.c" %defines %verbose %yacc],[],
1a5fb4f2 90 [bar.c bar.h bar.output])
951366c1 91AT_CHECK_OUTPUT([foo.y],
2062d72d 92 [%file-prefix "baz" %output "bar.c" %defines %verbose %yacc],
e9690142 93 [],
1a5fb4f2 94 [bar.c bar.h bar.output])
951366c1 95
342b8b6e
AD
96
97# Check priorities of extension control.
98AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
e9690142 99 [foo.output foo.tab.cc foo.tab.hh])
342b8b6e
AD
100
101AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
e9690142 102 [foo.c foo.h foo.output])
342b8b6e
AD
103
104AT_CHECK_OUTPUT([foo.yy], [],
e9690142
JD
105 [--defines=foo.hpp -o foo.c++],
106 [foo.c++ foo.hpp])
342b8b6e 107
02975b9a 108AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
e9690142
JD
109 [-o foo.c++],
110 [foo.c++ foo.hpp])
02975b9a 111
342b8b6e 112AT_CHECK_OUTPUT([foo.yy], [],
e9690142
JD
113 [-o foo.c++ --graph=foo.gph],
114 [foo.c++ foo.gph])
7625ec2c
AD
115
116
117## ------------ ##
118## C++ output. ##
119## ------------ ##
120
121m4_define([AT_CHECK_NO_SUBDIR_PART],
122[# Also make sure that the includes do not refer to the subdirectory.
123AT_CHECK([grep 'include .subdir/' $1.cc], 1, [])
124AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
125])
126
93549bcd 127AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose], [],
1a5fb4f2 128 [foo.output foo.tab.cc])
93549bcd 129
7625ec2c 130AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
1a5fb4f2 131 [foo.output foo.tab.cc foo.tab.hh stack.hh])
2ea7730c 132
93549bcd 133AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose %locations], [],
1a5fb4f2 134 [foo.output foo.tab.cc])
93549bcd 135
2ea7730c 136AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [],
1a5fb4f2 137 [foo.output foo.tab.cc foo.tab.hh location.hh position.hh stack.hh])
7625ec2c
AD
138
139AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
1a5fb4f2 140 [foo.output foo.tab.cc foo.tab.hh stack.hh],
e9690142 141 [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
7625ec2c 142
2ea7730c 143AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations],
e9690142 144 [-o subdir/foo.cc],
1a5fb4f2 145 [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/position.hh subdir/stack.hh],
e9690142 146 [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
3f7ca628 147
cae5057f
JD
148AT_CHECK_OUTPUT([gram_dir/foo.yy],
149 [%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"],
150 [],
1a5fb4f2 151 [output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/stack.hh])
2ea7730c
AD
152
153AT_CHECK_OUTPUT([gram_dir/foo.yy],
154 [%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"],
155 [],
1a5fb4f2 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])
cae5057f 157
3f7ca628 158
c0ee9e21
DJ
159# AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR,
160# [EXIT-STATUS])
161# ------------------------------------------------------------------
3f7ca628
JD
162m4_define([AT_CHECK_CONFLICTING_OUTPUT],
163[AT_SETUP([Conflicting output files: $2 $3])
164case "$1" in
165 */*) mkdir `echo "$1" | sed 's,/.*,,'`;;
166esac
167AT_DATA([$1],
168[[$2
169%%
170foo: {};
171]])
172
f39ab286 173[cp ]$1[ expout]
890aeb28
JD
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.
178AT_BISON_CHECK_NO_XML([$3 $1], $5, [], [$4])
f39ab286 179AT_CHECK([[cat $1]], [[0]], [expout])
3f7ca628
JD
180AT_CLEANUP
181])
182
183AT_CHECK_CONFLICTING_OUTPUT([foo.y],
184[], [--graph="foo.tab.c"],
73370a9d
VS
185[[foo.y: warning: conflicting outputs to file 'foo.tab.c' [-Wother]
186]])
3f7ca628
JD
187
188AT_CHECK_CONFLICTING_OUTPUT([foo.y],
189[%defines "foo.output"], [-v],
73370a9d
VS
190[[foo.y: warning: conflicting outputs to file 'foo.output' [-Wother]
191]])
3f7ca628
JD
192
193AT_CHECK_CONFLICTING_OUTPUT([foo.y],
2ea7730c 194[%skeleton "lalr1.cc" %defines %locations], [--graph="location.hh"],
73370a9d
VS
195[[foo.y: warning: conflicting outputs to file 'location.hh' [-Wother]
196]])
bd9d212b 197
c0ee9e21 198AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
11b19212 199[[foo.y: error: refusing to overwrite the input file 'foo.y'
73370a9d 200]], 1)
c0ee9e21 201
bd9d212b
JD
202
203# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
2ea7730c 204# ---------------------------------------------------------------
bd9d212b
JD
205m4_define([AT_CHECK_OUTPUT_FILE_NAME],
206[AT_SETUP([Output file name: $1])
207
290a8ff2 208AT_BISON_OPTION_PUSHDEFS
7439c5c0
JD
209# Skip if platform doesn't support file name. For example, Cygwin
210# doesn't support file names containing ":" or "\".
211AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]])
212
ce3448d5 213AT_DATA_GRAMMAR([glr.y],
bd9d212b
JD
214[[%glr-parser
215%code {
290a8ff2
AD
216]AT_YYERROR_DECLARE_EXTERN[
217]AT_YYLEX_DECLARE_EXTERN[
bd9d212b
JD
218}
219%%
220start: {};
221]])
da730230 222AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" glr.y])
bd9d212b
JD
223AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
224AT_COMPILE([glr.o], [-c "AS_ESCAPE([$1.c])"])
225$2
226
ce3448d5 227AT_DATA_GRAMMAR([cxx.y],
bd9d212b
JD
228[[%skeleton "lalr1.cc"
229%code { int yylex (yy::parser::semantic_type*); }
230%%
231start: {};
232]])
5cf79ede
AD
233AT_BISON_CHECK([-o "AS_ESCAPE([$1.cc])" --defines="AS_ESCAPE([$1.hh])" cxx.y])
234AT_CHECK([ls "AS_ESCAPE([$1.cc])" "AS_ESCAPE([$1.hh])"], [], [ignore])
235AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.cc])"])
bd9d212b
JD
236$2
237
290a8ff2 238AT_BISON_OPTION_POPDEFS
bd9d212b
JD
239AT_CLEANUP
240])
241
242# Notice that the header file name here cannot contain
ae93e4e4 243# '"' since FILENAME in '#include "FILENAME"' cannot.
bd9d212b 244AT_CHECK_OUTPUT_FILE_NAME([[`~!@#$%^&*()-=_+{}[]|\:;<>, .']])
f55efa38
JD
245dnl Work around a bug in m4_expand that broke AT_SETUP in autoconf 2.62,
246dnl by using the definition from 2.63.
215b40ac
EB
247m4_version_prereq([2.63], [],
248[m4_define([m4_expand], [_$0(-=<{($1)}>=-)])
f55efa38 249m4_define([_m4_expand],
215b40ac 250[m4_changequote([-=<{(], [)}>=-])$1m4_changequote([, ])])])
f55efa38
JD
251AT_CHECK_OUTPUT_FILE_NAME([[(]])
252AT_CHECK_OUTPUT_FILE_NAME([[)]])
cf48f675 253AT_CHECK_OUTPUT_FILE_NAME([[@%:@]])
bd9d212b
JD
254AT_CHECK_OUTPUT_FILE_NAME([[@@]])
255AT_CHECK_OUTPUT_FILE_NAME([[@{]])
256AT_CHECK_OUTPUT_FILE_NAME([[@}]])
bd9d212b
JD
257AT_CHECK_OUTPUT_FILE_NAME([[@<:@]])
258AT_CHECK_OUTPUT_FILE_NAME([[@:>@]])
dd47b522
TR
259
260
261# AT_TEST(SETUP-NAME, GRAMMAR, DOT-BODY)
262# --------------------------------------
263# Check that the DOT graph for GRAMMAR is DOT-BODY.
264m4_pushdef([AT_TEST],
265[AT_SETUP([$1])
266AT_KEYWORDS([[graph]])
267AT_DATA([[input.y]], [$2])
268AT_BISON_CHECK([[-rall --graph input.y]], [0], [[]], [[ignore]])
269AT_CHECK([[grep -v // input.dot]], [0],
270[[
271digraph "input.y"
272{
273 node [fontname = courier, shape = box, colorscheme = paired6]
274 edge [fontname = courier]
275 ]$3[}
276]])
277AT_CLEANUP
278])
279
280
281## ------------------------ ##
282## Graph with no conflicts. ##
283## ------------------------ ##
284
285AT_TEST([Graph with no conflicts],
286[[%%
287exp: a '?' b;
288a: ;
289b: 'b';
290]],
291[[
be3517b0 292 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a '?' b\l 2 a: .\l"]
dd47b522
TR
293 0 -> 1 [style=dashed label="exp"]
294 0 -> 2 [style=dashed label="a"]
be3517b0
TR
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"]
dd47b522 298 1 -> 3 [style=solid label="$end"]
be3517b0 299 2 [label="State 2\n\l 1 exp: a . '?' b\l"]
dd47b522 300 2 -> 4 [style=solid label="'?'"]
be3517b0
TR
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"]
dd47b522
TR
305 4 -> 5 [style=solid label="'b'"]
306 4 -> 6 [style=dashed label="b"]
be3517b0
TR
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]
dd47b522
TR
313]])
314
315## ------------------------ ##
316## Graph with unsolved S/R. ##
317## ------------------------ ##
318
319AT_TEST([Graph with unsolved S/R],
320[[%%
321start:
322 'a'
323 | empty_a 'a'
324 | 'b'
325 | empty_b 'b'
326 | 'c'
327 | empty_c 'c'
328 ;
329empty_a: %prec 'a';
330empty_b: %prec 'b';
331empty_c: %prec 'c';
332]],
333[[
be3517b0 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"]
dd47b522
TR
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"]
be3517b0
TR
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"]
dd47b522 358 4 -> 8 [style=solid label="$end"]
be3517b0 359 5 [label="State 5\n\l 2 start: empty_a . 'a'\l"]
dd47b522 360 5 -> 9 [style=solid label="'a'"]
be3517b0 361 6 [label="State 6\n\l 4 start: empty_b . 'b'\l"]
dd47b522 362 6 -> 10 [style=solid label="'b'"]
be3517b0 363 7 [label="State 7\n\l 6 start: empty_c . 'c'\l"]
dd47b522 364 7 -> 11 [style=solid label="'c'"]
be3517b0
TR
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]
dd47b522
TR
377]])
378
379## ---------------------- ##
380## Graph with solved S/R. ##
381## ---------------------- ##
382
383AT_TEST([Graph with solved S/R],
384[[%left 'a'
385%right 'b'
386%right 'c'
387%%
388start:
389 'a'
390 | empty_a 'a'
391 | 'b'
392 | empty_b 'b'
393 | 'c'
394 | empty_c 'c'
395 ;
396empty_a: %prec 'a';
397empty_b: %prec 'b';
398empty_c: %prec 'c';
399]],
400[[
be3517b0 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"]
dd47b522
TR
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"]
be3517b0
TR
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"]
dd47b522 417 3 -> 7 [style=solid label="$end"]
be3517b0 418 4 [label="State 4\n\l 2 start: empty_a . 'a'\l"]
dd47b522 419 4 -> 8 [style=solid label="'a'"]
be3517b0 420 5 [label="State 5\n\l 4 start: empty_b . 'b'\l"]
dd47b522 421 5 -> 9 [style=solid label="'b'"]
be3517b0 422 6 [label="State 6\n\l 6 start: empty_c . 'c'\l"]
dd47b522 423 6 -> 10 [style=solid label="'c'"]
be3517b0
TR
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]
dd47b522
TR
436]])
437
438## ---------------- ##
439## Graph with R/R. ##
440## ---------------- ##
441
442AT_TEST([Graph with R/R],
443[[%%
444exp: a | b;
445a: ;
446b: ;
447]],
448[[
be3517b0 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"]
dd47b522
TR
450 0 -> 1 [style=dashed label="exp"]
451 0 -> 2 [style=dashed label="a"]
452 0 -> 3 [style=dashed label="b"]
be3517b0
TR
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"]
dd47b522 458 1 -> 4 [style=solid label="$end"]
be3517b0
TR
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]
dd47b522
TR
468]])
469
470## ---------------------------------------- ##
471## Graph with reductions with multiple LAT. ##
472## ---------------------------------------- ##
473
474AT_TEST([Graph with reductions with multiple LAT],
475[[%%
476exp: a ';' | a ';' | a '.' | b '?' | b '!' | c '?' | c ';';
477a: ;
478b: ;
479c: ;
480]],
481[[
be3517b0 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"]
dd47b522
TR
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"]
be3517b0
TR
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"]
dd47b522 494 1 -> 5 [style=solid label="$end"]
be3517b0 495 2 [label="State 2\n\l 1 exp: a . ';'\l 2 | a . ';'\l 3 | a . '.'\l"]
dd47b522
TR
496 2 -> 6 [style=solid label="';'"]
497 2 -> 7 [style=solid label="'.'"]
be3517b0 498 3 [label="State 3\n\l 4 exp: b . '?'\l 5 | b . '!'\l"]
dd47b522
TR
499 3 -> 8 [style=solid label="'?'"]
500 3 -> 9 [style=solid label="'!'"]
be3517b0 501 4 [label="State 4\n\l 6 exp: c . '?'\l 7 | c . ';'\l"]
dd47b522
TR
502 4 -> 10 [style=solid label="';'"]
503 4 -> 11 [style=solid label="'?'"]
be3517b0
TR
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]
dd47b522
TR
527]])
528
529## ------------------------------------------------------ ##
530## Graph with a reduction rule both enabled and disabled. ##
531## ------------------------------------------------------ ##
532
533AT_TEST([Graph with a reduction rule both enabled and disabled],
534[[%%
535exp: ifexp | opexp | imm;
536ifexp: "if" exp "then" exp elseexp;
537elseexp: "else" exp | ;
538opexp: exp '+' exp;
539imm: '0';
540]],
541[[
be3517b0 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"]
dd47b522
TR
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"]
be3517b0 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"]
dd47b522
TR
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"]
be3517b0
TR
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"]
dd47b522
TR
560 3 -> 8 [style=solid label="$end"]
561 3 -> 9 [style=solid label="'+'"]
be3517b0
TR
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"]
dd47b522
TR
572 7 -> 10 [style=solid label="\"then\""]
573 7 -> 9 [style=solid label="'+'"]
be3517b0
TR
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"]
dd47b522
TR
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"]
be3517b0 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"]
dd47b522
TR
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"]
be3517b0 591 11 [label="State 11\n\l 7 opexp: exp . '+' exp\l 7 | exp '+' exp . [$end, \"then\", \"else\", '+']\l"]
dd47b522 592 11 -> 9 [style=solid label="'+'"]
be3517b0
TR
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"]
dd47b522
TR
598 12 -> 13 [style=solid label="\"else\""]
599 12 -> 9 [style=solid label="'+'"]
600 12 -> 14 [style=dashed label="elseexp"]
be3517b0
TR
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"]
dd47b522
TR
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"]
be3517b0
TR
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"]
dd47b522 616 15 -> 9 [style=solid label="'+'"]
be3517b0
TR
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]
dd47b522
TR
621]])
622
623m4_popdef([AT_TEST])