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