Fix multi-leg promotions
[xboard.git] / parser.c
index f02b9c8..4c634ca 100644 (file)
--- a/parser.c
+++ b/parser.c
-
-#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 <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. 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 <inttypes.h>
-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[644] =
-    {   0,
-       44,   42,   43,   42,   43,   42,   43,   41,   42,   43,
-       38,   42,   43,   39,   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, 8219,   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,   23,   41,   23,   25,
-       41,   41,   41,   41,   41,    7,   41,   41,   41,   41,
-       41,   41,   10,   41,   41,   41,   41,    5,   41,    4,
-       41,    4,    4,   41,    4,   41,    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,   26,   26,    7,
-       41,   11,    7,   41,    3,   41,    8,   41,    7,    7,
-       41,    7,    7,   41,    7,   41,   41,   41,   41,   20,
-       41,   41,   17,   41,   41,   41,   41,   41,   37,    4,
-       41,    2,   41,    6,    5,    6,    6,    6,   41,   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,    8,
-
-        7,    7,    3,    8,    8,    8,   41,    1,   41,   21,
-       41,   41,   20,   41,   41,   41,   41,   41,   41,   31,
-       37,    2,    2,    2,    2,   41,    6,    6,   41,   40,
-        8,   41,    1,   41,   41,   41,   20,   41,   41,   41,
-       41,   41,   41,    2,   41,    6,   41,   28,    8,    1,
-       24,   24,   23,   23,   25,   25,    1,    1,    1,   41,
-       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[693] =
-    {   0,
-        1,    1,    1,    2,    4,    6,    8,   11,   14,   17,
-       20,   22,   25,   29,   33,   35,   38,   41,   44,   47,
-       50,   53,   56,   59,   62,   65,   68,   70,   73,   76,
-       79,   82,   85,   88,   91,   94,   97,  100,  103,  106,
-      109,  112,  115,  118,  121,  124,  126,  128,  131,  134,
-      138,  142,  144,  147,  150,  153,  156,  159,  162,  165,
-      168,  171,  174,  177,  180,  183,  186,  189,  192,  195,
-      198,  201,  204,  207,  210,  213,  216,  219,  222,  225,
-      228,  231,  233,  233,  234,  235,  235,  235,  236,  236,
-      236,  236,  237,  237,  239,  239,  239,  239,  240,  241,
-
-      241,  241,  243,  243,  245,  245,  246,  246,  247,  247,
-      248,  248,  249,  249,  250,  251,  252,  253,  254,  255,
-      256,  257,  259,  260,  261,  262,  262,  262,  262,  262,
-      263,  264,  266,  266,  267,  269,  270,  271,  272,  273,
-      274,  276,  277,  278,  278,  278,  278,  279,  279,  280,
-      280,  281,  283,  283,  284,  286,  286,  288,  288,  289,
-      290,  290,  291,  292,  293,  294,  295,  296,  297,  298,
-      299,  301,  302,  303,  304,  305,  307,  307,  308,  310,
-      311,  312,  313,  314,  315,  317,  318,  319,  319,  319,
-      319,  319,  319,  320,  320,  320,  320,  320,  320,  322,
-
-      324,  325,  327,  327,  327,  327,  329,  330,  331,  331,
-      332,  332,  333,  333,  334,  335,  335,  336,  338,  338,
-      338,  338,  338,  338,  338,  338,  339,  340,  341,  342,
-      343,  345,  346,  347,  348,  348,  348,  348,  348,  350,
-      350,  351,  352,  352,  353,  355,  357,  359,  360,  360,
-      362,  363,  365,  366,  367,  368,  370,  371,  372,  372,
-      372,  372,  372,  373,  375,  377,  379,  381,  381,  382,
-      382,  383,  384,  384,  385,  386,  387,  389,  389,  390,
-      391,  392,  393,  394,  396,  397,  398,  399,  401,  402,
-      402,  404,  406,  408,  410,  412,  413,  414,  415,  417,
-
-      418,  418,  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,
-      432,  432,  433,  435,  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,  458,  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,
-      501,  502,  503,  503,  503,  503,  503,  503,  503,  503,
-      503,  503,  504,  504,  505,  506,  508,  510,  510,  510,
-      510,  510,  510,  511,  512,  513,  513,  515,  515,  516,
-      517,  518,  519,  520,  520,  520,  522,  522,  522,  523,
-      523,  524,  525,  527,  528,  528,  528,  530,  530,  530,
-      530,  530,  530,  530,  530,  531,  531,  531,  533,  535,
-      536,  537,  539,  540,  541,  542,  543,  544,  546,  548,
-      548,  548,  549,  549,  550,  551,  551,  552,  552,  553,
-      553,  554,  554,  555,  555,  556,  556,  557,  557,  557,
-
-      557,  558,  559,  561,  561,  561,  562,  562,  562,  563,
-      564,  564,  564,  564,  564,  564,  565,  566,  568,  569,
-      571,  571,  572,  573,  573,  573,  575,  575,  575,  576,
-      577,  577,  577,  579,  580,  581,  582,  584,  585,  585,
-      586,  586,  586,  587,  587,  588,  588,  588,  589,  589,
-      589,  590,  590,  590,  590,  590,  591,  592,  593,  595,
-      596,  596,  596,  596,  596,  596,  597,  598,  599,  601,
-      602,  602,  602,  602,  602,  602,  602,  603,  603,  603,
-      603,  603,  604,  605,  605,  605,  605,  605,  606,  607,
-      607,  607,  607,  607,  608,  608,  608,  608,  609,  610,
-
-      612,  612,  612,  612,  612,  613,  613,  614,  616,  616,
-      616,  616,  616,  617,  618,  618,  618,  618,  618,  619,
-      620,  621,  621,  621,  621,  621,  621,  622,  623,  623,
-      623,  623,  623,  624,  625,  626,  627,  627,  627,  627,
-      627,  627,  629,  629,  629,  629,  629,  630,  631,  633,
-      633,  633,  634,  634,  635,  635,  636,  636,  636,  638,
-      638,  639,  640,  640,  640,  640,  640,  642,  642,  642,
-      642,  642,  642,  642,  642,  642,  642,  642,  642,  642,
-      642,  642,  642,  642,  642,  642,  642,  642,  642,  643,
-      644,  644
-
-    } ;
-
-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,   33,   34,   35,   36,   37,   38,
-       38,   39,   40,   38,   41,   38,   42,   43,   38,   38,
-       44,    1,   45,    1,   46,    1,   47,   48,   49,   50,
-
-       51,   52,   53,   54,   55,   56,   57,   58,   59,   60,
-       61,   62,   63,   64,   65,   66,   67,   68,   69,   70,
-       71,   68,   72,    1,   73,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    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[74] =
-    {   0,
-        1,    2,    3,    2,    1,    1,    1,    1,    4,    5,
-        1,    1,    6,    7,    8,    9,   10,   10,   10,   10,
-       11,    1,    5,    1,   12,   12,   12,   12,   12,   12,
-       12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
-       12,   12,   13,    1,    1,    1,   14,   14,   14,   14,
-       15,   14,   14,   14,   14,   14,   14,   14,   16,   17,
-       17,   17,   17,   17,   16,   16,   16,   16,   16,   18,
-       16,    1,    1
-    } ;
-
-static yyconst flex_int16_t yy_base[756] =
-    {   0,
-        0,   73, 2885, 3866,  122,  131,    0,  135, 3866, 2880,
-      143,  154,  174,  244, 2880,  304,  155, 2828, 2817,  124,
-      162,  144,  182,  186,  203,  212,  374,  434,  168,  161,
-      223,  204,  228,  241,  237,  180,  249,  279,  282,  295,
-      161,  379,  174,  326,  390,  405, 2876,  203,  395,  503,
-      573,  162,  636,  210, 2825, 2813,  242,  326,  314,  412,
-      349,  442,  417,  693,  409,  416,  446,  391,  421,  478,
-      317,  480,  492,  494,  496,  586,  587,  588,  607,  605,
-      711,  648, 2823,  481,    0,  538,  228, 3866, 2862,  752,
-      564,  232, 2856, 2856, 2854,  403,  772, 3866, 2851,  561,
-
-      398,    0, 2850,    0, 2863, 3866,    0,  776,    0,  826,
-        0,  884,  927, 2818, 2813, 2816, 2821, 2794,  586, 2794,
-     2822, 2821, 2792, 2808, 2799, 2808,  996,  253, 1069, 3866,
-     1096, 1146,    0, 1171, 1220,  603,  617,  657, 2786, 2790,
-     2789, 2780, 2789,  360, 2770,  679, 2838, 2835,  436, 2824,
-      652,  494,  542,  707, 1270,  282,  455,  279, 1333, 1383,
-     2819, 1441, 2775, 2770,  708,  606,  558,  684, 2754, 2782,
-      524, 2753,  709, 2762, 1465, 1515, 2812, 1540, 1590,  890,
-      897,  963,  713,  716,  717,  718,  891,  777, 2751,  740,
-     2803, 2740, 3866,  768,  905, 2808, 2807, 2806, 2795, 2804,
-
-     2803,    0, 2802, 2800, 2799, 2798, 2796,  939,  795,  799,
-      932, 1637, 1671,  970,  975, 1004, 1000, 1721, 1022, 2744,
-     2734, 2733, 2746, 2741,  563, 1033, 1037, 2722,  793, 2739,
-     2773, 2730, 2726, 1028,  303, 1056,  162, 1792, 1856,    0,
-     3866, 1861,    0, 2772, 2769, 2767, 1078, 1089, 1106, 1910,
-     2767, 2761,  413, 2722, 2721, 2755, 2695, 3866, 1085,  946,
-     2751,  348, 2747,  827, 1106,  592, 1113,  476, 2745,  728,
-     1277, 1953, 2744, 1283, 1290, 1287, 2003, 2743, 1313, 1346,
-      947, 1347, 1110, 1255, 1028, 1112, 1340, 2066, 2109, 2742,
-      828, 2734, 1454, 2158, 1109, 1796, 1256, 1257, 1261, 1066,
-
-      962, 2693, 1118, 2732, 2730, 2667, 2666, 1214, 2200, 2720,
-     2719, 2717, 2717,  574, 2704,  564, 2700,  695, 1384,  677,
-     3866, 2261, 1329, 1306,    0, 2295, 1454, 1456, 3866, 2292,
-     1798, 1805, 2704, 2703, 1327, 2648, 2648, 2641, 2639, 2639,
-     2639, 2641, 2640,  659,  735,  913,    0, 2656, 2629, 2625,
-     2622,  719,  740,  925,  868, 2667, 2657, 1358, 1463, 1812,
-     1810, 2651, 1000, 1829, 3866, 2650, 2644, 1049, 3866, 2577,
-        0, 2573, 1831, 2629, 1839, 1853, 2584, 2548, 2597,  676,
-     1789,  171,  917, 2337,  938, 2398, 2395, 2591, 1835, 2583,
-     1946, 1913, 1968, 1967, 2101, 1259, 1838, 2116, 1947, 1948,
-
-     2122, 2259, 2069, 2111, 1272, 2114, 1454, 2539,  498, 2101,
-     2574, 2573, 1483, 2567, 2499, 2558, 2495, 2542, 2461, 2513,
-     1598, 3866, 2106, 3866, 2192, 2519, 2444, 2477, 2472, 1811,
-     2449, 2444, 2433, 2493, 1004, 1668, 2492, 1012, 2466, 2442,
-     2432, 2430, 2461,  747, 1425, 3866, 2459, 1632, 2193, 2194,
-     3866, 2252, 2452, 2451, 1544, 2399,    0, 2444, 2135, 2440,
-     1658, 2405, 2361, 2354, 1188, 1501, 1035, 2125, 2478, 2348,
-     2344, 2350, 2346, 2161, 2352, 2347, 2392, 2298, 1724, 1918,
-      737, 3866, 1488, 2407, 2353, 2406, 2403, 2336, 2326, 2387,
-     2372, 2308, 2305, 2366, 2363, 2291, 2244, 2300, 2296, 2387,
-
-     3866, 2392, 2303, 2252, 2261, 1907, 1759, 2258, 3866, 2263,
-     2295, 2234, 2212, 2234, 2210, 2219, 2155, 1328, 2172, 3866,
-     2082, 3866, 2168, 2163, 2519, 2173, 2103, 2098, 2148, 1367,
-     1475,  918, 2351, 2447, 2514, 2395, 2481, 2519, 2074, 3866,
-     2097, 1695, 2134, 2140, 2117, 2055, 2058, 3866, 2052, 2072,
-     2071, 2019, 2045, 2008, 1982, 1978, 1950, 1944,    0, 1927,
-     2524, 1986, 1894,  925, 1473, 2524, 2538, 2539, 2361, 2540,
-     2208, 1899, 1882, 1665, 1813, 1797, 1789, 1787, 1203, 1787,
-     1643, 2606, 1632, 1628, 1621, 1714, 1482, 2679, 2542, 2452,
-     1539, 1510, 1480, 3866, 1444, 1456, 1712, 2752, 1853,    0,
-
-     1431, 1312, 1869, 1706, 2825, 2214, 1878, 2541, 2553, 1304,
-     1293, 2527, 1209, 1182, 1110, 1102, 1349, 1842, 2526, 1104,
-     1069, 2562, 1001,  947, 1961, 2121,  945,  920,  770,  794,
-     1903, 1232, 2552, 2617,  765,  702, 2567, 2195,  617, 1966,
-     2213,    0,  656,  578,  563, 1923, 2601, 2612,    0, 2568,
-      487, 3866,  468, 1874,  499, 3866,  401,  424, 3866, 2169,
-     2570, 2593, 2572,  289,  283, 1678, 2622, 2574,  257, 2125,
-     1528, 1600, 1609, 2584, 2588, 2635, 2653, 2655, 2660, 2663,
-     2693, 2706, 2708, 2713, 2715, 2716, 2728, 2076,  194, 3866,
-     3866, 2895, 2908, 2920, 2938, 2956, 2974, 2989, 3006, 3023,
-
-     1313, 1696, 1856, 3040, 3058, 1914, 3076, 3094, 3111, 3129,
-     3147, 3165, 3177, 3195, 3213, 3231, 3249, 3256, 1916, 3270,
-     3285, 3303, 3321, 3339, 3357, 3375, 3387, 3401, 3414, 3432,
-     3450, 3468, 3483, 3497, 3512, 3530, 3545, 3559, 3572, 3590,
-     3608, 3626, 3644, 3662, 3676, 3694, 3708, 3721, 3739, 3757,
-     3775, 3793, 3811, 3829, 3847
-    } ;
-
-static yyconst flex_int16_t yy_def[756] =
-    {   0,
-      691,  691,  691,  691,  691,  691,  692,  691,  691,  691,
-      693,  692,  694,  694,  695,  692,   16,   16,   16,   16,
-       16,   16,   16,   16,   16,   16,  696,   16,   28,   28,
-       28,   28,   28,   28,   28,   28,   28,   28,   28,  692,
-      692,  692,  692,  692,  692,  697,  691,  698,  698,  699,
-      699,  695,  698,   53,   53,   53,   53,   53,   53,   53,
-       53,   53,   53,   53,   64,   64,   64,   64,   64,   64,
-       64,   64,   64,   64,   64,  698,  698,  698,  698,  698,
-      698,  697,  691,  691,  692,  691,  691,  691,  691,  691,
-      691,  692,  691,  692,  691,  700,  700,  691,  692,  700,
-
-      691,   14,  691,  692,  695,  691,  701,  692,  702,  691,
-      703,  692,  691,  112,  112,  692,  692,  692,  112,  112,
-      108,  692,  112,  692,  112,  704,  696,  704,  705,  691,
-      692,  691,  706,  692,  692,  692,  692,  692,  692,  692,
-      692,  692,  692,  697,  707,  697,  691,  708,  698,  691,
-      698,  698,  691,  698,  709,  691,  698,  710,  698,  691,
-      703,  159,  162,  162,  698,  698,  698,  162,  162,  159,
-      698,  162,  698,  162,  159,  691,  706,  159,  691,  698,
-      698,  698,  698,  698,  698,  698,  698,  697,  691,  691,
-      711,  712,  691,  713,  713,  691,  691,  691,  692,  692,
-
-      691,  692,  691,  691,  691,  692,  691,  691,  691,  692,
-      691,  692,  691,  692,  692,  691,  212,  691,  713,  691,
-      691,  691,  691,  691,  691,  692,  692,  692,  692,  692,
-      692,  692,  692,  692,  714,  715,  716,  717,  692,  718,
-      691,  692,  719,  718,  692,  242,  692,  720,  720,  692,
-      249,  692,  692,  692,  692,  692,  692,  691,  697,  691,
-      721,  691,  722,  698,  698,  698,  698,  723,  721,  724,
-      698,  698,  213,  698,  698,  272,  691,  219,  698,  698,
-      698,  698,  698,  698,  698,  698,  698,  698,  698,  719,
-      698,  289,  698,  288,  698,  698,  698,  698,  698,  698,
-
-      697,  691,  691,  725,  725,  726,  726,  691,  691,  691,
-      691,  691,  692,  691,  691,  691,  691,  691,  691,  691,
-      691,  692,  727,  691,  692,  692,  728,  728,  691,  692,
-      727,  728,  692,  330,  692,  691,  691,  691,  691,  691,
-      691,  692,  692,  692,  691,  692,  692,  692,  692,  692,
-      692,  729,  729,  730,  731,  732,  691,  692,  691,  733,
-      734,  691,  691,  734,  691,  364,  692,  692,  691,  691,
-      692,  692,  697,  691,  691,  691,  691,  691,  735,  691,
-      698,  736,  736,  277,  698,  384,  289,  331,  698,  387,
-      698,  698,  698,  698,  698,  698,  698,  698,  698,  698,
-
-      698,  737,  698,  698,  698,  698,  697,  691,  691,  738,
-      691,  331,  691,  739,  740,  741,  742,  743,  744,  691,
-      691,  691,  738,  691,  738,  692,  692,  691,  691,  691,
-      691,  691,  691,  692,  692,  691,  692,  691,  692,  692,
-      692,  692,  692,  729,  731,  691,  732,  691,  745,  745,
-      691,  745,  692,  691,  691,  691,  692,  691,  697,  691,
-      691,  691,  691,  691,  746,  736,  736,  698,  384,  698,
-      698,  698,  698,  698,  698,  698,  698,  698,  698,  697,
-      691,  691,  691,  691,  747,  739,  739,  740,  740,  741,
-      741,  742,  742,  743,  743,  744,  744,  691,  691,  747,
-
-      691,  747,  692,  691,  691,  691,  691,  691,  691,  692,
-      748,  691,  691,  691,  691,  692,  692,  692,  692,  691,
-      691,  691,  691,  691,  697,  691,  691,  691,  746,  746,
-      736,  736,  698,  698,  698,  698,  698,  698,  697,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  748,
-      748,  691,  691,  691,  691,  692,  692,  692,  692,  692,
-      697,  691,  691,  736,  736,  698,  698,  698,  698,  698,
-      697,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  749,  692,  691,  691,  736,  736,  750,  698,  697,
-      691,  691,  691,  691,  691,  751,  751,  749,  598,  692,
-
-      691,  691,  736,  736,  750,  751,  605,  698,  697,  691,
-      691,  751,  598,  598,  691,  691,  736,  736,  752,  605,
-      605,  697,  691,  691,  751,  751,  598,  598,  691,  691,
-      736,  736,  752,  752,  605,  605,  697,  691,  691,  751,
-      751,  598,  753,  691,  754,  736,  752,  752,  605,  697,
-      691,  691,  691,  751,  753,  691,  691,  754,  691,  736,
-      752,  752,  697,  691,  691,  736,  752,  697,  691,  736,
-      697,  755,  755,  755,  755,  755,  755,  755,  755,  755,
-      755,  755,  755,  755,  755,  755,  755,  755,  691,  691,
-        0,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691
-    } ;
-
-static yyconst flex_int16_t yy_nxt[3940] =
-    {   0,
-        4,    4,    4,    5,    4,    4,    6,    4,    7,    8,
-        9,   10,   11,    7,    4,    4,   12,   13,   14,   14,
-        4,   15,    4,    4,   16,   17,   18,   19,   16,   16,
-       20,   16,   16,   16,   21,   22,   23,   22,   24,   25,
-       22,   26,   22,   27,    4,    4,   28,   29,   30,   31,
-       32,   33,   34,   35,   36,   37,   38,   39,   40,   41,
-       42,   41,   41,   43,   44,   41,   41,   41,   45,   41,
-       41,   46,    4,    4,    4,    4,    5,    4,   47,    6,
-       47,    7,    8,    9,   10,   11,   48,    4,    4,   49,
-       50,   51,   51,    4,   52,    4,    4,   53,   54,   55,
-
-       56,   53,   53,   57,   53,   53,   53,   58,   59,   60,
-       59,   61,   62,   59,   63,   59,   27,    4,    4,   64,
-       65,   66,   67,   68,   69,   70,   71,   72,   73,   74,
-       75,   76,   77,   78,   77,   77,   79,   80,   77,   77,
-       77,   81,   77,   77,   82,    4,   83,   84,   84,   84,
-       84,   86,   86,   86,   86,   88,   89,   91,  113,  117,
-      119,  119,  119,  119,  106,  158,  355,   92,   83,   93,
-       94,  113,  107,  106,   95,   96,   96,   97,  119,  119,
-      119,  119,   85,  118,  107,  107,   98,   99,  100,  101,
-      102,  102,  102,  102,  103,  121,  690,  107,  119,  119,
-
-      119,  119,  119,  119,  119,  119,  356,  136,  120,  135,
-      135,   85,  114,  113,  138,  113,  135,  466,  122,  119,
-      119,  119,  119,  150,  142,  137,  136,  136,  119,  119,
-      119,  119,   85,  135,  135,  135,  123,  191,   85,   85,
-       85,   85,   85,   85,   85,   96,   96,   96,  199,  200,
-      136,  136,   85,  135,  135,  135,   98,   85,  100,  691,
-      102,  102,  102,  102,  691,  125,  235,  163,  124,  136,
-      136,  135,  135,  135,  136,  136,  117,  166,  135,  135,
-      135,  269,  270,  136,  136,  263,  116,  136,  136,  135,
-      135,  135,  135,  135,  135,  136,  136,  130,  207,  192,
-
-      118,  167,   85,  135,  135,  135,  107,  643,   85,   85,
-       85,   85,   85,   85,   85,  107,  353,  108,  107,  109,
-      110,  110,  110,  110,  111,  136,  136,  107,  136,  136,
-      168,  168,  168,  168,  135,  135,  135,  107,  135,  135,
-      669,  139,  168,  168,  168,  168,  108,  130,  540,  107,
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112,
-      112,  112,  145,  180,  180,  168,  168,  168,  168,  179,
-      179,  179,  169,  108,  126,  127,  127,  127,  126,  126,
-      126,  126,  126,  126,  126,  126,  126,  128,  126,  126,
-      107,  124,  140,  113,  126,  126,  126,  126,   91,  172,
-
-      377,  107,  107,   85,   96,   96,   96,  145,  151,  378,
-       93,  152,  113,  107,  207,  153,  208,  126,  130,  126,
-      113,  146,  146,  146,  146,  170,  659,  370,  168,  168,
-      168,  168,  147,  168,  168,  168,  168,  180,  180,  141,
-      179,  179,  179,  143,   85,  126,  126,  131,  171,  691,
-      132,  132,  132,  132,  133,  665,  150,  179,  168,  168,
-      168,  168,  180,   85,  179,  179,  181,  180,  180,  182,
-      174,  179,  179,  179,  371,  150,  134,  147,  269,  270,
-      135,  135,  136,  136,  136,  136,  136,  136,  136,  136,
-      136,  136,  180,  180,  179,  179,  179,   84,   84,   84,
-
-       84,  656,   85,  134,   96,   96,   97,  173,  482,  165,
-      266,   85,  483,  166,  150,   98,  154,  100,  101,  155,
-      155,  155,  155,  156,  180,  180,  180,  180,  664,  179,
-      179,  179,   85,  179,  179,  179,  652,  167,  180,  180,
-      180,  180,  180,  180,  150,  263,  179,  179,  179,  179,
-      179,  179,  179,  179,   86,   86,   86,   86,  190,  201,
-      266,  149,   96,   96,   96,  659,   85,  149,  149,  149,
-      149,  149,  149,  149,   96,   96,   96,  196,  150,  197,
-      207,   85,  208,  414,  198,   98,  149,  100,  691,  155,
-      155,  155,  155,  150,   85,   85,   85,  107,  107,  107,
-
-       85,  184,   85,   85,   85,   85,  150,  150,  150,  107,
-      107,  107,  150,   85,   85,   85,  107,  341,  107,  250,
-      250,  250,  250,  341,  282,  150,  150,  150,  107,  657,
-      107,  149,  183,  250,  250,  250,  250,  149,  149,  149,
-      149,  149,  149,  149,   85,  415,  282,  107,  185,  159,
-      145,  109,  160,  160,  160,  160,  161,  186,  656,  107,
-       85,  188,  436,  254,  146,  146,  146,  146,  264,  265,
-      173,  653,  150,  250,  250,  250,  250,  465,  159,  465,
-      420,  145,  162,  162,  162,  162,  162,  162,  162,  162,
-      162,  162,  162,  162,  421,  146,  146,  146,  146,  259,
-
-      149,  149,  149,  149,  416,  159,  175,  255,  691,  176,
-      176,  176,  176,  177,  113,   85,   85,   85,  437,   85,
-      147,   85,  107,  267,   85,   85,   85,  150,  150,  150,
-      106,  150,  353,  150,  107,  178,  150,  150,  150,  179,
-      179,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  147,  649,  444,  281,  286,  303,  303,  303,  303,
-      444,  438,  178,  130,  187,  111,  417,  109,  194,  194,
-      194,  194,  111,   96,   96,   96,  299,  266,  283,  145,
-      382,  219,  285,  438,  130,  203,  540,  204,  219,  383,
-      301,  520,  205,  649,  111,  541,  345,  644,  195,  195,
-
-      195,  195,  195,  195,  195,  195,  195,  195,  195,  195,
-      219,  321,  321,  321,  321,  322,  322,  322,  322,  346,
-      643,  111,  210,  210,  210,  210,  210,  210,  210,  210,
-      210,  210,  210,  210,   85,   85,   85,  219,  241,  212,
-      381,  346,   85,   85,   85,   85,  213,  150,  150,  147,
-      214,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-       85,   85,   85,   85,   85,   85,   85,   85,  212,  445,
-      445,  445,  215,  215,  215,  215,  215,  215,  215,  215,
-      215,  215,  215,  215,   85,   85,   85,   85,   85,   85,
-       85,   85,   85,   85,   85,  212,   85,  217,   85,   85,
-
-      218,  218,  218,  218,  219,   85,  294,  294,  294,  294,
-      150,  150,  446,  294,  294,  294,  294,  150,  219,  106,
-      106,  309,  309,  309,  309,  219,  217,  106,  586,  355,
-      215,  215,  215,  215,  215,  215,  215,  215,  215,  215,
-      215,  215,  319,  297,  439,  300,   85,  219,  323,  323,
-      323,  323,  320,  217,  220,   85,  221,  374,  150,  320,
-      222,  223,  375,  376,  145,  224,  440,  150,  225,  356,
-      642,   85,  565,  642,  219,  407,  220,  467,  221,  294,
-      294,  294,  294,  150,  222,  223,  325,  325,  325,  325,
-      224,  326,  326,  326,  326,  225,  126,  127,  127,  127,
-
-      126,  126,  126,  126,  126,  126,  126,  126,  126,  126,
-      126,  126,  639,  298,  370,  394,  126,  126,  126,  126,
-      327,  327,  327,  327,   85,   85,   85,   85,   85,   85,
-       85,   85,   85,   85,  147,  691,   85,  106,  510,  126,
-      130,  126,  691,  514,  326,  326,  326,  326,  150,  326,
-      326,  326,  326,  326,  326,  326,  326,  236,  236,  236,
-      237,  369,  510,  456,  691,  515,  638,  126,  126,  126,
-      236,  236,  236,  237,   85,  126,  126,  126,  126,  126,
-      126,  342,  398,  126,  126,  343,  150,  145,  241,  126,
-      126,  691,  126,  351,  360,  360,  360,  360,  249,  532,
-
-      130,  373,  373,  373,  373,  361,  361,  361,  361,  314,
-      457,  251,  126,  130,   85,  691,  318,   85,   85,  369,
-       85,   85,  691,  691,  691,  691,  150,  636,  691,  150,
-      150,  400,  150,  150,  409,  409,  409,  409,  635,  363,
-      126,  126,  239,  239,  239,  239,  239,  239,  239,  239,
-      239,  239,  239,  239,   85,  240,  691,  147,  241,  242,
-      396,  630,   85,   85,   85,   85,  243,  629,  244,  399,
-      245,  245,  245,  245,  245,  245,  245,  245,  245,  245,
-      245,  245,  245,  245,  245,  245,  245,  245,  246,  530,
-      380,  530,  247,  247,  247,  247,  247,  247,  247,  247,
-
-      247,  247,  247,  247,  245,  245,  245,  245,  245,  245,
-      245,  245,  245,  245,  245,  246,  245,  135,  135,  135,
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  249,
-      410,  410,  410,  410,  106,  646,  250,  250,  250,  250,
-      628,  512,  251,  627,  252,  252,  252,  252,  252,  252,
-      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
-      252,  252,  252,   85,   85,   85,  512,   85,  397,   85,
-      253,   96,   96,   96,  406,  150,  150,  150,   85,  150,
-       85,  150,   98,  149,  100,   85,  155,  155,  155,  155,
-      150,   85,  150,  384,  384,  384,  384,  150,   85,  385,
-
-      385,  385,  385,  150,  392,  393,  386,  386,  386,  386,
-      150,  149,  149,  149,  149,  149,  149,  149,  149,  149,
-      149,   85,  422,  422,  422,  422,  209,  209,  149,  386,
-      386,  386,  386,  150,  149,  149,  149,  149,  149,  149,
-      149,   85,  331,  427,  427,  427,  427,  624,   85,  331,
-      345,  106,  623,  150,   85,   85,  386,  386,  386,  386,
-      150,  392,  386,  386,  386,  386,  150,  150,  530,  380,
-      530,  331,  616,  395,  360,  360,  360,  360,  558,  271,
-      271,  271,  271,  271,  271,  271,  271,  271,  271,  271,
-      271,   85,  559,  418,  393,  395,  272,  320,  331,  149,
-
-      149,  149,  149,  273,  320,  400,  631,  274,  274,  274,
-      274,  274,  274,  274,  274,  274,  274,  149,  149,  149,
-      149,  149,  149,  149,  149,  272,  445,  445,  445,  275,
-      275,  275,  275,  275,  275,  275,  275,  275,  275,  275,
-      275,  149,  149,  149,  149,  149,  149,  149,  149,  149,
-      149,  149,  272,  149,  276,  419,  145,  277,  277,  277,
-      277,  278,   85,  328,  241,  691,  329,  480,  691,  446,
-      402,  402,  402,  402,  150,  106,  332,  106,  691,  449,
-      449,  449,  449,  276,  106,  615,  612,  275,  275,  275,
-      275,  275,  275,  275,  275,  275,  275,  275,  275,  485,
-
-      485,  485,  485,  106,  542,  542,  542,  542,  612,  611,
-      276,  288,  288,  288,  288,  288,  288,  288,  288,  288,
-      288,  288,  288,   85,  240,  564,  147,  241,  289,  594,
-      672,  149,  149,  149,  149,  290,  604,  244,  587,  291,
-      291,  291,  291,  291,  291,  291,  291,  291,  291,  291,
-      291,  291,  291,  291,  291,  291,  291,  292,  456,  531,
-      610,  293,  293,  293,  293,  293,  293,  293,  293,  293,
-      293,  293,  293,  291,  291,  291,  291,  291,  291,  291,
-      291,  291,  291,  291,  292,  291,  179,  179,  179,  179,
-      179,  179,  179,  179,  179,  179,  179,  179,   85,  249,
-
-      147,  498,  674,  149,  540,  365,  294,  294,  294,  294,
-      150,  674,  251,  499,  295,  295,  295,  295,  295,  295,
-      295,  295,  295,  295,  295,  295,  295,  295,  295,  295,
-      295,  295,  295,  521,  521,  521,  149,  149,  149,  149,
-      296,  149,  149,  149,  149,  149,  149,  149,  149,  149,
-      149,  149,  149,  149,  149,  149,  149,  149,  149,  149,
-      149,  214,  214,  214,  214,  214,  214,  214,  214,  214,
-      214,  203,  258,  204,  418,  602,  522,  511,  205,  601,
-      106,  258,  600,  215,  215,  215,  215,  215,  215,  215,
-      215,  215,  215,  215,  215,  324,  324,  324,  324,  324,
-
-      324,  324,  324,  324,  324,  482,  512,  596,  106,  211,
-      211,  542,  542,  542,  542,  513,  106,  308,  308,  308,
-      308,  308,  308,  308,  308,  308,  308,  308,  308,   85,
-      328,  512,   85,  329,  330,  670,  419,   85,   85,   85,
-       85,  331,  612,  332,  150,  333,  333,  333,  333,  333,
-      333,  333,  333,  333,  333,  333,  333,  333,  333,  333,
-      333,  333,  333,  334,  612,  603,  618,  335,  335,  335,
-      335,  335,  335,  335,  335,  335,  335,  335,  335,   85,
-       85,   85,   85,   85,   85,   85,   85,   85,   85,   85,
-      330,   85,  126,  236,  236,  236,  237,   85,  126,  126,
-
-      126,  126,  126,  126,   85,  266,  126,  126,  548,  150,
-      370,  691,  126,  126,  328,  126,  150,  691,  691,  364,
-       85,  450,  365,  509,  451,   85,  596,  691,   85,   85,
-       85,   85,  366,  145,  452,  126,  130,  595,  691,  593,
-      691,  691,   91,   85,  106,  329,   85,  459,  459,  459,
-      459,  691,  460,  594,   93,  150,  461,  405,  150,   95,
-      455,  506,  577,  126,  126,  249,  462,  691,  101,  216,
-      216,  106,  592,  103,  266,  506,  506,  613,  251,  691,
-      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
-      252,  252,  252,  252,  252,  252,  252,  252,  252,  614,
-
-      545,  632,  620,  147,  612,  106,  253,  358,  358,  358,
-      358,  358,  358,  358,  358,  358,  358,  358,  358,  364,
-      145,   85,  365,  617,  621,  106,  612,  248,  248,  359,
-      359,  539,  366,  150,  367,  367,  367,  367,  367,  367,
-      367,  367,  367,  367,  367,  367,  367,  367,  367,  367,
-      367,  367,  367,  645,   85,   85,   85,  506,  591,  585,
-      368,   85,  469,  469,  469,  469,  150,  150,  150,  470,
-      436,  506,  506,  150,  660,   85,   85,  274,  274,  274,
-      274,  274,  274,  274,  274,  274,  274,  150,  150,  584,
-      147,  612,  583,  559,  654,  640,  612,  476,  477,  275,
-
-      275,  275,  275,  275,  275,  275,  275,  275,  275,  275,
-      275,   85,  328,  612,  582,  329,  387,  582,  612,  149,
-      149,  149,  149,  388,  471,  332,  472,  389,  389,  389,
-      389,  389,  389,  389,  389,  389,  389,  389,  389,  389,
-      389,  389,  389,  389,  389,  390,  581,  580,  579,  391,
-      391,  391,  391,  391,  391,  391,  391,  391,  391,  391,
-      391,  149,  149,  149,  149,  149,  149,  149,  149,  149,
-      149,  149,  387,  149,   85,  249,  145,   85,  674,  365,
-      578,  551,  551,  521,  521,  521,  150,  571,  251,  150,
-      295,  295,  295,  295,  295,  295,  295,  295,  295,  295,
-
-      295,  295,  295,  295,  295,  295,  295,  295,  295,   85,
-      423,  577,  576,  424,  575,  691,  296,   85,  691,   85,
-      574,  150,   85,  425,   85,  456,  522,  106,  691,  150,
-       85,  150,  473,   85,  150,  424,  150,  145,  402,  402,
-      402,  402,  150,  573,  501,  150,  147,  572,  689,  525,
-      380,  612,  563,  562,  474,  401,  401,  401,  401,  401,
-      401,  401,  401,  401,  401,  401,  401,  364,  475,   85,
-      365,  106,  479,  612,  266,  645,  260,  365,  451,  641,
-      366,  150,  403,  403,  403,  403,  403,  403,  403,  403,
-      403,  403,  403,  403,  403,  403,  403,  403,  403,  403,
-
-      403,  423,  450,  691,  691,  451,  691,  526,  404,  328,
-      145,  536,  329,  331,  691,  452,  691,  619,  560,  557,
-      331,  590,  332,  666,  411,  411,  411,  411,  411,  411,
-      411,  411,  411,  411,  411,  411,  411,  411,  411,  411,
-      411,  411,  412,  612,  612,  651,  413,  413,  413,  413,
-      413,  413,  413,  413,  413,  413,  413,  413,  556,  652,
-      555,  450,  554,  654,  691,  612,  612,   85,  450,  331,
-      328,  451,  149,  329,  691,  149,  149,  149,  149,  150,
-      147,  452,  553,  332,  552,  333,  333,  333,  333,  333,
-      333,  333,  333,  333,  333,  333,  333,  333,  333,  333,
-
-      333,  333,  333,  333,  423,  551,   85,  424,  451,  139,
-      549,  547,  546,  501,  545,  544,  497,  425,  150,  426,
-      426,  426,  426,  426,  426,  426,  426,  426,  426,  426,
-      426,  426,  426,  426,  426,  426,  426,  426,  335,  335,
-      335,  335,  335,  335,  335,  335,  335,  335,  335,  335,
-      149,  113,   85,  436,   85,   85,   85,  150,   85,   85,
-       85,  501,  500,  497,  150,  501,  150,  150,  150,   85,
-      150,  150,  150,  495,  535,  502,  495,  493,  534,  389,
-      493,  150,  491,  149,  149,  149,  149,  149,  149,  149,
-      149,  149,  149,  149,  149,  113,  691,  491,  489,  691,
-
-       85,  500,  534,   85,  691,  538,  149,  423,  489,  691,
-      424,  537,  150,  487,  691,  150,  487,  424,  528,  527,
-      425,  207,  468,  468,  468,  468,  468,  468,  468,  468,
-      468,  468,  468,  468,  468,  468,  468,  468,  468,  468,
-      468,  391,  391,  391,  391,  391,  391,  391,  391,  391,
-      391,  391,  391,  500,  145,   85,  501,  201,  369,  567,
-      524,  365,  451,  448,  113,  609,  502,  150,  503,  503,
-      503,  503,  503,  503,  503,  503,  503,  503,  503,  503,
-      503,  503,  503,  503,  503,  503,  503,  500,  519,   85,
-      501,  518,  517,  183,  516,  436,  113,  509,  508,  507,
-
-      502,  150,  533,  533,  533,  533,  533,  533,  533,  533,
-      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
-      533,  145,   85,  505,  147,  504,  145,   85,  380,  424,
-      421,  568,   85,  497,  150,  561,  561,  561,  561,  150,
-      561,  561,  561,  561,  150,  569,   85,   85,   85,   85,
-       85,  625,  495,  566,  380,  145,  634,  612,  150,  150,
-      150,  150,  150,  588,  145,  570,  622,  493,  491,  145,
-      145,  489,  380,  626,  145,  637,  145,  487,  634,  612,
-      650,  663,  634,  329,  329,  668,  674,  671,  569,  481,
-      674,  147,  608,  329,  263,  380,  526,  675,  667,  380,
-
-      634,  676,  588,  380,  634,  589,  597,  597,  464,  597,
-      597,  597,  597,  597,  380,  597,  597,  597,  597,  380,
-      597,  597,  634,  634,  380,  147,  597,  597,  597,  597,
-      463,  634,   87,  202,  147,  661,  599,  674,  458,  147,
-      147,  647,  634,  667,  147,  634,  147,  634,  677,  597,
-      597,  597,  634,  634,  365,  674,  258,  674,  599,  364,
-      258,  369,  674,  648,  634,  674,  678,  241,  679,  634,
-      662,  448,  443,  680,  634,  442,  681,  597,  597,  597,
-      597,  441,  597,  597,  597,  597,  597,  598,  597,  597,
-      597,  597,  202,  597,  597,  674,  435,  434,  433,  606,
-
-      597,  597,  597,  432,  431,  430,  682,  258,  674,  607,
-      674,  429,  428,  329,  329,  674,  207,  674,  674,  683,
-      207,  684,  597,  597,  597,  258,  685,  258,  686,  687,
-      674,  607,  258,  202,  201,  258,  201,  201,  307,  307,
-      305,  688,  305,  408,  241,  263,  263,  263,  262,  380,
-      597,  597,  597,  597,  262,  597,  597,  597,  597,  597,
-      351,  597,  597,  597,  597,  258,  597,  597,  372,  343,
-      342,  369,  597,  597,  597,  597,  249,  241,  258,  241,
-      258,  240,  599,  350,  349,  258,  348,  258,  258,  347,
-      344,  340,  339,  338,  337,  597,  597,  597,  336,  318,
-
-      258,  318,  317,  316,  599,  315,  314,  314,  313,  312,
-      311,  310,  307,  305,  302,  263,  287,  285,  284,  283,
-      280,  279,  263,  597,  597,  597,  597,  263,  597,  597,
-      597,  597,  597,  598,  597,  597,  597,  597,  262,  597,
-      597,  260,  258,  257,  232,  606,  597,  597,  597,  202,
-      256,  230,  130,  234,  233,  607,  232,  202,  231,  230,
-      229,  229,  228,  227,  226,  106,  207,  206,  597,  597,
-      597,  201,  202,  201,  193,  189,  165,  607,  164,  148,
-      116,  115,  106,   87,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  597,  597,   85,  691,
-
-      691,   85,  691,  691,   85,  691,   85,   85,   85,   85,
-       85,   85,   85,   90,   90,  691,  691,  691,  691,   90,
-       90,  104,  104,  104,  691,  104,  104,  104,  104,  104,
-      104,  104,  104,  104,  104,  104,  104,  104,  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,  144,  144,  144,  144,  144,  144,
-      144,  144,  144,  144,  144,  144,  144,  144,  144,  144,
-      144,  144,  149,  691,  691,  149,  691,  691,  149,  149,
-
-      149,  149,  149,  149,  149,  149,  149,  157,  157,  157,
-      691,  157,  157,  157,  157,  157,  157,  157,  157,  157,
-      157,  157,  157,  157,   98,   98,  691,  691,   98,  691,
-      691,  691,  691,  691,   98,   98,   98,   98,  691,   98,
-      126,  126,  126,  126,  126,  126,  126,  126,  126,  126,
-      126,  126,  126,  126,  126,  126,  126,  126,  238,  238,
-      238,  238,  238,  238,  238,  238,  238,  238,  238,  238,
-      238,  238,  238,  238,  238,  238,  145,  145,  145,  145,
-      145,  145,  145,  145,  145,  145,  145,  145,  145,  145,
-      145,  145,  145,  145,  261,  261,  261,  261,  261,  261,
-
-      261,  261,  261,  261,  261,  261,  261,  261,  261,  261,
-      261,  261,  157,  157,  157,  691,  157,  157,  157,  691,
-      157,  157,  157,  157,  157,  157,  157,  157,  157,  268,
-      268,  268,  268,  268,  268,  268,  268,  268,  268,  268,
-      268,  268,  268,  268,  268,  268,  268,  304,  304,  691,
-      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
-      304,  304,  304,  304,  304,  306,  306,  691,  306,  306,
-      306,  306,  306,  306,  306,  306,  306,  306,  306,  306,
-      306,  306,  306,  308,  691,  691,  691,  308,  691,  308,
-      308,  308,  691,  691,  308,  352,  352,  352,  352,  352,
-
-      352,  352,  352,  352,  352,  352,  352,  352,  352,  352,
-      352,  352,  352,  126,  126,  126,  126,  126,  126,  126,
-      126,  126,  126,  126,  126,  126,  126,  126,  126,  126,
-      126,  354,  354,  354,  354,  354,  354,  354,  354,  354,
-      354,  354,  354,  354,  354,  354,  354,  354,  354,  238,
-      238,  238,  238,  238,  238,  238,  238,  238,  238,  238,
-      238,  238,  238,  238,  238,  238,  238,  357,  357,  357,
-      357,  357,  357,  357,  362,  691,  691,  691,  691,  362,
-      691,  362,  362,  691,  362,  261,  261,  261,  261,  261,
-      261,  261,  261,  261,  261,  261,  261,  261,  261,  261,
-
-      261,  261,  261,  379,  379,  379,  379,  379,  379,  379,
-      379,  379,  379,  379,  379,  379,  379,  379,  379,  379,
-      379,  268,  268,  268,  268,  268,  268,  268,  268,  268,
-      268,  268,  268,  268,  268,  268,  268,  268,  268,  105,
-      105,  105,  105,  105,  105,  105,  105,  105,  105,  105,
-      105,  105,  105,  105,  105,  105,  105,  304,  304,  691,
-      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
-      304,  304,  304,  304,  304,  306,  306,  691,  306,  306,
-      306,  306,  306,  306,  306,  306,  306,  306,  306,  306,
-      306,  306,  306,  413,  691,  691,  691,  413,  691,  413,
-
-      413,  413,  691,  691,  413,  411,  411,  691,  691,  691,
-      691,  691,  411,  411,  352,  352,  352,  352,  352,  352,
-      352,  352,  352,  352,  352,  352,  352,  352,  352,  352,
-      352,  352,  354,  354,  354,  354,  354,  354,  354,  354,
-      354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
-      126,  126,  126,  126,  126,  126,  126,  126,  126,  126,
-      126,  126,  126,  126,  126,  126,  126,  126,  447,  447,
-      447,  447,  447,  447,  447,  447,  447,  447,  447,  447,
-      447,  447,  447,  447,  447,  447,  453,  453,  453,  453,
-      691,  691,  453,  691,  453,  453,  453,  453,  453,  453,
-
-      453,  454,  454,  691,  691,  691,  691,  691,  454,  454,
-      691,  454,  379,  379,  379,  379,  379,  379,  379,  379,
-      379,  379,  379,  379,  379,  379,  379,  379,  379,  379,
-      105,  105,  105,  105,  105,  105,  105,  105,  105,  105,
-      105,  105,  105,  105,  105,  105,  105,  105,  478,  478,
-      478,  478,  691,  691,  478,  478,  478,  478,  478,  478,
-      478,  478,  478,  484,  484,  691,  691,  691,  691,  691,
-      484,  484,  486,  486,  691,  486,  486,  486,  486,  486,
-      486,  486,  486,  486,  486,  486,  486,  486,  486,  486,
-      488,  488,  691,  488,  488,  488,  488,  488,  488,  488,
-
-      488,  488,  488,  488,  488,  488,  488,  488,  490,  490,
-      691,  490,  490,  490,  490,  490,  490,  490,  490,  490,
-      490,  490,  490,  490,  490,  490,  492,  492,  691,  492,
-      492,  492,  492,  492,  492,  492,  492,  492,  492,  492,
-      492,  492,  492,  492,  494,  494,  691,  494,  494,  494,
-      494,  494,  494,  494,  494,  494,  494,  494,  494,  494,
-      494,  494,  496,  496,  691,  496,  496,  496,  496,  496,
-      496,  496,  496,  496,  496,  496,  496,  496,  496,  496,
-      523,  523,  691,  691,  691,  691,  691,  523,  523,  523,
-      523,  523,  523,  523,  529,  529,  529,  529,  529,  529,
-
-      529,  529,  529,  529,  529,  529,  529,  529,  529,  529,
-      529,  529,  543,  543,  691,  691,  691,  691,  691,  543,
-      543,  550,  550,  691,  550,  550,  550,  550,  550,  550,
-      550,  550,  550,  550,  550,  550,  550,  550,  550,  598,
-      598,  691,  598,  598,  598,  598,  598,  598,  598,  598,
-      598,  598,  598,  598,  598,  598,  598,  605,  605,  691,
-      605,  605,  605,  605,  605,  605,  605,  605,  605,  605,
-      605,  605,  605,  605,  605,  597,  597,  691,  597,  597,
-      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
-      597,  597,  597,  633,  633,  633,  633,  633,  633,  633,
-
-      633,  633,  633,  633,  633,  633,  633,  633,  633,  633,
-      633,  655,  655,  655,  655,  655,  655,  655,  655,  655,
-      655,  655,  655,  655,  655,  655,  655,  655,  655,  658,
-      658,  658,  658,  658,  658,  658,  658,  658,  658,  658,
-      658,  658,  658,  658,  658,  658,  658,  673,  673,  673,
-      673,  673,  673,  673,  673,  673,  673,  673,  673,  673,
-      673,  673,  673,  673,  673,    3,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691
-    } ;
-
-static yyconst flex_int16_t yy_chk[3940] =
-    {   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,    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,    8,    8,    8,   11,   11,   12,   17,   20,
-       22,   22,   22,   22,   52,   52,  237,   12,    5,   12,
-       12,   29,   41,  382,   12,   13,   13,   13,   21,   21,
-       21,   21,   13,   20,   41,   43,   13,   13,   13,   13,
-       13,   13,   13,   13,   13,   23,  689,   43,   23,   23,
-
-       23,   23,   24,   24,   24,   24,  237,   30,   21,   30,
-       30,   48,   17,   54,   30,   26,   29,  382,   23,   25,
-       25,   25,   25,   48,   43,   29,   36,   36,   26,   26,
-       26,   26,   13,   36,   36,   36,   24,   87,   13,   13,
-       13,   13,   13,   13,   13,   14,   14,   14,   92,   92,
-       32,   32,   14,   32,   32,   32,   14,   14,   14,   14,
-       14,   14,   14,   14,   14,   26,  128,   54,   25,   31,
-       31,   31,   31,   31,   33,   33,   34,   57,   33,   33,
-       33,  158,  158,   35,   35,  156,   31,   34,   34,   35,
-       35,   35,   34,   34,   34,   37,   37,  128,  156,   87,
-
-       34,   57,   14,   37,   37,   37,   40,  669,   14,   14,
-       14,   14,   14,   14,   14,   16,  235,   16,   40,   16,
-       16,   16,   16,   16,   16,   38,   38,   16,   39,   39,
-       59,   59,   59,   59,   38,   38,   38,   44,   39,   39,
-      665,   40,   58,   58,   58,   58,   16,  235,  664,   44,
-       16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
-       16,   16,  144,   71,   71,   61,   61,   61,   61,   71,
-       71,   71,   58,   16,   27,   27,   27,   27,   27,   27,
-       27,   27,   27,   27,   27,   27,   27,   27,   27,   27,
-       42,   44,   42,   45,   27,   27,   27,   27,   49,   61,
-
-      262,   45,   42,   49,   96,   96,   96,   46,   49,  262,
-       49,   49,   65,   45,  101,   49,  101,   27,   27,   27,
-       63,   46,   46,   46,   46,   60,  658,  253,   60,   60,
-       60,   60,  144,   63,   63,   63,   63,   68,   68,   42,
-       68,   68,   68,   45,  149,   27,   27,   28,   60,   28,
-       28,   28,   28,   28,   28,  657,  149,   65,   62,   62,
-       62,   62,   66,  157,   66,   66,   65,   69,   69,   66,
-       63,   69,   69,   69,  253,  157,   28,   46,  268,  268,
-       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
-       28,   28,   67,   67,   67,   67,   67,   84,   84,   84,
-
-       84,  655,  152,   28,   50,   50,   50,   62,  409,   67,
-      152,   50,  409,   70,  152,   50,   50,   50,   50,   50,
-       50,   50,   50,   50,   70,   70,   72,   72,  653,   70,
-       70,   70,  171,   72,   72,   72,  651,   70,   73,   73,
-       74,   74,   75,   75,  171,  153,   73,   73,   73,   74,
-       74,   74,   75,   75,   86,   86,   86,   86,   86,  153,
-      171,   50,  100,  100,  100,  645,  167,   50,   50,   50,
-       50,   50,   50,   50,   51,   51,   51,   91,  167,   91,
-      316,   51,  316,  314,   91,   51,   51,   51,   51,   51,
-       51,   51,   51,   51,   76,   77,   78,   76,   77,   78,
-
-      266,   78,  119,  119,  119,  119,   76,   77,   78,   76,
-       77,   78,  266,   80,  166,   79,   80,  225,   79,  136,
-      136,  136,  136,  225,  167,   80,  166,   79,   80,  644,
-       79,   51,   76,  137,  137,  137,  137,   51,   51,   51,
-       51,   51,   51,   51,   53,  314,  166,   53,   78,   53,
-       82,   53,   53,   53,   53,   53,   53,   79,  643,   53,
-      151,   82,  344,  137,   82,   82,   82,   82,  151,  151,
-       80,  639,  151,  138,  138,  138,  138,  380,   53,  380,
-      320,  146,   53,   53,   53,   53,   53,   53,   53,   53,
-       53,   53,   53,   53,  320,  146,  146,  146,  146,  146,
-
-      168,  168,  168,  168,  318,   53,   64,  138,   64,   64,
-       64,   64,   64,   64,   81,  154,  165,  173,  344,   81,
-       82,  183,   81,  154,  184,  185,  186,  154,  165,  173,
-      270,   81,  352,  183,   81,   64,  184,  185,  186,   64,
-       64,   64,   64,   64,   64,   64,   64,   64,   64,   64,
-       64,  146,  636,  353,  165,  173,  190,  190,  190,  190,
-      444,  345,   64,  352,   81,   90,  318,   90,   90,   90,
-       90,   90,   90,   97,   97,   97,  184,  185,  183,  188,
-      270,  194,  186,  345,  353,   97,  481,   97,  194,  270,
-      188,  444,   97,  635,   90,  481,  229,  630,   90,   90,
-
-       90,   90,   90,   90,   90,   90,   90,   90,   90,   90,
-      194,  209,  209,  209,  209,  210,  210,  210,  210,  229,
-      629,   90,  108,  108,  108,  108,  108,  108,  108,  108,
-      108,  108,  108,  108,  110,  264,  291,  194,  291,  110,
-      264,  229,  110,  110,  110,  110,  110,  264,  291,  188,
-      110,  110,  110,  110,  110,  110,  110,  110,  110,  110,
-      110,  110,  110,  110,  110,  110,  110,  110,  110,  355,
-      355,  355,  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,  187,
-
-      112,  112,  112,  112,  112,  181,  180,  180,  180,  180,
-      180,  187,  355,  181,  181,  181,  181,  181,  195,  383,
-      532,  195,  195,  195,  195,  195,  112,  564,  564,  354,
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112,
-      112,  112,  208,  181,  346,  187,  385,  195,  211,  211,
-      211,  211,  208,  112,  113,  281,  113,  260,  385,  208,
-      113,  113,  260,  260,  301,  113,  346,  281,  113,  354,
-      628,  182,  532,  627,  195,  301,  113,  383,  113,  182,
-      182,  182,  182,  182,  113,  113,  214,  214,  214,  214,
-      113,  215,  215,  215,  215,  113,  127,  127,  127,  127,
-
-      127,  127,  127,  127,  127,  127,  127,  127,  127,  127,
-      127,  127,  624,  182,  363,  281,  127,  127,  127,  127,
-      216,  216,  216,  216,  217,  217,  217,  217,  217,  217,
-      217,  217,  217,  217,  301,  219,  285,  467,  435,  127,
-      127,  127,  219,  438,  234,  234,  234,  234,  285,  226,
-      226,  226,  226,  227,  227,  227,  227,  236,  236,  236,
-      236,  363,  435,  368,  219,  438,  623,  127,  127,  129,
-      129,  129,  129,  129,  300,  129,  129,  129,  129,  129,
-      129,  226,  285,  129,  129,  227,  300,  259,  247,  129,
-      129,  219,  129,  234,  247,  247,  247,  247,  248,  467,
-
-      236,  259,  259,  259,  259,  248,  248,  248,  248,  265,
-      368,  248,  129,  129,  265,  249,  267,  295,  283,  295,
-      286,  267,  249,  249,  249,  249,  265,  621,  249,  295,
-      283,  300,  286,  267,  303,  303,  303,  303,  620,  248,
-      129,  129,  131,  131,  131,  131,  131,  131,  131,  131,
-      131,  131,  131,  131,  132,  132,  249,  259,  132,  132,
-      283,  616,  132,  132,  132,  132,  132,  615,  132,  286,
-      132,  132,  132,  132,  132,  132,  132,  132,  132,  132,
-      132,  132,  132,  132,  132,  132,  132,  132,  132,  465,
-      465,  465,  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,
-      308,  308,  308,  308,  632,  632,  135,  135,  135,  135,
-      614,  579,  135,  613,  135,  135,  135,  135,  135,  135,
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
-      135,  135,  135,  284,  297,  298,  579,  396,  284,  299,
-      135,  155,  155,  155,  299,  284,  297,  298,  155,  396,
-      405,  299,  155,  155,  155,  271,  155,  155,  155,  155,
-      155,  274,  405,  271,  271,  271,  271,  271,  275,  274,
-
-      274,  274,  274,  274,  297,  298,  275,  275,  275,  275,
-      275,  276,  276,  276,  276,  276,  276,  276,  276,  276,
-      276,  279,  324,  324,  324,  324,  701,  701,  155,  279,
-      279,  279,  279,  279,  155,  155,  155,  155,  155,  155,
-      155,  159,  323,  335,  335,  335,  335,  611,  287,  323,
-      282,  617,  610,  159,  280,  282,  287,  287,  287,  287,
-      287,  279,  280,  280,  280,  280,  280,  282,  530,  530,
-      530,  323,  602,  282,  358,  358,  358,  358,  518,  159,
-      159,  159,  159,  159,  159,  159,  159,  159,  159,  159,
-      159,  160,  518,  319,  280,  282,  160,  319,  323,  160,
-
-      160,  160,  160,  160,  319,  287,  617,  160,  160,  160,
-      160,  160,  160,  160,  160,  160,  160,  160,  160,  160,
-      160,  160,  160,  160,  160,  160,  445,  445,  445,  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,  319,  407,  162,  162,  162,
-      162,  162,  293,  327,  293,  328,  327,  407,  328,  445,
-      293,  293,  293,  293,  293,  565,  327,  531,  328,  359,
-      359,  359,  359,  162,  587,  601,  596,  162,  162,  162,
-      162,  162,  162,  162,  162,  162,  162,  162,  162,  413,
-
-      413,  413,  413,  466,  483,  483,  483,  483,  596,  595,
-      162,  175,  175,  175,  175,  175,  175,  175,  175,  175,
-      175,  175,  175,  176,  176,  531,  407,  176,  176,  593,
-      671,  176,  176,  176,  176,  176,  587,  176,  565,  176,
-      176,  176,  176,  176,  176,  176,  176,  176,  176,  176,
-      176,  176,  176,  176,  176,  176,  176,  176,  455,  466,
-      592,  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,
-
-      671,  421,  672,  179,  591,  455,  179,  179,  179,  179,
-      179,  673,  179,  421,  179,  179,  179,  179,  179,  179,
-      179,  179,  179,  179,  179,  179,  179,  179,  179,  179,
-      179,  179,  179,  448,  448,  448,  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,  212,  212,  212,  212,  212,  212,  212,  212,  212,
-      212,  461,  672,  461,  574,  585,  448,  436,  461,  584,
-      666,  673,  583,  212,  212,  212,  212,  212,  212,  212,
-      212,  212,  212,  212,  212,  213,  213,  213,  213,  213,
-
-      213,  213,  213,  213,  213,  542,  436,  581,  604,  702,
-      702,  542,  542,  542,  542,  436,  586,  213,  213,  213,
-      213,  213,  213,  213,  213,  213,  213,  213,  213,  218,
-      218,  436,  479,  218,  218,  666,  574,  218,  218,  218,
-      218,  218,  597,  218,  479,  218,  218,  218,  218,  218,
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
-      218,  218,  218,  218,  597,  586,  604,  218,  218,  218,
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
-      218,  218,  238,  238,  238,  238,  238,  381,  238,  238,
-
-      238,  238,  238,  238,  296,  381,  238,  238,  507,  381,
-      296,  331,  238,  238,  332,  238,  296,  332,  331,  361,
-      360,  360,  361,  507,  360,  360,  580,  332,  360,  360,
-      360,  360,  361,  373,  360,  238,  238,  578,  364,  577,
-      331,  364,  375,  389,  618,  389,  397,  373,  373,  373,
-      373,  364,  375,  577,  375,  389,  376,  296,  397,  375,
-      361,  430,  576,  238,  238,  239,  376,  331,  376,  703,
-      703,  603,  575,  376,  397,  430,  430,  599,  239,  364,
-      239,  239,  239,  239,  239,  239,  239,  239,  239,  239,
-      239,  239,  239,  239,  239,  239,  239,  239,  239,  599,
-
-      573,  618,  607,  373,  654,  631,  239,  242,  242,  242,
-      242,  242,  242,  242,  242,  242,  242,  242,  242,  250,
-      480,  392,  250,  603,  607,  646,  654,  706,  706,  719,
-      719,  480,  250,  392,  250,  250,  250,  250,  250,  250,
-      250,  250,  250,  250,  250,  250,  250,  250,  250,  250,
-      250,  250,  250,  631,  391,  399,  400,  506,  572,  563,
-      250,  272,  391,  391,  391,  391,  391,  399,  400,  392,
-      394,  506,  506,  272,  646,  394,  393,  272,  272,  272,
-      272,  272,  272,  272,  272,  272,  272,  394,  393,  562,
-      480,  625,  560,  558,  640,  625,  640,  399,  400,  272,
-
-      272,  272,  272,  272,  272,  272,  272,  272,  272,  272,
-      272,  277,  277,  625,  557,  277,  277,  556,  640,  277,
-      277,  277,  277,  277,  393,  277,  394,  277,  277,  277,
-      277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
-      277,  277,  277,  277,  277,  277,  555,  554,  553,  277,
-      277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
-      277,  277,  277,  277,  277,  277,  277,  277,  277,  277,
-      277,  277,  277,  277,  288,  288,  539,  403,  688,  403,
-      552,  551,  550,  521,  521,  521,  288,  539,  288,  403,
-      288,  288,  288,  288,  288,  288,  288,  288,  288,  288,
-
-      288,  288,  288,  288,  288,  288,  288,  288,  288,  395,
-      410,  549,  547,  410,  546,  423,  288,  289,  423,  404,
-      545,  395,  406,  410,  398,  404,  521,  670,  423,  289,
-      401,  404,  395,  468,  406,  468,  398,  459,  401,  401,
-      401,  401,  401,  544,  543,  468,  539,  541,  688,  459,
-      529,  626,  528,  527,  395,  289,  289,  289,  289,  289,
-      289,  289,  289,  289,  289,  289,  289,  294,  398,  474,
-      294,  660,  404,  626,  406,  670,  526,  524,  523,  626,
-      294,  474,  294,  294,  294,  294,  294,  294,  294,  294,
-      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
-
-      294,  425,  449,  450,  425,  449,  450,  459,  294,  309,
-      571,  474,  309,  309,  425,  449,  450,  606,  519,  517,
-      309,  571,  309,  660,  309,  309,  309,  309,  309,  309,
-      309,  309,  309,  309,  309,  309,  309,  309,  309,  309,
-      309,  309,  309,  641,  606,  638,  309,  309,  309,  309,
-      309,  309,  309,  309,  309,  309,  309,  309,  516,  638,
-      515,  452,  514,  641,  452,  641,  606,  402,  402,  309,
-      322,  402,  402,  322,  452,  402,  402,  402,  402,  402,
-      571,  402,  513,  322,  512,  322,  322,  322,  322,  322,
-      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
-      322,  322,  322,  322,  326,  511,  478,  326,  478,  510,
-      508,  505,  504,  503,  499,  498,  497,  326,  478,  326,
-      326,  326,  326,  326,  326,  326,  326,  326,  326,  326,
-      326,  326,  326,  326,  326,  326,  326,  326,  330,  330,
-      330,  330,  330,  330,  330,  330,  330,  330,  330,  330,
-      384,  470,  471,  472,  473,  476,  470,  384,  472,  533,
-      475,  533,  485,  496,  471,  485,  473,  476,  470,  569,
-      472,  533,  475,  495,  473,  485,  494,  493,  471,  384,
-      492,  569,  491,  384,  384,  384,  384,  384,  384,  384,
-      384,  384,  384,  384,  384,  477,  500,  490,  489,  500,
-
-      477,  502,  471,  536,  502,  476,  384,  386,  488,  500,
-      386,  475,  477,  487,  502,  536,  486,  484,  464,  463,
-      386,  462,  386,  386,  386,  386,  386,  386,  386,  386,
-      386,  386,  386,  386,  386,  386,  386,  386,  386,  386,
-      386,  387,  387,  387,  387,  387,  387,  387,  387,  387,
-      387,  387,  387,  427,  590,  534,  427,  460,  458,  536,
-      456,  454,  453,  447,  443,  590,  427,  534,  427,  427,
-      427,  427,  427,  427,  427,  427,  427,  427,  427,  427,
-      427,  427,  427,  427,  427,  427,  427,  469,  442,  537,
-      469,  441,  440,  534,  439,  437,  434,  433,  432,  431,
-
-      469,  537,  469,  469,  469,  469,  469,  469,  469,  469,
-      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
-      469,  525,  535,  429,  590,  428,  561,  538,  619,  426,
-      420,  537,  566,  419,  535,  525,  525,  525,  525,  538,
-      561,  561,  561,  561,  566,  537,  567,  568,  570,  608,
-      589,  612,  418,  535,  633,  609,  619,  612,  567,  568,
-      570,  608,  589,  566,  622,  538,  609,  417,  416,  637,
-      650,  415,  661,  612,  663,  622,  668,  414,  619,  612,
-      637,  650,  633,  412,  411,  663,  674,  668,  568,  408,
-      675,  525,  589,  390,  388,  662,  561,  674,  661,  379,
-
-      661,  675,  567,  647,  633,  570,  582,  582,  378,  582,
-      582,  582,  582,  582,  648,  582,  582,  582,  582,  634,
-      582,  582,  661,  662,  667,  609,  582,  582,  582,  582,
-      377,  647,  374,  372,  622,  647,  582,  676,  370,  637,
-      650,  634,  648,  662,  663,  662,  668,  634,  676,  582,
-      582,  582,  667,  647,  367,  677,  674,  678,  582,  366,
-      675,  362,  679,  634,  648,  680,  677,  357,  678,  634,
-      648,  356,  351,  679,  667,  350,  680,  582,  582,  588,
-      588,  349,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  348,  588,  588,  681,  343,  342,  341,  588,
-
-      588,  588,  588,  340,  339,  338,  681,  676,  682,  588,
-      683,  337,  336,  334,  333,  684,  317,  685,  686,  682,
-      315,  683,  588,  588,  588,  677,  684,  678,  685,  686,
-      687,  588,  679,  313,  312,  680,  311,  310,  307,  306,
-      305,  687,  304,  302,  292,  290,  278,  273,  269,  263,
-      588,  588,  598,  598,  261,  598,  598,  598,  598,  598,
-      257,  598,  598,  598,  598,  681,  598,  598,  256,  255,
-      254,  252,  598,  598,  598,  598,  251,  246,  682,  245,
-      683,  244,  598,  233,  232,  684,  231,  685,  686,  230,
-      228,  224,  223,  222,  221,  598,  598,  598,  220,  207,
-
-      687,  206,  205,  204,  598,  203,  201,  200,  199,  198,
-      197,  196,  192,  191,  189,  177,  174,  172,  170,  169,
-      164,  163,  161,  598,  598,  605,  605,  150,  605,  605,
-      605,  605,  605,  605,  605,  605,  605,  605,  148,  605,
-      605,  147,  145,  143,  142,  605,  605,  605,  605,  141,
-      140,  139,  126,  125,  124,  605,  123,  122,  121,  120,
-      118,  117,  116,  115,  114,  105,  103,   99,  605,  605,
-      605,   95,   94,   93,   89,   83,   56,  605,   55,   47,
-       19,   18,   15,   10,    3,    0,    0,    0,    0,    0,
-        0,    0,    0,    0,    0,    0,  605,  605,  692,    0,
-
-        0,  692,    0,    0,  692,    0,  692,  692,  692,  692,
-      692,  692,  692,  693,  693,    0,    0,    0,    0,  693,
-      693,  694,  694,  694,    0,  694,  694,  694,  694,  694,
-      694,  694,  694,  694,  694,  694,  694,  694,  695,  695,
-      695,  695,  695,  695,  695,  695,  695,  695,  695,  695,
-      695,  695,  695,  695,  695,  695,  696,  696,  696,  696,
-      696,  696,  696,  696,  696,  696,  696,  696,  696,  696,
-      696,  696,  696,  696,  697,  697,  697,  697,  697,  697,
-      697,  697,  697,  697,  697,  697,  697,  697,  697,  697,
-      697,  697,  698,    0,    0,  698,    0,    0,  698,  698,
-
-      698,  698,  698,  698,  698,  698,  698,  699,  699,  699,
-        0,  699,  699,  699,  699,  699,  699,  699,  699,  699,
-      699,  699,  699,  699,  700,  700,    0,    0,  700,    0,
-        0,    0,    0,    0,  700,  700,  700,  700,    0,  700,
-      704,  704,  704,  704,  704,  704,  704,  704,  704,  704,
-      704,  704,  704,  704,  704,  704,  704,  704,  705,  705,
-      705,  705,  705,  705,  705,  705,  705,  705,  705,  705,
-      705,  705,  705,  705,  705,  705,  707,  707,  707,  707,
-      707,  707,  707,  707,  707,  707,  707,  707,  707,  707,
-      707,  707,  707,  707,  708,  708,  708,  708,  708,  708,
-
-      708,  708,  708,  708,  708,  708,  708,  708,  708,  708,
-      708,  708,  709,  709,  709,    0,  709,  709,  709,    0,
-      709,  709,  709,  709,  709,  709,  709,  709,  709,  710,
-      710,  710,  710,  710,  710,  710,  710,  710,  710,  710,
-      710,  710,  710,  710,  710,  710,  710,  711,  711,    0,
-      711,  711,  711,  711,  711,  711,  711,  711,  711,  711,
-      711,  711,  711,  711,  711,  712,  712,    0,  712,  712,
-      712,  712,  712,  712,  712,  712,  712,  712,  712,  712,
-      712,  712,  712,  713,    0,    0,    0,  713,    0,  713,
-      713,  713,    0,    0,  713,  714,  714,  714,  714,  714,
-
-      714,  714,  714,  714,  714,  714,  714,  714,  714,  714,
-      714,  714,  714,  715,  715,  715,  715,  715,  715,  715,
-      715,  715,  715,  715,  715,  715,  715,  715,  715,  715,
-      715,  716,  716,  716,  716,  716,  716,  716,  716,  716,
-      716,  716,  716,  716,  716,  716,  716,  716,  716,  717,
-      717,  717,  717,  717,  717,  717,  717,  717,  717,  717,
-      717,  717,  717,  717,  717,  717,  717,  718,  718,  718,
-      718,  718,  718,  718,  720,    0,    0,    0,    0,  720,
-        0,  720,  720,    0,  720,  721,  721,  721,  721,  721,
-      721,  721,  721,  721,  721,  721,  721,  721,  721,  721,
-
-      721,  721,  721,  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,  724,
-      724,  724,  724,  724,  724,  724,  724,  724,  724,  724,
-      724,  724,  724,  724,  724,  724,  724,  725,  725,    0,
-      725,  725,  725,  725,  725,  725,  725,  725,  725,  725,
-      725,  725,  725,  725,  725,  726,  726,    0,  726,  726,
-      726,  726,  726,  726,  726,  726,  726,  726,  726,  726,
-      726,  726,  726,  727,    0,    0,    0,  727,    0,  727,
-
-      727,  727,    0,    0,  727,  728,  728,    0,    0,    0,
-        0,    0,  728,  728,  729,  729,  729,  729,  729,  729,
-      729,  729,  729,  729,  729,  729,  729,  729,  729,  729,
-      729,  729,  730,  730,  730,  730,  730,  730,  730,  730,
-      730,  730,  730,  730,  730,  730,  730,  730,  730,  730,
-      731,  731,  731,  731,  731,  731,  731,  731,  731,  731,
-      731,  731,  731,  731,  731,  731,  731,  731,  732,  732,
-      732,  732,  732,  732,  732,  732,  732,  732,  732,  732,
-      732,  732,  732,  732,  732,  732,  733,  733,  733,  733,
-        0,    0,  733,    0,  733,  733,  733,  733,  733,  733,
-
-      733,  734,  734,    0,    0,    0,    0,    0,  734,  734,
-        0,  734,  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,  737,  737,
-      737,  737,    0,    0,  737,  737,  737,  737,  737,  737,
-      737,  737,  737,  738,  738,    0,    0,    0,    0,    0,
-      738,  738,  739,  739,    0,  739,  739,  739,  739,  739,
-      739,  739,  739,  739,  739,  739,  739,  739,  739,  739,
-      740,  740,    0,  740,  740,  740,  740,  740,  740,  740,
-
-      740,  740,  740,  740,  740,  740,  740,  740,  741,  741,
-        0,  741,  741,  741,  741,  741,  741,  741,  741,  741,
-      741,  741,  741,  741,  741,  741,  742,  742,    0,  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,  744,  744,    0,  744,  744,  744,  744,  744,
-      744,  744,  744,  744,  744,  744,  744,  744,  744,  744,
-      745,  745,    0,    0,    0,    0,    0,  745,  745,  745,
-      745,  745,  745,  745,  746,  746,  746,  746,  746,  746,
-
-      746,  746,  746,  746,  746,  746,  746,  746,  746,  746,
-      746,  746,  747,  747,    0,    0,    0,    0,    0,  747,
-      747,  748,  748,    0,  748,  748,  748,  748,  748,  748,
-      748,  748,  748,  748,  748,  748,  748,  748,  748,  749,
-      749,    0,  749,  749,  749,  749,  749,  749,  749,  749,
-      749,  749,  749,  749,  749,  749,  749,  750,  750,    0,
-      750,  750,  750,  750,  750,  750,  750,  750,  750,  750,
-      750,  750,  750,  750,  750,  751,  751,    0,  751,  751,
-      751,  751,  751,  751,  751,  751,  751,  751,  751,  751,
-      751,  751,  751,  752,  752,  752,  752,  752,  752,  752,
-
-      752,  752,  752,  752,  752,  752,  752,  752,  752,  752,
-      752,  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,  755,  755,  755,
-      755,  755,  755,  755,  755,  755,  755,  755,  755,  755,
-      755,  755,  755,  755,  755,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691,  691,
-      691,  691,  691,  691,  691,  691,  691,  691,  691
-    } ;
-
-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.
+ * parser.c --
  *
- * 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
- *
- * 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
@@ -1697,2527 +15,849 @@ 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 <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
-
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else /* not STDC_HEADERS */
-# if HAVE_STRING_H
-#  include <string.h>
-# else /* not HAVE_STRING_H */
-#  include <strings.h>
-# endif /* not HAVE_STRING_H */
-#endif /* not STDC_HEADERS */
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if defined(_amigados)
-# include <errno.h>
-# if HAVE_FCNTL_H
-#  include <fcntl.h>    /*  isatty() prototype  */
-# endif /*  HAVE_FCNTL_H        */
-#endif  /*  defined(_amigados)  */
-
+#include <string.h>
 #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 1825 "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 <unistd.h>
-#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 1984 "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 >= 692 )
-                                       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] != 3866 );
-
-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];
+           }
        }
-        if(c == '+' && gameInfo.variant != VariantShogi) c = currentMoveString[4] = NULLCHAR; // + means check outside Shogi
-       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 271 "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];
        }
-        if(c == '+' && gameInfo.variant != VariantShogi) currentMoveString[4] = NULLCHAR; // + means check outside Shogi
-       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 340 "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 382 "parser.l"
-{
-    /*
-     * Pawn move, possibly with promotion
-     */
-    DisambiguateClosure cl;
-    int skip = 0;
-
-    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;
-    cl.promoCharIn = ToLower(yytext[2+skip]);
-    if(cl.promoCharIn == '+' && gameInfo.variant != VariantShogi) cl.promoCharIn = NULLCHAR; // + means check outside Shogi
-
-    /* [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 423 "parser.l"
-{
-    /*
-     * Pawn capture, possibly with promotion, possibly ambiguous
-     */
-    DisambiguateClosure cl;
-    int skip1 = 0, skip2 = 0;
-
-    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;
-    cl.promoCharIn = yytext[2+skip1+skip2];
-    if(cl.promoCharIn == '+' && gameInfo.variant != VariantShogi) cl.promoCharIn = NULLCHAR; // + means check outside Shogi
-
-    /* [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 474 "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 == '+' && gameInfo.variant != VariantShogi) c = currentMoveString[4] = NULLCHAR; // + means check outside Shogi
+    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'
        }
-    }
-
-    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 { // [HGM] all very nice, but this messed up the input move that we might want to accept with legality testing off...
-      if (WhiteOnMove(yyboardindex)) // undo the damage
-            currentMoveString[1]--,  currentMoveString[3]--;
-       else currentMoveString[1]++,  currentMoveString[3]++;
-      return (int) IllegalMove;
+       *q++ = buf[0]; *q++ = buf[1]; *q++ = (kifu & 1)*'+'; *q = NULLCHAR;
+       if(appData.debugMode) fprintf(debugFP, "kif2 move %s\n", ptr);
+       return NextUnit(&ptr);
     }
 }
-       YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 595 "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 && gameInfo.variant == VariantShogi) /* [HGM] can have Shogi-style promotion */
-        cl.promoCharIn = yytext[yyleng-1-(yytext[yyleng-1]==')')];
-    if(cl.promoCharIn == '+' && gameInfo.variant != VariantShogi) cl.promoCharIn = NULLCHAR; // + means check outside Shogi
-
-    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 652 "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]==')')];
-    if(cl.promoCharIn == '+' && gameInfo.variant != VariantShogi) cl.promoCharIn = NULLCHAR; // + means check outside Shogi
-
-    /* [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 713 "parser.l"
+static inline int
+Word (char *pattern, char **p)
 {
-    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(Match(pattern, p)) return 1;
+    if(*pattern >= 'a' && *pattern <= 'z' && *pattern - **p == 'a' - 'A') { // capitalized
+       (*p)++;
+       if(Match(pattern + 1, p)) return 1;
+       (*p)--;
     }
-    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 770 "parser.l"
-{
-    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;
-    }
-    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 825 "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 849 "parser.l"
-{
-    if (WhiteOnMove(yyboardindex))
-      return (int) BlackWins;
-    else
-      return (int) WhiteWins;
-}
-       YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 856 "parser.l"
-{
-    return (int) (ToUpper(yytext[0]) == 'W' ? BlackWins : WhiteWins);
-}
-       YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 860 "parser.l"
-{
-    return (int) GameUnfinished;
-}
-       YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 864 "parser.l"
-{
-    return (int) GameIsDrawn;
-}
-       YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 868 "parser.l"
-{
-    return (int) GameIsDrawn;
-}
-       YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 872 "parser.l"
-{
-    if (WhiteOnMove(yyboardindex))
-      return (int) BlackWins;
-    else
-      return (int) WhiteWins;
-}
-       YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 879 "parser.l"
-{
-    if (WhiteOnMove(yyboardindex))
-      return (int) BlackWins;
-    else
-      return (int) WhiteWins;
-}
-       YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 886 "parser.l"
-{
-    return (int) GameIsDrawn;
-}
-       YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 890 "parser.l"
-{
-    return (int) GameIsDrawn;
-}
-       YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 894 "parser.l"
-{ 
-    return (int) (ToUpper(yytext[0]) == 'W' ? WhiteWins : BlackWins);
-}
-       YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 898 "parser.l"
-{ 
-    return (int) (ToUpper(yytext[0]) == 'W' ? BlackWins : WhiteWins);
-}
-       YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 902 "parser.l"
-{ 
-    return (int) WhiteWins;
-}
-       YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 906 "parser.l"
-{ 
-    return (int) BlackWins;
-}
-       YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 910 "parser.l"
-{
-    return (int) GameIsDrawn;
-}
-       YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 914 "parser.l"
-{
-    return (int) GameUnfinished;
-}
-       YY_BREAK
-case 27:
-/* rule 27 can match eol */
-YY_RULE_SETUP
-#line 918 "parser.l"
-{
-    /* move numbers */
-    if ((yyleng == 1) && (yytext[0] == '1'))
-      return (int) MoveNumberOne;
-    else return (int) Nothing; // [HGM] make sure something is returned, for gathering parsed text
-}
-       YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 925 "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 930 "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 935 "parser.l"
-{
-    /* position diagram enclosed in {-- --} */
-    return (int) PositionDiagram;
-}
-       YY_BREAK
-case 31:
-/* rule 31 can match eol */
-YY_RULE_SETUP
-#line 940 "parser.l"
-{
-    return (int) PGNTag;
-}    
-       YY_BREAK
-case 32:
-YY_RULE_SETUP
-#line 944 "parser.l"
+int
+Verb (char *pattern, char **p)
 {
-    return (int) GNUChessGame;
+    int res = Word(pattern, p);
+    if(res && !Match("s", p)) Match("ed", p); // eat conjugation suffix, if any
+    return res;
 }
-       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 948 "parser.l"
-{
-    return (int) XBoardGame;
-}
-       YY_BREAK
-case 34:
-YY_RULE_SETUP
-#line 952 "parser.l"
-{                              /* numeric annotation glyph */
-    return (int) NAG;
-}
-       YY_BREAK
-case 35:
-/* rule 35 can match eol */
-YY_RULE_SETUP
-#line 956 "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 960 "parser.l"
-{                                          /* ; to end of line */
-    return (int) Comment;
-}
-       YY_BREAK
-case 37:
-/* rule 37 can match eol */
-YY_RULE_SETUP
-#line 964 "parser.l"
-{                              /* anything in [] */
-    return (int) Comment; 
-}
-       YY_BREAK
-case 38:
-YY_RULE_SETUP
-#line 968 "parser.l"
-{                               /* Opening parentheses */
-    return (int) Open; 
-}
-       YY_BREAK
-case 39:
-YY_RULE_SETUP
-#line 972 "parser.l"
-{                                    /* closing parentheses */
-    return (int) Close; 
-}       
-       YY_BREAK
-case 40:
-/* rule 40 can match eol */
-YY_RULE_SETUP
-#line 976 "parser.l"
+
+int
+Number (char **p)
 {
-    return (int) Nothing;                 /* 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 980 "parser.l"
+
+int
+RdTime (char c, char **p)
 {
-    return (int) Nothing;                 /* 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 984 "parser.l"
+
+char
+PromoSuffix (char **p)
 {
-    return (int) Nothing;                 /* 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 988 "parser.l"
-ECHO;
-       YY_BREAK
-#line 3052 "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;
+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_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;
-                               }
-                       }
+       // ********* try white first, because it is so common **************************
+       if(**p == ' ' || **p == '\n' || **p == '\t') { parseStart = (*p)++; return Nothing; }
 
-               else switch ( yy_get_next_buffer(  ) )
-                       {
-                       case EOB_ACT_END_OF_FILE:
-                               {
-                               (yy_did_buffer_switch_on_eof) = 0;
 
-                               if ( yywrap( ) )
-                                       {
-                                       /* Note: because we've taken care in
-                                        * yy_get_next_buffer() to have set up
-                                        * yytext, we can now set up
-                                        * yy_c_buf_p so that if some total
-                                        * hoser (like flex itself) wants to
-                                        * call the scanner after we return the
-                                        * YY_NULL, it'll still work - another
-                                        * YY_NULL will get returned.
-                                        */
-                                       (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
-                                       yy_act = YY_STATE_EOF(YY_START);
-                                       goto do_action;
-                                       }
-
-                               else
-                                       {
-                                       if ( ! (yy_did_buffer_switch_on_eof) )
-                                               YY_NEW_FILE;
-                                       }
-                               break;
-                               }
-
-                       case EOB_ACT_CONTINUE_SCAN:
-                               (yy_c_buf_p) =
-                                       (yytext_ptr) + yy_amount_of_matched_text;
-
-                               yy_current_state = yy_get_previous_state(  );
-
-                               yy_cp = (yy_c_buf_p);
-                               yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-                               goto yy_match;
-
-                       case EOB_ACT_LAST_MATCH:
-                               (yy_c_buf_p) =
-                               &YY_CURRENT_BUFFER_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];
+               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;
 
-       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();
-
-       (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 >= 692 )
-                               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 >= 692 )
-                       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 == 691);
-       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;
+       // ********* 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;
+       }
 
-       /* We always need two end-of-buffer characters.  The first causes
-        * a transition to the end-of-buffer state.  The second causes
-        * a jam in that state.
-        */
-       b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
-       b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
 
-       b->yy_buf_pos = &b->yy_ch_buf[0];
+       // ********* 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;
+       }
 
-       b->yy_at_bol = 1;
-       b->yy_buffer_status = YY_BUFFER_NEW;
 
-       if ( b == YY_CURRENT_BUFFER )
-               yy_load_buffer_state( );
-}
+       // ********* Numeric annotation glyph **********************************
+       if(**p == '$') { (*p)++; if(Number(p) != BADNUMBER) return NAG; return Nothing; }
 
-/** 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;
 
-       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;
+       // ********* Prevent 00 in unprotected time stamps to be mistaken for castling *******
+       if(Match(":00", p)) return Nothing;
 
-    /* Reset the globals. This is important in a non-reentrant scanner so the next time
-     * yylex() is called, initialization will occur. */
-    yy_init_globals( );
-
-    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 988 "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
+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);
+    return ftell(inputFile) - (inPtr - parsePtr); // subtract what is read but not yet parsed
 }
 
-
-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 (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 yynewfile(f)
-     FILE *f;
+void
+yynewstr P((char *s))
 {
-    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);
+    parsePtr = s;
+    inputFile = NULL;
+    fromString = 1;
 }
-#endif /*FLEX_SCANNER*/
 
-int yywrap()
-{
-    return TRUE;
+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;
 }
 
-/* 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 ret;
-    char *oldStringToLex;
-#ifdef FLEX_SCANNER
-    YY_BUFFER_STATE buffer, oldBuffer;
-#endif
-    
-    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) Myylex();
-     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;
-
-    return ret;
-}
-
-int Myylex()
+int
+Myylex ()
 {   // [HGM] wrapper for yylex, which treats nesting of parentheses
     int symbol, nestingLevel = 0, i=0;
     char *p;
@@ -4237,3 +877,18 @@ int Myylex()
     return symbol;
 }
 
+ChessMove
+yylexstr (int boardIndex, char *s, char *buf, int buflen)
+{
+    ChessMove ret;
+    char *savPP = parsePtr;
+    fromString = 1;
+    yyboardindex = boardIndex;
+    parsePtr = s;
+    ret = (ChessMove) Myylex();
+    strncpy(buf, yy_text, buflen-1);
+    buf[buflen-1] = NULLCHAR;
+    parsePtr = savPP;
+    fromString = 0;
+    return ret;
+}