2
Clif - A C-like Interpreter Framework
3
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 T. Hruz, L. Koren
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
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.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
* grammar for channel compiler
31
%token <myint> NUMBERI /* integer constant */
32
%token <mydouble> NUMBERD /* double constant */
33
%token <mystring> STRING
34
%token FIELDS TYPE PRINT_FORMAT DIRECTION START_TIME DURATION_TIME
35
%token W_RESOLUTION LOWER UPPER STYLE AUTOMATIC ON_LEAVE_WINDOW
38
/* precedence information about the operators */
43
#include "channel_maint.h"
47
int yylex PROTO((void));
48
char *string PROTO((char *));
49
int yyerror PROTO((char *));
57
%% /* beginnig of rules section */
59
list_stat_0 : list_stat_0 stat_0
64
stat_0 : FIELDS '=' NUMBERI
68
* FIELDS must be specified
70
channel[channel_handle].fields = $3;
71
if (channel[channel_handle].fields > 0)
73
channel[channel_handle].cnt = 0;
74
channel[channel_handle].global_cnt = 0;
75
channel[channel_handle].w_resolution[0] = 256;
76
channel[channel_handle].w_resolution[1] = 256;
77
channel[channel_handle].start_time = 0.;
78
channel[channel_handle].s_time = 0;
79
channel[channel_handle].duration_time = 1000.;
80
channel[channel_handle].d_time = 0.;
81
channel[channel_handle].print_format = string ("line");
82
channel[channel_handle].type = string ("graphic");
83
channel[channel_handle].on_leave_w = string ("noevent");
84
channel[channel_handle].list =
85
(struct LIST *)allocate (sizeof (struct LIST), PERM);
86
channel[channel_handle].list_tmp =
87
(struct LIST *)allocate (sizeof (struct LIST), PERM);
88
channel[channel_handle].member =
89
(struct FIELD *)allocate (channel[channel_handle].fields
90
* sizeof (struct FIELD), PERM);
91
for (cnt = 0; cnt < channel[channel_handle].fields; cnt++)
93
channel[channel_handle].member[cnt].style = 0xffffffL;
94
channel[channel_handle].member[cnt].upper = 1;
95
channel[channel_handle].member[cnt].lower = -1;
101
free (channel[channel_handle].type);
103
channel[channel_handle].type = $3;}
105
| PRINT_FORMAT '=' STRING
108
free (channel[channel_handle].print_format);
110
channel[channel_handle].print_format = $3;}
112
| ON_LEAVE_WINDOW '=' STRING
115
free (channel[channel_handle].on_leave_w);
117
channel[channel_handle].on_leave_w = $3;}
119
| DIRECTION '=' STRING
120
{if (0 == (strcmp ($3, "input")))
121
channel[channel_handle].direction = 0;
124
if (0 == (strcmp ($3, "output")))
125
channel[channel_handle].direction = 1;
128
fprintfx (stderr, "bad direction\n");
133
| START_TIME '=' s_time
135
| DURATION_TIME '=' d_time
137
| W_RESOLUTION '=' NUMBERI NUMBERI
138
{channel[channel_handle].w_resolution[0] = $3; channel[channel_handle].w_resolution[1] = $4;}
140
| LOWER '(' NUMBERI ')' '=' NUMBERD
141
{if (channel[channel_handle].fields > $3)
142
channel[channel_handle].member[$3].lower = $6;
145
fprintfx (stderr, "invalid subscript\n");
149
| UPPER '(' NUMBERI ')' '=' NUMBERD
150
{if (channel[channel_handle].fields > $3)
151
channel[channel_handle].member[$3].upper = $6;
154
fprintfx (stderr, "invalid subscript\n");
158
| STYLE '(' NUMBERI ')' '=' NUMBERI
159
{if (channel[channel_handle].fields > $3)
160
channel[channel_handle].member[$3].style=(unsigned long)$6;
163
fprintfx (stderr,"invalid subscript\n");
168
{fprintfx (stderr,"error in opening channel\n"); return (-2);}
173
{channel[channel_handle].duration_time = $1; channel[channel_handle].d_time = 0.;}
176
{channel[channel_handle].duration_time = 16.; channel[channel_handle].d_time = 1.;}
181
{channel[channel_handle].start_time = $1; channel[channel_handle].s_time = 0;}
184
{channel[channel_handle].s_time = 1;}