#define MAX_GRAMMAR 411
#define PHRASE_BASE 517
int gram[MAX_GRAMMAR] = {
    1,     4,   518,   519,   256,   520,     2,     2,   528,   518,     0,     2,     2,   535,   519,     0, 
    1,     4,   257,   523,   522,   258,     1,     4,   257,   523,   522,   258,     2,     2,   543,   522, 
    0,     2,     1,   529,     0,     2,     3,    44,   533,   524,     0,     1,     2,    35,   526,     3, 
    3,   259,   512,   527,     2,   260,   512,     1,   261,     5,     1,   512,     1,   578,     1,   514, 
    1,   515,     1,   516,     2,     3,    35,   262,   516,     1,   529,     2,     1,   525,     4,   530, 
  533,   524,   562,     1,     2,   531,   532,     2,     1,   263,     0,     2,     1,   264,     1,   265, 
    3,     2,    42,   512,     2,   512,   534,     1,   512,     2,     3,    91,   578,    93,     0,     2, 
    5,   266,   512,    40,    41,   536,     6,   266,   512,    40,   537,    41,   536,     2,     1,   521, 
    0,     2,     2,   542,   538,     0,     2,     3,    44,   539,   538,     0,     4,     3,   530,    42, 
  540,     2,   530,    42,     2,   530,   540,     1,   530,     1,     2,   512,   541,     2,     3,    44, 
  512,   541,     0,     2,     1,   539,     0,     1,     2,   544,   562,     6,     1,   545,     1,   547, 
    1,   548,     3,    35,   267,   516,     1,   525,     1,   549,     1,     7,   268,    40,   556,    41, 
  522,   546,   261,     2,     2,   269,   522,     0,     1,     6,   270,    40,   556,    41,   522,   271, 
    1,    11,   272,    40,   549,   562,   556,   562,   549,   562,    41,   522,   273,     3,     4,   512, 
   40,   550,    41,     3,   512,    40,    41,     3,   553,    61,   556,     1,     2,   555,   551,     2, 
    2,   552,   550,     0,     2,     1,    44,     0,     3,     2,    42,   554,     4,   512,    91,   565, 
   93,     1,   512,     2,     1,   514,     1,   512,     2,     1,   516,     1,   565,     1,     2,   558, 
  557,     2,     3,   572,   558,   557,     0,     1,     2,   560,   559,     2,     3,    38,   560,   559, 
    0,     1,     2,   561,   563,     2,     1,    33,     0,     2,     1,    59,     0,     1,     2,   565, 
  564,     2,     2,   573,   565,     0,     1,     2,   567,   566,     2,     3,   574,   567,   566,     0, 
    1,     3,   568,   570,   569,     2,     1,   575,     0,     2,     3,   575,   570,   569,     0,     1, 
    2,   577,   571,     2,     3,   576,   577,   571,     0,     2,     1,   124,     1,   126,     7,     2, 
   60,    62,     2,    60,    61,     1,    60,     2,    62,    61,     1,    62,     2,    33,    61,     1, 
   61,     2,     2,    60,    60,     2,    62,    62,     2,     1,    43,     1,    45,     2,     1,    42, 
    1,    47,     6,     3,    40,   556,    41,     5,    38,   512,    91,   565,    93,     2,    38,   512, 
    1,   553,     1,   578,     1,   514,     2,     1,   513,     1,   515, 
};

#define MAX_KEYWORD 18
char *keyword[MAX_KEYWORD] = { // Keywords are based at 256
  "program", "begin", "end", "define", 
  "ifdef", "endif", "include", "unsigned", 
  "char", "int", "procedure", "inline", 
  "if", "else", "while", "endwhile", 
  "for", "endfor", 
};

#define MAX_BIP 5
int BIP[MAX_BIP] = { // BIPs precede PHRASEs at 512 upwards
 1,  5,  6,  3,  2, 
};

#define MAX_PHRASE 67
#ifdef DEBUG_PARSER
// FOR DEBUGGING ONLY
char *phrasename[MAX_PHRASE] = { // Based at 512 upwards
  "IDENT", "NUM", "HEXNUM", "CHARLIT", 
  "STRING", "PROGRAM", "OPTGLOBAL", "OPTPROC", 
  "MAINBLOCK", "BLOCK", "SSLIST", "OPTLOCAL", 
  "RESTOFDECL", "DIRECTIVE", "COMMAND", "DEFN", 
  "GLOBAL", "LOCAL", "TYPE", "OPTUNSIGNED", 
  "SIZE", "DECL", "OPTINDEX", "PROC", 
  "OPTBLOCK", "FORMALLIST", "RESTOFFORMAL", "FORMAL", 
  "IDENTLIST", "RESTOFIDENTLIST", "OPTFORMAL", "STATEMENT", 
  "SS", "IF", "OPTELSE", "WHILE", 
  "FOR", "SIMPLE", "PARAMLIST", "RESTOFPARAMLIST", 
  "OPTCOMMA", "VARIABLE", "ADDR", "PARAM", 
  "BOOLEXPR", "RESTOFBOOLTERM", "BOOLTERM", "RESTOFBOOLFACTOR", 
  "BOOLFACTOR", "OPTNOT", "OPTSEMI", "RELATION", 
  "RESTOFRELATION", "EXPR", "RESTOFEXPR", "SUM", 
  "OPTADDOP", "RESTOFSUM", "TERM", "RESTOFTERM", 
  "OROP", "RELOP", "SHIFTOP", "ADDOP", 
  "MULOP", "FACTOR", "NUMBER", 
};
#endif /* DEBUG_PARSER */

int phrase_start[MAX_PHRASE-MAX_BIP] = {
    0,     6,    11,    16,    22,    28,    33,    37,    43,    47,    57, 
   68,    75,    83,    87,    91,    96,   105,   111,   125,   129,   134,   140,   153,   157,   163,   167, 
  171,   186,   195,   200,   208,   221,   235,   239,   244,   248,   259,   264,   269,   273,   279,   283, 
  289,   293,   297,   301,   305,   310,   314,   320,   325,   329,   335,   339,   345,   350,   369,   376, 
  381,   386,   406, 
};

#define P_IDENT 512
#define P_NUM 513
#define P_HEXNUM 514
#define P_CHARLIT 515
#define P_STRING 516
#define P_PROGRAM 517
#define P_OPTGLOBAL 518
#define P_OPTPROC 519
#define P_MAINBLOCK 520
#define P_BLOCK 521
#define P_SSLIST 522
#define P_OPTLOCAL 523
#define P_RESTOFDECL 524
#define P_DIRECTIVE 525
#define P_COMMAND 526
#define P_DEFN 527
#define P_GLOBAL 528
#define P_LOCAL 529
#define P_TYPE 530
#define P_OPTUNSIGNED 531
#define P_SIZE 532
#define P_DECL 533
#define P_OPTINDEX 534
#define P_PROC 535
#define P_OPTBLOCK 536
#define P_FORMALLIST 537
#define P_RESTOFFORMAL 538
#define P_FORMAL 539
#define P_IDENTLIST 540
#define P_RESTOFIDENTLIST 541
#define P_OPTFORMAL 542
#define P_STATEMENT 543
#define P_SS 544
#define P_IF 545
#define P_OPTELSE 546
#define P_WHILE 547
#define P_FOR 548
#define P_SIMPLE 549
#define P_PARAMLIST 550
#define P_RESTOFPARAMLIST 551
#define P_OPTCOMMA 552
#define P_VARIABLE 553
#define P_ADDR 554
#define P_PARAM 555
#define P_BOOLEXPR 556
#define P_RESTOFBOOLTERM 557
#define P_BOOLTERM 558
#define P_RESTOFBOOLFACTOR 559
#define P_BOOLFACTOR 560
#define P_OPTNOT 561
#define P_OPTSEMI 562
#define P_RELATION 563
#define P_RESTOFRELATION 564
#define P_EXPR 565
#define P_RESTOFEXPR 566
#define P_SUM 567
#define P_OPTADDOP 568
#define P_RESTOFSUM 569
#define P_TERM 570
#define P_RESTOFTERM 571
#define P_OROP 572
#define P_RELOP 573
#define P_SHIFTOP 574
#define P_ADDOP 575
#define P_MULOP 576
#define P_FACTOR 577
#define P_NUMBER 578