File indexing completed on 2024-05-19 12:20:58
0001 #line 2 "cool_lexer.cpp" 0002 0003 #line 4 "cool_lexer.cpp" 0004 0005 #define YY_INT_ALIGNED short int 0006 0007 /* A lexical scanner generated by flex */ 0008 0009 #define FLEX_SCANNER 0010 #define YY_FLEX_MAJOR_VERSION 2 0011 #define YY_FLEX_MINOR_VERSION 5 0012 #define YY_FLEX_SUBMINOR_VERSION 39 0013 #if YY_FLEX_SUBMINOR_VERSION > 0 0014 #define FLEX_BETA 0015 #endif 0016 0017 /* The c++ scanner is a mess. The FlexLexer.h header file relies on the 0018 * following macro. This is required in order to pass the c++-multiple-scanners 0019 * test in the regression suite. We get reports that it breaks inheritance. 0020 * We will address this in a future release of flex, or omit the C++ scanner 0021 * altogether. 0022 */ 0023 #define yyFlexLexer yyFlexLexer 0024 0025 /* First, we deal with platform-specific or compiler-specific issues. */ 0026 0027 /* begin standard C headers. */ 0028 0029 /* end standard C headers. */ 0030 0031 /* flex integer type definitions */ 0032 0033 #ifndef FLEXINT_H 0034 #define FLEXINT_H 0035 0036 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ 0037 0038 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 0039 0040 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, 0041 * if you want the limit (max/min) macros for int types. 0042 */ 0043 #ifndef __STDC_LIMIT_MACROS 0044 #define __STDC_LIMIT_MACROS 1 0045 #endif 0046 0047 #include <inttypes.h> 0048 typedef int8_t flex_int8_t; 0049 typedef uint8_t flex_uint8_t; 0050 typedef int16_t flex_int16_t; 0051 typedef uint16_t flex_uint16_t; 0052 typedef int32_t flex_int32_t; 0053 typedef uint32_t flex_uint32_t; 0054 #else 0055 typedef signed char flex_int8_t; 0056 typedef short int flex_int16_t; 0057 typedef int flex_int32_t; 0058 typedef unsigned char flex_uint8_t; 0059 typedef unsigned short int flex_uint16_t; 0060 typedef unsigned int flex_uint32_t; 0061 0062 /* Limits of integral types. */ 0063 #ifndef INT8_MIN 0064 #define INT8_MIN (-128) 0065 #endif 0066 #ifndef INT16_MIN 0067 #define INT16_MIN (-32767-1) 0068 #endif 0069 #ifndef INT32_MIN 0070 #define INT32_MIN (-2147483647-1) 0071 #endif 0072 #ifndef INT8_MAX 0073 #define INT8_MAX (127) 0074 #endif 0075 #ifndef INT16_MAX 0076 #define INT16_MAX (32767) 0077 #endif 0078 #ifndef INT32_MAX 0079 #define INT32_MAX (2147483647) 0080 #endif 0081 #ifndef UINT8_MAX 0082 #define UINT8_MAX (255U) 0083 #endif 0084 #ifndef UINT16_MAX 0085 #define UINT16_MAX (65535U) 0086 #endif 0087 #ifndef UINT32_MAX 0088 #define UINT32_MAX (4294967295U) 0089 #endif 0090 0091 #endif /* ! C99 */ 0092 0093 #endif /* ! FLEXINT_H */ 0094 0095 /* begin standard C++ headers. */ 0096 #include <iostream> 0097 #include <errno.h> 0098 #include <cstdlib> 0099 #include <cstdio> 0100 #include <cstring> 0101 /* end standard C++ headers. */ 0102 0103 #ifdef __cplusplus 0104 0105 /* The "const" storage-class-modifier is valid. */ 0106 #define YY_USE_CONST 0107 0108 #else /* ! __cplusplus */ 0109 0110 /* C99 requires __STDC__ to be defined as 1. */ 0111 #if defined (__STDC__) 0112 0113 #define YY_USE_CONST 0114 0115 #endif /* defined (__STDC__) */ 0116 #endif /* ! __cplusplus */ 0117 0118 #ifdef YY_USE_CONST 0119 #define yyconst const 0120 #else 0121 #define yyconst 0122 #endif 0123 0124 /* Returned upon end-of-file. */ 0125 #define YY_NULL 0 0126 0127 /* Promotes a possibly negative, possibly signed char to an unsigned 0128 * integer for use as an array index. If the signed char is negative, 0129 * we want to instead treat it as an 8-bit unsigned char, hence the 0130 * double cast. 0131 */ 0132 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) 0133 0134 /* Enter a start condition. This macro really ought to take a parameter, 0135 * but we do it the disgusting crufty way forced on us by the ()-less 0136 * definition of BEGIN. 0137 */ 0138 #define BEGIN (yy_start) = 1 + 2 * 0139 0140 /* Translate the current start state into a value that can be later handed 0141 * to BEGIN to return to the state. The YYSTATE alias is for lex 0142 * compatibility. 0143 */ 0144 #define YY_START (((yy_start) - 1) / 2) 0145 #define YYSTATE YY_START 0146 0147 /* Action number for EOF rule of a given start state. */ 0148 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) 0149 0150 /* Special action meaning "start processing a new file". */ 0151 #define YY_NEW_FILE yyrestart( yyin ) 0152 0153 #define YY_END_OF_BUFFER_CHAR 0 0154 0155 /* Size of default input buffer. */ 0156 #ifndef YY_BUF_SIZE 0157 #define YY_BUF_SIZE 16384 0158 #endif 0159 0160 /* The state buf must be large enough to hold one state per character in the main buffer. 0161 */ 0162 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) 0163 0164 #ifndef YY_TYPEDEF_YY_BUFFER_STATE 0165 #define YY_TYPEDEF_YY_BUFFER_STATE 0166 typedef struct yy_buffer_state *YY_BUFFER_STATE; 0167 #endif 0168 0169 #ifndef YY_TYPEDEF_YY_SIZE_T 0170 #define YY_TYPEDEF_YY_SIZE_T 0171 typedef size_t yy_size_t; 0172 #endif 0173 0174 extern yy_size_t yyleng; 0175 0176 #define EOB_ACT_CONTINUE_SCAN 0 0177 #define EOB_ACT_END_OF_FILE 1 0178 #define EOB_ACT_LAST_MATCH 2 0179 0180 #define YY_LESS_LINENO(n) 0181 #define YY_LINENO_REWIND_TO(ptr) 0182 0183 /* Return all but the first "n" matched characters back to the input stream. */ 0184 #define yyless(n) \ 0185 do \ 0186 { \ 0187 /* Undo effects of setting up yytext. */ \ 0188 int yyless_macro_arg = (n); \ 0189 YY_LESS_LINENO(yyless_macro_arg);\ 0190 *yy_cp = (yy_hold_char); \ 0191 YY_RESTORE_YY_MORE_OFFSET \ 0192 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ 0193 YY_DO_BEFORE_ACTION; /* set up yytext again */ \ 0194 } \ 0195 while ( 0 ) 0196 0197 #define unput(c) yyunput( c, (yytext_ptr) ) 0198 0199 #ifndef YY_STRUCT_YY_BUFFER_STATE 0200 #define YY_STRUCT_YY_BUFFER_STATE 0201 struct yy_buffer_state 0202 { 0203 0204 std::istream* yy_input_file; 0205 0206 char *yy_ch_buf; /* input buffer */ 0207 char *yy_buf_pos; /* current position in input buffer */ 0208 0209 /* Size of input buffer in bytes, not including room for EOB 0210 * characters. 0211 */ 0212 yy_size_t yy_buf_size; 0213 0214 /* Number of characters read into yy_ch_buf, not including EOB 0215 * characters. 0216 */ 0217 yy_size_t yy_n_chars; 0218 0219 /* Whether we "own" the buffer - i.e., we know we created it, 0220 * and can realloc() it to grow it, and should free() it to 0221 * delete it. 0222 */ 0223 int yy_is_our_buffer; 0224 0225 /* Whether this is an "interactive" input source; if so, and 0226 * if we're using stdio for input, then we want to use getc() 0227 * instead of fread(), to make sure we stop fetching input after 0228 * each newline. 0229 */ 0230 int yy_is_interactive; 0231 0232 /* Whether we're considered to be at the beginning of a line. 0233 * If so, '^' rules will be active on the next match, otherwise 0234 * not. 0235 */ 0236 int yy_at_bol; 0237 0238 int yy_bs_lineno; /**< The line count. */ 0239 int yy_bs_column; /**< The column count. */ 0240 0241 /* Whether to try to fill the input buffer when we reach the 0242 * end of it. 0243 */ 0244 int yy_fill_buffer; 0245 0246 int yy_buffer_status; 0247 0248 #define YY_BUFFER_NEW 0 0249 #define YY_BUFFER_NORMAL 1 0250 /* When an EOF's been seen but there's still some text to process 0251 * then we mark the buffer as YY_EOF_PENDING, to indicate that we 0252 * shouldn't try reading from the input source any more. We might 0253 * still have a bunch of tokens to match, though, because of 0254 * possible backing-up. 0255 * 0256 * When we actually see the EOF, we change the status to "new" 0257 * (via yyrestart()), so that the user can continue scanning by 0258 * just pointing yyin at a new input file. 0259 */ 0260 #define YY_BUFFER_EOF_PENDING 2 0261 0262 }; 0263 #endif /* !YY_STRUCT_YY_BUFFER_STATE */ 0264 0265 /* We provide macros for accessing buffer states in case in the 0266 * future we want to put the buffer states in a more general 0267 * "scanner state". 0268 * 0269 * Returns the top of the stack, or NULL. 0270 */ 0271 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ 0272 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ 0273 : NULL) 0274 0275 /* Same as previous macro, but useful when we know that the buffer stack is not 0276 * NULL or when we need an lvalue. For internal use only. 0277 */ 0278 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] 0279 0280 void *yyalloc (yy_size_t ); 0281 void *yyrealloc (void *,yy_size_t ); 0282 void yyfree (void * ); 0283 0284 #define yy_new_buffer yy_create_buffer 0285 0286 #define yy_set_interactive(is_interactive) \ 0287 { \ 0288 if ( ! YY_CURRENT_BUFFER ){ \ 0289 yyensure_buffer_stack (); \ 0290 YY_CURRENT_BUFFER_LVALUE = \ 0291 yy_create_buffer( yyin, YY_BUF_SIZE ); \ 0292 } \ 0293 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ 0294 } 0295 0296 #define yy_set_bol(at_bol) \ 0297 { \ 0298 if ( ! YY_CURRENT_BUFFER ){\ 0299 yyensure_buffer_stack (); \ 0300 YY_CURRENT_BUFFER_LVALUE = \ 0301 yy_create_buffer( yyin, YY_BUF_SIZE ); \ 0302 } \ 0303 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ 0304 } 0305 0306 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) 0307 0308 /* Begin user sect3 */ 0309 #define YY_SKIP_YYWRAP 0310 0311 typedef unsigned char YY_CHAR; 0312 0313 #define yytext_ptr yytext 0314 #define YY_INTERACTIVE 0315 0316 #include <FlexLexer.h> 0317 0318 int yyFlexLexer::yywrap() { return 1; } 0319 int yyFlexLexer::yylex() 0320 { 0321 LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" ); 0322 return 0; 0323 } 0324 0325 #define YY_DECL int cool::Lexer::yylex() 0326 0327 /* Done after the current pattern has been matched and before the 0328 * corresponding action - sets up yytext. 0329 */ 0330 #define YY_DO_BEFORE_ACTION \ 0331 (yytext_ptr) = yy_bp; \ 0332 yyleng = (size_t) (yy_cp - yy_bp); \ 0333 (yy_hold_char) = *yy_cp; \ 0334 *yy_cp = '\0'; \ 0335 (yy_c_buf_p) = yy_cp; 0336 0337 #define YY_NUM_RULES 51 0338 #define YY_END_OF_BUFFER 52 0339 /* This struct is not used in this scanner, 0340 but its presence is necessary. */ 0341 struct yy_trans_info 0342 { 0343 flex_int32_t yy_verify; 0344 flex_int32_t yy_nxt; 0345 }; 0346 static yyconst flex_int16_t yy_accept[116] = 0347 { 0, 0348 0, 0, 0, 0, 52, 50, 1, 1, 50, 7, 0349 8, 17, 15, 12, 16, 13, 18, 49, 22, 11, 0350 21, 19, 14, 47, 47, 48, 48, 48, 48, 48, 0351 48, 48, 48, 48, 48, 48, 9, 10, 25, 6, 0352 5, 6, 1, 0, 46, 0, 3, 2, 49, 23, 0353 20, 24, 47, 47, 48, 48, 48, 48, 48, 48, 0354 36, 34, 35, 48, 48, 48, 48, 48, 41, 48, 0355 48, 48, 48, 4, 2, 47, 48, 48, 48, 48, 0356 48, 48, 48, 38, 48, 40, 26, 48, 48, 48, 0357 48, 47, 28, 48, 32, 29, 48, 48, 48, 39, 0358 0359 42, 43, 44, 48, 31, 30, 33, 48, 48, 45, 0360 48, 27, 48, 37, 0 0361 } ; 0362 0363 static yyconst flex_int32_t yy_ec[256] = 0364 { 0, 0365 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 0366 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0367 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0368 1, 2, 1, 4, 1, 1, 1, 1, 1, 5, 0369 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, 0370 13, 13, 13, 13, 13, 13, 13, 14, 15, 16, 0371 17, 18, 1, 19, 20, 20, 21, 20, 20, 20, 0372 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0373 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0374 1, 22, 1, 1, 23, 1, 24, 23, 25, 26, 0375 0376 27, 28, 23, 29, 30, 23, 23, 31, 23, 32, 0377 33, 34, 23, 35, 36, 37, 38, 39, 40, 23, 0378 23, 23, 41, 1, 42, 43, 1, 1, 1, 1, 0379 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0381 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0382 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0383 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0384 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0385 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0386 0387 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0388 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0389 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0390 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0391 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0392 1, 1, 1, 1, 1 0393 } ; 0394 0395 static yyconst flex_int32_t yy_meta[44] = 0396 { 0, 0397 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 0398 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 0399 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 0400 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0401 1, 1, 1 0402 } ; 0403 0404 static yyconst flex_int16_t yy_base[121] = 0405 { 0, 0406 0, 0, 41, 42, 135, 136, 44, 48, 48, 127, 0407 136, 136, 136, 136, 123, 136, 136, 119, 136, 136, 0408 43, 113, 136, 0, 99, 0, 30, 26, 34, 27, 0409 38, 39, 101, 95, 38, 98, 136, 136, 136, 136, 0410 136, 120, 66, 52, 136, 122, 136, 0, 111, 136, 0411 136, 136, 0, 99, 0, 86, 97, 84, 95, 87, 0412 0, 0, 88, 77, 78, 81, 73, 75, 0, 78, 0413 83, 71, 78, 136, 0, 71, 79, 69, 77, 78, 0414 66, 74, 67, 0, 65, 0, 0, 67, 65, 69, 0415 64, 58, 0, 57, 0, 0, 65, 56, 60, 0, 0416 0417 0, 0, 0, 62, 0, 0, 0, 58, 61, 0, 0418 49, 0, 49, 0, 136, 74, 77, 81, 79, 80 0419 } ; 0420 0421 static yyconst flex_int16_t yy_def[121] = 0422 { 0, 0423 115, 1, 116, 116, 115, 115, 115, 115, 117, 115, 0424 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 0425 115, 115, 115, 118, 118, 119, 119, 119, 119, 119, 0426 119, 119, 119, 119, 119, 119, 115, 115, 115, 115, 0427 115, 115, 115, 117, 115, 117, 115, 120, 115, 115, 0428 115, 115, 118, 118, 119, 119, 119, 119, 119, 119, 0429 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 0430 119, 119, 119, 115, 120, 118, 119, 119, 119, 119, 0431 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 0432 119, 118, 119, 119, 119, 119, 119, 119, 119, 119, 0433 0434 119, 119, 119, 119, 118, 119, 119, 119, 119, 119, 0435 119, 119, 119, 119, 0, 115, 115, 115, 115, 115 0436 } ; 0437 0438 static yyconst flex_int16_t yy_nxt[180] = 0439 { 0, 0440 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0441 16, 17, 18, 19, 20, 21, 22, 6, 23, 24, 0442 25, 6, 26, 26, 27, 26, 28, 29, 26, 30, 0443 31, 32, 33, 34, 26, 26, 35, 26, 26, 36, 0444 37, 38, 39, 41, 41, 43, 43, 42, 42, 43, 0445 43, 45, 50, 56, 62, 45, 58, 60, 63, 51, 0446 57, 59, 64, 61, 65, 67, 71, 43, 43, 46, 0447 66, 68, 72, 46, 40, 40, 40, 44, 44, 44, 0448 75, 55, 75, 53, 114, 113, 112, 111, 110, 109, 0449 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 0450 0451 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 0452 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 0453 78, 77, 76, 49, 115, 74, 73, 70, 69, 54, 0454 52, 49, 48, 47, 115, 5, 115, 115, 115, 115, 0455 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 0456 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 0457 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 0458 115, 115, 115, 115, 115, 115, 115, 115, 115 0459 } ; 0460 0461 static yyconst flex_int16_t yy_chk[180] = 0462 { 0, 0463 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0464 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0465 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0466 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0467 1, 1, 1, 3, 4, 7, 7, 3, 4, 8, 0468 8, 9, 21, 27, 30, 44, 28, 29, 30, 21, 0469 27, 28, 30, 29, 31, 32, 35, 43, 43, 9, 0470 31, 32, 35, 44, 116, 116, 116, 117, 117, 117, 0471 120, 119, 120, 118, 113, 111, 109, 108, 104, 99, 0472 98, 97, 94, 92, 91, 90, 89, 88, 85, 83, 0473 0474 82, 81, 80, 79, 78, 77, 76, 73, 72, 71, 0475 70, 68, 67, 66, 65, 64, 63, 60, 59, 58, 0476 57, 56, 54, 49, 46, 42, 36, 34, 33, 25, 0477 22, 18, 15, 10, 5, 115, 115, 115, 115, 115, 0478 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 0479 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 0480 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 0481 115, 115, 115, 115, 115, 115, 115, 115, 115 0482 } ; 0483 0484 /* The intent behind this definition is that it'll catch 0485 * any uses of REJECT which flex missed. 0486 */ 0487 #define REJECT reject_used_but_not_detected 0488 #define yymore() yymore_used_but_not_detected 0489 #define YY_MORE_ADJ 0 0490 #define YY_RESTORE_YY_MORE_OFFSET 0491 #line 1 "cool_lexer.ll" 0492 #line 8 "cool_lexer.ll" 0493 0494 #define DONT_INCLUDE_FLEXLEXER 0495 #include "cool_lexer.h" 0496 0497 0498 #line 499 "cool_lexer.cpp" 0499 0500 #define INITIAL 0 0501 #define IN_BLOCKCOMMENT 1 0502 0503 #ifndef YY_NO_UNISTD_H 0504 /* Special case for "unistd.h", since it is non-ANSI. We include it way 0505 * down here because we want the user's section 1 to have been scanned first. 0506 * The user has a chance to override it with an option. 0507 */ 0508 #include <unistd.h> 0509 #endif 0510 0511 #ifndef YY_EXTRA_TYPE 0512 #define YY_EXTRA_TYPE void * 0513 #endif 0514 0515 #ifndef yytext_ptr 0516 static void yy_flex_strncpy (char *,yyconst char *,int ); 0517 #endif 0518 0519 #ifdef YY_NEED_STRLEN 0520 static int yy_flex_strlen (yyconst char * ); 0521 #endif 0522 0523 #ifndef YY_NO_INPUT 0524 0525 #endif 0526 0527 /* Amount of stuff to slurp up with each read. */ 0528 #ifndef YY_READ_BUF_SIZE 0529 #define YY_READ_BUF_SIZE 8192 0530 #endif 0531 0532 /* Copy whatever the last rule matched to the standard output. */ 0533 #ifndef ECHO 0534 #define ECHO LexerOutput( yytext, yyleng ) 0535 #endif 0536 0537 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 0538 * is returned in "result". 0539 */ 0540 #ifndef YY_INPUT 0541 #define YY_INPUT(buf,result,max_size) \ 0542 \ 0543 if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ 0544 YY_FATAL_ERROR( "input in flex scanner failed" ); 0545 0546 #endif 0547 0548 /* No semi-colon after return; correct usage is to write "yyterminate();" - 0549 * we don't want an extra ';' after the "return" because that will cause 0550 * some compilers to complain about unreachable statements. 0551 */ 0552 #ifndef yyterminate 0553 #define yyterminate() return YY_NULL 0554 #endif 0555 0556 /* Number of entries by which start-condition stack grows. */ 0557 #ifndef YY_START_STACK_INCR 0558 #define YY_START_STACK_INCR 25 0559 #endif 0560 0561 /* Report a fatal error. */ 0562 #ifndef YY_FATAL_ERROR 0563 #define YY_FATAL_ERROR(msg) LexerError( msg ) 0564 #endif 0565 0566 /* end tables serialization structures and prototypes */ 0567 0568 /* Default declaration of generated scanner - a define so the user can 0569 * easily add parameters. 0570 */ 0571 #ifndef YY_DECL 0572 #define YY_DECL_IS_OURS 1 0573 #define YY_DECL int yyFlexLexer::yylex() 0574 #endif /* !YY_DECL */ 0575 0576 /* Code executed at the beginning of each rule, after yytext and yyleng 0577 * have been set up. 0578 */ 0579 #ifndef YY_USER_ACTION 0580 #define YY_USER_ACTION 0581 #endif 0582 0583 /* Code executed at the end of each rule. */ 0584 #ifndef YY_BREAK 0585 #define YY_BREAK break; 0586 #endif 0587 0588 #define YY_RULE_SETUP \ 0589 YY_USER_ACTION 0590 0591 /** The main scanner function which does all the work. 0592 */ 0593 YY_DECL 0594 { 0595 register yy_state_type yy_current_state; 0596 register char *yy_cp, *yy_bp; 0597 register int yy_act; 0598 0599 if ( !(yy_init) ) 0600 { 0601 (yy_init) = 1; 0602 0603 #ifdef YY_USER_INIT 0604 YY_USER_INIT; 0605 #endif 0606 0607 if ( ! (yy_start) ) 0608 (yy_start) = 1; /* first start state */ 0609 0610 if ( ! yyin ) 0611 yyin = & std::cin; 0612 0613 if ( ! yyout ) 0614 yyout = & std::cout; 0615 0616 if ( ! YY_CURRENT_BUFFER ) { 0617 yyensure_buffer_stack (); 0618 YY_CURRENT_BUFFER_LVALUE = 0619 yy_create_buffer( yyin, YY_BUF_SIZE ); 0620 } 0621 0622 yy_load_buffer_state( ); 0623 } 0624 0625 { 0626 #line 19 "cool_lexer.ll" 0627 0628 0629 /* whitespace, newlines and comments */ 0630 0631 #line 632 "cool_lexer.cpp" 0632 0633 while ( 1 ) /* loops until end-of-file is reached */ 0634 { 0635 yy_cp = (yy_c_buf_p); 0636 0637 /* Support of yytext. */ 0638 *yy_cp = (yy_hold_char); 0639 0640 /* yy_bp points to the position in yy_ch_buf of the start of 0641 * the current run. 0642 */ 0643 yy_bp = yy_cp; 0644 0645 yy_current_state = (yy_start); 0646 yy_match: 0647 do 0648 { 0649 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; 0650 if ( yy_accept[yy_current_state] ) 0651 { 0652 (yy_last_accepting_state) = yy_current_state; 0653 (yy_last_accepting_cpos) = yy_cp; 0654 } 0655 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 0656 { 0657 yy_current_state = (int) yy_def[yy_current_state]; 0658 if ( yy_current_state >= 116 ) 0659 yy_c = yy_meta[(unsigned int) yy_c]; 0660 } 0661 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 0662 ++yy_cp; 0663 } 0664 while ( yy_base[yy_current_state] != 136 ); 0665 0666 yy_find_action: 0667 yy_act = yy_accept[yy_current_state]; 0668 if ( yy_act == 0 ) 0669 { /* have to back up */ 0670 yy_cp = (yy_last_accepting_cpos); 0671 yy_current_state = (yy_last_accepting_state); 0672 yy_act = yy_accept[yy_current_state]; 0673 } 0674 0675 YY_DO_BEFORE_ACTION; 0676 0677 do_action: /* This label is used only to access EOF actions. */ 0678 0679 switch ( yy_act ) 0680 { /* beginning of action switch */ 0681 case 0: /* must back up */ 0682 /* undo the effects of YY_DO_BEFORE_ACTION */ 0683 *yy_cp = (yy_hold_char); 0684 yy_cp = (yy_last_accepting_cpos); 0685 yy_current_state = (yy_last_accepting_state); 0686 goto yy_find_action; 0687 0688 case 1: 0689 /* rule 1 can match eol */ 0690 YY_RULE_SETUP 0691 #line 23 "cool_lexer.ll" 0692 /* skip */ ; 0693 YY_BREAK 0694 case 2: 0695 YY_RULE_SETUP 0696 #line 24 "cool_lexer.ll" 0697 /* line comments, skip */ ; 0698 YY_BREAK 0699 case 3: 0700 YY_RULE_SETUP 0701 #line 26 "cool_lexer.ll" 0702 BEGIN(IN_BLOCKCOMMENT); 0703 YY_BREAK 0704 0705 case 4: 0706 YY_RULE_SETUP 0707 #line 28 "cool_lexer.ll" 0708 BEGIN(INITIAL); 0709 YY_BREAK 0710 case YY_STATE_EOF(IN_BLOCKCOMMENT): 0711 #line 29 "cool_lexer.ll" 0712 return cool::Parser::Token_EOF; 0713 YY_BREAK 0714 case 5: 0715 /* rule 5 can match eol */ 0716 YY_RULE_SETUP 0717 #line 30 "cool_lexer.ll" 0718 /* skip */ ; 0719 YY_BREAK 0720 case 6: 0721 YY_RULE_SETUP 0722 #line 31 "cool_lexer.ll" 0723 /* skip */ ; 0724 YY_BREAK 0725 0726 /* seperators */ 0727 case 7: 0728 YY_RULE_SETUP 0729 #line 37 "cool_lexer.ll" 0730 return cool::Parser::Token_LPAREN; 0731 YY_BREAK 0732 case 8: 0733 YY_RULE_SETUP 0734 #line 38 "cool_lexer.ll" 0735 return cool::Parser::Token_RPAREN; 0736 YY_BREAK 0737 case 9: 0738 YY_RULE_SETUP 0739 #line 39 "cool_lexer.ll" 0740 return cool::Parser::Token_LBRACE; 0741 YY_BREAK 0742 case 10: 0743 YY_RULE_SETUP 0744 #line 40 "cool_lexer.ll" 0745 return cool::Parser::Token_RBRACE; 0746 YY_BREAK 0747 case 11: 0748 YY_RULE_SETUP 0749 #line 41 "cool_lexer.ll" 0750 return cool::Parser::Token_SEMICOLON; 0751 YY_BREAK 0752 case 12: 0753 YY_RULE_SETUP 0754 #line 42 "cool_lexer.ll" 0755 return cool::Parser::Token_COMMA; 0756 YY_BREAK 0757 case 13: 0758 YY_RULE_SETUP 0759 #line 43 "cool_lexer.ll" 0760 return cool::Parser::Token_DOT; 0761 YY_BREAK 0762 case 14: 0763 YY_RULE_SETUP 0764 #line 44 "cool_lexer.ll" 0765 return cool::Parser::Token_AT; 0766 YY_BREAK 0767 /* operators */ 0768 case 15: 0769 YY_RULE_SETUP 0770 #line 49 "cool_lexer.ll" 0771 return cool::Parser::Token_PLUS; 0772 YY_BREAK 0773 case 16: 0774 YY_RULE_SETUP 0775 #line 50 "cool_lexer.ll" 0776 return cool::Parser::Token_MINUS; 0777 YY_BREAK 0778 case 17: 0779 YY_RULE_SETUP 0780 #line 51 "cool_lexer.ll" 0781 return cool::Parser::Token_STAR; 0782 YY_BREAK 0783 case 18: 0784 YY_RULE_SETUP 0785 #line 52 "cool_lexer.ll" 0786 return cool::Parser::Token_SLASH; 0787 YY_BREAK 0788 case 19: 0789 YY_RULE_SETUP 0790 #line 53 "cool_lexer.ll" 0791 return cool::Parser::Token_EQUAL; 0792 YY_BREAK 0793 case 20: 0794 YY_RULE_SETUP 0795 #line 54 "cool_lexer.ll" 0796 return cool::Parser::Token_LESS_EQUAL; 0797 YY_BREAK 0798 case 21: 0799 YY_RULE_SETUP 0800 #line 55 "cool_lexer.ll" 0801 return cool::Parser::Token_LESS; 0802 YY_BREAK 0803 case 22: 0804 YY_RULE_SETUP 0805 #line 56 "cool_lexer.ll" 0806 return cool::Parser::Token_COLON; 0807 YY_BREAK 0808 case 23: 0809 YY_RULE_SETUP 0810 #line 57 "cool_lexer.ll" 0811 return cool::Parser::Token_ARROW_LEFT; 0812 YY_BREAK 0813 case 24: 0814 YY_RULE_SETUP 0815 #line 58 "cool_lexer.ll" 0816 return cool::Parser::Token_ARROW_RIGHT; 0817 YY_BREAK 0818 case 25: 0819 YY_RULE_SETUP 0820 #line 59 "cool_lexer.ll" 0821 return cool::Parser::Token_TILDE; 0822 YY_BREAK 0823 case 26: 0824 YY_RULE_SETUP 0825 #line 60 "cool_lexer.ll" 0826 return cool::Parser::Token_NOT; 0827 YY_BREAK 0828 case 27: 0829 YY_RULE_SETUP 0830 #line 61 "cool_lexer.ll" 0831 return cool::Parser::Token_ISVOID; 0832 YY_BREAK 0833 /* reserved words */ 0834 case 28: 0835 YY_RULE_SETUP 0836 #line 66 "cool_lexer.ll" 0837 return cool::Parser::Token_CASE; 0838 YY_BREAK 0839 case 29: 0840 YY_RULE_SETUP 0841 #line 67 "cool_lexer.ll" 0842 return cool::Parser::Token_ESAC; 0843 YY_BREAK 0844 case 30: 0845 YY_RULE_SETUP 0846 #line 68 "cool_lexer.ll" 0847 return cool::Parser::Token_CLASS; 0848 YY_BREAK 0849 case 31: 0850 YY_RULE_SETUP 0851 #line 69 "cool_lexer.ll" 0852 return cool::Parser::Token_CLASS; 0853 YY_BREAK 0854 case 32: 0855 YY_RULE_SETUP 0856 #line 70 "cool_lexer.ll" 0857 return cool::Parser::Token_ELSE; 0858 YY_BREAK 0859 case 33: 0860 YY_RULE_SETUP 0861 #line 71 "cool_lexer.ll" 0862 return cool::Parser::Token_FALSE; 0863 YY_BREAK 0864 case 34: 0865 YY_RULE_SETUP 0866 #line 72 "cool_lexer.ll" 0867 return cool::Parser::Token_IF; 0868 YY_BREAK 0869 case 35: 0870 YY_RULE_SETUP 0871 #line 73 "cool_lexer.ll" 0872 return cool::Parser::Token_IN; 0873 YY_BREAK 0874 case 36: 0875 YY_RULE_SETUP 0876 #line 74 "cool_lexer.ll" 0877 return cool::Parser::Token_FI; 0878 YY_BREAK 0879 case 37: 0880 YY_RULE_SETUP 0881 #line 75 "cool_lexer.ll" 0882 return cool::Parser::Token_INHERITS; 0883 YY_BREAK 0884 case 38: 0885 YY_RULE_SETUP 0886 #line 76 "cool_lexer.ll" 0887 return cool::Parser::Token_LET; 0888 YY_BREAK 0889 case 39: 0890 YY_RULE_SETUP 0891 #line 77 "cool_lexer.ll" 0892 return cool::Parser::Token_LOOP; 0893 YY_BREAK 0894 case 40: 0895 YY_RULE_SETUP 0896 #line 78 "cool_lexer.ll" 0897 return cool::Parser::Token_NEW; 0898 YY_BREAK 0899 case 41: 0900 YY_RULE_SETUP 0901 #line 79 "cool_lexer.ll" 0902 return cool::Parser::Token_OF; 0903 YY_BREAK 0904 case 42: 0905 YY_RULE_SETUP 0906 #line 80 "cool_lexer.ll" 0907 return cool::Parser::Token_POOL; 0908 YY_BREAK 0909 case 43: 0910 YY_RULE_SETUP 0911 #line 81 "cool_lexer.ll" 0912 return cool::Parser::Token_THEN; 0913 YY_BREAK 0914 case 44: 0915 YY_RULE_SETUP 0916 #line 82 "cool_lexer.ll" 0917 return cool::Parser::Token_TRUE; 0918 YY_BREAK 0919 case 45: 0920 YY_RULE_SETUP 0921 #line 83 "cool_lexer.ll" 0922 return cool::Parser::Token_WHILE; 0923 YY_BREAK 0924 /* literals */ 0925 case 46: 0926 /* rule 46 can match eol */ 0927 YY_RULE_SETUP 0928 #line 88 "cool_lexer.ll" 0929 return cool::Parser::Token_STRING; 0930 YY_BREAK 0931 case 47: 0932 YY_RULE_SETUP 0933 #line 90 "cool_lexer.ll" 0934 return cool::Parser::Token_TYPE; 0935 YY_BREAK 0936 case 48: 0937 YY_RULE_SETUP 0938 #line 91 "cool_lexer.ll" 0939 return cool::Parser::Token_IDENTIFIER; 0940 YY_BREAK 0941 case 49: 0942 YY_RULE_SETUP 0943 #line 92 "cool_lexer.ll" 0944 return cool::Parser::Token_INTEGER; 0945 YY_BREAK 0946 /* everything else is not a valid lexeme */ 0947 case 50: 0948 YY_RULE_SETUP 0949 #line 97 "cool_lexer.ll" 0950 return cool::Parser::Token_INVALID; 0951 YY_BREAK 0952 case 51: 0953 YY_RULE_SETUP 0954 #line 99 "cool_lexer.ll" 0955 ECHO; 0956 YY_BREAK 0957 #line 958 "cool_lexer.cpp" 0958 case YY_STATE_EOF(INITIAL): 0959 yyterminate(); 0960 0961 case YY_END_OF_BUFFER: 0962 { 0963 /* Amount of text matched not including the EOB char. */ 0964 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; 0965 0966 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 0967 *yy_cp = (yy_hold_char); 0968 YY_RESTORE_YY_MORE_OFFSET 0969 0970 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) 0971 { 0972 /* We're scanning a new file or input source. It's 0973 * possible that this happened because the user 0974 * just pointed yyin at a new source and called 0975 * yylex(). If so, then we have to assure 0976 * consistency between YY_CURRENT_BUFFER and our 0977 * globals. Here is the right place to do so, because 0978 * this is the first action (other than possibly a 0979 * back-up) that will match for the new input source. 0980 */ 0981 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 0982 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; 0983 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; 0984 } 0985 0986 /* Note that here we test for yy_c_buf_p "<=" to the position 0987 * of the first EOB in the buffer, since yy_c_buf_p will 0988 * already have been incremented past the NUL character 0989 * (since all states make transitions on EOB to the 0990 * end-of-buffer state). Contrast this with the test 0991 * in input(). 0992 */ 0993 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 0994 { /* This was really a NUL. */ 0995 yy_state_type yy_next_state; 0996 0997 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; 0998 0999 yy_current_state = yy_get_previous_state( ); 1000 1001 /* Okay, we're now positioned to make the NUL 1002 * transition. We couldn't have 1003 * yy_get_previous_state() go ahead and do it 1004 * for us because it doesn't know how to deal 1005 * with the possibility of jamming (and we don't 1006 * want to build jamming into it because then it 1007 * will run more slowly). 1008 */ 1009 1010 yy_next_state = yy_try_NUL_trans( yy_current_state ); 1011 1012 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1013 1014 if ( yy_next_state ) 1015 { 1016 /* Consume the NUL. */ 1017 yy_cp = ++(yy_c_buf_p); 1018 yy_current_state = yy_next_state; 1019 goto yy_match; 1020 } 1021 1022 else 1023 { 1024 yy_cp = (yy_c_buf_p); 1025 goto yy_find_action; 1026 } 1027 } 1028 1029 else switch ( yy_get_next_buffer( ) ) 1030 { 1031 case EOB_ACT_END_OF_FILE: 1032 { 1033 (yy_did_buffer_switch_on_eof) = 0; 1034 1035 if ( yywrap( ) ) 1036 { 1037 /* Note: because we've taken care in 1038 * yy_get_next_buffer() to have set up 1039 * yytext, we can now set up 1040 * yy_c_buf_p so that if some total 1041 * hoser (like flex itself) wants to 1042 * call the scanner after we return the 1043 * YY_NULL, it'll still work - another 1044 * YY_NULL will get returned. 1045 */ 1046 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; 1047 1048 yy_act = YY_STATE_EOF(YY_START); 1049 goto do_action; 1050 } 1051 1052 else 1053 { 1054 if ( ! (yy_did_buffer_switch_on_eof) ) 1055 YY_NEW_FILE; 1056 } 1057 break; 1058 } 1059 1060 case EOB_ACT_CONTINUE_SCAN: 1061 (yy_c_buf_p) = 1062 (yytext_ptr) + yy_amount_of_matched_text; 1063 1064 yy_current_state = yy_get_previous_state( ); 1065 1066 yy_cp = (yy_c_buf_p); 1067 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1068 goto yy_match; 1069 1070 case EOB_ACT_LAST_MATCH: 1071 (yy_c_buf_p) = 1072 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; 1073 1074 yy_current_state = yy_get_previous_state( ); 1075 1076 yy_cp = (yy_c_buf_p); 1077 yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1078 goto yy_find_action; 1079 } 1080 break; 1081 } 1082 1083 default: 1084 YY_FATAL_ERROR( 1085 "fatal flex scanner internal error--no action found" ); 1086 } /* end of action switch */ 1087 } /* end of scanning one token */ 1088 } /* end of user's declarations */ 1089 } /* end of yylex */ 1090 1091 /* The contents of this function are C++ specific, so the () macro is not used. 1092 */ 1093 yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) 1094 { 1095 yyin = arg_yyin; 1096 yyout = arg_yyout; 1097 yy_c_buf_p = 0; 1098 yy_init = 0; 1099 yy_start = 0; 1100 yy_flex_debug = 0; 1101 yylineno = 1; // this will only get updated if %option yylineno 1102 1103 yy_did_buffer_switch_on_eof = 0; 1104 1105 yy_looking_for_trail_begin = 0; 1106 yy_more_flag = 0; 1107 yy_more_len = 0; 1108 yy_more_offset = yy_prev_more_offset = 0; 1109 1110 yy_start_stack_ptr = yy_start_stack_depth = 0; 1111 yy_start_stack = NULL; 1112 1113 yy_buffer_stack = 0; 1114 yy_buffer_stack_top = 0; 1115 yy_buffer_stack_max = 0; 1116 1117 yy_state_buf = 0; 1118 1119 } 1120 1121 /* The contents of this function are C++ specific, so the () macro is not used. 1122 */ 1123 yyFlexLexer::~yyFlexLexer() 1124 { 1125 delete [] yy_state_buf; 1126 yyfree(yy_start_stack ); 1127 yy_delete_buffer( YY_CURRENT_BUFFER ); 1128 yyfree(yy_buffer_stack ); 1129 } 1130 1131 /* The contents of this function are C++ specific, so the () macro is not used. 1132 */ 1133 void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) 1134 { 1135 if ( new_in ) 1136 { 1137 yy_delete_buffer( YY_CURRENT_BUFFER ); 1138 yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); 1139 } 1140 1141 if ( new_out ) 1142 yyout = new_out; 1143 } 1144 1145 #ifdef YY_INTERACTIVE 1146 int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) 1147 #else 1148 int yyFlexLexer::LexerInput( char* buf, int max_size ) 1149 #endif 1150 { 1151 if ( yyin->eof() || yyin->fail() ) 1152 return 0; 1153 1154 #ifdef YY_INTERACTIVE 1155 yyin->get( buf[0] ); 1156 1157 if ( yyin->eof() ) 1158 return 0; 1159 1160 if ( yyin->bad() ) 1161 return -1; 1162 1163 return 1; 1164 1165 #else 1166 (void) yyin->read( buf, max_size ); 1167 1168 if ( yyin->bad() ) 1169 return -1; 1170 else 1171 return yyin->gcount(); 1172 #endif 1173 } 1174 1175 void yyFlexLexer::LexerOutput( const char* buf, int size ) 1176 { 1177 (void) yyout->write( buf, size ); 1178 } 1179 1180 /* yy_get_next_buffer - try to read in a new buffer 1181 * 1182 * Returns a code representing an action: 1183 * EOB_ACT_LAST_MATCH - 1184 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position 1185 * EOB_ACT_END_OF_FILE - end of file 1186 */ 1187 int yyFlexLexer::yy_get_next_buffer() 1188 { 1189 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 1190 register char *source = (yytext_ptr); 1191 register int number_to_move, i; 1192 int ret_val; 1193 1194 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) 1195 YY_FATAL_ERROR( 1196 "fatal flex scanner internal error--end of buffer missed" ); 1197 1198 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) 1199 { /* Don't try to fill the buffer, so this is an EOF. */ 1200 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) 1201 { 1202 /* We matched a single character, the EOB, so 1203 * treat this as a final EOF. 1204 */ 1205 return EOB_ACT_END_OF_FILE; 1206 } 1207 1208 else 1209 { 1210 /* We matched some text prior to the EOB, first 1211 * process it. 1212 */ 1213 return EOB_ACT_LAST_MATCH; 1214 } 1215 } 1216 1217 /* Try to read more data. */ 1218 1219 /* First move last chars to start of buffer. */ 1220 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; 1221 1222 for ( i = 0; i < number_to_move; ++i ) 1223 *(dest++) = *(source++); 1224 1225 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1226 /* don't do the read, it's not guaranteed to return an EOF, 1227 * just force an EOF 1228 */ 1229 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; 1230 1231 else 1232 { 1233 yy_size_t num_to_read = 1234 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; 1235 1236 while ( num_to_read <= 0 ) 1237 { /* Not enough room in the buffer - grow it. */ 1238 1239 /* just a shorter name for the current buffer */ 1240 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; 1241 1242 int yy_c_buf_p_offset = 1243 (int) ((yy_c_buf_p) - b->yy_ch_buf); 1244 1245 if ( b->yy_is_our_buffer ) 1246 { 1247 yy_size_t new_size = b->yy_buf_size * 2; 1248 1249 if ( new_size <= 0 ) 1250 b->yy_buf_size += b->yy_buf_size / 8; 1251 else 1252 b->yy_buf_size *= 2; 1253 1254 b->yy_ch_buf = (char *) 1255 /* Include room in for 2 EOB chars. */ 1256 yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); 1257 } 1258 else 1259 /* Can't grow it, we don't own it. */ 1260 b->yy_ch_buf = 0; 1261 1262 if ( ! b->yy_ch_buf ) 1263 YY_FATAL_ERROR( 1264 "fatal error - scanner input buffer overflow" ); 1265 1266 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; 1267 1268 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - 1269 number_to_move - 1; 1270 1271 } 1272 1273 if ( num_to_read > YY_READ_BUF_SIZE ) 1274 num_to_read = YY_READ_BUF_SIZE; 1275 1276 /* Read in more data. */ 1277 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), 1278 (yy_n_chars), num_to_read ); 1279 1280 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1281 } 1282 1283 if ( (yy_n_chars) == 0 ) 1284 { 1285 if ( number_to_move == YY_MORE_ADJ ) 1286 { 1287 ret_val = EOB_ACT_END_OF_FILE; 1288 yyrestart( yyin ); 1289 } 1290 1291 else 1292 { 1293 ret_val = EOB_ACT_LAST_MATCH; 1294 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = 1295 YY_BUFFER_EOF_PENDING; 1296 } 1297 } 1298 1299 else 1300 ret_val = EOB_ACT_CONTINUE_SCAN; 1301 1302 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { 1303 /* Extend the array by 50%, plus the number we really need. */ 1304 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); 1305 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); 1306 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1307 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); 1308 } 1309 1310 (yy_n_chars) += number_to_move; 1311 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; 1312 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; 1313 1314 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; 1315 1316 return ret_val; 1317 } 1318 1319 /* yy_get_previous_state - get the state just before the EOB char was reached */ 1320 1321 yy_state_type yyFlexLexer::yy_get_previous_state() 1322 { 1323 register yy_state_type yy_current_state; 1324 register char *yy_cp; 1325 1326 yy_current_state = (yy_start); 1327 1328 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) 1329 { 1330 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); 1331 if ( yy_accept[yy_current_state] ) 1332 { 1333 (yy_last_accepting_state) = yy_current_state; 1334 (yy_last_accepting_cpos) = yy_cp; 1335 } 1336 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1337 { 1338 yy_current_state = (int) yy_def[yy_current_state]; 1339 if ( yy_current_state >= 116 ) 1340 yy_c = yy_meta[(unsigned int) yy_c]; 1341 } 1342 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1343 } 1344 1345 return yy_current_state; 1346 } 1347 1348 /* yy_try_NUL_trans - try to make a transition on the NUL character 1349 * 1350 * synopsis 1351 * next_state = yy_try_NUL_trans( current_state ); 1352 */ 1353 yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) 1354 { 1355 register int yy_is_jam; 1356 register char *yy_cp = (yy_c_buf_p); 1357 1358 register YY_CHAR yy_c = 1; 1359 if ( yy_accept[yy_current_state] ) 1360 { 1361 (yy_last_accepting_state) = yy_current_state; 1362 (yy_last_accepting_cpos) = yy_cp; 1363 } 1364 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1365 { 1366 yy_current_state = (int) yy_def[yy_current_state]; 1367 if ( yy_current_state >= 116 ) 1368 yy_c = yy_meta[(unsigned int) yy_c]; 1369 } 1370 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1371 yy_is_jam = (yy_current_state == 115); 1372 1373 return yy_is_jam ? 0 : yy_current_state; 1374 } 1375 1376 void yyFlexLexer::yyunput( int c, register char* yy_bp) 1377 { 1378 register char *yy_cp; 1379 1380 yy_cp = (yy_c_buf_p); 1381 1382 /* undo effects of setting up yytext */ 1383 *yy_cp = (yy_hold_char); 1384 1385 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) 1386 { /* need to shift things up to make room */ 1387 /* +2 for EOB chars. */ 1388 register yy_size_t number_to_move = (yy_n_chars) + 2; 1389 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ 1390 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; 1391 register char *source = 1392 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; 1393 1394 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1395 *--dest = *--source; 1396 1397 yy_cp += (int) (dest - source); 1398 yy_bp += (int) (dest - source); 1399 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = 1400 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; 1401 1402 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) 1403 YY_FATAL_ERROR( "flex scanner push-back overflow" ); 1404 } 1405 1406 *--yy_cp = (char) c; 1407 1408 (yytext_ptr) = yy_bp; 1409 (yy_hold_char) = *yy_cp; 1410 (yy_c_buf_p) = yy_cp; 1411 } 1412 1413 int yyFlexLexer::yyinput() 1414 { 1415 int c; 1416 1417 *(yy_c_buf_p) = (yy_hold_char); 1418 1419 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) 1420 { 1421 /* yy_c_buf_p now points to the character we want to return. 1422 * If this occurs *before* the EOB characters, then it's a 1423 * valid NUL; if not, then we've hit the end of the buffer. 1424 */ 1425 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 1426 /* This was really a NUL. */ 1427 *(yy_c_buf_p) = '\0'; 1428 1429 else 1430 { /* need more input */ 1431 yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); 1432 ++(yy_c_buf_p); 1433 1434 switch ( yy_get_next_buffer( ) ) 1435 { 1436 case EOB_ACT_LAST_MATCH: 1437 /* This happens because yy_g_n_b() 1438 * sees that we've accumulated a 1439 * token and flags that we need to 1440 * try matching the token before 1441 * proceeding. But for input(), 1442 * there's no matching to consider. 1443 * So convert the EOB_ACT_LAST_MATCH 1444 * to EOB_ACT_END_OF_FILE. 1445 */ 1446 1447 /* Reset buffer status. */ 1448 yyrestart( yyin ); 1449 1450 /*FALLTHROUGH*/ 1451 1452 case EOB_ACT_END_OF_FILE: 1453 { 1454 if ( yywrap( ) ) 1455 return EOF; 1456 1457 if ( ! (yy_did_buffer_switch_on_eof) ) 1458 YY_NEW_FILE; 1459 #ifdef __cplusplus 1460 return yyinput(); 1461 #else 1462 return input(); 1463 #endif 1464 } 1465 1466 case EOB_ACT_CONTINUE_SCAN: 1467 (yy_c_buf_p) = (yytext_ptr) + offset; 1468 break; 1469 } 1470 } 1471 } 1472 1473 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ 1474 *(yy_c_buf_p) = '\0'; /* preserve yytext */ 1475 (yy_hold_char) = *++(yy_c_buf_p); 1476 1477 return c; 1478 } 1479 1480 /** Immediately switch to a different input stream. 1481 * @param input_file A readable stream. 1482 * 1483 * @note This function does not reset the start condition to @c INITIAL . 1484 */ 1485 void yyFlexLexer::yyrestart( std::istream* input_file ) 1486 { 1487 1488 if ( ! YY_CURRENT_BUFFER ){ 1489 yyensure_buffer_stack (); 1490 YY_CURRENT_BUFFER_LVALUE = 1491 yy_create_buffer( yyin, YY_BUF_SIZE ); 1492 } 1493 1494 yy_init_buffer( YY_CURRENT_BUFFER, input_file ); 1495 yy_load_buffer_state( ); 1496 } 1497 1498 /** Switch to a different input buffer. 1499 * @param new_buffer The new input buffer. 1500 * 1501 */ 1502 void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) 1503 { 1504 1505 /* TODO. We should be able to replace this entire function body 1506 * with 1507 * yypop_buffer_state(); 1508 * yypush_buffer_state(new_buffer); 1509 */ 1510 yyensure_buffer_stack (); 1511 if ( YY_CURRENT_BUFFER == new_buffer ) 1512 return; 1513 1514 if ( YY_CURRENT_BUFFER ) 1515 { 1516 /* Flush out information for old buffer. */ 1517 *(yy_c_buf_p) = (yy_hold_char); 1518 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 1519 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1520 } 1521 1522 YY_CURRENT_BUFFER_LVALUE = new_buffer; 1523 yy_load_buffer_state( ); 1524 1525 /* We don't actually know whether we did this switch during 1526 * EOF (yywrap()) processing, but the only time this flag 1527 * is looked at is after yywrap() is called, so it's safe 1528 * to go ahead and always set it. 1529 */ 1530 (yy_did_buffer_switch_on_eof) = 1; 1531 } 1532 1533 void yyFlexLexer::yy_load_buffer_state() 1534 { 1535 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 1536 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; 1537 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; 1538 (yy_hold_char) = *(yy_c_buf_p); 1539 } 1540 1541 /** Allocate and initialize an input buffer state. 1542 * @param file A readable stream. 1543 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. 1544 * 1545 * @return the allocated buffer state. 1546 */ 1547 YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) 1548 { 1549 YY_BUFFER_STATE b; 1550 1551 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); 1552 if ( ! b ) 1553 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1554 1555 b->yy_buf_size = size; 1556 1557 /* yy_ch_buf has to be 2 characters longer than the size given because 1558 * we need to put in 2 end-of-buffer characters. 1559 */ 1560 b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); 1561 if ( ! b->yy_ch_buf ) 1562 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1563 1564 b->yy_is_our_buffer = 1; 1565 1566 yy_init_buffer( b, file ); 1567 1568 return b; 1569 } 1570 1571 /** Destroy the buffer. 1572 * @param b a buffer created with yy_create_buffer() 1573 * 1574 */ 1575 void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) 1576 { 1577 1578 if ( ! b ) 1579 return; 1580 1581 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ 1582 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; 1583 1584 if ( b->yy_is_our_buffer ) 1585 yyfree((void *) b->yy_ch_buf ); 1586 1587 yyfree((void *) b ); 1588 } 1589 1590 /* Initializes or reinitializes a buffer. 1591 * This function is sometimes called more than once on the same buffer, 1592 * such as during a yyrestart() or at EOF. 1593 */ 1594 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) 1595 1596 { 1597 int oerrno = errno; 1598 1599 yy_flush_buffer( b ); 1600 1601 b->yy_input_file = file; 1602 b->yy_fill_buffer = 1; 1603 1604 /* If b is the current buffer, then yy_init_buffer was _probably_ 1605 * called from yyrestart() or through yy_get_next_buffer. 1606 * In that case, we don't want to reset the lineno or column. 1607 */ 1608 if (b != YY_CURRENT_BUFFER){ 1609 b->yy_bs_lineno = 1; 1610 b->yy_bs_column = 0; 1611 } 1612 1613 b->yy_is_interactive = 0; 1614 errno = oerrno; 1615 } 1616 1617 /** Discard all buffered characters. On the next scan, YY_INPUT will be called. 1618 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. 1619 * 1620 */ 1621 void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) 1622 { 1623 if ( ! b ) 1624 return; 1625 1626 b->yy_n_chars = 0; 1627 1628 /* We always need two end-of-buffer characters. The first causes 1629 * a transition to the end-of-buffer state. The second causes 1630 * a jam in that state. 1631 */ 1632 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; 1633 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; 1634 1635 b->yy_buf_pos = &b->yy_ch_buf[0]; 1636 1637 b->yy_at_bol = 1; 1638 b->yy_buffer_status = YY_BUFFER_NEW; 1639 1640 if ( b == YY_CURRENT_BUFFER ) 1641 yy_load_buffer_state( ); 1642 } 1643 1644 /** Pushes the new state onto the stack. The new state becomes 1645 * the current state. This function will allocate the stack 1646 * if necessary. 1647 * @param new_buffer The new state. 1648 * 1649 */ 1650 void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) 1651 { 1652 if (new_buffer == NULL) 1653 return; 1654 1655 yyensure_buffer_stack(); 1656 1657 /* This block is copied from yy_switch_to_buffer. */ 1658 if ( YY_CURRENT_BUFFER ) 1659 { 1660 /* Flush out information for old buffer. */ 1661 *(yy_c_buf_p) = (yy_hold_char); 1662 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 1663 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1664 } 1665 1666 /* Only push if top exists. Otherwise, replace top. */ 1667 if (YY_CURRENT_BUFFER) 1668 (yy_buffer_stack_top)++; 1669 YY_CURRENT_BUFFER_LVALUE = new_buffer; 1670 1671 /* copied from yy_switch_to_buffer. */ 1672 yy_load_buffer_state( ); 1673 (yy_did_buffer_switch_on_eof) = 1; 1674 } 1675 1676 /** Removes and deletes the top of the stack, if present. 1677 * The next element becomes the new top. 1678 * 1679 */ 1680 void yyFlexLexer::yypop_buffer_state (void) 1681 { 1682 if (!YY_CURRENT_BUFFER) 1683 return; 1684 1685 yy_delete_buffer(YY_CURRENT_BUFFER ); 1686 YY_CURRENT_BUFFER_LVALUE = NULL; 1687 if ((yy_buffer_stack_top) > 0) 1688 --(yy_buffer_stack_top); 1689 1690 if (YY_CURRENT_BUFFER) { 1691 yy_load_buffer_state( ); 1692 (yy_did_buffer_switch_on_eof) = 1; 1693 } 1694 } 1695 1696 /* Allocates the stack if it does not exist. 1697 * Guarantees space for at least one push. 1698 */ 1699 void yyFlexLexer::yyensure_buffer_stack(void) 1700 { 1701 yy_size_t num_to_alloc; 1702 1703 if (!(yy_buffer_stack)) { 1704 1705 /* First allocation is just for 2 elements, since we don't know if this 1706 * scanner will even need a stack. We use 2 instead of 1 to avoid an 1707 * immediate realloc on the next call. 1708 */ 1709 num_to_alloc = 1; 1710 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc 1711 (num_to_alloc * sizeof(struct yy_buffer_state*) 1712 ); 1713 if ( ! (yy_buffer_stack) ) 1714 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 1715 1716 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); 1717 1718 (yy_buffer_stack_max) = num_to_alloc; 1719 (yy_buffer_stack_top) = 0; 1720 return; 1721 } 1722 1723 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ 1724 1725 /* Increase the buffer to prepare for a possible push. */ 1726 int grow_size = 8 /* arbitrary grow size */; 1727 1728 num_to_alloc = (yy_buffer_stack_max) + grow_size; 1729 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc 1730 ((yy_buffer_stack), 1731 num_to_alloc * sizeof(struct yy_buffer_state*) 1732 ); 1733 if ( ! (yy_buffer_stack) ) 1734 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 1735 1736 /* zero only the new slots.*/ 1737 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); 1738 (yy_buffer_stack_max) = num_to_alloc; 1739 } 1740 } 1741 1742 void yyFlexLexer::yy_push_state( int new_state ) 1743 { 1744 if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) 1745 { 1746 yy_size_t new_size; 1747 1748 (yy_start_stack_depth) += YY_START_STACK_INCR; 1749 new_size = (yy_start_stack_depth) * sizeof( int ); 1750 1751 if ( ! (yy_start_stack) ) 1752 (yy_start_stack) = (int *) yyalloc(new_size ); 1753 1754 else 1755 (yy_start_stack) = (int *) yyrealloc((void *) (yy_start_stack),new_size ); 1756 1757 if ( ! (yy_start_stack) ) 1758 YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); 1759 } 1760 1761 (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; 1762 1763 BEGIN(new_state); 1764 } 1765 1766 void yyFlexLexer::yy_pop_state() 1767 { 1768 if ( --(yy_start_stack_ptr) < 0 ) 1769 YY_FATAL_ERROR( "start-condition stack underflow" ); 1770 1771 BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); 1772 } 1773 1774 int yyFlexLexer::yy_top_state() 1775 { 1776 return (yy_start_stack)[(yy_start_stack_ptr) - 1]; 1777 } 1778 1779 #ifndef YY_EXIT_FAILURE 1780 #define YY_EXIT_FAILURE 2 1781 #endif 1782 1783 void yyFlexLexer::LexerError( yyconst char msg[] ) 1784 { 1785 std::cerr << msg << std::endl; 1786 exit( YY_EXIT_FAILURE ); 1787 } 1788 1789 /* Redefine yyless() so it works in section 3 code. */ 1790 1791 #undef yyless 1792 #define yyless(n) \ 1793 do \ 1794 { \ 1795 /* Undo effects of setting up yytext. */ \ 1796 int yyless_macro_arg = (n); \ 1797 YY_LESS_LINENO(yyless_macro_arg);\ 1798 yytext[yyleng] = (yy_hold_char); \ 1799 (yy_c_buf_p) = yytext + yyless_macro_arg; \ 1800 (yy_hold_char) = *(yy_c_buf_p); \ 1801 *(yy_c_buf_p) = '\0'; \ 1802 yyleng = yyless_macro_arg; \ 1803 } \ 1804 while ( 0 ) 1805 1806 /* Accessor methods (get/set functions) to struct members. */ 1807 1808 /* 1809 * Internal utility routines. 1810 */ 1811 1812 #ifndef yytext_ptr 1813 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) 1814 { 1815 register int i; 1816 for ( i = 0; i < n; ++i ) 1817 s1[i] = s2[i]; 1818 } 1819 #endif 1820 1821 #ifdef YY_NEED_STRLEN 1822 static int yy_flex_strlen (yyconst char * s ) 1823 { 1824 register int n; 1825 for ( n = 0; s[n]; ++n ) 1826 ; 1827 1828 return n; 1829 } 1830 #endif 1831 1832 void *yyalloc (yy_size_t size ) 1833 { 1834 return (void *) malloc( size ); 1835 } 1836 1837 void *yyrealloc (void * ptr, yy_size_t size ) 1838 { 1839 /* The cast to (char *) in the following accommodates both 1840 * implementations that use char* generic pointers, and those 1841 * that use void* generic pointers. It works with the latter 1842 * because both ANSI C and C++ allow castless assignment from 1843 * any pointer type to void*, and deal with argument conversions 1844 * as though doing an assignment. 1845 */ 1846 return (void *) realloc( (char *) ptr, size ); 1847 } 1848 1849 void yyfree (void * ptr ) 1850 { 1851 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ 1852 } 1853 1854 #define YYTABLES_NAME "yytables" 1855 1856 #line 99 "cool_lexer.ll" 1857 1858 1859 1860 namespace cool 1861 { 1862 1863 Lexer::Lexer( Parser *parser, char *contents ) 1864 { 1865 restart( parser, contents ); 1866 } 1867 1868 void Lexer::restart( Parser *parser, char *contents ) 1869 { 1870 m_parser = parser; 1871 m_locationTable = parser->tokenStream->locationTable(); 1872 m_contents = contents; 1873 m_tokenBegin = m_tokenEnd = 0; 1874 m_currentOffset = 0; 1875 1876 // check for and ignore the UTF-8 byte order mark 1877 unsigned char *ucontents = (unsigned char *) m_contents; 1878 if ( ucontents[0] == 0xEF && ucontents[1] == 0xBB && ucontents[2] == 0xBF ) 1879 { 1880 m_tokenBegin = m_tokenEnd = 3; 1881 m_currentOffset = 3; 1882 } 1883 1884 yyrestart(NULL); 1885 BEGIN(INITIAL); // is not set automatically by yyrestart() 1886 } 1887 1888 // reads a character, and returns 1 as the number of characters read 1889 // (or 0 when the end of the string is reached) 1890 int Lexer::LexerInput( char *buf, int /*max_size*/ ) 1891 { 1892 int c = m_contents[ m_currentOffset++ ]; 1893 1894 switch(c) 1895 { 1896 case '\r': 1897 c = '\n'; // only have one single line break character: '\n' 1898 if ( m_contents[m_currentOffset + 1] == '\n' ) 1899 { 1900 m_currentOffset++; 1901 m_tokenEnd++; 1902 } 1903 1904 // fall through 1905 case '\n': 1906 m_locationTable->newline( m_currentOffset ); 1907 break; 1908 1909 default: 1910 break; 1911 } 1912 1913 return (c == 0) ? 0 : (buf[0] = c, 1); 1914 } 1915 1916 } // end of namespace cool 1917 1918