
#ifdef YY_QUERY_API_VER
#define YY_BYACCIC
#define YY_API_MAJOR 1
#define YY_API_MINOR 0
#endif /*YY_QUERY_API_VER*/

#define sch_bxl_EMPTY        (-1)
#define sch_bxl_clearin      (sch_bxl_chr = sch_bxl_EMPTY)
#define sch_bxl_errok        (sch_bxl_errflag = 0)
#define sch_bxl_RECOVERING() (sch_bxl_errflag != 0)
#define sch_bxl_ENOMEM       (-2)
#define sch_bxl_EOF          0
#line 16 "../plugins/io_bxl/bxl_gram.c"
#include "../plugins/io_bxl/bxl_gram.h"
static const sch_bxl_int_t sch_bxl_lhs[] = {                     -1,
    0,    5,    5,    6,    6,    6,    3,    3,    7,    7,
    4,    4,    1,    1,    2,   11,   11,   11,   11,   12,
   13,   15,    8,   14,   14,   16,   16,   16,   16,   16,
   19,   17,   18,   18,   20,   20,   20,   20,   20,   23,
   21,   22,   22,   24,   24,   24,   24,   27,   25,   26,
   26,   28,   28,   28,   28,   31,   29,   30,   30,   32,
   32,   32,   32,   32,   32,   35,   33,   34,   34,   36,
   36,   36,   36,   36,   36,   37,   39,   38,   38,   40,
   40,   40,   43,   45,   46,   41,   42,   42,   47,   47,
   47,   47,   47,   47,   44,   44,   48,   48,   48,   48,
   48,   50,    9,   49,   49,   51,   51,   51,   52,   53,
   53,   54,   54,   54,   54,   54,   54,   54,   55,   10,
   56,   10,   57,   10,
};
static const sch_bxl_int_t sch_bxl_len[] = {                      2,
    2,    0,    3,    1,    1,    1,    1,    1,    1,    2,
    0,    1,    1,    1,    1,    2,    2,    2,    2,    4,
    2,    0,    4,    0,    4,    2,    2,    2,    2,    2,
    0,    3,    0,    4,    2,    3,    1,    1,    1,    0,
    3,    0,    4,    4,    1,    1,    1,    0,    3,    0,
    4,    3,    1,    1,    1,    0,    3,    0,    4,    2,
    2,    2,    1,    1,    1,    0,    3,    0,    4,    2,
    2,    2,    1,    1,    1,    2,    2,    0,    4,    2,
    2,    1,    0,    0,    0,   23,    0,    2,    4,    6,
    4,    4,    4,    4,    0,    2,    4,    4,    4,    4,
    4,    0,    6,    0,    3,    1,    6,    2,    6,    0,
    3,    1,    1,    1,    1,    1,    1,    1,    0,    4,
    0,    4,    0,    4,
};
static const sch_bxl_int_t sch_bxl_defred[] = {                   0,
    0,    0,    0,   12,   10,    0,    0,    1,    0,    4,
    5,    6,    0,    0,    0,   22,    0,    0,    0,    0,
    0,    0,  102,    3,    0,    0,    0,    0,   23,    0,
  120,  122,  124,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,  106,   13,   14,   26,   27,   28,
   29,   30,    0,    0,    0,  108,  103,    0,   25,    0,
   15,    0,  105,    0,    0,   31,   40,   48,   56,   66,
    0,   83,  113,  114,  115,  116,  117,  118,  112,    0,
    0,    0,    0,    0,    0,    0,    0,    0,   76,    0,
  109,    0,  107,    0,   32,    0,   41,    0,   49,    0,
   57,    0,   67,    0,    0,    0,   82,    0,    0,    0,
    0,  111,    0,    0,   38,    0,   37,   39,    0,    0,
   46,   45,   47,    0,    0,    0,    0,    0,    0,   55,
   53,   54,    0,    0,    0,    0,   64,   63,   65,    0,
    0,    0,    0,   75,   73,   74,    0,    0,   80,   81,
    0,    0,    0,    0,    0,    0,    0,    0,   88,   21,
   35,    0,    0,    0,    0,   17,    0,   16,    7,    8,
   19,   18,    0,   60,   61,   62,    0,   72,   70,   71,
    0,    0,   79,    0,    0,    0,    0,    0,    0,    0,
   36,   34,    0,   43,   52,   51,   59,   69,   20,   93,
    0,   92,   94,   89,   91,    0,   44,    0,    0,   90,
    0,    0,    0,    0,    0,   84,    0,    0,    0,    0,
    0,    0,    0,   96,    0,    0,    0,    0,    0,    0,
   99,  101,   98,  100,   97,    0,    0,    0,    0,    0,
    0,    0,   85,   86,
};
static const sch_bxl_int_t sch_bxl_dgoto[] = {                    2,
   61,   62,  171,    3,    8,    9,    4,   10,   11,   12,
  131,  107,  118,   29,   22,   39,   73,   95,   83,  119,
   74,   97,   84,  124,   75,   99,   85,  133,   76,  101,
   86,  140,   77,  103,   87,  147,   78,   89,    0,  108,
   79,  110,   90,  216,  223,  244,  111,  217,   43,   30,
   44,   45,   80,   81,   13,   14,   15,
};
static const sch_bxl_int_t sch_bxl_sindex[] = {                   7,
    7,    0, -250,    0,    0, -237, -224,    0,    7,    0,
    0,    0, -227, -234, -269,    0,    7, -250, -201, -195,
 -192,   35,    0,    0, -189, -190, -231, -151,    0, -244,
    0,    0,    0, -226, -226, -226, -171, -165,   55,   39,
   61, -158, -210,    7,    0,    0,    0,    0,    0,    0,
    0,    0,   35, -155, -226,    0,    0, -244,    0,    7,
    0,   63,    0, -169, -226,    0,    0,    0,    0,    0,
   68,    0,    0,    0,    0,    0,    0,    0,    0, -163,
    7,   77,   81,   82,   83,   88,   91, -282,    0,   93,
    0, -169,    0, -247,    0, -213,    0, -248,    0, -255,
    0, -238,    0, -226, -126, -125,    0,   96, -194,    7,
   93,    0, -226, -120,    0,   97,    0,    0,  101, -226,
    0,    0,    0,  102, -116, -115, -110, -174, -109,    0,
    0,    0,  109, -226, -226, -226,    0,    0,    0,  111,
 -226, -107, -174,    0,    0,    0,  113,  112,    0,    0,
   68, -103, -226, -101, -174, -100, -226, -161,    0,    0,
    0, -226,   81,  116,   82,    0,  -99,    0,    0,    0,
    0,    0,   83,    0,    0,    0,   88,    0,    0,    0,
   91, -226,    0,  121,  119,  123,  124,  125,  126,  -92,
    0,    0, -226,    0,    0,    0,    0,    0,    0,    0,
 -226,    0,    0,    0,    0,  129,    0,  130, -226,    0,
  128, -226,  132,  134, -228,    0,  134,  -90, -226,  -81,
 -174,  -82,    7,    0,  138,  139,  140,  141,  142, -105,
    0,    0,    0,    0,    0,  -75,  146, -226,  143, -226,
  148,  134,    0,    0,
};
static const sch_bxl_int_t sch_bxl_rindex[] = {                   9,
    1,    0,    6,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    6,    0,    0,
    0,  180,    0,    0,    0,    0,    0,    0,    0, -124,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,  180,    0,    0,    0,    0, -124,    0,    0,
    0,    0,    0,  -89,    0,    0,    0,    0,    0,    0,
  181,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,  183,  185,  186,  187,  188,    0,    0,  189,
    0,  -89,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  189,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  181,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,  183,    0,  185,    0,    0,    0,    0,    0,
    0,    0,  186,    0,    0,    0,  187,    0,    0,    0,
  188,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,  190,    0,    0,  190,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,  190,    0,    0,
};
static const sch_bxl_int_t sch_bxl_gindex[] = {                   0,
  -31,  -63, -136,    0,  184,    0,   -1,    0,    0,    0,
   99,  -76,  -66,  150,    0,    0,    0,   41,    0,    0,
    0,   40,    0,    0,    0,   33,    0,    0,    0,   30,
    0,    0,    0,   27,    0,    0,    0,   58,    0,    0,
    0,  100,    0, -203,    0,    0,    0,    0,  152,    0,
    0,    0,  120,    0,    0,    0,    0,
};
#define sch_bxl_TABLESIZE 331
static const sch_bxl_int_t sch_bxl_table[] = {                    5,
    9,   82,   48,   49,   50,    2,  180,   18,   11,  104,
   46,   47,    6,  224,  125,   23,    1,  117,  187,  122,
  113,  132,   16,  138,  125,  146,  105,  106,  113,  123,
  116,   46,   47,  139,  218,   17,  104,   40,  243,   41,
  148,   19,   58,  104,  104,   20,  134,  135,  136,  160,
  126,  127,   21,  104,   25,  141,  164,  128,   64,  114,
   26,  127,  113,   27,    7,  219,  142,  128,  137,   42,
  174,  220,  129,  143,   28,  130,  115,  221,  104,   92,
   31,  152,  129,  120,  228,  144,  169,  170,   51,  185,
   32,   33,  222,  189,   52,   53,   54,  153,  191,  154,
   55,   56,   60,  175,  176,   57,   65,   88,  158,  178,
  121,  155,   34,   35,   36,   37,   38,   93,  199,   91,
   94,   96,   98,  156,  157,   66,   67,  100,   68,  207,
  102,   69,  109,  149,  150,   70,  151,  208,   71,  161,
  162,  163,  165,  166,  167,  211,  168,   72,  213,  173,
  172,  177,  179,  181,  184,  182,  186,  188,  190,  193,
  195,  200,  201,  202,  203,  204,  205,  206,  209,  225,
  210,  212,  214,  215,  239,  227,  241,  229,  231,  232,
  233,  234,  235,  236,  237,  238,  240,  226,  242,   24,
   78,  104,   33,  110,   42,   50,   58,   68,   87,   95,
  145,   24,   59,  192,  194,  196,  197,  198,  183,   63,
  159,  112,    0,    0,    0,    0,    0,    0,    0,    0,
    0,  230,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    9,    0,    0,    0,    0,    0,    9,
    0,   11,    0,    0,  119,    0,    0,   11,    0,    0,
    9,    0,    9,    9,    9,  121,    0,    0,   11,    9,
    0,    0,    0,    0,    0,    9,    9,    0,    9,    0,
    0,    9,    0,    0,    0,    9,    0,    0,    9,    0,
    0,    0,    0,    0,    9,    9,    9,    9,    0,    0,
    9,    0,    9,   11,    0,    0,    0,  123,    0,    0,
   11,
};
static const sch_bxl_int_t sch_bxl_check[] = {                    1,
    0,   65,   34,   35,   36,    0,  143,    9,    0,  292,
  258,  259,  263,  217,  263,   17,   10,   94,  155,   96,
  276,   98,  260,  100,  263,  102,  309,  310,  276,   96,
   94,  258,  259,  100,  263,  260,  292,  282,  242,  284,
  104,  269,   44,  292,  292,  280,  302,  303,  304,  113,
  299,  300,  322,  292,  256,  294,  120,  306,   60,  307,
  256,  300,  276,  256,  315,  294,  305,  306,  324,  314,
  134,  300,  321,  312,   40,  324,  324,  306,  292,   81,
  270,  276,  321,  297,  221,  324,  261,  262,  260,  153,
  281,  323,  321,  157,  260,   41,   58,  292,  162,  294,
   40,  260,  258,  135,  136,  316,   44,   40,  110,  141,
  324,  306,  264,  265,  266,  267,  268,   41,  182,  283,
   40,   40,   40,  318,  319,  295,  296,   40,  298,  193,
   40,  301,   40,  260,  260,  305,   41,  201,  308,  260,
   44,   41,   41,  260,  260,  209,  257,  317,  212,   41,
  260,   41,  260,   41,  258,   44,  258,  258,  320,   44,
  260,   41,   44,   41,   41,   41,   41,  260,   40,  260,
   41,   44,   41,   40,  238,  257,  240,  260,   41,   41,
   41,   41,   41,  289,  260,   40,   44,  219,   41,   10,
   10,  316,   10,  283,   10,   10,   10,   10,   10,   10,
  102,   18,   53,  163,  165,  173,  177,  181,  151,   58,
  111,   92,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,  223,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,  263,   -1,   -1,   -1,   -1,   -1,  269,
   -1,  263,   -1,   -1,  269,   -1,   -1,  269,   -1,   -1,
  280,   -1,  282,  283,  284,  280,   -1,   -1,  280,  289,
   -1,   -1,   -1,   -1,   -1,  295,  296,   -1,  298,   -1,
   -1,  301,   -1,   -1,   -1,  305,   -1,   -1,  308,   -1,
   -1,   -1,   -1,   -1,  314,  315,  316,  317,   -1,   -1,
  320,   -1,  322,  315,   -1,   -1,   -1,  322,   -1,   -1,
  322,
};
#define sch_bxl_FINAL 2
#define sch_bxl_MAXTOKEN 324
#define sch_bxl_UNDFTOKEN 384
#define sch_bxl_TRANSLATE(a) ((a) > sch_bxl_MAXTOKEN ? sch_bxl_UNDFTOKEN : (a))
#if sch_bxl_DEBUG
static const char *const sch_bxl_name[] = {

"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"T_ID",
"T_INTEGER","T_REAL_ONLY","T_QSTR","T_TRUE","T_FALSE","T_TEXTSTYLE",
"T_FONTWIDTH","T_FONTCHARWIDTH","T_FONTHEIGHT","T_FONTFAMILY","T_FONTFACE",
"T_PADSTACK","T_ENDPADSTACK","T_SHAPES","T_PADSHAPE","T_HOLEDIAM","T_SURFACE",
"T_PLATED","T_WIDTH","T_HEIGHT","T_PADTYPE","T_LAYER","T_PATTERN",
"T_ENDPATTERN","T_DATA","T_ENDDATA","T_ORIGINPOINT","T_PICKPOINT","T_GLUEPOINT",
"T_PAD","T_NUMBER","T_PINNAME","T_PADSTYLE","T_ORIGINALPADSTYLE","T_ORIGIN",
"T_ORIGINALPINNUMBER","T_ROTATE","T_POLY","T_LINE","T_ENDPOINT","T_ATTRIBUTE",
"T_ATTR","T_JUSTIFY","T_ARC","T_RADIUS","T_STARTANGLE","T_SWEEPANGLE","T_TEXT",
"T_ISVISIBLE","T_PROPERTY","T_WIZARD","T_VARNAME","T_VARDATA","T_TEMPLATEDATA",
"T_ISFLIPPED","T_NOPASTE","T_ORIGINALNAME","T_SYMBOL","T_ENDSYMBOL","T_PIN",
"T_PINNUM","T_PINLENGTH","T_PINDES","T_TEXTSTYLEREF","T_COMPONENT",
"T_ENDCOMPONENT","common_layer",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
"illegal-symbol",
};
static const char *const sch_bxl_rule[] = {
"$accept : full_file",
"full_file : maybe_nl file",
"file :",
"file : statement nl file",
"statement : text_style",
"statement : symbol",
"statement : boring_section",
"boolean : T_TRUE",
"boolean : T_FALSE",
"nl : '\\n'",
"nl : '\\n' nl",
"maybe_nl :",
"maybe_nl : nl",
"real : T_INTEGER",
"real : T_REAL_ONLY",
"coord : real",
"common_attr_text : T_JUSTIFY T_ID",
"common_attr_text : T_TEXTSTYLE T_QSTR",
"common_attr_text : T_TEXTSTYLEREF T_QSTR",
"common_attr_text : T_ISVISIBLE boolean",
"common_origin : T_ORIGIN coord ',' coord",
"common_width : T_WIDTH coord",
"$$1 :",
"text_style : T_TEXTSTYLE T_QSTR $$1 text_style_attrs",
"text_style_attrs :",
"text_style_attrs : '(' text_style_attr ')' text_style_attrs",
"text_style_attr : T_FONTWIDTH real",
"text_style_attr : T_FONTCHARWIDTH real",
"text_style_attr : T_FONTHEIGHT real",
"text_style_attr : T_FONTFAMILY T_QSTR",
"text_style_attr : T_FONTFACE T_QSTR",
"$$2 :",
"poly : T_POLY $$2 poly_attrs",
"poly_attrs :",
"poly_attrs : '(' poly_attr ')' poly_attrs",
"poly_attr : T_PROPERTY T_QSTR",
"poly_attr : coord ',' coord",
"poly_attr : common_origin",
"poly_attr : common_layer",
"poly_attr : common_width",
"$$3 :",
"line : T_LINE $$3 line_attrs",
"line_attrs :",
"line_attrs : '(' line_attr ')' line_attrs",
"line_attr : T_ENDPOINT coord ',' coord",
"line_attr : common_origin",
"line_attr : common_layer",
"line_attr : common_width",
"$$4 :",
"attribute : T_ATTRIBUTE $$4 attribute_attrs",
"attribute_attrs :",
"attribute_attrs : '(' attribute_attr ')' attribute_attrs",
"attribute_attr : T_ATTR T_QSTR T_QSTR",
"attribute_attr : common_attr_text",
"attribute_attr : common_origin",
"attribute_attr : common_layer",
"$$5 :",
"arc : T_ARC $$5 arc_attrs",
"arc_attrs :",
"arc_attrs : '(' arc_attr ')' arc_attrs",
"arc_attr : T_RADIUS coord",
"arc_attr : T_STARTANGLE real",
"arc_attr : T_SWEEPANGLE real",
"arc_attr : common_origin",
"arc_attr : common_layer",
"arc_attr : common_width",
"$$6 :",
"text : T_TEXT $$6 text_attrs",
"text_attrs :",
"text_attrs : '(' text_attr ')' text_attrs",
"text_attr : T_TEXT T_QSTR",
"text_attr : T_ISFLIPPED boolean",
"text_attr : T_ROTATE real",
"text_attr : common_attr_text",
"text_attr : common_origin",
"text_attr : common_layer",
"wizard : T_WIZARD wizard_attrs",
"templatedata : T_TEMPLATEDATA wizard_attrs",
"wizard_attrs :",
"wizard_attrs : '(' wizard_attr ')' wizard_attrs",
"wizard_attr : T_VARNAME T_QSTR",
"wizard_attr : T_VARDATA T_QSTR",
"wizard_attr : common_origin",
"$$7 :",
"$$8 :",
"$$9 :",
"pin : T_PIN $$7 pin_fields nl T_PINDES T_QSTR '(' coord ',' coord ')' pintext_fields $$8 nl T_PINNAME T_QSTR '(' coord ',' coord ')' pintext_fields $$9",
"pin_fields :",
"pin_fields : pin_field pin_fields",
"pin_field : '(' T_PINNUM T_INTEGER ')'",
"pin_field : '(' T_ORIGIN coord ',' coord ')'",
"pin_field : '(' T_PINLENGTH coord ')'",
"pin_field : '(' T_ROTATE T_INTEGER ')'",
"pin_field : '(' T_WIDTH T_INTEGER ')'",
"pin_field : '(' T_ISVISIBLE boolean ')'",
"pintext_fields :",
"pintext_fields : pintext_field pintext_fields",
"pintext_field : '(' T_TEXTSTYLEREF T_QSTR ')'",
"pintext_field : '(' T_JUSTIFY T_ID ')'",
"pintext_field : '(' T_TEXTSTYLE T_QSTR ')'",
"pintext_field : '(' T_ISVISIBLE boolean ')'",
"pintext_field : '(' T_ROTATE real ')'",
"$$10 :",
"symbol : T_SYMBOL T_QSTR nl $$10 symbol_chldrn T_ENDSYMBOL",
"symbol_chldrn :",
"symbol_chldrn : symbol_chld nl symbol_chldrn",
"symbol_chld : data",
"symbol_chld : T_ORIGINPOINT '(' coord ',' coord ')'",
"symbol_chld : T_ORIGINALNAME T_QSTR",
"data : T_DATA ':' T_INTEGER nl data_chldrn T_ENDDATA",
"data_chldrn :",
"data_chldrn : data_chld nl data_chldrn",
"data_chld : pin",
"data_chld : poly",
"data_chld : line",
"data_chld : attribute",
"data_chld : arc",
"data_chld : text",
"data_chld : wizard",
"$$11 :",
"boring_section : $$11 T_PADSTACK error T_ENDPADSTACK",
"$$12 :",
"boring_section : $$12 T_PATTERN error T_ENDPATTERN",
"$$13 :",
"boring_section : $$13 T_COMPONENT error T_ENDCOMPONENT",

};
#endif


#if sch_bxl_DEBUG
#include <stdio.h> /* needed for printf */
#endif

#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */

/* allocate initial stack or double stack size, up to yyctx->stack_max_depth */
static int sch_bxl_growstack(sch_bxl_yyctx_t *yyctx, sch_bxl_STACKDATA *data)
{
	int i;
	unsigned newsize;
	sch_bxl_int_t *newss;
	sch_bxl_STYPE *newvs;

	if ((newsize = data->stacksize) == 0)
		newsize = sch_bxl_INITSTACKSIZE;
	else if (newsize >= yyctx->stack_max_depth)
		return sch_bxl_ENOMEM;
	else if ((newsize *= 2) > yyctx->stack_max_depth)
		newsize = yyctx->stack_max_depth;

	i = (int)(data->s_mark - data->s_base);
	newss = (sch_bxl_int_t *) realloc(data->s_base, newsize * sizeof(*newss));
	if (newss == 0)
		return sch_bxl_ENOMEM;

	data->s_base = newss;
	data->s_mark = newss + i;

	newvs = (sch_bxl_STYPE *) realloc(data->l_base, newsize * sizeof(*newvs));
	if (newvs == 0)
		return sch_bxl_ENOMEM;

	data->l_base = newvs;
	data->l_mark = newvs + i;

	data->stacksize = newsize;
	data->s_last = data->s_base + newsize - 1;
	return 0;
}

static void sch_bxl_freestack(sch_bxl_STACKDATA *data)
{
	free(data->s_base);
	free(data->l_base);
	memset(data, 0, sizeof(*data));
}

#define sch_bxl_ABORT  goto yyabort
#define sch_bxl_REJECT goto yyabort
#define sch_bxl_ACCEPT goto yyaccept
#define sch_bxl_ERROR  goto yyerrlab

int sch_bxl_parse_init(sch_bxl_yyctx_t *yyctx)
{
#if sch_bxl_DEBUG
	const char *yys;

	if ((yys = getenv("sch_bxl_DEBUG")) != 0) {
		yyctx->yyn = *yys;
		if (yyctx->yyn >= '0' && yyctx->yyn <= '9')
			yyctx->debug = yyctx->yyn - '0';
	}
#endif

	memset(&yyctx->val, 0, sizeof(yyctx->val));
	memset(&yyctx->lval, 0, sizeof(yyctx->lval));

	yyctx->yym = 0;
	yyctx->yyn = 0;
	yyctx->nerrs = 0;
	yyctx->errflag = 0;
	yyctx->chr = sch_bxl_EMPTY;
	yyctx->state = 0;

	memset(&yyctx->stack, 0, sizeof(yyctx->stack));

	yyctx->stack_max_depth = sch_bxl_INITSTACKSIZE > 10000 ? sch_bxl_INITSTACKSIZE : 10000;
	if (yyctx->stack.s_base == NULL && sch_bxl_growstack(yyctx, &yyctx->stack) == sch_bxl_ENOMEM)
		return -1;
	yyctx->stack.s_mark = yyctx->stack.s_base;
	yyctx->stack.l_mark = yyctx->stack.l_base;
	yyctx->state = 0;
	*yyctx->stack.s_mark = 0;
	yyctx->jump = 0;
	return 0;
}


#define sch_bxl_GETCHAR(labidx) \
do { \
	if (used)               { yyctx->jump = labidx; return sch_bxl_RES_NEXT; } \
	getchar_ ## labidx:;    yyctx->chr = tok; yyctx->lval = *lval; used = 1; \
} while(0)

sch_bxl_res_t sch_bxl_parse(sch_bxl_yyctx_t *yyctx, sch_bxl_ctx_t *ctx, int tok, sch_bxl_STYPE *lval)
{
	int used = 0;
#if sch_bxl_DEBUG
	const char *yys;
#endif

yyloop:;
	if (yyctx->jump == 1) { yyctx->jump = 0; goto getchar_1; }
	if (yyctx->jump == 2) { yyctx->jump = 0; goto getchar_2; }

	if ((yyctx->yyn = sch_bxl_defred[yyctx->state]) != 0)
		goto yyreduce;
	if (yyctx->chr < 0) {
		sch_bxl_GETCHAR(1);
		if (yyctx->chr < 0)
			yyctx->chr = sch_bxl_EOF;
#if sch_bxl_DEBUG
		if (yyctx->debug) {
			if ((yys = sch_bxl_name[sch_bxl_TRANSLATE(yyctx->chr)]) == NULL)
				yys = sch_bxl_name[sch_bxl_UNDFTOKEN];
			printf("yyctx->debug: state %d, reading %d (%s)\n", yyctx->state, yyctx->chr, yys);
		}
#endif
	}
	if (((yyctx->yyn = sch_bxl_sindex[yyctx->state]) != 0) && (yyctx->yyn += yyctx->chr) >= 0 && yyctx->yyn <= sch_bxl_TABLESIZE && sch_bxl_check[yyctx->yyn] == (sch_bxl_int_t) yyctx->chr) {
#if sch_bxl_DEBUG
		if (yyctx->debug)
			printf("yyctx->debug: state %d, shifting to state %d\n", yyctx->state, sch_bxl_table[yyctx->yyn]);
#endif
		if (yyctx->stack.s_mark >= yyctx->stack.s_last && sch_bxl_growstack(yyctx, &yyctx->stack) == sch_bxl_ENOMEM)
			goto yyoverflow;
		yyctx->state = sch_bxl_table[yyctx->yyn];
		*++yyctx->stack.s_mark = sch_bxl_table[yyctx->yyn];
		*++yyctx->stack.l_mark = yyctx->lval;
		yyctx->chr = sch_bxl_EMPTY;
		if (yyctx->errflag > 0)
			--yyctx->errflag;
		goto yyloop;
	}
	if (((yyctx->yyn = sch_bxl_rindex[yyctx->state]) != 0) && (yyctx->yyn += yyctx->chr) >= 0 && yyctx->yyn <= sch_bxl_TABLESIZE && sch_bxl_check[yyctx->yyn] == (sch_bxl_int_t) yyctx->chr) {
		yyctx->yyn = sch_bxl_table[yyctx->yyn];
		goto yyreduce;
	}
	if (yyctx->errflag != 0)
		goto yyinrecovery;

	sch_bxl_error(ctx, yyctx->lval, "syntax error");

	goto yyerrlab;	/* redundant goto avoids 'unused label' warning */
yyerrlab:
	++yyctx->nerrs;

yyinrecovery:
	if (yyctx->errflag < 3) {
		yyctx->errflag = 3;
		for(;;) {
			if (((yyctx->yyn = sch_bxl_sindex[*yyctx->stack.s_mark]) != 0) && (yyctx->yyn += sch_bxl_ERRCODE) >= 0 && yyctx->yyn <= sch_bxl_TABLESIZE && sch_bxl_check[yyctx->yyn] == (sch_bxl_int_t) sch_bxl_ERRCODE) {
#if sch_bxl_DEBUG
				if (yyctx->debug)
					printf("yyctx->debug: state %d, error recovery shifting to state %d\n", *yyctx->stack.s_mark, sch_bxl_table[yyctx->yyn]);
#endif
				if (yyctx->stack.s_mark >= yyctx->stack.s_last && sch_bxl_growstack(yyctx, &yyctx->stack) == sch_bxl_ENOMEM)
					goto yyoverflow;
				yyctx->state = sch_bxl_table[yyctx->yyn];
				*++yyctx->stack.s_mark = sch_bxl_table[yyctx->yyn];
				*++yyctx->stack.l_mark = yyctx->lval;
				goto yyloop;
			}
			else {
#if sch_bxl_DEBUG
				if (yyctx->debug)
					printf("yyctx->debug: error recovery discarding state %d\n", *yyctx->stack.s_mark);
#endif
				if (yyctx->stack.s_mark <= yyctx->stack.s_base)
					goto yyabort;
				--yyctx->stack.s_mark;
				--yyctx->stack.l_mark;
			}
		}
	}
	else {
		if (yyctx->chr == sch_bxl_EOF)
			goto yyabort;
#if sch_bxl_DEBUG
		if (yyctx->debug) {
			if ((yys = sch_bxl_name[sch_bxl_TRANSLATE(yyctx->chr)]) == NULL)
				yys = sch_bxl_name[sch_bxl_UNDFTOKEN];
			printf("yyctx->debug: state %d, error recovery discards token %d (%s)\n", yyctx->state, yyctx->chr, yys);
		}
#endif
		yyctx->chr = sch_bxl_EMPTY;
		goto yyloop;
	}

yyreduce:
#if sch_bxl_DEBUG
	if (yyctx->debug)
		printf("yyctx->debug: state %d, reducing by rule %d (%s)\n", yyctx->state, yyctx->yyn, sch_bxl_rule[yyctx->yyn]);
#endif
	yyctx->yym = sch_bxl_len[yyctx->yyn];
	if (yyctx->yym > 0)
		yyctx->val = yyctx->stack.l_mark[1 - yyctx->yym];
	else
		memset(&yyctx->val, 0, sizeof yyctx->val);

	switch (yyctx->yyn) {
case 7:
#line 102 "../plugins/io_bxl/bxl_gram.y"
	{ yyctx->val.un.i = 1; }
break;
case 8:
#line 103 "../plugins/io_bxl/bxl_gram.y"
	{ yyctx->val.un.i = 0; }
break;
case 13:
#line 117 "../plugins/io_bxl/bxl_gram.y"
	{ yyctx->val.un.d = yyctx->stack.l_mark[0].un.i; }
break;
case 14:
#line 118 "../plugins/io_bxl/bxl_gram.y"
	{ yyctx->val.un.d = yyctx->stack.l_mark[0].un.d; }
break;
case 15:
#line 122 "../plugins/io_bxl/bxl_gram.y"
	{ yyctx->val.un.c = yyctx->stack.l_mark[0].un.d; }
break;
case 16:
#line 126 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_set_justify(ctx, yyctx->stack.l_mark[0].un.s); free(yyctx->stack.l_mark[0].un.s); }
break;
case 17:
#line 127 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_set_text_style(ctx, yyctx->stack.l_mark[0].un.s); free(yyctx->stack.l_mark[0].un.s); }
break;
case 18:
#line 128 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_set_text_style_ref(ctx, yyctx->stack.l_mark[0].un.s); free(yyctx->stack.l_mark[0].un.s); }
break;
case 19:
#line 129 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.is_visible = yyctx->stack.l_mark[0].un.i; }
break;
case 20:
#line 133 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.origin_x = yyctx->stack.l_mark[-2].un.c; ctx->state.origin_y = yyctx->stack.l_mark[0].un.c; }
break;
case 21:
#line 137 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.width = yyctx->stack.l_mark[0].un.c; }
break;
case 22:
#line 143 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_text_style_begin(ctx, yyctx->stack.l_mark[0].un.s); /* $2 is taken over */ }
break;
case 23:
#line 144 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_text_style_end(ctx); }
break;
case 26:
#line 153 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.text_style->width = yyctx->stack.l_mark[0].un.d; }
break;
case 27:
#line 154 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.text_style->char_width = yyctx->stack.l_mark[0].un.d; }
break;
case 28:
#line 155 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.text_style->height = yyctx->stack.l_mark[0].un.d; }
break;
case 29:
#line 156 "../plugins/io_bxl/bxl_gram.y"
	{ free(yyctx->stack.l_mark[0].un.s); /* ignore for now */ }
break;
case 30:
#line 157 "../plugins/io_bxl/bxl_gram.y"
	{ free(yyctx->stack.l_mark[0].un.s); /* ignore for now */ }
break;
case 31:
#line 162 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_poly_begin(ctx); }
break;
case 32:
#line 163 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_poly_end(ctx); }
break;
case 35:
#line 173 "../plugins/io_bxl/bxl_gram.y"
	{ /* can't add attributes to polygons */ free(yyctx->stack.l_mark[0].un.s); }
break;
case 36:
#line 174 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_poly_add_vertex(ctx, yyctx->stack.l_mark[-2].un.c, yyctx->stack.l_mark[0].un.c); }
break;
case 40:
#line 182 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_reset(ctx); }
break;
case 41:
#line 183 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_add_line(ctx); sch_bxl_reset(ctx); }
break;
case 44:
#line 192 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.endp_x = yyctx->stack.l_mark[-2].un.c; ctx->state.endp_y = yyctx->stack.l_mark[0].un.c; }
break;
case 48:
#line 200 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_reset(ctx); ctx->state.is_text = 0; }
break;
case 49:
#line 201 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_add_text(ctx); sch_bxl_reset(ctx); }
break;
case 52:
#line 210 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_set_attr_val(ctx, yyctx->stack.l_mark[-1].un.s, yyctx->stack.l_mark[0].un.s); /* $2 and $3 are taken over */ }
break;
case 56:
#line 219 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_reset(ctx); }
break;
case 57:
#line 220 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_add_arc(ctx); sch_bxl_reset(ctx); }
break;
case 60:
#line 229 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.radius = yyctx->stack.l_mark[0].un.c;  }
break;
case 61:
#line 230 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.arc_start = yyctx->stack.l_mark[0].un.d; }
break;
case 62:
#line 231 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.arc_delta = yyctx->stack.l_mark[0].un.d; }
break;
case 66:
#line 239 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_reset(ctx); ctx->state.is_text = 1; }
break;
case 67:
#line 240 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_add_text(ctx); sch_bxl_reset(ctx); }
break;
case 70:
#line 249 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_set_text_str(ctx, yyctx->stack.l_mark[0].un.s); /* $2 is taken over */ }
break;
case 71:
#line 250 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.flipped = yyctx->stack.l_mark[0].un.i; }
break;
case 72:
#line 251 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.rot = yyctx->stack.l_mark[0].un.d; }
break;
case 80:
#line 272 "../plugins/io_bxl/bxl_gram.y"
	{ free(yyctx->stack.l_mark[0].un.s); }
break;
case 81:
#line 273 "../plugins/io_bxl/bxl_gram.y"
	{ free(yyctx->stack.l_mark[0].un.s); }
break;
case 83:
#line 280 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_pin_begin(ctx); }
break;
case 84:
#line 282 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_pin_des(ctx, yyctx->stack.l_mark[-6].un.s, yyctx->stack.l_mark[-4].un.c, yyctx->stack.l_mark[-2].un.c); }
break;
case 85:
#line 283 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_pin_name(ctx, yyctx->stack.l_mark[-6].un.s, yyctx->stack.l_mark[-4].un.c, yyctx->stack.l_mark[-2].un.c); }
break;
case 86:
#line 284 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_pin_end(ctx); }
break;
case 89:
#line 293 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->pin.num = yyctx->stack.l_mark[-1].un.i; }
break;
case 90:
#line 294 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->pin.origin_x = yyctx->stack.l_mark[-3].un.c; ctx->pin.origin_y = yyctx->stack.l_mark[-1].un.c; }
break;
case 91:
#line 295 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->pin.length = yyctx->stack.l_mark[-1].un.c; }
break;
case 92:
#line 296 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->pin.rot = yyctx->stack.l_mark[-1].un.i; }
break;
case 93:
#line 297 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->pin.width = yyctx->stack.l_mark[-1].un.i; }
break;
case 94:
#line 298 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->pin.is_visible = yyctx->stack.l_mark[-1].un.i; }
break;
case 97:
#line 306 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_set_text_style_ref(ctx, yyctx->stack.l_mark[-1].un.s); free(yyctx->stack.l_mark[-1].un.s); }
break;
case 98:
#line 307 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_set_justify(ctx, yyctx->stack.l_mark[-1].un.s); free(yyctx->stack.l_mark[-1].un.s); }
break;
case 99:
#line 308 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_set_text_style(ctx, yyctx->stack.l_mark[-1].un.s); free(yyctx->stack.l_mark[-1].un.s); }
break;
case 100:
#line 309 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.is_visible = yyctx->stack.l_mark[-1].un.i; }
break;
case 101:
#line 310 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->state.rot = yyctx->stack.l_mark[-1].un.d; }
break;
case 102:
#line 316 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_reset_symbol(ctx); sch_bxl_symbol_begin(ctx, yyctx->stack.l_mark[-1].un.s); free(yyctx->stack.l_mark[-1].un.s); }
break;
case 103:
#line 318 "../plugins/io_bxl/bxl_gram.y"
	{ sch_bxl_symbol_end(ctx); sch_bxl_reset_symbol(ctx); }
break;
case 107:
#line 328 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->sym_state.origin_x = yyctx->stack.l_mark[-3].un.c; ctx->sym_state.origin_y = yyctx->stack.l_mark[-1].un.c; }
break;
case 108:
#line 329 "../plugins/io_bxl/bxl_gram.y"
	{ free(yyctx->stack.l_mark[0].un.s); }
break;
case 119:
#line 355 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->in_error = 1; }
break;
case 120:
#line 355 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->in_error = 0; }
break;
case 121:
#line 356 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->in_error = 1; }
break;
case 122:
#line 356 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->in_error = 0; }
break;
case 123:
#line 357 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->in_error = 1; }
break;
case 124:
#line 357 "../plugins/io_bxl/bxl_gram.y"
	{ ctx->in_error = 0; }
break;
#line 852 "../plugins/io_bxl/bxl_gram.c"
	}
	yyctx->stack.s_mark -= yyctx->yym;
	yyctx->state = *yyctx->stack.s_mark;
	yyctx->stack.l_mark -= yyctx->yym;
	yyctx->yym = sch_bxl_lhs[yyctx->yyn];
	if (yyctx->state == 0 && yyctx->yym == 0) {
#if sch_bxl_DEBUG
		if (yyctx->debug)
			printf("yyctx->debug: after reduction, shifting from state 0 to state %d\n", sch_bxl_FINAL);
#endif
		yyctx->state = sch_bxl_FINAL;
		*++yyctx->stack.s_mark = sch_bxl_FINAL;
		*++yyctx->stack.l_mark = yyctx->val;
		if (yyctx->chr < 0) {
			sch_bxl_GETCHAR(2);
			if (yyctx->chr < 0)
				yyctx->chr = sch_bxl_EOF;
#if sch_bxl_DEBUG
			if (yyctx->debug) {
				if ((yys = sch_bxl_name[sch_bxl_TRANSLATE(yyctx->chr)]) == NULL)
					yys = sch_bxl_name[sch_bxl_UNDFTOKEN];
				printf("yyctx->debug: state %d, reading %d (%s)\n", sch_bxl_FINAL, yyctx->chr, yys);
			}
#endif
		}
		if (yyctx->chr == sch_bxl_EOF)
			goto yyaccept;
		goto yyloop;
	}
	if (((yyctx->yyn = sch_bxl_gindex[yyctx->yym]) != 0) && (yyctx->yyn += yyctx->state) >= 0 && yyctx->yyn <= sch_bxl_TABLESIZE && sch_bxl_check[yyctx->yyn] == (sch_bxl_int_t) yyctx->state)
		yyctx->state = sch_bxl_table[yyctx->yyn];
	else
		yyctx->state = sch_bxl_dgoto[yyctx->yym];
#if sch_bxl_DEBUG
	if (yyctx->debug)
		printf("yyctx->debug: after reduction, shifting from state %d to state %d\n", *yyctx->stack.s_mark, yyctx->state);
#endif
	if (yyctx->stack.s_mark >= yyctx->stack.s_last && sch_bxl_growstack(yyctx, &yyctx->stack) == sch_bxl_ENOMEM)
		goto yyoverflow;
	*++yyctx->stack.s_mark = (sch_bxl_int_t) yyctx->state;
	*++yyctx->stack.l_mark = yyctx->val;
	goto yyloop;

yyoverflow:
	sch_bxl_error(ctx, yyctx->lval, "yacc stack overflow");

yyabort:
	sch_bxl_freestack(&yyctx->stack);
	return sch_bxl_RES_ABORT;

yyaccept:
	sch_bxl_freestack(&yyctx->stack);
	return sch_bxl_RES_DONE;
}
