#line 2 "avrlex.cc" /* A lexical scanner generated by flex */ /* Scanner skeleton version: * $Header: /cvs/root/flex/flex/skel.c,v 1.2 2004/05/07 00:28:17 jkh Exp $ */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #include /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #ifdef __cplusplus #include #include /* Use prototypes in function declarations. */ #define YY_USE_PROTOS /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ #if __STDC__ #define YY_USE_PROTOS #define YY_USE_CONST #endif /* __STDC__ */ #endif /* ! __cplusplus */ #ifdef __TURBOC__ #pragma warn -rch #pragma warn -use #include #include #define YY_USE_CONST #define YY_USE_PROTOS #endif #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif #ifdef YY_USE_PROTOS #define YY_PROTO(proto) proto #else #define YY_PROTO(proto) () #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #define YY_BUF_SIZE 16384 typedef struct yy_buffer_state *YY_BUFFER_STATE; extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* The funky do-while in the following #define is used to turn the definition * int a single C statement (which needs a semi-colon terminator). This * avoids problems with code like: * * if ( condition_holds ) * yyless( 5 ); * else * do_something_else(); * * Prior to using the do-while the compiler would get upset at the * "else" because it interpreted the "if" statement as being all * done when it reached the ';' after the yyless() call. */ /* Return all but the first 'n' matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ *yy_cp = yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, yytext_ptr ) /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). */ typedef unsigned int yy_size_t; struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; static YY_BUFFER_STATE yy_current_buffer = 0; /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". */ #define YY_CURRENT_BUFFER yy_current_buffer /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; void yyrestart YY_PROTO(( FILE *input_file )); void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); void yy_load_buffer_state YY_PROTO(( void )); YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) #define yywrap() 1 #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern char *yytext; #define yytext_ptr yytext static yy_state_type yy_get_previous_state YY_PROTO(( void )); static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); static int yy_get_next_buffer YY_PROTO(( void )); static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yytext_ptr = yy_bp; \ yyleng = (int) (yy_cp - yy_bp); \ yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; #define YY_NUM_RULES 199 #define YY_END_OF_BUFFER 200 static yyconst short int yy_accept[402] = { 0, 0, 0, 200, 198, 194, 193, 26, 198, 197, 198, 3, 15, 198, 17, 18, 1, 22, 20, 23, 21, 2, 181, 181, 19, 195, 8, 24, 9, 16, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 163, 164, 165, 14, 25, 194, 198, 21, 194, 11, 0, 179, 0, 197, 184, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 181, 185, 185, 0, 195, 4, 6, 10, 7, 5, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 52, 169, 192, 170, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 156, 192, 159, 192, 192, 192, 192, 192, 192, 192, 192, 60, 192, 192, 168, 192, 192, 180, 192, 192, 192, 192, 192, 192, 192, 192, 160, 192, 192, 192, 192, 12, 194, 0, 0, 0, 0, 0, 0, 0, 179, 191, 0, 191, 0, 0, 0, 0, 0, 30, 0, 0, 31, 0, 29, 0, 0, 0, 196, 183, 182, 56, 55, 192, 58, 100, 192, 153, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 154, 192, 192, 144, 155, 117, 122, 124, 119, 105, 121, 123, 120, 118, 107, 51, 71, 192, 102, 192, 192, 192, 59, 192, 192, 192, 192, 192, 192, 192, 99, 140, 161, 76, 77, 192, 40, 166, 152, 101, 192, 61, 63, 97, 125, 74, 148, 192, 103, 192, 192, 129, 192, 150, 108, 53, 145, 78, 109, 114, 116, 111, 151, 113, 115, 112, 110, 192, 134, 162, 149, 54, 192, 106, 131, 0, 0, 0, 0, 0, 0, 190, 188, 0, 0, 0, 0, 0, 27, 0, 0, 0, 28, 0, 32, 35, 69, 75, 136, 142, 143, 79, 80, 82, 87, 89, 90, 93, 94, 96, 88, 84, 81, 83, 95, 91, 92, 85, 86, 137, 192, 141, 57, 192, 192, 167, 135, 49, 66, 41, 47, 192, 127, 50, 46, 62, 64, 48, 104, 192, 128, 139, 72, 146, 147, 70, 157, 158, 192, 73, 98, 0, 0, 0, 0, 0, 188, 0, 186, 0, 0, 34, 37, 0, 38, 178, 39, 42, 43, 44, 45, 192, 132, 67, 126, 65, 138, 130, 175, 0, 174, 0, 0, 0, 0, 33, 0, 133, 68, 0, 0, 177, 0, 189, 0, 187, 0, 36, 0, 0, 172, 176, 173, 0, 176, 0, 171, 0 } ; static yyconst int yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 27, 27, 28, 28, 29, 30, 31, 32, 33, 1, 1, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 36, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 1, 34, 1, 35, 36, 1, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 36, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 1, 62, 1, 63, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst int yy_meta[64] = { 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 5, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1 } ; static yyconst short int yy_base[417] = { 0, 0, 62, 542, 543, 65, 543, 509, 57, 0, 0, 543, 528, 505, 543, 543, 543, 543, 543, 543, 35, 517, 70, 31, 543, 0, 46, 505, 47, 543, 0, 64, 67, 85, 42, 92, 488, 41, 94, 487, 94, 69, 74, 31, 91, 131, 124, 480, 493, 0, 0, 0, 470, 543, 181, 172, 165, 158, 543, 92, 543, 159, 0, 0, 543, 518, 198, 483, 469, 474, 188, 142, 474, 485, 0, 79, 0, 79, 0, 0, 543, 543, 543, 543, 543, 0, 150, 485, 471, 476, 482, 220, 143, 466, 473, 116, 194, 471, 191, 0, 479, 0, 127, 466, 463, 464, 463, 457, 469, 458, 473, 461, 469, 456, 187, 45, 458, 181, 452, 447, 456, 459, 450, 455, 444, 455, 0, 446, 442, 237, 458, 439, 445, 184, 217, 240, 451, 443, 200, 452, 452, 433, 434, 543, 286, 294, 262, 263, 437, 440, 447, 433, 201, 543, 469, 468, 303, 467, 434, 423, 436, 543, 224, 435, 543, 435, 418, 432, 429, 416, 0, 127, 0, 0, 0, 412, 424, 0, 415, 0, 265, 266, 415, 425, 269, 159, 263, 420, 423, 416, 418, 282, 285, 406, 0, 419, 412, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 417, 0, 420, 408, 407, 0, 406, 429, 405, 407, 410, 402, 397, 0, 0, 0, 0, 0, 423, 0, 0, 0, 0, 406, 387, 390, 0, 0, 0, 0, 402, 0, 398, 391, 380, 369, 0, 0, 368, 292, 293, 0, 0, 0, 0, 0, 0, 0, 0, 0, 367, 0, 0, 0, 358, 347, 0, 0, 331, 344, 349, 333, 347, 338, 543, 543, 329, 371, 340, 328, 325, 543, 321, 322, 316, 543, 320, 543, 543, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 334, 0, 0, 315, 298, 0, 0, 0, 294, 0, 0, 298, 0, 0, 0, 0, 288, 0, 0, 296, 0, 0, 0, 0, 0, 0, 0, 0, 290, 0, 0, 285, 291, 282, 282, 289, 543, 348, 543, 320, 253, 543, 543, 260, 543, 543, 543, 0, 0, 0, 0, 239, 0, 226, 0, 0, 0, 0, 543, 224, 225, 222, 206, 354, 240, 543, 211, 0, 0, 210, 207, 543, 163, 543, 369, 543, 204, 543, 175, 169, 159, 0, 543, 160, 0, 149, 543, 543, 396, 401, 164, 406, 411, 413, 418, 423, 112, 101, 426, 428, 430, 432, 436 } ; static yyconst short int yy_def[417] = { 0, 401, 1, 401, 401, 401, 401, 401, 402, 403, 404, 401, 401, 405, 401, 401, 401, 401, 401, 401, 401, 401, 401, 22, 401, 406, 401, 401, 401, 401, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 401, 401, 401, 401, 401, 401, 401, 402, 401, 402, 403, 404, 401, 401, 408, 401, 401, 401, 401, 401, 401, 401, 409, 22, 410, 410, 411, 406, 401, 401, 401, 401, 401, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 45, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 401, 401, 401, 401, 401, 401, 401, 401, 401, 402, 401, 401, 401, 401, 412, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 409, 410, 411, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 401, 401, 401, 401, 401, 401, 401, 401, 401, 413, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 401, 401, 401, 401, 401, 401, 401, 401, 414, 401, 401, 401, 401, 401, 401, 401, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, 401, 401, 401, 401, 401, 401, 415, 401, 401, 407, 407, 401, 401, 401, 401, 401, 401, 401, 415, 401, 401, 401, 401, 416, 401, 401, 416, 401, 401, 0, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401 } ; static yyconst short int yy_nxt[607] = { 0, 4, 5, 6, 4, 5, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 23, 23, 23, 23, 24, 25, 26, 27, 28, 4, 29, 30, 31, 32, 33, 34, 35, 36, 30, 37, 38, 39, 40, 41, 42, 43, 44, 30, 45, 46, 47, 30, 30, 48, 49, 50, 51, 52, 53, 54, 60, 55, 57, 54, 76, 57, 57, 67, 68, 69, 70, 71, 80, 81, 83, 84, 99, 56, 100, 123, 72, 108, 124, 229, 73, 401, 61, 75, 75, 75, 75, 75, 75, 75, 109, 60, 171, 171, 230, 86, 172, 89, 76, 77, 76, 76, 76, 76, 87, 90, 121, 76, 76, 88, 119, 91, 92, 94, 95, 122, 120, 61, 93, 125, 78, 126, 101, 96, 110, 114, 97, 98, 102, 401, 103, 111, 127, 104, 112, 115, 116, 105, 128, 117, 171, 171, 106, 118, 129, 129, 129, 129, 129, 129, 129, 57, 197, 134, 57, 57, 135, 213, 152, 63, 198, 130, 136, 131, 214, 145, 137, 145, 132, 145, 138, 139, 133, 140, 144, 193, 145, 57, 144, 400, 173, 174, 165, 146, 61, 166, 175, 167, 399, 194, 301, 302, 146, 67, 68, 69, 70, 147, 397, 396, 60, 148, 155, 149, 150, 151, 72, 395, 389, 394, 73, 156, 156, 156, 156, 156, 156, 161, 226, 232, 162, 209, 247, 227, 199, 233, 61, 210, 248, 200, 201, 263, 228, 163, 202, 393, 211, 164, 203, 204, 205, 392, 206, 391, 389, 264, 207, 249, 157, 180, 181, 386, 182, 250, 183, 184, 185, 282, 186, 187, 188, 251, 189, 385, 384, 190, 191, 85, 192, 85, 252, 383, 283, 382, 85, 253, 254, 381, 85, 144, 255, 145, 57, 144, 256, 257, 258, 145, 259, 145, 380, 145, 260, 379, 269, 293, 295, 146, 148, 299, 149, 150, 151, 165, 303, 146, 166, 276, 167, 304, 294, 296, 309, 270, 300, 311, 277, 277, 277, 277, 277, 277, 337, 340, 352, 376, 375, 310, 374, 373, 312, 372, 371, 350, 370, 369, 368, 338, 341, 367, 366, 339, 351, 351, 351, 351, 351, 351, 361, 362, 363, 364, 350, 365, 360, 359, 358, 357, 387, 356, 355, 377, 377, 377, 377, 377, 377, 388, 388, 388, 388, 388, 388, 387, 354, 352, 349, 348, 347, 346, 345, 270, 388, 388, 388, 388, 388, 388, 59, 344, 59, 59, 59, 62, 343, 62, 62, 62, 65, 342, 65, 65, 65, 79, 336, 79, 79, 79, 85, 85, 154, 335, 154, 154, 154, 170, 334, 170, 170, 170, 278, 278, 353, 353, 378, 378, 390, 390, 398, 333, 398, 398, 398, 332, 331, 330, 329, 328, 327, 326, 325, 324, 323, 322, 321, 320, 319, 318, 317, 316, 315, 314, 313, 308, 307, 306, 305, 298, 297, 292, 291, 290, 289, 288, 287, 286, 285, 284, 281, 280, 279, 275, 275, 275, 274, 273, 272, 271, 268, 267, 266, 265, 262, 261, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 231, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 212, 208, 196, 195, 179, 178, 177, 176, 169, 168, 160, 159, 158, 153, 143, 142, 141, 113, 107, 82, 74, 66, 64, 58, 401, 3, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401 } ; static yyconst short int yy_chk[607] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 8, 2, 5, 2, 23, 5, 5, 20, 20, 20, 20, 20, 26, 26, 28, 28, 34, 2, 34, 43, 20, 37, 43, 115, 20, 23, 8, 22, 22, 22, 22, 22, 22, 22, 37, 59, 77, 77, 115, 31, 411, 32, 22, 22, 22, 22, 22, 22, 31, 32, 42, 410, 75, 31, 41, 32, 32, 33, 33, 42, 41, 59, 32, 44, 22, 44, 35, 33, 38, 40, 33, 33, 35, 75, 35, 38, 44, 35, 38, 40, 40, 35, 44, 40, 171, 171, 35, 40, 45, 45, 45, 45, 45, 45, 45, 57, 95, 46, 57, 57, 46, 102, 61, 404, 95, 45, 46, 45, 102, 55, 46, 55, 45, 55, 46, 46, 45, 46, 54, 92, 54, 54, 54, 399, 86, 86, 71, 55, 61, 71, 86, 71, 397, 92, 185, 185, 54, 56, 56, 56, 56, 56, 394, 393, 152, 56, 66, 56, 56, 56, 56, 392, 390, 386, 56, 66, 66, 66, 66, 66, 66, 70, 114, 117, 70, 98, 133, 114, 96, 117, 152, 98, 133, 96, 96, 138, 114, 70, 96, 384, 98, 70, 96, 96, 96, 383, 96, 380, 378, 138, 96, 134, 66, 91, 91, 376, 91, 134, 91, 91, 91, 162, 91, 91, 91, 134, 91, 375, 374, 91, 91, 129, 91, 129, 135, 373, 162, 367, 129, 135, 135, 365, 129, 144, 135, 144, 144, 144, 135, 135, 135, 145, 135, 145, 357, 145, 135, 354, 146, 180, 181, 144, 146, 184, 146, 146, 146, 147, 186, 145, 147, 156, 147, 186, 180, 181, 191, 147, 184, 192, 156, 156, 156, 156, 156, 156, 250, 251, 353, 349, 348, 191, 347, 346, 192, 345, 342, 277, 333, 330, 325, 250, 251, 322, 318, 250, 277, 277, 277, 277, 277, 277, 314, 314, 314, 314, 351, 317, 287, 285, 284, 283, 377, 281, 280, 351, 351, 351, 351, 351, 351, 377, 377, 377, 377, 377, 377, 388, 279, 278, 274, 273, 272, 271, 270, 269, 388, 388, 388, 388, 388, 388, 402, 266, 402, 402, 402, 403, 265, 403, 403, 403, 405, 261, 405, 405, 405, 406, 249, 406, 406, 406, 407, 407, 408, 246, 408, 408, 408, 409, 245, 409, 409, 409, 412, 412, 413, 413, 414, 414, 415, 415, 416, 244, 416, 416, 416, 243, 241, 236, 235, 234, 229, 223, 222, 221, 220, 219, 218, 217, 215, 214, 213, 211, 196, 195, 193, 190, 189, 188, 187, 183, 182, 178, 176, 175, 169, 168, 167, 166, 165, 163, 160, 159, 158, 157, 155, 154, 151, 150, 149, 148, 142, 141, 140, 139, 137, 136, 132, 131, 130, 128, 127, 125, 124, 123, 122, 121, 120, 119, 118, 116, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 100, 97, 94, 93, 90, 89, 88, 87, 73, 72, 69, 68, 67, 65, 52, 48, 47, 39, 36, 27, 21, 13, 12, 7, 3, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, 401 } ; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "avrlex.l" #define INITIAL 0 #line 2 "avrlex.l" ////////////////////////////////////////////////////////////////////////////// // // File : avrlex.l // // Author : Tom Mortensen - Copyright (C) 1999 // // Description : Scanner file for AVR assembler // // History // ======================================================================== // // 980902 : Tom - File created. // 990124 : Tom - Added GPL notice. // 990329 : Tom - Added support for hex values like 1AB without $ or 0x // 990512 : Tom - Fixed detection on binary numbers. // 990522 : Tom - Added support for PC/DC/EC. // 991211 : Tom - Fixed .endm problem (it had to be lower case) // 991217 : Kurt- Added # and support for local labels // 001101 : Brian - Added support for multiple include search paths // 010319 : Timothy Lee - Added byte1 function (sames as low()) // 041212 : Tom - Fixed problem with .db 00 // //////////////////////////////////////////////////////// Tom did this //////// // // Copyright notice: // // tavrasm - A GNU/Linux assembler for the Atmel AVR series // of microcontrollers. Copyright (C) 1999 Tom Mortensen // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Tom Mortensen // // E-mail : tom@tavrasm.org // WWW : http://www.tavrasm.org // ////////////////////////////////////////////////////////////////////////////// /// Include ////////////////////////////////////////////////////////////////// #include #include #include "symbol.hh" #include "semantic.hh" #include "avrparse.hh" #include "avrasm.hh" #include "utils.hh" /// Extern /////////////////////////////////////////////////////////////////// GLOBALS(extern); /// Global /////////////////////////////////////////////////////////////////// symbolTableEntry *sym; YY_BUFFER_STATE statestack[MAX_CONTEXT_DEPTH]; int restartcount = 0; int ret; /// Defines ////////////////////////////////////////////////////////////////// #define SKIPRESTART 0x02BABE // Any value that is not a token /// Prototypes for support function ////////////////////////////////////////// int restart(void); int endofline(void); int identifier(void); int registers(void); int integers(void); int macrodef(void); int includefile(void); int string(void); int character(void); int doexit(void); int macro(symbolSA symb); void list(int listtype); void illegal(void); /// Scanner definition /////////////////////////////////////////////////////// #define YY_NEVER_INTERACTIVE 1 #line 734 "avrlex.cc" /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap YY_PROTO(( void )); #else extern int yywrap YY_PROTO(( void )); #endif #endif #ifndef YY_NO_UNPUT static void yyunput YY_PROTO(( int c, char *buf_ptr )); #endif #ifndef yytext_ptr static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen YY_PROTO(( yyconst char * )); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput YY_PROTO(( void )); #else static int input YY_PROTO(( void )); #endif #endif #if YY_STACK_USED static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = 0; #ifndef YY_NO_PUSH_STATE static void yy_push_state YY_PROTO(( int new_state )); #endif #ifndef YY_NO_POP_STATE static void yy_pop_state YY_PROTO(( void )); #endif #ifndef YY_NO_TOP_STATE static int yy_top_state YY_PROTO(( void )); #endif #else #define YY_NO_PUSH_STATE 1 #define YY_NO_POP_STATE 1 #define YY_NO_TOP_STATE 1 #endif #ifdef YY_MALLOC_DECL YY_MALLOC_DECL #else #if __STDC__ #ifndef __cplusplus #include #endif #else /* Just try to get by without declaring the routines. This will fail * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) * or sizeof(void*) != sizeof(int). */ #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( yy_current_buffer->yy_is_interactive ) \ { \ int c = '*', n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL int yylex YY_PROTO(( void )) #endif /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ if ( yyleng > 0 ) \ yy_current_buffer->yy_at_bol = \ (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 115 "avrlex.l" #line 891 "avrlex.cc" if ( yy_init ) { yy_init = 0; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! yy_start ) yy_start = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_load_buffer_state(); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = yy_c_buf_p; /* Support of yytext. */ *yy_cp = yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = yy_start; yy_current_state += YY_AT_BOL(); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 402 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 543 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yy_hold_char; yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; goto yy_find_action; case 1: YY_RULE_SETUP #line 117 "avrlex.l" return STAR; YY_BREAK case 2: YY_RULE_SETUP #line 118 "avrlex.l" return DIV; YY_BREAK case 3: YY_RULE_SETUP #line 119 "avrlex.l" return MOD; YY_BREAK case 4: YY_RULE_SETUP #line 120 "avrlex.l" return LS; YY_BREAK case 5: YY_RULE_SETUP #line 121 "avrlex.l" return RS; YY_BREAK case 6: YY_RULE_SETUP #line 122 "avrlex.l" return LE; YY_BREAK case 7: YY_RULE_SETUP #line 123 "avrlex.l" return GE; YY_BREAK case 8: YY_RULE_SETUP #line 124 "avrlex.l" return LESS; YY_BREAK case 9: YY_RULE_SETUP #line 125 "avrlex.l" return GREAT; YY_BREAK case 10: YY_RULE_SETUP #line 126 "avrlex.l" return EQ; YY_BREAK case 11: YY_RULE_SETUP #line 127 "avrlex.l" return NE; YY_BREAK case 12: YY_RULE_SETUP #line 128 "avrlex.l" return OROR; YY_BREAK case 13: YY_RULE_SETUP #line 129 "avrlex.l" return ANDAND; YY_BREAK case 14: YY_RULE_SETUP #line 130 "avrlex.l" return OR; YY_BREAK case 15: YY_RULE_SETUP #line 131 "avrlex.l" return AND; YY_BREAK case 16: YY_RULE_SETUP #line 132 "avrlex.l" return XOR; YY_BREAK case 17: YY_RULE_SETUP #line 133 "avrlex.l" return LPAR; YY_BREAK case 18: YY_RULE_SETUP #line 134 "avrlex.l" return RPAR; YY_BREAK case 19: YY_RULE_SETUP #line 135 "avrlex.l" return COLON; YY_BREAK case 20: YY_RULE_SETUP #line 136 "avrlex.l" return COMMA; YY_BREAK case 21: YY_RULE_SETUP #line 137 "avrlex.l" return DOT; YY_BREAK case 22: YY_RULE_SETUP #line 138 "avrlex.l" return PLUS; YY_BREAK case 23: YY_RULE_SETUP #line 139 "avrlex.l" return MINUS; YY_BREAK case 24: YY_RULE_SETUP #line 140 "avrlex.l" return EQUAL; YY_BREAK case 25: YY_RULE_SETUP #line 141 "avrlex.l" return WAVE; YY_BREAK case 26: YY_RULE_SETUP #line 142 "avrlex.l" return NOT; YY_BREAK case 27: YY_RULE_SETUP #line 144 "avrlex.l" return DEF; YY_BREAK case 28: YY_RULE_SETUP #line 145 "avrlex.l" return EQU; YY_BREAK case 29: YY_RULE_SETUP #line 146 "avrlex.l" return EQU; YY_BREAK case 30: YY_RULE_SETUP #line 147 "avrlex.l" return DB; YY_BREAK case 31: YY_RULE_SETUP #line 148 "avrlex.l" return DW; YY_BREAK case 32: YY_RULE_SETUP #line 149 "avrlex.l" return ORG; YY_BREAK case 33: YY_RULE_SETUP #line 150 "avrlex.l" return ALIGN; YY_BREAK case 34: YY_RULE_SETUP #line 151 "avrlex.l" return BYTE; YY_BREAK case 35: YY_RULE_SETUP #line 152 "avrlex.l" return SET; YY_BREAK case 36: YY_RULE_SETUP #line 153 "avrlex.l" return DEVICE; YY_BREAK case 37: YY_RULE_SETUP #line 155 "avrlex.l" { yysegment = SEGMENT_CODE; return CSEG; } YY_BREAK case 38: YY_RULE_SETUP #line 156 "avrlex.l" { yysegment = SEGMENT_DATA; return DSEG; } YY_BREAK case 39: YY_RULE_SETUP #line 157 "avrlex.l" { yysegment = SEGMENT_EEPROM; return ESEG; } YY_BREAK case 40: YY_RULE_SETUP #line 159 "avrlex.l" { yylval.func = OP_LOW; return FUNCTION;} YY_BREAK case 41: YY_RULE_SETUP #line 160 "avrlex.l" { yylval.func = OP_HIGH; return FUNCTION;} YY_BREAK case 42: YY_RULE_SETUP #line 161 "avrlex.l" { yylval.func = OP_LOW; return FUNCTION;} YY_BREAK case 43: YY_RULE_SETUP #line 162 "avrlex.l" { yylval.func = OP_BYTE2; return FUNCTION;} YY_BREAK case 44: YY_RULE_SETUP #line 163 "avrlex.l" { yylval.func = OP_BYTE3; return FUNCTION;} YY_BREAK case 45: YY_RULE_SETUP #line 164 "avrlex.l" { yylval.func = OP_BYTE4; return FUNCTION;} YY_BREAK case 46: YY_RULE_SETUP #line 165 "avrlex.l" { yylval.func = OP_LWRD; return FUNCTION;} YY_BREAK case 47: YY_RULE_SETUP #line 166 "avrlex.l" { yylval.func = OP_HWRD; return FUNCTION;} YY_BREAK case 48: YY_RULE_SETUP #line 167 "avrlex.l" { yylval.func = OP_PAGE; return FUNCTION;} YY_BREAK case 49: YY_RULE_SETUP #line 168 "avrlex.l" { yylval.func = OP_EXP2; return FUNCTION;} YY_BREAK case 50: YY_RULE_SETUP #line 169 "avrlex.l" { yylval.func = OP_LOG2; return FUNCTION;} YY_BREAK case 51: YY_RULE_SETUP #line 170 "avrlex.l" { yylval.opcode = O_CPC; return IREGREG; } /* Register */ YY_BREAK case 52: YY_RULE_SETUP #line 171 "avrlex.l" { yylval.opcode = O_CP; return IREGREG; } YY_BREAK case 53: YY_RULE_SETUP #line 172 "avrlex.l" { yylval.opcode = O_SBC; return IREGREG; } YY_BREAK case 54: YY_RULE_SETUP #line 173 "avrlex.l" { yylval.opcode = O_SUB; return IREGREG; } YY_BREAK case 55: YY_RULE_SETUP #line 174 "avrlex.l" { yylval.opcode = O_ADD; return IREGREG; } YY_BREAK case 56: YY_RULE_SETUP #line 175 "avrlex.l" { yylval.opcode = O_ADC; return IREGREG; } YY_BREAK case 57: YY_RULE_SETUP #line 176 "avrlex.l" { yylval.opcode = O_CPSE; return IREGREG; } YY_BREAK case 58: YY_RULE_SETUP #line 177 "avrlex.l" { yylval.opcode = O_AND; return IREGREG; } YY_BREAK case 59: YY_RULE_SETUP #line 178 "avrlex.l" { yylval.opcode = O_EOR; return IREGREG; } YY_BREAK case 60: YY_RULE_SETUP #line 179 "avrlex.l" { yylval.opcode = O_OR; return IREGREG; } YY_BREAK case 61: YY_RULE_SETUP #line 180 "avrlex.l" { yylval.opcode = O_MOV; return IREGREG; } YY_BREAK case 62: YY_RULE_SETUP #line 181 "avrlex.l" { yylval.opcode = O_MOVW; return IREGREGW; } YY_BREAK case 63: YY_RULE_SETUP #line 182 "avrlex.l" { yylval.opcode = O_MUL; return IREGREG; } YY_BREAK case 64: YY_RULE_SETUP #line 183 "avrlex.l" { yylval.opcode = O_MULS; return IREGREG; } YY_BREAK case 65: YY_RULE_SETUP #line 184 "avrlex.l" { yylval.opcode = O_MULSU; return IREGREG; } YY_BREAK case 66: YY_RULE_SETUP #line 185 "avrlex.l" { yylval.opcode = O_FMUL; return IREGREG; } YY_BREAK case 67: YY_RULE_SETUP #line 186 "avrlex.l" { yylval.opcode = O_FMULS; return IREGREG; } YY_BREAK case 68: YY_RULE_SETUP #line 187 "avrlex.l" { yylval.opcode = O_FMULSU; return IREGREG; } YY_BREAK case 69: YY_RULE_SETUP #line 188 "avrlex.l" { yylval.opcode = O_ADIW; return IREGIMMW; } /* Reg/Imm */ YY_BREAK case 70: YY_RULE_SETUP #line 189 "avrlex.l" { yylval.opcode = O_SBIW; return IREGIMMW; } YY_BREAK case 71: YY_RULE_SETUP #line 190 "avrlex.l" { yylval.opcode = O_CPI; return IREGIMM; } YY_BREAK case 72: YY_RULE_SETUP #line 191 "avrlex.l" { yylval.opcode = O_SBCI; return IREGIMM; } YY_BREAK case 73: YY_RULE_SETUP #line 192 "avrlex.l" { yylval.opcode = O_SUBI; return IREGIMM; } YY_BREAK case 74: YY_RULE_SETUP #line 193 "avrlex.l" { yylval.opcode = O_ORI; return IREGIMM; } YY_BREAK case 75: YY_RULE_SETUP #line 194 "avrlex.l" { yylval.opcode = O_ANDI; return IREGIMM; } YY_BREAK case 76: YY_RULE_SETUP #line 195 "avrlex.l" { yylval.opcode = O_LDI; return IREGIMM; } YY_BREAK case 77: YY_RULE_SETUP #line 196 "avrlex.l" { yylval.opcode = O_LDS; return IREGIMM; } YY_BREAK case 78: YY_RULE_SETUP #line 197 "avrlex.l" { yylval.opcode = O_SBR; return IREGIMM; } YY_BREAK case 79: YY_RULE_SETUP #line 198 "avrlex.l" { yylval.opcode = O_BRCC; return IIMM; } /* Immediate */ YY_BREAK case 80: YY_RULE_SETUP #line 199 "avrlex.l" { yylval.opcode = O_BRCS; return IIMM; } YY_BREAK case 81: YY_RULE_SETUP #line 200 "avrlex.l" { yylval.opcode = O_BRNE; return IIMM; } YY_BREAK case 82: YY_RULE_SETUP #line 201 "avrlex.l" { yylval.opcode = O_BREQ; return IIMM; } YY_BREAK case 83: YY_RULE_SETUP #line 202 "avrlex.l" { yylval.opcode = O_BRPL; return IIMM; } YY_BREAK case 84: YY_RULE_SETUP #line 203 "avrlex.l" { yylval.opcode = O_BRMI; return IIMM; } YY_BREAK case 85: YY_RULE_SETUP #line 204 "avrlex.l" { yylval.opcode = O_BRVC; return IIMM; } YY_BREAK case 86: YY_RULE_SETUP #line 205 "avrlex.l" { yylval.opcode = O_BRVS; return IIMM; } YY_BREAK case 87: YY_RULE_SETUP #line 206 "avrlex.l" { yylval.opcode = O_BRGE; return IIMM; } YY_BREAK case 88: YY_RULE_SETUP #line 207 "avrlex.l" { yylval.opcode = O_BRLT; return IIMM; } YY_BREAK case 89: YY_RULE_SETUP #line 208 "avrlex.l" { yylval.opcode = O_BRHC; return IIMM; } YY_BREAK case 90: YY_RULE_SETUP #line 209 "avrlex.l" { yylval.opcode = O_BRHS; return IIMM; } YY_BREAK case 91: YY_RULE_SETUP #line 210 "avrlex.l" { yylval.opcode = O_BRTC; return IIMM; } YY_BREAK case 92: YY_RULE_SETUP #line 211 "avrlex.l" { yylval.opcode = O_BRTS; return IIMM; } YY_BREAK case 93: YY_RULE_SETUP #line 212 "avrlex.l" { yylval.opcode = O_BRID; return IIMM; } YY_BREAK case 94: YY_RULE_SETUP #line 213 "avrlex.l" { yylval.opcode = O_BRIE; return IIMM; } YY_BREAK case 95: YY_RULE_SETUP #line 214 "avrlex.l" { yylval.opcode = O_BRSH; return IIMM; } YY_BREAK case 96: YY_RULE_SETUP #line 215 "avrlex.l" { yylval.opcode = O_BRLO; return IIMM; } YY_BREAK case 97: YY_RULE_SETUP #line 216 "avrlex.l" { yylval.opcode = O_NEG; return IREG; } /* Register */ YY_BREAK case 98: YY_RULE_SETUP #line 217 "avrlex.l" { yylval.opcode = O_SWAP; return IREG; } YY_BREAK case 99: YY_RULE_SETUP #line 218 "avrlex.l" { yylval.opcode = O_INC; return IREG; } YY_BREAK case 100: YY_RULE_SETUP #line 219 "avrlex.l" { yylval.opcode = O_ASR; return IREG; } YY_BREAK case 101: YY_RULE_SETUP #line 220 "avrlex.l" { yylval.opcode = O_LSR; return IREG; } YY_BREAK case 102: YY_RULE_SETUP #line 221 "avrlex.l" { yylval.opcode = O_DEC; return IREG; } YY_BREAK case 103: YY_RULE_SETUP #line 222 "avrlex.l" { yylval.opcode = O_POP; return IREG; } YY_BREAK case 104: YY_RULE_SETUP #line 223 "avrlex.l" { yylval.opcode = O_PUSH; return IREG; } YY_BREAK case 105: YY_RULE_SETUP #line 224 "avrlex.l" { yylval.opcode = O_CLR; return IREG; } YY_BREAK case 106: YY_RULE_SETUP #line 225 "avrlex.l" { yylval.opcode = O_TST; return IREG; } YY_BREAK case 107: YY_RULE_SETUP #line 226 "avrlex.l" { yylval.opcode = O_COM; return IREG; } YY_BREAK case 108: YY_RULE_SETUP #line 227 "avrlex.l" { yylval.opcode = O_ROR; return IREG; } YY_BREAK case 109: YY_RULE_SETUP #line 228 "avrlex.l" { yylval.opcode = O_SEC; return INOARGS; } /* No arguments */ YY_BREAK case 110: YY_RULE_SETUP #line 229 "avrlex.l" { yylval.opcode = O_SEZ; return INOARGS; } YY_BREAK case 111: YY_RULE_SETUP #line 230 "avrlex.l" { yylval.opcode = O_SEN; return INOARGS; } YY_BREAK case 112: YY_RULE_SETUP #line 231 "avrlex.l" { yylval.opcode = O_SEV; return INOARGS; } YY_BREAK case 113: YY_RULE_SETUP #line 232 "avrlex.l" { yylval.opcode = O_SES; return INOARGS; } YY_BREAK case 114: YY_RULE_SETUP #line 233 "avrlex.l" { yylval.opcode = O_SEH; return INOARGS; } YY_BREAK case 115: YY_RULE_SETUP #line 234 "avrlex.l" { yylval.opcode = O_SET; return INOARGS; } YY_BREAK case 116: YY_RULE_SETUP #line 235 "avrlex.l" { yylval.opcode = O_SEI; return INOARGS; } YY_BREAK case 117: YY_RULE_SETUP #line 236 "avrlex.l" { yylval.opcode = O_CLC; return INOARGS; } YY_BREAK case 118: YY_RULE_SETUP #line 237 "avrlex.l" { yylval.opcode = O_CLZ; return INOARGS; } YY_BREAK case 119: YY_RULE_SETUP #line 238 "avrlex.l" { yylval.opcode = O_CLN; return INOARGS; } YY_BREAK case 120: YY_RULE_SETUP #line 239 "avrlex.l" { yylval.opcode = O_CLV; return INOARGS; } YY_BREAK case 121: YY_RULE_SETUP #line 240 "avrlex.l" { yylval.opcode = O_CLS; return INOARGS; } YY_BREAK case 122: YY_RULE_SETUP #line 241 "avrlex.l" { yylval.opcode = O_CLH; return INOARGS; } YY_BREAK case 123: YY_RULE_SETUP #line 242 "avrlex.l" { yylval.opcode = O_CLT; return INOARGS; } YY_BREAK case 124: YY_RULE_SETUP #line 243 "avrlex.l" { yylval.opcode = O_CLI; return INOARGS; } YY_BREAK case 125: YY_RULE_SETUP #line 244 "avrlex.l" { yylval.opcode = O_NOP; return INOARGS; } YY_BREAK case 126: YY_RULE_SETUP #line 245 "avrlex.l" { yylval.opcode = O_ICALL; return INOARGS; } /* Misc. */ YY_BREAK case 127: YY_RULE_SETUP #line 246 "avrlex.l" { yylval.opcode = O_IJMP; return INOARGS; } YY_BREAK case 128: YY_RULE_SETUP #line 247 "avrlex.l" { yylval.opcode = O_RETI; return INOARGS; } YY_BREAK case 129: YY_RULE_SETUP #line 248 "avrlex.l" { yylval.opcode = O_RET; return INOARGS; } YY_BREAK case 130: YY_RULE_SETUP #line 249 "avrlex.l" { yylval.opcode = O_SLEEP; return INOARGS; } YY_BREAK case 131: YY_RULE_SETUP #line 250 "avrlex.l" { yylval.opcode = O_WDR; return INOARGS; } YY_BREAK case 132: YY_RULE_SETUP #line 251 "avrlex.l" { yylval.opcode = O_EIJMP; return INOARGS; } YY_BREAK case 133: YY_RULE_SETUP #line 252 "avrlex.l" { yylval.opcode = O_EICALL; return INOARGS; } YY_BREAK case 134: YY_RULE_SETUP #line 253 "avrlex.l" { yylval.opcode = O_SPM; return INOARGS; } YY_BREAK case 135: YY_RULE_SETUP #line 254 "avrlex.l" { yylval.opcode = O_ESPM; return INOARGS; } YY_BREAK case 136: YY_RULE_SETUP #line 255 "avrlex.l" { yylval.opcode = O_BCLR; return IIMM; } YY_BREAK case 137: YY_RULE_SETUP #line 256 "avrlex.l" { yylval.opcode = O_BSET; return IIMM; } YY_BREAK case 138: YY_RULE_SETUP #line 257 "avrlex.l" { yylval.opcode = O_RCALL; return IIMM; } YY_BREAK case 139: YY_RULE_SETUP #line 258 "avrlex.l" { yylval.opcode = O_RJMP; return IIMM; } YY_BREAK case 140: YY_RULE_SETUP #line 259 "avrlex.l" { yylval.opcode = O_JMP; return IIMM; } YY_BREAK case 141: YY_RULE_SETUP #line 260 "avrlex.l" { yylval.opcode = O_CALL; return IIMM; } YY_BREAK case 142: YY_RULE_SETUP #line 261 "avrlex.l" { yylval.opcode = O_BRBC; return IIMMIMM; } YY_BREAK case 143: YY_RULE_SETUP #line 262 "avrlex.l" { yylval.opcode = O_BRBS; return IIMMIMM; } YY_BREAK case 144: YY_RULE_SETUP #line 263 "avrlex.l" { yylval.opcode = O_CBI; return IIMMIMM; } YY_BREAK case 145: YY_RULE_SETUP #line 264 "avrlex.l" { yylval.opcode = O_SBI; return IIMMIMM; } YY_BREAK case 146: YY_RULE_SETUP #line 265 "avrlex.l" { yylval.opcode = O_SBIC; return IIMMIMM; } YY_BREAK case 147: YY_RULE_SETUP #line 266 "avrlex.l" { yylval.opcode = O_SBIS; return IIMMIMM; } YY_BREAK case 148: YY_RULE_SETUP #line 267 "avrlex.l" { yylval.opcode = O_OUT; return IIMMREG; } YY_BREAK case 149: YY_RULE_SETUP #line 268 "avrlex.l" { yylval.opcode = O_STS; return IIMMREG; } YY_BREAK case 150: YY_RULE_SETUP #line 269 "avrlex.l" { yylval.opcode = O_ROL; return IREG; } YY_BREAK case 151: YY_RULE_SETUP #line 270 "avrlex.l" { yylval.opcode = O_SER; return IREG; } YY_BREAK case 152: YY_RULE_SETUP #line 271 "avrlex.l" { yylval.opcode = O_LSL; return IREG; } YY_BREAK case 153: YY_RULE_SETUP #line 272 "avrlex.l" { yylval.opcode = O_BLD; return IREGIMM; } YY_BREAK case 154: YY_RULE_SETUP #line 273 "avrlex.l" { yylval.opcode = O_BST; return IREGIMM; } YY_BREAK case 155: YY_RULE_SETUP #line 274 "avrlex.l" { yylval.opcode = O_CBR; return IREGIMM; } YY_BREAK case 156: YY_RULE_SETUP #line 275 "avrlex.l" { yylval.opcode = O_IN; return IREGIMM; } YY_BREAK case 157: YY_RULE_SETUP #line 276 "avrlex.l" { yylval.opcode = O_SBRC; return IREGIMM; } YY_BREAK case 158: YY_RULE_SETUP #line 277 "avrlex.l" { yylval.opcode = O_SBRS; return IREGIMM; } YY_BREAK case 159: YY_RULE_SETUP #line 278 "avrlex.l" { yylval.opcode = O_LD; return IINDIRC; } YY_BREAK case 160: YY_RULE_SETUP #line 279 "avrlex.l" { yylval.opcode = O_ST; return IINDIRC; } YY_BREAK case 161: YY_RULE_SETUP #line 280 "avrlex.l" { yylval.opcode = O_LDD; return IINDIRC; } YY_BREAK case 162: YY_RULE_SETUP #line 281 "avrlex.l" { yylval.opcode = O_STD; return IINDIRC; } YY_BREAK case 163: YY_RULE_SETUP #line 282 "avrlex.l" { yylval.regid = 26; return REGXYZ; } YY_BREAK case 164: YY_RULE_SETUP #line 283 "avrlex.l" { yylval.regid = 28; return REGXYZ; } YY_BREAK case 165: YY_RULE_SETUP #line 284 "avrlex.l" { yylval.regid = 30; return REGXYZ; } YY_BREAK case 166: YY_RULE_SETUP #line 285 "avrlex.l" { yylval.opcode = O_LPM; return ILPM; } YY_BREAK case 167: YY_RULE_SETUP #line 286 "avrlex.l" { yylval.opcode = O_ELPM; return ILPM; } YY_BREAK case 168: YY_RULE_SETUP #line 288 "avrlex.l" { yylval.val.value=yycodepos/2;yylval.val.valid=TRUE; return COUNTER;} YY_BREAK case 169: YY_RULE_SETUP #line 289 "avrlex.l" { yylval.val.value=yydatapos; yylval.val.valid=TRUE; return COUNTER;} YY_BREAK case 170: YY_RULE_SETUP #line 290 "avrlex.l" { yylval.val.value=yyerompos; yylval.val.valid=TRUE; return COUNTER;} YY_BREAK case 171: YY_RULE_SETUP #line 292 "avrlex.l" list(LIST_NO_MACRO); YY_BREAK case 172: YY_RULE_SETUP #line 293 "avrlex.l" list(LIST_NO); YY_BREAK case 173: YY_RULE_SETUP #line 294 "avrlex.l" list(LIST_YES_MACRO); YY_BREAK case 174: YY_RULE_SETUP #line 295 "avrlex.l" list(LIST_YES); YY_BREAK case 175: YY_RULE_SETUP #line 296 "avrlex.l" yyeol=TRUE; if((ret=doexit() )!=SKIPRESTART) return ret; YY_BREAK case 176: YY_RULE_SETUP #line 297 "avrlex.l" if(includefile()==EOL) return EOL; YY_BREAK case 177: YY_RULE_SETUP #line 298 "avrlex.l" return macrodef(); YY_BREAK case 178: YY_RULE_SETUP #line 299 "avrlex.l" errorin(E_ENDM); YY_BREAK case 179: YY_RULE_SETUP #line 300 "avrlex.l" return string(); YY_BREAK case 180: YY_RULE_SETUP #line 301 "avrlex.l" return registers(); YY_BREAK case 181: YY_RULE_SETUP #line 302 "avrlex.l" return integers(); YY_BREAK case 182: YY_RULE_SETUP #line 303 "avrlex.l" return integers(); YY_BREAK case 183: YY_RULE_SETUP #line 304 "avrlex.l" return integers(); YY_BREAK case 184: YY_RULE_SETUP #line 305 "avrlex.l" return integers(); YY_BREAK case 185: YY_RULE_SETUP #line 306 "avrlex.l" return integers(); YY_BREAK case 186: YY_RULE_SETUP #line 307 "avrlex.l" return character(); YY_BREAK case 187: YY_RULE_SETUP #line 308 "avrlex.l" warningin(W_HEX_ESCAPE_INVALID);yylval.val.valid = TRUE;yylval.val.value = 0; return INTEGER; YY_BREAK case 188: YY_RULE_SETUP #line 309 "avrlex.l" return character(); YY_BREAK case 189: YY_RULE_SETUP #line 310 "avrlex.l" warningin(W_OCT_ESCAPE_INVALID);yylval.val.valid = TRUE;yylval.val.value = 0; return INTEGER; YY_BREAK case 190: YY_RULE_SETUP #line 311 "avrlex.l" return character(); YY_BREAK case 191: YY_RULE_SETUP #line 312 "avrlex.l" return character(); YY_BREAK case 192: YY_RULE_SETUP #line 313 "avrlex.l" if((ret=identifier())!=SKIPRESTART)return ret; YY_BREAK case YY_STATE_EOF(INITIAL): #line 314 "avrlex.l" yyeol=TRUE; if((ret=restart() )!=SKIPRESTART)return ret; YY_BREAK case 193: YY_RULE_SETUP #line 315 "avrlex.l" yyeol=TRUE; return endofline(); YY_BREAK case 194: YY_RULE_SETUP #line 316 "avrlex.l" ; YY_BREAK case 195: YY_RULE_SETUP #line 317 "avrlex.l" ; YY_BREAK case 196: YY_RULE_SETUP #line 318 "avrlex.l" ; YY_BREAK case 197: YY_RULE_SETUP #line 319 "avrlex.l" ; YY_BREAK case 198: YY_RULE_SETUP #line 320 "avrlex.l" illegal(); YY_BREAK case 199: YY_RULE_SETUP #line 322 "avrlex.l" ECHO; YY_BREAK #line 1974 "avrlex.cc" case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between yy_current_buffer and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ yy_n_chars = yy_current_buffer->yy_n_chars; yy_current_buffer->yy_input_file = yyin; yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = yy_c_buf_p; goto yy_find_action; } } else switch ( yy_get_next_buffer() ) { case EOB_ACT_END_OF_FILE: { yy_did_buffer_switch_on_eof = 0; if ( yywrap() ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: yy_c_buf_p = &yy_current_buffer->yy_ch_buf[yy_n_chars]; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer() { register char *dest = yy_current_buffer->yy_ch_buf; register char *source = yytext_ptr; register int number_to_move, i; int ret_val; if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( yy_current_buffer->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ yy_current_buffer->yy_n_chars = yy_n_chars = 0; else { int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ #ifdef YY_USES_REJECT YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); #else /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = yy_current_buffer; int yy_c_buf_p_offset = (int) (yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yy_flex_realloc( (void *) b->yy_ch_buf, b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; #endif } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), yy_n_chars, num_to_read ); yy_current_buffer->yy_n_chars = yy_n_chars; } if ( yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; yy_current_buffer->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; yy_n_chars += number_to_move; yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state() { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = yy_start; yy_current_state += YY_AT_BOL(); for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 402 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ #ifdef YY_USE_PROTOS static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) #else static yy_state_type yy_try_NUL_trans( yy_current_state ) yy_state_type yy_current_state; #endif { register int yy_is_jam; register char *yy_cp = yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 402 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 401); return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_UNPUT #ifdef YY_USE_PROTOS static void yyunput( int c, register char *yy_bp ) #else static void yyunput( c, yy_bp ) int c; register char *yy_bp; #endif { register char *yy_cp = yy_c_buf_p; /* undo effects of setting up yytext */ *yy_cp = yy_hold_char; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = yy_n_chars + 2; register char *dest = &yy_current_buffer->yy_ch_buf[ yy_current_buffer->yy_buf_size + 2]; register char *source = &yy_current_buffer->yy_ch_buf[number_to_move]; while ( source > yy_current_buffer->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); yy_current_buffer->yy_n_chars = yy_n_chars = yy_current_buffer->yy_buf_size; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; yytext_ptr = yy_bp; yy_hold_char = *yy_cp; yy_c_buf_p = yy_cp; } #endif /* ifndef YY_NO_UNPUT */ #ifdef __cplusplus static int yyinput() #else static int input() #endif { int c; *yy_c_buf_p = yy_hold_char; if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) /* This was really a NUL. */ *yy_c_buf_p = '\0'; else { /* need more input */ int offset = yy_c_buf_p - yytext_ptr; ++yy_c_buf_p; switch ( yy_get_next_buffer() ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart( yyin ); /* fall through */ case EOB_ACT_END_OF_FILE: { if ( yywrap() ) return EOF; if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + offset; break; } } } c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ *yy_c_buf_p = '\0'; /* preserve yytext */ yy_hold_char = *++yy_c_buf_p; yy_current_buffer->yy_at_bol = (c == '\n'); return c; } #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) #else void yyrestart( input_file ) FILE *input_file; #endif { if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_init_buffer( yy_current_buffer, input_file ); yy_load_buffer_state(); } #ifdef YY_USE_PROTOS void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) #else void yy_switch_to_buffer( new_buffer ) YY_BUFFER_STATE new_buffer; #endif { if ( yy_current_buffer == new_buffer ) return; if ( yy_current_buffer ) { /* Flush out information for old buffer. */ *yy_c_buf_p = yy_hold_char; yy_current_buffer->yy_buf_pos = yy_c_buf_p; yy_current_buffer->yy_n_chars = yy_n_chars; } yy_current_buffer = new_buffer; yy_load_buffer_state(); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yy_did_buffer_switch_on_eof = 1; } #ifdef YY_USE_PROTOS void yy_load_buffer_state( void ) #else void yy_load_buffer_state() #endif { yy_n_chars = yy_current_buffer->yy_n_chars; yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; yyin = yy_current_buffer->yy_input_file; yy_hold_char = *yy_c_buf_p; } #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) #else YY_BUFFER_STATE yy_create_buffer( file, size ) FILE *file; int size; #endif { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer( b, file ); return b; } #ifdef YY_USE_PROTOS void yy_delete_buffer( YY_BUFFER_STATE b ) #else void yy_delete_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; if ( b == yy_current_buffer ) yy_current_buffer = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yy_flex_free( (void *) b->yy_ch_buf ); yy_flex_free( (void *) b ); } #ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE extern int isatty YY_PROTO(( int )); #endif #endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) #else void yy_init_buffer( b, file ) YY_BUFFER_STATE b; FILE *file; #endif { yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; #if YY_ALWAYS_INTERACTIVE b->yy_is_interactive = 1; #else #if YY_NEVER_INTERACTIVE b->yy_is_interactive = 0; #else b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif #endif } #ifdef YY_USE_PROTOS void yy_flush_buffer( YY_BUFFER_STATE b ) #else void yy_flush_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == yy_current_buffer ) yy_load_buffer_state(); } #ifndef YY_NO_SCAN_BUFFER #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) #else YY_BUFFER_STATE yy_scan_buffer( base, size ) char *base; yy_size_t size; #endif { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer( b ); return b; } #endif #ifndef YY_NO_SCAN_STRING #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) #else YY_BUFFER_STATE yy_scan_string( yy_str ) yyconst char *yy_str; #endif { int len; for ( len = 0; yy_str[len]; ++len ) ; return yy_scan_bytes( yy_str, len ); } #endif #ifndef YY_NO_SCAN_BYTES #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) #else YY_BUFFER_STATE yy_scan_bytes( bytes, len ) yyconst char *bytes; int len; #endif { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) yy_flex_alloc( n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < len; ++i ) buf[i] = bytes[i]; buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer( buf, n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #endif #ifndef YY_NO_PUSH_STATE #ifdef YY_USE_PROTOS static void yy_push_state( int new_state ) #else static void yy_push_state( new_state ) int new_state; #endif { if ( yy_start_stack_ptr >= yy_start_stack_depth ) { yy_size_t new_size; yy_start_stack_depth += YY_START_STACK_INCR; new_size = yy_start_stack_depth * sizeof( int ); if ( ! yy_start_stack ) yy_start_stack = (int *) yy_flex_alloc( new_size ); else yy_start_stack = (int *) yy_flex_realloc( (void *) yy_start_stack, new_size ); if ( ! yy_start_stack ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } yy_start_stack[yy_start_stack_ptr++] = YY_START; BEGIN(new_state); } #endif #ifndef YY_NO_POP_STATE static void yy_pop_state() { if ( --yy_start_stack_ptr < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN(yy_start_stack[yy_start_stack_ptr]); } #endif #ifndef YY_NO_TOP_STATE static int yy_top_state() { return yy_start_stack[yy_start_stack_ptr - 1]; } #endif #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif #ifdef YY_USE_PROTOS static void yy_fatal_error( yyconst char msg[] ) #else static void yy_fatal_error( msg ) char msg[]; #endif { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ yytext[yyleng] = yy_hold_char; \ yy_c_buf_p = yytext + n; \ yy_hold_char = *yy_c_buf_p; \ *yy_c_buf_p = '\0'; \ yyleng = n; \ } \ while ( 0 ) /* Internal utility routines. */ #ifndef yytext_ptr #ifdef YY_USE_PROTOS static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) #else static void yy_flex_strncpy( s1, s2, n ) char *s1; yyconst char *s2; int n; #endif { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN #ifdef YY_USE_PROTOS static int yy_flex_strlen( yyconst char *s ) #else static int yy_flex_strlen( s ) yyconst char *s; #endif { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif #ifdef YY_USE_PROTOS static void *yy_flex_alloc( yy_size_t size ) #else static void *yy_flex_alloc( size ) yy_size_t size; #endif { return (void *) malloc( size ); } #ifdef YY_USE_PROTOS static void *yy_flex_realloc( void *ptr, yy_size_t size ) #else static void *yy_flex_realloc( ptr, size ) void *ptr; yy_size_t size; #endif { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } #ifdef YY_USE_PROTOS static void yy_flex_free( void *ptr ) #else static void yy_flex_free( ptr ) void *ptr; #endif { free( ptr ); } #if YY_MAIN int main() { yylex(); return 0; } #endif #line 322 "avrlex.l" ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// /// /// /// Scanner support functions /// /// /// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // // Identifiers // int character(void) { yylval.val.value = 0; yylval.val.valid = FALSE; if(yytext[1]=='\\') { switch (yytext[2]) { case 'n' : yylval.val.value = '\n' ; yylval.val.valid = TRUE; break; case 't' : yylval.val.value = '\t' ; yylval.val.valid = TRUE; break; case 'v' : yylval.val.value = '\v' ; yylval.val.valid = TRUE; break; case 'b' : yylval.val.value = '\b' ; yylval.val.valid = TRUE; break; case 'r' : yylval.val.value = '\r' ; yylval.val.valid = TRUE; break; case 'f' : yylval.val.value = '\f' ; yylval.val.valid = TRUE; break; case 'a' : yylval.val.value = '\a' ; yylval.val.valid = TRUE; break; case '\\' : yylval.val.value = '\\' ; yylval.val.valid = TRUE; break; case '\'' : yylval.val.value = '\'' ; yylval.val.valid = TRUE; break; case '\"' : yylval.val.value = '\"' ; yylval.val.valid = TRUE; break; case '\?' : yylval.val.value = '\?' ; yylval.val.valid = TRUE; break; case 'x' : case 'X' : { if(isdigit(yytext[3])) yylval.val.value = yytext[3] - '0'; else if(isxdigit(yytext[3])) yylval.val.value = tolower(yytext[3]) - 'a' + 10; if(isxdigit(yytext[3]) && isxdigit(yytext[4])) { if(isdigit(yytext[4])) yylval.val.value = 16*yylval.val.value + yytext[4] - '0'; else yylval.val.value = 16*yylval.val.value+tolower(yytext[4])-'a'+10; } yylval.val.valid = TRUE; } break; case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : { yylval.val.value = yytext[2] - '0'; if(isdigit(yytext[3])) { yylval.val.value = 8*yylval.val.value + yytext[3] - '0'; if(isdigit(yytext[4])) yylval.val.value = 8*yylval.val.value + yytext[4] - '0'; } if(yylval.val.value > 0xFF) { yylval.val.value = 0; warningin(W_OCT_OUT_OF_RANGE); } yylval.val.valid = TRUE; } break; default : errorin(E_UNDEF_ESCAPE,yytext); } } else { yylval.val.value = yytext[1]; yylval.val.valid = TRUE; } return INTEGER; } //////////////////////////////////////////////////////////////////////////// // // Identifiers // int identifier(void) { char name[MAX_ID_LENGTH+1]; if(yytext[0] == '_' && yycfg->local_labels) { if(strlen(yytext)+strlen(yylast_used_label)+2>MAX_ID_LENGTH) { size_t len; warningin(W_IDENTIFIER_TOO_LONG); name[0]='@'; memcpy(name+1, yylast_used_label, MAX_ID_LENGTH-1); name[MAX_ID_LENGTH] = '\0'; len = strlen(name); if(len>MAX_ID_LENGTH-9) len = MAX_ID_LENGTH-9; // truncate the last_used_label to leave at least 8 characters for the local label name[len++] = '@'; memcpy(name+len, yytext, MAX_ID_LENGTH-len); name[MAX_ID_LENGTH] = '\0'; } else { sprintf(name, "@%s@%s", yylast_used_label, yytext); } } else { if(strlen(yytext)>MAX_ID_LENGTH) { warningin(W_IDENTIFIER_TOO_LONG); memcpy(name, yytext, MAX_ID_LENGTH); name[MAX_ID_LENGTH] = '\0'; } else strcpy(name, yytext); } yylval.symb = getsym(name); if(yylval.symb -> macro) return macro(yylval.symb); return SYMBOL; } //////////////////////////////////////////////////////////////////////////// // // Registers : r0 - r31 // int registers(void) { int registerno; if(strlen(yytext)==2) { if(isdigit(yytext[1])) registerno= yytext[1] - '0'; else return identifier(); } else if(strlen(yytext)==3) { if(isdigit(yytext[1]) && isdigit(yytext[2]) ) registerno= 10 * (yytext[1] - '0') + yytext[2] - '0'; else return identifier(); } else return identifier(); if(registerno <= 31) { yylval.regid = registerno; return REGISTER; } return identifier(); } //////////////////////////////////////////////////////////////////////////// // // Strings // int string(void) { if( !(yylval.string = new char[strlen(yytext)+1]) ) errorexit(X_OUT_OF_MEMORY); strcpy(yylval.string, yytext); return STRING; } //////////////////////////////////////////////////////////////////////////// // // Integer constants : Decimal=10 Hex=0xA Hex=$A Octal=012 Binaray=0b1010 // int integers(void) { int val; int pos; char temp[12]; bool foundhex = (strpbrk(yytext,"ABCDEFabcdef")!=NULL); bool foundbin = !(strpbrk(yytext,"ACDEFacdef23456789")!=NULL); // Hex : $BABE if(yytext[0] == '$' ) { val = 0; pos = 1; while( yytext[pos] ) { if(isdigit(yytext[pos])) val = 16*val + yytext[pos] - '0'; else val = 16*val + tolower(yytext[pos]) - 'a' + 10; pos++; } if(pos>9) warningin(W_CONSTANT_TO_BIG); } // Hex : 0xBABE or 0XBABE else if( (yytext[0] == '0' ) && (tolower(yytext[1]) == 'x' )) { val = 0; pos = 2; while( yytext[pos] ) { if(isdigit(yytext[pos])) val = 16*val + yytext[pos] - '0'; else val = 16*val + tolower(yytext[pos]) - 'a' + 10; pos++; } if(pos>10) warningin(W_CONSTANT_TO_BIG); } // Bin : 0b01010 or 0B01010 else if( (yytext[0] == '0' ) && (tolower(yytext[1]) == 'b' ) && foundbin) { val = 0; pos = 2; while( yytext[pos] ) val = 2*val + yytext[pos++] - '0'; if(pos>34) warningin(W_CONSTANT_TO_BIG); } // Hex : 1BABE (Hex that starts with a decimal) else if(isdigit(yytext[0]) && foundhex ) { val = 0; pos = 0; while( yytext[pos] ) { if(isdigit(yytext[pos])) val = 16*val + yytext[pos] - '0'; else val = 16*val + tolower(yytext[pos]) - 'a' + 10; pos++; } if(pos>8) warningin(W_CONSTANT_TO_BIG); } // Integer 47806 else { int zp = 0; for(; yytext[zp]=='0' ; zp++); if(!isdigit(yytext[zp]) && (zp>0)) zp--; val = atoi(yytext+zp); sprintf(temp, "%i", val); if(val && strcmp(temp,yytext+zp)) { val = atol(yytext+zp); sprintf(temp, "%u", val); if(strcmp(temp,yytext+zp)) { val = atoi(yytext); warningin(W_CONSTANT_TO_BIG); } } } yylval.val.value = val; yylval.val.valid = TRUE; return INTEGER; } //////////////////////////////////////////////////////////////////////////// // // Illegal character // void illegal(void) { if(isprint(yytext[0])) warningin(W_INVALID_CHAR,yytext[0]); else warningin(W_INVALID_ASCII,(unsigned char)yytext[0]); } //////////////////////////////////////////////////////////////////////////// // // Include file // int includefile(void) { char name[MAX_LINE_LENGTH+2]; char filename[MAX_FILENAME_LENGTH+1]; int c; FILE *f1,*f2; if(strlen(yytext)==strlen(".include")) { yyinput(); endofline(); error(E_NO_FILENAME); return EOL; } /// Check filename //////////////////////////////////////////////////////// if(strlen(yytext) >= MAX_LINE_LENGTH) errorexit(X_LINE_TOO_LONG, yyfilename); strcpy(name,yytext+8+strspn(yytext,"\t\v ") +strspn(yytext+8+strspn(yytext,"\t\v "),"\t\v ")); if(!strlen(name)) { yyinput(); endofline(); error(E_NO_FILENAME); return EOL; } striprem(name); if(!strlen(name)) { yyinput(); endofline(); error(E_NO_FILENAME); return EOL; } /// Read NL (or EOF) ////////////////////////////////////////////////////// yyinput(); endofline(); if( !getfilename(name, filename) ) { error(E_INVALID_FILENAME); return EOL; } /// Check context depth /////////////////////////////////////////////////// if( yycontext == (MAX_CONTEXT_DEPTH-1) ) { errorin(E_INCLUDE_DEPTH, name); return EOL; } if( !(f1 = fopenInIncpath(filename,"r")) ) { error(E_OPEN_FILE, filename); return EOL; } else if( !(f2 = fopenInIncpath(filename,"r")) ) { fclose(f1); error(E_OPEN_FILE, filename); return EOL; } /// Setup context stack /////////////////////////////////////////////////// CONTEXT->file = yyin; CONTEXT->file2 = yyin2; CONTEXT->line = yyline; CONTEXT->offset = yyoffset; CONTEXT->dataoffset = yydataoffset; CONTEXT->eromoffset = yyeromoffset; strcpy(CONTEXT->yyinlineold, yyinlineold); strcpy(CONTEXT->yyinline, yyinline); strcpy(CONTEXT->yyinlinenew, yyinlinenew); statestack[yycontext++] = YY_CURRENT_BUFFER; /// Open input file /////////////////////////////////////////////////////// if(yyfilecount==MAX_FILES) errorexit(X_TOO_MANY_FILES); yyfileno = -1; for(c=0;cfile = f1; yyin2 = CONTEXT->file2 = f2; strcpy(CONTEXT->filename, filename); strcpy(yyfilename, filename); /// Add .include line to log ////////////////////////////////////////////// tolog(); if(!yyinmacro) yyline = 1; else yyline =0; yyline = 1; // XXX /// Read new lines into log buffers /////////////////////////////////////// if(!fgets(yyinline, MAX_LINE_LENGTH, yyin2)) yyinline[0] = 0; if(!fgets(yyinlinenew, MAX_LINE_LENGTH, yyin2)) yyinlinenew[0] = 0; if(strlen(yyinline) == MAX_LINE_LENGTH-1) errorexit(X_LINE_TOO_LONG, yyfilename); if(strlen(yyinlinenew) == MAX_LINE_LENGTH-1) errorexit(X_LINE_TOO_LONG, yyfilename); STRIPNR(yyinlinenew); STRIPNR(yyinline); /// Setup scanner to read from new file /////////////////////////////////// yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); return TRUE; } //////////////////////////////////////////////////////////////////////////// // // End of line // int endofline(void) { int pos; strcpy(yyinlineold, yyinline); strcpy(yyinline, yyinlinenew); if(!ISMACRO) { if(!fgets(yyinlinenew,MAX_LINE_LENGTH,yyin2)) yyinlinenew[0] = '\0'; if(strlen(yyinlinenew)==MAX_LINE_LENGTH-1) errorexit(X_LINE_TOO_LONG, yyfilename); //if(yyinmacro) yyline++; } else { if( (int)strlen(CONTEXT->macstr) > CONTEXT->stringpos) { pos = strcspn(CONTEXT->macstr+CONTEXT->stringpos,"\n"); if(posmacstr+CONTEXT->stringpos, pos); else errorexit(X_MACRO_LINE_TOO_LONG, yyline, yyfilename); yyinlinenew[pos] = 0; CONTEXT->stringpos += pos+1; } else yyinlinenew[0] = 0; } STRIPNR(yyinlinenew); return EOL; } //////////////////////////////////////////////////////////////////////////// // // Restart scanner after first parse, and handle macro/include context // int restart(void) { int c; if(!restartcount++ && !ISMACRO) { strcpy(yyinlineold, yyinline); strcpy(yyinline, yyinlinenew); strcpy(yyinlinenew, "This should never show up"); yyline++; return EOL; } restartcount = 0; if(yycontext) { yy_delete_buffer(YY_CURRENT_BUFFER); yy_switch_to_buffer(statestack[--yycontext]); if( yycontextstack[yycontext+1]->ismacro ) { yyinmacro--; strcpy(yyinlineold, CONTEXT->yyinlineold); strcpy(yyinline, CONTEXT->yyinline); strcpy(yyinlinenew, CONTEXT->yyinlinenew); delete yycontextstack[yycontext+1]->macstr; yysymbolstack[yycontext+1] = NULL; yyoffset = CONTEXT->offset; yydataoffset = CONTEXT->dataoffset; yyeromoffset = CONTEXT->eromoffset; yyline = CONTEXT->line + 1; if(ISMACRO) endofline(); else { if(!fgets(yyinlinenew, MAX_LINE_LENGTH, yyin2)) yyinlinenew[0] = 0; } if(strlen(yyinlinenew) == MAX_LINE_LENGTH-1) errorexit(X_LINE_TOO_LONG, yyfilename); memset(yycontextstack[yycontext+1],0,sizeof(context)); return SKIPRESTART; } else { if(ISMACRO) { for(c=yycontext;c>=0;c--) { if(!yycontextstack[c]->ismacro) { strcpy(yyfilename, yycontextstack[c]->filename); c = -1; } } } else strcpy(yyfilename, CONTEXT->filename); yyline = CONTEXT->line; fclose(yycontextstack[yycontext+1]->file); fclose(yycontextstack[yycontext+1]->file2); yyin = CONTEXT->file; yyin2 = CONTEXT->file2; yyoffset = CONTEXT->offset; yydataoffset = CONTEXT->dataoffset; yyeromoffset = CONTEXT->eromoffset; strcpy(yyinline, CONTEXT->yyinline); strcpy(yyinlinenew, CONTEXT->yyinlinenew); memset(yycontextstack[yycontext+1],0,sizeof(context)); yyfileno = -1; for(c=0;cismacro) { while( ((ch=yyinput())!='\r') && (ch!='\n') && (ch!=EOF) ); errorin(E_MACRO_IN_MACRO); endofline(); return EOL; } /// Allocate buffer /////////////////////////////////////////////////////// if( !(buf1 = new char[bufsize]) ) errorexit(X_OUT_OF_MEMORY); /// Get macro string from input /////////////////////////////////////////// while(!found) { ch = yyinput(); if(tolower(ch)==endmacro[founddot]) founddot++; else founddot=0; if(founddot==4) { found = TRUE; buf1[pos-3] = '\0'; sprintf(yyinlinenew,".endm"); } else if(ch=='\n') { comment = FALSE; temp[temppos] = 0; temppos = 0; if(temptime++) { STRIPNR(temp); strcpy(yyinlinenew, temp); endofline(); tolog(); } } else if(ch==EOF) found = TRUE; else if(ch==';') comment = TRUE; buf1[pos++] = ch; if(ch!='\n') temp[temppos++] = ch; if(pos==bufsize) { buf2 = new char[2*bufsize]; memcpy(buf2, buf1, bufsize); delete buf1; buf1 = buf2; bufsize *=2; } } /// Read until end of .endmacro line ////////////////////////////////////// while( ((ch=yyinput()) != EOF) && (ch!='\n') && (ch!='\r')) yyinlinenew[temppos++] = ch; yyinlinenew[temppos] = 0; strcpy(temp, yyinlinenew); endofline(); tolog(); if((ch==EOF)&&(founddot<4)) { delete buf1; if(strlen(yyinlineold)) yyinlineold[strlen(yyinlineold)-1] = '\0'; STRIPWS(yyinlineold); error(E_EOF_IN_MACRO); return restart(); } /// Process string //////////////////////////////////////////////////////// pos = strlen(buf1); if( pos && !(buf1[pos-1]=='\n') ) strcat(buf1, "\n"); /// Get macro name //////////////////////////////////////////////////////// namestart = strspn(buf1,"\t\v "); nameend = strcspn(buf1+namestart,"\t\v \r\n;")+namestart; memcpy(name, buf1+namestart, nameend-namestart); name[nameend-namestart] = '\0'; /// Setup macro /////////////////////////////////////////////////////////// for(i=yycontext; !yysymbolstack[i]; i--); if(!yyparseno) { if(strlen(name)>MAX_ID_LENGTH) { warningin(W_MAC_IDENTIFIER_TOO_LONG); name[MAX_ID_LENGTH] = '\0'; } if( (symb=yysymbolstack[i]->get(name)) ) { error(E_MACRO_REDEF,name); return EOL; } symb = yysymbolstack[i]->add(name); } else { if(strlen(name)>MAX_ID_LENGTH) { warningin(W_MAC_IDENTIFIER_TOO_LONG); name[MAX_ID_LENGTH] = '\0'; } symb=yysymbolstack[i]->get(name); } if(!symb) internalerror("DM"); if( ISUSED(symb) && ((symb->macdefline != yyline) ||(strcmp(symb->macfilename, yyfilename)) )) { strcpy(yyinlineold,".endmacro"); error(E_MACRO_REDEF,name); } else { // If first parse - allocate space in symbol table for macro if(!yyparseno) { symb -> macro = TRUE; symb -> macsize = strlen(buf1)-nameend; symb -> macdefline = yyline; if( !(symb -> macstr = new char[symb->macsize+2])) errorexit(X_OUT_OF_MEMORY); strcpy(symb->macstr, buf1+nameend); strcpy(symb->macfilename,yyfilename); } // In second parse - check argument usage else if( yyline == symb->macdefline ) { l = symb->macsize; symb -> macrodone = TRUE; while(l) { if( isdigit(symb->macstr[l]) && (symb->macstr[l-1] == '@' ) ) symb->macparmlist[(symb->macstr[l]) -'0'] = 1; l--; } lastparm = -1; for(l=0;l<10;l++) if(symb->macparmlist[l]) lastparm = l; inmacro=yyinmacro; yyinmacro=1; for(l=0;l<=lastparm;l++) if(!symb->macparmlist[l]) warningin(W_MACRO_UNUSES_PARM, l, name); yyinmacro=inmacro; strcpy(yyinlineold, yyinline); strcpy(yyinline, yyinlinenew); } } strcpy(yyinline, temp); endofline(); delete buf1; if(!strlen(name)) error(E_NO_MACRO_NAME); return MACRODEF; } //////////////////////////////////////////////////////////////////////////// // // Insert macro in input stream // int macro(symbolSA symb) { char **parmlist; int c; char line[MAX_LINE_LENGTH+2]; int pos = 0; int parm; int inputparms = 0; int parmpos; int rem; int next; int l; int len; char *str; int res; int ch; char orginline[MAX_LINE_LENGTH+2]; if( (!symb -> macrodone) && (yyparseno) ) { errorin(E_DEF_USE); while(((ch=yyinput())!='\n') && (ch!=EOF) ); endofline(); return EOL; } strcpy(orginline, yyinline); /// Allocate space for parameters ///////////////////////////////////////// if( !(parmlist = new char*[10]) ) errorexit(X_OUT_OF_MEMORY); for(c=0;c<10;c++) { if(!(parmlist[c]= new char [MAX_LINE_LENGTH+1])) errorexit(X_OUT_OF_MEMORY); else memset(parmlist[c], 0, MAX_LINE_LENGTH+1); } /// Get parameters from input ///////////////////////////////////////////// while( ((line[pos]=yyinput())!='\n') && (line[pos++]!=EOF) ); if(pos && (line[pos-1]==EOF) ) line[--pos] = 0; line[pos]=0; line[pos+1]=0; /// Local strtok() that inserts parameters into parameter list //////////// if(pos) { pos = 0; parm = 0; rem = FALSE; striprem(line); while(line[pos] && (parm<10)) { next = FALSE; parmpos = 0; while( (!next) && (line[pos]) ) { if( (line[pos]=='"') || (line[pos]=='\'') ) rem ? rem = FALSE : rem = TRUE; else if( line[pos]=='\\' ) parmlist[parm][parmpos++] = line[pos++]; else if ( (line[pos]==',') && !rem) { parmlist[parm][parmpos] = '\0'; next = TRUE; } parmlist[parm][parmpos++] = line[pos++]; } parm++; } inputparms = parm; /// Clean up parametes (remove leading/trailing whitespaces and ',' //////// for(c=0;c<10;c++) { pos = strlen(parmlist[c]); if(pos) pos--; while( ((parmlist[c][pos]==',')||(isspace(parmlist[c][pos])))&&(pos>=0)) parmlist[c][pos--] = '\0'; if(pos) { l = strspn(parmlist[c], "\t\v "); len = strlen(parmlist[c])-l; if(l) memmove(parmlist[c], parmlist[c]+l,len); parmlist[c][len] = '\0'; } } } /// Check that number of parameters specified, equals the ones used //////// for(c=0;c<10;c++) { if( parmlist[c][0] && !symb->macparmlist[c]) warningin(W_ARG_SPEC, c); else if( !parmlist[c][0] && symb->macparmlist[c]) warningin(W_ARG_USED, c); } /// Insert parameters in macro string ////////////////////////////////////// if(! (str = new char[symb-> macsize + MAX_LINE_LENGTH +5] ) ) errorexit(X_OUT_OF_MEMORY); memset(str,0, symb-> macsize + MAX_LINE_LENGTH +5); pos = 0; parm = 0; res = 0; while( symb->macstr[pos] ) { if( (symb->macstr[pos]=='@') && (isdigit(symb->macstr[pos+1])) ) { parm = symb->macstr[pos+1] - '0'; pos += 2; parmpos = 0; while(parmlist[parm][parmpos]) str[res++] = parmlist[parm][parmpos++]; } else str[res++] = symb->macstr[pos++]; } /// Setup new scanner context ////////////////////////////////////////////// if( yycontext == (MAX_CONTEXT_DEPTH-1) ) { errorexit(X_MACRO_DEPTH); for(c=0;c<10;c++) delete parmlist[c]; delete parmlist; return EOL; } strcpy(yyinlineold, yyinline); strcpy(yyinline, yyinlinenew); strcpy(CONTEXT->yyinlineold, yyinlineold); strcpy(CONTEXT->yyinline, yyinline); strcpy(CONTEXT->yyinlinenew, yyinlinenew); CONTEXT->line = yyline; CONTEXT->offset = yyoffset; CONTEXT->dataoffset = yydataoffset; CONTEXT->eromoffset = yyeromoffset; statestack[yycontext++] = YY_CURRENT_BUFFER; CONTEXT->ismacro = TRUE; CONTEXT->macstr = str; yyoffset = yycodepos/2; yyeromoffset = yyerompos; yydataoffset = yydatapos; memset(yyinlinenew, 0, MAX_LINE_LENGTH); memset(yyinline, 0, MAX_LINE_LENGTH); pos = strcspn(str,"\n") + 1; strcpy(yyinline, symb->name); for(l=0;l= MAX_LINE_LENGTH-1 ) errorexit(X_MACRO_LINE_TOO_LONG, yyline, yyfilename); memcpy(yyinline+strlen(yyinline), str ,pos); CONTEXT->stringpos = strcspn(str+pos,"\n") + 1; memcpy(yyinlinenew, str + pos, CONTEXT->stringpos); CONTEXT->stringpos += pos; strcpy(yyinline, orginline); yyinmacro++; yyfirstmacroline = TRUE; yy_scan_string(str); /// Delete parameter list ////////////////////////////////////////////////// for(c=0;c<10;c++) delete parmlist[c]; delete parmlist; /// Allocate new symbol table ////////////////////////////////////////////// if(!yyparseno) { if(symb -> macsym) yysymbolstack[yycontext] = symb -> macsym; else { if( !(yysymbolstack[yycontext] = symb -> macsym = new symbolTable()) ) errorexit(X_OUT_OF_MEMORY); if( !symb -> macsym->init(yycfg->casesensitive, 16) ) errorexit(X_OUT_OF_MEMORY); } } else yysymbolstack[yycontext] = symb -> macsym; if(!yysymbolstack[yycontext]) internalerror("MA %i", yycontext); // yyline++; return SKIPRESTART; } //////////////////////////////////////////////////////////////////////////// // // Turn listing on/off // void list(int listtype) { switch(listtype) { case LIST_NO : yylist = FALSE; break; case LIST_YES : yylist = TRUE ; break; case LIST_NO_MACRO : yylistmacro = FALSE; break; case LIST_YES_MACRO : yylistmacro = TRUE ; break; default : internalerror("LU %04X",listtype); } } //////////////////////////////////////////////////////////////////////////// // // Read to end of current context // int doexit(void) { while(yyinput()!=EOF); yyeol=TRUE; return restart(); } /// END OF FILE //////////////////////////////////////////////////////////////