// This file is regenerated on every build.  It builds the concrete syntax tree, embedding code from the grammar file.
// To be honest the whole parse/cst/ast thing is a bit muddled and at a minimum needs to be documented if indeed not rewritten.
// Note that the code in a .g file can only walk the CST.  A user-built AST can be expected to have a totally different structure
// from the grammar, so embedding code in the grammar to walk the AST make no sense.

#define X_AST 1
//\\ B<EOF> = 0;
//\\#
//\\ P<begin-arguments> =
   case G_begin_arguments:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // left bracket

#endif
                                    //\\    "(";
     T[++phrases] = kw(CST(P++), "(");
     return T[0] = G_mktuple(G_begin_arguments, alt, phrases, T);

//\\ P<end-arguments> =
   case G_end_arguments:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // right bracket

#endif
                                    //\\    ")";
     T[++phrases] = kw(CST(P++), ")");
     return T[0] = G_mktuple(G_end_arguments, alt, phrases, T);

//\\ P<begin-array> =
   case G_begin_array:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // left square bracket

#endif
                                    //\\    "[";
     T[++phrases] = kw(CST(P++), "[");
     return T[0] = G_mktuple(G_begin_array, alt, phrases, T);

//\\ P<end-array> =
   case G_end_array:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // right square bracket

#endif
                                    //\\    "]";
     T[++phrases] = kw(CST(P++), "]");
     return T[0] = G_mktuple(G_end_array, alt, phrases, T);

//\\ P<begin-scope> =
   case G_begin_scope:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // left curly bracket

#endif
                                    //\\    "{";
     T[++phrases] = kw(CST(P++), "{");
     return T[0] = G_mktuple(G_begin_scope, alt, phrases, T);

//\\ P<end-scope> =
   case G_end_scope:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // right curly bracket

#endif
                                    //\\    "}";
     T[++phrases] = kw(CST(P++), "}");
     return T[0] = G_mktuple(G_end_scope, alt, phrases, T);

//\\ P<value-separator> =
   case G_value_separator:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // comma

#endif
                                    //\\    ",";
     T[++phrases] = kw(CST(P++), ",");
     return T[0] = G_mktuple(G_value_separator, alt, phrases, T);

//\\ P<object-separator> =
   case G_object_separator:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // semicolon

#endif
                                    //\\    ";";
     T[++phrases] = kw(CST(P++), ";");
     return T[0] = G_mktuple(G_object_separator, alt, phrases, T);

//\\ P<name-separator> =
   case G_name_separator:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // equals sign

#endif
                                    //\\    "=";
     T[++phrases] = kw(CST(P++), "=");
     return T[0] = G_mktuple(G_name_separator, alt, phrases, T);

//\\ P<array> =
   case G_array:
#if defined(NOT_SURE) || defined(BUILDING_CST)

  // Vector, e.g. [ 1.0, 2, 0 ]
  // Matrix: array of vectors, e.g. [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [15.0, 20.0, 5.0, 1]]

#endif
                                    //\\    <begin_array> <value_list> <end_array>;
     T[++phrases] = build_ast(CST(P++) /* G_begin_array */);
     T[++phrases] = build_ast(CST(P++) /* G_value_list */);
     T[++phrases] = build_ast(CST(P++) /* G_end_array */);
     return T[0] = G_mktuple(G_array, alt, phrases, T);

//\\ P<opt-sign> =
   case G_opt_sign:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    "-",
       T[++phrases] = kw(CST(P++), "-");
     } else                      {  //\\    ;
     }
     return T[0] = G_mktuple(G_opt_sign, alt, phrases, T);

//\\ P<number> =
   case G_number:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    <opt_sign> <float>,
       T[++phrases] = build_ast(CST(P++) /* G_opt_sign */);
       T[++phrases] = build_ast(CST(P++) /* G_float */);
     } else                      {  //\\    <opt_sign> <integer>;
       T[++phrases] = build_ast(CST(P++) /* G_opt_sign */);
       T[++phrases] = build_ast(CST(P++) /* G_integer */);
     }
     return T[0] = G_mktuple(G_number, alt, phrases, T);

//\\ P<value> =
   case G_value:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    "true",
       T[++phrases] = kw(CST(P++), "true");
     } else if (alt == 1)        {  //\\    "false",
       T[++phrases] = kw(CST(P++), "false");
     } else if (alt == 2)        {  //\\    "undef",
       T[++phrases] = kw(CST(P++), "undef");
     } else if (alt == 3)        {  //\\    <array>,
       T[++phrases] = build_ast(CST(P++) /* G_array */);
     } else if (alt == 4)        {  //\\    <number>,
       T[++phrases] = build_ast(CST(P++) /* G_number */);
     } else if (alt == 5)        {  //\\    <instruction>,
       T[++phrases] = build_ast(CST(P++) /* G_instruction */);
     } else if (alt == 6)        {  //\\    <name>,
       T[++phrases] = build_ast(CST(P++) /* G_name */);
     } else                      {  //\\    <string>;
       T[++phrases] = build_ast(CST(P++) /* G_string */);
     }
     return T[0] = G_mktuple(G_value, alt, phrases, T);

//\\ P<rest-of-value-list> =
   case G_rest_of_value_list:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    <value_separator> <value> <rest_of_value_list>,
       T[++phrases] = build_ast(CST(P++) /* G_value_separator */);
       T[++phrases] = build_ast(CST(P++) /* G_value */);
       T[++phrases] = build_ast(CST(P++) /* G_rest_of_value_list */);
     } else                      {  //\\    ;
     }
     return T[0] = G_mktuple(G_rest_of_value_list, alt, phrases, T);

//\\ P<value-list> =
   case G_value_list:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    <value> <rest_of_value_list>;
     T[++phrases] = build_ast(CST(P++) /* G_value */);
     T[++phrases] = build_ast(CST(P++) /* G_rest_of_value_list */);
     return T[0] = G_mktuple(G_value_list, alt, phrases, T);

//\\ P<quote> =
   case G_quote:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    «"»;
     T[++phrases] = reg(CST(P++), "\"");
     return T[0] = G_mktuple(G_quote, alt, phrases, T);

//\\ P<escaped-char> =
   case G_escaped_char:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    «\.»;
     T[++phrases] = reg(CST(P++), "\\.");
     return T[0] = G_mktuple(G_escaped_char, alt, phrases, T);

//\\ P<char> =
   case G_char:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    <!quote> «.»;
     T[++phrases] = -1 +(0 * P++);
     T[++phrases] = reg(CST(P++), ".");
     return T[0] = G_mktuple(G_char, alt, phrases, T);

//\\ P<chars> =
   case G_chars:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    <char> <chars>,
       T[++phrases] = build_ast(CST(P++) /* G_char */);
       T[++phrases] = build_ast(CST(P++) /* G_chars */);
     } else                      {  //\\    ;
     }
     return T[0] = G_mktuple(G_chars, alt, phrases, T);

//\\ P<string> =
   case G_string:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    <quote> <chars> <quote>;
     T[++phrases] = build_ast(CST(P++) /* G_quote */);
     T[++phrases] = build_ast(CST(P++) /* G_chars */);
     T[++phrases] = build_ast(CST(P++) /* G_quote */);
     return T[0] = G_mktuple(G_string, alt, phrases, T);

//\\ P<name> =
   case G_name:
#if defined(NOT_SURE) || defined(BUILDING_CST)

/*
  int i;
  int Literal = P(1);
  fwprintf(stderr, L"*** NAME = ");
  for (i = atom(Literal).start; i < atom(Literal).end; i++) fwprintf(stderr, L"%lc", source(i).ch);
  fwprintf(stderr, L"\n");
  fwprintf(stdout, L"*** NAME = ");
  for (i = atom(Literal).start; i < atom(Literal).end; i++) fwprintf(stdout, L"%lc", source(i).ch);
  fwprintf(stdout, L"\n");
  */

#endif
                                    //\\    «[A-Za-z\$][A-Za-z0-9_]*»;
     T[++phrases] = reg(CST(P++), "[A-Za-z\\$][A-Za-z0-9_]*");
     return T[0] = G_mktuple(G_name, alt, phrases, T);

//\\ P<opt-exponent> =
   case G_opt_exponent:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    «[Ee]» <opt_sign> <integer>,
       T[++phrases] = reg(CST(P++), "[Ee]");
       T[++phrases] = build_ast(CST(P++) /* G_opt_sign */);
       T[++phrases] = build_ast(CST(P++) /* G_integer */);
     } else                      {  //\\    ;
     }
     return T[0] = G_mktuple(G_opt_exponent, alt, phrases, T);

//\\ P<opt-integer> =
   case G_opt_integer:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    <integer>,
       T[++phrases] = build_ast(CST(P++) /* G_integer */);
     } else                      {  //\\    ;
     }
     return T[0] = G_mktuple(G_opt_integer, alt, phrases, T);

//\\ P<decimal-part> =
   case G_decimal_part:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    «[0-9][0-9]*»;
     T[++phrases] = reg(CST(P++), "[0-9][0-9]*");
     return T[0] = G_mktuple(G_decimal_part, alt, phrases, T);

//\\ P<float> =
   case G_float:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    <opt_integer> «\.» <decimal_part> <opt_exponent>;
     T[++phrases] = build_ast(CST(P++) /* G_opt_integer */);
     T[++phrases] = reg(CST(P++), "\\.");
     T[++phrases] = build_ast(CST(P++) /* G_decimal_part */);
     T[++phrases] = build_ast(CST(P++) /* G_opt_exponent */);
     return T[0] = G_mktuple(G_float, alt, phrases, T);

//\\ P<integer> =
   case G_integer:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    «[0-9][0-9]*»;
     T[++phrases] = reg(CST(P++), "[0-9][0-9]*");
     return T[0] = G_mktuple(G_integer, alt, phrases, T);

//\\ P<instruction-list> =
   case G_instruction_list:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    <instruction> <instruction_list>,
       T[++phrases] = build_ast(CST(P++) /* G_instruction */);
       T[++phrases] = build_ast(CST(P++) /* G_instruction_list */);
     } else                      {  //\\    ;
     }
     return T[0] = G_mktuple(G_instruction_list, alt, phrases, T);

//\\ P<opt-block> =
   case G_opt_block:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    <begin_scope> <instruction_list> <end_scope>,
       T[++phrases] = build_ast(CST(P++) /* G_begin_scope */);
       T[++phrases] = build_ast(CST(P++) /* G_instruction_list */);
       T[++phrases] = build_ast(CST(P++) /* G_end_scope */);
     } else                      {  //\\    <object_separator>;
       T[++phrases] = build_ast(CST(P++) /* G_object_separator */);
     }
     return T[0] = G_mktuple(G_opt_block, alt, phrases, T);

//\\ P<argument> =
   case G_argument:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    <name> <name_separator> <value>,
       T[++phrases] = build_ast(CST(P++) /* G_name */);
       T[++phrases] = build_ast(CST(P++) /* G_name_separator */);
       T[++phrases] = build_ast(CST(P++) /* G_value */);
     } else                      {  //\\    <value>;
       T[++phrases] = build_ast(CST(P++) /* G_value */);
     }
     return T[0] = G_mktuple(G_argument, alt, phrases, T);

//\\ P<rest-of-argument-list> =
   case G_rest_of_argument_list:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    <value_separator> <argument> <rest_of_argument_list>,
       T[++phrases] = build_ast(CST(P++) /* G_value_separator */);
       T[++phrases] = build_ast(CST(P++) /* G_argument */);
       T[++phrases] = build_ast(CST(P++) /* G_rest_of_argument_list */);
     } else                      {  //\\    ;
     }
     return T[0] = G_mktuple(G_rest_of_argument_list, alt, phrases, T);

//\\ P<opt-argument-list> =
   case G_opt_argument_list:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
     if (alt == 0)               {  //\\    <argument> <rest_of_argument_list>,
       T[++phrases] = build_ast(CST(P++) /* G_argument */);
       T[++phrases] = build_ast(CST(P++) /* G_rest_of_argument_list */);
     } else                      {  //\\    ;
     }
     return T[0] = G_mktuple(G_opt_argument_list, alt, phrases, T);

//\\ P<instruction> =
   case G_instruction:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    <name> <begin_arguments> <opt_argument_list> <end_arguments> <opt_block>;
     T[++phrases] = build_ast(CST(P++) /* G_name */);
     T[++phrases] = build_ast(CST(P++) /* G_begin_arguments */);
     T[++phrases] = build_ast(CST(P++) /* G_opt_argument_list */);
     T[++phrases] = build_ast(CST(P++) /* G_end_arguments */);
     T[++phrases] = build_ast(CST(P++) /* G_opt_block */);
     return T[0] = G_mktuple(G_instruction, alt, phrases, T);

//\\ P<SS> =
   case G_SS:
#if defined(NOT_SURE) || defined(BUILDING_CST)


#endif
                                    //\\    <instruction_list> <EOF>;
     T[++phrases] = build_ast(CST(P++) /* G_instruction_list */);
     T[++phrases] = BIP(CST(P++), B_EOF);
     return T[0] = G_mktuple(G_SS, alt, phrases, T);

//\\ E
