X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=blobdiff_plain;f=parser.c;h=4c634ca3a6a5e139ec317bb063e5a7dda92796f2;hp=95769ad55a7b5164e0b49894ad3850ccc134ad9b;hb=ebf8f690dfc868c231baacd2232840e14586d00f;hpb=d098a3196db8758737f6a79992b460306045d499 diff --git a/parser.c b/parser.c index 95769ad..4c634ca 100644 --- a/parser.c +++ b/parser.c @@ -1,1883 +1,7 @@ - -#line 3 "parser.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 34 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#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. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -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 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - 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). - * Given that the standard has decreed that size_t exists since 1989, - * I guess we can afford to depend on it. Manoj. - */ - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -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; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* 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 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* 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". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* 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 = 0; /* 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 (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); - -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -typedef int yy_state_type; - -extern int yylineno; - -int yylineno = 1; - -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (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 = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 43 -#define YY_END_OF_BUFFER 44 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_acclist[646] = - { 0, - 44, 42, 43, 42, 43, 42, 43, 41, 42, 43, - 42, 43, 26, 42, 43, 42, 43, 41, 42, 43, - 41, 42, 43,16411, 41, 42, 43,16411, 42, 43, - 41, 42, 43, 41, 42, 43, 41, 42, 43, 41, - 42, 43, 41, 42, 43, 41, 42, 43, 41, 42, - 43, 41, 42, 43, 41, 42, 43, 41, 42, 43, - 41, 42, 43, 42, 43, 41, 42, 43, 41, 42, - 43, 41, 42, 43, 41, 42, 43, 41, 42, 43, - 41, 42, 43, 41, 42, 43, 41, 42, 43, 41, - 42, 43, 41, 42, 43, 41, 42, 43, 41, 42, - - 43, 41, 42, 43, 41, 42, 43, 41, 42, 43, - 41, 42, 43, 41, 42, 43, 41, 42, 43, 42, - 43, 42, 43, 41, 42, 43, 41, 42, 43, 41, - 42, 43,16411, 41, 42, 43,16411, 42, 43, 41, - 42, 43, 41, 42, 43, 41, 42, 43, 41, 42, - 43, 41, 42, 43, 41, 42, 43, 41, 42, 43, - 41, 42, 43, 41, 42, 43, 41, 42, 43, 41, - 42, 43, 41, 42, 43, 41, 42, 43, 41, 42, - 43, 41, 42, 43, 41, 42, 43, 41, 42, 43, - 41, 42, 43, 41, 42, 43, 41, 42, 43, 41, - - 42, 43, 41, 42, 43, 41, 42, 43, 41, 42, - 43, 41, 42, 43, 41, 42, 43, 41, 42, 43, - 41, 42, 43, 41, 42, 43, 42, 43, 34, 41, - 18, 41, 10, 41, 41, 41,16411, 8219, 41, 36, - 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 10, 41, 41, 41, 41, 37, 41, 4, 41, - 41, 5, 41, 41, 41, 41, 41, 41, 10, 41, - 41, 41, 35, 41, 41, 10, 41, 41, 41,16411, - 8219, 41, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 10, 41, 41, 41, 41, 41, 4, - - 41, 41, 5, 41, 41, 41, 41, 41, 41, 10, - 41, 41, 41, 16, 10, 41, 24, 41, 24, 9, - 41, 8219, 23, 41, 23, 25, 41, 41, 41, 41, - 41, 7, 41, 41, 41, 41, 41, 41, 10, 41, - 41, 41, 41, 5, 41, 41, 4, 4, 41, 4, - 41, 4, 4, 41, 5, 6, 41, 5, 5, 41, - 41, 41, 41, 10, 41, 41, 35, 40, 10, 41, - 24, 41, 9, 41, 23, 41, 36, 41, 41, 41, - 41, 41, 7, 41, 41, 41, 41, 41, 41, 10, - 41, 41, 41, 41, 5, 41, 41, 4, 41, 4, - - 41, 4, 41, 6, 41, 5, 41, 41, 41, 41, - 10, 41, 41, 39, 39, 39, 38, 26, 26, 7, - 41, 11, 7, 41, 3, 41, 8, 41, 7, 41, - 7, 7, 41, 7, 41, 7, 41, 41, 41, 20, - 41, 41, 17, 41, 41, 41, 41, 41, 37, 4, - 41, 2, 41, 6, 5, 6, 6, 41, 6, 41, - 5, 5, 41, 41, 26, 40, 41, 7, 41, 3, - 41, 8, 41, 41, 7, 41, 7, 41, 41, 41, - 41, 20, 41, 41, 17, 41, 41, 41, 41, 41, - 41, 2, 41, 6, 41, 41, 5, 41, 41, 39, - - 8, 7, 7, 3, 8, 8, 41, 8, 1, 41, - 21, 41, 41, 20, 41, 41, 41, 41, 41, 41, - 31, 37, 2, 2, 2, 41, 2, 6, 6, 41, - 40, 8, 41, 1, 41, 41, 41, 20, 41, 41, - 41, 41, 41, 41, 2, 41, 6, 41, 28, 39, - 8, 1, 24, 24, 23, 23, 25, 25, 1, 1, - 41, 1, 22, 21, 41, 41, 41, 12, 41, 41, - 29, 37, 31, 2, 28, 35, 40, 40, 1, 41, - 41, 41, 41, 12, 41, 41, 19, 1, 25, 22, - 20, 41, 41, 41, 12, 41, 41, 41, 41, 41, - - 12, 41, 41, 13, 41, 41, 41, 41, 13, 41, - 41, 15, 41, 41, 41, 15, 41, 41, 41, 40, - 41, 41, 41, 41, 40, 40, 41, 41, 32, 41, - 40, 40, 32, 41, 14, 32, 33, 33, 36, 40, - 40, 32, 40, 35, 30 - } ; - -static yyconst flex_int16_t yy_accept[720] = - { 0, - 1, 1, 1, 2, 4, 6, 8, 11, 13, 16, - 18, 21, 25, 29, 31, 34, 37, 40, 43, 46, - 49, 52, 55, 58, 61, 64, 66, 69, 72, 75, - 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, - 108, 111, 114, 117, 120, 122, 124, 127, 130, 134, - 138, 140, 143, 146, 149, 152, 155, 158, 161, 164, - 167, 170, 173, 176, 179, 182, 185, 188, 191, 194, - 197, 200, 203, 206, 209, 212, 215, 218, 221, 224, - 227, 229, 229, 230, 231, 231, 231, 231, 231, 232, - 232, 232, 232, 233, 233, 235, 235, 235, 235, 236, - - 236, 236, 238, 238, 240, 240, 241, 241, 242, 242, - 243, 243, 244, 244, 245, 246, 247, 248, 249, 250, - 251, 252, 254, 255, 256, 257, 257, 257, 257, 257, - 258, 259, 261, 261, 262, 264, 265, 266, 267, 268, - 269, 271, 272, 273, 273, 273, 273, 274, 274, 275, - 275, 276, 278, 278, 279, 281, 281, 283, 283, 284, - 285, 285, 286, 287, 288, 289, 290, 291, 292, 293, - 294, 296, 297, 298, 299, 300, 302, 302, 303, 305, - 306, 307, 308, 309, 310, 312, 313, 314, 314, 314, - 314, 314, 314, 314, 314, 314, 314, 314, 314, 315, - - 315, 315, 315, 315, 315, 317, 319, 320, 322, 323, - 323, 323, 323, 325, 326, 327, 327, 328, 328, 329, - 329, 330, 331, 331, 332, 334, 334, 334, 334, 334, - 334, 334, 334, 335, 336, 337, 338, 339, 341, 342, - 343, 344, 344, 344, 344, 344, 346, 346, 347, 347, - 348, 350, 352, 353, 355, 356, 356, 358, 359, 361, - 362, 363, 364, 366, 367, 368, 368, 368, 368, 368, - 369, 371, 373, 375, 377, 377, 378, 378, 379, 380, - 380, 381, 382, 383, 385, 385, 386, 387, 388, 389, - 390, 392, 393, 394, 395, 397, 398, 398, 400, 402, - - 404, 406, 408, 409, 410, 411, 413, 414, 414, 414, - 415, 416, 416, 416, 417, 417, 417, 418, 418, 418, - 419, 419, 420, 420, 421, 421, 421, 421, 422, 422, - 422, 422, 422, 422, 422, 422, 423, 425, 425, 425, - 427, 429, 430, 430, 431, 431, 432, 434, 436, 437, - 438, 438, 438, 438, 438, 438, 438, 439, 440, 442, - 442, 443, 445, 446, 447, 448, 449, 449, 449, 449, - 449, 450, 451, 452, 452, 454, 455, 456, 456, 456, - 457, 459, 460, 461, 462, 462, 464, 465, 465, 466, - 466, 466, 466, 466, 467, 467, 468, 468, 468, 470, - - 472, 474, 475, 475, 477, 479, 480, 481, 482, 484, - 485, 487, 488, 489, 490, 491, 492, 494, 496, 497, - 499, 500, 500, 500, 500, 500, 501, 501, 501, 501, - 501, 502, 503, 504, 504, 504, 504, 504, 504, 504, - 504, 504, 504, 505, 505, 506, 508, 509, 511, 511, - 511, 511, 511, 511, 512, 513, 514, 514, 516, 516, - 517, 518, 519, 520, 521, 521, 521, 523, 523, 523, - 524, 524, 525, 527, 528, 529, 529, 529, 531, 531, - 531, 531, 531, 531, 531, 531, 532, 532, 532, 534, - 536, 537, 538, 540, 541, 542, 543, 544, 545, 547, - - 549, 549, 549, 549, 549, 549, 549, 551, 551, 552, - 553, 553, 554, 554, 555, 555, 556, 556, 557, 557, - 558, 558, 559, 559, 559, 559, 560, 562, 563, 563, - 563, 564, 564, 564, 565, 566, 566, 566, 566, 566, - 566, 567, 568, 570, 571, 573, 573, 574, 575, 575, - 575, 577, 577, 577, 578, 579, 579, 579, 581, 582, - 583, 584, 586, 587, 587, 588, 588, 588, 588, 588, - 589, 589, 590, 590, 590, 591, 591, 591, 592, 592, - 592, 592, 592, 593, 594, 595, 597, 598, 598, 598, - 598, 598, 598, 599, 600, 601, 603, 604, 604, 604, - - 604, 604, 604, 604, 605, 605, 605, 605, 605, 606, - 607, 607, 607, 607, 607, 608, 609, 609, 609, 609, - 609, 610, 610, 610, 610, 611, 612, 614, 614, 614, - 614, 614, 615, 615, 616, 618, 618, 618, 618, 618, - 619, 620, 620, 620, 620, 620, 621, 622, 623, 623, - 623, 623, 623, 623, 624, 625, 625, 625, 625, 625, - 626, 627, 628, 629, 629, 629, 629, 629, 629, 631, - 631, 631, 631, 631, 632, 633, 635, 635, 635, 636, - 636, 637, 637, 638, 638, 638, 640, 640, 641, 642, - 642, 642, 642, 642, 644, 644, 644, 644, 644, 644, - - 644, 644, 644, 644, 644, 644, 644, 644, 644, 644, - 644, 644, 644, 644, 644, 644, 645, 646, 646 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 4, 1, 5, 6, 7, 8, 1, 9, 10, - 11, 12, 13, 1, 14, 15, 16, 17, 18, 19, - 20, 20, 20, 20, 20, 20, 20, 21, 22, 1, - 23, 1, 1, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 33, 34, 35, 36, 37, 38, 39, - 39, 40, 41, 42, 43, 42, 44, 45, 42, 42, - 46, 1, 47, 48, 49, 1, 50, 51, 52, 53, - - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 71, 75, 1, 76, 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, 1 - } ; - -static yyconst flex_int32_t yy_meta[77] = - { 0, - 1, 2, 3, 2, 1, 1, 1, 1, 4, 5, - 6, 1, 7, 8, 1, 1, 9, 9, 9, 9, - 10, 1, 11, 1, 12, 12, 12, 12, 12, 12, - 12, 12, 13, 12, 13, 13, 12, 12, 12, 12, - 13, 13, 13, 12, 14, 1, 1, 15, 1, 16, - 16, 16, 16, 17, 16, 16, 16, 16, 16, 16, - 16, 18, 19, 19, 19, 19, 19, 18, 18, 18, - 18, 18, 20, 18, 1, 1 - } ; - -static yyconst flex_int16_t yy_base[807] = - { 0, - 0, 76, 3128, 4684, 128, 137, 0, 148, 3123, 146, - 158, 178, 169, 3120, 241, 165, 3065, 3054, 126, 253, - 249, 270, 257, 261, 300, 357, 420, 260, 272, 281, - 286, 295, 337, 326, 339, 351, 293, 255, 152, 176, - 400, 395, 418, 404, 426, 3116, 317, 446, 501, 478, - 167, 567, 221, 3062, 3051, 164, 403, 439, 471, 494, - 478, 576, 627, 545, 548, 584, 560, 553, 602, 450, - 604, 367, 642, 644, 687, 697, 698, 704, 705, 711, - 724, 3061, 612, 0, 3106, 299, 650, 181, 4684, 3102, - 787, 731, 310, 3096, 3096, 3094, 521, 751, 3094, 671, - - 167, 735, 3093, 0, 3106, 4684, 0, 811, 0, 864, - 0, 925, 971, 3058, 3053, 3056, 3061, 3033, 758, 3033, - 3063, 3062, 3031, 3044, 3035, 3045, 1043, 309, 1119, 4684, - 1146, 1199, 0, 1224, 1277, 762, 766, 770, 3022, 3026, - 3025, 3020, 3029, 310, 3010, 810, 3081, 3080, 426, 3079, - 752, 793, 381, 800, 1350, 338, 445, 448, 1416, 1469, - 3078, 1530, 3031, 3025, 802, 655, 725, 774, 3009, 3039, - 813, 3008, 938, 3017, 1554, 1607, 3070, 1632, 1685, 931, - 944, 1051, 581, 945, 946, 750, 739, 812, 3002, 458, - 473, 567, 679, 720, 1002, 839, 3057, 2991, 4684, 1059, - - 1064, 3062, 3059, 3048, 3033, 3042, 3041, 0, 4684, 3040, - 3039, 3038, 3037, 3036, 578, 857, 893, 954, 1735, 1772, - 972, 985, 1010, 1068, 1825, 1065, 2981, 2974, 2973, 2986, - 2981, 633, 1022, 1094, 2962, 1010, 2979, 3018, 2973, 2969, - 1141, 401, 1145, 719, 1899, 1966, 0, 1971, 0, 3018, - 3016, 3015, 4684, 1134, 1158, 1425, 2023, 3015, 3013, 601, - 2971, 2966, 3003, 2947, 4684, 1169, 1145, 3011, 198, 3011, - 1170, 1135, 947, 1351, 760, 3009, 1060, 1432, 2069, 3008, - 1437, 1536, 1533, 2122, 3007, 1762, 1907, 1419, 1908, 1161, - 1352, 1763, 1162, 1913, 2188, 2193, 3006, 1066, 2998, 1799, - - 2245, 1418, 1417, 948, 1927, 1471, 1067, 1287, 2954, 4684, - 788, 809, 825, 843, 869, 985, 4684, 1559, 2996, 2995, - 2929, 2927, 1306, 2290, 2984, 2983, 2982, 2981, 950, 2976, - 266, 2975, 1098, 1940, 638, 4684, 2354, 1941, 1379, 0, - 2393, 1132, 1608, 2392, 1943, 1686, 2980, 2979, 4684, 1442, - 2914, 2909, 2903, 2901, 2901, 2905, 2907, 2906, 792, 966, - 1004, 0, 2927, 2908, 2909, 2907, 1416, 1417, 1164, 1729, - 2955, 2948, 1498, 1554, 2065, 1895, 2947, 943, 1929, 1930, - 2945, 4684, 1149, 4684, 2889, 0, 2887, 2289, 2946, 1952, - 2352, 2897, 2878, 2938, 1113, 2026, 174, 1182, 2445, 1353, - - 2484, 2524, 2936, 1960, 2928, 2097, 2084, 2293, 2348, 2529, - 1472, 1942, 2349, 2282, 2346, 2482, 2539, 2191, 2392, 1828, - 1949, 2031, 2884, 1006, 2924, 1024, 1096, 1278, 1282, 1582, - 2063, 2923, 2922, 1581, 2921, 2855, 2919, 2853, 2913, 2841, - 2898, 2065, 4684, 2123, 2246, 2904, 4684, 2578, 2859, 2839, - 2306, 2838, 2833, 2820, 2881, 1558, 2496, 2869, 1597, 2843, - 2817, 2796, 2795, 2851, 1764, 2258, 4684, 2846, 2263, 2482, - 2521, 2541, 2836, 4684, 2809, 1233, 2752, 0, 2799, 2551, - 2794, 1951, 2794, 2748, 2734, 1354, 1774, 1770, 2350, 2619, - 2531, 2534, 2661, 2657, 2487, 2071, 2581, 2664, 2660, 2525, - - 2621, 1645, 1423, 2787, 1585, 1612, 4684, 2673, 2786, 2664, - 2784, 2783, 2717, 2714, 2774, 2772, 2705, 2703, 2759, 2749, - 2678, 2677, 2733, 2728, 2665, 2666, 2720, 4684, 2660, 2652, - 2626, 2019, 2648, 4684, 2652, 2689, 2625, 2565, 2609, 2582, - 2593, 2565, 682, 2582, 4684, 2457, 4684, 2620, 2585, 2698, - 2591, 2540, 2533, 2568, 2015, 1599, 428, 2687, 2690, 2698, - 2700, 2701, 2711, 2627, 4684, 2511, 2531, 1690, 2716, 2528, - 2533, 2494, 2434, 2437, 4684, 2406, 2456, 2452, 2393, 2452, - 2376, 2338, 2363, 2310, 2319, 0, 2270, 2725, 2297, 2228, - 1771, 344, 2716, 2720, 2729, 2616, 2737, 2745, 2232, 2221, - - 1799, 2145, 2137, 2244, 2147, 1773, 2128, 2070, 2821, 2058, - 2053, 2012, 1935, 754, 2897, 2742, 2759, 1975, 1983, 1884, - 4684, 1844, 1816, 1888, 2973, 1962, 0, 1813, 1777, 1982, - 2073, 3049, 2203, 2085, 2743, 2762, 1763, 1754, 2542, 1661, - 1490, 1423, 1402, 2196, 586, 2207, 1411, 1374, 2763, 1230, - 1152, 2736, 2537, 1164, 1136, 1120, 1129, 2035, 1938, 2409, - 2753, 1002, 943, 2772, 2308, 929, 2208, 2408, 0, 938, - 832, 830, 2036, 2768, 2784, 0, 2777, 772, 4684, 676, - 2541, 730, 4684, 492, 392, 4684, 2200, 2827, 2810, 2786, - 328, 314, 2293, 2674, 2802, 253, 2669, 1543, 2033, 2165, - - 2804, 2805, 2846, 2847, 2851, 2860, 2872, 2873, 2876, 2879, - 2881, 2886, 2911, 2923, 2334, 158, 4684, 4684, 3122, 3142, - 3156, 3170, 3190, 3210, 3227, 3247, 3267, 3286, 2025, 2188, - 2219, 3305, 3325, 2392, 3345, 3365, 3382, 3402, 3422, 3442, - 3462, 3482, 3502, 3522, 3535, 3555, 3575, 3595, 3615, 3624, - 2398, 3640, 3657, 3677, 3694, 3714, 3734, 3754, 3774, 3794, - 3814, 3834, 3854, 3874, 3894, 3907, 3923, 3938, 3958, 3978, - 3998, 4015, 4031, 4048, 4068, 4085, 4105, 4125, 4145, 4165, - 4185, 4205, 4225, 4241, 4256, 4276, 4296, 4316, 4336, 4356, - 4376, 4396, 4416, 4432, 4452, 4472, 4492, 4508, 4523, 4543, - - 4563, 4583, 4603, 4623, 4643, 4663 - } ; - -static yyconst flex_int16_t yy_def[807] = - { 0, - 718, 718, 718, 718, 718, 718, 719, 720, 718, 721, - 719, 718, 12, 722, 719, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 723, 15, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 719, 719, - 719, 719, 719, 719, 724, 718, 725, 725, 718, 49, - 722, 725, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 725, 725, 725, 725, 725, 725, - 724, 718, 718, 719, 726, 727, 726, 718, 718, 718, - 718, 718, 719, 718, 719, 718, 728, 728, 719, 728, - - 718, 12, 718, 719, 722, 718, 729, 719, 730, 718, - 731, 719, 718, 112, 112, 719, 719, 719, 112, 112, - 108, 719, 112, 719, 112, 732, 723, 732, 733, 718, - 719, 718, 734, 719, 718, 719, 719, 719, 719, 719, - 719, 719, 719, 724, 735, 724, 718, 736, 737, 718, - 737, 737, 718, 737, 718, 718, 737, 738, 737, 718, - 731, 159, 162, 162, 737, 737, 737, 162, 162, 159, - 737, 162, 737, 162, 159, 718, 734, 159, 718, 737, - 737, 737, 737, 737, 737, 737, 737, 724, 718, 739, - 740, 740, 741, 742, 739, 739, 743, 744, 718, 745, - - 745, 718, 718, 718, 719, 719, 718, 719, 718, 718, - 718, 718, 719, 718, 718, 718, 719, 718, 719, 718, - 719, 719, 718, 219, 718, 745, 718, 718, 718, 718, - 718, 718, 719, 719, 719, 719, 719, 719, 719, 719, - 719, 746, 747, 748, 749, 719, 750, 719, 751, 750, - 719, 248, 718, 719, 752, 752, 719, 256, 719, 719, - 719, 719, 719, 719, 718, 724, 718, 753, 718, 754, - 755, 755, 755, 755, 756, 753, 757, 755, 755, 220, - 755, 755, 279, 718, 226, 755, 755, 755, 755, 755, - 755, 755, 755, 755, 755, 283, 751, 755, 296, 755, - - 295, 755, 755, 755, 755, 755, 755, 724, 718, 718, - 758, 759, 760, 761, 758, 762, 718, 763, 764, 764, - 765, 765, 718, 718, 718, 718, 718, 719, 718, 718, - 718, 718, 718, 718, 718, 718, 719, 766, 718, 719, - 719, 767, 767, 719, 766, 767, 719, 344, 718, 719, - 718, 718, 718, 718, 718, 718, 719, 719, 719, 718, - 719, 719, 719, 719, 719, 719, 768, 768, 769, 770, - 771, 718, 719, 718, 772, 773, 718, 718, 773, 773, - 719, 718, 719, 718, 718, 719, 719, 724, 718, 718, - 718, 718, 718, 774, 718, 755, 775, 775, 755, 755, - - 399, 755, 345, 755, 402, 755, 755, 755, 755, 755, - 755, 755, 755, 755, 755, 755, 776, 755, 755, 755, - 755, 724, 718, 777, 778, 779, 780, 781, 782, 783, - 784, 718, 345, 718, 785, 786, 787, 788, 789, 790, - 718, 718, 718, 784, 784, 719, 718, 719, 718, 718, - 718, 718, 718, 718, 719, 719, 718, 719, 718, 719, - 719, 719, 719, 719, 791, 792, 718, 793, 718, 794, - 794, 794, 719, 718, 718, 718, 718, 719, 718, 724, - 718, 718, 718, 718, 718, 795, 796, 796, 755, 755, - 755, 755, 755, 755, 755, 755, 755, 755, 755, 755, - - 724, 718, 779, 797, 780, 781, 718, 783, 718, 798, - 785, 785, 786, 786, 787, 787, 788, 788, 789, 789, - 790, 790, 718, 718, 798, 798, 719, 718, 718, 718, - 718, 718, 718, 718, 719, 799, 718, 718, 718, 718, - 719, 719, 719, 719, 718, 718, 718, 718, 718, 724, - 718, 718, 718, 795, 795, 796, 796, 755, 755, 755, - 755, 755, 755, 724, 718, 718, 797, 779, 783, 718, - 718, 718, 718, 718, 718, 718, 799, 799, 718, 718, - 718, 718, 719, 719, 719, 719, 719, 724, 718, 718, - 796, 796, 755, 755, 755, 755, 755, 724, 718, 718, - - 718, 718, 718, 718, 718, 718, 718, 718, 800, 719, - 718, 718, 796, 796, 801, 755, 724, 718, 718, 718, - 718, 718, 802, 802, 800, 625, 719, 718, 718, 796, - 796, 801, 802, 632, 755, 724, 718, 718, 802, 625, - 625, 718, 718, 796, 796, 803, 632, 632, 724, 718, - 718, 802, 802, 625, 625, 718, 718, 796, 796, 803, - 803, 632, 632, 724, 718, 718, 802, 802, 625, 804, - 718, 805, 796, 803, 803, 632, 724, 718, 718, 718, - 802, 804, 718, 718, 805, 718, 796, 803, 803, 724, - 718, 718, 796, 803, 724, 718, 796, 724, 806, 806, - - 806, 806, 806, 806, 806, 806, 806, 806, 806, 806, - 806, 806, 806, 806, 806, 718, 718, 0, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - - 718, 718, 718, 718, 718, 718 - } ; - -static yyconst flex_int16_t yy_nxt[4761] = - { 0, - 4, 4, 4, 5, 4, 4, 6, 4, 7, 8, - 4, 9, 10, 7, 4, 4, 11, 12, 13, 13, - 4, 14, 4, 4, 15, 16, 17, 18, 15, 15, - 19, 15, 15, 15, 15, 20, 21, 22, 21, 23, - 24, 21, 21, 25, 21, 26, 4, 4, 4, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 40, 40, 42, 43, 40, 40, - 40, 44, 40, 40, 45, 4, 4, 4, 4, 5, - 4, 46, 6, 46, 7, 8, 4, 9, 10, 47, - 4, 4, 48, 49, 50, 50, 4, 51, 4, 4, - - 52, 53, 54, 55, 52, 52, 56, 52, 52, 52, - 52, 57, 58, 59, 58, 60, 61, 58, 58, 62, - 58, 26, 4, 4, 4, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 76, 76, 78, 79, 76, 76, 76, 80, 76, 76, - 81, 4, 82, 83, 83, 83, 83, 86, 89, 90, - 717, 92, 117, 107, 87, 87, 87, 87, 113, 106, - 158, 93, 97, 94, 95, 107, 106, 82, 96, 97, - 97, 98, 84, 214, 718, 215, 84, 107, 118, 718, - 197, 99, 100, 101, 102, 102, 102, 102, 103, 107, - - 166, 139, 104, 104, 104, 104, 104, 104, 104, 104, - 84, 104, 84, 84, 104, 104, 104, 104, 84, 84, - 84, 104, 84, 487, 113, 114, 167, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 84, - 104, 104, 104, 104, 104, 84, 84, 84, 84, 84, - 84, 84, 107, 392, 108, 198, 109, 110, 110, 110, - 110, 111, 393, 113, 107, 119, 119, 119, 119, 119, - 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, - 119, 163, 214, 121, 215, 108, 119, 119, 119, 119, - 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, - - 112, 112, 120, 113, 136, 136, 670, 122, 193, 194, - 123, 135, 145, 108, 135, 135, 119, 119, 119, 119, - 137, 136, 242, 135, 135, 84, 205, 206, 138, 124, - 136, 136, 135, 135, 135, 136, 136, 150, 135, 135, - 135, 270, 136, 136, 136, 136, 106, 116, 135, 135, - 135, 135, 135, 135, 214, 130, 125, 126, 127, 127, - 127, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 128, 126, 126, 117, 696, 136, 136, 126, 126, 126, - 126, 135, 135, 135, 270, 147, 136, 136, 136, 136, - 565, 135, 135, 135, 686, 135, 135, 135, 207, 118, - - 136, 136, 126, 130, 126, 126, 107, 113, 135, 135, - 135, 107, 614, 140, 368, 107, 180, 180, 107, 168, - 168, 168, 168, 107, 179, 179, 179, 107, 145, 107, - 106, 126, 126, 131, 84, 718, 132, 132, 132, 132, - 133, 107, 146, 146, 146, 146, 150, 130, 142, 92, - 276, 277, 169, 84, 84, 168, 168, 168, 168, 151, - 143, 94, 152, 141, 134, 150, 153, 191, 310, 135, - 135, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 97, 193, 311, 170, 592, 124, 168, 168, 168, - 168, 149, 134, 718, 168, 168, 168, 168, 150, 180, - - 180, 147, 97, 97, 98, 179, 179, 179, 171, 84, - 168, 168, 168, 168, 154, 100, 101, 155, 155, 155, - 155, 156, 97, 97, 97, 157, 157, 157, 157, 157, - 157, 157, 157, 149, 157, 149, 149, 157, 157, 157, - 157, 149, 149, 149, 157, 149, 173, 172, 113, 692, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 149, 157, 157, 157, 157, 157, 149, 149, - 149, 149, 149, 149, 149, 84, 193, 311, 107, 113, - 159, 334, 109, 160, 160, 160, 160, 161, 106, 84, - 107, 335, 168, 168, 168, 168, 179, 180, 335, 179, - - 179, 150, 180, 180, 182, 181, 179, 179, 179, 180, - 180, 159, 179, 179, 179, 385, 162, 162, 162, 162, - 162, 162, 162, 162, 162, 162, 162, 162, 83, 83, - 83, 83, 174, 180, 180, 179, 179, 179, 166, 159, - 175, 441, 718, 176, 176, 176, 176, 177, 659, 290, - 165, 180, 180, 180, 180, 442, 179, 179, 179, 191, - 179, 179, 179, 84, 167, 386, 195, 195, 195, 195, - 196, 178, 97, 97, 97, 150, 179, 179, 180, 180, - 180, 180, 180, 180, 180, 180, 180, 180, 313, 314, - 356, 180, 180, 180, 180, 84, 356, 289, 107, 178, - - 179, 179, 179, 179, 179, 84, 84, 150, 107, 107, - 107, 184, 84, 84, 113, 107, 107, 150, 150, 84, - 107, 107, 107, 370, 150, 150, 145, 107, 107, 316, - 317, 150, 683, 84, 107, 585, 183, 188, 97, 691, - 146, 146, 146, 146, 202, 150, 203, 84, 84, 586, - 718, 204, 97, 97, 97, 718, 106, 186, 84, 150, - 84, 185, 276, 277, 210, 371, 211, 187, 271, 272, - 150, 212, 150, 173, 84, 84, 84, 84, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 149, 149, 149, 149, 289, 457, 307, 316, 317, 147, - - 111, 84, 109, 200, 200, 200, 200, 111, 84, 273, - 84, 631, 145, 150, 145, 261, 274, 292, 313, 314, - 150, 84, 150, 262, 679, 308, 146, 146, 146, 146, - 266, 111, 686, 150, 425, 426, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 191, 310, - 273, 288, 428, 194, 458, 318, 318, 318, 318, 111, - 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, - 217, 217, 84, 336, 336, 336, 336, 219, 316, 317, - 84, 84, 84, 84, 220, 147, 684, 147, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 84, - - 84, 84, 84, 84, 84, 84, 84, 84, 219, 337, - 337, 337, 337, 222, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 222, 222, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 219, 84, 224, 84, - 683, 225, 225, 225, 225, 226, 84, 301, 301, 301, - 301, 150, 84, 84, 84, 84, 84, 385, 150, 435, - 301, 301, 301, 301, 150, 150, 150, 150, 150, 224, - 338, 338, 338, 338, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 222, 222, 222, 680, 293, 340, 340, - 340, 340, 459, 304, 428, 194, 676, 224, 227, 407, - - 228, 341, 341, 341, 341, 229, 230, 384, 306, 273, - 231, 191, 310, 360, 232, 425, 426, 459, 195, 195, - 195, 195, 196, 227, 436, 228, 342, 342, 342, 342, - 676, 229, 230, 504, 505, 460, 361, 231, 341, 341, - 341, 341, 232, 126, 127, 127, 127, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 84, - 461, 361, 106, 126, 126, 126, 126, 301, 301, 301, - 301, 150, 226, 357, 84, 84, 253, 226, 718, 226, - 324, 324, 324, 324, 226, 718, 150, 150, 126, 130, - 126, 126, 84, 84, 84, 84, 84, 84, 84, 84, - - 84, 84, 84, 226, 305, 428, 194, 437, 226, 718, - 341, 341, 341, 341, 486, 397, 486, 126, 126, 126, - 243, 243, 243, 244, 398, 126, 126, 126, 126, 126, - 126, 226, 671, 126, 126, 415, 226, 718, 329, 126, - 126, 343, 126, 84, 253, 358, 243, 243, 243, 244, - 375, 375, 375, 375, 346, 150, 389, 341, 341, 341, - 341, 390, 391, 477, 126, 130, 126, 256, 370, 84, - 84, 145, 438, 670, 376, 376, 376, 376, 84, 349, - 258, 150, 150, 396, 106, 388, 388, 388, 388, 669, - 150, 130, 669, 126, 126, 246, 246, 246, 246, 246, - - 246, 246, 246, 246, 246, 246, 246, 84, 247, 366, - 371, 378, 248, 478, 411, 84, 84, 84, 84, 249, - 666, 250, 414, 251, 251, 251, 251, 251, 251, 251, - 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, - 251, 251, 251, 252, 147, 488, 253, 477, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, - 251, 252, 251, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 84, 256, 504, 505, 145, - 84, 428, 194, 257, 257, 257, 257, 382, 665, 258, - - 422, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 431, 431, 431, 431, 84, 84, 84, 84, - 260, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, - 84, 97, 97, 97, 333, 555, 395, 555, 84, 84, - 84, 84, 147, 149, 100, 412, 155, 155, 155, 155, - 150, 150, 150, 150, 157, 157, 157, 157, 157, 157, - 157, 157, 149, 157, 149, 149, 157, 157, 157, 157, - 149, 149, 149, 157, 149, 443, 443, 443, 443, 157, - - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 149, 157, 157, 157, 157, 157, 149, 149, 149, - 149, 149, 149, 149, 84, 84, 84, 84, 384, 368, - 465, 385, 504, 505, 718, 663, 150, 150, 150, 150, - 84, 718, 718, 718, 718, 84, 662, 718, 399, 399, - 399, 399, 150, 400, 400, 400, 400, 150, 448, 448, - 448, 448, 130, 130, 657, 278, 278, 278, 278, 278, - 278, 278, 278, 278, 278, 278, 278, 84, 718, 84, - 84, 420, 279, 656, 421, 149, 149, 149, 149, 280, - 409, 150, 150, 281, 281, 281, 281, 281, 281, 281, - - 281, 281, 281, 281, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 279, 375, 375, 375, 375, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 279, 149, 283, 84, 699, 284, 284, 284, 284, - 285, 655, 401, 401, 401, 401, 150, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 191, 310, - 470, 470, 470, 470, 283, 430, 430, 430, 430, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 282, 191, 507, 535, 428, 194, 508, 510, 510, 510, - - 510, 106, 283, 295, 295, 295, 295, 295, 295, 295, - 295, 295, 295, 295, 295, 84, 247, 718, 147, 535, - 296, 504, 505, 149, 149, 149, 149, 297, 539, 250, - 718, 298, 298, 298, 298, 298, 298, 298, 298, 298, - 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, - 298, 299, 591, 540, 253, 718, 300, 300, 300, 300, - 300, 300, 300, 300, 300, 300, 300, 300, 298, 298, - 298, 298, 298, 298, 298, 298, 298, 298, 298, 299, - 298, 179, 179, 179, 179, 179, 179, 179, 179, 179, - 179, 179, 179, 84, 256, 343, 654, 565, 149, 504, - - 505, 301, 301, 301, 301, 150, 566, 258, 718, 302, - 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, - 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, - 466, 466, 466, 718, 149, 149, 149, 149, 303, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 84, 84, 106, 106, 613, 467, 106, 465, 401, 401, - 401, 401, 150, 150, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 222, 222, 222, 339, 339, 339, 339, - - 339, 339, 339, 339, 339, 339, 339, 84, 439, 253, - 545, 651, 537, 407, 650, 417, 417, 417, 417, 150, - 413, 323, 323, 323, 323, 323, 323, 323, 323, 323, - 323, 323, 323, 84, 343, 556, 84, 557, 344, 537, - 643, 84, 84, 84, 84, 345, 639, 346, 150, 347, - 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, - 347, 347, 347, 347, 347, 347, 347, 347, 347, 348, - 642, 639, 349, 440, 350, 350, 350, 350, 350, 350, - 350, 350, 350, 350, 350, 350, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 344, 84, 126, - - 243, 243, 243, 244, 379, 126, 126, 126, 126, 126, - 126, 360, 638, 126, 126, 84, 84, 380, 639, 126, - 126, 84, 126, 401, 401, 401, 401, 150, 150, 401, - 401, 401, 401, 150, 410, 84, 621, 106, 718, 379, - 106, 673, 382, 639, 126, 130, 126, 150, 476, 439, - 84, 718, 718, 335, 345, 92, 718, 84, 408, 410, - 335, 345, 150, 718, 210, 481, 211, 94, 84, 150, - 349, 212, 96, 126, 126, 256, 718, 718, 408, 273, - 150, 415, 718, 718, 106, 345, 640, 718, 258, 630, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 641, 273, 345, 440, 718, 555, 395, 555, 260, - 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, - 373, 373, 379, 145, 84, 701, 637, 106, 106, 644, - 216, 216, 273, 565, 501, 380, 150, 381, 381, 381, - 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, - 381, 381, 381, 381, 381, 381, 381, 381, 523, 629, - 382, 575, 444, 84, 471, 106, 383, 84, 84, 84, - 524, 84, 84, 84, 84, 445, 534, 472, 672, 150, - 687, 150, 84, 281, 281, 281, 281, 281, 281, 281, - - 281, 281, 281, 281, 150, 84, 147, 628, 265, 647, - 447, 627, 474, 490, 490, 490, 490, 150, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 84, 343, 718, 562, 648, 402, 645, 623, 149, 149, - 149, 149, 403, 491, 346, 718, 404, 404, 404, 404, - 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, - 404, 404, 404, 404, 404, 404, 405, 701, 623, 349, - 718, 406, 406, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 402, 149, 84, 256, 106, 84, - - 622, 382, 106, 218, 218, 604, 646, 619, 150, 395, - 258, 150, 302, 302, 302, 302, 302, 302, 302, 302, - 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, - 302, 302, 302, 639, 223, 223, 681, 661, 639, 572, - 265, 303, 416, 416, 416, 416, 416, 416, 416, 416, - 416, 416, 416, 416, 379, 444, 658, 693, 639, 466, - 466, 466, 661, 639, 546, 546, 546, 380, 718, 418, - 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - 84, 145, 382, 718, 618, 106, 612, 620, 419, 343, - - 611, 84, 150, 345, 467, 480, 480, 480, 480, 547, - 345, 621, 346, 150, 432, 432, 432, 432, 432, 432, - 432, 432, 432, 432, 432, 432, 432, 432, 432, 432, - 432, 432, 432, 432, 433, 497, 701, 349, 610, 434, - 434, 434, 434, 434, 434, 434, 434, 434, 434, 434, - 434, 457, 492, 697, 84, 482, 84, 84, 84, 531, - 447, 678, 345, 343, 147, 483, 150, 101, 150, 150, - 150, 586, 103, 531, 531, 679, 346, 609, 347, 347, - 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, - 347, 347, 347, 347, 347, 347, 347, 347, 347, 498, - - 84, 349, 444, 609, 496, 608, 477, 255, 255, 716, - 493, 395, 150, 374, 374, 445, 607, 446, 446, 446, - 446, 446, 446, 446, 446, 446, 446, 446, 446, 446, - 446, 446, 446, 446, 446, 446, 446, 446, 639, 661, - 447, 350, 350, 350, 350, 350, 350, 350, 350, 350, - 350, 350, 350, 84, 343, 606, 500, 605, 546, 546, - 546, 681, 578, 639, 661, 150, 578, 346, 604, 404, - 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, - 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, - 84, 471, 349, 444, 603, 84, 602, 601, 417, 417, - - 417, 417, 150, 547, 472, 536, 445, 150, 489, 489, - 489, 489, 489, 489, 489, 489, 489, 489, 489, 489, - 489, 489, 489, 489, 489, 489, 489, 489, 489, 474, - 718, 447, 84, 84, 113, 537, 600, 84, 528, 84, - 561, 568, 84, 718, 150, 150, 538, 84, 471, 150, - 471, 150, 149, 145, 150, 149, 149, 149, 149, 150, - 494, 472, 537, 718, 599, 550, 652, 639, 718, 559, - 395, 639, 639, 406, 406, 406, 406, 406, 406, 406, - 406, 406, 406, 406, 406, 495, 474, 525, 718, 84, - 590, 653, 639, 589, 267, 559, 639, 639, 668, 382, - - 526, 150, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - 527, 527, 527, 145, 84, 528, 551, 84, 525, 145, - 474, 587, 584, 583, 564, 582, 150, 581, 580, 150, - 598, 526, 563, 558, 558, 558, 558, 558, 558, 558, - 558, 558, 558, 558, 558, 558, 558, 558, 558, 558, - 558, 558, 558, 558, 457, 84, 528, 113, 84, 84, - 474, 106, 84, 525, 718, 525, 395, 150, 579, 531, - 150, 150, 191, 310, 150, 560, 526, 718, 718, 569, - 569, 569, 569, 531, 531, 84, 147, 528, 84, 578, - - 145, 139, 147, 576, 661, 574, 84, 150, 84, 84, - 150, 528, 718, 718, 588, 588, 588, 588, 150, 84, - 150, 150, 672, 573, 84, 191, 507, 145, 84, 661, - 528, 150, 569, 569, 569, 569, 150, 84, 593, 183, - 150, 588, 588, 588, 588, 84, 572, 145, 571, 150, - 84, 84, 522, 522, 595, 395, 615, 150, 617, 520, - 597, 145, 150, 150, 145, 145, 639, 594, 596, 520, - 395, 667, 636, 147, 145, 649, 664, 674, 518, 145, - 518, 596, 516, 661, 516, 677, 395, 615, 145, 514, - 690, 639, 514, 512, 512, 635, 447, 568, 661, 695, - - 551, 553, 675, 688, 145, 616, 701, 701, 661, 552, - 214, 207, 395, 384, 661, 698, 549, 702, 703, 382, - 147, 624, 624, 661, 624, 624, 624, 624, 624, 395, - 624, 624, 624, 624, 147, 624, 624, 147, 147, 661, - 661, 624, 624, 624, 624, 689, 474, 147, 701, 701, - 469, 626, 147, 701, 113, 694, 544, 661, 543, 704, - 705, 147, 701, 694, 706, 661, 624, 624, 624, 624, - 542, 541, 457, 707, 701, 701, 626, 147, 701, 265, - 265, 701, 661, 701, 113, 708, 709, 534, 701, 710, - 533, 532, 711, 530, 712, 624, 624, 624, 624, 713, - - 624, 624, 624, 624, 624, 625, 624, 624, 624, 624, - 529, 624, 624, 701, 447, 442, 522, 633, 624, 624, - 624, 265, 265, 520, 714, 701, 265, 634, 518, 516, - 514, 512, 349, 349, 310, 265, 715, 502, 349, 270, - 395, 485, 624, 624, 624, 624, 484, 265, 265, 88, - 208, 265, 634, 479, 265, 382, 265, 384, 253, 469, - 464, 265, 463, 462, 208, 456, 455, 454, 453, 452, - 451, 624, 624, 624, 624, 450, 624, 624, 624, 624, - 624, 449, 624, 624, 624, 624, 265, 624, 624, 349, - 349, 214, 214, 624, 624, 624, 624, 208, 265, 207, - - 207, 207, 322, 626, 322, 320, 320, 423, 253, 270, - 270, 270, 269, 395, 269, 366, 387, 358, 624, 624, - 624, 624, 357, 384, 256, 253, 253, 247, 626, 365, - 364, 363, 362, 359, 355, 354, 353, 352, 351, 333, - 333, 332, 331, 330, 329, 329, 328, 624, 624, 624, - 624, 327, 624, 624, 624, 624, 624, 625, 624, 624, - 624, 624, 326, 624, 624, 325, 322, 320, 309, 633, - 624, 624, 624, 270, 294, 292, 291, 290, 287, 634, - 286, 270, 270, 269, 267, 265, 264, 239, 208, 263, - 237, 130, 241, 240, 624, 624, 624, 624, 239, 208, - - 238, 237, 236, 236, 634, 235, 234, 233, 106, 214, - 213, 207, 208, 207, 199, 191, 189, 165, 164, 148, - 116, 115, 106, 624, 624, 84, 88, 718, 718, 84, - 84, 718, 718, 84, 84, 84, 718, 84, 84, 84, - 84, 84, 85, 85, 85, 85, 85, 718, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 91, 91, 718, 718, 718, 91, 91, 91, - 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, - 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, - 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - - 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, - 149, 718, 718, 718, 149, 149, 149, 718, 149, 149, - 149, 718, 149, 149, 149, 149, 149, 190, 190, 190, - 190, 190, 718, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 209, 209, 718, - 718, 718, 718, 718, 718, 718, 718, 209, 718, 718, - - 718, 209, 209, 718, 209, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 245, 245, 245, 245, 245, - 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, - 245, 245, 245, 245, 245, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 268, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 149, 718, 718, 718, 149, - 149, 149, 718, 149, 149, 149, 718, 149, 149, 149, - - 149, 149, 275, 275, 275, 275, 275, 275, 275, 275, - 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - 275, 275, 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 312, 312, 312, 312, 312, 312, 312, 312, - 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, - 312, 312, 315, 315, 315, 315, 315, 315, 315, 315, - 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - - 315, 315, 319, 319, 718, 319, 319, 319, 319, 319, - 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, - 319, 319, 321, 321, 718, 321, 321, 321, 321, 321, - 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, - 321, 321, 323, 718, 323, 718, 718, 718, 323, 718, - 323, 323, 718, 718, 323, 367, 367, 367, 367, 367, - 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - 367, 367, 367, 367, 367, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 369, 369, 369, 369, 369, - - 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, - 369, 369, 369, 369, 369, 245, 245, 245, 245, 245, - 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, - 245, 245, 245, 245, 245, 372, 372, 372, 718, 372, - 372, 372, 372, 372, 377, 718, 718, 718, 377, 718, - 377, 377, 377, 377, 718, 718, 377, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 149, 718, 718, - - 718, 149, 149, 149, 718, 149, 149, 149, 718, 149, - 149, 149, 149, 149, 275, 275, 275, 275, 275, 275, - 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - 275, 275, 275, 275, 105, 105, 105, 105, 105, 105, - 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, - 105, 105, 105, 105, 315, 315, 315, 315, 315, 315, - 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - 315, 315, 315, 315, 312, 312, 312, 312, 312, 312, - 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, - 312, 312, 312, 312, 424, 424, 424, 424, 424, 424, - - 424, 424, 424, 424, 424, 424, 424, 424, 424, 424, - 424, 424, 424, 424, 427, 427, 427, 427, 427, 427, - 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, - 427, 427, 427, 427, 429, 429, 429, 429, 429, 429, - 429, 429, 429, 429, 429, 429, 429, 429, 429, 429, - 429, 429, 429, 429, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 319, 319, 718, 319, 319, 319, - 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, - 319, 319, 319, 319, 321, 321, 718, 321, 321, 321, - - 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, - 321, 321, 321, 321, 434, 718, 434, 718, 718, 718, - 434, 718, 434, 434, 718, 718, 434, 432, 718, 718, - 718, 718, 718, 432, 432, 432, 432, 432, 367, 367, - 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - 367, 367, 367, 367, 367, 367, 367, 367, 369, 369, - 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, - 369, 369, 369, 369, 369, 369, 369, 369, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 468, 468, - - 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, - 468, 468, 468, 468, 468, 468, 468, 468, 473, 473, - 718, 718, 473, 473, 718, 473, 473, 473, 473, 473, - 473, 473, 473, 473, 473, 475, 718, 718, 718, 718, - 718, 475, 475, 475, 475, 475, 718, 475, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 394, 105, 105, - 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, - 105, 105, 105, 105, 105, 105, 105, 105, 499, 499, - 718, 718, 499, 499, 499, 499, 499, 499, 499, 499, - - 499, 499, 499, 499, 499, 424, 424, 424, 424, 424, - 424, 424, 424, 424, 424, 424, 424, 424, 424, 424, - 424, 424, 424, 424, 424, 425, 425, 425, 425, 425, - 425, 425, 425, 425, 425, 425, 425, 425, 425, 425, - 425, 425, 425, 425, 425, 503, 503, 503, 503, 503, - 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, - 503, 503, 503, 503, 503, 427, 427, 427, 427, 427, - 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, - 427, 427, 427, 427, 427, 506, 506, 506, 506, 506, - 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, - - 506, 506, 506, 506, 506, 429, 429, 429, 429, 429, - 429, 429, 429, 429, 429, 429, 429, 429, 429, 429, - 429, 429, 429, 429, 429, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 509, 718, 718, 718, 718, - 718, 509, 509, 509, 509, 509, 511, 511, 718, 511, - 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 513, 513, 718, 513, - 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, - 513, 513, 513, 513, 513, 513, 515, 515, 718, 515, - - 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, - 515, 515, 515, 515, 515, 515, 517, 517, 718, 517, - 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, - 517, 517, 517, 517, 517, 517, 519, 519, 718, 519, - 519, 519, 519, 519, 519, 519, 519, 519, 519, 519, - 519, 519, 519, 519, 519, 519, 521, 521, 718, 521, - 521, 521, 521, 521, 521, 521, 521, 521, 521, 521, - 521, 521, 521, 521, 521, 521, 367, 367, 367, 367, - 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - 367, 367, 367, 367, 367, 367, 126, 126, 126, 126, - - 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 468, 468, 468, 468, - 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, - 468, 468, 468, 468, 468, 468, 548, 718, 718, 718, - 718, 718, 548, 548, 548, 548, 548, 548, 548, 548, - 548, 548, 554, 554, 554, 554, 554, 554, 554, 554, - 554, 554, 554, 554, 554, 554, 554, 554, 554, 554, - 554, 554, 105, 105, 105, 105, 105, 105, 105, 105, - 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, - 105, 105, 567, 567, 567, 567, 718, 567, 567, 567, - - 567, 567, 567, 567, 567, 567, 567, 567, 567, 567, - 567, 567, 570, 718, 718, 718, 718, 718, 570, 570, - 570, 570, 570, 577, 577, 718, 577, 577, 577, 577, - 577, 577, 577, 577, 577, 577, 577, 577, 577, 577, - 577, 577, 577, 625, 625, 718, 625, 625, 625, 625, - 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, - 625, 625, 625, 632, 632, 718, 632, 632, 632, 632, - 632, 632, 632, 632, 632, 632, 632, 632, 632, 632, - 632, 632, 632, 624, 624, 718, 624, 624, 624, 624, - 624, 624, 624, 624, 624, 624, 624, 624, 624, 624, - - 624, 624, 624, 660, 660, 660, 660, 660, 660, 660, - 660, 660, 660, 660, 660, 660, 660, 660, 660, 660, - 660, 660, 660, 682, 682, 682, 682, 682, 682, 682, - 682, 682, 682, 682, 682, 682, 682, 682, 682, 682, - 682, 682, 682, 685, 685, 685, 685, 685, 685, 685, - 685, 685, 685, 685, 685, 685, 685, 685, 685, 685, - 685, 685, 685, 700, 700, 700, 700, 700, 700, 700, - 700, 700, 700, 700, 700, 700, 700, 700, 700, 700, - 700, 700, 700, 3, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718 - } ; - -static yyconst flex_int16_t yy_chk[4761] = - { 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, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 5, 6, 6, 6, 6, 8, 10, 10, - 716, 11, 19, 39, 8, 8, 8, 8, 16, 51, - 51, 11, 13, 11, 11, 39, 397, 5, 11, 12, - 12, 12, 13, 101, 13, 101, 12, 40, 19, 13, - 88, 12, 12, 12, 12, 12, 12, 12, 12, 40, - - 56, 39, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 397, 53, 16, 56, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 15, 269, 15, 88, 15, 15, 15, 15, - 15, 15, 269, 28, 15, 21, 21, 21, 21, 20, - 20, 20, 20, 23, 23, 23, 23, 24, 24, 24, - 24, 53, 331, 22, 331, 15, 22, 22, 22, 22, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - - 15, 15, 20, 25, 38, 38, 696, 22, 86, 86, - 23, 28, 144, 15, 38, 38, 25, 25, 25, 25, - 28, 29, 128, 29, 29, 47, 93, 93, 29, 24, - 30, 30, 30, 30, 30, 31, 31, 47, 31, 31, - 31, 156, 37, 37, 32, 32, 592, 30, 32, 32, - 32, 37, 37, 37, 156, 128, 25, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 33, 692, 34, 34, 26, 26, 26, - 26, 34, 34, 34, 153, 144, 33, 33, 35, 35, - 691, 33, 33, 33, 685, 35, 35, 35, 153, 33, - - 36, 36, 26, 26, 26, 26, 42, 44, 36, 36, - 36, 41, 592, 41, 242, 44, 72, 72, 42, 57, - 57, 57, 57, 41, 72, 72, 72, 44, 45, 43, - 557, 26, 26, 27, 149, 27, 27, 27, 27, 27, - 27, 43, 45, 45, 45, 45, 149, 242, 42, 48, - 158, 158, 57, 157, 48, 58, 58, 58, 58, 48, - 44, 48, 48, 41, 27, 157, 48, 190, 190, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 50, 191, 191, 59, 557, 43, 59, 59, 59, - 59, 50, 27, 50, 61, 61, 61, 61, 50, 70, - - 70, 45, 49, 49, 49, 70, 70, 70, 59, 49, - 60, 60, 60, 60, 49, 49, 49, 49, 49, 49, - 49, 49, 97, 97, 97, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 61, 60, 64, 684, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 52, 192, 192, 52, 62, - 52, 215, 52, 52, 52, 52, 52, 52, 645, 183, - 52, 215, 62, 62, 62, 62, 64, 65, 215, 65, - - 65, 183, 68, 68, 65, 64, 68, 68, 68, 67, - 67, 52, 67, 67, 67, 260, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 83, 83, - 83, 83, 62, 66, 66, 66, 66, 66, 69, 52, - 63, 335, 63, 63, 63, 63, 63, 63, 645, 183, - 66, 69, 69, 71, 71, 335, 69, 69, 69, 87, - 71, 71, 71, 166, 69, 260, 87, 87, 87, 87, - 87, 63, 100, 100, 100, 166, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 193, 193, - 232, 73, 73, 74, 74, 75, 232, 166, 75, 63, - - 73, 73, 73, 74, 74, 76, 77, 75, 76, 77, - 75, 77, 78, 79, 80, 78, 79, 76, 77, 80, - 76, 77, 80, 244, 78, 79, 81, 78, 79, 194, - 194, 80, 682, 167, 80, 543, 75, 81, 102, 680, - 81, 81, 81, 81, 92, 167, 92, 187, 102, 543, - 102, 92, 98, 98, 98, 102, 614, 78, 186, 187, - 151, 77, 275, 275, 98, 244, 98, 80, 151, 151, - 186, 98, 151, 79, 119, 119, 119, 119, 136, 136, - 136, 136, 137, 137, 137, 137, 138, 138, 138, 138, - 168, 168, 168, 168, 167, 359, 187, 311, 311, 81, - - 91, 152, 91, 91, 91, 91, 91, 91, 154, 152, - 165, 614, 146, 152, 188, 137, 154, 186, 312, 312, - 154, 171, 165, 138, 678, 188, 146, 146, 146, 146, - 146, 91, 672, 171, 313, 313, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, 196, 196, - 171, 165, 314, 314, 359, 196, 196, 196, 196, 91, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 110, 216, 216, 216, 216, 110, 315, 315, - 110, 110, 110, 110, 110, 146, 671, 188, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - - 110, 110, 110, 110, 110, 110, 110, 110, 110, 217, - 217, 217, 217, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, 112, 180, - 670, 112, 112, 112, 112, 112, 173, 180, 180, 180, - 180, 180, 181, 184, 185, 273, 304, 378, 173, 329, - 181, 181, 181, 181, 181, 184, 185, 273, 304, 112, - 218, 218, 218, 218, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 666, 173, 221, 221, - 221, 221, 360, 181, 316, 316, 663, 112, 113, 304, - - 113, 222, 222, 222, 222, 113, 113, 378, 184, 185, - 113, 195, 195, 236, 113, 424, 424, 360, 195, 195, - 195, 195, 195, 113, 329, 113, 223, 223, 223, 223, - 662, 113, 113, 426, 426, 361, 236, 113, 233, 233, - 233, 233, 113, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 182, - 361, 236, 277, 127, 127, 127, 127, 182, 182, 182, - 182, 182, 200, 233, 298, 307, 298, 201, 226, 200, - 201, 201, 201, 201, 201, 226, 298, 307, 127, 127, - 127, 127, 224, 224, 224, 224, 224, 224, 224, 224, - - 224, 224, 224, 200, 182, 427, 427, 333, 201, 226, - 234, 234, 234, 234, 395, 277, 395, 127, 127, 129, - 129, 129, 129, 129, 277, 129, 129, 129, 129, 129, - 129, 200, 657, 129, 129, 307, 201, 226, 272, 129, - 129, 342, 129, 272, 254, 234, 243, 243, 243, 243, - 254, 254, 254, 254, 342, 272, 267, 241, 241, 241, - 241, 267, 267, 383, 129, 129, 129, 255, 369, 290, - 293, 266, 333, 656, 255, 255, 255, 255, 271, 342, - 255, 290, 293, 271, 398, 266, 266, 266, 266, 655, - 271, 243, 654, 129, 129, 131, 131, 131, 131, 131, - - 131, 131, 131, 131, 131, 131, 131, 132, 132, 241, - 369, 255, 132, 383, 290, 132, 132, 132, 132, 132, - 651, 132, 293, 132, 132, 132, 132, 132, 132, 132, - 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, - 132, 132, 132, 132, 266, 398, 132, 476, 132, 132, - 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, - 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, - 132, 132, 132, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 135, 135, 428, 428, 308, - 135, 429, 429, 135, 135, 135, 135, 476, 650, 135, - - 308, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 323, 323, 323, 323, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 155, 155, 155, 274, 486, 486, 486, 155, 274, - 291, 400, 308, 155, 155, 291, 155, 155, 155, 155, - 155, 274, 291, 400, 155, 155, 155, 155, 155, 155, - 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, - 155, 155, 155, 155, 155, 339, 339, 339, 339, 155, - - 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, - 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, - 155, 155, 155, 155, 159, 303, 302, 288, 302, 367, - 368, 303, 503, 503, 256, 648, 159, 303, 302, 288, - 278, 256, 256, 256, 256, 281, 647, 256, 278, 278, - 278, 278, 278, 281, 281, 281, 281, 281, 350, 350, - 350, 350, 367, 368, 643, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159, 159, 160, 256, 306, - 411, 303, 160, 642, 306, 160, 160, 160, 160, 160, - 288, 306, 411, 160, 160, 160, 160, 160, 160, 160, - - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 373, 373, 373, 373, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 162, 282, 698, 162, 162, 162, 162, - 162, 641, 282, 282, 282, 282, 282, 283, 283, 283, - 283, 283, 283, 283, 283, 283, 283, 283, 318, 318, - 374, 374, 374, 374, 162, 318, 318, 318, 318, 162, - 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, - 162, 430, 430, 456, 505, 505, 430, 434, 434, 434, - - 434, 556, 162, 175, 175, 175, 175, 175, 175, 175, - 175, 175, 175, 175, 175, 176, 176, 343, 698, 456, - 176, 506, 506, 176, 176, 176, 176, 176, 459, 176, - 343, 176, 176, 176, 176, 176, 176, 176, 176, 176, - 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, - 176, 176, 556, 459, 176, 343, 176, 176, 176, 176, - 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, - 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, - 176, 178, 178, 178, 178, 178, 178, 178, 178, 178, - 178, 178, 178, 179, 179, 346, 640, 502, 179, 568, - - 568, 179, 179, 179, 179, 179, 502, 179, 346, 179, - 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, - 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, - 370, 370, 370, 346, 179, 179, 179, 179, 179, 179, - 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, - 179, 179, 179, 179, 179, 179, 179, 179, 179, 219, - 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, - 286, 292, 488, 591, 591, 370, 487, 465, 286, 286, - 286, 286, 286, 292, 219, 219, 219, 219, 219, 219, - 219, 219, 219, 219, 219, 219, 220, 220, 220, 220, - - 220, 220, 220, 220, 220, 220, 220, 300, 601, 300, - 465, 638, 606, 286, 637, 300, 300, 300, 300, 300, - 292, 220, 220, 220, 220, 220, 220, 220, 220, 220, - 220, 220, 220, 225, 225, 487, 420, 488, 225, 606, - 629, 225, 225, 225, 225, 225, 623, 225, 420, 225, - 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, - 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, - 628, 623, 225, 601, 225, 225, 225, 225, 225, 225, - 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, - 225, 225, 225, 225, 225, 225, 225, 225, 225, 245, - - 245, 245, 245, 245, 376, 245, 245, 245, 245, 245, - 245, 289, 622, 245, 245, 287, 289, 376, 624, 245, - 245, 294, 245, 287, 287, 287, 287, 287, 289, 294, - 294, 294, 294, 294, 289, 305, 620, 613, 379, 380, - 659, 659, 376, 624, 245, 245, 245, 305, 376, 334, - 412, 379, 380, 334, 338, 390, 345, 421, 287, 289, - 334, 338, 412, 345, 482, 390, 482, 390, 404, 421, - 404, 482, 390, 245, 245, 246, 379, 380, 305, 412, - 404, 294, 379, 380, 630, 338, 626, 345, 246, 613, - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - - 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, - 246, 626, 421, 338, 334, 345, 555, 555, 555, 246, - 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - 248, 248, 257, 422, 396, 699, 619, 658, 673, 630, - 729, 729, 396, 618, 422, 257, 396, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 442, 612, - 257, 532, 431, 375, 375, 631, 257, 279, 375, 496, - 442, 375, 375, 375, 375, 431, 532, 375, 658, 279, - 673, 496, 407, 279, 279, 279, 279, 279, 279, 279, - - 279, 279, 279, 279, 407, 406, 422, 611, 699, 634, - 431, 610, 375, 406, 406, 406, 406, 406, 279, 279, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 284, 284, 444, 496, 634, 284, 631, 608, 284, 284, - 284, 284, 284, 407, 284, 444, 284, 284, 284, 284, - 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, - 284, 284, 284, 284, 284, 284, 284, 700, 607, 284, - 444, 284, 284, 284, 284, 284, 284, 284, 284, 284, - 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, - 284, 284, 284, 284, 284, 284, 295, 295, 644, 418, - - 605, 418, 687, 730, 730, 603, 633, 602, 295, 646, - 295, 418, 295, 295, 295, 295, 295, 295, 295, 295, - 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, - 295, 295, 295, 633, 731, 731, 667, 646, 667, 600, - 700, 295, 296, 296, 296, 296, 296, 296, 296, 296, - 296, 296, 296, 296, 301, 445, 644, 687, 633, 466, - 466, 466, 646, 667, 469, 469, 469, 301, 445, 301, - 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, - 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, - 414, 388, 301, 445, 599, 693, 590, 604, 301, 324, - - 589, 408, 414, 324, 466, 388, 388, 388, 388, 469, - 324, 604, 324, 408, 324, 324, 324, 324, 324, 324, - 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, - 324, 324, 324, 324, 324, 414, 715, 324, 587, 324, - 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, - 324, 409, 408, 693, 415, 391, 409, 413, 489, 451, - 489, 665, 324, 337, 388, 391, 415, 391, 409, 413, - 489, 585, 391, 451, 451, 665, 337, 584, 337, 337, - 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, - 337, 337, 337, 337, 337, 337, 337, 337, 337, 415, - - 419, 337, 341, 583, 413, 582, 419, 734, 734, 715, - 409, 660, 419, 751, 751, 341, 581, 341, 341, 341, - 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, - 341, 341, 341, 341, 341, 341, 341, 341, 668, 660, - 341, 344, 344, 344, 344, 344, 344, 344, 344, 344, - 344, 344, 344, 399, 399, 580, 419, 579, 546, 546, - 546, 668, 578, 668, 660, 399, 577, 399, 576, 399, - 399, 399, 399, 399, 399, 399, 399, 399, 399, 399, - 399, 399, 399, 399, 399, 399, 399, 399, 399, 399, - 416, 470, 399, 401, 574, 495, 573, 572, 416, 416, - - 416, 416, 416, 546, 470, 457, 401, 495, 401, 401, - 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, - 401, 401, 401, 401, 401, 401, 401, 401, 401, 470, - 471, 401, 402, 500, 491, 457, 571, 410, 570, 491, - 495, 567, 492, 471, 402, 500, 457, 417, 417, 410, - 472, 491, 417, 480, 492, 417, 417, 417, 417, 417, - 410, 417, 457, 472, 566, 480, 639, 653, 471, 492, - 554, 681, 639, 402, 402, 402, 402, 402, 402, 402, - 402, 402, 402, 402, 402, 410, 417, 448, 472, 497, - 553, 639, 653, 552, 551, 492, 681, 639, 653, 549, - - 448, 497, 448, 448, 448, 448, 448, 448, 448, 448, - 448, 448, 448, 448, 448, 448, 448, 448, 448, 448, - 448, 448, 448, 501, 596, 448, 480, 490, 490, 564, - 548, 544, 542, 541, 501, 540, 596, 539, 538, 490, - 564, 490, 497, 490, 490, 490, 490, 490, 490, 490, - 490, 490, 490, 490, 490, 490, 490, 490, 490, 490, - 490, 490, 490, 490, 493, 494, 490, 498, 499, 493, - 499, 697, 498, 510, 525, 526, 694, 494, 537, 531, - 499, 493, 508, 508, 498, 494, 510, 525, 526, 508, - 508, 508, 508, 531, 531, 558, 501, 558, 559, 536, - - 550, 535, 564, 533, 694, 530, 560, 558, 561, 562, - 559, 510, 525, 526, 550, 550, 550, 550, 560, 563, - 561, 562, 697, 529, 593, 569, 569, 588, 594, 694, - 527, 563, 569, 569, 569, 569, 593, 595, 560, 559, - 594, 588, 588, 588, 588, 597, 524, 598, 523, 595, - 616, 635, 522, 521, 562, 661, 593, 597, 598, 520, - 563, 617, 616, 635, 636, 649, 652, 561, 562, 519, - 674, 652, 617, 550, 664, 636, 649, 661, 518, 677, - 517, 595, 516, 661, 515, 664, 675, 594, 690, 514, - 677, 652, 513, 512, 511, 616, 509, 504, 674, 690, - - 588, 485, 661, 674, 695, 597, 701, 702, 661, 484, - 483, 481, 689, 479, 675, 695, 477, 701, 702, 475, - 598, 609, 609, 674, 609, 609, 609, 609, 609, 688, - 609, 609, 609, 609, 617, 609, 609, 636, 649, 675, - 689, 609, 609, 609, 609, 675, 473, 664, 703, 704, - 468, 609, 677, 705, 464, 688, 463, 688, 462, 703, - 704, 690, 706, 689, 705, 689, 609, 609, 609, 609, - 461, 460, 458, 706, 707, 708, 609, 695, 709, 701, - 702, 710, 688, 711, 455, 707, 708, 454, 712, 709, - 453, 452, 710, 450, 711, 609, 609, 615, 615, 712, - - 615, 615, 615, 615, 615, 615, 615, 615, 615, 615, - 449, 615, 615, 713, 446, 441, 440, 615, 615, 615, - 615, 703, 704, 439, 713, 714, 705, 615, 438, 437, - 436, 435, 433, 432, 425, 706, 714, 423, 405, 403, - 394, 393, 615, 615, 615, 615, 392, 707, 708, 389, - 387, 709, 615, 385, 710, 381, 711, 377, 372, 371, - 366, 712, 365, 364, 363, 358, 357, 356, 355, 354, - 353, 615, 615, 625, 625, 352, 625, 625, 625, 625, - 625, 351, 625, 625, 625, 625, 713, 625, 625, 348, - 347, 332, 330, 625, 625, 625, 625, 328, 714, 327, - - 326, 325, 322, 625, 321, 320, 319, 309, 299, 297, - 285, 280, 276, 270, 268, 264, 263, 262, 625, 625, - 625, 625, 261, 259, 258, 252, 251, 250, 625, 240, - 239, 238, 237, 235, 231, 230, 229, 228, 227, 214, - 213, 212, 211, 210, 207, 206, 205, 625, 625, 632, - 632, 204, 632, 632, 632, 632, 632, 632, 632, 632, - 632, 632, 203, 632, 632, 202, 198, 197, 189, 632, - 632, 632, 632, 177, 174, 172, 170, 169, 164, 632, - 163, 161, 150, 148, 147, 145, 143, 142, 141, 140, - 139, 126, 125, 124, 632, 632, 632, 632, 123, 122, - - 121, 120, 118, 117, 632, 116, 115, 114, 105, 103, - 99, 96, 95, 94, 90, 85, 82, 55, 54, 46, - 18, 17, 14, 632, 632, 719, 9, 3, 0, 719, - 719, 0, 0, 719, 719, 719, 0, 719, 719, 719, - 719, 719, 720, 720, 720, 720, 720, 0, 720, 720, - 720, 720, 720, 720, 720, 720, 720, 720, 720, 720, - 720, 720, 721, 721, 0, 0, 0, 721, 721, 721, - 722, 722, 722, 722, 722, 722, 722, 722, 722, 722, - 722, 722, 722, 722, 722, 722, 722, 722, 722, 722, - 723, 723, 723, 723, 723, 723, 723, 723, 723, 723, - - 723, 723, 723, 723, 723, 723, 723, 723, 723, 723, - 724, 724, 724, 724, 724, 724, 724, 724, 724, 724, - 724, 724, 724, 724, 724, 724, 724, 724, 724, 724, - 725, 0, 0, 0, 725, 725, 725, 0, 725, 725, - 725, 0, 725, 725, 725, 725, 725, 726, 726, 726, - 726, 726, 0, 726, 726, 726, 726, 726, 726, 726, - 726, 726, 726, 726, 726, 726, 726, 727, 727, 727, - 727, 727, 727, 727, 727, 727, 727, 727, 727, 727, - 727, 727, 727, 727, 727, 727, 727, 728, 728, 0, - 0, 0, 0, 0, 0, 0, 0, 728, 0, 0, - - 0, 728, 728, 0, 728, 732, 732, 732, 732, 732, - 732, 732, 732, 732, 732, 732, 732, 732, 732, 732, - 732, 732, 732, 732, 732, 733, 733, 733, 733, 733, - 733, 733, 733, 733, 733, 733, 733, 733, 733, 733, - 733, 733, 733, 733, 733, 735, 735, 735, 735, 735, - 735, 735, 735, 735, 735, 735, 735, 735, 735, 735, - 735, 735, 735, 735, 735, 736, 736, 736, 736, 736, - 736, 736, 736, 736, 736, 736, 736, 736, 736, 736, - 736, 736, 736, 736, 736, 737, 0, 0, 0, 737, - 737, 737, 0, 737, 737, 737, 0, 737, 737, 737, - - 737, 737, 738, 738, 738, 738, 738, 738, 738, 738, - 738, 738, 738, 738, 738, 738, 738, 738, 738, 738, - 738, 738, 739, 739, 739, 739, 739, 739, 739, 739, - 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, - 739, 739, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 740, 740, 740, 740, 740, 740, 740, 740, - 740, 740, 741, 741, 741, 741, 741, 741, 741, 741, - 741, 741, 741, 741, 741, 741, 741, 741, 741, 741, - 741, 741, 742, 742, 742, 742, 742, 742, 742, 742, - 742, 742, 742, 742, 742, 742, 742, 742, 742, 742, - - 742, 742, 743, 743, 0, 743, 743, 743, 743, 743, - 743, 743, 743, 743, 743, 743, 743, 743, 743, 743, - 743, 743, 744, 744, 0, 744, 744, 744, 744, 744, - 744, 744, 744, 744, 744, 744, 744, 744, 744, 744, - 744, 744, 745, 0, 745, 0, 0, 0, 745, 0, - 745, 745, 0, 0, 745, 746, 746, 746, 746, 746, - 746, 746, 746, 746, 746, 746, 746, 746, 746, 746, - 746, 746, 746, 746, 746, 747, 747, 747, 747, 747, - 747, 747, 747, 747, 747, 747, 747, 747, 747, 747, - 747, 747, 747, 747, 747, 748, 748, 748, 748, 748, - - 748, 748, 748, 748, 748, 748, 748, 748, 748, 748, - 748, 748, 748, 748, 748, 749, 749, 749, 749, 749, - 749, 749, 749, 749, 749, 749, 749, 749, 749, 749, - 749, 749, 749, 749, 749, 750, 750, 750, 0, 750, - 750, 750, 750, 750, 752, 0, 0, 0, 752, 0, - 752, 752, 752, 752, 0, 0, 752, 753, 753, 753, - 753, 753, 753, 753, 753, 753, 753, 753, 753, 753, - 753, 753, 753, 753, 753, 753, 753, 754, 754, 754, - 754, 754, 754, 754, 754, 754, 754, 754, 754, 754, - 754, 754, 754, 754, 754, 754, 754, 755, 0, 0, - - 0, 755, 755, 755, 0, 755, 755, 755, 0, 755, - 755, 755, 755, 755, 756, 756, 756, 756, 756, 756, - 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - 756, 756, 756, 756, 757, 757, 757, 757, 757, 757, - 757, 757, 757, 757, 757, 757, 757, 757, 757, 757, - 757, 757, 757, 757, 758, 758, 758, 758, 758, 758, - 758, 758, 758, 758, 758, 758, 758, 758, 758, 758, - 758, 758, 758, 758, 759, 759, 759, 759, 759, 759, - 759, 759, 759, 759, 759, 759, 759, 759, 759, 759, - 759, 759, 759, 759, 760, 760, 760, 760, 760, 760, - - 760, 760, 760, 760, 760, 760, 760, 760, 760, 760, - 760, 760, 760, 760, 761, 761, 761, 761, 761, 761, - 761, 761, 761, 761, 761, 761, 761, 761, 761, 761, - 761, 761, 761, 761, 762, 762, 762, 762, 762, 762, - 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, - 762, 762, 762, 762, 763, 763, 763, 763, 763, 763, - 763, 763, 763, 763, 763, 763, 763, 763, 763, 763, - 763, 763, 763, 763, 764, 764, 0, 764, 764, 764, - 764, 764, 764, 764, 764, 764, 764, 764, 764, 764, - 764, 764, 764, 764, 765, 765, 0, 765, 765, 765, - - 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, - 765, 765, 765, 765, 766, 0, 766, 0, 0, 0, - 766, 0, 766, 766, 0, 0, 766, 767, 0, 0, - 0, 0, 0, 767, 767, 767, 767, 767, 768, 768, - 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, - 768, 768, 768, 768, 768, 768, 768, 768, 769, 769, - 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, - 769, 769, 769, 769, 769, 769, 769, 769, 770, 770, - 770, 770, 770, 770, 770, 770, 770, 770, 770, 770, - 770, 770, 770, 770, 770, 770, 770, 770, 771, 771, - - 771, 771, 771, 771, 771, 771, 771, 771, 771, 771, - 771, 771, 771, 771, 771, 771, 771, 771, 772, 772, - 0, 0, 772, 772, 0, 772, 772, 772, 772, 772, - 772, 772, 772, 772, 772, 773, 0, 0, 0, 0, - 0, 773, 773, 773, 773, 773, 0, 773, 774, 774, - 774, 774, 774, 774, 774, 774, 774, 774, 774, 774, - 774, 774, 774, 774, 774, 774, 774, 774, 775, 775, - 775, 775, 775, 775, 775, 775, 775, 775, 775, 775, - 775, 775, 775, 775, 775, 775, 775, 775, 776, 776, - 0, 0, 776, 776, 776, 776, 776, 776, 776, 776, - - 776, 776, 776, 776, 776, 777, 777, 777, 777, 777, - 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - 777, 777, 777, 777, 777, 778, 778, 778, 778, 778, - 778, 778, 778, 778, 778, 778, 778, 778, 778, 778, - 778, 778, 778, 778, 778, 779, 779, 779, 779, 779, - 779, 779, 779, 779, 779, 779, 779, 779, 779, 779, - 779, 779, 779, 779, 779, 780, 780, 780, 780, 780, - 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, - 780, 780, 780, 780, 780, 781, 781, 781, 781, 781, - 781, 781, 781, 781, 781, 781, 781, 781, 781, 781, - - 781, 781, 781, 781, 781, 782, 782, 782, 782, 782, - 782, 782, 782, 782, 782, 782, 782, 782, 782, 782, - 782, 782, 782, 782, 782, 783, 783, 783, 783, 783, - 783, 783, 783, 783, 783, 783, 783, 783, 783, 783, - 783, 783, 783, 783, 783, 784, 0, 0, 0, 0, - 0, 784, 784, 784, 784, 784, 785, 785, 0, 785, - 785, 785, 785, 785, 785, 785, 785, 785, 785, 785, - 785, 785, 785, 785, 785, 785, 786, 786, 0, 786, - 786, 786, 786, 786, 786, 786, 786, 786, 786, 786, - 786, 786, 786, 786, 786, 786, 787, 787, 0, 787, - - 787, 787, 787, 787, 787, 787, 787, 787, 787, 787, - 787, 787, 787, 787, 787, 787, 788, 788, 0, 788, - 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, - 788, 788, 788, 788, 788, 788, 789, 789, 0, 789, - 789, 789, 789, 789, 789, 789, 789, 789, 789, 789, - 789, 789, 789, 789, 789, 789, 790, 790, 0, 790, - 790, 790, 790, 790, 790, 790, 790, 790, 790, 790, - 790, 790, 790, 790, 790, 790, 791, 791, 791, 791, - 791, 791, 791, 791, 791, 791, 791, 791, 791, 791, - 791, 791, 791, 791, 791, 791, 792, 792, 792, 792, - - 792, 792, 792, 792, 792, 792, 792, 792, 792, 792, - 792, 792, 792, 792, 792, 792, 793, 793, 793, 793, - 793, 793, 793, 793, 793, 793, 793, 793, 793, 793, - 793, 793, 793, 793, 793, 793, 794, 0, 0, 0, - 0, 0, 794, 794, 794, 794, 794, 794, 794, 794, - 794, 794, 795, 795, 795, 795, 795, 795, 795, 795, - 795, 795, 795, 795, 795, 795, 795, 795, 795, 795, - 795, 795, 796, 796, 796, 796, 796, 796, 796, 796, - 796, 796, 796, 796, 796, 796, 796, 796, 796, 796, - 796, 796, 797, 797, 797, 797, 0, 797, 797, 797, - - 797, 797, 797, 797, 797, 797, 797, 797, 797, 797, - 797, 797, 798, 0, 0, 0, 0, 0, 798, 798, - 798, 798, 798, 799, 799, 0, 799, 799, 799, 799, - 799, 799, 799, 799, 799, 799, 799, 799, 799, 799, - 799, 799, 799, 800, 800, 0, 800, 800, 800, 800, - 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, - 800, 800, 800, 801, 801, 0, 801, 801, 801, 801, - 801, 801, 801, 801, 801, 801, 801, 801, 801, 801, - 801, 801, 801, 802, 802, 0, 802, 802, 802, 802, - 802, 802, 802, 802, 802, 802, 802, 802, 802, 802, - - 802, 802, 802, 803, 803, 803, 803, 803, 803, 803, - 803, 803, 803, 803, 803, 803, 803, 803, 803, 803, - 803, 803, 803, 804, 804, 804, 804, 804, 804, 804, - 804, 804, 804, 804, 804, 804, 804, 804, 804, 804, - 804, 804, 804, 805, 805, 805, 805, 805, 805, 805, - 805, 805, 805, 805, 805, 805, 805, 805, 805, 805, - 805, 805, 805, 806, 806, 806, 806, 806, 806, 806, - 806, 806, 806, 806, 806, 806, 806, 806, 806, 806, - 806, 806, 806, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718, - 718, 718, 718, 718, 718, 718, 718, 718, 718, 718 - } ; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; -static char *yy_full_match; -static int yy_lp; -static int yy_looking_for_trail_begin = 0; -static int yy_full_lp; -static int *yy_full_state; -#define YY_TRAILING_MASK 0x2000 -#define YY_TRAILING_HEAD_MASK 0x4000 -#define REJECT \ -{ \ -*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ \ -yy_cp = (yy_full_match); /* restore poss. backed-over text */ \ -(yy_lp) = (yy_full_lp); /* restore orig. accepting pos. */ \ -(yy_state_ptr) = (yy_full_state); /* restore orig. state */ \ -yy_current_state = *(yy_state_ptr); /* restore curr. state */ \ -++(yy_lp); \ -goto find_rule; \ -} - -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "parser.l" -#line 8 "parser.l" /* - * parser.l -- lex parser of algebraic chess moves for XBoard - * - * Copyright 1991 by Digital Equipment Corporation, Maynard, - * Massachusetts. - * - * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, - * 2006, 2007, 2008, 2009 Free Software Foundation, Inc. - * - * The following terms apply to Digital Equipment Corporation's copyright - * interest in XBoard: - * ------------------------------------------------------------------------ - * All Rights Reserved + * parser.c -- * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Digital not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * - * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR - * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * ------------------------------------------------------------------------ - * - * The following terms apply to the enhanced version of XBoard - * distributed by the Free Software Foundation: + * Copyright 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc. * ------------------------------------------------------------------------ * * GNU XBoard is free software: you can redistribute it and/or modify @@ -1891,2515 +15,880 @@ char *yytext; * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. + * along with this program. If not, see http://www.gnu.org/licenses/. * * *------------------------------------------------------------------------ ** See the file ChangeLog for a revision history. */ -/* This parser handles all forms of promotion. - * The parser resolves ambiguous moves by searching and check-testing. - * It also parses comments of the form [anything] or (anything). - * - * [HGM] Parser extensively modified for bigger boards, Shogi-like syntax, - * and unknow pieces. All pieces are now mandatory upper case, but can be - * any letter A-Z. Files must be lower case (as before), but can run upto 'l'. - * Ranks can be 0-9. The parser returns 0 for off-board files and ranks. - * For an unknown piece (as mover or promotion piece) it returns - * IllegalMove, like it does when the piece doesn't match. - * Promotions can now also be appended Shogi-style, a bare '=' or '^', - * and this is then returned as promotion character. The piece indicator - * can be prefixed by a '+' to indicate it is a promoted piece. - */ - #include "config.h" - -#define NO_CONSTRAINT -1 -#undef YYLMAX -#define YYLMAX 4096 -#define UNPUT_BUF_SIZE YYLMAX - -#ifdef FLEX_SCANNER -/* yytext is probably a char*, but could be a char[]. yy_text is set - in YY_DECL below, because if yytext is a char*, its value is not - constant. */ -char *yy_text; -#else /*!FLEX_SCANNER*/ -/* yytext is definitely a char[], so yy_text can be set here, statically. */ -char *yy_text = (char *) yytext; -#endif - -#ifdef FLEX_SCANNER -/* This is flex */ -/* [AP] use prototypes in function declarations */ -#define YY_USE_PROTOS - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif -/* end of [AP] fix */ - -#undef YY_INPUT -#define YY_INPUT(buf, result, max_size) my_yy_input(buf, &result, max_size) -#undef YY_DECL -#define YY_DECL \ - int _yylex YY_PROTO((void)); \ - int yylex YY_PROTO((void)) \ - { \ - int result = _yylex(); \ - yy_text = (char *) yytext; \ - return(result); \ - } \ - int _yylex YY_PROTO((void)) -#else -/* This is lex */ -#undef input -#undef output -#undef unput -#endif - -/* The includes must be here, below the #undef input */ - +#include +#include #include - -#if STDC_HEADERS -# include -# include -#else /* not STDC_HEADERS */ -# if HAVE_STRING_H -# include -# else /* not HAVE_STRING_H */ -# include -# endif /* not HAVE_STRING_H */ -#endif /* not STDC_HEADERS */ - -#if HAVE_UNISTD_H -# include -#endif - -#if defined(_amigados) -# include -# if HAVE_FCNTL_H -# include /* isatty() prototype */ -# endif /* HAVE_FCNTL_H */ -#endif /* defined(_amigados) */ - +#include #include "common.h" #include "backend.h" #include "frontend.h" #include "parser.h" #include "moves.h" -extern int PosFlags P((int)); extern Board boards[MAX_MOVES]; +extern int PosFlags(int nr); int yyboardindex; int yyskipmoves = FALSE; -char currentMoveString[YYLMAX]; -#ifndef FLEX_SCANNER -char unputBuffer[UNPUT_BUF_SIZE]; -int unputCount = 0; -#endif - -#ifdef FLEX_SCANNER -void my_yy_input P((char *buf, int *result, int max_size)); -#else /*!FLEX_SCANNER*/ -static int input P((void)); -static void output P((int ch)); -static void unput P((int ch)); -int yylook P((void)); -int yyback P((int *, int)); -#endif -#undef yywrap -int yywrap P((void)); -extern void CopyBoard P((Board to, Board from)); - -#line 2019 "parser.c" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (void ); -#else -extern int yywrap (void ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#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 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_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int 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 \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#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 - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (void); - -#define YY_DECL int yylex (void) -#endif /* !YY_DECL */ - -/* 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_LVALUE->yy_at_bol = \ - (yytext[yyleng - 1] == '\n'); \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 179 "parser.l" - - -#line 2178 "parser.c" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! (yy_state_buf) ) - (yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE ); - if ( ! (yy_state_buf) ) - YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - 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_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*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 >= 719 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *(yy_state_ptr)++ = yy_current_state; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 4684 ); - -yy_find_action: - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; -find_rule: /* we branch to this label when backing up */ - for ( ; ; ) /* until we find what rule we matched */ - { - if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] ) - { - yy_act = yy_acclist[(yy_lp)]; - if ( yy_act & YY_TRAILING_HEAD_MASK || - (yy_looking_for_trail_begin) ) - { - if ( yy_act == (yy_looking_for_trail_begin) ) - { - (yy_looking_for_trail_begin) = 0; - yy_act &= ~YY_TRAILING_HEAD_MASK; - break; - } - } - else if ( yy_act & YY_TRAILING_MASK ) - { - (yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK; - (yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK; - } - else - { - (yy_full_match) = yy_cp; - (yy_full_state) = (yy_state_ptr); - (yy_full_lp) = (yy_lp); - break; - } - ++(yy_lp); - goto find_rule; - } - --yy_cp; - yy_current_state = *--(yy_state_ptr); - (yy_lp) = 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 1: -YY_RULE_SETUP -#line 181 "parser.l" -{ - /* - * Fully-qualified algebraic move, possibly with promotion - */ - int skip1 = 0, skip2 = 0, skip3 = 0, promoted = 0; - ChessSquare piece; - ChessMove result; - char c; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - if (yytext[0] == '+') skip1 = skip3 = promoted = 1; /* [HGM] Shogi promoted */ - - /* remove the / */ - if (yytext[1+skip1] == '/') skip1++; - - /* remove the [xX:-] */ - if ((yytext[3+skip1] == 'x') || (yytext[3+skip1] == 'X') || - (yytext[3+skip1] == '-') || (yytext[3+skip1] == ':')) skip2 = 1; - - currentMoveString[0] = yytext[1+skip1]; - currentMoveString[1] = yytext[2+skip1]; - currentMoveString[2] = yytext[3+skip1+skip2]; - currentMoveString[3] = yytext[4+skip1+skip2]; - currentMoveString[4] = NULLCHAR; - - if (appData.debugMode) { - fprintf(debugFP, "Parser Qa1b2: yyleng=%d\n", - yyleng); - } +char currentMoveString[4096]; // a bit ridiculous size? +char *yy_text; - if (yyleng-skip1-skip2 > 5) { char c; - if (yytext[yyleng-1] == ')') { - c = currentMoveString[4] = ToLower(yytext[yyleng-2]); - } else { - c = currentMoveString[4] = ToLower(yytext[yyleng-1]); +#define PARSEBUFSIZE 10000 + +static FILE *inputFile; +static char *inPtr, *parsePtr, *parseStart; +static char inputBuf[PARSEBUFSIZE]; +static char yytext[PARSEBUFSIZE]; +static char fromString = 0, lastChar = '\n'; + +#define NOTHING 0 +#define NUMERIC 1 +#define ALPHABETIC 2 +#define BADNUMBER (-2000000000) + +#define XCO 0 +#define YCO 53 +#define PIECE 94 +#define MISC 155 +#define JIS 200 + +unsigned char kanjiTab[] = { + '1', 0357, 0274, 0221, // kanji notation for arabic digits + '2', 0357, 0274, 0222, + '3', 0357, 0274, 0223, + '4', 0357, 0274, 0224, + '5', 0357, 0274, 0225, + '6', 0357, 0274, 0226, + '7', 0357, 0274, 0227, + '8', 0357, 0274, 0230, + '9', 0357, 0274, 0231, + 'x', 0345, 0220, 0214, + 's', 0345, 0205, 0210, // sente + 'g', 0345, 0276, 0214, // gote + '-', 0346, 0212, 0225, // resign + 0, + 'a', 0344, 0270, 0200, // in reality these are numbers in Japanese a=1, b=2 etc. + 'b', 0344, 0272, 0214, + 'c', 0344, 0270, 0211, + 'd', 0345, 0233, 0233, + 'e', 0344, 0272, 0224, + 'f', 0345, 0205, 0255, + 'g', 0344, 0270, 0203, + 'h', 0345, 0205, 0253, + 'i', 0344, 0271, 0235, + ' ', 0343, 0200, 0200, + 0, + 'K', 0347, 0216, 0211, // piece names + 'K', 0347, 0216, 0213, + 'G', 0351, 0207, 0221, + 'S', 0351, 0212, 0200, + 'R', 0351, 0243, 0233, + 'B', 0350, 0247, 0222, + 'N', 0346, 0241, 0202, + 'L', 0351, 0246, 0231, + 'P', 0346, 0255, 0251, + 'r', 0351, 0276, 0215, + 'b', 0351, 0246, 0254, + 'p', 0343, 0201, 0250, + 'r', 0347, 0253, 0234, + '+', 0346, 0210, 0220, + 'G', 0, 0, 0, + 0, + '+', 0346, 0210, 0220, // helper + '@', 0346, 0211, 0223, + 'p', 0346, 0211, 0213, // player + ':', 0357, 0274, 0232, + '-', 0344, 0272, 0206, + 'f', 0344, 0270, 0212, + 's', 0345, 0257, 0204, + 'b', 0345, 0274, 0225, + 'r', 0345, 0267, 0246, + 'l', 0345, 0217, 0263, + 'v', 0347, 0233, 0264, + 0, + // shift-JIS + '1', 0202, 0120, 0, + '2', 0202, 0121, 0, + '3', 0202, 0122, 0, + '4', 0202, 0123, 0, + '5', 0202, 0124, 0, + '6', 0202, 0125, 0, + '7', 0202, 0126, 0, + '8', 0202, 0127, 0, + '9', 0202, 0130, 0, + 'x', 0223, 0257, 0, + 's', 0220, 0346, 0, + 'g', 0214, 0343, 0, + '-', 0223, 0212, 0, + 0, + 'a', 0210, 0352, 0, + 'b', 0223, 0361, 0, + 'c', 0216, 0117, 0, + 'd', 0216, 0154, 0, + 'e', 0214, 0334, 0, + 'f', 0230, 0132, 0, + 'g', 0216, 0265, 0, + 'h', 0224, 0252, 0, + 'i', 0213, 0343, 0, + ' ', 0201, 0100, 0, + 0, + 'K', 0213, 0312, 0, + 'K', 0213, 0312, 0, + 'G', 0213, 0340, 0, + 'S', 0213, 0342, 0, + 'R', 0224, 0362, 0, + 'B', 0212, 0160, 0, + 'N', 0214, 0152, 0, + 'L', 0215, 0201, 0, + 'P', 0225, 0340, 0, + 'r', 0227, 0264, 0, + 'b', 0224, 0156, 0, + 'p', 0202, 0306, 0, + 'r', 0227, 0263, 0, + '+', 0220, 0254, 0, + 'G', 0, 0, 0, + 0, + '+', 0220, 0254, 0, + '@', 0221, 0305, 0, +// 'p', 0214, 0343, 0, + 'p', 0216, 0350, 0, + ':', 0201, 0106, 0, + '-', 0227, 0271, 0, + 'f', 0217, 0343, 0, + 's', 0212, 0361, 0, + 'b', 0210, 0370, 0, + 'r', 0215, 0266, 0, + 'l', 0211, 0105, 0, + 'v', 0222, 0274, 0, + 0, + +}; + +int NextUnit P((char **p)); + +int kifu = 0; + +char +GetKanji (char **p, int start) +{ + unsigned char *q = *(unsigned char **) p; + int i; + + if((*q & 0x80) == 0) return 0; // plain ASCII, refuse to parse + if((**p & 0xC0) == 0x80) { // this is an illegal starting code in utf-8, so assume shift-JIS + for(i=start+JIS; kanjiTab[i]; i+=4) { + if(q[0] == kanjiTab[i+1] && q[1] == kanjiTab[i+2]) { + (*p) += 2; kifu = 0x80; + return kanjiTab[i]; + } } - currentMoveString[5] = NULLCHAR; + (*p) += (kifu ? 2 : 1); // assume this is an unrecognized kanji when reading kif files + return 0; } - if (appData.debugMode) { - fprintf(debugFP, "parser: %s\n", currentMoveString); - } - /* [HGM] do not allow values beyond board size */ - if(currentMoveString[1] - ONE >= BOARD_HEIGHT || - currentMoveString[1] - ONE < 0 || - currentMoveString[0] - AAA >= BOARD_RGHT || - currentMoveString[3] - ONE >= BOARD_HEIGHT || - currentMoveString[3] - ONE < 0 || - currentMoveString[2] - AAA >= BOARD_RGHT || - currentMoveString[0] - AAA < BOARD_LEFT || - currentMoveString[2] - AAA < BOARD_LEFT ) - return ImpossibleMove; - - piece = boards[yyboardindex] - [currentMoveString[1] - ONE][currentMoveString[0] - AAA]; - if(PieceToChar(piece) == '+' && appData.icsActive) promoted = 1, yytext[skip3] = PieceToChar(DEMOTED piece); // trust ICS - if(promoted) piece = (ChessSquare) (DEMOTED piece); - c = PieceToChar(piece); - if(c == '~') c = PieceToChar((ChessSquare) (DEMOTED piece)); - if (ToLower(yytext[skip3]) != ToLower(c)) - return (int) IllegalMove; - - result = LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! - currentMoveString[1] - ONE, - currentMoveString[0] - AAA, - currentMoveString[3] - ONE, - currentMoveString[2] - AAA, - currentMoveString[4]); - - if (currentMoveString[4] == NULLCHAR) { - if(result == WhitePromotion || result == BlackPromotion) { - if(gameInfo.variant == VariantCourier || gameInfo.variant == VariantShatranj) - currentMoveString[4] = PieceToChar(BlackFerz); - else if(gameInfo.variant == VariantGreat) - currentMoveString[4] = PieceToChar(BlackMan); - else if(gameInfo.variant == VariantShogi) - currentMoveString[4] = '^'; - else - currentMoveString[4] = PieceToChar(BlackQueen); - } else if(result == WhiteNonPromotion || result == BlackNonPromotion) - currentMoveString[4] = '='; - currentMoveString[5] = NULLCHAR; - } - - return (int) result; -} - YY_BREAK -case 2: -YY_RULE_SETUP -#line 270 "parser.l" -{ - /* - * Simple algebraic move, possibly with promotion - * [HGM] Engine moves are received in this format, with lower-case promoChar! - */ - int skip = 0; - ChessMove result; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - /* remove the [xX:-] */ - if ((yytext[2] == 'x') || (yytext[2] == 'X') || - (yytext[2] == '-') || (yytext[2] == ':')) skip = 1; - - currentMoveString[0] = yytext[0]; - currentMoveString[1] = yytext[1]; - currentMoveString[2] = yytext[2+skip]; - currentMoveString[3] = yytext[3+skip]; - currentMoveString[4] = NULLCHAR; - - if (yyleng-skip > 4) { char c; - if (yytext[yyleng-1] == ')') { - c = currentMoveString[4] = ToLower(yytext[yyleng-2]); - } else { - c = currentMoveString[4] = ToLower(yytext[yyleng-1]); + for(i=start; kanjiTab[i]; i+=4) { + if(q[0] == kanjiTab[i+1] && q[1] == kanjiTab[i+2] && q[2] == kanjiTab[i+3]) { + (*p) += 3; kifu = 0x80; + return kanjiTab[i]; } - currentMoveString[5] = NULLCHAR; } - /* [HGM] do not allow values beyond board size */ - if(currentMoveString[1] - ONE >= BOARD_HEIGHT || - currentMoveString[1] - ONE < 0 || - currentMoveString[0] - AAA >= BOARD_RGHT || - currentMoveString[3] - ONE >= BOARD_HEIGHT || - currentMoveString[3] - ONE < 0 || - currentMoveString[2] - AAA >= BOARD_RGHT || - currentMoveString[0] - AAA < BOARD_LEFT || - currentMoveString[2] - AAA < BOARD_LEFT ) - return ImpossibleMove; - - result = LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! - currentMoveString[1] - ONE, - currentMoveString[0] - AAA, - currentMoveString[3] - ONE, - currentMoveString[2] - AAA, - currentMoveString[4]); - - if (currentMoveString[4] == NULLCHAR) { - if(result == WhitePromotion || result == BlackPromotion) { - if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || gameInfo.variant == VariantMakruk) - currentMoveString[4] = PieceToChar(BlackFerz); - else if(gameInfo.variant == VariantGreat) - currentMoveString[4] = PieceToChar(BlackMan); - else if(gameInfo.variant == VariantShogi) - currentMoveString[4] = '^'; // Queen might not be defined in mini variants! - else - currentMoveString[4] = PieceToChar(BlackQueen); - } else if(result == WhiteNonPromotion || result == BlackNonPromotion) - currentMoveString[4] = '='; - currentMoveString[5] = NULLCHAR; - } else if(appData.testLegality && // strip off unnecessary and false promo characters - !(result == WhitePromotion || result == BlackPromotion || - result == WhiteNonPromotion || result == BlackNonPromotion)) currentMoveString[4] = NULLCHAR; - - return (int) result; -} - YY_BREAK -case 3: -YY_RULE_SETUP -#line 338 "parser.l" -{ - /* - * Simple algebraic move, in capitals - * [HGM] Some Xiangqi engines use this format ('ICCS notation'). So no promotions! - */ - int skip = 0; - ChessMove result; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - /* remove the [xX:-] */ - if ((yytext[2] == 'x') || (yytext[2] == 'X') || - (yytext[2] == '-') || (yytext[2] == ':')) skip = 1; - - currentMoveString[0] = yytext[0]+32; - currentMoveString[1] = yytext[1]; - currentMoveString[2] = yytext[2+skip]+32; - currentMoveString[3] = yytext[3+skip]; - currentMoveString[4] = NULLCHAR; - - /* [HGM] do not allow values beyond board size */ - if(currentMoveString[1] - ONE >= BOARD_HEIGHT || - currentMoveString[1] - ONE < 0 || - currentMoveString[0] - AAA >= BOARD_RGHT || - currentMoveString[3] - ONE >= BOARD_HEIGHT || - currentMoveString[3] - ONE < 0 || - currentMoveString[2] - AAA >= BOARD_RGHT || - currentMoveString[0] - AAA < BOARD_LEFT || - currentMoveString[2] - AAA < BOARD_LEFT ) - return ImpossibleMove; - - result = LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! - currentMoveString[1] - ONE, - currentMoveString[0] - AAA, - currentMoveString[3] - ONE, - currentMoveString[2] - AAA, - currentMoveString[4]); - - return (int) result; -} - YY_BREAK -case 4: -YY_RULE_SETUP -#line 380 "parser.l" -{ - /* - * Pawn move, possibly with promotion - */ - DisambiguateClosure cl; - int skip = 0; char c; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - /* remove the =() */ - if (yytext[2] == '=' && yytext[3] != NULLCHAR) skip++; - if (yytext[2+skip] == '(') skip++; - - cl.pieceIn = WhiteOnMove(yyboardindex) ? WhitePawn : BlackPawn; - cl.rfIn = -1; - cl.ffIn = yytext[0] - AAA; - cl.rtIn = yytext[1] - ONE; - cl.ftIn = yytext[0] - AAA; - c = cl.promoCharIn = ToLower(yytext[2+skip]); - - /* [HGM] do not allow values beyond board size */ - if(cl.rtIn >= BOARD_HEIGHT || - cl.rtIn < 0 || - cl.ffIn >= BOARD_RGHT || - cl.ftIn < BOARD_LEFT ) - return ImpossibleMove; - - Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); - - currentMoveString[0] = cl.ff + AAA; - currentMoveString[1] = cl.rf + ONE; - currentMoveString[2] = cl.ft + AAA; - currentMoveString[3] = cl.rt + ONE; - currentMoveString[4] = cl.promoChar; - currentMoveString[5] = NULLCHAR; - - return (int) cl.kind; -} - YY_BREAK -case 5: -YY_RULE_SETUP -#line 420 "parser.l" -{ - /* - * Pawn capture, possibly with promotion, possibly ambiguous - */ - DisambiguateClosure cl; - int skip1 = 0, skip2 = 0; char c; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - /* remove trailing ep or e.p. (nonstandard PGN) */ - if (yytext[yyleng-1] == 'p') { - yyleng -= 2; - yytext[yyleng] = NULLCHAR; - } else if (yytext[yyleng-1] == '.') { - yyleng -= 4; - yytext[yyleng] = NULLCHAR; - } - - /* remove the [xX:-] and =() */ - if ((yytext[1] == 'x') || (yytext[1] == 'X') - || (yytext[1] == ':') || (yytext[1] == '-')) skip1 = 1; - if (yytext[2+skip1] == '=' && yytext[3+skip1] != NULLCHAR) skip2++; - if (yytext[2+skip1+skip2] == '(') skip2++; - - cl.pieceIn = WhiteOnMove(yyboardindex) ? WhitePawn : BlackPawn; - cl.rfIn = -1; - cl.ffIn = yytext[0] - AAA; - cl.rtIn = -1; - cl.ftIn = yytext[1+skip1] - AAA; - c = cl.promoCharIn = yytext[2+skip1+skip2]; - - /* [HGM] do not allow values beyond board size */ - if(cl.ffIn >= BOARD_RGHT || - cl.ffIn < BOARD_LEFT || - cl.ftIn >= BOARD_RGHT || - cl.ftIn < BOARD_LEFT ) - return ImpossibleMove; - - Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); - - currentMoveString[0] = cl.ff + AAA; - currentMoveString[1] = cl.rf + ONE; - currentMoveString[2] = cl.ft + AAA; - currentMoveString[3] = cl.rt + ONE; - currentMoveString[4] = cl.promoChar; - currentMoveString[5] = NULLCHAR; - - return (int) cl.kind; -} - YY_BREAK -case 6: -YY_RULE_SETUP -#line 470 "parser.l" -{ - /* - * unambiguously abbreviated Pawn capture, possibly with promotion - */ - int skip = 0; - ChessMove result; char c; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - /* remove trailing ep or e.p. (nonstandard PGN) */ - if (yytext[yyleng-1] == 'p') { - yyleng -= 2; - yytext[yyleng] = NULLCHAR; - } else if (yytext[yyleng-1] == '.') { - yyleng -= 4; - yytext[yyleng] = NULLCHAR; - } - - /* remove the [xX:-] */ - if ((yytext[1] == 'x') || (yytext[1] == 'X') - || (yytext[1] == ':') || (yytext[1] == '-')) skip = 1; - - currentMoveString[0] = yytext[0]; - currentMoveString[2] = yytext[1+skip]; - currentMoveString[3] = yytext[2+skip]; - - /* [HGM] do not allow values beyond board size */ - if(currentMoveString[0] - AAA >= BOARD_RGHT || - currentMoveString[3] - ONE >= BOARD_HEIGHT || - currentMoveString[3] - ONE < 0 || - currentMoveString[2] - AAA >= BOARD_RGHT || - currentMoveString[0] - AAA < BOARD_LEFT || - currentMoveString[2] - AAA < BOARD_LEFT ) - return ImpossibleMove; - - if (gameInfo.variant == VariantXiangqi && /* [HGM] In Xiangqi rank stays same */ - currentMoveString[0] != currentMoveString[2] ) { - currentMoveString[1] = yytext[2+skip]; - } else - if (WhiteOnMove(yyboardindex)) { - if (yytext[2+skip] == ONE) return (int) ImpossibleMove; - currentMoveString[1] = yytext[2+skip] - 1; - if(boards[yyboardindex][currentMoveString[1]-ONE][currentMoveString[0]-AAA] != WhitePawn) - return ImpossibleMove; - } else { - currentMoveString[1] = currentMoveString[3] + 1; - if (currentMoveString[3] == ONE+BOARD_HEIGHT-1) return (int) ImpossibleMove; - if(boards[yyboardindex][currentMoveString[1]-ONE][currentMoveString[0]-AAA] != BlackPawn) - return ImpossibleMove; - } - if (yyleng-skip > 3) { - if (yytext[yyleng-1] == ')') - c = currentMoveString[4] = ToLower(yytext[yyleng-2]); - else - c = currentMoveString[4] = ToLower(yytext[yyleng-1]); - currentMoveString[5] = NULLCHAR; - if(c != '=' && c != '^' && CharToPiece(c) == EmptySquare) - return ImpossibleMove; + if((q[0] & 0xE0) == 0xC0 && (q[1] & 0xC0) == 0x80) (*p) += 2; else // for now skip unrecognized utf-8 characters + if((q[0] & 0xF0) == 0xE0 && (q[1] & 0xC0) == 0x80 && (q[2] & 0xC0) == 0x80) (*p) += 3; else + if((q[0] & 0xF8) == 0xF0 && (q[1] & 0xC0) == 0x80 && (q[2] & 0xC0) == 0x80 && (q[3] & 0xC0) == 0x80) (*p) += 4; + else if(**p & 0x80) return -1; // not valid utf-8 + + return 0; // unrecognized but valid kanji (skipped), or plain ASCII +} + +int +KifuMove (char **p) +{ + static char buf[MSG_SIZ]; + char *ptr = buf+3, *q, k; + int wom = quickFlag ? quickFlag&1 : WhiteOnMove(yyboardindex); + k = GetKanji(p, XCO); + if(k < 0) { (*p)++; return Nothing; } // must try shift-JIS here + if(k >= '1' && k <= '9') { + buf[0] = k; buf[1] = GetKanji(p, YCO); // to-square coords + } else if(k == 'x') { + if(GetKanji(p, YCO) != ' ') (*p) -= 3; // skip spacer kanji after recapture + } else if((k == 's' || k == 'g') && GetKanji(p, MISC) == 'p' && GetKanji(p, MISC) == ':') { // player name + snprintf(yytext, MSG_SIZ, "[%s \"", k == 's' ? "White" : "Black"); // construct PGN tag + for(q=yytext+8; **p && **p != '\n' && **p != '\r' && q < yytext + MSG_SIZ; ) *q++ = *(*p)++; + strcpy(q, "\"]\n"); parseStart = yytext; lastChar = '\n'; + return PGNTag; + } else if(k == '-' && GetKanji(p, MISC) == '-') { // resign + int res; + parseStart = yytext; + if(wom) + res = BlackWins, strcpy(yytext, "{sente resigns} 0-1"); + else res = WhiteWins, strcpy(yytext, "{gote resigns} 1-0"); + return res; } else { - currentMoveString[4] = NULLCHAR; + while(**p && **p != '\n') (*p)++; // unrecognized Japanese kanji: skip to end of line + return Nothing; } - - result = LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! - currentMoveString[1] - ONE, - currentMoveString[0] - AAA, - currentMoveString[3] - ONE, - currentMoveString[2] - AAA, - currentMoveString[4]); - - if (currentMoveString[4] == NULLCHAR) { - if(result == WhitePromotion || result == BlackPromotion) { - currentMoveString[4] = PieceToChar(BlackQueen); - // [HGM] shatranj: take care of variants without Queen - if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || gameInfo.variant == VariantMakruk) - currentMoveString[4] = PieceToChar(BlackFerz); - if(gameInfo.variant == VariantGreat) - currentMoveString[4] = PieceToChar(BlackMan); - if(gameInfo.variant == VariantShogi) - currentMoveString[4] = '^'; - } else if(result == WhiteNonPromotion || result == BlackNonPromotion) - currentMoveString[4] = '='; - currentMoveString[5] = NULLCHAR; + buf[3] = GetKanji(p, PIECE); // piece ID + if(buf[3] == '+') buf[2] = '+', buf[3] = GetKanji(p, PIECE); // +N, +L, +S + k = GetKanji(p, MISC); + if(k == '@') { // drop move + buf[4] = '@', buf[5] = buf[0], buf[6] = buf[1]; buf[7] = NULLCHAR; + if(appData.debugMode) fprintf(debugFP, "kifu drop %s\n", ptr); + return NextUnit(&ptr); } - if (result != IllegalMove) return (int) result; - - /* Special case: improperly written en passant capture */ - if (WhiteOnMove(yyboardindex)) { - if (currentMoveString[3] == '5') { - currentMoveString[1] = '5'; - currentMoveString[3] = '6'; - } else { - return (int) IllegalMove; + kifu = 0x80; + do { // read disambiguation (and promotion) kanji + switch(k) { + case '+': kifu |= 1; break; + case 'f': kifu |= 2; break; + case 'b': kifu |= 4; break; + case 's': kifu |= 8; break; + case 'l': kifu |= 0x10; break; + case 'r': kifu |= 0x20; break; + case 'v': kifu |= 0x40; break; } - } else { - if (currentMoveString[3] == '4') { - currentMoveString[1] = '4'; - currentMoveString[3] = '3'; - } else { - return (int) IllegalMove; + } while(k = GetKanji(p, MISC)); + + if(**p == '(' && (*p)[3] == ')') { // kif disambiguation + buf[4] = (*p)[1]; buf[5] = (*p)[2] + 'a' - '1'; buf[6] = buf[0]; buf[7] = buf[1]; buf[8] = (kifu & 1)*'+'; buf[9] = NULLCHAR; + (*p) += 4; ptr++; // strip off piece name if we know full from-square + if(appData.debugMode) fprintf(debugFP, "kifu move %s\n", ptr); + return NextUnit(&ptr); + } else { // kif2 + char *q = buf+4; + if(islower(buf[3])) // kludge: kanji for promoted types translate as lower case + buf[3] += 'A' - 'a', buf[2] = '+', ptr--; // so prefix with '+' + if(kifu * ~1) { // disambiguation was given, and thus is probably needed + if(buf[3] != 'B' && buf[3] != 'R') { // stepper, so distance must be <= 1 (N or L never need vertical disambiguation!) + if(kifu & 0x10) *q++ = buf[0] - (wom ? -1 : 1); // translate left/right/straight to PSN file disambiguators + if(kifu & 0x20) *q++ = buf[0] + (wom ? -1 : 1); + if(kifu & 0x40) *q++ = buf[0], kifu |= 2; // kludge: 'straight' only needs disambiguation if forward! + if(kifu & 2) *q++ = buf[1] + (wom ? -1 : 1); // translate forward/backward/sideway to PSN rank disambiguators + if(kifu & 4) *q++ = buf[1] - (wom ? -1 : 1); + if(kifu & 8) *q++ = buf[1]; + } // for B, R, +B and +R it gets ugly, as we cannot deduce the distance, and the Disambiguate callback has to directly look at 'kifu' } + *q++ = buf[0]; *q++ = buf[1]; *q++ = (kifu & 1)*'+'; *q = NULLCHAR; + if(appData.debugMode) fprintf(debugFP, "kif2 move %s\n", ptr); + return NextUnit(&ptr); } - - result = LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! - currentMoveString[1] - ONE, - currentMoveString[0] - AAA, - currentMoveString[3] - ONE, - currentMoveString[2] - AAA, - currentMoveString[4]); - - if (result == WhiteCapturesEnPassant || result == BlackCapturesEnPassant) - return (int) result; - else - return (int) IllegalMove; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 588 "parser.l" -{ - /* - * piece move, possibly ambiguous - */ - DisambiguateClosure cl; - int skip = 0, skip2 = 0, promoted = 0; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - if(yytext[0] == '+') promoted = skip = skip2 = 1; - /* remove the [xX:-] */ - if ((yytext[1+skip] == 'x') || (yytext[1+skip] == 'X') - || (yytext[1+skip] == ':') || (yytext[1+skip] == '-')) skip++; - - if (WhiteOnMove(yyboardindex)) { - cl.pieceIn = CharToPiece(ToUpper(yytext[skip2])); - } else { - cl.pieceIn = CharToPiece(ToLower(yytext[skip2])); +int +ReadLine () +{ // Read one line from the input file, and append to the buffer + int c; char *start = inPtr; + if(fromString) return 0; // parsing string, so the end is a hard end + if(!inputFile) return 0; + while((c = fgetc(inputFile)) != EOF) { + *inPtr++ = c; + if(c == '\n') { *inPtr = NULLCHAR; return 1; } + if(inPtr - inputBuf > PARSEBUFSIZE-2) inPtr--; //prevent crash on overflow } - if(promoted) cl.pieceIn = (ChessSquare) (PROMOTED cl.pieceIn); - - cl.rfIn = -1; - cl.ffIn = -1; - cl.rtIn = yytext[2+skip] - ONE; - cl.ftIn = yytext[1+skip] - AAA; - cl.promoCharIn = NULLCHAR; - - if(yyleng-skip > 3) /* [HGM] can have Shogi-style promotion */ - cl.promoCharIn = yytext[yyleng-1-(yytext[yyleng-1]==')')]; - - if (appData.debugMode) { - fprintf(debugFP, "Parser Qa1: yyleng=%d, %d(%d,%d)-(%d,%d) = %d (%c)\n", - yyleng, - cl.pieceIn,cl.ffIn,cl.rfIn,cl.ftIn,cl.rtIn,cl.promoCharIn,cl.promoCharIn?cl.promoCharIn:' '); + if(inPtr == start) return 0; + *inPtr++ = '\n', *inPtr = NULLCHAR; // repair missing linefeed at EOF + return 1; +} + +int +Scan (char c, char **p) +{ // line-spanning skip to mentioned character or EOF + do { + while(**p) if(*(*p)++ == c) return 0; + } while(ReadLine()); + // no closing bracket; force match for entire rest of file. + return 1; +} + +int +SkipWhite (char **p) +{ // skip spaces tabs and newlines; return 1 if anything was skipped + char *start = *p; + do{ + while(**p == ' ' || **p == '\t' || **p == '\n' || **p == '\r') (*p)++; + } while(**p == NULLCHAR && ReadLine()); // continue as long as ReadLine reads something + return *p != start; +} + +static inline int +Match (char *pattern, char **ptr) +{ + char *p = pattern, *s = *ptr; + while(*p && (*p == *s++ || s[-1] == '\r' && *p--)) p++; + if(*p == 0) { + *ptr = s; + return 1; } - - /* [HGM] but do not allow values beyond board size */ - if(cl.rtIn >= BOARD_HEIGHT || - cl.rtIn < 0 || - cl.ftIn >= BOARD_RGHT || - cl.ftIn < BOARD_LEFT ) - return ImpossibleMove; - - Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); - - currentMoveString[0] = cl.ff + AAA; - currentMoveString[1] = cl.rf + ONE; - currentMoveString[2] = cl.ft + AAA; - currentMoveString[3] = cl.rt + ONE; - currentMoveString[4] = cl.promoChar; - currentMoveString[5] = NULLCHAR; - - return (int) cl.kind; + return 0; // no match, no ptr update } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 644 "parser.l" -{ - /* - * piece move with rank or file disambiguator - */ - DisambiguateClosure cl; - int skip = 0, skip2 = 0; int promoted=0; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - if(yytext[0]=='+') promoted = skip = skip2 = 1; - - /* remove the [xX:-] */ - if ((yytext[2+skip] == 'x') || (yytext[2+skip] == 'X') - || (yytext[2+skip] == ':') || (yytext[2+skip] == '-')) skip++; - - if (WhiteOnMove(yyboardindex)) { - cl.pieceIn = CharToPiece(ToUpper(yytext[skip2])); - } else { - cl.pieceIn = CharToPiece(ToLower(yytext[skip2])); - } - if(promoted) cl.pieceIn = (ChessSquare) (PROMOTED cl.pieceIn); - - if (isalpha(yytext[1+skip2])) { - cl.rfIn = -1; - cl.ffIn = yytext[1+skip2] - AAA; - - if(cl.ffIn >= BOARD_RGHT || - cl.ffIn < BOARD_LEFT ) return 0; - } else { - cl.rfIn = yytext[1+skip2] - ONE; - cl.ffIn = -1; - if(cl.rfIn >= BOARD_HEIGHT || - cl.rfIn < 0) return 0; - } - cl.rtIn = yytext[3+skip] - ONE; - cl.ftIn = yytext[2+skip] - AAA; - cl.promoCharIn = NULLCHAR; - - if(yyleng-skip > 4) /* [HGM] can have Shogi-style promotion */ - cl.promoCharIn = yytext[yyleng-1-(yytext[yyleng-1]==')')]; - /* [HGM] do not allow values beyond board size */ - if(cl.rtIn >= BOARD_HEIGHT || - cl.rtIn < 0 || - cl.ftIn >= BOARD_RGHT || - cl.ftIn < BOARD_LEFT ) - return ImpossibleMove; - - Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); - - currentMoveString[0] = cl.ff + AAA; - currentMoveString[1] = cl.rf + ONE; - currentMoveString[2] = cl.ft + AAA; - currentMoveString[3] = cl.rt + ONE; - currentMoveString[4] = cl.promoChar; - currentMoveString[5] = NULLCHAR; - - return (int) cl.kind; -} - YY_BREAK -case 9: -YY_RULE_SETUP -#line 704 "parser.l" -{ - int rf, ff, rt, ft; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - /* [HGM] all squares referenced to board edges in stead of absolute */ - if (WhiteOnMove(yyboardindex)) { - if (boards[yyboardindex][0][(BOARD_WIDTH-1)>>1] == WhiteKing) { - /* ICS wild castling */ - rf = 0; - ff = (BOARD_WIDTH-1)>>1; - rt = 0; - ft = BOARD_RGHT-3; - } else { - rf = 0; - ff = BOARD_WIDTH>>1; - rt = 0; - ft = BOARD_LEFT+2; - } - } else{ - if (boards[yyboardindex][BOARD_HEIGHT-1][(BOARD_WIDTH-1)>>1] == BlackKing) { - /* ICS wild castling */ - rf = BOARD_HEIGHT-1; - ff = (BOARD_WIDTH-1)>>1; - rt = BOARD_HEIGHT-1; - ft = BOARD_RGHT-3; - } else { - rf = BOARD_HEIGHT-1; - ff = BOARD_WIDTH>>1; - rt = BOARD_HEIGHT-1; - ft = BOARD_LEFT+2; - } - } - if(PosFlags(0) & F_FRC_TYPE_CASTLING) { - - if (WhiteOnMove(yyboardindex)) { - ff = initialRights[2]; - ft = initialRights[1]; - } else { - ff = initialRights[5]; - ft = initialRights[4]; - } - if (appData.debugMode) - { - fprintf(debugFP, "Parser FRC long %d %d\n", ff, ft); - }; - if(ff < 0 || ft < 0) return 0; - } - sprintf(currentMoveString, "%c%c%c%c",ff+AAA,rf+ONE,ft+AAA,rt+ONE); - if (appData.debugMode) { - fprintf(debugFP, "long castling %d %d\n", ff, ft); - } - return (int) LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.! - rf, ff, rt, ft, NULLCHAR); -} - YY_BREAK -case 10: -YY_RULE_SETUP -#line 761 "parser.l" +static inline int +Word (char *pattern, char **p) { - int rf, ff, rt, ft; - - if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ - - if (WhiteOnMove(yyboardindex)) { - if (boards[yyboardindex][0][(BOARD_WIDTH-1)>>1] == WhiteKing) { - /* ICS wild castling */ - rf = 0; - ff = (BOARD_WIDTH-1)>>1; - rt = 0; - ft = BOARD_LEFT+1; - } else { - rf = 0; - ff = BOARD_WIDTH>>1; - rt = 0; - ft = BOARD_RGHT-2; - } - } else { - if (boards[yyboardindex][BOARD_HEIGHT-1][(BOARD_WIDTH-1)>>1] == BlackKing) { - /* ICS wild castling */ - rf = BOARD_HEIGHT-1; - ff = (BOARD_WIDTH-1)>>1; - rt = BOARD_HEIGHT-1; - ft = BOARD_LEFT+1; - } else { - rf = BOARD_HEIGHT-1; - ff = BOARD_WIDTH>>1; - rt = BOARD_HEIGHT-1; - ft = BOARD_RGHT-2; - } - } - if(PosFlags(0) & F_FRC_TYPE_CASTLING) { - if (WhiteOnMove(yyboardindex)) { - ff = initialRights[2]; - ft = initialRights[0]; - } else { - ff = initialRights[5]; - ft = initialRights[3]; - } - if (appData.debugMode) { - fprintf(debugFP, "Parser FRC short %d %d\n", ff, ft); - } - if(ff < 0 || ft < 0) return 0; + if(Match(pattern, p)) return 1; + if(*pattern >= 'a' && *pattern <= 'z' && *pattern - **p == 'a' - 'A') { // capitalized + (*p)++; + if(Match(pattern + 1, p)) return 1; + (*p)--; } - sprintf(currentMoveString, "%c%c%c%c",ff+AAA,rf+ONE,ft+AAA,rt+ONE); - if (appData.debugMode) { - fprintf(debugFP, "short castling %d %d\n", ff, ft); - } - - return (int) LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.! - rf, ff, rt, ft, NULLCHAR); + return 0; } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 816 "parser.l" -{ - /* Bughouse piece drop. */ - currentMoveString[1] = '@'; - currentMoveString[2] = yytext[2]; - currentMoveString[3] = yytext[3]; - currentMoveString[4] = NULLCHAR; - - if (appData.debugMode) { - fprintf(debugFP, "Drop: %s\n", currentMoveString); - } - /* [HGM] do not allow values beyond board size */ - if(currentMoveString[3] - ONE >= BOARD_HEIGHT || - currentMoveString[2] - AAA >= BOARD_WIDTH ) - return ImpossibleMove; - if (WhiteOnMove(yyboardindex)) { - currentMoveString[0] = ToUpper(yytext[0]); - } else { - currentMoveString[0] = ToLower(yytext[0]); - } - return LegalityTest(boards[yyboardindex], PosFlags(yyboardindex), DROP_RANK, // [HGM] does drops now too - CharToPiece(currentMoveString[0]), currentMoveString[3] - ONE, currentMoveString[2] - AAA, NULLCHAR); -} - YY_BREAK -case 12: -YY_RULE_SETUP -#line 840 "parser.l" -{ - if (WhiteOnMove(yyboardindex)) - return (int) BlackWins; - else - return (int) WhiteWins; -} - YY_BREAK -case 13: -YY_RULE_SETUP -#line 847 "parser.l" -{ - return (int) (ToUpper(yytext[0]) == 'W' ? BlackWins : WhiteWins); -} - YY_BREAK -case 14: -YY_RULE_SETUP -#line 851 "parser.l" -{ - return (int) GameUnfinished; -} - YY_BREAK -case 15: -YY_RULE_SETUP -#line 855 "parser.l" -{ - return (int) GameIsDrawn; -} - YY_BREAK -case 16: -YY_RULE_SETUP -#line 859 "parser.l" -{ - return (int) GameIsDrawn; -} - YY_BREAK -case 17: -YY_RULE_SETUP -#line 863 "parser.l" -{ - if (WhiteOnMove(yyboardindex)) - return (int) BlackWins; - else - return (int) WhiteWins; -} - YY_BREAK -case 18: -YY_RULE_SETUP -#line 870 "parser.l" -{ - if (WhiteOnMove(yyboardindex)) - return (int) BlackWins; - else - return (int) WhiteWins; -} - YY_BREAK -case 19: -YY_RULE_SETUP -#line 877 "parser.l" +int +Verb (char *pattern, char **p) { - return (int) GameIsDrawn; + int res = Word(pattern, p); + if(res && !Match("s", p)) Match("ed", p); // eat conjugation suffix, if any + return res; } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 881 "parser.l" -{ - return (int) GameIsDrawn; -} - YY_BREAK -case 21: -YY_RULE_SETUP -#line 885 "parser.l" -{ - return (int) (ToUpper(yytext[0]) == 'W' ? WhiteWins : BlackWins); -} - YY_BREAK -case 22: -YY_RULE_SETUP -#line 889 "parser.l" -{ - return (int) (ToUpper(yytext[0]) == 'W' ? BlackWins : WhiteWins); -} - YY_BREAK -case 23: -YY_RULE_SETUP -#line 893 "parser.l" -{ - return (int) WhiteWins; -} - YY_BREAK -case 24: -YY_RULE_SETUP -#line 897 "parser.l" -{ - return (int) BlackWins; -} - YY_BREAK -case 25: -YY_RULE_SETUP -#line 901 "parser.l" -{ - return (int) GameIsDrawn; -} - YY_BREAK -case 26: -YY_RULE_SETUP -#line 905 "parser.l" -{ - return (int) GameUnfinished; -} - YY_BREAK -case 27: -/* rule 27 can match eol */ -YY_RULE_SETUP -#line 909 "parser.l" -{ - /* move numbers */ - if ((yyleng == 1) && (yytext[0] == '1')) - return (int) MoveNumberOne; -} - YY_BREAK -case 28: -YY_RULE_SETUP -#line 915 "parser.l" -{ - /* elapsed time indication, e.g. (0:12) or {10:21.071} */ - return (int) ElapsedTime; -} - YY_BREAK -case 29: -/* rule 29 can match eol */ -YY_RULE_SETUP -#line 920 "parser.l" -{ - /* position diagram enclosed in [-- --] */ - return (int) PositionDiagram; -} - YY_BREAK -case 30: -/* rule 30 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 925 "parser.l" -{ - /* position diagram enclosed in {-- --} */ - return (int) PositionDiagram; -} - YY_BREAK -case 31: -/* rule 31 can match eol */ -YY_RULE_SETUP -#line 930 "parser.l" -{ - return (int) PGNTag; -} - YY_BREAK -case 32: -YY_RULE_SETUP -#line 934 "parser.l" -{ - return (int) GNUChessGame; -} - YY_BREAK -case 33: -/* rule 33 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 938 "parser.l" -{ - return (int) XBoardGame; -} - YY_BREAK -case 34: -YY_RULE_SETUP -#line 942 "parser.l" -{ /* numeric annotation glyph */ - return (int) NAG; -} - YY_BREAK -case 35: -/* rule 35 can match eol */ -YY_RULE_SETUP -#line 946 "parser.l" -{ /* anything in {} */ - return (int) Comment; -} - YY_BREAK -case 36: -*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 950 "parser.l" -{ /* ; to end of line */ - return (int) Comment; -} - YY_BREAK -case 37: -/* rule 37 can match eol */ -YY_RULE_SETUP -#line 954 "parser.l" -{ /* anything in [] */ - return (int) Comment; -} - YY_BREAK -case 38: -/* rule 38 can match eol */ -YY_RULE_SETUP -#line 958 "parser.l" -{ /* very nested () */ - return (int) Comment; -} - YY_BREAK -case 39: -/* rule 39 can match eol */ -YY_RULE_SETUP -#line 962 "parser.l" -{ /* >=2 chars in () */ - return (int) Comment; -} - YY_BREAK -case 40: -/* rule 40 can match eol */ -YY_RULE_SETUP -#line 966 "parser.l" + +int +Number (char **p) { - /* Skip mail headers */ + int val = 0; + if(**p < '0' || **p > '9') return BADNUMBER; + while(**p >= '0' && **p <= '9') { + val = 10*val + *(*p)++ - '0'; + } + return val; } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 970 "parser.l" + +int +RdTime (char c, char **p) { - /* Skip random words */ + char *start = ++(*p), *sec; // increment *p, as it was pointing to the opening ( or { + if(Number(p) == BADNUMBER) return 0; + sec = *p; + if(Match(":", p) && Number(p) != BADNUMBER && *p - sec == 3) { // well formed + sec = *p; + if(Match(".", p) && Number(p) != BADNUMBER && *(*p)++ == c) return 1; // well-formed fraction + *p = sec; + if(*(*p)++ == c) return 1; // matching bracket without fraction + } + *p = start; // failure + return 0; } - YY_BREAK -case 42: -/* rule 42 can match eol */ -YY_RULE_SETUP -#line 974 "parser.l" + +char +PromoSuffix (char **p) { - /* Skip everything else */ + char *start = *p; + if(**p == ' ') return NULLCHAR; // common case, test explicitly for speed + if(**p == 'e' && (Match("ep", p) || Match("e.p.", p))) { *p = start; return NULLCHAR; } // non-compliant e.p. suffix is no promoChar! + if(**p == '+' && IS_SHOGI(gameInfo.variant)) { (*p)++; return '+'; } + if(**p == '=' || (gameInfo.variant == VariantSChess) && **p == '/') (*p)++; // optional = (or / for Seirawan gating) + if(**p == '(' && (*p)[2] == ')' && isalpha( (*p)[1] )) { (*p) += 3; return ToLower((*p)[-2]); } + if(isalpha(**p) && **p != 'x') return ToLower(*(*p)++); // reserve 'x' for multi-leg captures? + if(*p != start) return **p == '+' ? *(*p)++ : '='; // must be the optional = (or =+) + return NULLCHAR; // no suffix detected } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 978 "parser.l" -ECHO; - YY_BREAK -#line 3238 "parser.c" - case YY_STATE_EOF(INITIAL): - yyterminate(); - - 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_LVALUE->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_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->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_LVALUE->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; +int +NextUnit (char **p) +{ // Main parser routine + int coord[4], n, result, piece, i; + char type[4], promoted, separator, slash, *oldp, *commentEnd, c; + int wom = quickFlag ? quickFlag&1 : WhiteOnMove(yyboardindex); - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } + // ********* try white first, because it is so common ************************** + if(**p == ' ' || **p == '\n' || **p == '\t') { parseStart = (*p)++; return Nothing; } - 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_LVALUE->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; + if(**p == NULLCHAR) { // make sure there is something to parse + if(fromString) return 0; // we are parsing string, so the end is really the end + *p = inPtr = parseStart = inputBuf; + if(!ReadLine()) return 0; // EOF + } else if(inPtr > inputBuf + PARSEBUFSIZE/2) { // buffer fills up with already parsed stuff + char *q = *p, *r = inputBuf; + while(*r++ = *q++); + *p = inputBuf; inPtr = r - 1; + } + parseStart = oldp = *p; // remember where we begin + + // ********* attempt to recognize a SAN move in the leading non-blank text ***** + piece = separator = promoted = slash = n = 0; + for(i=0; i<4; i++) coord[i] = -1, type[i] = NOTHING; + if(**p & 0x80) return KifuMove(p); // non-ascii. Could be some kanj notation for Shogi or Xiangqi + if(**p == '+') (*p)++, promoted++; + if(**p >= 'a' && **p <= 'z' && (*p)[1]== '@') piece =*(*p)++ + 'A' - 'a'; else + if(**p >= 'A' && **p <= 'Z') { + static char s[] = SUFFIXES; + char *q; + piece = *(*p)++; // Note we could test for 2-byte non-ascii names here + if(q = strchr(s, **p)) (*p)++, piece += 64*(q - s + 1); + if(**p == '/') slash = *(*p)++; + } + while(n < 4) { + if(**p >= 'a' && **p < 'x') coord[n] = *(*p)++ - 'a', type[n++] = ALPHABETIC; + else if((i = Number(p)) != BADNUMBER) coord[n] = i, type[n++] = NUMERIC; + else break; + if(n == 2 && type[0] == type[1]) { // if two identical types, the opposite type in between must have been missing + type[2] = type[1]; coord[2] = coord[1]; + type[1] = NOTHING; coord[1] = -1; n++; + } + } + // we always get here, and might have read a +, a piece, and upto 4 potential coordinates + if(n <= 2) { // could be from-square or disambiguator, when -:xX follow, or drop with @ directly after piece, but also to-square + if(**p == '-' || **p == ':' || **p == 'x' || **p == 'X' || // these cannot be move suffix, so to-square must follow + (**p == '@' || **p == '*') && n == 0 && !promoted && piece) { // P@ must also be followed by to-square + separator = *(*p)++; + if(n == 1) coord[1] = coord[0]; // must be disambiguator, but we do not know which yet + n = 2; + while(n < 4) { // attempt to read to-square + if(**p >= 'a' && **p < 'x') coord[n] = *(*p)++ - 'a', type[n++] = ALPHABETIC; + else if((i = Number(p)) != BADNUMBER) coord[n] = i, type[n++] = NUMERIC; + else 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 (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->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; - } + } else if((**p == '+' || **p == '=') && n == 1 && piece && type[0] == NUMERIC) { // can be traditional Xiangqi notation + separator = *(*p)++; + n = 2; + if((i = Number(p)) != BADNUMBER) coord[n] = i, type[n++] = NUMERIC; + } else if(n == 2) { // only one square mentioned, must be to-square + while(n < 4) { coord[n] = coord[n-2], type[n] = type[n-2], coord[n-2] = -1, type[n-2] = NOTHING; n++; } + } + } else if(n == 3 && type[1] != NOTHING) { // must be hyphenless disambiguator + to-square + for(i=3; i>0; i--) coord[i] = coord[i-1], type[i] = type[i-1]; // move to-square to where it belongs + type[1] = NOTHING; // disambiguator goes in first two positions + n = 4; + } + // we always get here; move must be completely read now, with to-square coord(s) at end + if(n == 3) { // incomplete to-square. Could be Xiangqi traditional, or stuff like fxg + if(piece && type[1] == NOTHING && type[0] == NUMERIC && type[2] == NUMERIC && + (separator == '+' || separator == '=' || separator == '-')) { + // Xiangqi traditional + + return ImpossibleMove; // for now treat as invalid + } + // fxg stuff, but also things like 0-0, 0-1 and 1-0 + if(!piece && type[1] == NOTHING && type[0] == ALPHABETIC && type[2] == ALPHABETIC + && (coord[0] != 14 || coord[2] != 14) /* reserve oo for castling! */ ) { + piece = 'P'; n = 4; // kludge alert: fake full to-square + } + } else if(n == 1 && type[0] == NUMERIC && coord[0] > 1) { while(**p == '.') (*p)++; return Nothing; } // fast exit for move numbers + if(n == 4 && type[2] != type[3] && // we have a valid to-square (kludge: type[3] can be NOTHING on fxg type move) + (piece || !promoted) && // promoted indicator only valid on named piece type + (type[2] == ALPHABETIC || IS_SHOGI(gameInfo.variant))) { // in Shogi also allow alphabetic rank + DisambiguateClosure cl; + int fromX, fromY, toX, toY; + + if(slash && (!piece || type[1] == NOTHING)) goto badMove; // slash after piece only in ICS long format + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + if(type[2] == NUMERIC) { // alpha-rank + coord[2] = BOARD_RGHT - BOARD_LEFT - coord[2]; + coord[3] = BOARD_HEIGHT - coord[3]; + if(coord[0] >= 0) coord[0] = BOARD_RGHT - BOARD_LEFT - coord[0]; + if(coord[1] >= 0) coord[1] = BOARD_HEIGHT - coord[1]; + } + toX = cl.ftIn = (currentMoveString[2] = coord[2] + 'a') - AAA; + toY = cl.rtIn = (currentMoveString[3] = coord[3] + '0') - ONE; + if(type[3] == NOTHING) cl.rtIn = -1; // for fxg type moves ask for toY disambiguation + else if(toY >= BOARD_HEIGHT || toY < 0) return ImpossibleMove; // vert off-board to-square + if(toX < BOARD_LEFT || toX >= BOARD_RGHT) return ImpossibleMove; + if(piece) { + cl.pieceIn = CharToPiece(wom ? piece : piece + 'a' - 'A'); + if(cl.pieceIn == EmptySquare) return ImpossibleMove; // non-existent piece + if(promoted) cl.pieceIn = (ChessSquare) (CHUPROMOTED(cl.pieceIn)); + } else cl.pieceIn = EmptySquare; + if(separator == '@' || separator == '*') { // drop move. We only get here without from-square or promoted piece + fromY = DROP_RANK; fromX = cl.pieceIn; + currentMoveString[0] = piece; + currentMoveString[1] = '@'; + currentMoveString[4] = NULLCHAR; + return LegalityTest(boards[yyboardindex], PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, fromY, fromX, toY, toX, NULLCHAR); + } + if(type[1] == NOTHING && type[0] != NOTHING) { // there is a disambiguator + if(type[0] != type[2]) coord[0] = -1, type[1] = type[0], type[0] = NOTHING; // it was a rank-disambiguator + } + if( type[1] != type[2] && // means fromY is of opposite type as ToX, or NOTHING + (type[0] == NOTHING || type[0] == type[2]) ) { // well formed + int suffix = 7; + fromX = (currentMoveString[0] = coord[0] + 'a') - AAA; + fromY = (currentMoveString[1] = coord[1] + '0') - ONE; + currentMoveString[4] = cl.promoCharIn = PromoSuffix(p); + currentMoveString[5] = NULLCHAR; + if(**p == 'x' && !cl.promoCharIn) { // other leg follows + char *q = *p; + int x = *++*p, y; + ++*p; y = Number(p); + if(**p == '-' || **p == 'x') { // 3-leg move! + currentMoveString[7] = (kill2X = toX) + AAA; // what we thought was to-square is in fact 1st kill-square of two + currentMoveString[8] = (kill2Y = toY) + ONE; // append it after 2nd kill-square + toX = x - AAA; // kludge alert: this will become 2nd kill square + toY = y + '0' - ONE; + suffix += 2; + } else *p = q; // 2-leg move, rewind to leave reading of 2nd leg to code below } - - /* 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_LVALUE->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_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + if(!cl.promoCharIn && (**p == '-' || **p == 'x')) { // Lion-type multi-leg move + currentMoveString[5] = (killX = toX) + AAA; // what we thought was to-square is in fact kill-square + currentMoveString[6] = (killY = toY) + ONE; // append it as suffix behind long algebraic move + currentMoveString[4] = ';'; + currentMoveString[suffix+1] = NULLCHAR; + // read new to-square (VERY non-robust! Assumes correct (non-alpha-rank) syntax, and messes up on errors) + toX = cl.ftIn = (currentMoveString[2] = *++*p) - AAA; ++*p; + toY = cl.rtIn = (currentMoveString[3] = Number(p) + '0') - ONE; + currentMoveString[suffix] = cl.promoCharIn = PromoSuffix(p); } - - 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_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; + if(type[0] != NOTHING && type[1] != NOTHING && type[3] != NOTHING) { // fully specified. + ChessSquare realPiece = boards[yyboardindex][fromY][fromX]; + // Note that Disambiguate does not work for illegal moves, but flags them as impossible + if(piece) { // check if correct piece indicated + if(PieceToChar(realPiece) == '~') realPiece = (ChessSquare) (DEMOTED(realPiece)); + if(!(appData.icsActive && PieceToChar(realPiece) == '+') && // trust ICS if it moves promoted pieces + piece && realPiece != cl.pieceIn) return ImpossibleMove; + } else if(!separator && **p == '+') { // could be a protocol move, where bare '+' suffix means shogi-style promotion + if(realPiece < (wom ? WhiteCannon : BlackCannon) && PieceToChar(PROMOTED(realPiece)) == '+') // seems to be that + currentMoveString[4] = cl.promoCharIn = *(*p)++; // append promochar after all + } + result = LegalityTest(boards[yyboardindex], PosFlags(yyboardindex), fromY, fromX, toY, toX, cl.promoCharIn); + if (currentMoveString[4] == NULLCHAR) { // suppy missing mandatory promotion character + if(result == WhitePromotion || result == BlackPromotion) { + switch(gameInfo.variant) { + case VariantCourier: + case VariantShatranj: currentMoveString[4] = PieceToChar(BlackFerz); break; + case VariantGreat: currentMoveString[4] = PieceToChar(BlackMan); break; + case VariantShogi: currentMoveString[4] = '+'; break; + default: currentMoveString[4] = PieceToChar(BlackQueen); } + } else if(result == WhiteNonPromotion || result == BlackNonPromotion) { + currentMoveString[4] = '='; + } + } else if(appData.testLegality && gameInfo.variant != VariantSChess && // strip off unnecessary and false promo characters + !(result == WhitePromotion || result == BlackPromotion || + result == WhiteNonPromotion || result == BlackNonPromotion)) currentMoveString[4] = NULLCHAR; + return result; + } else if(cl.pieceIn == EmptySquare) cl.pieceIn = wom ? WhitePawn : BlackPawn; + cl.ffIn = type[0] == NOTHING ? -1 : coord[0] + 'a' - AAA; + cl.rfIn = type[1] == NOTHING ? -1 : coord[1] + '0' - ONE; + + Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); + + if(cl.kind == ImpossibleMove && !piece && type[1] == NOTHING // fxg5 type + && toY == (wom ? 4 : 3)) { // could be improperly written e.p. + cl.rtIn += wom ? 1 : -1; // shift target square to e.p. square + Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); + if((cl.kind != WhiteCapturesEnPassant && cl.kind != BlackCapturesEnPassant)) + return ImpossibleMove; // nice try, but no cigar } - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->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 (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); + currentMoveString[0] = cl.ff + AAA; + currentMoveString[1] = cl.rf + ONE; + currentMoveString[3] = cl.rt + ONE; + if(killX < 0) // [HGM] lion: do not overwrite kill-square suffix + currentMoveString[4] = cl.promoChar; - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; + if((cl.kind == WhiteCapturesEnPassant || cl.kind == BlackCapturesEnPassant) && !Match("ep", p)) Match("e.p.", p); - 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); - 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 >= 719 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *(yy_state_ptr)++ = yy_current_state; + return (int) cl.kind; + } + } +badMove:// we failed to find algebraic move + *p = oldp; + + + // Next we do some common symbols where the first character commits us to things that cannot possibly be a move + + // ********* PGN tags ****************************************** + if(**p == '[') { + oldp = ++(*p); kifu = 0; + if(Match("--", p)) { // "[--" could be start of position diagram + if(!Scan(']', p) && (*p)[-3] == '-' && (*p)[-2] == '-') return PositionDiagram; + *p = oldp; + } + SkipWhite(p); + if(isdigit(**p) || isalpha(**p)) { + do (*p)++; while(isdigit(**p) || isalpha(**p) || **p == '+' || + **p == '-' || **p == '=' || **p == '_' || **p == '#'); + SkipWhite(p); + if(**p == '"') { + (*p)++; + while(**p != '\n' && (*(*p)++ != '"'|| (*p)[-2] == '\\')); // look for unescaped quote + if((*p)[-1] !='"') { *p = oldp; Scan(']', p); return Comment; } // string closing delimiter missing + SkipWhite(p); if(*(*p)++ == ']') return PGNTag; } + } + Scan(']', p); return Comment; + } - 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 ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - - register YY_CHAR yy_c = 1; - 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 >= 719 ) - yy_c = yy_meta[(unsigned int) yy_c]; + // ********* SAN Castings ************************************* + if(**p == 'O' || **p == 'o' || **p == '0' && !Match("00:", p)) { // exclude 00 in time stamps + int castlingType = 0; + if(Match("O-O-O", p) || Match("o-o-o", p) || Match("0-0-0", p) || + Match("OOO", p) || Match("ooo", p) || Match("000", p)) castlingType = 2; + else if(Match("O-O", p) || Match("o-o", p) || Match("0-0", p) || + Match("OO", p) || Match("oo", p) || Match("00", p)) castlingType = 1; + if(castlingType) { //code from old parser, collapsed for both castling types, and streamlined a bit + int rf, ff, rt, ft; ChessSquare king; + char promo=NULLCHAR; + + if(gameInfo.variant == VariantSChess) promo = PromoSuffix(p); + + if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ + + if (wom) { + rf = castlingRank[0]; + rt = castlingRank[0]; + king = WhiteKing; + } else { + rf = castlingRank[3]; + rt = castlingRank[3]; + king = BlackKing; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 718); - if ( ! yy_is_jam ) - *(yy_state_ptr)++ = yy_current_state; - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); + ff = (BOARD_WIDTH-1)>>1; // this would be d-file + if (boards[yyboardindex][rf][ff] == king) { + /* ICS wild castling */ + ft = castlingType == 1 ? BOARD_LEFT+1 : (gameInfo.variant == VariantJanus ? BOARD_RGHT-2 : BOARD_RGHT-3); + } else { + char *q; + ff = BOARD_WIDTH>>1; // e-file + ft = castlingType == 1 ? BOARD_RGHT-2 : BOARD_LEFT+2; + if(pieceDesc[king] && (q = strchr(pieceDesc[king], 'O'))) { // redefined to non-default King stride + ft = (castlingType == 1 ? ff + atoi(q+1) : ff - atoi(q+1)); + } } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#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_LVALUE->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 ); - - /*FALLTHROUGH*/ - - 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; - } - } + if(PosFlags(0) & F_FRC_TYPE_CASTLING) { + if (wom) { + ff = initialRights[2]; + ft = initialRights[castlingType-1]; + } else { + ff = initialRights[5]; + ft = initialRights[castlingType+2]; + } + if (appData.debugMode) fprintf(debugFP, "Parser FRC (type=%d) %d %d\n", castlingType, ff, ft); + if(ff == NoRights || ft == NoRights) return ImpossibleMove; } + sprintf(currentMoveString, "%c%c%c%c%c",ff+AAA,rf+ONE,ft+AAA,rt+ONE,promo); + if (appData.debugMode) fprintf(debugFP, "(%d-type) castling %d %d\n", castlingType, ff, ft); - 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_LVALUE->yy_at_bol = (c == '\n'); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + return (int) LegalityTest(boards[yyboardindex], + PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.! + rf, ff, rt, ft, promo); + } else if(Match("01", p)) return Nothing; // prevent this from being mistaken for move number 1 } - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - 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_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = 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; -} - -static void yy_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(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 *) yyalloc(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; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ - void yy_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); - - yyfree((void *) b ); -} - -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - yy_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void yy_flush_buffer (YY_BUFFER_STATE b ) -{ - 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; + // ********* variations (nesting) ****************************** + if(**p =='(') { + if(RdTime(')', p)) return ElapsedTime; + return Open; + } + if(**p ==')') { (*p)++; return Close; } + if(**p == ';') { while(**p != '\n') (*p)++; return Comment; } + + + // ********* Comments and result messages ********************** + *p = oldp; commentEnd = NULL; result = 0; + if(**p == '{') { + if(RdTime('}', p)) return ElapsedTime; + if(lastChar == '\n' && Match("--------------\n", p)) { + char *q; + i = Scan ('}', p); q = *p - 16; + if(Match("\n--------------}\n", &q)) return PositionDiagram; + } else i = Scan('}', p); + commentEnd = *p; if(i) return Comment; // return comment that runs to EOF immediately + } + if(commentEnd) SkipWhite(p); + if(kifu && **p == '*') { // .kif comment + char *q = yytext; + while(**p && **p != '\n') { if(q < yytext + 10*MSG_SIZ-3) *q++ = **p; (*p)++; } + parseStart = yytext; *yytext = '{'; strcpy(q, "}\n"); // wrap in braces + return Comment; + } + if(Match("*", p)) result = GameUnfinished; + else if(**p == '0') { + if( Match("0-1", p) || Match("0/1", p) || Match("0:1", p) || + Match("0 - 1", p) || Match("0 / 1", p) || Match("0 : 1", p)) result = BlackWins; + } else if(**p == '1') { + if( Match("1-0", p) || Match("1/0", p) || Match("1:0", p) || + Match("1 - 0", p) || Match("1 / 0", p) || Match("1 : 0", p)) result = WhiteWins; + else if(Match("1/2 - 1/2", p) || Match("1/2:1/2", p) || Match("1/2 : 1/2", p) || Match("1 / 2 - 1 / 2", p) || + Match("1 / 2 : 1 / 2", p) || Match("1/2", p) || Match("1 / 2", p)) result = GameIsDrawn; + } + if(result) { + if(Match(" (", p) && !Scan(')', p) || Match(" {", p) && !Scan('}', p)) { // there is a comment after the PGN result! + if(commentEnd) { *p = commentEnd; return Comment; } // so comment before it is normal comment; return that first + } + return result; // this returns a possible preceeding comment as result details + } + if(commentEnd) { *p = commentEnd; return Comment; } // there was no PGN result following, so return as normal comment + + + // ********* Move numbers (after castlings or PGN results!) *********** + if((i = Number(p)) != BADNUMBER) { // a single number was read as part of our attempt to read a move + char *numEnd = *p; + if(**p == '.') (*p)++; SkipWhite(p); + if(**p == '+' || isalpha(**p) || gameInfo.variant == VariantShogi && *p != numEnd && isdigit(**p)) { + *p = numEnd; + return i == 1 ? MoveNumberOne : Nothing; + } + *p = numEnd; return Nothing; + } - b->yy_buf_pos = &b->yy_ch_buf[0]; - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; + // ********* non-compliant game-result indicators ********************* + if(Match("+-+", p) || Word("stalemate", p)) return GameIsDrawn; + if(Match("++", p) || Verb("resign", p) || (Word("check", p) || 1) && Word("mate", p) ) + return (wom ? BlackWins : WhiteWins); + c = ToUpper(**p); + if(Word("w", p) && (Match("hite", p) || 1) || Word("b", p) && (Match("lack", p) || 1) ) { + if(**p != ' ') return Nothing; + ++*p; + if(Verb("disconnect", p)) return GameUnfinished; + if(Verb("resign", p) || Verb("forfeit", p) || Word("mated", p) || Word("lost", p) || Word("loses", p)) + return (c == 'W' ? BlackWins : WhiteWins); + if(Word("mates", p) || Word("wins", p) || Word("won", p)) + return (c != 'W' ? BlackWins : WhiteWins); + return Nothing; + } + if(Word("draw", p)) { + if(**p == 'n') (*p)++; + if(**p != ' ') return GameIsDrawn; + oldp = ++*p; + if(Word("agreed", p)) return GameIsDrawn; + if(Match("by ", p) && (Word("repetition", p) || Word("agreement", p)) ) return GameIsDrawn; + *p = oldp; + if(*(*p)++ == '(') { + while(**p != '\n') if(*(*p)++ == ')') break; + if((*p)[-1] == ')') return GameIsDrawn; + } + *p = oldp - 1; return GameIsDrawn; + } - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; + // ********* Numeric annotation glyph ********************************** + if(**p == '$') { (*p)++; if(Number(p) != BADNUMBER) return NAG; return Nothing; } - yyensure_buffer_stack(); - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + // ********** by now we are getting down to the silly stuff ************ + if(Word("gnu", p) || Match("GNU", p)) { + if(**p == ' ') (*p)++; + if(Word("chess", p) || Match("CHESS", p)) { + char *q; + if((q = strstr(*p, "game")) || (q = strstr(*p, "GAME")) || (q = strstr(*p, "Game"))) { + (*p) = q + 4; return GNUChessGame; } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; + } + return Nothing; } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; + if(lastChar == '\n' && (Match("# ", p) || Match("; ", p) || Match("% ", p))) { + while(**p != '\n' && **p != ' ') (*p)++; + if(**p == ' ' && (Match(" game file", p) || Match(" position file", p))) { + while(**p != '\n') (*p)++; // skip to EOLN + return XBoardGame; + } + *p = oldp; // we might need to re-match the skipped stuff } - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; + if(Match("---", p)) { while(**p == '-') (*p)++; return Nothing; } // prevent separators parsing as null move + if(Match("@@@@", p) || Match("--", p) || Match("Z0", p) || Match("pass", p) || Match("null", p)) { + strncpy(currentMoveString, "@@@@", 5); + return yyboardindex & F_WHITE_ON_MOVE ? WhiteDrop : BlackDrop; } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) -{ - 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) yyalloc(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; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_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; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (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. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno (void) -{ - - return yylineno; -} - -/** Get the input stream. - * - */ -FILE *yyget_in (void) -{ - return yyin; -} - -/** Get the output stream. - * - */ -FILE *yyget_out (void) -{ - return yyout; -} - -/** Get the length of the current token. - * - */ -int yyget_leng (void) -{ - return yyleng; -} - -/** Get the current token. - * - */ - -char *yyget_text (void) -{ - return yytext; -} - -/** Set the current line number. - * @param line_number - * - */ -void yyset_lineno (int line_number ) -{ - - yylineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str ) -{ - yyin = in_str ; -} - -void yyset_out (FILE * out_str ) -{ - yyout = out_str ; -} - -int yyget_debug (void) -{ - return yy_flex_debug; -} - -void yyset_debug (int bdebug ) -{ - yy_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - - (yy_state_buf) = 0; - (yy_state_ptr) = 0; - (yy_full_match) = 0; - (yy_lp) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); + // ********* Efficient skipping of (mostly) alphabetic chatter ********** + while(isdigit(**p) || isalpha(**p) || **p == '-') (*p)++; + if(*p != oldp) { + if(**p == '\'') { + while(isdigit(**p) || isalpha(**p) || **p == '-' || **p == '\'') (*p)++; + return Nothing; // random word + } + if(lastChar == '\n' && Match(": ", p)) { // mail header, skip indented lines + do { + while(**p != '\n') (*p)++; + if(!ReadLine()) return Nothing; // append next line if not EOF + } while(Match("\n ", p) || Match("\n\t", p)); + } + return Nothing; } - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - yyfree ( (yy_state_buf) ); - (yy_state_buf) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( ); + // ********* Prevent 00 in unprotected time stamps to be mistaken for castling ******* + if(Match(":00", p)) return Nothing; - return 0; + // ********* Could not match to anything. Return offending character **** + (*p)++; + return Nothing; } /* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - /* 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 ); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 978 "parser.l" - - - - -static char *StringToLex; - -#ifndef FLEX_SCANNER -static FILE *lexFP; - -static int input() -{ - int ret; - - if (StringToLex != NULL) { - ret = *StringToLex; - if (ret == NULLCHAR) - ret = EOF; - else - StringToLex++; - } else if (unputCount > 0) { - ret = unputBuffer[--unputCount]; - } else { - ret = fgetc(lexFP); - } - - if (ret == EOF) - return 0; - else - return ret; -} - -/* - * Return offset of next pattern within current file - */ -int yyoffset() -{ - int offset = ftell(lexFP) - unputCount; - - if (offset < 0) { - offset = 0; - } - return(offset); -} - -static void output(ch) - int ch; -{ - if(appData.debugMode) fprintf(debugFP, "PARSER BUG: unmatched character '%c' (0%o)\n", - ch, ch); -} - -static void unput(ch) - int ch; -{ - if (ch == 0) return; - if (StringToLex != NULL) { - StringToLex--; - } else { - if (unputCount >= UNPUT_BUF_SIZE) - if(appData.debugMode) fprintf(debugFP, "PARSER BUG: unput buffer overflow '%c' (0%o)\n", - ch, ch); - unputBuffer[unputCount++] = ch; - } -} - -/* Get ready to lex from a new file. Kludge below sticks - an artificial newline at the front of the file, which the - above grammar ignores, but which makes ^ at start of pattern - match at the real start of the file. -*/ -void yynewfile(f) - FILE *f; -{ - lexFP = f; - StringToLex = NULL; - unputCount = 0; - unput('\n'); /* kludge */ -} - -/* Get ready to lex from a string. ^ at start of pattern WON'T - match at the start of the string! -*/ -void yynewstr(s) - char *s; -{ - lexFP = NULL; - StringToLex = s; - unputCount = 0; -} -#endif /*!FLEX_SCANNER*/ - -#ifdef FLEX_SCANNER -void my_yy_input(buf, result, max_size) - char *buf; - int *result; - int max_size; -{ - int count; - - if (StringToLex != NULL) { - count = 0; - while (*StringToLex != NULLCHAR) { - *buf++ = *StringToLex++; - count++; - } - *result = count; - return; - } else { - count = fread(buf, 1, max_size, yyin); - if (count == 0) { - *result = YY_NULL; - } else { - *result = count; - } - return; - } -} - -static YY_BUFFER_STATE my_file_buffer = NULL; - -/* Return offset of next pattern in the current file. */ -int yyoffset() -{ - int pos = yy_c_buf_p - YY_CURRENT_BUFFER->yy_ch_buf; - - return(ftell(YY_CURRENT_BUFFER->yy_input_file) - - yy_n_chars + pos); -} - - -void yynewstr(s) - char *s; -{ - if (my_file_buffer != NULL) - yy_delete_buffer(my_file_buffer); - StringToLex = s; - my_file_buffer = yy_create_buffer(stdin,YY_BUF_SIZE); - yy_switch_to_buffer(my_file_buffer); -} - -void yynewfile(f) - FILE *f; -{ - if (my_file_buffer != NULL) - yy_delete_buffer(my_file_buffer); - StringToLex = NULL; - my_file_buffer = yy_create_buffer(f,YY_BUF_SIZE); - yy_switch_to_buffer(my_file_buffer); -} -#endif /*FLEX_SCANNER*/ - -int yywrap() -{ - return TRUE; +int +yyoffset () +{ + return ftell(inputFile) - (inPtr - parsePtr); // subtract what is read but not yet parsed +} + +void +yynewfile (FILE *f) +{ // prepare parse buffer for reading file + inputFile = f; + inPtr = parsePtr = inputBuf; + fromString = 0; + lastChar = '\n'; + *inPtr = NULLCHAR; // make sure we will start by reading a line +} + +void +yynewstr P((char *s)) +{ + parsePtr = s; + inputFile = NULL; + fromString = 1; +} + +int +yylex () +{ // this replaces the flex-generated parser + int result = NextUnit(&parsePtr); + char *p = parseStart, *q = yytext; + if(p == yytext) return result; // kludge to allow kanji expansion + while(p < parsePtr) *q++ = *p++; // copy the matched text to yytext[] + *q = NULLCHAR; + lastChar = q[-1]; + return result; +} + +int +Myylex () +{ // [HGM] wrapper for yylex, which treats nesting of parentheses + int symbol, nestingLevel = 0, i=0; + char *p; + static char buf[256*MSG_SIZ]; + buf[0] = NULLCHAR; + do { // eat away anything not at level 0 + symbol = yylex(); + if(symbol == Open) nestingLevel++; + if(nestingLevel) { // save all parsed text between (and including) the () + for(p=yytext; *p && i<256*MSG_SIZ-2;) buf[i++] = *p++; + buf[i] = NULLCHAR; + } + if(symbol == 0) break; // ran into EOF + if(symbol == Close) symbol = Comment, nestingLevel--; + } while(nestingLevel || symbol == Nothing); + yy_text = buf[0] ? buf : (char*)yytext; + return symbol; } -/* Parse a move from the given string s */ -/* ^ at start of pattern WON'T work here unless using flex */ -ChessMove yylexstr(boardIndex, s, text, len) - int boardIndex, len; - char *s, *text; +ChessMove +yylexstr (int boardIndex, char *s, char *buf, int buflen) { ChessMove ret; - char *oldStringToLex; -#ifdef FLEX_SCANNER - YY_BUFFER_STATE buffer, oldBuffer; -#endif - + char *savPP = parsePtr; + fromString = 1; yyboardindex = boardIndex; - oldStringToLex = StringToLex; - StringToLex = s; -#ifdef FLEX_SCANNER - buffer = yy_create_buffer(stdin,YY_BUF_SIZE); - oldBuffer = YY_CURRENT_BUFFER; - yy_switch_to_buffer(buffer); -#endif /*FLEX_SCANNER*/ - - ret = (ChessMove) yylex(); - strncpy(text, yy_text, len-1); // [HGM] vari: yy_text is not available to caller after buffer switch ?!? - text[len-1] = NULLCHAR; - -#ifdef FLEX_SCANNER - if (oldBuffer != NULL) - yy_switch_to_buffer(oldBuffer); - yy_delete_buffer(buffer); -#endif /*FLEX_SCANNER*/ - StringToLex = oldStringToLex; - + parsePtr = s; + ret = (ChessMove) Myylex(); + strncpy(buf, yy_text, buflen-1); + buf[buflen-1] = NULLCHAR; + parsePtr = savPP; + fromString = 0; return ret; } -