~ubuntu-branches/ubuntu/oneiric/clif/oneiric

« back to all changes in this revision

Viewing changes to channel.y

  • Committer: Bazaar Package Importer
  • Author(s): Adrian Bunk
  • Date: 2002-01-25 14:05:49 UTC
  • Revision ID: james.westby@ubuntu.com-20020125140549-v5mmddxqlcrgzhd2
Tags: upstream-0.93
ImportĀ upstreamĀ versionĀ 0.93

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Clif - A C-like Interpreter Framework
 
3
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 T. Hruz, L. Koren
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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.
 
18
 
 
19
*/
 
20
 
 
21
/* 
 
22
 * channel_y
 
23
 *
 
24
 * grammar for channel compiler
 
25
 */
 
26
%union {
 
27
        int myint;
 
28
        double mydouble;
 
29
        char *mystring;
 
30
        }
 
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
 
36
%start list_stat_0
 
37
 
 
38
        /* precedence information about the operators */
 
39
%right '='
 
40
%{
 
41
#include "global.h"
 
42
#include "mystdio.h"
 
43
#include "channel_maint.h"
 
44
#include "allocx.h"
 
45
#include "printfx.h"
 
46
 
 
47
int yylex PROTO((void));
 
48
char *string PROTO((char *));
 
49
int yyerror PROTO((char *));
 
50
 
 
51
int yyerror(s)
 
52
    char *s;
 
53
{
 
54
   return(0);;
 
55
}
 
56
%}
 
57
%% /* beginnig of rules section */
 
58
 
 
59
list_stat_0 : list_stat_0  stat_0
 
60
 
 
61
            |
 
62
            ;
 
63
 
 
64
stat_0 : FIELDS '=' NUMBERI
 
65
                {int cnt;
 
66
                 /* 
 
67
                  * Defaults filling
 
68
                  * FIELDS must be specified 
 
69
                  */
 
70
                 channel[channel_handle].fields = $3;
 
71
                 if (channel[channel_handle].fields > 0)
 
72
                   {
 
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++)
 
92
                       {
 
93
                         channel[channel_handle].member[cnt].style = 0xffffffL;
 
94
                         channel[channel_handle].member[cnt].upper = 1;
 
95
                         channel[channel_handle].member[cnt].lower = -1;
 
96
                        }}}
 
97
 
 
98
        | TYPE '=' STRING
 
99
                {
 
100
#if 0
 
101
                  free (channel[channel_handle].type);
 
102
#endif
 
103
                  channel[channel_handle].type = $3;}
 
104
 
 
105
        | PRINT_FORMAT '=' STRING
 
106
                {
 
107
#if 0
 
108
                  free (channel[channel_handle].print_format);
 
109
#endif
 
110
                  channel[channel_handle].print_format = $3;}
 
111
 
 
112
        | ON_LEAVE_WINDOW '=' STRING
 
113
                {
 
114
#if 0
 
115
                  free (channel[channel_handle].on_leave_w);
 
116
#endif
 
117
                  channel[channel_handle].on_leave_w = $3;}
 
118
 
 
119
        | DIRECTION '=' STRING
 
120
                {if (0 == (strcmp ($3, "input")))
 
121
                   channel[channel_handle].direction = 0;
 
122
                 else
 
123
                   {
 
124
                     if (0 == (strcmp ($3, "output")))
 
125
                       channel[channel_handle].direction = 1;
 
126
                     else
 
127
                       {
 
128
                         fprintfx (stderr, "bad direction\n");
 
129
                         exit (0);
 
130
                        }
 
131
                }}
 
132
 
 
133
        | START_TIME '=' s_time
 
134
 
 
135
        | DURATION_TIME '=' d_time
 
136
 
 
137
        | W_RESOLUTION '=' NUMBERI NUMBERI
 
138
                {channel[channel_handle].w_resolution[0] = $3; channel[channel_handle].w_resolution[1] = $4;}
 
139
 
 
140
        | LOWER '(' NUMBERI ')' '=' NUMBERD
 
141
                {if (channel[channel_handle].fields > $3)
 
142
                   channel[channel_handle].member[$3].lower = $6;
 
143
                 else
 
144
                   {
 
145
                     fprintfx (stderr, "invalid subscript\n");
 
146
                     exit (0);
 
147
                   }}
 
148
 
 
149
        | UPPER '(' NUMBERI ')' '=' NUMBERD
 
150
                {if (channel[channel_handle].fields > $3)
 
151
                   channel[channel_handle].member[$3].upper = $6;
 
152
                 else
 
153
                   {
 
154
                     fprintfx (stderr, "invalid subscript\n");
 
155
                     exit (0);
 
156
                   }}
 
157
 
 
158
        | STYLE '(' NUMBERI ')' '=' NUMBERI
 
159
                {if (channel[channel_handle].fields > $3)
 
160
                   channel[channel_handle].member[$3].style=(unsigned long)$6;
 
161
                 else
 
162
                   {
 
163
                     fprintfx (stderr,"invalid subscript\n");
 
164
                     exit (0);
 
165
                   }}
 
166
 
 
167
        | error
 
168
                {fprintfx (stderr,"error in opening channel\n"); return (-2);}
 
169
 
 
170
        ;
 
171
 
 
172
d_time : NUMBERD 
 
173
                {channel[channel_handle].duration_time = $1; channel[channel_handle].d_time = 0.;}
 
174
 
 
175
        | AUTOMATIC
 
176
                {channel[channel_handle].duration_time = 16.; channel[channel_handle].d_time = 1.;}
 
177
 
 
178
        ;
 
179
 
 
180
s_time : NUMBERD
 
181
                {channel[channel_handle].start_time = $1; channel[channel_handle].s_time = 0;}
 
182
 
 
183
        | AUTOMATIC
 
184
                {channel[channel_handle].s_time = 1;}
 
185
 
 
186
        ;
 
187
 
 
188
%%