#define WHITESPACE_PHRASE 1023
#define GUARD  (1<<30)
#define NEGATE (1<<29)
#define MAX_GRAMMAR 1504
#define PHRASES_START 512
#define PHRASE_BASE 526
int gram[MAX_GRAMMAR] = {
    1,     2,   527|NEGATE,   513,    33,     2,  1023|GUARD ,   256,     2,  1023|GUARD ,   257,     2,  1023|GUARD ,   258,     2,  1023|GUARD , 
  259,     2,  1023|GUARD ,   260,     2,  1023|GUARD ,   261,     2,  1023|GUARD ,   262,     2,  1023|GUARD ,   263,     2,  1023|GUARD ,   264, 
    2,  1023|GUARD ,   265,     2,  1023|GUARD ,   266,     2,  1023|GUARD ,   267,     2,  1023|GUARD ,   268,     2,  1023|GUARD ,   269,     2, 
 1023|GUARD ,   270,     2,  1023|GUARD ,   271,     2,  1023|GUARD ,   272,     2,  1023|GUARD ,   273,     2,  1023|GUARD ,   274,     2,  1023|GUARD , 
  275,     2,  1023|GUARD ,   276,     2,  1023|GUARD ,   277,     2,  1023|GUARD ,   278,     2,  1023|GUARD ,   279,     2,  1023|GUARD ,   280, 
    2,  1023|GUARD ,   281,     2,  1023|GUARD ,   282,     2,  1023|GUARD ,   283,     2,  1023|GUARD ,   284,     2,  1023|GUARD ,   285,     2, 
 1023|GUARD ,   286,     2,  1023|GUARD ,   287,     2,  1023|GUARD ,   288,     1,     3, 10000,  1023|GUARD ,    59,     1,     1,   530, 
    2,     2,   531,   530,     1,   525,     6,     3,   673,  1023|GUARD ,    59,     1,   633,     1,   537,     1, 
  591,     1,   532,     2,  1023|GUARD ,    59,     3,     7,   533,   526,  1023|GUARD ,   123,   534,  1023|GUARD ,   125,     6, 
  533,  1023|GUARD ,   123,   534,  1023|GUARD ,   125,     2,   533,   526,     2,     2,  1023|GUARD ,   258,     2,  1023|GUARD ,   259, 
    1,     2,   536,   535,     2,     2,   536,   535,     0,     1,     1,   537,     1,     6,   624,   622, 
  621,   538,  1023|GUARD ,    59,     3,     5,   585,   526,   618,   614,   539,    14,   585,  1023|GUARD ,    40,   585, 
  526,  1023|GUARD ,    41,  1023|GUARD ,    40,   660,  1023|GUARD ,    41,   540,   539,     4,   585,   526,   540,   539,     2, 
    3,  1023|GUARD ,    44,   538,     0,     2,     3,  1023|GUARD ,    61,   541,     0,     1,     3,   613,   543,   542, 
    2,     3,   612,   543,   542,     0,     1,     2,   548,   544,     2,     6,  1023|GUARD ,    63,   545,  1023|GUARD , 
   58,   543,     0,     1,     1,   546,     1,     2,   541,   547,     2,     4,  1023|GUARD ,    44,   541,   547, 
    0,     1,     2,   550,   549,     2,     3,   522,   550,   549,     0,     1,     2,   552,   551,     2, 
    3,   521,   552,   551,     0,     1,     2,   554,   553,     2,     4,  1023|GUARD ,   124,   554,   553,     0, 
    1,     2,   556,   555,     2,     4,  1023|GUARD ,    94,   556,   555,     0,     1,     2,   558,   557,     2, 
    4,  1023|GUARD ,    38,   558,   557,     0,     1,     2,   560,   559,     2,     3,   611,   560,   559,     0, 
    1,     2,   562,   561,     2,     3,   610,   562,   561,     0,     1,     2,   564,   563,     2,     3, 
  609,   564,   563,     0,     1,     2,   566,   565,     2,     3,   608,   566,   565,     0,     1,     2, 
  568,   567,     2,     3,   607,   568,   567,     0,     9,     2,   606,   601,     2,   604,   601,     2, 
  602,   601,     2,   586,   582,     3,  1023|GUARD ,   260,   568,     3,  1023|GUARD ,   260,   575,     4,  1023|GUARD ,   260, 
  588,   587,     8,  1023|GUARD ,   260,  1023|GUARD ,    40,   588,   587,  1023|GUARD ,    41,     1,   569,     2,     2,   584, 
  569,     1,   570,     2,     2,   579,   571,     2,   575,   571,     6,     6,  1023|GUARD ,    91,   545,  1023|GUARD , 
   93,   571,     6,  1023|GUARD ,    40,   573,  1023|GUARD ,    41,   571,     4,  1023|GUARD ,    46,   526,   571,     6,  1023|GUARD , 
   45,  1023|GUARD ,    62,   526,   571,     2,   572,   571,     0,     2,     1,   519,     1,   520,     2,     2, 
  541,   574,     0,     2,     4,  1023|GUARD ,    44,   541,   574,     0,     4,     2,   600,   575,     2,   586, 
  583,     1,   582,     1,   576,     1,     2,   579,   577,     6,     6,  1023|GUARD ,    91,   545,  1023|GUARD ,    93, 
  577,     6,  1023|GUARD ,    40,   573,  1023|GUARD ,    41,   578,     4,  1023|GUARD ,    46,   526,   577,     6,  1023|GUARD ,    45, 
 1023|GUARD ,    62,   526,   577,     2,   572,   577,     0,     5,     6,  1023|GUARD ,    91,   545,  1023|GUARD ,    93,   577, 
    6,  1023|GUARD ,    40,   573,  1023|GUARD ,    41,   578,     4,  1023|GUARD ,    46,   526,   577,     6,  1023|GUARD ,    45,  1023|GUARD , 
   62,   526,   577,     2,   572,   577,     4,     1,   526,     1,   580,     1,   517,     5,  1023|GUARD ,    40, 
  545,  1023|GUARD ,    41,     4,     1,   514,     1,   515,     1,   516,     1,   581,     1,     1,   526,     1, 
    2,   599,   583,     2,     2,   584,   583,     1,   575,     3,     6,  1023|GUARD ,    40,   588,   587,  1023|GUARD , 
   41,    11,  1023|GUARD ,    40,  1023|GUARD ,   261,  1023|GUARD ,    40,   575,  1023|GUARD ,    41,  1023|GUARD ,    41,    12,  1023|GUARD ,    40, 
 1023|GUARD ,   261,  1023|GUARD ,    40,   588,   587,  1023|GUARD ,    41,  1023|GUARD ,    41,     2,     4,   622,  1023|GUARD ,    42,   585, 
    0,     1,     3,  1023|GUARD ,    42,   587,     2,     3,  1023|GUARD ,    42,   587,     0,     2,     1,   590,     1, 
  589,     1,     1,   526,     8,     2,  1023|GUARD ,   262,     4,  1023|GUARD ,   263,  1023|GUARD ,   262,     3,   598,  1023|GUARD , 
  264,     1,   596,     2,  1023|GUARD ,   265,     1,   532,     1,   591,     2,  1023|GUARD ,   266,     3,     7,  1023|GUARD , 
  267,  1023|GUARD ,   123,   592,  1023|GUARD ,   125,     8,  1023|GUARD ,   267,   526,  1023|GUARD ,   123,   592,  1023|GUARD ,   125,     3, 
 1023|GUARD ,   267,   526,     1,     2,   594,   593,     3,     4,  1023|GUARD ,    44,   594,   593,     2,  1023|GUARD ,    44, 
    0,     2,     4,   526,  1023|GUARD ,    61,   595,     1,   526,     1,     1,   543,     6,     4,   598,  1023|GUARD , 
  268,   597,     6,   598,  1023|GUARD ,   263,  1023|GUARD ,   263,   597,     4,   598,  1023|GUARD ,   263,   597,     3,   598, 
 1023|GUARD ,   269,     2,  1023|GUARD ,   270,     2,  1023|GUARD ,   271,     2,     2,  1023|GUARD ,   269,     0,     3,     2,  1023|GUARD , 
  270,     2,  1023|GUARD ,   271,     0,     1,     2,  1023|GUARD ,    38,     2,     1,   519,     1,   520,     2,     2, 
  584,   601,     1,   568,     1,     3,  1023|GUARD ,   126,   603,     2,     3,  1023|GUARD ,   126,   603,     0,     1, 
    3,  1023|GUARD ,    33,   605,     2,     3,  1023|GUARD ,    33,   605,     0,     2,     2,  1023|GUARD ,    43,     2,  1023|GUARD , 
   45,     3,     2,  1023|GUARD ,    42,     2,  1023|GUARD ,    47,     2,  1023|GUARD ,    37,     2,     2,  1023|GUARD ,    43,     2, 
 1023|GUARD ,    45,     2,     4,  1023|GUARD ,    60,  1023|GUARD ,    60,     4,  1023|GUARD ,    62,  1023|GUARD ,    62,     4,     4,  1023|GUARD , 
   60,  1023|GUARD ,    61,     2,  1023|GUARD ,    60,     4,  1023|GUARD ,    62,  1023|GUARD ,    61,     2,  1023|GUARD ,    62,     2,     1, 
  523,     4,  1023|GUARD ,    33,  1023|GUARD ,    61,    11,     2,  1023|GUARD ,    61,     4,  1023|GUARD ,    42,  1023|GUARD ,    61,     4, 
 1023|GUARD ,    47,  1023|GUARD ,    61,     4,  1023|GUARD ,    37,  1023|GUARD ,    61,     4,  1023|GUARD ,    43,  1023|GUARD ,    61,     4,  1023|GUARD , 
   45,  1023|GUARD ,    61,     6,  1023|GUARD ,    60,  1023|GUARD ,    60,  1023|GUARD ,    61,     6,  1023|GUARD ,    62,  1023|GUARD ,    62,  1023|GUARD , 
   61,     4,  1023|GUARD ,    38,  1023|GUARD ,    61,     4,  1023|GUARD ,    94,  1023|GUARD ,    61,     4,  1023|GUARD ,   124,  1023|GUARD ,    61, 
    2,     2,   575,   612,     0,     3,     7,  1023|GUARD ,    61,  1023|GUARD ,   123,   615,  1023|GUARD ,   125,     3,  1023|GUARD , 
   61,   517,     0,     1,     2,   617,   616,     3,     4,  1023|GUARD ,    44,   617,   616,     2,  1023|GUARD ,    44, 
    0,     2,     1,   595,     5,  1023|GUARD ,   123,   615,  1023|GUARD ,   125,     1,     6,  1023|GUARD ,    91,   620,  1023|GUARD , 
   93,   619,     2,     6,  1023|GUARD ,    91,   620,  1023|GUARD ,    93,   619,     0,     2,     1,   595,     0,     7, 
    1,   591,     1,   532,     7,  1023|GUARD ,   261,  1023|GUARD ,    40,   575,  1023|GUARD ,    41,     8,  1023|GUARD ,   261,  1023|GUARD , 
   40,   588,   587,  1023|GUARD ,    41,     1,   590,     1,   589,     2,  1023|GUARD ,   266,     2,     1,   623,     0, 
    2,     2,  1023|GUARD ,   257,     2,  1023|GUARD ,   272,     5,     2,  1023|GUARD ,   273,     2,  1023|GUARD ,   274,     2,  1023|GUARD , 
  275,     2,  1023|GUARD ,   276,     0,     1,     2,   526,   626,     2,     3,  1023|GUARD ,    44,   625,     0,     2, 
    3,   632,  1023|GUARD ,    59,     1,   634,     1,     3,   624,   622,   629,     2,     1,   672,     1,   589, 
    2,     7,  1023|GUARD ,    40,  1023|GUARD ,    42,   526,  1023|GUARD ,    41,     1,   526,     1,     7,   585,   630,  1023|GUARD , 
   40,   660,  1023|GUARD ,    41,     2,     4,  1023|GUARD ,    44,   631,   632,     0,     2,     3,   628,   631,   627, 
   12,   628,   585,   526,  1023|GUARD ,    40,   625,  1023|GUARD ,    41,   661,  1023|GUARD ,    59,   634,     2,     4,  1023|GUARD , 
  123,  1023|GUARD ,   125,     5,  1023|GUARD ,   123,   635,  1023|GUARD ,   125,     1,     3,   659,   637,   636,     2,     3, 
  659,   637,   636,     0,     9,     2,  1023|GUARD ,    59,     1,   634,     1,   656,     1,   655,     1,   652, 
    3,   545,  1023|GUARD ,    59,     3,   628,   631,   627,     1,   638,     1,   530,     2,     4,   624,   622, 
  621,   647,     1,   639,     1,     8,  1023|GUARD ,   258,   646,  1023|GUARD ,   123,   640,  1023|GUARD ,   125,     2,     2, 
  641,   640,     0,     3,     1,   639,     1,   643,     1,   642,     1,     9,   624,   622,   621,   585, 
  526,   618,   614,  1023|GUARD ,    59,     1,     4,   624,   622,   621,   644,     1,     6,   585,   526,   540, 
  645,  1023|GUARD ,    59,     2,     6,  1023|GUARD ,    44,   585,   526,   540,   645,     0,     1,     1,   526,     1, 
    2,   649,   648,     2,     3,  1023|GUARD ,    44,   647,     0,     2,     4,   585,   526,   650,   614,     3, 
  585,   526,   540,     1,     6,  1023|GUARD ,    91,   620,  1023|GUARD ,    93,   651,     2,     6,  1023|GUARD ,    91,   620, 
 1023|GUARD ,    93,   651,     0,     4,     5,  1023|GUARD ,   277,   654,  1023|GUARD ,    59,     4,  1023|GUARD ,   278,  1023|GUARD ,    59, 
    4,  1023|GUARD ,   279,  1023|GUARD ,    59,     5,  1023|GUARD ,   280,   653,  1023|GUARD ,    59,     2,     1,   545,     0,     1, 
    1,   526,     3,     8,  1023|GUARD ,   281,  1023|GUARD ,    40,   545,  1023|GUARD ,    41,   637,    12,  1023|GUARD ,   282,   637, 
 1023|GUARD ,   281,  1023|GUARD ,    40,   545,  1023|GUARD ,    41,  1023|GUARD ,    59,    14,  1023|GUARD ,   283,  1023|GUARD ,    40,   653,  1023|GUARD , 
   59,   653,  1023|GUARD ,    59,   653,  1023|GUARD ,    41,   637,     2,     9,  1023|GUARD ,   256,  1023|GUARD ,    40,   545,  1023|GUARD , 
   41,   637,   657,     8,  1023|GUARD ,   284,  1023|GUARD ,    40,   545,  1023|GUARD ,    41,   637,     2,     3,  1023|GUARD ,   285, 
  637,     0,     1,     2,  1023|GUARD ,   125,     4,     5,   654,  1023|GUARD ,    58,   659,   658|NEGATE,     7,  1023|GUARD ,   286, 
  595,  1023|GUARD ,    58,   659,   658|NEGATE,     6,  1023|GUARD ,   287,  1023|GUARD ,    58,   659,   658|NEGATE,     0,     3,     2,   669, 
  668,     2,  1023|GUARD ,   266,     0,     2,     1,   662,     0,     2,     2,   664,   663,     2,  1023|GUARD ,   266, 
    2,     3,  1023|GUARD ,    59,   662,     0,     1,     3,   622,   621,   665,     1,     2,   667,   666,     2, 
    3,  1023|GUARD ,    44,   665,     0,     1,     3,   585,   670,   651,     3,     8,  1023|GUARD ,    44,  1023|GUARD ,    46, 
 1023|GUARD ,    46,  1023|GUARD ,    46,     4,  1023|GUARD ,    44,   669,   668,     0,     2,     1,   671,     5,   622,   621, 
  585,   670,   651,     2,     1,   526,     0,     2,    14,   624,   622,   672,  1023|GUARD ,    40,   585,   526, 
 1023|GUARD ,    41,  1023|GUARD ,    40,   660,  1023|GUARD ,    41,    14,   624,   622,   589,  1023|GUARD ,    40,   585,   526,  1023|GUARD , 
   41,  1023|GUARD ,    40,   660,  1023|GUARD ,    41,     2,     1,   590,     0,     3,    15,  1023|GUARD ,   288,   588,   585, 
 1023|GUARD ,    40,   585,   526,  1023|GUARD ,    41,  1023|GUARD ,    40,   660,  1023|GUARD ,    41,     4,  1023|GUARD ,   288,   639,   674, 
    4,  1023|GUARD ,   288,   588,   674,     1,     3,   585,   589,   675,     2,     3,  1023|GUARD ,    44,   674,     0, 
};

#define MAX_KEYWORD 33
char *keyword[MAX_KEYWORD] = { // Keywords are based at 256
  "if", "const", "struct", "union", 
  "sizeof", "typeof", "double", "long", 
  "char", "float", "void", "enum", 
  "short", "int", "signed", "unsigned", 
  "volatile", "auto", "register", "static", 
  "extern", "goto", "continue", "break", 
  "return", "while", "do", "for", 
  "switch", "else", "case", "default", 
  "typedef", 
};

// These are used in AST__KW records:
#define KW_if 0
#define KW_const 1
#define KW_struct 2
#define KW_union 3
#define KW_sizeof 4
#define KW_typeof 5
#define KW_double 6
#define KW_long 7
#define KW_char 8
#define KW_float 9
#define KW_void 10
#define KW_enum 11
#define KW_short 12
#define KW_int 13
#define KW_signed 14
#define KW_unsigned 15
#define KW_volatile 16
#define KW_auto 17
#define KW_register 18
#define KW_static 19
#define KW_extern 20
#define KW_goto 21
#define KW_continue 22
#define KW_break 23
#define KW_return 24
#define KW_while 25
#define KW_do 26
#define KW_for 27
#define KW_switch 28
#define KW_else 29
#define KW_case 30
#define KW_default 31
#define KW_typedef 32

#define MAX_BIP 14
int BIP[MAX_BIP] = { // BIPs precede PHRASEs at PHRASES_START upwards
 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 
};

#define MAX_PHRASE 164
#if defined(DEBUG_PARSER) || defined(EXTENDED_ERROR_REPORTING)
// FOR DEBUGGING ONLY
char *phrasename[MAX_PHRASE] = { // Based at PHRASES_START upwards
  "char", "internal-identifier", "integer-constant", "sqstring", 
  "floating-constant", "dqstring", "keyword", "pp", 
  "mm", "andand", "oror", "eqeq", 
  "NL", "EOF", "identifier", "keyword-not-allowed-in-context-of-an-identifier", 
  "ignored", "SS", "opt-external-declaration-list", "external-declaration", 
  "struct-or-union-specifier", "struct-or-union", "struct-field-declarations", "rest-of-struct-field-declarations", 
  "struct-field-declaration", "possibly-initialised-scalar-or-array-decl", "rest-of-scalar-or-array-decl", "opt-rest-of-scalar-or-array-decl", 
  "opt-scalar-init", "assignment-expression", "opt-rest-of-assignment-expression", "conditional-expression", 
  "rest-of-conditional-expression", "expression", "comma-statement", "rest-of-comma-statement", 
  "logical-or-expression", "rest-of-logical-or-expression", "logical-and-expression", "rest-of-logical-and-expression", 
  "inclusive-or-expression", "rest-of-inclusive-or-expression", "exclusive-or-expression", "rest-of-exclusive-or-expression", 
  "bitwise-and-expression", "rest-of-bitwise-and-expression", "equality-expression", "rest-of-equality-expression", 
  "relational-expression", "rest-of-relational-expression", "shift-expression", "rest-of-shift-expression", 
  "additive-expression", "rest-of-additive-expression", "multiplicative-expression", "rest-of-multiplicative-expression", 
  "unary-rvalue-expression", "optionally-cast-postfix-rvalue-expression", "postfix-rvalue-expression", "rest-of-postfix-rvalue-expression", 
  "post-increment-op", "actual-param-list", "rest-of-param-list", "unary-lvalue-expression", 
  "postfix-lvalue-expression", "rest-of-postfix-expression", "non-empty-rest-of-postfix-expression", "primary-expression", 
  "constant", "enumeration-constant", "unary-address-expression", "optionally-cast-unary-lvalue-expression", 
  "cast", "opt-indirection-decl", "indirection-unary-ops", "opt-indirection-unary-ops", 
  "type-specifier", "typedef-name", "basic-type-specifier", "enum-specifier", 
  "enumerator-list", "rest-of-enumerator-list", "enumerator", "constant-expression", 
  "opt-signed-inttype", "opt-int", "opt-signed", "address-operator", 
  "pre-increment-op", "optionally-cast-unary-rvalue-expression", "bitwise-unary-ops", "rest-of-bitwise-unary-ops", 
  "boolean-unary-ops", "rest-of-boolean-unary-ops", "arithmetic-unary-op", "mulop", 
  "plusminus", "shiftop", "relop", "eqop", 
  "assignment-operator", "opt-lvalue-assign", "opt-array-init", "constant-initializer-list", 
  "rest-of-constant-initializer-list", "constant-initializer", "array-bounds", "opt-array-bounds", 
  "opt-constant-expression", "type", "opt-const-or-volatile-type-qualifier", "const-or-volatile-type-qualifier", 
  "opt-auto-reg-static-ext", "identifier-list", "rest-of-identifier-list", "more-forward-decls-or-actual-body", 
  "extern-proc-spec", "opt-basic-type-specifier-or-typedef-name", "identifier-or-function-pointer", "extern-proc-name-and-params", 
  "opt-extern-proc-name-and-params-list", "proc-fn-decl", "compound-statement", "statement-list", 
  "rest-of-statement-list", "statement", "in-proc-data-declaration", "struct-decl", 
  "struct-member-list", "struct-member-declaration", "possibly-initialised-array-decl", "possibly-initialised-scalar-decl", 
  "rest-of-scalar-decl", "opt-rest-of-scalar-decl", "new-structname", "decl-list", 
  "rest-of-decl-list", "decl", "possibly-empty-array-bounds-list", "optional-possibly-empty-array-bounds-list", 
  "jump-statement", "opt-expression", "label", "iteration-statement", 
  "selection-statement", "opt-else", "missing-semicolon-after-label-at-end-of-block", "opt-labels", 
  "opt-param-list", "opt-oldstyle-param-list", "oldstyle-param-list", "opt-rest-of-oldstyle-param-list", 
  "oldstyle-formal-param", "oldstyle-parameter-list", "rest-of-oldstyle-parameter-list", "whatever", 
  "opt-rest-of-param-list", "formal-param", "opt-identifier", "procedure-as-parameter", 
  "opt-basic-type-specifier", "typedef-declaration", "maybe-indirect-typedef-name-list", "rest-of-maybe-indirect-typedef-name-list", 
  };
#endif /* DEBUG_PARSER */

int phrase_start[MAX_PHRASE-MAX_BIP] = {
    0,     4, 
  104,   109,   112,   118,   134,   153,   160,   164,   169,   172,   180,   207,   213,   219,   224,   230, 
  234,   243,   246,   250,   257,   261,   267,   271,   277,   281,   288,   292,   299,   303,   310,   314, 
  320,   324,   330,   334,   340,   344,   350,   354,   360,   397,   403,   410,   441,   446,   451,   458, 
  469,   473,   504,   534,   547,   556,   559,   563,   569,   602,   609,   614,   620,   625,   628,   653, 
  675,   679,   689,   697,   700,   728,   733,   741,   745,   750,   756,   761,   767,   772,   778,   785, 
  795,   802,   813,   830,   838,   896,   901,   915,   919,   929,   938,   946,   955,   959,   988,   992, 
  999,  1013,  1017,  1023,  1030,  1035,  1040,  1051,  1060,  1067,  1085,  1097,  1102,  1108,  1132,  1140, 
 1150,  1155,  1162,  1173,  1179,  1187,  1196,  1199,  1203,  1209,  1219,  1227,  1236,  1259,  1263,  1266, 
 1304,  1324,  1330,  1334,  1357,  1365,  1369,  1376,  1382,  1387,  1391,  1397,  1402,  1418,  1427,  1431, 
 1462,  1466,  1493,  1498, 
};

#define P_char 512
#define B_char 0
#define AST_char 0

#define P_internal_identifier 513
#define B_internal_identifier 1
#define AST_internal_identifier 1

#define P_integer_constant 514
#define B_integer_constant 2
#define AST_integer_constant 2

#define P_sqstring 515
#define B_sqstring 3
#define AST_sqstring 3

#define P_floating_constant 516
#define B_floating_constant 4
#define AST_floating_constant 4

#define P_dqstring 517
#define B_dqstring 5
#define AST_dqstring 5

#define P_keyword 518
#define B_keyword 6
#define AST_keyword 6

#define P_pp 519
#define B_pp 7
#define AST_pp 7

#define P_mm 520
#define B_mm 8
#define AST_mm 8

#define P_andand 521
#define B_andand 9
#define AST_andand 9

#define P_oror 522
#define B_oror 10
#define AST_oror 10

#define P_eqeq 523
#define B_eqeq 11
#define AST_eqeq 11

#define P_NL 524
#define B_NL 12
#define AST_NL 12

#define P_EOF 525
#define B_EOF 13
#define AST_EOF 13

#define P_identifier 526
#define AST_identifier 14

#define P_keyword_not_allowed_in_context_of_an_identifier 527
#define AST_keyword_not_allowed_in_context_of_an_identifier 15

#define P_ignored 528
#define AST_ignored 16

#define P_SS 529
#define AST_SS 17

#define P_opt_external_declaration_list 530
#define AST_opt_external_declaration_list 18

#define P_external_declaration 531
#define AST_external_declaration 19

#define P_struct_or_union_specifier 532
#define AST_struct_or_union_specifier 20

#define P_struct_or_union 533
#define AST_struct_or_union 21

#define P_struct_field_declarations 534
#define AST_struct_field_declarations 22

#define P_rest_of_struct_field_declarations 535
#define AST_rest_of_struct_field_declarations 23

#define P_struct_field_declaration 536
#define AST_struct_field_declaration 24

#define P_possibly_initialised_scalar_or_array_decl 537
#define AST_possibly_initialised_scalar_or_array_decl 25

#define P_rest_of_scalar_or_array_decl 538
#define AST_rest_of_scalar_or_array_decl 26

#define P_opt_rest_of_scalar_or_array_decl 539
#define AST_opt_rest_of_scalar_or_array_decl 27

#define P_opt_scalar_init 540
#define AST_opt_scalar_init 28

#define P_assignment_expression 541
#define AST_assignment_expression 29

#define P_opt_rest_of_assignment_expression 542
#define AST_opt_rest_of_assignment_expression 30

#define P_conditional_expression 543
#define AST_conditional_expression 31

#define P_rest_of_conditional_expression 544
#define AST_rest_of_conditional_expression 32

#define P_expression 545
#define AST_expression 33

#define P_comma_statement 546
#define AST_comma_statement 34

#define P_rest_of_comma_statement 547
#define AST_rest_of_comma_statement 35

#define P_logical_or_expression 548
#define AST_logical_or_expression 36

#define P_rest_of_logical_or_expression 549
#define AST_rest_of_logical_or_expression 37

#define P_logical_and_expression 550
#define AST_logical_and_expression 38

#define P_rest_of_logical_and_expression 551
#define AST_rest_of_logical_and_expression 39

#define P_inclusive_or_expression 552
#define AST_inclusive_or_expression 40

#define P_rest_of_inclusive_or_expression 553
#define AST_rest_of_inclusive_or_expression 41

#define P_exclusive_or_expression 554
#define AST_exclusive_or_expression 42

#define P_rest_of_exclusive_or_expression 555
#define AST_rest_of_exclusive_or_expression 43

#define P_bitwise_and_expression 556
#define AST_bitwise_and_expression 44

#define P_rest_of_bitwise_and_expression 557
#define AST_rest_of_bitwise_and_expression 45

#define P_equality_expression 558
#define AST_equality_expression 46

#define P_rest_of_equality_expression 559
#define AST_rest_of_equality_expression 47

#define P_relational_expression 560
#define AST_relational_expression 48

#define P_rest_of_relational_expression 561
#define AST_rest_of_relational_expression 49

#define P_shift_expression 562
#define AST_shift_expression 50

#define P_rest_of_shift_expression 563
#define AST_rest_of_shift_expression 51

#define P_additive_expression 564
#define AST_additive_expression 52

#define P_rest_of_additive_expression 565
#define AST_rest_of_additive_expression 53

#define P_multiplicative_expression 566
#define AST_multiplicative_expression 54

#define P_rest_of_multiplicative_expression 567
#define AST_rest_of_multiplicative_expression 55

#define P_unary_rvalue_expression 568
#define AST_unary_rvalue_expression 56

#define P_optionally_cast_postfix_rvalue_expression 569
#define AST_optionally_cast_postfix_rvalue_expression 57

#define P_postfix_rvalue_expression 570
#define AST_postfix_rvalue_expression 58

#define P_rest_of_postfix_rvalue_expression 571
#define AST_rest_of_postfix_rvalue_expression 59

#define P_post_increment_op 572
#define AST_post_increment_op 60

#define P_actual_param_list 573
#define AST_actual_param_list 61

#define P_rest_of_param_list 574
#define AST_rest_of_param_list 62

#define P_unary_lvalue_expression 575
#define AST_unary_lvalue_expression 63

#define P_postfix_lvalue_expression 576
#define AST_postfix_lvalue_expression 64

#define P_rest_of_postfix_expression 577
#define AST_rest_of_postfix_expression 65

#define P_non_empty_rest_of_postfix_expression 578
#define AST_non_empty_rest_of_postfix_expression 66

#define P_primary_expression 579
#define AST_primary_expression 67

#define P_constant 580
#define AST_constant 68

#define P_enumeration_constant 581
#define AST_enumeration_constant 69

#define P_unary_address_expression 582
#define AST_unary_address_expression 70

#define P_optionally_cast_unary_lvalue_expression 583
#define AST_optionally_cast_unary_lvalue_expression 71

#define P_cast 584
#define AST_cast 72

#define P_opt_indirection_decl 585
#define AST_opt_indirection_decl 73

#define P_indirection_unary_ops 586
#define AST_indirection_unary_ops 74

#define P_opt_indirection_unary_ops 587
#define AST_opt_indirection_unary_ops 75

#define P_type_specifier 588
#define AST_type_specifier 76

#define P_typedef_name 589
#define AST_typedef_name 77

#define P_basic_type_specifier 590
#define AST_basic_type_specifier 78

#define P_enum_specifier 591
#define AST_enum_specifier 79

#define P_enumerator_list 592
#define AST_enumerator_list 80

#define P_rest_of_enumerator_list 593
#define AST_rest_of_enumerator_list 81

#define P_enumerator 594
#define AST_enumerator 82

#define P_constant_expression 595
#define AST_constant_expression 83

#define P_opt_signed_inttype 596
#define AST_opt_signed_inttype 84

#define P_opt_int 597
#define AST_opt_int 85

#define P_opt_signed 598
#define AST_opt_signed 86

#define P_address_operator 599
#define AST_address_operator 87

#define P_pre_increment_op 600
#define AST_pre_increment_op 88

#define P_optionally_cast_unary_rvalue_expression 601
#define AST_optionally_cast_unary_rvalue_expression 89

#define P_bitwise_unary_ops 602
#define AST_bitwise_unary_ops 90

#define P_rest_of_bitwise_unary_ops 603
#define AST_rest_of_bitwise_unary_ops 91

#define P_boolean_unary_ops 604
#define AST_boolean_unary_ops 92

#define P_rest_of_boolean_unary_ops 605
#define AST_rest_of_boolean_unary_ops 93

#define P_arithmetic_unary_op 606
#define AST_arithmetic_unary_op 94

#define P_mulop 607
#define AST_mulop 95

#define P_plusminus 608
#define AST_plusminus 96

#define P_shiftop 609
#define AST_shiftop 97

#define P_relop 610
#define AST_relop 98

#define P_eqop 611
#define AST_eqop 99

#define P_assignment_operator 612
#define AST_assignment_operator 100

#define P_opt_lvalue_assign 613
#define AST_opt_lvalue_assign 101

#define P_opt_array_init 614
#define AST_opt_array_init 102

#define P_constant_initializer_list 615
#define AST_constant_initializer_list 103

#define P_rest_of_constant_initializer_list 616
#define AST_rest_of_constant_initializer_list 104

#define P_constant_initializer 617
#define AST_constant_initializer 105

#define P_array_bounds 618
#define AST_array_bounds 106

#define P_opt_array_bounds 619
#define AST_opt_array_bounds 107

#define P_opt_constant_expression 620
#define AST_opt_constant_expression 108

#define P_type 621
#define AST_type 109

#define P_opt_const_or_volatile_type_qualifier 622
#define AST_opt_const_or_volatile_type_qualifier 110

#define P_const_or_volatile_type_qualifier 623
#define AST_const_or_volatile_type_qualifier 111

#define P_opt_auto_reg_static_ext 624
#define AST_opt_auto_reg_static_ext 112

#define P_identifier_list 625
#define AST_identifier_list 113

#define P_rest_of_identifier_list 626
#define AST_rest_of_identifier_list 114

#define P_more_forward_decls_or_actual_body 627
#define AST_more_forward_decls_or_actual_body 115

#define P_extern_proc_spec 628
#define AST_extern_proc_spec 116

#define P_opt_basic_type_specifier_or_typedef_name 629
#define AST_opt_basic_type_specifier_or_typedef_name 117

#define P_identifier_or_function_pointer 630
#define AST_identifier_or_function_pointer 118

#define P_extern_proc_name_and_params 631
#define AST_extern_proc_name_and_params 119

#define P_opt_extern_proc_name_and_params_list 632
#define AST_opt_extern_proc_name_and_params_list 120

#define P_proc_fn_decl 633
#define AST_proc_fn_decl 121

#define P_compound_statement 634
#define AST_compound_statement 122

#define P_statement_list 635
#define AST_statement_list 123

#define P_rest_of_statement_list 636
#define AST_rest_of_statement_list 124

#define P_statement 637
#define AST_statement 125

#define P_in_proc_data_declaration 638
#define AST_in_proc_data_declaration 126

#define P_struct_decl 639
#define AST_struct_decl 127

#define P_struct_member_list 640
#define AST_struct_member_list 128

#define P_struct_member_declaration 641
#define AST_struct_member_declaration 129

#define P_possibly_initialised_array_decl 642
#define AST_possibly_initialised_array_decl 130

#define P_possibly_initialised_scalar_decl 643
#define AST_possibly_initialised_scalar_decl 131

#define P_rest_of_scalar_decl 644
#define AST_rest_of_scalar_decl 132

#define P_opt_rest_of_scalar_decl 645
#define AST_opt_rest_of_scalar_decl 133

#define P_new_structname 646
#define AST_new_structname 134

#define P_decl_list 647
#define AST_decl_list 135

#define P_rest_of_decl_list 648
#define AST_rest_of_decl_list 136

#define P_decl 649
#define AST_decl 137

#define P_possibly_empty_array_bounds_list 650
#define AST_possibly_empty_array_bounds_list 138

#define P_optional_possibly_empty_array_bounds_list 651
#define AST_optional_possibly_empty_array_bounds_list 139

#define P_jump_statement 652
#define AST_jump_statement 140

#define P_opt_expression 653
#define AST_opt_expression 141

#define P_label 654
#define AST_label 142

#define P_iteration_statement 655
#define AST_iteration_statement 143

#define P_selection_statement 656
#define AST_selection_statement 144

#define P_opt_else 657
#define AST_opt_else 145

#define P_missing_semicolon_after_label_at_end_of_block 658
#define AST_missing_semicolon_after_label_at_end_of_block 146

#define P_opt_labels 659
#define AST_opt_labels 147

#define P_opt_param_list 660
#define AST_opt_param_list 148

#define P_opt_oldstyle_param_list 661
#define AST_opt_oldstyle_param_list 149

#define P_oldstyle_param_list 662
#define AST_oldstyle_param_list 150

#define P_opt_rest_of_oldstyle_param_list 663
#define AST_opt_rest_of_oldstyle_param_list 151

#define P_oldstyle_formal_param 664
#define AST_oldstyle_formal_param 152

#define P_oldstyle_parameter_list 665
#define AST_oldstyle_parameter_list 153

#define P_rest_of_oldstyle_parameter_list 666
#define AST_rest_of_oldstyle_parameter_list 154

#define P_whatever 667
#define AST_whatever 155

#define P_opt_rest_of_param_list 668
#define AST_opt_rest_of_param_list 156

#define P_formal_param 669
#define AST_formal_param 157

#define P_opt_identifier 670
#define AST_opt_identifier 158

#define P_procedure_as_parameter 671
#define AST_procedure_as_parameter 159

#define P_opt_basic_type_specifier 672
#define AST_opt_basic_type_specifier 160

#define P_typedef_declaration 673
#define AST_typedef_declaration 161

#define P_maybe_indirect_typedef_name_list 674
#define AST_maybe_indirect_typedef_name_list 162

#define P_rest_of_maybe_indirect_typedef_name_list 675
#define AST_rest_of_maybe_indirect_typedef_name_list 163

#define AST__LIT 164
#define AST__KW 165


#ifdef WANT_COMMENT
// These are only used to reconstitute the grammar file:
char *comment[/*MAX_PHRASE-MAX_BIP*/] = {
  NULL, NULL, NULL, 
  " <character-constant> temporarily replaced by <sqstring>\n"
  " and <string> temporarily replaced by <dqstring>\n"
  " because parser.c TEMPORARILY assumes these exist in all parsers :-(\n",
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  " char, NL, and EOF are required by all parsers\n",
  NULL, 
  " top-level statement\n",
  " want to use keyword[] array from parser.h, but this will have to do for now\n"
  " until I can work out a clean mechanism using <immediate:...>\n",
  NULL, NULL, NULL, NULL, 
  " Oops - these can be initialised.  Not yet done so.\n"
  "\n",
  NULL, NULL, NULL, NULL, 
  " I originally thought you could only initialise an array after a declaration\n"
  " that had '[]' in it.  But not the case - a typedef'd declaration may have\n"
  " the array part in the typedef rather than the instance.  Ugly language.\n"
  "\n"
  " Also we can have initialised structs :-/\n"
  "\n",
  " The <opt-scalar-init> part of function pointers is usually going to be \"= &procname\"... any other type of scalar is dubious...\n",
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  NULL, NULL, NULL, NULL, NULL, 
  " my reading of the spec is that \"sizeof\" <type-specifier> is valid but \"sizeof\" '(' <type-specifier> ')' is not,\n"
  " however the latter appears to be accepted by gcc.\n"
  " Should we merge <type-specifier> with <opt-indirection-unary-ops>? Is <type-specifier> ever used without an optional '*' following?\n",
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  NULL, NULL, NULL, NULL, 
  " <opt-indirection-decl> looks just like <opt-indirection-unary-ops> except that it only\n"
  " happens in a declaration, not a data access.  The significant difference is that the '*'\n"
  " can be preceded by a \"const\" (and maybe \"volatile\") keyword, eg \"int const *fred\" which\n"
  " is a constant pointer to an int.\n"
  "\n",
  NULL, NULL, NULL, NULL, 
  " I think struct or union or enum specifier below can be an actual declaration using '{}'s\n"
  " rather than just a struct or enum name.\n"
  "\n",
  NULL, NULL, NULL, NULL, NULL, 
  " does this omit \"signed int\"? - check, and add <opt-signed> \"int\" if needed...\n",
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  NULL, NULL, 
  " Actually I don't think declarations inside a block are allowed\n"
  " to be preceded by labels.\n"
  " So the three lines below (which are in P<statement>) probably should\n"
  " be separated out and put in <statement-list> below separately from the\n"
  " options which can have <opt-labels> in front of them.\n"
  "\n"
  "   <extern-proc-spec> <extern-proc-name-and-params> <more-forward-decls-or-actual-body>,\n"
  "   <in-proc-data-declaration>,\n"
  "   <opt-external-declaration-list>;\n"
  " Also still to add are label declarations (inside blocks):\n"
  " P<label-declaration> =\n"
  "    \"__label__\" <identifier-list> ';';\n"
  " (I'm not sure if \"label\" as a keyword is valid too, or does it have to be #define'd as __label__ ?\n",
  NULL, 
  " added as a test: <extern-proc-spec> <extern-proc-name-and-params> <more-forward-decls-or-actual-body>,\n",
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  " guard to give better error on \"label: }\" which should be \"label: ; }\"\n",
  NULL, 
  " formal parameter list can also be just a list of types (but can still end in \"...\")\n"
  " normal current style however is to have named parameters.\n"
  "\n",
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
  " Wonder if this would do it? <opt-indirection-decl> '(' <opt-indirection-decl> <identifier> ')' '(' <opt-param-list> ')' <opt-scalar-init> <opt-rest-of-scalar-or-array-decl>,\n",
  NULL, NULL, /*6*/
};
#endif

#ifdef WANT_SEMANTIC_CODE
/* header code from grammar */

// WARNING: currently parse-time phrases are not being handled properly
//          by compile(). Are they set to -1 or skipped completely?
extern int *A; // remove as much of this as possible as soon as things start working again...
extern int cp;                     // code pointer.  Has to be global state.
extern int ap;                     // Analysis record pointer.
int kw(int AST_op, int kw_idx, int ap)  // kw(AST__KW, KW_void, A[ap+0]);

{
  int data[3];

  data[1] =  kw_idx;

  data[2] =  ap;

  return mktuple(B_keyword, 1, 2, data);

}
int check(int Aval, int *table);

// variables used in line_reconstruction() moved here so they are available to semantic code in grammar.
int saved = TRUE;

int at_startofline = TRUE;

/* end of header code from grammar */
#endif


#ifdef WANT_SEMANTIC_TABLE
#define SEMANTIC_NAME "immediate"
#define SEMANTIC 10000
#define MAX_SEMANTIC 1
#define SEMANTIC_HEADER "\n" \
        "// WARNING: currently parse-time phrases are not being handled properly\n" \
        "//          by compile(). Are they set to -1 or skipped completely?\n" \
        "extern int *A; // remove as much of this as possible as soon as things start working again...\n" \
        "extern int cp;                     // code pointer.  Has to be global state.\n" \
        "extern int ap;                     // Analysis record pointer.\n" \
        "int kw(int AST_op, int kw_idx, int ap)  // kw(AST__KW, KW_void, A[ap+0]);\n" \
        "\n" \
        "{\n" \
        "  int data[3];\n" \
        "\n" \
        "  data[1] =  kw_idx;\n" \
        "\n" \
        "  data[2] =  ap;\n" \
        "\n" \
        "  return mktuple(B_keyword, 1, 2, data);\n" \
        "\n" \
        "}\n" \
        "int check(int Aval, int *table);\n" \
        "\n" \
        "// variables used in line_reconstruction() moved here so they are available to semantic code in grammar.\n" \
        "int saved = TRUE;\n" \
        "\n" \
        "int at_startofline = TRUE;\n" \
        "\n" \
        ""
char *semantic_code[MAX_SEMANTIC] = {
  "return FALSE;",
};
int semantic(int phrase) {
#ifdef WANT_SEMANTIC_CODE
  switch (phrase) {
  case 0: return FALSE;
  default: break;
  }
  // put diagnostics on error here
#endif
};
#endif
