]> git.saurik.com Git - bison.git/blob - tests/actions.at
* tests/actions.at (Mid-rule actions): Output on a single line
[bison.git] / tests / actions.at
1 # Executing Actions. -*- Autotest -*-
2 # Copyright 2001 Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 # 02111-1307, USA.
18
19 AT_BANNER([[User Actions.]])
20
21 ## ------------------ ##
22 ## Mid-rule actions. ##
23 ## ------------------ ##
24
25 AT_SETUP([Mid-rule actions])
26
27 # Bison once forgot the mid-rule actions. It was because the action
28 # was attached to the host rule (the one with the mid-rule action),
29 # instead of being attached to the empty rule dedicated to this
30 # action.
31
32 AT_DATA([[input.y]],
33 [[%{
34 #include <stdio.h>
35 #include <stdlib.h>
36 static void yyerror (const char *msg);
37 static int yylex (void);
38 %}
39 %%
40 exp: { putchar ('0'); }
41 '1' { putchar ('1'); }
42 '2' { putchar ('2'); }
43 '3' { putchar ('3'); }
44 '4' { putchar ('4'); }
45 '5' { putchar ('5'); }
46 '6' { putchar ('6'); }
47 '7' { putchar ('7'); }
48 '8' { putchar ('8'); }
49 '9' { putchar ('9'); }
50 { putchar ('\n'); }
51 ;
52 %%
53 static int
54 yylex (void)
55 {
56 static const char *input = "123456789";
57 return *input++;
58 }
59
60 static void
61 yyerror (const char *msg)
62 {
63 fprintf (stderr, "%s\n", msg);
64 }
65
66 int
67 main (void)
68 {
69 return yyparse ();
70 }
71 ]])
72
73 AT_CHECK([bison input.y -d -v -o input.c])
74 AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore])
75 AT_CHECK([input], 0,
76 [[0123456789
77 ]])
78
79 AT_CLEANUP