]> git.saurik.com Git - bison.git/blame_incremental - tests/actions.at
* doc/bison.texinfo: Formatting changes.
[bison.git] / tests / actions.at
... / ...
CommitLineData
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
19AT_BANNER([[User Actions.]])
20
21## ------------------ ##
22## Mid-rule actions. ##
23## ------------------ ##
24
25AT_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
32AT_DATA([[input.y]],
33[[%{
34#include <stdio.h>
35#include <stdlib.h>
36static void yyerror (const char *msg);
37static int yylex (void);
38%}
39%%
40exp: { printf ("0\n"); }
41 '1' { printf ("1\n"); }
42 '2' { printf ("2\n"); }
43 '3' { printf ("3\n"); }
44 '4' { printf ("4\n"); }
45 '5' { printf ("5\n"); }
46 '6' { printf ("6\n"); }
47 '7' { printf ("7\n"); }
48 '8' { printf ("8\n"); }
49 '9' { printf ("9\n"); }
50 ;
51%%
52static int
53yylex (void)
54{
55 static const char *input = "123456789";
56 return *input++;
57}
58
59static void
60yyerror (const char *msg)
61{
62 fprintf (stderr, "%s\n", msg);
63}
64
65int
66main (void)
67{
68 return yyparse ();
69}
70]])
71
72AT_CHECK([bison input.y -d -v -o input.c])
73AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore])
74AT_CHECK([input], 0,
75[[0
761
772
783
794
805
816
827
838
849
85]])
86
87AT_CLEANUP