2 /* A lexical scanner generated by flex */
4 /* Scanner skeleton version:
9 #define YY_FLEX_MAJOR_VERSION 2
10 #define YY_FLEX_MINOR_VERSION 5
18 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
35 /* Use prototypes in function declarations. */
38 /* The "const" storage-class-modifier is valid. */
41 #else /* ! __cplusplus */
49 #endif /* ! __cplusplus */
68 #define YY_PROTO(proto) proto
70 #define YY_PROTO(proto) ()
73 /* Returned upon end-of-file. */
76 /* Promotes a possibly negative, possibly signed char to an unsigned
77 * integer for use as an array index. If the signed char is negative,
78 * we want to instead treat it as an 8-bit unsigned char, hence the
81 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
83 /* Enter a start condition. This macro really ought to take a parameter,
84 * but we do it the disgusting crufty way forced on us by the ()-less
85 * definition of BEGIN.
87 #define BEGIN yy_start = 1 + 2 *
89 /* Translate the current start state into a value that can be later handed
90 * to BEGIN to return to the state. The YYSTATE alias is for lex
93 #define YY_START ((yy_start - 1) / 2)
94 #define YYSTATE YY_START
96 /* Action number for EOF rule of a given start state. */
97 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
99 /* Special action meaning "start processing a new file". */
100 #define YY_NEW_FILE yyrestart( yyin )
102 #define YY_END_OF_BUFFER_CHAR 0
104 /* Size of default input buffer. */
105 #define YY_BUF_SIZE 16384
107 typedef struct yy_buffer_state *YY_BUFFER_STATE;
110 extern FILE *yyin, *yyout;
112 #define EOB_ACT_CONTINUE_SCAN 0
113 #define EOB_ACT_END_OF_FILE 1
114 #define EOB_ACT_LAST_MATCH 2
116 /* The funky do-while in the following #define is used to turn the definition
117 * int a single C statement (which needs a semi-colon terminator). This
118 * avoids problems with code like:
120 * if ( condition_holds )
123 * do_something_else();
125 * Prior to using the do-while the compiler would get upset at the
126 * "else" because it interpreted the "if" statement as being all
127 * done when it reached the ';' after the yyless() call.
130 /* Return all but the first 'n' matched characters back to the input stream. */
135 /* Undo effects of setting up yytext. */ \
136 *yy_cp = yy_hold_char; \
137 YY_RESTORE_YY_MORE_OFFSET \
138 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
139 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
143 #define unput(c) yyunput( c, yytext_ptr )
145 /* The following is because we cannot portably get our hands on size_t
146 * (without autoconf's help, which isn't available because we want
147 * flex-generated scanners to compile on their own).
149 typedef unsigned int yy_size_t;
152 struct yy_buffer_state
156 char *yy_ch_buf; /* input buffer */
157 char *yy_buf_pos; /* current position in input buffer */
159 /* Size of input buffer in bytes, not including room for EOB
162 yy_size_t yy_buf_size;
164 /* Number of characters read into yy_ch_buf, not including EOB
169 /* Whether we "own" the buffer - i.e., we know we created it,
170 * and can realloc() it to grow it, and should free() it to
173 int yy_is_our_buffer;
175 /* Whether this is an "interactive" input source; if so, and
176 * if we're using stdio for input, then we want to use getc()
177 * instead of fread(), to make sure we stop fetching input after
180 int yy_is_interactive;
182 /* Whether we're considered to be at the beginning of a line.
183 * If so, '^' rules will be active on the next match, otherwise
188 /* Whether to try to fill the input buffer when we reach the
193 int yy_buffer_status;
194 #define YY_BUFFER_NEW 0
195 #define YY_BUFFER_NORMAL 1
196 /* When an EOF's been seen but there's still some text to process
197 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
198 * shouldn't try reading from the input source any more. We might
199 * still have a bunch of tokens to match, though, because of
200 * possible backing-up.
202 * When we actually see the EOF, we change the status to "new"
203 * (via yyrestart()), so that the user can continue scanning by
204 * just pointing yyin at a new input file.
206 #define YY_BUFFER_EOF_PENDING 2
209 static YY_BUFFER_STATE yy_current_buffer = 0;
211 /* We provide macros for accessing buffer states in case in the
212 * future we want to put the buffer states in a more general
215 #define YY_CURRENT_BUFFER yy_current_buffer
218 /* yy_hold_char holds the character lost when yytext is formed. */
219 static char yy_hold_char;
221 static int yy_n_chars; /* number of characters read into yy_ch_buf */
226 /* Points to current character in buffer. */
227 static char *yy_c_buf_p = (char *) 0;
228 static int yy_init = 1; /* whether we need to initialize */
229 static int yy_start = 0; /* start state number */
231 /* Flag which is used to allow yywrap()'s to do buffer switches
232 * instead of setting up a fresh yyin. A bit of a hack ...
234 static int yy_did_buffer_switch_on_eof;
236 void yyrestart YY_PROTO(( FILE *input_file ));
238 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
239 void yy_load_buffer_state YY_PROTO(( void ));
240 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
241 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
242 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
243 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
244 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
246 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
247 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
248 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
250 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
251 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
252 static void yy_flex_free YY_PROTO(( void * ));
254 #define yy_new_buffer yy_create_buffer
256 #define yy_set_interactive(is_interactive) \
258 if ( ! yy_current_buffer ) \
259 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
260 yy_current_buffer->yy_is_interactive = is_interactive; \
263 #define yy_set_bol(at_bol) \
265 if ( ! yy_current_buffer ) \
266 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
267 yy_current_buffer->yy_at_bol = at_bol; \
270 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
272 typedef unsigned char YY_CHAR;
273 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
274 typedef int yy_state_type;
276 #define yytext_ptr yytext
278 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
279 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
280 static int yy_get_next_buffer YY_PROTO(( void ));
281 static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
283 /* Done after the current pattern has been matched and before the
284 * corresponding action - sets up yytext.
286 #define YY_DO_BEFORE_ACTION \
287 yytext_ptr = yy_bp; \
288 yyleng = (int) (yy_cp - yy_bp); \
289 yy_hold_char = *yy_cp; \
293 #define YY_NUM_RULES 16
294 #define YY_END_OF_BUFFER 17
295 static yyconst short int yy_accept[106] =
297 0, 0, 17, 15, 13, 14, 15, 15, 15, 9,
298 8, 4, 4, 13, 0, 11, 0, 0, 0, 6,
299 5, 9, 0, 0, 9, 9, 0, 8, 8, 8,
300 4, 4, 0, 0, 12, 0, 0, 0, 6, 5,
301 0, 5, 0, 7, 9, 9, 10, 8, 8, 4,
302 0, 0, 0, 0, 0, 6, 0, 5, 7, 10,
303 10, 4, 4, 0, 0, 0, 0, 10, 10, 4,
304 4, 0, 0, 4, 4, 0, 0, 4, 4, 0,
305 0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
306 4, 4, 3, 4, 4, 4, 4, 4, 4, 4,
311 static yyconst int yy_ec[256] =
313 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
314 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
315 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
316 1, 2, 1, 4, 1, 1, 1, 1, 5, 1,
317 1, 1, 6, 1, 6, 7, 1, 8, 9, 10,
318 10, 10, 10, 10, 10, 11, 11, 1, 1, 1,
319 1, 1, 12, 1, 13, 13, 14, 15, 16, 17,
320 18, 18, 19, 18, 18, 20, 18, 18, 18, 21,
321 18, 18, 22, 18, 23, 18, 18, 24, 18, 18,
322 1, 25, 1, 1, 18, 1, 26, 27, 28, 13,
324 29, 30, 18, 18, 31, 18, 32, 33, 34, 35,
325 36, 37, 18, 38, 18, 39, 23, 40, 18, 24,
326 18, 18, 1, 1, 1, 1, 1, 1, 1, 1,
327 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
328 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
329 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
330 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
331 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
332 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
333 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
335 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
336 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
337 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
338 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
339 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
343 static yyconst int yy_meta[41] =
345 1, 1, 2, 3, 4, 1, 1, 5, 5, 5,
346 6, 4, 6, 6, 6, 6, 6, 7, 7, 7,
347 7, 7, 7, 8, 4, 5, 5, 6, 6, 5,
348 7, 7, 7, 7, 8, 7, 7, 8, 8, 8
351 static yyconst short int yy_base[115] =
353 0, 25, 226, 415, 223, 415, 13, 198, 10, 44,
354 71, 0, 185, 217, 18, 415, 32, 19, 37, 97,
355 123, 189, 150, 87, 189, 29, 0, 0, 187, 37,
356 0, 173, 111, 0, 415, 137, 0, 159, 415, 0,
357 165, 415, 75, 172, 415, 415, 43, 415, 415, 50,
358 186, 85, 189, 98, 140, 207, 176, 233, 415, 183,
359 38, 175, 168, 86, 263, 99, 290, 415, 415, 173,
360 151, 184, 196, 145, 141, 313, 336, 146, 132, 112,
361 138, 117, 128, 115, 111, 53, 102, 93, 97, 96,
362 87, 78, 0, 66, 62, 53, 55, 43, 30, 10,
364 6, 4, 0, 0, 415, 366, 374, 382, 386, 393,
368 static yyconst short int yy_def[115] =
370 106, 106, 105, 105, 105, 105, 107, 108, 105, 105,
371 105, 109, 109, 105, 107, 105, 110, 108, 111, 105,
372 105, 10, 105, 105, 105, 105, 112, 11, 105, 105,
373 109, 109, 107, 113, 105, 108, 114, 105, 105, 21,
374 105, 105, 105, 105, 105, 105, 112, 105, 105, 109,
375 107, 107, 108, 108, 105, 105, 105, 105, 105, 105,
376 105, 109, 109, 107, 107, 108, 108, 105, 105, 109,
377 109, 107, 108, 109, 109, 65, 67, 109, 109, 107,
378 108, 109, 109, 109, 109, 109, 109, 109, 109, 109,
379 109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
381 109, 109, 109, 109, 0, 105, 105, 105, 105, 105,
385 static yyconst short int yy_nxt[456] =
387 4, 5, 6, 7, 8, 4, 9, 10, 11, 11,
388 11, 4, 104, 13, 103, 105, 16, 20, 20, 20,
389 20, 16, 35, 105, 4, 4, 5, 6, 7, 8,
390 4, 9, 10, 11, 11, 11, 4, 17, 13, 33,
391 33, 33, 17, 19, 36, 36, 36, 102, 46, 4,
392 21, 22, 22, 22, 23, 34, 49, 69, 101, 24,
393 37, 46, 60, 25, 62, 61, 26, 27, 63, 49,
394 69, 100, 24, 88, 89, 60, 25, 21, 28, 28,
395 28, 28, 44, 44, 44, 44, 24, 99, 16, 16,
396 29, 98, 43, 30, 44, 44, 44, 44, 97, 24,
398 96, 35, 35, 29, 20, 20, 20, 20, 65, 17,
399 17, 95, 38, 39, 16, 16, 39, 94, 51, 51,
400 51, 67, 19, 19, 93, 38, 39, 92, 91, 39,
401 40, 40, 40, 40, 90, 17, 17, 87, 41, 42,
402 35, 35, 42, 86, 53, 53, 53, 56, 56, 56,
403 56, 41, 42, 85, 84, 42, 21, 23, 23, 23,
404 23, 19, 19, 83, 55, 24, 56, 56, 56, 56,
405 57, 82, 58, 58, 58, 58, 79, 78, 24, 44,
406 44, 44, 44, 58, 58, 58, 58, 16, 59, 16,
407 75, 59, 35, 64, 64, 64, 66, 66, 66, 35,
409 74, 59, 71, 70, 59, 68, 50, 76, 17, 48,
410 17, 45, 105, 19, 56, 56, 56, 56, 14, 77,
411 19, 32, 19, 39, 14, 105, 39, 105, 105, 105,
412 105, 105, 105, 105, 105, 105, 39, 105, 105, 39,
413 58, 58, 58, 58, 105, 105, 105, 105, 105, 42,
414 105, 105, 42, 105, 105, 105, 105, 105, 105, 105,
415 105, 105, 42, 105, 105, 42, 16, 105, 105, 105,
416 72, 72, 72, 72, 105, 72, 72, 72, 72, 72,
417 105, 105, 105, 105, 105, 105, 105, 17, 72, 72,
418 72, 72, 72, 35, 105, 105, 105, 73, 73, 73,
420 73, 105, 73, 73, 73, 73, 73, 105, 105, 105,
421 105, 105, 105, 105, 19, 73, 73, 73, 73, 73,
422 80, 80, 80, 80, 105, 80, 80, 80, 80, 80,
423 105, 105, 105, 105, 105, 105, 105, 105, 80, 80,
424 80, 80, 80, 81, 81, 81, 81, 105, 81, 81,
425 81, 81, 81, 105, 105, 105, 105, 105, 105, 105,
426 105, 81, 81, 81, 81, 81, 12, 12, 12, 12,
427 12, 12, 12, 12, 15, 105, 15, 15, 15, 15,
428 15, 15, 18, 105, 105, 18, 18, 18, 18, 18,
429 31, 31, 31, 31, 15, 15, 15, 15, 105, 105,
431 15, 18, 18, 18, 18, 105, 105, 18, 47, 47,
432 52, 52, 54, 54, 3, 105, 105, 105, 105, 105,
433 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
434 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
435 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
436 105, 105, 105, 105, 105
439 static yyconst short int yy_chk[456] =
441 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
442 1, 1, 102, 1, 101, 0, 7, 9, 9, 9,
443 9, 15, 18, 0, 1, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 7, 2, 17,
445 17, 17, 15, 18, 19, 19, 19, 100, 26, 2,
446 10, 10, 10, 10, 10, 17, 30, 61, 99, 10,
447 19, 26, 47, 10, 50, 47, 10, 10, 50, 30,
448 61, 98, 10, 86, 86, 47, 10, 11, 11, 11,
449 11, 11, 43, 43, 43, 43, 11, 97, 52, 64,
450 11, 96, 24, 11, 24, 24, 24, 24, 95, 11,
452 94, 54, 66, 11, 20, 20, 20, 20, 52, 52,
453 64, 92, 20, 20, 33, 80, 20, 91, 33, 33,
454 33, 54, 54, 66, 90, 20, 20, 89, 88, 20,
455 21, 21, 21, 21, 87, 33, 80, 85, 21, 21,
456 36, 81, 21, 84, 36, 36, 36, 55, 55, 55,
457 55, 21, 21, 83, 82, 21, 23, 23, 23, 23,
458 23, 36, 81, 79, 38, 23, 38, 38, 38, 38,
459 41, 78, 41, 41, 41, 41, 75, 74, 23, 44,
460 44, 44, 44, 57, 57, 57, 57, 72, 44, 51,
461 71, 44, 53, 51, 51, 51, 53, 53, 53, 73,
463 70, 44, 63, 62, 44, 60, 32, 72, 72, 29,
464 51, 25, 22, 53, 56, 56, 56, 56, 14, 73,
465 73, 13, 8, 56, 5, 3, 56, 0, 0, 0,
466 0, 0, 0, 0, 0, 0, 56, 0, 0, 56,
467 58, 58, 58, 58, 0, 0, 0, 0, 0, 58,
468 0, 0, 58, 0, 0, 0, 0, 0, 0, 0,
469 0, 0, 58, 0, 0, 58, 65, 0, 0, 0,
470 65, 65, 65, 65, 0, 65, 65, 65, 65, 65,
471 0, 0, 0, 0, 0, 0, 0, 65, 65, 65,
472 65, 65, 65, 67, 0, 0, 0, 67, 67, 67,
474 67, 0, 67, 67, 67, 67, 67, 0, 0, 0,
475 0, 0, 0, 0, 67, 67, 67, 67, 67, 67,
476 76, 76, 76, 76, 0, 76, 76, 76, 76, 76,
477 0, 0, 0, 0, 0, 0, 0, 0, 76, 76,
478 76, 76, 76, 77, 77, 77, 77, 0, 77, 77,
479 77, 77, 77, 0, 0, 0, 0, 0, 0, 0,
480 0, 77, 77, 77, 77, 77, 106, 106, 106, 106,
481 106, 106, 106, 106, 107, 0, 107, 107, 107, 107,
482 107, 107, 108, 0, 0, 108, 108, 108, 108, 108,
483 109, 109, 109, 109, 110, 110, 110, 110, 0, 0,
485 110, 111, 111, 111, 111, 0, 0, 111, 112, 112,
486 113, 113, 114, 114, 105, 105, 105, 105, 105, 105,
487 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
488 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
489 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
490 105, 105, 105, 105, 105
493 static yy_state_type yy_last_accepting_state;
494 static char *yy_last_accepting_cpos;
496 /* The intent behind this definition is that it'll catch
497 * any uses of REJECT which flex missed.
499 #define REJECT reject_used_but_not_detected
500 #define yymore() yymore_used_but_not_detected
501 #define YY_MORE_ADJ 0
502 #define YY_RESTORE_YY_MORE_OFFSET
504 #line 1 "conv-cpm.flex"
506 #line 2 "conv-cpm.flex"
512 /******************************************************************************
516 *****************************************************************************/
521 /******************************************************************************
525 *****************************************************************************/
526 #line 520 "conv-cpm.C"
528 /* Macros after this point can all be overridden by user definitions in
532 #ifndef YY_SKIP_YYWRAP
534 extern "C" int yywrap YY_PROTO(( void ));
536 extern int yywrap YY_PROTO(( void ));
541 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
545 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
548 #ifdef YY_NEED_STRLEN
549 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
554 static int yyinput YY_PROTO(( void ));
556 static int input YY_PROTO(( void ));
561 static int yy_start_stack_ptr = 0;
562 static int yy_start_stack_depth = 0;
563 static int *yy_start_stack = 0;
564 #ifndef YY_NO_PUSH_STATE
565 static void yy_push_state YY_PROTO(( int new_state ));
567 #ifndef YY_NO_POP_STATE
568 static void yy_pop_state YY_PROTO(( void ));
570 #ifndef YY_NO_TOP_STATE
571 static int yy_top_state YY_PROTO(( void ));
575 #define YY_NO_PUSH_STATE 1
576 #define YY_NO_POP_STATE 1
577 #define YY_NO_TOP_STATE 1
580 #ifdef YY_MALLOC_DECL
588 /* Just try to get by without declaring the routines. This will fail
589 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
590 * or sizeof(void*) != sizeof(int).
595 /* Amount of stuff to slurp up with each read. */
596 #ifndef YY_READ_BUF_SIZE
597 #define YY_READ_BUF_SIZE 8192
600 /* Copy whatever the last rule matched to the standard output. */
603 /* This used to be an fputs(), but since the string might contain NUL's,
604 * we now use fwrite().
606 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
609 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
610 * is returned in "result".
613 #define YY_INPUT(buf,result,max_size) \
614 if ( yy_current_buffer->yy_is_interactive ) \
617 for ( n = 0; n < max_size && \
618 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
621 buf[n++] = (char) c; \
622 if ( c == EOF && ferror( yyin ) ) \
623 YY_FATAL_ERROR( "input in flex scanner failed" ); \
626 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
627 && ferror( yyin ) ) \
628 YY_FATAL_ERROR( "input in flex scanner failed" );
631 /* No semi-colon after return; correct usage is to write "yyterminate();" -
632 * we don't want an extra ';' after the "return" because that will cause
633 * some compilers to complain about unreachable statements.
636 #define yyterminate() return YY_NULL
639 /* Number of entries by which start-condition stack grows. */
640 #ifndef YY_START_STACK_INCR
641 #define YY_START_STACK_INCR 25
644 /* Report a fatal error. */
645 #ifndef YY_FATAL_ERROR
646 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
649 /* Default declaration of generated scanner - a define so the user can
650 * easily add parameters.
653 #define YY_DECL int yylex YY_PROTO(( void ))
656 /* Code executed at the beginning of each rule, after yytext and yyleng
659 #ifndef YY_USER_ACTION
660 #define YY_USER_ACTION
663 /* Code executed at the end of each rule. */
665 #define YY_BREAK break;
668 #define YY_RULE_SETUP \
673 yy_state_type yy_current_state;
677 #line 32 "conv-cpm.flex"
680 #line 674 "conv-cpm.C"
691 yy_start = 1; /* first start state */
699 if ( ! yy_current_buffer )
701 yy_create_buffer( yyin, YY_BUF_SIZE );
703 yy_load_buffer_state();
706 while ( 1 ) /* loops until end-of-file is reached */
710 /* Support of yytext. */
711 *yy_cp = yy_hold_char;
713 /* yy_bp points to the position in yy_ch_buf of the start of
718 yy_current_state = yy_start;
722 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
723 if ( yy_accept[yy_current_state] )
725 yy_last_accepting_state = yy_current_state;
726 yy_last_accepting_cpos = yy_cp;
728 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
730 yy_current_state = (int) yy_def[yy_current_state];
731 if ( yy_current_state >= 106 )
732 yy_c = yy_meta[(unsigned int) yy_c];
734 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
737 while ( yy_base[yy_current_state] != 415 );
740 yy_act = yy_accept[yy_current_state];
742 { /* have to back up */
743 yy_cp = yy_last_accepting_cpos;
744 yy_current_state = yy_last_accepting_state;
745 yy_act = yy_accept[yy_current_state];
751 do_action: /* This label is used only to access EOF actions. */
755 { /* beginning of action switch */
756 case 0: /* must back up */
757 /* undo the effects of YY_DO_BEFORE_ACTION */
758 *yy_cp = yy_hold_char;
759 yy_cp = yy_last_accepting_cpos;
760 yy_current_state = yy_last_accepting_state;
765 #line 34 "conv-cpm.flex"
770 #line 35 "conv-cpm.flex"
775 #line 36 "conv-cpm.flex"
780 #line 37 "conv-cpm.flex"
785 #line 38 "conv-cpm.flex"
790 #line 39 "conv-cpm.flex"
795 #line 40 "conv-cpm.flex"
800 #line 41 "conv-cpm.flex"
805 #line 42 "conv-cpm.flex"
810 #line 43 "conv-cpm.flex"
815 #line 44 "conv-cpm.flex"
820 #line 45 "conv-cpm.flex"
825 #line 46 "conv-cpm.flex"
830 #line 47 "conv-cpm.flex"
835 #line 48 "conv-cpm.flex"
836 { return yytext[0]; }
840 #line 50 "conv-cpm.flex"
843 #line 837 "conv-cpm.C"
844 case YY_STATE_EOF(INITIAL):
847 case YY_END_OF_BUFFER:
849 /* Amount of text matched not including the EOB char. */
850 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
852 /* Undo the effects of YY_DO_BEFORE_ACTION. */
853 *yy_cp = yy_hold_char;
854 YY_RESTORE_YY_MORE_OFFSET
856 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
858 /* We're scanning a new file or input source. It's
859 * possible that this happened because the user
860 * just pointed yyin at a new source and called
861 * yylex(). If so, then we have to assure
862 * consistency between yy_current_buffer and our
863 * globals. Here is the right place to do so, because
864 * this is the first action (other than possibly a
865 * back-up) that will match for the new input source.
867 yy_n_chars = yy_current_buffer->yy_n_chars;
868 yy_current_buffer->yy_input_file = yyin;
869 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
872 /* Note that here we test for yy_c_buf_p "<=" to the position
873 * of the first EOB in the buffer, since yy_c_buf_p will
874 * already have been incremented past the NUL character
875 * (since all states make transitions on EOB to the
876 * end-of-buffer state). Contrast this with the test
879 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
880 { /* This was really a NUL. */
881 yy_state_type yy_next_state;
883 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
885 yy_current_state = yy_get_previous_state();
887 /* Okay, we're now positioned to make the NUL
888 * transition. We couldn't have
889 * yy_get_previous_state() go ahead and do it
890 * for us because it doesn't know how to deal
891 * with the possibility of jamming (and we don't
892 * want to build jamming into it because then it
893 * will run more slowly).
896 yy_next_state = yy_try_NUL_trans( yy_current_state );
898 yy_bp = yytext_ptr + YY_MORE_ADJ;
902 /* Consume the NUL. */
903 yy_cp = ++yy_c_buf_p;
904 yy_current_state = yy_next_state;
915 else switch ( yy_get_next_buffer() )
917 case EOB_ACT_END_OF_FILE:
919 yy_did_buffer_switch_on_eof = 0;
923 /* Note: because we've taken care in
924 * yy_get_next_buffer() to have set up
925 * yytext, we can now set up
926 * yy_c_buf_p so that if some total
927 * hoser (like flex itself) wants to
928 * call the scanner after we return the
929 * YY_NULL, it'll still work - another
930 * YY_NULL will get returned.
932 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
934 yy_act = YY_STATE_EOF(YY_START);
940 if ( ! yy_did_buffer_switch_on_eof )
946 case EOB_ACT_CONTINUE_SCAN:
948 yytext_ptr + yy_amount_of_matched_text;
950 yy_current_state = yy_get_previous_state();
953 yy_bp = yytext_ptr + YY_MORE_ADJ;
956 case EOB_ACT_LAST_MATCH:
958 &yy_current_buffer->yy_ch_buf[yy_n_chars];
960 yy_current_state = yy_get_previous_state();
963 yy_bp = yytext_ptr + YY_MORE_ADJ;
971 "fatal flex scanner internal error--no action found" );
972 } /* end of action switch */
973 } /* end of scanning one token */
977 /* yy_get_next_buffer - try to read in a new buffer
979 * Returns a code representing an action:
980 * EOB_ACT_LAST_MATCH -
981 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
982 * EOB_ACT_END_OF_FILE - end of file
985 static int yy_get_next_buffer()
987 char *dest = yy_current_buffer->yy_ch_buf;
988 char *source = yytext_ptr;
989 int number_to_move, i;
992 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
994 "fatal flex scanner internal error--end of buffer missed" );
996 if ( yy_current_buffer->yy_fill_buffer == 0 )
997 { /* Don't try to fill the buffer, so this is an EOF. */
998 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
1000 /* We matched a single character, the EOB, so
1001 * treat this as a final EOF.
1003 return EOB_ACT_END_OF_FILE;
1008 /* We matched some text prior to the EOB, first
1011 return EOB_ACT_LAST_MATCH;
1015 /* Try to read more data. */
1017 /* First move last chars to start of buffer. */
1018 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
1020 for ( i = 0; i < number_to_move; ++i )
1021 *(dest++) = *(source++);
1023 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1024 /* don't do the read, it's not guaranteed to return an EOF,
1027 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1032 yy_current_buffer->yy_buf_size - number_to_move - 1;
1034 while ( num_to_read <= 0 )
1035 { /* Not enough room in the buffer - grow it. */
1036 #ifdef YY_USES_REJECT
1038 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1041 /* just a shorter name for the current buffer */
1042 YY_BUFFER_STATE b = yy_current_buffer;
1044 int yy_c_buf_p_offset =
1045 (int) (yy_c_buf_p - b->yy_ch_buf);
1047 if ( b->yy_is_our_buffer )
1049 int new_size = b->yy_buf_size * 2;
1051 if ( new_size <= 0 )
1052 b->yy_buf_size += b->yy_buf_size / 8;
1054 b->yy_buf_size *= 2;
1056 b->yy_ch_buf = (char *)
1057 /* Include room in for 2 EOB chars. */
1058 yy_flex_realloc( (void *) b->yy_ch_buf,
1059 b->yy_buf_size + 2 );
1062 /* Can't grow it, we don't own it. */
1065 if ( ! b->yy_ch_buf )
1067 "fatal error - scanner input buffer overflow" );
1069 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1071 num_to_read = yy_current_buffer->yy_buf_size -
1076 if ( num_to_read > YY_READ_BUF_SIZE )
1077 num_to_read = YY_READ_BUF_SIZE;
1079 /* Read in more data. */
1080 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1081 yy_n_chars, num_to_read );
1083 yy_current_buffer->yy_n_chars = yy_n_chars;
1086 if ( yy_n_chars == 0 )
1088 if ( number_to_move == YY_MORE_ADJ )
1090 ret_val = EOB_ACT_END_OF_FILE;
1096 ret_val = EOB_ACT_LAST_MATCH;
1097 yy_current_buffer->yy_buffer_status =
1098 YY_BUFFER_EOF_PENDING;
1103 ret_val = EOB_ACT_CONTINUE_SCAN;
1105 yy_n_chars += number_to_move;
1106 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1107 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1109 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1115 /* yy_get_previous_state - get the state just before the EOB char was reached */
1117 static yy_state_type yy_get_previous_state()
1119 yy_state_type yy_current_state;
1122 yy_current_state = yy_start;
1124 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1126 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1127 if ( yy_accept[yy_current_state] )
1129 yy_last_accepting_state = yy_current_state;
1130 yy_last_accepting_cpos = yy_cp;
1132 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1134 yy_current_state = (int) yy_def[yy_current_state];
1135 if ( yy_current_state >= 106 )
1136 yy_c = yy_meta[(unsigned int) yy_c];
1138 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1141 return yy_current_state;
1145 /* yy_try_NUL_trans - try to make a transition on the NUL character
1148 * next_state = yy_try_NUL_trans( current_state );
1151 #ifdef YY_USE_PROTOS
1152 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1154 static yy_state_type yy_try_NUL_trans( yy_current_state )
1155 yy_state_type yy_current_state;
1159 char *yy_cp = yy_c_buf_p;
1162 if ( yy_accept[yy_current_state] )
1164 yy_last_accepting_state = yy_current_state;
1165 yy_last_accepting_cpos = yy_cp;
1167 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1169 yy_current_state = (int) yy_def[yy_current_state];
1170 if ( yy_current_state >= 106 )
1171 yy_c = yy_meta[(unsigned int) yy_c];
1173 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1174 yy_is_jam = (yy_current_state == 105);
1176 return yy_is_jam ? 0 : yy_current_state;
1181 #ifdef YY_USE_PROTOS
1182 static void yyunput( int c, char *yy_bp )
1184 static void yyunput( c, yy_bp )
1189 char *yy_cp = yy_c_buf_p;
1191 /* undo effects of setting up yytext */
1192 *yy_cp = yy_hold_char;
1194 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1195 { /* need to shift things up to make room */
1196 /* +2 for EOB chars. */
1197 int number_to_move = yy_n_chars + 2;
1198 char *dest = &yy_current_buffer->yy_ch_buf[
1199 yy_current_buffer->yy_buf_size + 2];
1201 &yy_current_buffer->yy_ch_buf[number_to_move];
1203 while ( source > yy_current_buffer->yy_ch_buf )
1204 *--dest = *--source;
1206 yy_cp += (int) (dest - source);
1207 yy_bp += (int) (dest - source);
1208 yy_current_buffer->yy_n_chars =
1209 yy_n_chars = yy_current_buffer->yy_buf_size;
1211 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1212 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1215 *--yy_cp = (char) c;
1219 yy_hold_char = *yy_cp;
1222 #endif /* ifndef YY_NO_UNPUT */
1226 static int yyinput()
1232 static int _xpg = -1;
1236 char *_xpgenv = getenv("_XPG");
1237 if (_xpgenv == NULL)
1241 _xpg = atoi(_xpgenv);
1247 *yy_c_buf_p = yy_hold_char;
1249 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1251 /* yy_c_buf_p now points to the character we want to return.
1252 * If this occurs *before* the EOB characters, then it's a
1253 * valid NUL; if not, then we've hit the end of the buffer.
1255 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1256 /* This was really a NUL. */
1260 { /* need more input */
1261 int offset = yy_c_buf_p - yytext_ptr;
1264 switch ( yy_get_next_buffer() )
1266 case EOB_ACT_LAST_MATCH:
1267 /* This happens because yy_g_n_b()
1268 * sees that we've accumulated a
1269 * token and flags that we need to
1270 * try matching the token before
1271 * proceeding. But for input(),
1272 * there's no matching to consider.
1273 * So convert the EOB_ACT_LAST_MATCH
1274 * to EOB_ACT_END_OF_FILE.
1277 /* Reset buffer status. */
1282 case EOB_ACT_END_OF_FILE:
1290 if ( ! yy_did_buffer_switch_on_eof )
1299 case EOB_ACT_CONTINUE_SCAN:
1300 yy_c_buf_p = yytext_ptr + offset;
1306 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1307 *yy_c_buf_p = '\0'; /* preserve yytext */
1308 yy_hold_char = *++yy_c_buf_p;
1315 #ifdef YY_USE_PROTOS
1316 void yyrestart( FILE *input_file )
1318 void yyrestart( input_file )
1322 if ( ! yy_current_buffer )
1323 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1325 yy_init_buffer( yy_current_buffer, input_file );
1326 yy_load_buffer_state();
1330 #ifdef YY_USE_PROTOS
1331 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1333 void yy_switch_to_buffer( new_buffer )
1334 YY_BUFFER_STATE new_buffer;
1337 if ( yy_current_buffer == new_buffer )
1340 if ( yy_current_buffer )
1342 /* Flush out information for old buffer. */
1343 *yy_c_buf_p = yy_hold_char;
1344 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1345 yy_current_buffer->yy_n_chars = yy_n_chars;
1348 yy_current_buffer = new_buffer;
1349 yy_load_buffer_state();
1351 /* We don't actually know whether we did this switch during
1352 * EOF (yywrap()) processing, but the only time this flag
1353 * is looked at is after yywrap() is called, so it's safe
1354 * to go ahead and always set it.
1356 yy_did_buffer_switch_on_eof = 1;
1360 #ifdef YY_USE_PROTOS
1361 void yy_load_buffer_state( void )
1363 void yy_load_buffer_state()
1366 yy_n_chars = yy_current_buffer->yy_n_chars;
1367 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1368 yyin = yy_current_buffer->yy_input_file;
1369 yy_hold_char = *yy_c_buf_p;
1373 #ifdef YY_USE_PROTOS
1374 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1376 YY_BUFFER_STATE yy_create_buffer( file, size )
1383 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1385 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1387 b->yy_buf_size = size;
1389 /* yy_ch_buf has to be 2 characters longer than the size given because
1390 * we need to put in 2 end-of-buffer characters.
1392 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1393 if ( ! b->yy_ch_buf )
1394 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1396 b->yy_is_our_buffer = 1;
1398 yy_init_buffer( b, file );
1404 #ifdef YY_USE_PROTOS
1405 void yy_delete_buffer( YY_BUFFER_STATE b )
1407 void yy_delete_buffer( b )
1414 if ( b == yy_current_buffer )
1415 yy_current_buffer = (YY_BUFFER_STATE) 0;
1417 if ( b->yy_is_our_buffer )
1418 yy_flex_free( (void *) b->yy_ch_buf );
1420 yy_flex_free( (void *) b );
1424 #ifndef YY_ALWAYS_INTERACTIVE
1425 #ifndef YY_NEVER_INTERACTIVE
1426 extern int isatty YY_PROTO(( int ));
1430 #ifdef YY_USE_PROTOS
1431 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1433 void yy_init_buffer( b, file )
1440 yy_flush_buffer( b );
1442 b->yy_input_file = file;
1443 b->yy_fill_buffer = 1;
1445 #if YY_ALWAYS_INTERACTIVE
1446 b->yy_is_interactive = 1;
1448 #if YY_NEVER_INTERACTIVE
1449 b->yy_is_interactive = 0;
1451 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1457 #ifdef YY_USE_PROTOS
1458 void yy_flush_buffer( YY_BUFFER_STATE b )
1460 void yy_flush_buffer( b )
1470 /* We always need two end-of-buffer characters. The first causes
1471 * a transition to the end-of-buffer state. The second causes
1472 * a jam in that state.
1474 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1475 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1477 b->yy_buf_pos = &b->yy_ch_buf[0];
1480 b->yy_buffer_status = YY_BUFFER_NEW;
1482 if ( b == yy_current_buffer )
1483 yy_load_buffer_state();
1487 #ifndef YY_NO_SCAN_BUFFER
1488 #ifdef YY_USE_PROTOS
1489 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1491 YY_BUFFER_STATE yy_scan_buffer( base, size )
1499 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1500 base[size-1] != YY_END_OF_BUFFER_CHAR )
1501 /* They forgot to leave room for the EOB's. */
1504 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1506 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1508 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1509 b->yy_buf_pos = b->yy_ch_buf = base;
1510 b->yy_is_our_buffer = 0;
1511 b->yy_input_file = 0;
1512 b->yy_n_chars = b->yy_buf_size;
1513 b->yy_is_interactive = 0;
1515 b->yy_fill_buffer = 0;
1516 b->yy_buffer_status = YY_BUFFER_NEW;
1518 yy_switch_to_buffer( b );
1525 #ifndef YY_NO_SCAN_STRING
1526 #ifdef YY_USE_PROTOS
1527 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1529 YY_BUFFER_STATE yy_scan_string( yy_str )
1530 yyconst char *yy_str;
1534 for ( len = 0; yy_str[len]; ++len )
1537 return yy_scan_bytes( yy_str, len );
1542 #ifndef YY_NO_SCAN_BYTES
1543 #ifdef YY_USE_PROTOS
1544 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1546 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1547 yyconst char *bytes;
1556 /* Get memory for full buffer, including space for trailing EOB's. */
1558 buf = (char *) yy_flex_alloc( n );
1560 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1562 for ( i = 0; i < len; ++i )
1565 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1567 b = yy_scan_buffer( buf, n );
1569 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1571 /* It's okay to grow etc. this buffer, and we should throw it
1572 * away when we're done.
1574 b->yy_is_our_buffer = 1;
1581 #ifndef YY_NO_PUSH_STATE
1582 #ifdef YY_USE_PROTOS
1583 static void yy_push_state( int new_state )
1585 static void yy_push_state( new_state )
1589 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1593 yy_start_stack_depth += YY_START_STACK_INCR;
1594 new_size = yy_start_stack_depth * sizeof( int );
1596 if ( ! yy_start_stack )
1597 yy_start_stack = (int *) yy_flex_alloc( new_size );
1600 yy_start_stack = (int *) yy_flex_realloc(
1601 (void *) yy_start_stack, new_size );
1603 if ( ! yy_start_stack )
1605 "out of memory expanding start-condition stack" );
1608 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1615 #ifndef YY_NO_POP_STATE
1616 static void yy_pop_state()
1618 if ( --yy_start_stack_ptr < 0 )
1619 YY_FATAL_ERROR( "start-condition stack underflow" );
1621 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1626 #ifndef YY_NO_TOP_STATE
1627 static int yy_top_state()
1629 return yy_start_stack[yy_start_stack_ptr - 1];
1633 #ifndef YY_EXIT_FAILURE
1634 #define YY_EXIT_FAILURE 2
1637 #ifdef YY_USE_PROTOS
1638 static void yy_fatal_error( yyconst char msg[] )
1640 static void yy_fatal_error( msg )
1644 (void) fprintf( stderr, "%s\n", msg );
1645 exit( YY_EXIT_FAILURE );
1650 /* Redefine yyless() so it works in section 3 code. */
1656 /* Undo effects of setting up yytext. */ \
1657 yytext[yyleng] = yy_hold_char; \
1658 yy_c_buf_p = yytext + n; \
1659 yy_hold_char = *yy_c_buf_p; \
1660 *yy_c_buf_p = '\0'; \
1666 /* Internal utility routines. */
1669 #ifdef YY_USE_PROTOS
1670 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1672 static void yy_flex_strncpy( s1, s2, n )
1679 for ( i = 0; i < n; ++i )
1684 #ifdef YY_NEED_STRLEN
1685 #ifdef YY_USE_PROTOS
1686 static int yy_flex_strlen( yyconst char *s )
1688 static int yy_flex_strlen( s )
1693 for ( n = 0; s[n]; ++n )
1701 #ifdef YY_USE_PROTOS
1702 static void *yy_flex_alloc( yy_size_t size )
1704 static void *yy_flex_alloc( size )
1708 return (void *) malloc( size );
1711 #ifdef YY_USE_PROTOS
1712 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1714 static void *yy_flex_realloc( ptr, size )
1719 /* The cast to (char *) in the following accommodates both
1720 * implementations that use char* generic pointers, and those
1721 * that use void* generic pointers. It works with the latter
1722 * because both ANSI C and C++ allow castless assignment from
1723 * any pointer type to void*, and deal with argument conversions
1724 * as though doing an assignment.
1726 return (void *) realloc( (char *) ptr, size );
1729 #ifdef YY_USE_PROTOS
1730 static void yy_flex_free( void *ptr )
1732 static void yy_flex_free( ptr )
1746 #line 50 "conv-cpm.flex"
1753 int yywrap(){ return(1); }
1760 void yychkword(const char *s)
1762 if (strcmp(yytext, s)) {
1763 fprintf(stderr,"%s expected\n", s);
1768 void yychktype(char c)
1770 if (yytoktype == c) return;
1772 fprintf(stderr,"identifier expected\n");
1775 fprintf(stderr,"%c expected\n",c);
1780 /******************************************************************************
1782 * The 'symbol table', such as it is.
1784 *****************************************************************************/
1786 char *mod_funcs[1000];
1789 char *type_name[1000];
1790 int type_kind[1000];
1794 char *func_args[1000];
1795 int func_array[1000];
1796 int func_pointer[1000];
1800 int type_simple(char *type)
1803 for (i=0; i<type_count; i++) {
1804 if (strcmp(type, type_name[i])==0)
1805 return (type_kind[i]=='S') ? 1:0;
1807 fprintf(stderr,"Unknown type %s\n", type);
1811 void type_declare(char *type, int kind)
1813 if (type_count==1000) {
1814 fprintf(stderr,"error: type table overflow.\n");
1817 type_name[type_count] = strdup(type);
1818 type_kind[type_count] = kind;
1822 /******************************************************************************
1826 *****************************************************************************/
1828 void gen_actual_args(FILE *f)
1833 fprintf(f, "CpmA0");
1834 for (i=1; i<func_len; i++) {
1835 fprintf(f, ",CpmA%d", i);
1841 void gen_dimension_required()
1843 fprintf(stderr,"CpmDim required before array.\n");
1847 void gen_func_struct()
1850 fprintf(file_cpm, "struct CpmSt_%s\n", func_name);
1851 fprintf(file_cpm, "{\n");
1852 fprintf(file_cpm, "char convcore[CmiMsgHeaderSizeBytes];\n");
1853 fprintf(file_cpm, "unsigned int envpos;\n");
1854 for (i=0; i<func_len; i++) {
1855 if ((func_pointer[i]==0) && (func_array[i]==0)) {
1856 fprintf(file_cpm, "%s f%d;\n",func_args[i],i);
1858 fprintf(file_cpm, "int f%d;\n",i);
1861 fprintf(file_cpm, "};\n");
1864 void gen_func_recv()
1867 fprintf(file_cpm, "static void CpmRecv_%s(char *CpmM)\n", func_name);
1868 fprintf(file_cpm, "{\n");
1869 fprintf(file_cpm, "struct CpmSt_%s *CpmS=(struct CpmSt_%s *)CpmM;\n",
1870 func_name, func_name);
1871 fprintf(file_cpm, "char *CpmX = (char *)CpmS;\n");
1872 fprintf(file_cpm, "int i;\n");
1873 for (i=0; i<func_len; i++) {
1874 fprintf(file_cpm, "%s %sCpmA%d;\n", func_args[i], func_array[i]?"*":"", i);
1876 for (i=0; i<func_len; i++) {
1877 int mode = (func_pointer[i] ? 2 : 0) + (func_array[i] ? 1 : 0);
1879 case 0: /* simple */
1880 fprintf(file_cpm, "CpmA%d = CpmS->f%d;\n", i, i);
1881 fprintf(file_cpm, "CpmUnpack_%s(CpmA%d);\n", func_args[i], i);
1883 case 1: /* array of simple */
1884 if ((i==0)||(func_array[i-1])||(strcmp(func_args[i-1],"CpmDim")))
1885 gen_dimension_required();
1886 fprintf(file_cpm, "CpmA%d = (%s *)(CpmX+(CpmS->f%d));\n", i, func_args[i], i);
1887 fprintf(file_cpm, "for (i=0; i<CpmA%d; i++)\n", i-1);
1888 fprintf(file_cpm, " CpmUnpack_%s(CpmA%d[i]);\n", func_args[i], i);
1890 case 2: /* pointer */
1891 fprintf(file_cpm, "CpmA%d = (%s)(CpmX+(CpmS->f%d));\n", i, func_args[i], i);
1892 fprintf(file_cpm, "CpmPtrUnpack_%s(CpmA%d);\n", func_args[i], i);
1894 case 3: /* array of pointer */
1895 if ((i==0)||(func_array[i-1])||(strcmp(func_args[i-1],"CpmDim")))
1896 gen_dimension_required();
1897 fprintf(file_cpm, "CpmA%d = (%s *)(CpmX+(CpmS->f%d));\n", i, func_args[i], i);
1898 fprintf(file_cpm, "for (i=0; i<CpmA%d; i++) {\n", i-1);
1899 fprintf(file_cpm, " CpmA%d[i] = CpmM + (size_t)(CpmA%d[i]);\n", i, i);
1900 fprintf(file_cpm, " CpmPtrUnpack_%s(CpmA%d[i]);\n", func_args[i], i);
1901 fprintf(file_cpm, "}\n");
1905 fprintf(file_cpm,"%s", func_name);
1906 gen_actual_args(file_cpm);
1907 fprintf(file_cpm,"CmiFree(CpmM);\n");
1908 fprintf(file_cpm, "}\n");
1911 void gen_func_send()
1914 if (func_static) fprintf(file_cpm, "static ");
1916 fprintf(file_cpm,"void *Cpm_%s(CpmDestination ctrl",func_name);
1917 for (i=0; i<func_len; i++) {
1918 fprintf(file_cpm, ",%s %sa%d", func_args[i], func_array[i]?"*":"", i);
1920 fprintf(file_cpm, ")\n");
1921 fprintf(file_cpm, "{\n");
1922 fprintf(file_cpm, "struct CpmSt_%s *msg;\n",func_name);
1923 fprintf(file_cpm, "char *data; int size, i, envpos; void *result;\n");
1924 fprintf(file_cpm, "int offs = CpmAlign(sizeof(struct CpmSt_%s), double);\n",func_name);
1925 for (i=0; i<func_len; i++) {
1927 fprintf(file_cpm, "int aoffs%d;\n",i);
1928 if (func_pointer[i]) {
1929 if (func_array[i]) {
1930 fprintf(file_cpm, "size_t *poffs%d = (size_t *)malloc(a%d*sizeof(size_t));\n",i,i-1);
1932 fprintf(file_cpm, "int poffs%d;\n",i);
1936 fprintf(file_cpm, "envpos=offs; offs=CpmAlign(offs+(ctrl->envsize),double);\n");
1937 for (i=0; i<func_len; i++) {
1938 if (func_array[i]) {
1939 fprintf(file_cpm, "size=a%d*sizeof(%s);\n",i-1,func_args[i]);
1940 fprintf(file_cpm, "aoffs%d=offs; offs=CpmAlign(offs+size,double);\n",i);
1943 for (i=0; i<func_len; i++) {
1944 if (func_pointer[i]) {
1945 if (func_array[i]) {
1946 fprintf(file_cpm, "for (i=0; i<a%d; i++) {\n",i-1) ;
1947 fprintf(file_cpm, " size = CpmPtrSize_%s(a%d[i]);\n",func_args[i],i);
1948 fprintf(file_cpm, " poffs%d[i]=offs; offs=CpmAlign(offs+size,double);\n",i);
1949 fprintf(file_cpm, "}\n");
1951 fprintf(file_cpm, "size = CpmPtrSize_%s(a%d);\n",func_args[i],i);
1952 fprintf(file_cpm, "poffs%d=offs; offs=CpmAlign(offs+size, double);\n",i);
1956 fprintf(file_cpm, "data = (char *)CmiAlloc(offs);\n");
1957 fprintf(file_cpm, "msg = (struct CpmSt_%s *)data;\n",func_name);
1958 fprintf(file_cpm, "msg->envpos = envpos;\n");
1959 for (i=0; i<func_len; i++) {
1960 int mode = (func_array[i]?2:0) | (func_pointer[i]?1:0);
1962 case 0: /* one simple */
1963 fprintf(file_cpm, "CpmPack_%s(a%d);\n",func_args[i],i);
1964 fprintf(file_cpm, "msg->f%d = a%d;\n",i,i);
1966 case 1: /* one pointer */
1967 fprintf(file_cpm, "msg->f%d = poffs%d;\n",i,i);
1968 fprintf(file_cpm, "CpmPtrPack_%s(((%s)(data+poffs%d)), a%d);\n",
1969 func_args[i],func_args[i],i,i);
1971 case 2: /* array simple */
1972 fprintf(file_cpm, "msg->f%d = aoffs%d;\n",i,i);
1973 fprintf(file_cpm, "memcpy(data+aoffs%d, a%d, a%d*sizeof(%s));\n",
1974 i,i,i-1,func_args[i]);
1975 fprintf(file_cpm, "for(i=0; i<a%d; i++)\n",i-1);
1976 fprintf(file_cpm, " CpmPack_%s(((%s *)(data+aoffs%d))[i]);\n",
1977 func_args[i],func_args[i],i);
1979 case 3: /* array pointer */
1980 fprintf(file_cpm, "msg->f%d = aoffs%d;\n",i,i);
1981 fprintf(file_cpm, "memcpy(data+aoffs%d, poffs%d, a%d*sizeof(size_t));\n",
1983 fprintf(file_cpm, "for(i=0; i<a%d; i++)\n",i-1);
1984 fprintf(file_cpm, " CpmPtrPack_%s(((%s)(data+(poffs%d[i]))), a%d[i]);\n",
1985 func_args[i],func_args[i], i,i);
1989 fprintf(file_cpm,"CmiSetHandler(msg, CpvAccess(CpmIndex_%s));\n",func_name);
1990 fprintf(file_cpm,"result = (ctrl->sendfn)(ctrl, offs, msg);\n");
1991 for (i=0; i<func_len; i++)
1992 if ((func_pointer[i])&&(func_array[i]))
1993 fprintf(file_cpm, "free(poffs%d);\n", i);
1994 fprintf(file_cpm,"return result;\n");
1995 fprintf(file_cpm,"}\n");
1998 void gen_func_protos()
2002 fprintf(file_cpm, "CpvStaticDeclare(int, CpmIndex_%s);\n", func_name);
2004 fprintf(file_cpm,"void %s(",func_name);
2006 fprintf(file_cpm, "%s %s", func_args[0], func_array[0]?"*":"");
2007 for (i=1; i<func_len; i++)
2008 fprintf(file_cpm, ",%s %s", func_args[i], func_array[i]?"*":"");
2010 fprintf(file_cpm,");\n");
2023 fprintf(file_cpm, "CpvStaticDeclare(int, CpmIPRIO);\n");
2029 fprintf(file_cpm, "static void CpmInitializeThisModule()\n");
2030 fprintf(file_cpm, "{\n");
2031 fprintf(file_cpm, "CpvInitialize(int, CpmIPRIO);\n");
2032 for (i=0; i<mod_len; i++) {
2033 fprintf(file_cpm, "CpvInitialize(int, CpmIndex_%s);\n", mod_funcs[i]);
2034 fprintf(file_cpm, "CpvAccess(CpmIndex_%s) = CmiRegisterHandler((CmiHandler)CpmRecv_%s);\n",
2035 mod_funcs[i], mod_funcs[i]);
2037 fprintf(file_cpm, "}\n");
2040 /******************************************************************************
2044 *****************************************************************************/
2048 int kind = yytoktype;
2050 if (strncmp(yytext,"CpmType_",8)==0) {
2051 type_declare(yytext+8, kind);
2062 if (yytoktype == '{') level++;
2063 if (yytoktype == '}') level--;
2064 if (yytoktype==0) return;
2071 yychkword("CpmInvokable");
2077 if (strcmp(yytext,"static")==0) {
2082 func_name = strdup(yytext);
2086 if (yytoktype != ')') {
2089 func_args[func_len] = strdup(yytext);
2090 func_array[func_len] = 0;
2092 if (yytoktype == '*') {
2094 func_array[func_len] = 1;
2096 func_pointer[func_len] = !type_simple(func_args[func_len]);
2100 if (yytoktype == ')') break;
2106 mod_funcs[mod_len++] = func_name;
2116 switch (yytoktype) {
2118 case 'P': parse_type(); goto top;
2119 case 'S': parse_type(); goto top;
2120 case 'I': parse_func(); goto top;
2121 case '{': parse_list(); goto top;
2122 default: yytokget(); goto top;
2127 /******************************************************************************
2131 *****************************************************************************/
2135 fprintf(stderr,"usage: cpm <modulename>\n");
2139 FILE *fopen_nofail(const char *path, const char *mode)
2141 FILE *res = fopen(path, mode);
2143 fprintf(stderr,"Couldn't open %s with mode %s\n",path,mode);
2149 void disclaim(FILE *f, char *src)
2151 fprintf(f,"/* WARNING: This file generated by Converse */\n");
2152 fprintf(f,"/* Marshalling System from source-file %s. */\n",src);
2156 int main(int argc, char **argv)
2158 if (argc != 3) usage();
2159 file_src = fopen_nofail(argv[1], "r");
2160 file_cpm = fopen_nofail(argv[2], "w");
2161 disclaim(file_cpm, argv[1]);