/* Driver template for the LEMON parser generator.
** The author disclaims copyright to this source code.
*/
/* First off, code is include which follows the "include" declaration
** in the input file. */
#include <stdio.h>
#line 400 "parser.y"

#include <assert.h>
#include <string.h>
#include <strings.h>
#define CSS_INTERNALS
#include "css/css.h"
#include "utils/utils.h" 
#line 17 "parser.c"
/* Next is all token values, in a form suitable for use by makeheaders.
** This section will be null unless lemon is run with the -m switch.
*/
/* 
** These constants (all generated automatically by the parser generator)
** specify the various kinds of tokens (terminals) that the parser
** understands. 
**
** Each symbol here is a terminal symbol in the grammar.
*/
/* Make sure the INTERFACE macro is defined.
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/* The next thing included is series of defines which control
** various aspects of the generated parser.
**    YYCODETYPE         is the data type used for storing terminal
**                       and nonterminal numbers.  "unsigned char" is
**                       used if there are fewer than 250 terminals
**                       and nonterminals.  "int" is used otherwise.
**    YYNOCODE           is a number of type YYCODETYPE which corresponds
**                       to no legal terminal or nonterminal number.  This
**                       number is used to fill in empty slots of the hash 
**                       table.
**    YYFALLBACK         If defined, this indicates that one or more tokens
**                       have fall-back values which should be used if the
**                       original value of the token will not parse.
**    YYACTIONTYPE       is the data type used for storing terminal
**                       and nonterminal numbers.  "unsigned char" is
**                       used if there are fewer than 250 rules and
**                       states combined.  "int" is used otherwise.
**    css_parser_TOKENTYPE     is the data type used for minor tokens given 
**                       directly to the parser from the tokenizer.
**    YYMINORTYPE        is the data type used for all minor tokens.
**                       This is typically a union of many types, one of
**                       which is css_parser_TOKENTYPE.  The entry in the union
**                       for base tokens is called "yy0".
**    YYSTACKDEPTH       is the maximum depth of the parser's stack.
**    css_parser_ARG_SDECL     A static variable declaration for the %extra_argument
**    css_parser_ARG_PDECL     A parameter declaration for the %extra_argument
**    css_parser_ARG_STORE     Code to store %extra_argument into yypParser
**    css_parser_ARG_FETCH     Code to extract %extra_argument from yypParser
**    YYNSTATE           the combined number of states.
**    YYNRULE            the number of rules in the grammar
**    YYERRORSYMBOL      is the code number of the error symbol.  If not
**                       defined, then do no error processing.
*/
#define YYCODETYPE unsigned char
#define YYNOCODE 57
#define YYACTIONTYPE unsigned short int
#define css_parser_TOKENTYPE  struct css_parser_token 
typedef union {
  css_parser_TOKENTYPE yy0;
  css_combinator yy35;
  struct css_node * yy42;
  struct css_selector * yy105;
  int yy113;
} YYMINORTYPE;
#define YYSTACKDEPTH 100
#define css_parser_ARG_SDECL  struct css_parser_params *param ;
#define css_parser_ARG_PDECL , struct css_parser_params *param 
#define css_parser_ARG_FETCH  struct css_parser_params *param  = yypParser->param 
#define css_parser_ARG_STORE yypParser->param  = param 
#define YYNSTATE 200
#define YYNRULE 91
#define YYERRORSYMBOL 32
#define YYERRSYMDT yy113
#define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)
#define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)
#define YY_ERROR_ACTION   (YYNSTATE+YYNRULE)

/* Next are that tables used to determine what action to take based on the
** current state and lookahead token.  These tables are used to implement
** functions that take a state number and lookahead value and return an
** action integer.  
**
** Suppose the action integer is N.  Then the action is determined as
** follows
**
**   0 <= N < YYNSTATE                  Shift N.  That is, push the lookahead
**                                      token onto the stack and goto state N.
**
**   YYNSTATE <= N < YYNSTATE+YYNRULE   Reduce by rule N-YYNSTATE.
**
**   N == YYNSTATE+YYNRULE              A syntax error has occurred.
**
**   N == YYNSTATE+YYNRULE+1            The parser accepts its input.
**
**   N == YYNSTATE+YYNRULE+2            No such action.  Denotes unused
**                                      slots in the yy_action[] table.
**
** The action table is constructed as a single large table named yy_action[].
** Given state S and lookahead X, the action is computed as
**
**      yy_action[ yy_shift_ofst[S] + X ]
**
** If the index value yy_shift_ofst[S]+X is out of range or if the value
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
** and that yy_default[S] should be used instead.  
**
** The formula above is for computing the action when the lookahead is
** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
** a reduce action) then the yy_reduce_ofst[] array is used in place of
** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
** YY_SHIFT_USE_DFLT.
**
** The following are the tables generated in this section:
**
**  yy_action[]        A single table containing all actions.
**  yy_lookahead[]     A table containing the lookahead for each entry in
**                     yy_action.  Used to detect hash collisions.
**  yy_shift_ofst[]    For each state, the offset into yy_action for
**                     shifting terminals.
**  yy_reduce_ofst[]   For each state, the offset into yy_action for
**                     shifting non-terminals after a reduce.
**  yy_default[]       Default action for each state.
*/
static const YYACTIONTYPE yy_action[] = {
 /*     0 */    30,   31,   27,   28,  156,  158,  159,  140,  162,  147,
 /*    10 */   157,   35,  174,   23,  144,  149,  151,  152,  153,  154,
 /*    20 */   155,   32,  128,  145,  141,  142,  143,  146,  148,   34,
 /*    30 */   128,   25,  137,    4,   29,  156,  158,  159,   81,   82,
 /*    40 */    83,  127,   73,  175,   23,  144,  149,  151,  152,  153,
 /*    50 */   154,  101,   32,  133,  145,  141,  142,  143,  146,  148,
 /*    60 */    34,  156,  158,  159,   88,  162,  147,  157,   35,   26,
 /*    70 */    27,  144,  149,  151,  152,  153,  154,  155,   32,  166,
 /*    80 */    78,  141,  142,  143,  146,  148,   34,  156,  158,  159,
 /*    90 */   140,  162,  147,  157,   35,  168,   39,  144,  149,  151,
 /*   100 */   152,  153,  154,  155,   32,    1,  145,  141,  142,  143,
 /*   110 */   146,  148,   34,  156,  158,  159,   21,  162,  147,  157,
 /*   120 */    35,   49,   50,  144,  149,  151,  152,  153,  154,  155,
 /*   130 */    32,   43,  145,  141,  142,  143,  146,  148,   34,  102,
 /*   140 */   130,  131,  132,   41,  260,   74,   47,   86,   33,  126,
 /*   150 */     9,  197,   43,   22,  194,   23,  231,  292,   79,  231,
 /*   160 */   103,  231,  231,  231,   24,  260,  231,  231,  231,  232,
 /*   170 */   191,   89,  232,   85,  232,  232,  232,  231,   10,  232,
 /*   180 */   232,  232,  235,  129,   71,  235,    7,  235,  235,  235,
 /*   190 */   232,  128,  235,  235,  235,    8,  197,  160,   22,  194,
 /*   200 */    23,   43,  161,  235,  201,  201,   38,  201,  201,  201,
 /*   210 */   201,  201,  173,   46,   22,  194,   23,  106,  178,   53,
 /*   220 */    33,   56,   59,   62,   65,   68,  163,  165,  195,  196,
 /*   230 */   176,  111,   51,   84,   47,  103,   87,  169,  128,  192,
 /*   240 */   262,   96,  262,   40,  107,   44,  150,   45,   47,   33,
 /*   250 */   108,  169,   47,  104,   98,  169,   33,  105,  107,   44,
 /*   260 */    33,  177,  107,   44,  100,   47,   85,   99,  169,  179,
 /*   270 */   176,  111,   51,  149,    5,  107,   44,  129,  149,    7,
 /*   280 */   202,   96,  202,  202,  202,  170,  149,   76,   33,  103,
 /*   290 */    11,  134,  103,  103,   80,  135,  103,  103,  136,  138,
 /*   300 */   103,  103,  139,   12,  103,  103,   13,   14,  103,  103,
 /*   310 */   180,   15,    2,  103,  103,  164,    3,  103,  103,  109,
 /*   320 */    16,  103,  103,   75,  167,  103,  103,   17,  110,  103,
 /*   330 */   103,   18,   77,  103,  103,   19,    6,  103,  103,  171,
 /*   340 */   172,  103,  103,  112,   90,  103,  103,  113,  114,  103,
 /*   350 */   103,   91,  115,  103,  103,  116,   92,  103,  103,  117,
 /*   360 */   118,  103,  103,   93,  119,  103,  103,  120,   94,  103,
 /*   370 */   103,  121,  122,  103,  103,   95,  123,  103,  103,  124,
 /*   380 */    97,  103,  103,  125,   20,  103,  103,   42,   36,   27,
 /*   390 */    48,  165,   54,   37,  181,   57,   60,  149,   63,   55,
 /*   400 */    66,   69,   58,   61,  182,   64,   72,   67,   70,  165,
 /*   410 */   165,  198,  199,   52,  183,  184,  185,  186,  149,  187,
 /*   420 */   149,  193,  188,  189,  190,
};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */     2,    3,    4,    5,    6,    7,    8,    9,   10,   11,
 /*    10 */    12,   13,   51,   52,   16,   17,   18,   19,   20,   21,
 /*    20 */    22,   23,    1,   25,   26,   27,   28,   29,   30,   31,
 /*    30 */     1,    2,   41,    4,   43,    6,    7,    8,    9,   10,
 /*    40 */    11,   12,   13,   51,   52,   16,   17,   18,   19,   20,
 /*    50 */    21,   22,   23,   41,   25,   26,   27,   28,   29,   30,
 /*    60 */    31,    6,    7,    8,    9,   10,   11,   12,   13,    3,
 /*    70 */     4,   16,   17,   18,   19,   20,   21,   22,   23,   41,
 /*    80 */    25,   26,   27,   28,   29,   30,   31,    6,    7,    8,
 /*    90 */     9,   10,   11,   12,   13,    9,   54,   16,   17,   18,
 /*   100 */    19,   20,   21,   22,   23,   35,   25,   26,   27,   28,
 /*   110 */    29,   30,   31,    6,    7,    8,    9,   10,   11,   12,
 /*   120 */    13,    7,    8,   16,   17,   18,   19,   20,   21,   22,
 /*   130 */    23,   43,   25,   26,   27,   28,   29,   30,   31,   36,
 /*   140 */    37,   38,   39,   55,    1,   40,   43,   44,   43,   46,
 /*   150 */    47,   48,   43,   50,   51,   52,    1,   33,   34,    4,
 /*   160 */    36,    6,    7,    8,   55,   22,   11,   12,   13,    1,
 /*   170 */     9,   34,    4,   36,    6,    7,    8,   22,   42,   11,
 /*   180 */    12,   13,    1,    1,   23,    4,   49,    6,    7,    8,
 /*   190 */    22,    1,   11,   12,   13,   47,   48,   24,   50,   51,
 /*   200 */    52,   43,   14,   22,   14,   15,    3,   17,   18,   19,
 /*   210 */    20,   21,   48,   55,   50,   51,   52,   40,   14,   15,
 /*   220 */    43,   17,   18,   19,   20,   21,   24,    3,    9,   10,
 /*   230 */    11,   12,   13,   34,   43,   36,   45,   46,    1,   24,
 /*   240 */     3,   22,    5,   22,   53,   54,   40,   22,   43,   43,
 /*   250 */    45,   46,   43,   40,   45,   46,   43,   40,   53,   54,
 /*   260 */    43,    9,   53,   54,   34,   43,   36,   45,   46,   14,
 /*   270 */    11,   12,   13,   56,    4,   53,   54,    1,   56,   49,
 /*   280 */     4,   22,    6,    7,    8,   40,   56,   34,   43,   36,
 /*   290 */    34,   34,   36,   36,   34,   34,   36,   36,   34,   34,
 /*   300 */    36,   36,   34,   34,   36,   36,   34,   34,   36,   36,
 /*   310 */    14,   34,   34,   36,   36,   34,   34,   36,   36,   34,
 /*   320 */    34,   36,   36,   34,   34,   36,   36,   34,   34,   36,
 /*   330 */    36,   34,   34,   36,   36,   34,   34,   36,   36,   34,
 /*   340 */    34,   36,   36,   34,   34,   36,   36,   34,   34,   36,
 /*   350 */    36,   34,   34,   36,   36,   34,   34,   36,   36,   34,
 /*   360 */    34,   36,   36,   34,   34,   36,   36,   34,   34,   36,
 /*   370 */    36,   34,   34,   36,   36,   34,   34,   36,   36,   34,
 /*   380 */    34,   36,   36,   34,   34,   36,   36,    2,    4,    4,
 /*   390 */     6,    3,    9,    5,   14,    9,    9,   56,    9,   16,
 /*   400 */     9,    9,   16,   16,   14,   16,    9,   16,   16,    3,
 /*   410 */     3,    5,    5,    9,   14,   14,   14,   14,   56,   14,
 /*   420 */    56,   24,   14,   14,   14,
};
#define YY_SHIFT_USE_DFLT (-3)
#define YY_SHIFT_MAX 127
static const short yy_shift_ofst[] = {
 /*     0 */    21,   29,   55,   55,   55,   55,  219,  219,   21,   21,
 /*    10 */    -2,   81,   81,   81,   81,   81,   81,   81,   81,   81,
 /*    20 */   107,  190,  259,  259,  237,   21,   21,   21,   21,   21,
 /*    30 */    21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
 /*    40 */    21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
 /*    50 */    21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
 /*    60 */    21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
 /*    70 */    21,   21,   21,   21,   66,  385,  385,  385,   86,   -3,
 /*    80 */    -3,  155,  168,  181,  204,  276,  384,  388,  143,  114,
 /*    90 */   383,  386,  387,  389,  391,  392,  161,  397,  406,  407,
 /*   100 */   114,  161,  182,  182,  173,  188,  202,  203,  224,  221,
 /*   110 */   225,  252,  404,  255,  296,  380,  390,  400,  401,  402,
 /*   120 */   403,  405,  408,  409,  410,  215,  270,  252,
};
#define YY_REDUCE_USE_DFLT (-40)
#define YY_REDUCE_MAX 80
static const short yy_reduce_ofst[] = {
 /*     0 */   124,  103,  191,  205,  209,  222,  148,  164,  137,  230,
 /*    10 */    -9,  105,  177,  206,  213,  217,   88,  109,  158,  245,
 /*    20 */   217,  199,  -39,   -8,  253,  256,  257,  260,  261,  264,
 /*    30 */   265,  268,  269,  272,  273,  277,  278,  281,  282,  285,
 /*    40 */   286,  289,  290,  293,  294,  297,  298,  301,  302,  305,
 /*    50 */   306,  309,  199,  310,  313,  314,  317,  318,  321,  322,
 /*    60 */   325,  326,  329,  330,  333,  334,  337,  338,  341,  342,
 /*    70 */   345,  346,  349,  350,   12,   38,   38,   38,   42,   70,
 /*    80 */   136,
};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */   201,  200,  253,  253,  253,  253,  291,  291,  201,  201,
 /*    10 */   291,  265,  265,  265,  265,  265,  291,  261,  291,  265,
 /*    20 */   265,  268,  229,  233,  201,  201,  201,  201,  201,  201,
 /*    30 */   201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
 /*    40 */   201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
 /*    50 */   201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
 /*    60 */   201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
 /*    70 */   201,  201,  201,  201,  291,  257,  291,  258,  273,  205,
 /*    80 */   213,  268,  290,  275,  291,  227,  291,  291,  268,  222,
 /*    90 */   291,  291,  291,  291,  291,  291,  291,  291,  291,  291,
 /*   100 */   221,  283,  207,  202,  291,  291,  291,  254,  256,  291,
 /*   110 */   291,  291,  291,  291,  291,  291,  291,  291,  291,  291,
 /*   120 */   291,  291,  291,  291,  291,  291,  291,  285,  203,  204,
 /*   130 */   206,  208,  209,  210,  211,  212,  214,  215,  216,  217,
 /*   140 */   268,  269,  270,  271,  272,  273,  274,  275,  276,  277,
 /*   150 */   266,  279,  280,  281,  282,  283,  284,  285,  286,  287,
 /*   160 */   288,  289,  290,  278,  218,  255,  263,  264,  260,  259,
 /*   170 */   267,  225,  226,  224,  228,  234,  235,  236,  237,  238,
 /*   180 */   239,  240,  241,  242,  243,  244,  245,  246,  247,  248,
 /*   190 */   249,  250,  251,  252,  230,  231,  232,  223,  219,  220,
};
#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))

/* The next table maps tokens into fallback tokens.  If a construct
** like the following:
** 
**      %fallback ID X Y Z.
**
** appears in the grammer, then ID becomes a fallback token for X, Y,
** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
** but it does not parse, the type of the token is changed to ID and
** the parse is retried before an error is thrown.
*/
#ifdef YYFALLBACK
static const YYCODETYPE yyFallback[] = {
};
#endif /* YYFALLBACK */

/* The following structure represents a single element of the
** parser's stack.  Information stored includes:
**
**   +  The state number for the parser at this level of the stack.
**
**   +  The value of the token stored at this level of the stack.
**      (In other words, the "major" token.)
**
**   +  The semantic value stored at this level of the stack.  This is
**      the information used by the action routines in the grammar.
**      It is sometimes called the "minor" token.
*/
struct yyStackEntry {
  int stateno;       /* The state-number */
  int major;         /* The major token value.  This is the code
                     ** number for the token at this stack level */
  YYMINORTYPE minor; /* The user-supplied minor token value.  This
                     ** is the value of the token  */
};
typedef struct yyStackEntry yyStackEntry;

/* The state of the parser is completely contained in an instance of
** the following structure */
struct yyParser {
  int yyidx;                    /* Index of top element in stack */
  int yyerrcnt;                 /* Shifts left before out of the error */
  css_parser_ARG_SDECL                /* A place to hold %extra_argument */
  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
};
typedef struct yyParser yyParser;

#ifndef NDEBUG
#include <stdio.h>
static FILE *yyTraceFILE = 0;
static char *yyTracePrompt = 0;
#endif /* NDEBUG */

#ifndef NDEBUG
/* 
** Turn parser tracing on by giving a stream to which to write the trace
** and a prompt to preface each trace message.  Tracing is turned off
** by making either argument NULL 
**
** Inputs:
** <ul>
** <li> A FILE* to which trace output should be written.
**      If NULL, then tracing is turned off.
** <li> A prefix string written at the beginning of every
**      line of trace output.  If NULL, then tracing is
**      turned off.
** </ul>
**
** Outputs:
** None.
*/
void css_parser_Trace(FILE *TraceFILE, char *zTracePrompt){
  yyTraceFILE = TraceFILE;
  yyTracePrompt = zTracePrompt;
  if( yyTraceFILE==0 ) yyTracePrompt = 0;
  else if( yyTracePrompt==0 ) yyTraceFILE = 0;
}
#endif /* NDEBUG */

#ifndef NDEBUG
/* For tracing shifts, the names of all terminals and nonterminals
** are required.  The following table supplies these names */
static const char *const yyTokenName[] = { 
  "$",             "S",             "ATKEYWORD",     "SEMI",        
  "LBRACE",        "RBRACE",        "COMMA",         "PLUS",        
  "GT",            "IDENT",         "ASTERISK",      "HASH",        
  "DOT",           "LBRAC",         "RBRAC",         "EQUALS",      
  "STRING",        "INCLUDES",      "DASHMATCH",     "PREFIX",      
  "SUFFIX",        "SUBSTR",        "COLON",         "FUNCTION",    
  "RPAREN",        "DELIM",         "NUMBER",        "PERCENTAGE",  
  "DIMENSION",     "URI",           "UNICODE_RANGE",  "LPAREN",      
  "error",         "stylesheet",    "ws",            "statement_list",
  "ws_1",          "statement",     "ruleset",       "at_rule",     
  "any_list",      "block",         "block_body",    "any",         
  "selector_list",  "declaration_list",  "any_list_1",    "selector",    
  "simple_selector",  "css_combinator",  "element_name",  "detail_list", 
  "detail",        "declaration",   "property",      "value",       
};
#endif /* NDEBUG */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
 /*   0 */ "stylesheet ::= ws statement_list",
 /*   1 */ "ws ::=",
 /*   2 */ "ws ::= ws_1",
 /*   3 */ "ws_1 ::= S",
 /*   4 */ "ws_1 ::= ws_1 S",
 /*   5 */ "statement_list ::=",
 /*   6 */ "statement_list ::= statement_list statement",
 /*   7 */ "statement ::= ws_1",
 /*   8 */ "statement ::= ruleset",
 /*   9 */ "statement ::= at_rule",
 /*  10 */ "at_rule ::= ATKEYWORD ws any_list block",
 /*  11 */ "at_rule ::= ATKEYWORD ws any_list SEMI ws",
 /*  12 */ "block ::= LBRACE ws block_body RBRACE ws",
 /*  13 */ "block_body ::=",
 /*  14 */ "block_body ::= block_body any ws",
 /*  15 */ "block_body ::= block_body block",
 /*  16 */ "block_body ::= block_body ATKEYWORD ws",
 /*  17 */ "block_body ::= block_body SEMI ws",
 /*  18 */ "ruleset ::= selector_list LBRACE ws declaration_list RBRACE ws",
 /*  19 */ "ruleset ::= LBRACE declaration_list RBRACE",
 /*  20 */ "ruleset ::= any_list_1 LBRACE declaration_list RBRACE",
 /*  21 */ "selector_list ::= selector ws",
 /*  22 */ "selector_list ::= selector_list COMMA ws selector ws",
 /*  23 */ "selector ::= simple_selector",
 /*  24 */ "selector ::= selector css_combinator simple_selector",
 /*  25 */ "css_combinator ::= ws PLUS ws",
 /*  26 */ "css_combinator ::= ws GT ws",
 /*  27 */ "css_combinator ::= ws_1",
 /*  28 */ "simple_selector ::= element_name detail_list",
 /*  29 */ "simple_selector ::= element_name",
 /*  30 */ "simple_selector ::= detail_list",
 /*  31 */ "element_name ::= IDENT",
 /*  32 */ "element_name ::= ASTERISK",
 /*  33 */ "detail_list ::= detail",
 /*  34 */ "detail_list ::= detail detail_list",
 /*  35 */ "detail ::= HASH",
 /*  36 */ "detail ::= DOT IDENT",
 /*  37 */ "detail ::= LBRAC ws IDENT ws RBRAC",
 /*  38 */ "detail ::= LBRAC ws IDENT ws EQUALS ws IDENT ws RBRAC",
 /*  39 */ "detail ::= LBRAC ws IDENT ws EQUALS ws STRING ws RBRAC",
 /*  40 */ "detail ::= LBRAC ws IDENT ws INCLUDES ws IDENT ws RBRAC",
 /*  41 */ "detail ::= LBRAC ws IDENT ws INCLUDES ws STRING ws RBRAC",
 /*  42 */ "detail ::= LBRAC ws IDENT ws DASHMATCH ws IDENT ws RBRAC",
 /*  43 */ "detail ::= LBRAC ws IDENT ws DASHMATCH ws STRING ws RBRAC",
 /*  44 */ "detail ::= LBRAC ws IDENT ws PREFIX ws IDENT ws RBRAC",
 /*  45 */ "detail ::= LBRAC ws IDENT ws PREFIX ws STRING ws RBRAC",
 /*  46 */ "detail ::= LBRAC ws IDENT ws SUFFIX ws IDENT ws RBRAC",
 /*  47 */ "detail ::= LBRAC ws IDENT ws SUFFIX ws STRING ws RBRAC",
 /*  48 */ "detail ::= LBRAC ws IDENT ws SUBSTR ws IDENT ws RBRAC",
 /*  49 */ "detail ::= LBRAC ws IDENT ws SUBSTR ws STRING ws RBRAC",
 /*  50 */ "detail ::= COLON IDENT",
 /*  51 */ "detail ::= COLON FUNCTION ws IDENT ws RPAREN",
 /*  52 */ "detail ::= COLON FUNCTION ws RPAREN",
 /*  53 */ "declaration_list ::=",
 /*  54 */ "declaration_list ::= declaration",
 /*  55 */ "declaration_list ::= declaration_list SEMI",
 /*  56 */ "declaration_list ::= declaration SEMI ws declaration_list",
 /*  57 */ "declaration ::= DELIM property ws COLON ws value ws",
 /*  58 */ "declaration ::= property ws COLON ws value ws",
 /*  59 */ "declaration ::= any_list_1",
 /*  60 */ "property ::= IDENT",
 /*  61 */ "value ::= any ws",
 /*  62 */ "value ::= any ws value",
 /*  63 */ "value ::= value ws block",
 /*  64 */ "value ::= value ws ATKEYWORD ws",
 /*  65 */ "any_list ::=",
 /*  66 */ "any_list ::= any ws any_list",
 /*  67 */ "any_list_1 ::= any ws any_list",
 /*  68 */ "any ::= IDENT",
 /*  69 */ "any ::= NUMBER",
 /*  70 */ "any ::= PERCENTAGE",
 /*  71 */ "any ::= DIMENSION",
 /*  72 */ "any ::= STRING",
 /*  73 */ "any ::= DELIM",
 /*  74 */ "any ::= URI",
 /*  75 */ "any ::= HASH",
 /*  76 */ "any ::= UNICODE_RANGE",
 /*  77 */ "any ::= INCLUDES",
 /*  78 */ "any ::= FUNCTION ws any_list RPAREN",
 /*  79 */ "any ::= DASHMATCH",
 /*  80 */ "any ::= PREFIX",
 /*  81 */ "any ::= SUFFIX",
 /*  82 */ "any ::= SUBSTR",
 /*  83 */ "any ::= COLON",
 /*  84 */ "any ::= COMMA",
 /*  85 */ "any ::= DOT",
 /*  86 */ "any ::= PLUS",
 /*  87 */ "any ::= GT",
 /*  88 */ "any ::= LPAREN ws any_list RPAREN",
 /*  89 */ "any ::= LBRAC ws any_list RBRAC",
 /*  90 */ "any ::= ASTERISK",
};
#endif /* NDEBUG */

/*
** This function returns the symbolic name associated with a token
** value.
*/
const char *css_parser_TokenName(int tokenType){
#ifndef NDEBUG
  if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){
    return yyTokenName[tokenType];
  }else{
    return "Unknown";
  }
#else
  return "";
#endif
}

/* 
** This function allocates a new parser.
** The only argument is a pointer to a function which works like
** malloc.
**
** Inputs:
** A pointer to the function used to allocate memory.
**
** Outputs:
** A pointer to a parser.  This pointer is used in subsequent calls
** to css_parser_ and css_parser_Free.
*/
void *css_parser_Alloc(void *(*mallocProc)(size_t)){
  yyParser *pParser;
  pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
  if( pParser ){
    pParser->yyidx = -1;
  }
  return pParser;
}

/* The following function deletes the value associated with a
** symbol.  The symbol can be either a terminal or nonterminal.
** "yymajor" is the symbol code, and "yypminor" is a pointer to
** the value.
*/
static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
  switch( yymajor ){
    /* Here is inserted the actions which take place when a
    ** terminal or non-terminal is destroyed.  This can happen
    ** when the symbol is popped from the stack during a
    ** reduce or during error processing or when a parser is 
    ** being destroyed before it is finished parsing.
    **
    ** Note: during a reduce, the only symbols destroyed are those
    ** which appear on the RHS of the rule, but which are not used
    ** inside the C code.
    */
    case 40:
    case 43:
    case 45:
    case 46:
    case 53:
    case 55:
#line 432 "parser.y"
{ css_free_node((yypminor->yy42)); }
#line 540 "parser.c"
      break;
    case 44:
    case 47:
    case 48:
    case 51:
    case 52:
#line 424 "parser.y"
{ css_free_selector((yypminor->yy105)); }
#line 549 "parser.c"
      break;
    default:  break;   /* If no destructor action specified: do nothing */
  }
}

/*
** Pop the parser's stack once.
**
** If there is a destructor routine associated with the token which
** is popped from the stack, then call it.
**
** Return the major token number for the symbol popped.
*/
static int yy_pop_parser_stack(yyParser *pParser){
  YYCODETYPE yymajor;
  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];

  if( pParser->yyidx<0 ) return 0;
#ifndef NDEBUG
  if( yyTraceFILE && pParser->yyidx>=0 ){
    fprintf(yyTraceFILE,"%sPopping %s\n",
      yyTracePrompt,
      yyTokenName[yytos->major]);
  }
#endif
  yymajor = yytos->major;
  yy_destructor( yymajor, &yytos->minor);
  pParser->yyidx--;
  return yymajor;
}

/* 
** Deallocate and destroy a parser.  Destructors are all called for
** all stack elements before shutting the parser down.
**
** Inputs:
** <ul>
** <li>  A pointer to the parser.  This should be a pointer
**       obtained from css_parser_Alloc.
** <li>  A pointer to a function used to reclaim memory obtained
**       from malloc.
** </ul>
*/
void css_parser_Free(
  void *p,                    /* The parser to be deleted */
  void (*freeProc)(void*)     /* Function used to reclaim memory */
){
  yyParser *pParser = (yyParser*)p;
  if( pParser==0 ) return;
  while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
  (*freeProc)((void*)pParser);
}

/*
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
**
** If the look-ahead token is YYNOCODE, then check to see if the action is
** independent of the look-ahead.  If it is, return the action, otherwise
** return YY_NO_ACTION.
*/
static int yy_find_shift_action(
  yyParser *pParser,        /* The parser */
  YYCODETYPE iLookAhead     /* The look-ahead token */
){
  int i;
  int stateno = pParser->yystack[pParser->yyidx].stateno;
 
  if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
    return yy_default[stateno];
  }
  if( iLookAhead==YYNOCODE ){
    return YY_NO_ACTION;
  }
  i += iLookAhead;
  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
    if( iLookAhead>0 ){
#ifdef YYFALLBACK
      int iFallback;            /* Fallback token */
      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
             && (iFallback = yyFallback[iLookAhead])!=0 ){
#ifndef NDEBUG
        if( yyTraceFILE ){
          fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
        }
#endif
        return yy_find_shift_action(pParser, iFallback);
      }
#endif
#ifdef YYWILDCARD
      {
        int j = i - iLookAhead + YYWILDCARD;
        if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
#ifndef NDEBUG
          if( yyTraceFILE ){
            fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
               yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
          }
#endif /* NDEBUG */
          return yy_action[j];
        }
      }
#endif /* YYWILDCARD */
    }
    return yy_default[stateno];
  }else{
    return yy_action[i];
  }
}

/*
** Find the appropriate action for a parser given the non-terminal
** look-ahead token iLookAhead.
**
** If the look-ahead token is YYNOCODE, then check to see if the action is
** independent of the look-ahead.  If it is, return the action, otherwise
** return YY_NO_ACTION.
*/
static int yy_find_reduce_action(
  int stateno,              /* Current state number */
  YYCODETYPE iLookAhead     /* The look-ahead token */
){
  int i;
  /* int stateno = pParser->yystack[pParser->yyidx].stateno; */
 
  if( stateno>YY_REDUCE_MAX ||
      (i = yy_reduce_ofst[stateno])==YY_REDUCE_USE_DFLT ){
    return yy_default[stateno];
  }
  if( iLookAhead==YYNOCODE ){
    return YY_NO_ACTION;
  }
  i += iLookAhead;
  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
    return yy_default[stateno];
  }else{
    return yy_action[i];
  }
}

/*
** Perform a shift action.
*/
static void yy_shift(
  yyParser *yypParser,          /* The parser to be shifted */
  int yyNewState,               /* The new state to shift in */
  int yyMajor,                  /* The major token to shift in */
  YYMINORTYPE *yypMinor         /* Pointer ot the minor token to shift in */
){
  yyStackEntry *yytos;
  yypParser->yyidx++;
  if( yypParser->yyidx>=YYSTACKDEPTH ){
     css_parser_ARG_FETCH;
     yypParser->yyidx--;
#ifndef NDEBUG
     if( yyTraceFILE ){
       fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
     }
#endif
     while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
     /* Here code is inserted which will execute if the parser
     ** stack every overflows */
     css_parser_ARG_STORE; /* Suppress warning about unused %extra_argument var */
     return;
  }
  yytos = &yypParser->yystack[yypParser->yyidx];
  yytos->stateno = yyNewState;
  yytos->major = yyMajor;
  yytos->minor = *yypMinor;
#ifndef NDEBUG
  if( yyTraceFILE && yypParser->yyidx>0 ){
    int i;
    fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
    fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
    for(i=1; i<=yypParser->yyidx; i++)
      fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
    fprintf(yyTraceFILE,"\n");
  }
#endif
}

/* The following table contains information about every rule that
** is used during the reduce.
*/
static const struct {
  YYCODETYPE lhs;         /* Symbol on the left-hand side of the rule */
  unsigned char nrhs;     /* Number of right-hand side symbols in the rule */
} yyRuleInfo[] = {
  { 33, 2 },
  { 34, 0 },
  { 34, 1 },
  { 36, 1 },
  { 36, 2 },
  { 35, 0 },
  { 35, 2 },
  { 37, 1 },
  { 37, 1 },
  { 37, 1 },
  { 39, 4 },
  { 39, 5 },
  { 41, 5 },
  { 42, 0 },
  { 42, 3 },
  { 42, 2 },
  { 42, 3 },
  { 42, 3 },
  { 38, 6 },
  { 38, 3 },
  { 38, 4 },
  { 44, 2 },
  { 44, 5 },
  { 47, 1 },
  { 47, 3 },
  { 49, 3 },
  { 49, 3 },
  { 49, 1 },
  { 48, 2 },
  { 48, 1 },
  { 48, 1 },
  { 50, 1 },
  { 50, 1 },
  { 51, 1 },
  { 51, 2 },
  { 52, 1 },
  { 52, 2 },
  { 52, 5 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 9 },
  { 52, 2 },
  { 52, 6 },
  { 52, 4 },
  { 45, 0 },
  { 45, 1 },
  { 45, 2 },
  { 45, 4 },
  { 53, 7 },
  { 53, 6 },
  { 53, 1 },
  { 54, 1 },
  { 55, 2 },
  { 55, 3 },
  { 55, 3 },
  { 55, 4 },
  { 40, 0 },
  { 40, 3 },
  { 46, 3 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 4 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 1 },
  { 43, 4 },
  { 43, 4 },
  { 43, 1 },
};

static void yy_accept(yyParser*);  /* Forward Declaration */

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  css_parser_ARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

#ifndef NDEBUG
  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  */
  memset(&yygotominor, 0, sizeof(yygotominor));
#endif

  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 11:
#line 49 "parser.y"
{ if ((yymsp[-4].minor.yy0.length == 7) && (strncasecmp(yymsp[-4].minor.yy0.text, "@import", 7) == 0)
				&& yymsp[-2].minor.yy42 && !param->had_ruleset)
			css_atimport(param->stylesheet, yymsp[-2].minor.yy42);
		css_free_node(yymsp[-2].minor.yy42); }
#line 884 "parser.c"
        break;
      case 18:
#line 62 "parser.y"
{ if (yymsp[-5].minor.yy105 && yymsp[-2].minor.yy42) {
			/*param->had_ruleset = true;*/
			css_add_ruleset(param->stylesheet, yymsp[-5].minor.yy105, yymsp[-2].minor.yy42);
		}
		else
			css_free_selector(yymsp[-5].minor.yy105);
		css_free_node(yymsp[-2].minor.yy42); }
#line 895 "parser.c"
        break;
      case 19:
#line 72 "parser.y"
{ if (param->ruleset_only) param->declaration = yymsp[-1].minor.yy42;
		  else css_free_node(yymsp[-1].minor.yy42); }
#line 901 "parser.c"
        break;
      case 20:
#line 75 "parser.y"
{ css_free_node(yymsp[-3].minor.yy42); css_free_node(yymsp[-1].minor.yy42); }
#line 906 "parser.c"
        break;
      case 21:
#line 78 "parser.y"
{ yygotominor.yy105 = yymsp[-1].minor.yy105; }
#line 911 "parser.c"
        break;
      case 22:
#line 80 "parser.y"
{ if (yymsp[-4].minor.yy105 && yymsp[-1].minor.yy105) {
			yymsp[-1].minor.yy105->next = yymsp[-4].minor.yy105;
			yygotominor.yy105 = yymsp[-1].minor.yy105;
		} else {
			css_free_selector(yymsp[-4].minor.yy105);
			css_free_selector(yymsp[-1].minor.yy105);
			yygotominor.yy105 = 0;
		} }
#line 923 "parser.c"
        break;
      case 23:
      case 33:
#line 90 "parser.y"
{ yygotominor.yy105 = yymsp[0].minor.yy105; }
#line 929 "parser.c"
        break;
      case 24:
#line 92 "parser.y"
{ if (yymsp[-2].minor.yy105 && yymsp[0].minor.yy105) {
			yymsp[0].minor.yy105->combiner = yymsp[-2].minor.yy105;
			yymsp[0].minor.yy105->comb = yymsp[-1].minor.yy35;
			yymsp[0].minor.yy105->specificity += yymsp[-2].minor.yy105->specificity;
			yygotominor.yy105 = yymsp[0].minor.yy105;
		} else {
			css_free_selector(yymsp[-2].minor.yy105);
			css_free_selector(yymsp[0].minor.yy105);
			yygotominor.yy105 = 0;
		} }
#line 943 "parser.c"
        break;
      case 25:
#line 104 "parser.y"
{ yygotominor.yy35 = CSS_COMB_PRECEDED; }
#line 948 "parser.c"
        break;
      case 26:
#line 106 "parser.y"
{ yygotominor.yy35 = CSS_COMB_PARENT; }
#line 953 "parser.c"
        break;
      case 27:
#line 108 "parser.y"
{ yygotominor.yy35 = CSS_COMB_ANCESTOR; }
#line 958 "parser.c"
        break;
      case 28:
#line 111 "parser.y"
{ if (yymsp[0].minor.yy105 && (yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ELEMENT,
				yymsp[-1].minor.yy0.text, yymsp[-1].minor.yy0.length))) {
			yygotominor.yy105->detail = yymsp[0].minor.yy105;
			yygotominor.yy105->specificity = 1 + yymsp[0].minor.yy105->specificity;
		} else {
			param->memory_error = true;
			css_free_selector(yymsp[0].minor.yy105);
			yygotominor.yy105 = 0;
		} }
#line 971 "parser.c"
        break;
      case 29:
#line 121 "parser.y"
{ if ((yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ELEMENT,
				yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length)))
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ELEMENT;
		else
			param->memory_error = true;
		}
#line 981 "parser.c"
        break;
      case 30:
#line 128 "parser.y"
{ if (yymsp[0].minor.yy105 && (yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ELEMENT, 0, 0))) {
			yygotominor.yy105->detail = yymsp[0].minor.yy105;
			yygotominor.yy105->specificity = yymsp[0].minor.yy105->specificity;
		} else {
			param->memory_error = true;
			css_free_selector(yymsp[0].minor.yy105);
			yygotominor.yy105 = 0;
                } }
#line 993 "parser.c"
        break;
      case 31:
      case 60:
#line 138 "parser.y"
{ yygotominor.yy0 = yymsp[0].minor.yy0; }
#line 999 "parser.c"
        break;
      case 32:
#line 140 "parser.y"
{ yygotominor.yy0.text = 0; }
#line 1004 "parser.c"
        break;
      case 34:
#line 145 "parser.y"
{ if (yymsp[-1].minor.yy105 && yymsp[0].minor.yy105) {
			yymsp[-1].minor.yy105->specificity += yymsp[0].minor.yy105->specificity;
			yymsp[-1].minor.yy105->next = yymsp[0].minor.yy105;
			yygotominor.yy105 = yymsp[-1].minor.yy105;
		} else {
			css_free_selector(yymsp[-1].minor.yy105);
			css_free_selector(yymsp[0].minor.yy105);
			yygotominor.yy105 = 0;
		} }
#line 1017 "parser.c"
        break;
      case 35:
#line 156 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ID, yymsp[0].minor.yy0.text+1, yymsp[0].minor.yy0.length-1);
		if (yygotominor.yy105) yygotominor.yy105->specificity = CSS_SPECIFICITY_ID;
		else param->memory_error = true; }
#line 1024 "parser.c"
        break;
      case 36:
#line 160 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_CLASS, yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
		if (yygotominor.yy105) yygotominor.yy105->specificity = CSS_SPECIFICITY_CLASS;
		else param->memory_error = true; }
#line 1031 "parser.c"
        break;
      case 37:
#line 164 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB, yymsp[-2].minor.yy0.text, yymsp[-2].minor.yy0.length);
		if (yygotominor.yy105) yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR;
		else param->memory_error = true; }
#line 1038 "parser.c"
        break;
      case 38:
#line 168 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_EQ, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1046 "parser.c"
        break;
      case 39:
#line 173 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_EQ, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text + 1; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length - 2;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1054 "parser.c"
        break;
      case 40:
#line 178 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_INC, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1062 "parser.c"
        break;
      case 41:
#line 183 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_INC, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text + 1; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length - 2;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1070 "parser.c"
        break;
      case 42:
#line 188 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_DM, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1078 "parser.c"
        break;
      case 43:
#line 193 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_DM, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text + 1; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length - 2;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1086 "parser.c"
        break;
      case 44:
#line 198 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_PRE, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1094 "parser.c"
        break;
      case 45:
#line 203 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_PRE, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text + 1; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length - 2;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1102 "parser.c"
        break;
      case 46:
#line 208 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_SUF, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1110 "parser.c"
        break;
      case 47:
#line 213 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_SUF, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text + 1; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length - 2;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1118 "parser.c"
        break;
      case 48:
#line 218 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_SUB, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1126 "parser.c"
        break;
      case 49:
#line 223 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB_SUB, yymsp[-6].minor.yy0.text, yymsp[-6].minor.yy0.length);
		if (yygotominor.yy105) { yygotominor.yy105->data2 = yymsp[-2].minor.yy0.text + 1; yygotominor.yy105->data2_length = yymsp[-2].minor.yy0.length - 2;
			yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR; }
		else param->memory_error = true; }
#line 1134 "parser.c"
        break;
      case 50:
#line 228 "parser.y"
{ if (yymsp[0].minor.yy0.length == 4 && strncasecmp(yymsp[0].minor.yy0.text, "link", 4) == 0) {
			yygotominor.yy105 = css_new_selector(CSS_SELECTOR_ATTRIB, "href", 4);
			if (yygotominor.yy105) yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR;
			else param->memory_error = true;
		} else {
			yygotominor.yy105 = css_new_selector(CSS_SELECTOR_PSEUDO, yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
			if (yygotominor.yy105) yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR;
			else param->memory_error = true;
		} }
#line 1147 "parser.c"
        break;
      case 51:
#line 238 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_PSEUDO, yymsp[-4].minor.yy0.text, yymsp[-4].minor.yy0.length);
		if (yygotominor.yy105) yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR;
		else param->memory_error = true; }
#line 1154 "parser.c"
        break;
      case 52:
#line 242 "parser.y"
{ yygotominor.yy105 = css_new_selector(CSS_SELECTOR_PSEUDO, yymsp[-2].minor.yy0.text, yymsp[-2].minor.yy0.length);
		if (yygotominor.yy105) yygotominor.yy105->specificity = CSS_SPECIFICITY_ATTR;
		else param->memory_error = true; }
#line 1161 "parser.c"
        break;
      case 53:
      case 65:
#line 247 "parser.y"
{ yygotominor.yy42 = 0; }
#line 1167 "parser.c"
        break;
      case 54:
#line 249 "parser.y"
{ yygotominor.yy42 = yymsp[0].minor.yy42; }
#line 1172 "parser.c"
        break;
      case 55:
      case 61:
#line 251 "parser.y"
{ yygotominor.yy42 = yymsp[-1].minor.yy42; }
#line 1178 "parser.c"
        break;
      case 56:
#line 253 "parser.y"
{ if (yymsp[-3].minor.yy42) { yymsp[-3].minor.yy42->next = yymsp[0].minor.yy42; yygotominor.yy42 = yymsp[-3].minor.yy42; } else { yygotominor.yy42 = yymsp[0].minor.yy42; } }
#line 1183 "parser.c"
        break;
      case 58:
#line 259 "parser.y"
{ if (yymsp[-1].minor.yy42 && (yygotominor.yy42 = css_new_node(param->stylesheet,
		                CSS_NODE_DECLARATION,
				yymsp[-5].minor.yy0.text, yymsp[-5].minor.yy0.length))) {
			yygotominor.yy42->value = yymsp[-1].minor.yy42;
		} else {
			param->memory_error = true;
			css_free_node(yymsp[-1].minor.yy42);
			yygotominor.yy42 = 0;
		} }
#line 1196 "parser.c"
        break;
      case 59:
#line 269 "parser.y"
{ yygotominor.yy42 = 0; css_free_node(yymsp[0].minor.yy42); }
#line 1201 "parser.c"
        break;
      case 62:
#line 277 "parser.y"
{ if (yymsp[-2].minor.yy42 && yymsp[0].minor.yy42) { yymsp[-2].minor.yy42->next = yymsp[0].minor.yy42; yygotominor.yy42 = yymsp[-2].minor.yy42; }
		else { css_free_node(yymsp[-2].minor.yy42); css_free_node(yymsp[0].minor.yy42); yygotominor.yy42 = 0; } }
#line 1207 "parser.c"
        break;
      case 63:
#line 280 "parser.y"
{ yygotominor.yy42 = yymsp[-2].minor.yy42; }
#line 1212 "parser.c"
        break;
      case 64:
#line 282 "parser.y"
{ yygotominor.yy42 = yymsp[-3].minor.yy42; }
#line 1217 "parser.c"
        break;
      case 66:
      case 67:
#line 288 "parser.y"
{ if (yymsp[-2].minor.yy42) { yymsp[-2].minor.yy42->next = yymsp[0].minor.yy42; yygotominor.yy42 = yymsp[-2].minor.yy42; }
		else { css_free_node(yymsp[-2].minor.yy42); css_free_node(yymsp[0].minor.yy42); yygotominor.yy42 = 0; } }
#line 1224 "parser.c"
        break;
      case 68:
#line 294 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_IDENT,
		                   yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1231 "parser.c"
        break;
      case 69:
#line 298 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_NUMBER,
		                   yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1238 "parser.c"
        break;
      case 70:
#line 302 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_PERCENTAGE,
		                   yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1245 "parser.c"
        break;
      case 71:
#line 306 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_DIMENSION,
		                   yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1252 "parser.c"
        break;
      case 72:
#line 310 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_STRING,
		                   yymsp[0].minor.yy0.text + 1, yymsp[0].minor.yy0.length - 2);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1259 "parser.c"
        break;
      case 73:
      case 90:
#line 314 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_DELIM,
		                   yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1267 "parser.c"
        break;
      case 74:
#line 318 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_URI,
		                   yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1274 "parser.c"
        break;
      case 75:
#line 322 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_HASH,
		                   yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1281 "parser.c"
        break;
      case 76:
#line 326 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_UNICODE_RANGE,
		                   yymsp[0].minor.yy0.text, yymsp[0].minor.yy0.length);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1288 "parser.c"
        break;
      case 77:
#line 330 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_INCLUDES,
		                   0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1295 "parser.c"
        break;
      case 78:
#line 334 "parser.y"
{ if ((yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_FUNCTION,
		                        yymsp[-3].minor.yy0.text, yymsp[-3].minor.yy0.length)))
			yygotominor.yy42->value = yymsp[-1].minor.yy42;
		else {
			param->memory_error = true;
			css_free_node(yymsp[-1].minor.yy42);
			yygotominor.yy42 = 0;
		} }
#line 1307 "parser.c"
        break;
      case 79:
#line 343 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_DASHMATCH,
		                   0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1314 "parser.c"
        break;
      case 80:
#line 347 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_PREFIX,
		                   0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1321 "parser.c"
        break;
      case 81:
#line 351 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_SUFFIX,
		                   0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1328 "parser.c"
        break;
      case 82:
#line 355 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_SUBSTR,
		                   0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1335 "parser.c"
        break;
      case 83:
#line 359 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_COLON, 0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1341 "parser.c"
        break;
      case 84:
#line 362 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_COMMA, 0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1347 "parser.c"
        break;
      case 85:
#line 365 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_DOT, 0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1353 "parser.c"
        break;
      case 86:
#line 368 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_PLUS, 0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1359 "parser.c"
        break;
      case 87:
#line 371 "parser.y"
{ yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_GT, 0, 0);
		if (!yygotominor.yy42) param->memory_error = true; }
#line 1365 "parser.c"
        break;
      case 88:
#line 374 "parser.y"
{ if ((yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_PAREN,
		                        0, 0)))
			yygotominor.yy42->value = yymsp[-1].minor.yy42;
		else {
			param->memory_error = true;
			css_free_node(yymsp[-1].minor.yy42);
			yygotominor.yy42 = 0;
		} }
#line 1377 "parser.c"
        break;
      case 89:
#line 383 "parser.y"
{ if ((yygotominor.yy42 = css_new_node(param->stylesheet, CSS_NODE_BRAC,
		                        0, 0)))
			yygotominor.yy42->value = yymsp[-1].minor.yy42;
		else {
			param->memory_error = true;
			css_free_node(yymsp[-1].minor.yy42);
			yygotominor.yy42 = 0;
		} }
#line 1389 "parser.c"
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = yyact;
      yymsp->major = yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
    {
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else if( yyact == YYNSTATE + YYNRULE + 1 ){
    yy_accept(yypParser);
  }
}

/*
** The following code executes when the parse fails
*/
static void yy_parse_failed(
  yyParser *yypParser           /* The parser */
){
  css_parser_ARG_FETCH;
#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
  }
#endif
  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  /* Here code is inserted which will be executed whenever the
  ** parser fails */
  css_parser_ARG_STORE; /* Suppress warning about unused %extra_argument variable */
}

/*
** The following code executes when a syntax error first occurs.
*/
static void yy_syntax_error(
  yyParser *yypParser,           /* The parser */
  int yymajor,                   /* The major type of the error token */
  YYMINORTYPE yyminor            /* The minor type of the error token */
){
  css_parser_ARG_FETCH;
#define TOKEN (yyminor.yy0)
#line 441 "parser.y"
 param->syntax_error = true; 
#line 1449 "parser.c"
  css_parser_ARG_STORE; /* Suppress warning about unused %extra_argument variable */
}

/*
** The following is executed when the parser accepts
*/
static void yy_accept(
  yyParser *yypParser           /* The parser */
){
  css_parser_ARG_FETCH;
#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
  }
#endif
  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
  /* Here code is inserted which will be executed whenever the
  ** parser accepts */
  css_parser_ARG_STORE; /* Suppress warning about unused %extra_argument variable */
}

/* The main parser program.
** The first argument is a pointer to a structure obtained from
** "css_parser_Alloc" which describes the current state of the parser.
** The second argument is the major token number.  The third is
** the minor token.  The fourth optional argument is whatever the
** user wants (and specified in the grammar) and is available for
** use by the action routines.
**
** Inputs:
** <ul>
** <li> A pointer to the parser (an opaque structure.)
** <li> The major token number.
** <li> The minor token number.
** <li> An option argument of a grammar-specified type.
** </ul>
**
** Outputs:
** None.
*/
void css_parser_(
  void *yyp,                   /* The parser */
  int yymajor,                 /* The major token code number */
  css_parser_TOKENTYPE yyminor       /* The value for the token */
  css_parser_ARG_PDECL               /* Optional %extra_argument parameter */
){
  YYMINORTYPE yyminorunion;
  int yyact;            /* The parser action. */
  int yyendofinput;     /* True if we are at the end of input */
  int yyerrorhit = 0;   /* True if yymajor has invoked an error */
  yyParser *yypParser;  /* The parser */

  /* (re)initialize the parser, if necessary */
  yypParser = (yyParser*)yyp;
  if( yypParser->yyidx<0 ){
    /* if( yymajor==0 ) return; // not sure why this was here... */
    yypParser->yyidx = 0;
    yypParser->yyerrcnt = -1;
    yypParser->yystack[0].stateno = 0;
    yypParser->yystack[0].major = 0;
  }
  yyminorunion.yy0 = yyminor;
  yyendofinput = (yymajor==0);
  css_parser_ARG_STORE;

#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
  }
#endif

  do{
    yyact = yy_find_shift_action(yypParser,yymajor);
    if( yyact<YYNSTATE ){
      yy_shift(yypParser,yyact,yymajor,&yyminorunion);
      yypParser->yyerrcnt--;
      if( yyendofinput && yypParser->yyidx>=0 ){
        yymajor = 0;
      }else{
        yymajor = YYNOCODE;
      }
    }else if( yyact < YYNSTATE + YYNRULE ){
      yy_reduce(yypParser,yyact-YYNSTATE);
    }else if( yyact == YY_ERROR_ACTION ){
      int yymx;
#ifndef NDEBUG
      if( yyTraceFILE ){
        fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
      }
#endif
#ifdef YYERRORSYMBOL
      /* A syntax error has occurred.
      ** The response to an error depends upon whether or not the
      ** grammar defines an error token "ERROR".  
      **
      ** This is what we do if the grammar does define ERROR:
      **
      **  * Call the %syntax_error function.
      **
      **  * Begin popping the stack until we enter a state where
      **    it is legal to shift the error symbol, then shift
      **    the error symbol.
      **
      **  * Set the error count to three.
      **
      **  * Begin accepting and shifting new tokens.  No new error
      **    processing will occur until three tokens have been
      **    shifted successfully.
      **
      */
      if( yypParser->yyerrcnt<0 ){
        yy_syntax_error(yypParser,yymajor,yyminorunion);
      }
      yymx = yypParser->yystack[yypParser->yyidx].major;
      if( yymx==YYERRORSYMBOL || yyerrorhit ){
#ifndef NDEBUG
        if( yyTraceFILE ){
          fprintf(yyTraceFILE,"%sDiscard input token %s\n",
             yyTracePrompt,yyTokenName[yymajor]);
        }
#endif
        yy_destructor(yymajor,&yyminorunion);
        yymajor = YYNOCODE;
      }else{
         while(
          yypParser->yyidx >= 0 &&
          yymx != YYERRORSYMBOL &&
          (yyact = yy_find_reduce_action(
                        yypParser->yystack[yypParser->yyidx].stateno,
                        YYERRORSYMBOL)) >= YYNSTATE
        ){
          yy_pop_parser_stack(yypParser);
        }
        if( yypParser->yyidx < 0 || yymajor==0 ){
          yy_destructor(yymajor,&yyminorunion);
          yy_parse_failed(yypParser);
          yymajor = YYNOCODE;
        }else if( yymx!=YYERRORSYMBOL ){
          YYMINORTYPE u2;
          u2.YYERRSYMDT = 0;
          yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
        }
      }
      yypParser->yyerrcnt = 3;
      yyerrorhit = 1;
#else  /* YYERRORSYMBOL is not defined */
      /* This is what we do if the grammar does not define ERROR:
      **
      **  * Report an error message, and throw away the input token.
      **
      **  * If the input token is $, then fail the parse.
      **
      ** As before, subsequent error messages are suppressed until
      ** three input tokens have been successfully shifted.
      */
      if( yypParser->yyerrcnt<=0 ){
        yy_syntax_error(yypParser,yymajor,yyminorunion);
      }
      yypParser->yyerrcnt = 3;
      yy_destructor(yymajor,&yyminorunion);
      if( yyendofinput ){
        yy_parse_failed(yypParser);
      }
      yymajor = YYNOCODE;
#endif
    }else{
      yy_accept(yypParser);
      yymajor = YYNOCODE;
    }
  }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
  return;
}
