readcuiksystem.l
Go to the documentation of this file.
1 %{
2 /*
3 * Lexical analizer for the function that initilizes a set of equations from a file
4 */
5 
8 #include <stdlib.h>
9 #include <string.h>
10 
11 #include "defines.h"
12 #include "error.h"
13 #include "readcuiksystemtypes.h"
14 #include "readcuiksystem.tab.h"
15 
16 int Readcuiksystemlex(void);
17 
18 extern unsigned int RCSline;
19 
22 %}
23 %s IN_COMMENT
24 
25 EMPTY [ \t]+
26 RETURN [\n|\r\n]
27 DIGIT [0-9]
28 LETTER [a-zA-Z]
29 R_NUMBER (({DIGIT}+(\.{DIGIT}+)?)|(\.{DIGIT}+))((E|e)[+-]?{DIGIT}+)?
30 I_NUMBER {DIGIT}+
31 IDENTIFIER {LETTER}({DIGIT}|{LETTER}|"_")*
32 COMMENT \%[^{\n|\r\n|\{}]*
33 COMMENT2 \#[^{\n|\r\n|\{}]*
34 COMMENT3 \/\/[^{\n|\r\n|\{}]*
35 
36 %%
37 {COMMENT} { }
38 {COMMENT2} { }
39 {COMMENT3} { }
40 
41 <INITIAL>{
42  "/*" BEGIN(IN_COMMENT);
43 }
44 <IN_COMMENT>{
45  "*/" BEGIN(INITIAL);
46  [^*\n]+ // eat comment in chunks
47  "*" // eat the lone star
48  \n RCSline++;
49 }
50 
51 {EMPTY} { }
52 
53 {RETURN} { RCSline++; }
54 
55 "[CONSTANTS]" {
56  return(_CONSTANTS);
57  }
58 
59 "[SYSTEM VARS]" {
60  return(_SYSTEM_VARS);
61  }
62 
63 "[SECONDARY VARS]" {
64  return(_SECONDARY_VARS);
65  }
66 
67 "[DUMMY VARS]" {
68  return(_DUMMY_VARS);
69  }
70 
71 "[CARTESIAN VARS]" {
72  return(_CARTESIAN_VARS);
73  }
74 
75 "[SYSTEM EQS]" {
76  return(_SYSTEM_EQS);
77  }
78 
79 "[COORD EQS]" {
80  return(_COORD_EQS);
81  }
82 
83 "[DUMMY EQS]" {
84  return(_DUMMY_EQS);
85  }
86 
87 "[SEARCH]" {
88  return(_SEARCH);
89  }
90 
91 DEPTH {
92  return(_DEPTH);
93  }
94 
95 FIRST {
96  return(_FIRST);
97  }
98 
99 BREADTH {
100  return(_BREADTH);
101  }
102 
103 MIN {
104  return(_MIN);
105  }
106 
107 INF {
108  return(_INF);
109  }
110 
111 PI {
112  return(_PI);
113  }
114 
115 SIN {
116  return(_SIN);
117  }
118 
119 COS {
120  return(_COS);
121  }
122 
123 TAN {
124  return(_TAN);
125  }
126 
127 EXP {
128  return(_EXP);
129  }
130 
131 PWP {
132  return(_PWP);
133  }
134 
135 SQRT {
136  return(_SQRT);
137  }
138 
139 T {
140  return(_T);
141  }
142 
143 TX {
144  return(_TX);
145  }
146 
147 TY {
148  return(_TY);
149  }
150 
151 TZ {
152  return(_TZ);
153  }
154 
155 TV {
156  return(_TV);
157  }
158 
159 PA {
160  return(_PA);
161  }
162 
163 RX {
164  return(_RX);
165  }
166 
167 RY {
168  return(_RY);
169  }
170 
171 RZ {
172  return(_RZ);
173  }
174 
175 DRX {
176  return(_DRX);
177  }
178 
179 DRY {
180  return(_DRY);
181  }
182 
183 DRZ {
184  return(_DRZ);
185  }
186 
187 DPA_U {
188  return(_DPA_U);
189  }
190 
191 DPA_V {
192  return(_DPA_V);
193  }
194 
195 DDRX {
196  return(_DDRX);
197  }
198 
199 DDRY {
200  return(_DDRY);
201  }
202 
203 DDRZ {
204  return(_DDRZ);
205  }
206 
207 DDPA_UU {
208  return(_DDPA_UU);
209  }
210 
211 DDPA_UV {
212  return(_DDPA_UV);
213  }
214 
215 DDPA_VV {
216  return(_DDPA_VV);
217  }
218 
219 ID {
220  return(_ID);
221  }
222 
223 "^-1" {
224  return(_INV);
225  }
226 
227 "=" {
228  return(_EQU);
229  }
230 
231 ">=" {
232  return(_GEQ);
233  }
234 
235 "<=" {
236  return(_LEQ);
237  }
238 
239 ":=" {
240  return(_ASSIGN);
241  }
242 
243 {I_NUMBER} {
244  char string_tmp[100];
245 
246  memcpy(string_tmp,Readcuiksystemtext,(unsigned int)Readcuiksystemleng);
247  string_tmp[Readcuiksystemleng]=0;
248  Readcuiksystemlval.int_number=atoi(string_tmp);
249  return(_INTEGER);
250  }
251 
252 {R_NUMBER} {
253  char string_tmp[100];
254 
255  memcpy(string_tmp,Readcuiksystemtext,(unsigned int)Readcuiksystemleng);
256  string_tmp[Readcuiksystemleng]=0;
257  Readcuiksystemlval.real_number=atof(string_tmp);
258 
259  return(_REAL);
260  }
261 
262 {IDENTIFIER} {
263  NEW(Readcuiksystemlval.id,Readcuiksystemleng+1,char);
264  memcpy(Readcuiksystemlval.id,Readcuiksystemtext,(unsigned int)Readcuiksystemleng);
265 
266  Readcuiksystemlval.id[Readcuiksystemleng]=0;
267 
268  return(_IDENTIFIER);
269  }
270 
271 \{ {
272  Readcuiksystemerror("The input file can not include the symbol '{'");
273  }
274 
275 . { return(Readcuiksystemtext[0]); }
276 
277 %%
278 
287 int Readcuiksystemwrap()
288 {
289  return(1);
290 }
291 
#define NEW(_var, _n, _type)
Allocates memory space.
Definition: defines.h:385
#define RZ
One of the types of homogeneous transforms in R^3.
Definition: htransform.h:75
#define RY
One of the types of homogeneous transforms in R^3.
Definition: htransform.h:67
#define TZ
One of the types of homogeneous transforms in R^3.
Definition: htransform.h:51
Error and warning functions.
#define TX
One of the types of homogeneous transforms in R^3.
Definition: htransform.h:35
Definitions of constants and macros used in several parts of the cuik library.
Definition of data types shared between the lexical and the syntactical analizer for ...
#define RX
One of the types of homogeneous transforms in R^3.
Definition: htransform.h:59
int Readcuiksystemerror(const char *s)
Syntax errors in .cuik files.
Definition: error.c:88
#define PA
Point on a patch.
Definition: trans_seq.h:31
#define INF
Infinite.
Definition: defines.h:70
#define TV
Displacement along a vector.
Definition: trans_seq.h:24
unsigned int RCSline
Number of the line currently parsed when reading a .cuik file.
Definition: error.c:71
#define TY
One of the types of homogeneous transforms in R^3.
Definition: htransform.h:43