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 
20 %}
21 %s IN_COMMENT
22 
23 EMPTY [ \t]+
24 RETURN [\n|\r\n]
25 DIGIT [0-9]
26 LETTER [a-zA-Z]
27 R_NUMBER (({DIGIT}+(\.{DIGIT}+)?)|(\.{DIGIT}+))((E|e)[+-]?{DIGIT}+)?
28 I_NUMBER {DIGIT}+
29 IDENTIFIER {LETTER}({DIGIT}|{LETTER}|"_")*
30 COMMENT \%[^{\n|\r\n|\{}]*
31 COMMENT2 \#[^{\n|\r\n|\{}]*
32 COMMENT3 \/\/[^{\n|\r\n|\{}]*
33 
34 %%
35 {COMMENT} { }
36 {COMMENT2} { }
37 {COMMENT3} { }
38 
39 <INITIAL>{
40  "/*" BEGIN(IN_COMMENT);
41 }
42 
43 <IN_COMMENT>{
44  "*/" BEGIN(INITIAL);
45  [^*\n]+ // eat comment in chunks
46  "*" // eat the lone star
47  \n RCSline++;
48 }
49 
50 {EMPTY} { }
51 
52 {RETURN} { RCSline++; }
53 
54 "[CONSTANTS]" {
55  return(_CONSTANTS);
56  }
57 
58 "[SYSTEM VARS]" {
59  return(_SYSTEM_VARS);
60  }
61 
62 "[SECONDARY VARS]" {
63  return(_SECONDARY_VARS);
64  }
65 
66 "[DUMMY VARS]" {
67  return(_DUMMY_VARS);
68  }
69 
70 "[CARTESIAN VARS]" {
71  return(_CARTESIAN_VARS);
72  }
73 
74 "[SYSTEM EQS]" {
75  return(_SYSTEM_EQS);
76  }
77 
78 "[COORD EQS]" {
79  return(_COORD_EQS);
80  }
81 
82 "[DUMMY EQS]" {
83  return(_DUMMY_EQS);
84  }
85 
86 "[SEARCH]" {
87  return(_SEARCH);
88  }
89 
90 DEPTH {
91  return(_DEPTH);
92  }
93 
94 FIRST {
95  return(_FIRST);
96  }
97 
98 BREADTH {
99  return(_BREADTH);
100  }
101 
102 MIN {
103  return(_MIN);
104  }
105 
106 INF {
107  return(_INF);
108  }
109 
110 PI {
111  return(_PI);
112  }
113 
114 SIN {
115  return(_SIN);
116  }
117 
118 COS {
119  return(_COS);
120  }
121 
122 TAN {
123  return(_TAN);
124  }
125 
126 COT {
127  return(_COT);
128  }
129 
130 ACOS {
131  return(_ACOS);
132  }
133 
134 ASIN {
135  return(_ASIN);
136  }
137 
138 ATAN {
139  return(_ATAN);
140  }
141 
142 ATAN2 {
143  return(_ATAN2);
144  }
145 
146 EXP {
147  return(_EXP);
148  }
149 
150 PWP {
151  return(_PWP);
152  }
153 
154 SQRT {
155  return(_SQRT);
156  }
157 
158 ABS {
159  return(_ABS);
160  }
161 
162 PARAMETER {
163  return(_PARAMETER);
164  }
165 
166 PRINT {
167  return(_PRINT);
168  }
169 
170 T {
171  return(_T);
172  }
173 
174 TX {
175  return(_TX);
176  }
177 
178 TY {
179  return(_TY);
180  }
181 
182 TZ {
183  return(_TZ);
184  }
185 
186 TV {
187  return(_TV);
188  }
189 
190 PA {
191  return(_PA);
192  }
193 
194 RX {
195  return(_RX);
196  }
197 
198 RY {
199  return(_RY);
200  }
201 
202 RZ {
203  return(_RZ);
204  }
205 
206 DRX {
207  return(_DRX);
208  }
209 
210 DRY {
211  return(_DRY);
212  }
213 
214 DRZ {
215  return(_DRZ);
216  }
217 
218 DPA_U {
219  return(_DPA_U);
220  }
221 
222 DPA_V {
223  return(_DPA_V);
224  }
225 
226 DDRX {
227  return(_DDRX);
228  }
229 
230 DDRY {
231  return(_DDRY);
232  }
233 
234 DDRZ {
235  return(_DDRZ);
236  }
237 
238 DDPA_UU {
239  return(_DDPA_UU);
240  }
241 
242 DDPA_UV {
243  return(_DDPA_UV);
244  }
245 
246 DDPA_VV {
247  return(_DDPA_VV);
248  }
249 
250 ID {
251  return(_ID);
252  }
253 
254 "^-1" {
255  return(_INV);
256  }
257 
258 "=" {
259  return(_EQU);
260  }
261 
262 ">=" {
263  return(_GEQ);
264  }
265 
266 "<=" {
267  return(_LEQ);
268  }
269 
270 ">" {
271  return(_GREATER);
272  }
273 
274 "<" {
275  return(_LESS);
276  }
277 
278 "==" {
279  return(_EQUAL);
280  }
281 
282 "!=" {
283  return(_NOT_EQUAL);
284  }
285 
286 ":=" {
287  return(_ASSIGN);
288  }
289 
290 {I_NUMBER} {
291  char string_tmp[100];
292 
293  memcpy(string_tmp,Readcuiksystemtext,(unsigned int)Readcuiksystemleng);
294  string_tmp[Readcuiksystemleng]=0;
295  Readcuiksystemlval.int_number=atoi(string_tmp);
296  return(_INTEGER);
297  }
298 
299 {R_NUMBER} {
300  char string_tmp[100];
301 
302  memcpy(string_tmp,Readcuiksystemtext,(unsigned int)Readcuiksystemleng);
303  string_tmp[Readcuiksystemleng]=0;
304  Readcuiksystemlval.real_number=atof(string_tmp);
305 
306  return(_REAL);
307  }
308 
309 {IDENTIFIER} {
310  NEW(Readcuiksystemlval.id,Readcuiksystemleng+1,char);
311  memcpy(Readcuiksystemlval.id,Readcuiksystemtext,(unsigned int)Readcuiksystemleng);
312 
313  Readcuiksystemlval.id[Readcuiksystemleng]=0;
314 
315  return(_IDENTIFIER);
316  }
317 
318 \{ {
319  Readcuiksystemerror("The input file can not include the symbol '{'");
320  }
321 
322 . { return(Readcuiksystemtext[0]); }
323 
324 %%
336 {
337  return(1);
338 }
339 
#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.
int Readcuiksystemwrap()
Function called at the end of the parsing process.
#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