File: channel.y

package info (click to toggle)
clif 0.93-9.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 4,228 kB
  • sloc: ansic: 31,464; yacc: 5,067; lex: 819; makefile: 383; sh: 48
file content (188 lines) | stat: -rw-r--r-- 4,997 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
    Clif - A C-like Interpreter Framework
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 T. Hruz, L. Koren

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

/* 
 * channel_y
 *
 * grammar for channel compiler
 */
%union {
	int myint;
	double mydouble;
	char *mystring;
	}
%token <myint> NUMBERI 		/* integer constant */
%token <mydouble> NUMBERD 	/* double constant */
%token <mystring> STRING
%token FIELDS TYPE PRINT_FORMAT DIRECTION START_TIME DURATION_TIME 
%token W_RESOLUTION LOWER UPPER STYLE AUTOMATIC ON_LEAVE_WINDOW
%start list_stat_0

	/* precedence information about the operators */
%right '='
%{
#include "global.h"
#include "mystdio.h"
#include "channel_maint.h"
#include "allocx.h"
#include "printfx.h"

int yylex PROTO((void));
char *string PROTO((char *));
int yyerror PROTO((char *));

int yyerror(s)
    char *s;
{
   return(0);;
}
%}
%% /* beginnig of rules section */

list_stat_0 : list_stat_0  stat_0

	    |
	    ;

stat_0 : FIELDS '=' NUMBERI
		{int cnt;
		 /* 
	 	  * Defaults filling
	 	  * FIELDS must be specified 
	 	  */
		 channel[channel_handle].fields = $3;
		 if (channel[channel_handle].fields > 0)
		   {
		     channel[channel_handle].cnt = 0;
		     channel[channel_handle].global_cnt = 0;
		     channel[channel_handle].w_resolution[0] = 256;
		     channel[channel_handle].w_resolution[1] = 256;
		     channel[channel_handle].start_time = 0.;
		     channel[channel_handle].s_time = 0;
		     channel[channel_handle].duration_time = 1000.;
		     channel[channel_handle].d_time = 0.;
		     channel[channel_handle].print_format = string ("line");
		     channel[channel_handle].type = string ("graphic");
		     channel[channel_handle].on_leave_w = string ("noevent");
		     channel[channel_handle].list = 
		       (struct LIST *)allocate (sizeof (struct LIST), PERM);
		     channel[channel_handle].list_tmp = 
		       (struct LIST *)allocate (sizeof (struct LIST), PERM);
		     channel[channel_handle].member =
		       (struct FIELD *)allocate (channel[channel_handle].fields 
						 * sizeof (struct FIELD), PERM);
		     for (cnt = 0; cnt < channel[channel_handle].fields; cnt++)
		       {
			 channel[channel_handle].member[cnt].style = 0xffffffL;
			 channel[channel_handle].member[cnt].upper = 1;
			 channel[channel_handle].member[cnt].lower = -1;
			}}}

	| TYPE '=' STRING
		{
#if 0
		  free (channel[channel_handle].type);
#endif
		  channel[channel_handle].type = $3;}

	| PRINT_FORMAT '=' STRING
		{
#if 0
		  free (channel[channel_handle].print_format);
#endif
		  channel[channel_handle].print_format = $3;}

	| ON_LEAVE_WINDOW '=' STRING
		{
#if 0
		  free (channel[channel_handle].on_leave_w);
#endif
		  channel[channel_handle].on_leave_w = $3;}

	| DIRECTION '=' STRING
		{if (0 == (strcmp ($3, "input")))
		   channel[channel_handle].direction = 0;
		 else
		   {
		     if (0 == (strcmp ($3, "output")))
		       channel[channel_handle].direction = 1;
		     else
		       {
			 fprintfx (stderr, "bad direction\n");
			 exit (0);
			}
		}}

	| START_TIME '=' s_time

	| DURATION_TIME '=' d_time

	| W_RESOLUTION '=' NUMBERI NUMBERI
		{channel[channel_handle].w_resolution[0] = $3; channel[channel_handle].w_resolution[1] = $4;}

	| LOWER '(' NUMBERI ')' '=' NUMBERD
		{if (channel[channel_handle].fields > $3)
		   channel[channel_handle].member[$3].lower = $6;
		 else
		   {
		     fprintfx (stderr, "invalid subscript\n");
		     exit (0);
		   }}

	| UPPER '(' NUMBERI ')' '=' NUMBERD
		{if (channel[channel_handle].fields > $3)
		   channel[channel_handle].member[$3].upper = $6;
		 else
		   {
		     fprintfx (stderr, "invalid subscript\n");
		     exit (0);
		   }}

	| STYLE '(' NUMBERI ')' '=' NUMBERI
		{if (channel[channel_handle].fields > $3)
		   channel[channel_handle].member[$3].style=(unsigned long)$6;
		 else
		   {
		     fprintfx (stderr,"invalid subscript\n");
		     exit (0);
		   }}

	| error
		{fprintfx (stderr,"error in opening channel\n"); return (-2);}

	;

d_time : NUMBERD 
		{channel[channel_handle].duration_time = $1; channel[channel_handle].d_time = 0.;}

	| AUTOMATIC
		{channel[channel_handle].duration_time = 16.; channel[channel_handle].d_time = 1.;}

	;

s_time : NUMBERD
		{channel[channel_handle].start_time = $1; channel[channel_handle].s_time = 0;}

	| AUTOMATIC
		{channel[channel_handle].s_time = 1;}

	;

%%