49 #include "create_enumtype_conversion_functions.hh" |
49 #include "create_enumtype_conversion_functions.hh" |
50 |
50 |
51 |
51 |
52 |
52 |
53 |
53 |
54 /**************************************/ |
|
55 /* The name of the file being parsed. */ |
|
56 /**************************************/ |
|
57 /* The name of the file currently being parsed... |
|
58 * Note that flex accesses and updates this global variable |
|
59 * apropriately whenever it comes across an (*#include <filename> *) |
|
60 * directive... |
|
61 * ... and bison will use it when producing error messages. |
|
62 * Note that bison also sets this variable correctly to the first |
|
63 * file being parsed. |
|
64 */ |
|
65 const char *current_filename = NULL; |
|
66 |
54 |
67 |
55 |
68 /******************************************************/ |
56 /******************************************************/ |
69 /* whether we are supporting safe extensions */ |
57 /* whether we are supporting safe extensions */ |
70 /* as defined in PLCopen - Technical Committee 5 */ |
58 /* as defined in PLCopen - Technical Committee 5 */ |
218 if (!res) |
206 if (!res) |
219 return NULL; |
207 return NULL; |
220 return strcat(strcat(strcpy(res, a), b), c); /* safe, actually */ |
208 return strcat(strcat(strcpy(res, a), b), c); /* safe, actually */ |
221 } |
209 } |
222 |
210 |
223 /*************************/ |
211 |
224 /* Tracking Functions... */ |
|
225 /*************************/ |
|
226 |
|
227 extern tracking_t* current_tracking; |
|
228 |
|
229 /*-------------------------------------------------------------------- |
|
230 * GetNextChar |
|
231 * |
|
232 * reads a character from input for flex |
|
233 *------------------------------------------------------------------*/ |
|
234 int GetNextChar(char *b, int maxBuffer) { |
|
235 char *p; |
|
236 |
|
237 if ( current_tracking->eof ) |
|
238 return 0; |
|
239 |
|
240 while ( current_tracking->currentChar >= current_tracking->lineLength ) { |
|
241 current_tracking->currentChar = 0; |
|
242 current_tracking->currentTokenStart = 1; |
|
243 current_tracking->eof = false; |
|
244 |
|
245 p = fgets(current_tracking->buffer, MAX_BUFFER_LENGTH, current_tracking->in_file); |
|
246 if ( p == NULL ) { |
|
247 if ( ferror(current_tracking->in_file) ) |
|
248 return 0; |
|
249 current_tracking->eof = true; |
|
250 return 0; |
|
251 } |
|
252 |
|
253 current_tracking->lineNumber++; |
|
254 current_tracking->lineLength = strlen(current_tracking->buffer); |
|
255 } |
|
256 |
|
257 b[0] = current_tracking->buffer[current_tracking->currentChar]; |
|
258 if (b[0] == ' ' || b[0] == '\t') |
|
259 current_tracking->currentTokenStart++; |
|
260 current_tracking->currentChar++; |
|
261 |
|
262 return b[0]==0?0:1; |
|
263 } |
|
264 |
|
265 tracking_t* GetNewTracking(FILE* in_file) { |
|
266 tracking_t* new_env = new tracking_t; |
|
267 new_env->eof = 0; |
|
268 new_env->lineNumber = 0; |
|
269 new_env->currentChar = 0; |
|
270 new_env->lineLength = 0; |
|
271 new_env->currentTokenStart = 0; |
|
272 new_env->buffer = (char*)malloc(MAX_BUFFER_LENGTH); |
|
273 new_env->in_file = in_file; |
|
274 return new_env; |
|
275 } |
|
276 |
212 |
277 /***********************************************************************/ |
213 /***********************************************************************/ |
278 /***********************************************************************/ |
214 /***********************************************************************/ |
279 /***********************************************************************/ |
215 /***********************************************************************/ |
280 /***********************************************************************/ |
216 /***********************************************************************/ |