1 /* A Bison parser, made by GNU Bison 2.4.2.  */
2 
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
4 
5       Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
6    Foundation, Inc.
7 
8    This program is free software: you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20 
21 /* As a special exception, you may create a larger work that contains
22    part or all of the Bison parser skeleton and distribute that work
23    under terms of your choice, so long as that work isn't itself a
24    parser generator using the skeleton or a modified version thereof
25    as a parser skeleton.  Alternatively, if you modify or redistribute
26    the parser skeleton itself, you may (at your option) remove this
27    special exception, which will cause the skeleton and the resulting
28    Bison output files to be licensed under the GNU General Public
29    License without this special exception.
30 
31    This special exception was added by the Free Software Foundation in
32    version 2.2 of Bison.  */
33 
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35    simplifying the original so-called "semantic" parser.  */
36 
37 /* All symbols defined below should begin with yy or YY, to avoid
38    infringing on user name space.  This should be done even for local
39    variables, as they might otherwise be expanded by user macros.
40    There are some unavoidable exceptions within include files to
41    define necessary library symbols; they are noted "INFRINGES ON
42    USER NAME SPACE" below.  */
43 
44 /* Identify Bison output.  */
45 #define YYBISON 1
46 
47 /* Bison version.  */
48 #define YYBISON_VERSION "2.4.2"
49 
50 /* Skeleton name.  */
51 #define YYSKELETON_NAME "yacc.c"
52 
53 /* Pure parsers.  */
54 #define YYPURE 0
55 
56 /* Push parsers.  */
57 #define YYPUSH 0
58 
59 /* Pull parsers.  */
60 #define YYPULL 1
61 
62 /* Using locations.  */
63 #define YYLSP_NEEDED 0
64 
65 /* Substitute the variable and function names.  */
66 #define yyparse         khtmlxpathyyparse
67 #define yylex           khtmlxpathyylex
68 #define yyerror         khtmlxpathyyerror
69 #define yylval          khtmlxpathyylval
70 #define yychar          khtmlxpathyychar
71 #define yydebug         khtmlxpathyydebug
72 #define yynerrs         khtmlxpathyynerrs
73 
74 /* Copy the first part of user declarations.  */
75 
76 /* Line 189 of yacc.c  */
77 #line 1 "parser.y"
78 
79 #include "functions.h"
80 #include "path.h"
81 #include "predicate.h"
82 #include "util.h"
83 #include "tokenizer.h"
84 
85 #include "expression.h"
86 #include "util.h"
87 #include "variablereference.h"
88 
89 #include "dom/dom_string.h"
90 #include "dom/dom_exception.h"
91 #include "dom/dom3_xpath.h"
92 #include "xml/dom_stringimpl.h"
93 #include "xml/dom3_xpathimpl.h"
94 
95 using namespace DOM;
96 using namespace DOM::XPath;
97 using namespace khtml;
98 using namespace khtml::XPath;
99 
100 #include <QList>
101 #include <QPair>
102 #include <QtDebug>
103 
104 #define YYDEBUG 1
105 
106 Expression *khtmlParseXPathStatement(const DOM::DOMString &statement, int &ec);
107 
108 static Expression *_topExpr;
109 static int xpathParseException;
110 
111 /* Line 189 of yacc.c  */
112 #line 118 "parser.tab.c"
113 
114 /* Enabling traces.  */
115 #ifndef YYDEBUG
116 # define YYDEBUG 0
117 #endif
118 
119 /* Enabling verbose error messages.  */
120 #ifdef YYERROR_VERBOSE
121 # undef YYERROR_VERBOSE
122 # define YYERROR_VERBOSE 1
123 #else
124 # define YYERROR_VERBOSE 0
125 #endif
126 
127 /* Enabling the token table.  */
128 #ifndef YYTOKEN_TABLE
129 # define YYTOKEN_TABLE 0
130 #endif
131 
132 /* Tokens.  */
133 #ifndef YYTOKENTYPE
134 # define YYTOKENTYPE
135 /* Put the tokens into the symbol table, so that GDB and other debuggers
136    know about them.  */
137 enum yytokentype {
138     EQOP = 258,
139     RELOP = 259,
140     MULOP = 260,
141     MINUS = 261,
142     PLUS = 262,
143     AND = 263,
144     OR = 264,
145     AXISNAME = 265,
146     NODETYPE = 266,
147     PI = 267,
148     FUNCTIONNAME = 268,
149     LITERAL = 269,
150     VARIABLEREFERENCE = 270,
151     NUMBER = 271,
152     DOTDOT = 272,
153     SLASHSLASH = 273,
154     NAMETEST = 274,
155     ERROR = 275
156 };
157 #endif
158 
159 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
160 typedef union YYSTYPE {
161 
162     /* Line 214 of yacc.c  */
163 #line 39 "parser.y"
164 
165     khtml::XPath::Step::AxisType axisType;
166     int        num;
167     DOM::DOMString *str; // we use this and not DOMStringImpl*, so the
168     // memory management for this is entirely manual,
169     // and not an RC/manual hybrid
170     khtml::XPath::Expression *expr;
171     QList<khtml::XPath::Predicate *> *predList;
172     QList<khtml::XPath::Expression *> *argList;
173     khtml::XPath::Step *step;
174     khtml::XPath::LocationPath *locationPath;
175 
176     /* Line 214 of yacc.c  */
177 #line 189 "parser.tab.c"
178 } YYSTYPE;
179 # define YYSTYPE_IS_TRIVIAL 1
180 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
181 # define YYSTYPE_IS_DECLARED 1
182 #endif
183 
184 /* Copy the second part of user declarations.  */
185 
186 /* Line 264 of yacc.c  */
187 #line 52 "parser.y"
188 
189 /* Line 264 of yacc.c  */
190 #line 205 "parser.tab.c"
191 
192 #ifdef short
193 # undef short
194 #endif
195 
196 #ifdef YYTYPE_UINT8
197 typedef YYTYPE_UINT8 yytype_uint8;
198 #else
199 typedef unsigned char yytype_uint8;
200 #endif
201 
202 #ifdef YYTYPE_INT8
203 typedef YYTYPE_INT8 yytype_int8;
204 #elif (defined __STDC__ || defined __C99__FUNC__ \
205      || defined __cplusplus || defined _MSC_VER)
206 typedef signed char yytype_int8;
207 #else
208 typedef short int yytype_int8;
209 #endif
210 
211 #ifdef YYTYPE_UINT16
212 typedef YYTYPE_UINT16 yytype_uint16;
213 #else
214 typedef unsigned short int yytype_uint16;
215 #endif
216 
217 #ifdef YYTYPE_INT16
218 typedef YYTYPE_INT16 yytype_int16;
219 #else
220 typedef short int yytype_int16;
221 #endif
222 
223 #ifndef YYSIZE_T
224 # ifdef __SIZE_TYPE__
225 #  define YYSIZE_T __SIZE_TYPE__
226 # elif defined size_t
227 #  define YYSIZE_T size_t
228 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
229      || defined __cplusplus || defined _MSC_VER)
230 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
231 #  define YYSIZE_T size_t
232 # else
233 #  define YYSIZE_T unsigned int
234 # endif
235 #endif
236 
237 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
238 
239 #ifndef YY_
240 # if defined YYENABLE_NLS && YYENABLE_NLS
241 #  if ENABLE_NLS
242 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
243 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
244 #  endif
245 # endif
246 # ifndef YY_
247 #  define YY_(msgid) msgid
248 # endif
249 #endif
250 
251 /* Suppress unused-variable warnings by "using" E.  */
252 #if ! defined lint || defined __GNUC__
253 # define YYUSE(e) ((void) (e))
254 #else
255 # define YYUSE(e) /* empty */
256 #endif
257 
258 /* Identity function, used to suppress warnings about constant conditions.  */
259 #ifndef lint
260 # define YYID(n) (n)
261 #else
262 #if (defined __STDC__ || defined __C99__FUNC__ \
263      || defined __cplusplus || defined _MSC_VER)
264 static int
YYID(int yyi)265 YYID(int yyi)
266 #else
267 static int
268 YYID(yyi)
269 int yyi;
270 #endif
271 {
272     return yyi;
273 }
274 #endif
275 
276 #if ! defined yyoverflow || YYERROR_VERBOSE
277 
278 /* The parser invokes alloca or malloc; define the necessary symbols.  */
279 
280 # ifdef YYSTACK_USE_ALLOCA
281 #  if YYSTACK_USE_ALLOCA
282 #   ifdef __GNUC__
283 #    define YYSTACK_ALLOC __builtin_alloca
284 #   elif defined __BUILTIN_VA_ARG_INCR
285 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
286 #   elif defined _AIX
287 #    define YYSTACK_ALLOC __alloca
288 #   elif defined _MSC_VER
289 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
290 #    define alloca _alloca
291 #   else
292 #    define YYSTACK_ALLOC alloca
293 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
294      || defined __cplusplus || defined _MSC_VER)
295 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
296 #     ifndef _STDLIB_H
297 #      define _STDLIB_H 1
298 #     endif
299 #    endif
300 #   endif
301 #  endif
302 # endif
303 
304 # ifdef YYSTACK_ALLOC
305 /* Pacify GCC's `empty if-body' warning.  */
306 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
307 #  ifndef YYSTACK_ALLOC_MAXIMUM
308 /* The OS might guarantee only one guard page at the bottom of the stack,
309    and a page size can be as small as 4096 bytes.  So we cannot safely
310    invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
311    to allow for a few compiler-allocated temporary stack slots.  */
312 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
313 #  endif
314 # else
315 #  define YYSTACK_ALLOC YYMALLOC
316 #  define YYSTACK_FREE YYFREE
317 #  ifndef YYSTACK_ALLOC_MAXIMUM
318 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
319 #  endif
320 #  if (defined __cplusplus && ! defined _STDLIB_H \
321        && ! ((defined YYMALLOC || defined malloc) \
322          && (defined YYFREE || defined free)))
323 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
324 #   ifndef _STDLIB_H
325 #    define _STDLIB_H 1
326 #   endif
327 #  endif
328 #  ifndef YYMALLOC
329 #   define YYMALLOC malloc
330 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
331      || defined __cplusplus || defined _MSC_VER)
332 void *malloc(YYSIZE_T);  /* INFRINGES ON USER NAME SPACE */
333 #   endif
334 #  endif
335 #  ifndef YYFREE
336 #   define YYFREE free
337 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
338      || defined __cplusplus || defined _MSC_VER)
339 void free(void *);  /* INFRINGES ON USER NAME SPACE */
340 #   endif
341 #  endif
342 # endif
343 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
344 
345 #if (! defined yyoverflow \
346      && (! defined __cplusplus \
347      || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
348 
349 /* A type that is properly aligned for any stack member.  */
350 union yyalloc {
351     yytype_int16 yyss_alloc;
352     YYSTYPE yyvs_alloc;
353 };
354 
355 /* The size of the maximum gap between one aligned stack and the next.  */
356 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
357 
358 /* The size of an array large to enough to hold all stacks, each with
359    N elements.  */
360 # define YYSTACK_BYTES(N) \
361     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
362      + YYSTACK_GAP_MAXIMUM)
363 
364 /* Copy COUNT objects from FROM to TO.  The source and destination do
365    not overlap.  */
366 # ifndef YYCOPY
367 #  if defined __GNUC__ && 1 < __GNUC__
368 #   define YYCOPY(To, From, Count) \
369     __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
370 #  else
371 #   define YYCOPY(To, From, Count)      \
372     do                    \
373     {                   \
374         YYSIZE_T yyi;             \
375         for (yyi = 0; yyi < (Count); yyi++)   \
376             (To)[yyi] = (From)[yyi];        \
377     }                   \
378     while (YYID (0))
379 #  endif
380 # endif
381 
382 /* Relocate STACK from its old location to the new one.  The
383    local variables YYSIZE and YYSTACKSIZE give the old and new number of
384    elements in the stack, and YYPTR gives the new location of the
385    stack.  Advance YYPTR to a properly aligned location for the next
386    stack.  */
387 # define YYSTACK_RELOCATE(Stack_alloc, Stack)               \
388     do                                  \
389     {                                 \
390         YYSIZE_T yynewbytes;                        \
391         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);            \
392         Stack = &yyptr->Stack_alloc;                    \
393         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
394         yyptr += yynewbytes / sizeof (*yyptr);              \
395     }                                 \
396     while (YYID (0))
397 
398 #endif
399 
400 /* YYFINAL -- State number of the termination state.  */
401 #define YYFINAL  43
402 /* YYLAST -- Last index in YYTABLE.  */
403 #define YYLAST   115
404 
405 /* YYNTOKENS -- Number of terminals.  */
406 #define YYNTOKENS  30
407 /* YYNNTS -- Number of nonterminals.  */
408 #define YYNNTS  26
409 /* YYNRULES -- Number of rules.  */
410 #define YYNRULES  60
411 /* YYNRULES -- Number of states.  */
412 #define YYNSTATES  90
413 
414 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
415 #define YYUNDEFTOK  2
416 #define YYMAXUTOK   275
417 
418 #define YYTRANSLATE(YYX)                        \
419     ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
420 
421 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
422 static const yytype_uint8 yytranslate[] = {
423     0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
424     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
425     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
426     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
427     23,    24,     2,     2,    28,     2,    27,    21,     2,     2,
428     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
429     2,     2,     2,     2,    22,     2,     2,     2,     2,     2,
430     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
431     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
432     2,    25,     2,    26,     2,     2,     2,     2,     2,     2,
433     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
434     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
435     2,     2,     2,     2,    29,     2,     2,     2,     2,     2,
436     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
437     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
438     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
439     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
440     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
441     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
442     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
443     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
444     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
445     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
446     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
447     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
448     2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
449     5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
450     15,    16,    17,    18,    19,    20
451 };
452 
453 #if YYDEBUG
454 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
455    YYRHS.  */
456 static const yytype_uint8 yyprhs[] = {
457     0,     0,     3,     5,     7,     9,    11,    14,    17,    19,
458     23,    27,    29,    32,    35,    39,    41,    43,    45,    47,
459     51,    55,    60,    62,    65,    69,    71,    73,    75,    77,
460     81,    83,    85,    87,    91,    96,    98,   102,   104,   106,
461     110,   112,   114,   118,   122,   124,   127,   129,   133,   135,
462     139,   141,   145,   147,   151,   153,   157,   161,   163,   167,
463     169
464 };
465 
466 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
467 static const yytype_int8 yyrhs[] = {
468     31,     0,    -1,    49,    -1,    34,    -1,    33,    -1,    21,
469     -1,    21,    34,    -1,    40,    34,    -1,    35,    -1,    34,
470     21,    35,    -1,    34,    40,    35,    -1,    37,    -1,    37,
471     38,    -1,    36,    37,    -1,    36,    37,    38,    -1,    41,
472     -1,    10,    -1,    22,    -1,    19,    -1,    11,    23,    24,
473     -1,    12,    23,    24,    -1,    12,    23,    14,    24,    -1,
474     39,    -1,    38,    39,    -1,    25,    31,    26,    -1,    18,
475     -1,    27,    -1,    17,    -1,    15,    -1,    23,    31,    24,
476     -1,    14,    -1,    16,    -1,    43,    -1,    13,    23,    24,
477     -1,    13,    23,    44,    24,    -1,    45,    -1,    44,    28,
478     45,    -1,    31,    -1,    47,    -1,    46,    29,    47,    -1,
479     32,    -1,    48,    -1,    48,    21,    34,    -1,    48,    40,
480     34,    -1,    42,    -1,    42,    38,    -1,    50,    -1,    49,
481     9,    50,    -1,    51,    -1,    50,     8,    51,    -1,    52,
482     -1,    51,     3,    52,    -1,    53,    -1,    52,     4,    53,
483     -1,    54,    -1,    53,     7,    54,    -1,    53,     6,    54,
484     -1,    55,    -1,    54,     5,    55,    -1,    46,    -1,     6,
485     55,    -1
486 };
487 
488 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
489 static const yytype_uint16 yyrline[] = {
490     0,    93,    93,   100,   105,   112,   117,   122,   130,   136,
491     141,   149,   155,   162,   168,   175,   179,   181,   188,   202,
492     207,   209,   220,   226,   233,   240,   247,   252,   259,   265,
493     270,   276,   282,   286,   298,   312,   318,   325,   330,   332,
494     341,   346,   351,   356,   364,   369,   376,   378,   385,   387,
495     394,   396,   403,   405,   412,   414,   419,   426,   428,   435,
496     437
497 };
498 #endif
499 
500 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
501 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
502    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
503 static const char *const yytname[] = {
504     "$end", "error", "$undefined", "EQOP", "RELOP", "MULOP", "MINUS",
505     "PLUS", "AND", "OR", "AXISNAME", "NODETYPE", "PI", "FUNCTIONNAME",
506     "LITERAL", "VARIABLEREFERENCE", "NUMBER", "DOTDOT", "SLASHSLASH",
507     "NAMETEST", "ERROR", "'/'", "'@'", "'('", "')'", "'['", "']'", "'.'",
508     "','", "'|'", "$accept", "Expr", "LocationPath", "AbsoluteLocationPath",
509     "RelativeLocationPath", "Step", "AxisSpecifier", "NodeTest",
510     "PredicateList", "Predicate", "DescendantOrSelf", "AbbreviatedStep",
511     "PrimaryExpr", "FunctionCall", "ArgumentList", "Argument", "UnionExpr",
512     "PathExpr", "FilterExpr", "OrExpr", "AndExpr", "EqualityExpr",
513     "RelationalExpr", "AdditiveExpr", "MultiplicativeExpr", "UnaryExpr", nullptr
514 };
515 #endif
516 
517 # ifdef YYPRINT
518 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
519    token YYLEX-NUM.  */
520 static const yytype_uint16 yytoknum[] = {
521     0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
522     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
523     275,    47,    64,    40,    41,    91,    93,    46,    44,   124
524 };
525 # endif
526 
527 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
528 static const yytype_uint8 yyr1[] = {
529     0,    30,    31,    32,    32,    33,    33,    33,    34,    34,
530     34,    35,    35,    35,    35,    35,    36,    36,    37,    37,
531     37,    37,    38,    38,    39,    40,    41,    41,    42,    42,
532     42,    42,    42,    43,    43,    44,    44,    45,    46,    46,
533     47,    47,    47,    47,    48,    48,    49,    49,    50,    50,
534     51,    51,    52,    52,    53,    53,    53,    54,    54,    55,
535     55
536 };
537 
538 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
539 static const yytype_uint8 yyr2[] = {
540     0,     2,     1,     1,     1,     1,     2,     2,     1,     3,
541     3,     1,     2,     2,     3,     1,     1,     1,     1,     3,
542     3,     4,     1,     2,     3,     1,     1,     1,     1,     3,
543     1,     1,     1,     3,     4,     1,     3,     1,     1,     3,
544     1,     1,     3,     3,     1,     2,     1,     3,     1,     3,
545     1,     3,     1,     3,     1,     3,     3,     1,     3,     1,
546     2
547 };
548 
549 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
550    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
551    means the default is an error.  */
552 static const yytype_uint8 yydefact[] = {
553     0,     0,    16,     0,     0,     0,    30,    28,    31,    27,
554     25,    18,     5,    17,     0,    26,     0,    40,     4,     3,
555     8,     0,    11,     0,    15,    44,    32,    59,    38,    41,
556     2,    46,    48,    50,    52,    54,    57,    60,     0,     0,
557     0,     6,     0,     1,     0,     0,    13,     0,    12,    22,
558     7,    45,     0,     0,     0,     0,     0,     0,     0,     0,
559     0,     0,    19,     0,    20,    33,    37,     0,    35,    29,
560     9,    10,    14,     0,    23,    39,    42,    43,    47,    49,
561     51,    53,    56,    55,    58,    21,    34,     0,    24,    36
562 };
563 
564 /* YYDEFGOTO[NTERM-NUM].  */
565 static const yytype_int8 yydefgoto[] = {
566     -1,    66,    17,    18,    19,    20,    21,    22,    48,    49,
567     23,    24,    25,    26,    67,    68,    27,    28,    29,    30,
568     31,    32,    33,    34,    35,    36
569 };
570 
571 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
572    STATE-NUM.  */
573 #define YYPACT_NINF -45
574 static const yytype_int8 yypact[] = {
575     70,    70,   -45,   -17,     4,    14,   -45,   -45,   -45,   -45,
576     -45,   -45,    -2,   -45,    70,   -45,    39,   -45,   -45,     3,
577     -45,    19,    17,    -2,   -45,    17,   -45,    18,   -45,    15,
578     34,    38,    45,    46,     6,    47,   -45,   -45,    27,     5,
579     51,     3,    29,   -45,    -2,    -2,    17,    70,    17,   -45,
580     3,    17,    88,    -2,    -2,    70,    70,    70,    70,    70,
581     70,    70,   -45,    30,   -45,   -45,   -45,    -6,   -45,   -45,
582     -45,   -45,    17,    53,   -45,   -45,     3,     3,    38,    45,
583     46,     6,    47,    47,   -45,   -45,   -45,    70,   -45,   -45
584 };
585 
586 /* YYPGOTO[NTERM-NUM].  */
587 static const yytype_int8 yypgoto[] = {
588     -45,     2,   -45,   -45,    -9,   -10,   -45,    35,   -20,   -44,
589     -18,   -45,   -45,   -45,   -45,   -32,   -45,    25,   -45,   -45,
590     16,    40,    33,    36,   -19,    -1
591 };
592 
593 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
594    positive, shift that token.  If negative, reduce the rule which
595    number is the opposite.  If zero, do what YYDEFACT says.
596    If YYTABLE_NINF, syntax error.  */
597 #define YYTABLE_NINF -1
598 static const yytype_uint8 yytable[] = {
599     37,    45,    16,    41,    74,    51,    38,    74,     2,     3,
600     4,    54,    59,    60,    50,     9,    42,    11,    86,    63,
601     13,    10,    87,    45,    44,    15,    72,    39,    74,    64,
602     3,     4,    45,    10,    70,    71,    53,    40,    11,    43,
603     82,    83,    47,    55,    76,    77,    56,    52,    57,    73,
604     58,    62,    61,    69,    85,    89,    46,     1,    45,    45,
605     84,     2,     3,     4,     5,     6,     7,     8,     9,    10,
606     11,    78,    12,    13,    14,    65,     1,    75,    15,    88,
607     2,     3,     4,     5,     6,     7,     8,     9,    10,    11,
608     80,    12,    13,    14,    81,     0,    79,    15,     2,     3,
609     4,     5,     6,     7,     8,     9,    10,    11,     0,    12,
610     13,    14,     0,     0,     0,    15
611 };
612 
613 static const yytype_int8 yycheck[] = {
614     1,    19,     0,    12,    48,    25,    23,    51,    10,    11,
615     12,    29,     6,     7,    23,    17,    14,    19,    24,    14,
616     22,    18,    28,    41,    21,    27,    46,    23,    72,    24,
617     11,    12,    50,    18,    44,    45,    21,    23,    19,     0,
618     59,    60,    25,     9,    53,    54,     8,    29,     3,    47,
619     4,    24,     5,    24,    24,    87,    21,     6,    76,    77,
620     61,    10,    11,    12,    13,    14,    15,    16,    17,    18,
621     19,    55,    21,    22,    23,    24,     6,    52,    27,    26,
622     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
623     57,    21,    22,    23,    58,    -1,    56,    27,    10,    11,
624     12,    13,    14,    15,    16,    17,    18,    19,    -1,    21,
625     22,    23,    -1,    -1,    -1,    27
626 };
627 
628 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
629    symbol of state STATE-NUM.  */
630 static const yytype_uint8 yystos[] = {
631     0,     6,    10,    11,    12,    13,    14,    15,    16,    17,
632     18,    19,    21,    22,    23,    27,    31,    32,    33,    34,
633     35,    36,    37,    40,    41,    42,    43,    46,    47,    48,
634     49,    50,    51,    52,    53,    54,    55,    55,    23,    23,
635     23,    34,    31,     0,    21,    40,    37,    25,    38,    39,
636     34,    38,    29,    21,    40,     9,     8,     3,     4,     6,
637     7,     5,    24,    14,    24,    24,    31,    44,    45,    24,
638     35,    35,    38,    31,    39,    47,    34,    34,    50,    51,
639     52,    53,    54,    54,    55,    24,    24,    28,    26,    45
640 };
641 
642 #define yyerrok     (yyerrstatus = 0)
643 #define yyclearin   (yychar = YYEMPTY)
644 #define YYEMPTY     (-2)
645 #define YYEOF       0
646 
647 #define YYACCEPT    goto yyacceptlab
648 #define YYABORT     goto yyabortlab
649 #define YYERROR     goto yyerrorlab
650 
651 /* Like YYERROR except do call yyerror.  This remains here temporarily
652    to ease the transition to the new meaning of YYERROR, for GCC.
653    Once GCC version 2 has supplanted version 1, this can go.  However,
654    YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
655    in Bison 2.4.2's NEWS entry, where a plan to phase it out is
656    discussed.  */
657 
658 #define YYFAIL      goto yyerrlab
659 #if defined YYFAIL
660 /* This is here to suppress warnings from the GCC cpp's
661    -Wunused-macros.  Normally we don't worry about that warning, but
662    some users do, and we want to make it easy for users to remove
663    YYFAIL uses, which will produce warnings from Bison 2.5.  */
664 #endif
665 
666 #define YYRECOVERING()  (!!yyerrstatus)
667 
668 #define YYBACKUP(Token, Value)                  \
669     do                              \
670         if (yychar == YYEMPTY && yylen == 1)              \
671         {                               \
672             yychar = (Token);                     \
673             yylval = (Value);                     \
674             yytoken = YYTRANSLATE (yychar);               \
675             YYPOPSTACK (1);                       \
676             goto yybackup;                        \
677         }                               \
678         else                              \
679         {                               \
680             yyerror (YY_("syntax error: cannot back up")); \
681             YYERROR;                          \
682         }                               \
683     while (YYID (0))
684 
685 #define YYTERROR    1
686 #define YYERRCODE   256
687 
688 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
689    If N is 0, then set CURRENT to the empty location which ends
690    the previous symbol: RHS[0] (always defined).  */
691 
692 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
693 #ifndef YYLLOC_DEFAULT
694 # define YYLLOC_DEFAULT(Current, Rhs, N)                \
695     do                                  \
696         if (YYID (N))                                                    \
697         {                               \
698             (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;    \
699             (Current).first_column = YYRHSLOC (Rhs, 1).first_column;  \
700             (Current).last_line    = YYRHSLOC (Rhs, N).last_line;     \
701             (Current).last_column  = YYRHSLOC (Rhs, N).last_column;   \
702         }                               \
703         else                              \
704         {                               \
705             (Current).first_line   = (Current).last_line   =      \
706                                      YYRHSLOC (Rhs, 0).last_line;                \
707             (Current).first_column = (Current).last_column =      \
708                                      YYRHSLOC (Rhs, 0).last_column;              \
709         }                               \
710     while (YYID (0))
711 #endif
712 
713 /* YY_LOCATION_PRINT -- Print the location on the stream.
714    This macro was not mandated originally: define only if we know
715    we won't break user code: when these are the locations we know.  */
716 
717 #ifndef YY_LOCATION_PRINT
718 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
719 #  define YY_LOCATION_PRINT(File, Loc)          \
720     fprintf (File, "%d.%d-%d.%d",          \
721              (Loc).first_line, (Loc).first_column, \
722              (Loc).last_line,  (Loc).last_column)
723 # else
724 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
725 # endif
726 #endif
727 
728 /* YYLEX -- calling `yylex' with the right arguments.  */
729 
730 #ifdef YYLEX_PARAM
731 # define YYLEX yylex (YYLEX_PARAM)
732 #else
733 # define YYLEX yylex ()
734 #endif
735 
736 /* Enable debugging if requested.  */
737 #if YYDEBUG
738 
739 # ifndef YYFPRINTF
740 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
741 #  define YYFPRINTF fprintf
742 # endif
743 
744 # define YYDPRINTF(Args)            \
745     do {                        \
746         if (yydebug)                  \
747             YYFPRINTF Args;             \
748     } while (YYID (0))
749 
750 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)            \
751     do {                                      \
752         if (yydebug)                                \
753         {                                     \
754             YYFPRINTF (stderr, "%s ", Title);                   \
755             yy_symbol_print (stderr,                        \
756                              Type, Value); \
757             YYFPRINTF (stderr, "\n");                       \
758         }                                     \
759     } while (YYID (0))
760 
761 /*--------------------------------.
762 | Print this symbol on YYOUTPUT.  |
763 `--------------------------------*/
764 
765 /*ARGSUSED*/
766 #if (defined __STDC__ || defined __C99__FUNC__ \
767      || defined __cplusplus || defined _MSC_VER)
768 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)769 yy_symbol_value_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep)
770 #else
771 static void
772 yy_symbol_value_print(yyoutput, yytype, yyvaluep)
773 FILE *yyoutput;
774 int yytype;
775 YYSTYPE const *const yyvaluep;
776 #endif
777 {
778     if (!yyvaluep) {
779         return;
780     }
781 # ifdef YYPRINT
782     if (yytype < YYNTOKENS) {
783         YYPRINT(yyoutput, yytoknum[yytype], *yyvaluep);
784     }
785 # else
786     YYUSE(yyoutput);
787 # endif
788     switch (yytype) {
789     default:
790         break;
791     }
792 }
793 
794 /*--------------------------------.
795 | Print this symbol on YYOUTPUT.  |
796 `--------------------------------*/
797 
798 #if (defined __STDC__ || defined __C99__FUNC__ \
799      || defined __cplusplus || defined _MSC_VER)
800 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)801 yy_symbol_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep)
802 #else
803 static void
804 yy_symbol_print(yyoutput, yytype, yyvaluep)
805 FILE *yyoutput;
806 int yytype;
807 YYSTYPE const *const yyvaluep;
808 #endif
809 {
810     if (yytype < YYNTOKENS) {
811         YYFPRINTF(yyoutput, "token %s (", yytname[yytype]);
812     } else {
813         YYFPRINTF(yyoutput, "nterm %s (", yytname[yytype]);
814     }
815 
816     yy_symbol_value_print(yyoutput, yytype, yyvaluep);
817     YYFPRINTF(yyoutput, ")");
818 }
819 
820 /*------------------------------------------------------------------.
821 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
822 | TOP (included).                                                   |
823 `------------------------------------------------------------------*/
824 
825 #if (defined __STDC__ || defined __C99__FUNC__ \
826      || defined __cplusplus || defined _MSC_VER)
827 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)828 yy_stack_print(yytype_int16 *yybottom, yytype_int16 *yytop)
829 #else
830 static void
831 yy_stack_print(yybottom, yytop)
832 yytype_int16 *yybottom;
833 yytype_int16 *yytop;
834 #endif
835 {
836     YYFPRINTF(stderr, "Stack now");
837     for (; yybottom <= yytop; yybottom++) {
838         int yybot = *yybottom;
839         YYFPRINTF(stderr, " %d", yybot);
840     }
841     YYFPRINTF(stderr, "\n");
842 }
843 
844 # define YY_STACK_PRINT(Bottom, Top)                \
845     do {                                \
846         if (yydebug)                          \
847             yy_stack_print ((Bottom), (Top));               \
848     } while (YYID (0))
849 
850 /*------------------------------------------------.
851 | Report that the YYRULE is going to be reduced.  |
852 `------------------------------------------------*/
853 
854 #if (defined __STDC__ || defined __C99__FUNC__ \
855      || defined __cplusplus || defined _MSC_VER)
856 static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule)857 yy_reduce_print(YYSTYPE *yyvsp, int yyrule)
858 #else
859 static void
860 yy_reduce_print(yyvsp, yyrule)
861 YYSTYPE *yyvsp;
862 int yyrule;
863 #endif
864 {
865     int yynrhs = yyr2[yyrule];
866     int yyi;
867     unsigned long int yylno = yyrline[yyrule];
868     YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n",
869               yyrule - 1, yylno);
870     /* The symbols being reduced.  */
871     for (yyi = 0; yyi < yynrhs; yyi++) {
872         YYFPRINTF(stderr, "   $%d = ", yyi + 1);
873         yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi],
874                         &(yyvsp[(yyi + 1) - (yynrhs)])
875                        );
876         YYFPRINTF(stderr, "\n");
877     }
878 }
879 
880 # define YY_REDUCE_PRINT(Rule)      \
881     do {                    \
882         if (yydebug)              \
883             yy_reduce_print (yyvsp, Rule); \
884     } while (YYID (0))
885 
886 /* Nonzero means print parse trace.  It is left uninitialized so that
887    multiple parsers can coexist.  */
888 int yydebug;
889 #else /* !YYDEBUG */
890 # define YYDPRINTF(Args)
891 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
892 # define YY_STACK_PRINT(Bottom, Top)
893 # define YY_REDUCE_PRINT(Rule)
894 #endif /* !YYDEBUG */
895 
896 /* YYINITDEPTH -- initial size of the parser's stacks.  */
897 #ifndef YYINITDEPTH
898 # define YYINITDEPTH 200
899 #endif
900 
901 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
902    if the built-in stack extension method is used).
903 
904    Do not make this value too large; the results are undefined if
905    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
906    evaluated with infinite-precision integer arithmetic.  */
907 
908 #ifndef YYMAXDEPTH
909 # define YYMAXDEPTH 10000
910 #endif
911 
912 #if YYERROR_VERBOSE
913 
914 # ifndef yystrlen
915 #  if defined __GLIBC__ && defined _STRING_H
916 #   define yystrlen strlen
917 #  else
918 /* Return the length of YYSTR.  */
919 #if (defined __STDC__ || defined __C99__FUNC__ \
920      || defined __cplusplus || defined _MSC_VER)
921 static YYSIZE_T
yystrlen(const char * yystr)922 yystrlen(const char *yystr)
923 #else
924 static YYSIZE_T
925 yystrlen(yystr)
926 const char *yystr;
927 #endif
928 {
929     YYSIZE_T yylen;
930     for (yylen = 0; yystr[yylen]; yylen++) {
931         continue;
932     }
933     return yylen;
934 }
935 #  endif
936 # endif
937 
938 # ifndef yystpcpy
939 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
940 #   define yystpcpy stpcpy
941 #  else
942 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
943    YYDEST.  */
944 #if (defined __STDC__ || defined __C99__FUNC__ \
945      || defined __cplusplus || defined _MSC_VER)
946 static char *
yystpcpy(char * yydest,const char * yysrc)947 yystpcpy(char *yydest, const char *yysrc)
948 #else
949 static char *
950 yystpcpy(yydest, yysrc)
951 char *yydest;
952 const char *yysrc;
953 #endif
954 {
955     char *yyd = yydest;
956     const char *yys = yysrc;
957 
958     while ((*yyd++ = *yys++) != '\0') {
959         continue;
960     }
961 
962     return yyd - 1;
963 }
964 #  endif
965 # endif
966 
967 # ifndef yytnamerr
968 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
969    quotes and backslashes, so that it's suitable for yyerror.  The
970    heuristic is that double-quoting is unnecessary unless the string
971    contains an apostrophe, a comma, or backslash (other than
972    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
973    null, do not copy; instead, return the length of what the result
974    would have been.  */
975 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)976 yytnamerr(char *yyres, const char *yystr)
977 {
978     if (*yystr == '"') {
979         YYSIZE_T yyn = 0;
980         char const *yyp = yystr;
981 
982         for (;;)
983             switch (*++yyp) {
984             case '\'':
985             case ',':
986                 goto do_not_strip_quotes;
987 
988             case '\\':
989                 if (*++yyp != '\\') {
990                     goto do_not_strip_quotes;
991                 }
992             /* Fall through.  */
993             default:
994                 if (yyres) {
995                     yyres[yyn] = *yyp;
996                 }
997                 yyn++;
998                 break;
999 
1000             case '"':
1001                 if (yyres) {
1002                     yyres[yyn] = '\0';
1003                 }
1004                 return yyn;
1005             }
1006     do_not_strip_quotes:;
1007     }
1008 
1009     if (! yyres) {
1010         return yystrlen(yystr);
1011     }
1012 
1013     return yystpcpy(yyres, yystr) - yyres;
1014 }
1015 # endif
1016 
1017 /* Copy into YYRESULT an error message about the unexpected token
1018    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1019    including the terminating null byte.  If YYRESULT is null, do not
1020    copy anything; just return the number of bytes that would be
1021    copied.  As a special case, return 0 if an ordinary "syntax error"
1022    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1023    size calculation.  */
1024 static YYSIZE_T
yysyntax_error(char * yyresult,int yystate,int yychar)1025 yysyntax_error(char *yyresult, int yystate, int yychar)
1026 {
1027     int yyn = yypact[yystate];
1028 
1029     if (!(YYPACT_NINF < yyn && yyn <= YYLAST)) {
1030         return 0;
1031     } else {
1032         int yytype = YYTRANSLATE(yychar);
1033         YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]);
1034         YYSIZE_T yysize = yysize0;
1035         YYSIZE_T yysize1;
1036         int yysize_overflow = 0;
1037         enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1038         char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1039         int yyx;
1040 
1041 # if 0
1042         /* This is so xgettext sees the translatable formats that are
1043         constructed on the fly.  */
1044         YY_("syntax error, unexpected %s");
1045         YY_("syntax error, unexpected %s, expecting %s");
1046         YY_("syntax error, unexpected %s, expecting %s or %s");
1047         YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1048         YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1049 # endif
1050         char *yyfmt;
1051         char const *yyf;
1052         static char const yyunexpected[] = "syntax error, unexpected %s";
1053         static char const yyexpecting[] = ", expecting %s";
1054         static char const yyor[] = " or %s";
1055         char yyformat[sizeof yyunexpected
1056                       + sizeof yyexpecting - 1
1057                       + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1058                          * (sizeof yyor - 1))];
1059         char const *yyprefix = yyexpecting;
1060 
1061         /* Start YYX at -YYN if negative to avoid negative indexes in
1062         YYCHECK.  */
1063         int yyxbegin = yyn < 0 ? -yyn : 0;
1064 
1065         /* Stay within bounds of both yycheck and yytname.  */
1066         int yychecklim = YYLAST - yyn + 1;
1067         int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1068         int yycount = 1;
1069 
1070         yyarg[0] = yytname[yytype];
1071         yyfmt = yystpcpy(yyformat, yyunexpected);
1072 
1073         for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1074             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
1075                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) {
1076                     yycount = 1;
1077                     yysize = yysize0;
1078                     yyformat[sizeof yyunexpected - 1] = '\0';
1079                     break;
1080                 }
1081                 yyarg[yycount++] = yytname[yyx];
1082                 yysize1 = yysize + yytnamerr(0, yytname[yyx]);
1083                 yysize_overflow |= (yysize1 < yysize);
1084                 yysize = yysize1;
1085                 yyfmt = yystpcpy(yyfmt, yyprefix);
1086                 yyprefix = yyor;
1087             }
1088 
1089         yyf = YY_(yyformat);
1090         yysize1 = yysize + yystrlen(yyf);
1091         yysize_overflow |= (yysize1 < yysize);
1092         yysize = yysize1;
1093 
1094         if (yysize_overflow) {
1095             return YYSIZE_MAXIMUM;
1096         }
1097 
1098         if (yyresult) {
1099             /* Avoid sprintf, as that infringes on the user's name space.
1100                Don't have undefined behavior even if the translation
1101                produced a string with the wrong number of "%s"s.  */
1102             char *yyp = yyresult;
1103             int yyi = 0;
1104             while ((*yyp = *yyf) != '\0') {
1105                 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) {
1106                     yyp += yytnamerr(yyp, yyarg[yyi++]);
1107                     yyf += 2;
1108                 } else {
1109                     yyp++;
1110                     yyf++;
1111                 }
1112             }
1113         }
1114         return yysize;
1115     }
1116 }
1117 #endif /* YYERROR_VERBOSE */
1118 
1119 /*-----------------------------------------------.
1120 | Release the memory associated to this symbol.  |
1121 `-----------------------------------------------*/
1122 
1123 /*ARGSUSED*/
1124 #if (defined __STDC__ || defined __C99__FUNC__ \
1125      || defined __cplusplus || defined _MSC_VER)
1126 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1127 yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1128 #else
1129 static void
1130 yydestruct(yymsg, yytype, yyvaluep)
1131 const char *yymsg;
1132 int yytype;
1133 YYSTYPE *yyvaluep;
1134 #endif
1135 {
1136     YYUSE(yyvaluep);
1137 
1138     if (!yymsg) {
1139         yymsg = "Deleting";
1140     }
1141     YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp);
1142 
1143     switch (yytype) {
1144 
1145     default:
1146         break;
1147     }
1148 }
1149 
1150 /* Prevent warnings from -Wmissing-prototypes.  */
1151 #ifdef YYPARSE_PARAM
1152 #if defined __STDC__ || defined __cplusplus
1153 int yyparse(void *YYPARSE_PARAM);
1154 #else
1155 int yyparse();
1156 #endif
1157 #else /* ! YYPARSE_PARAM */
1158 #if defined __STDC__ || defined __cplusplus
1159 int yyparse(void);
1160 #else
1161 int yyparse();
1162 #endif
1163 #endif /* ! YYPARSE_PARAM */
1164 
1165 /* The lookahead symbol.  */
1166 int yychar;
1167 
1168 /* The semantic value of the lookahead symbol.  */
1169 YYSTYPE yylval;
1170 
1171 /* Number of syntax errors so far.  */
1172 int yynerrs;
1173 
1174 /*-------------------------.
1175 | yyparse or yypush_parse.  |
1176 `-------------------------*/
1177 
1178 #ifdef YYPARSE_PARAM
1179 #if (defined __STDC__ || defined __C99__FUNC__ \
1180      || defined __cplusplus || defined _MSC_VER)
1181 int
yyparse(void * YYPARSE_PARAM)1182 yyparse(void *YYPARSE_PARAM)
1183 #else
1184 int
1185 yyparse(YYPARSE_PARAM)
1186 void *YYPARSE_PARAM;
1187 #endif
1188 #else /* ! YYPARSE_PARAM */
1189 #if (defined __STDC__ || defined __C99__FUNC__ \
1190      || defined __cplusplus || defined _MSC_VER)
1191 int
1192 yyparse(void)
1193 #else
1194 int
1195 yyparse()
1196 
1197 #endif
1198 #endif
1199 {
1200 
1201     int yystate;
1202     /* Number of tokens to shift before error messages enabled.  */
1203     int yyerrstatus;
1204 
1205     /* The stacks and their tools:
1206        `yyss': related to states.
1207        `yyvs': related to semantic values.
1208 
1209        Refer to the stacks thru separate pointers, to allow yyoverflow
1210        to reallocate them elsewhere.  */
1211 
1212     /* The state stack.  */
1213     yytype_int16 yyssa[YYINITDEPTH];
1214     yytype_int16 *yyss;
1215     yytype_int16 *yyssp;
1216 
1217     /* The semantic value stack.  */
1218     YYSTYPE yyvsa[YYINITDEPTH];
1219     YYSTYPE *yyvs;
1220     YYSTYPE *yyvsp;
1221 
1222     YYSIZE_T yystacksize;
1223 
1224     int yyn;
1225     int yyresult;
1226     /* Lookahead token as an internal (translated) token number.  */
1227     int yytoken;
1228     /* The variables used to return semantic value and location from the
1229        action routines.  */
1230     YYSTYPE yyval;
1231 
1232 #if YYERROR_VERBOSE
1233     /* Buffer for error messages, and its allocated size.  */
1234     char yymsgbuf[128];
1235     char *yymsg = yymsgbuf;
1236     YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1237 #endif
1238 
1239 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1240 
1241     /* The number of symbols on the RHS of the reduced rule.
1242        Keep to zero when no symbol should be popped.  */
1243     int yylen = 0;
1244 
1245     yytoken = 0;
1246     yyss = yyssa;
1247     yyvs = yyvsa;
1248     yystacksize = YYINITDEPTH;
1249 
1250     YYDPRINTF((stderr, "Starting parse\n"));
1251 
1252     yystate = 0;
1253     yyerrstatus = 0;
1254     yynerrs = 0;
1255     yychar = YYEMPTY; /* Cause a token to be read.  */
1256 
1257     /* Initialize stack pointers.
1258        Waste one element of value and location stack
1259        so that they stay on the same level as the state stack.
1260        The wasted elements are never initialized.  */
1261     yyssp = yyss;
1262     yyvsp = yyvs;
1263 
1264     goto yysetstate;
1265 
1266     /*------------------------------------------------------------.
1267     | yynewstate -- Push a new state, which is found in yystate.  |
1268     `------------------------------------------------------------*/
1269 yynewstate:
1270     /* In all cases, when you get here, the value and location stacks
1271        have just been pushed.  So pushing a state here evens the stacks.  */
1272     yyssp++;
1273 
1274 yysetstate:
1275     *yyssp = yystate;
1276 
1277     if (yyss + yystacksize - 1 <= yyssp) {
1278         /* Get the current used size of the three stacks, in elements.  */
1279         YYSIZE_T yysize = yyssp - yyss + 1;
1280 
1281 #ifdef yyoverflow
1282         {
1283             /* Give user a chance to reallocate the stack.  Use copies of
1284                these so that the &'s don't force the real ones into
1285                memory.  */
1286             YYSTYPE *yyvs1 = yyvs;
1287             yytype_int16 *yyss1 = yyss;
1288 
1289             /* Each stack pointer address is followed by the size of the
1290                data in use in that stack, in bytes.  This used to be a
1291                conditional around just the two extra args, but that might
1292                be undefined if yyoverflow is a macro.  */
1293             yyoverflow(YY_("memory exhausted"),
1294                        &yyss1, yysize * sizeof(*yyssp),
1295                        &yyvs1, yysize * sizeof(*yyvsp),
1296                        &yystacksize);
1297 
1298             yyss = yyss1;
1299             yyvs = yyvs1;
1300         }
1301 #else /* no yyoverflow */
1302 # ifndef YYSTACK_RELOCATE
1303         goto yyexhaustedlab;
1304 # else
1305         /* Extend the stack our own way.  */
1306         if (YYMAXDEPTH <= yystacksize) {
1307             goto yyexhaustedlab;
1308         }
1309         yystacksize *= 2;
1310         if (YYMAXDEPTH < yystacksize) {
1311             yystacksize = YYMAXDEPTH;
1312         }
1313 
1314         {
1315             yytype_int16 *yyss1 = yyss;
1316             union yyalloc *yyptr =
1317                         (union yyalloc *) YYSTACK_ALLOC(YYSTACK_BYTES(yystacksize));
1318             if (! yyptr) {
1319                 goto yyexhaustedlab;
1320             }
1321             YYSTACK_RELOCATE(yyss_alloc, yyss);
1322             YYSTACK_RELOCATE(yyvs_alloc, yyvs);
1323 #  undef YYSTACK_RELOCATE
1324             if (yyss1 != yyssa) {
1325                 YYSTACK_FREE(yyss1);
1326             }
1327         }
1328 # endif
1329 #endif /* no yyoverflow */
1330 
1331         yyssp = yyss + yysize - 1;
1332         yyvsp = yyvs + yysize - 1;
1333 
1334         YYDPRINTF((stderr, "Stack size increased to %lu\n",
1335                    (unsigned long int) yystacksize));
1336 
1337         if (yyss + yystacksize - 1 <= yyssp) {
1338             YYABORT;
1339         }
1340     }
1341 
1342     YYDPRINTF((stderr, "Entering state %d\n", yystate));
1343 
1344     if (yystate == YYFINAL) {
1345         YYACCEPT;
1346     }
1347 
1348     goto yybackup;
1349 
1350     /*-----------.
1351     | yybackup.  |
1352     `-----------*/
1353 yybackup:
1354 
1355     /* Do appropriate processing given the current state.  Read a
1356        lookahead token if we need one and don't already have one.  */
1357 
1358     /* First try to decide what to do without reference to lookahead token.  */
1359     yyn = yypact[yystate];
1360     if (yyn == YYPACT_NINF) {
1361         goto yydefault;
1362     }
1363 
1364     /* Not known => get a lookahead token if don't already have one.  */
1365 
1366     /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1367     if (yychar == YYEMPTY) {
1368         YYDPRINTF((stderr, "Reading a token: "));
1369         yychar = YYLEX;
1370     }
1371 
1372     if (yychar <= YYEOF) {
1373         yychar = yytoken = YYEOF;
1374         YYDPRINTF((stderr, "Now at end of input.\n"));
1375     } else {
1376         yytoken = YYTRANSLATE(yychar);
1377         YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
1378     }
1379 
1380     /* If the proper action on seeing token YYTOKEN is to reduce or to
1381        detect an error, take that action.  */
1382     yyn += yytoken;
1383     if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) {
1384         goto yydefault;
1385     }
1386     yyn = yytable[yyn];
1387     if (yyn <= 0) {
1388         if (yyn == 0 || yyn == YYTABLE_NINF) {
1389             goto yyerrlab;
1390         }
1391         yyn = -yyn;
1392         goto yyreduce;
1393     }
1394 
1395     /* Count tokens shifted since error; after three, turn off error
1396        status.  */
1397     if (yyerrstatus) {
1398         yyerrstatus--;
1399     }
1400 
1401     /* Shift the lookahead token.  */
1402     YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc);
1403 
1404     /* Discard the shifted token.  */
1405     yychar = YYEMPTY;
1406 
1407     yystate = yyn;
1408     *++yyvsp = yylval;
1409 
1410     goto yynewstate;
1411 
1412     /*-----------------------------------------------------------.
1413     | yydefault -- do the default action for the current state.  |
1414     `-----------------------------------------------------------*/
1415 yydefault:
1416     yyn = yydefact[yystate];
1417     if (yyn == 0) {
1418         goto yyerrlab;
1419     }
1420     goto yyreduce;
1421 
1422     /*-----------------------------.
1423     | yyreduce -- Do a reduction.  |
1424     `-----------------------------*/
1425 yyreduce:
1426     /* yyn is the number of a rule to reduce with.  */
1427     yylen = yyr2[yyn];
1428 
1429     /* If YYLEN is nonzero, implement the default value of the action:
1430        `$$ = $1'.
1431 
1432        Otherwise, the following line sets YYVAL to garbage.
1433        This behavior is undocumented and Bison
1434        users should not rely upon it.  Assigning to YYVAL
1435        unconditionally makes the parser a bit smaller, and it avoids a
1436        GCC warning that YYVAL may be used uninitialized.  */
1437     yyval = yyvsp[1 - yylen];
1438 
1439     YY_REDUCE_PRINT(yyn);
1440     switch (yyn) {
1441     case 2:
1442 
1443         /* Line 1464 of yacc.c  */
1444 #line 94 "parser.y"
1445         {
1446             _topExpr = (yyvsp[(1) - (1)].expr);
1447             ;
1448         }
1449         break;
1450 
1451     case 3:
1452 
1453         /* Line 1464 of yacc.c  */
1454 #line 101 "parser.y"
1455         {
1456             (yyval.locationPath)->m_absolute = false;
1457             ;
1458         }
1459         break;
1460 
1461     case 4:
1462 
1463         /* Line 1464 of yacc.c  */
1464 #line 106 "parser.y"
1465         {
1466             (yyval.locationPath)->m_absolute = true;
1467             ;
1468         }
1469         break;
1470 
1471     case 5:
1472 
1473         /* Line 1464 of yacc.c  */
1474 #line 113 "parser.y"
1475         {
1476             (yyval.locationPath) = new LocationPath;
1477             ;
1478         }
1479         break;
1480 
1481     case 6:
1482 
1483         /* Line 1464 of yacc.c  */
1484 #line 118 "parser.y"
1485         {
1486             (yyval.locationPath) = (yyvsp[(2) - (2)].locationPath);
1487             ;
1488         }
1489         break;
1490 
1491     case 7:
1492 
1493         /* Line 1464 of yacc.c  */
1494 #line 123 "parser.y"
1495         {
1496             (yyval.locationPath) = (yyvsp[(2) - (2)].locationPath);
1497             (yyval.locationPath)->m_steps.prepend((yyvsp[(1) - (2)].step));
1498             ;
1499         }
1500         break;
1501 
1502     case 8:
1503 
1504         /* Line 1464 of yacc.c  */
1505 #line 131 "parser.y"
1506         {
1507             (yyval.locationPath) = new LocationPath;
1508             (yyval.locationPath)->m_steps.append((yyvsp[(1) - (1)].step));
1509             ;
1510         }
1511         break;
1512 
1513     case 9:
1514 
1515         /* Line 1464 of yacc.c  */
1516 #line 137 "parser.y"
1517         {
1518             (yyval.locationPath)->m_steps.append((yyvsp[(3) - (3)].step));
1519             ;
1520         }
1521         break;
1522 
1523     case 10:
1524 
1525         /* Line 1464 of yacc.c  */
1526 #line 142 "parser.y"
1527         {
1528             (yyval.locationPath)->m_steps.append((yyvsp[(2) - (3)].step));
1529             (yyval.locationPath)->m_steps.append((yyvsp[(3) - (3)].step));
1530             ;
1531         }
1532         break;
1533 
1534     case 11:
1535 
1536         /* Line 1464 of yacc.c  */
1537 #line 150 "parser.y"
1538         {
1539             (yyval.step) = new Step(Step::ChildAxis, *(yyvsp[(1) - (1)].str));
1540             delete(yyvsp[(1) - (1)].str);
1541             ;
1542         }
1543         break;
1544 
1545     case 12:
1546 
1547         /* Line 1464 of yacc.c  */
1548 #line 156 "parser.y"
1549         {
1550             (yyval.step) = new Step(Step::ChildAxis, *(yyvsp[(1) - (2)].str), *(yyvsp[(2) - (2)].predList));
1551             delete(yyvsp[(1) - (2)].str);
1552             delete(yyvsp[(2) - (2)].predList);
1553             ;
1554         }
1555         break;
1556 
1557     case 13:
1558 
1559         /* Line 1464 of yacc.c  */
1560 #line 163 "parser.y"
1561         {
1562             (yyval.step) = new Step((yyvsp[(1) - (2)].axisType), *(yyvsp[(2) - (2)].str));
1563             delete(yyvsp[(2) - (2)].str);
1564             ;
1565         }
1566         break;
1567 
1568     case 14:
1569 
1570         /* Line 1464 of yacc.c  */
1571 #line 169 "parser.y"
1572         {
1573             (yyval.step) = new Step((yyvsp[(1) - (3)].axisType), *(yyvsp[(2) - (3)].str),  *(yyvsp[(3) - (3)].predList));
1574             delete(yyvsp[(2) - (3)].str);
1575             delete(yyvsp[(3) - (3)].predList);
1576             ;
1577         }
1578         break;
1579 
1580     case 17:
1581 
1582         /* Line 1464 of yacc.c  */
1583 #line 182 "parser.y"
1584         {
1585             (yyval.axisType) = Step::AttributeAxis;
1586             ;
1587         }
1588         break;
1589 
1590     case 18:
1591 
1592         /* Line 1464 of yacc.c  */
1593 #line 189 "parser.y"
1594         {
1595             const int colon = (yyvsp[(1) - (1)].str)->find(':');
1596             if (colon > -1) {
1597                 DOMString prefix((yyvsp[(1) - (1)].str)->substring(0, colon));
1598                 XPathNSResolverImpl *resolver = Expression::evaluationContext().resolver;
1599                 if (!resolver || resolver->lookupNamespaceURI(prefix).isNull()) {
1600                     qCWarning(KHTML_LOG) << "Found unknown namespace prefix " << prefix.string();
1601                     xpathParseException = DOMException::NAMESPACE_ERR;
1602                     YYABORT;
1603                 }
1604             }
1605             ;
1606         }
1607         break;
1608 
1609     case 19:
1610 
1611         /* Line 1464 of yacc.c  */
1612 #line 203 "parser.y"
1613         {
1614             (yyval.str) = new DOMString(*(yyvsp[(1) - (3)].str) + DOMString("()"));
1615             ;
1616         }
1617         break;
1618 
1619     case 21:
1620 
1621         /* Line 1464 of yacc.c  */
1622 #line 210 "parser.y"
1623         {
1624             QString s = (yyvsp[(1) - (4)].str)->string() + QLatin1Char(' ') + (yyvsp[(3) - (4)].str)->string();
1625             s = s.trimmed();
1626             (yyval.str) = new DOMString(s);
1627             delete(yyvsp[(1) - (4)].str);
1628             delete(yyvsp[(3) - (4)].str);
1629             ;
1630         }
1631         break;
1632 
1633     case 22:
1634 
1635         /* Line 1464 of yacc.c  */
1636 #line 221 "parser.y"
1637         {
1638             (yyval.predList) = new QList<Predicate *>;
1639             (yyval.predList)->append(new Predicate((yyvsp[(1) - (1)].expr)));
1640             ;
1641         }
1642         break;
1643 
1644     case 23:
1645 
1646         /* Line 1464 of yacc.c  */
1647 #line 227 "parser.y"
1648         {
1649             (yyval.predList)->append(new Predicate((yyvsp[(2) - (2)].expr)));
1650             ;
1651         }
1652         break;
1653 
1654     case 24:
1655 
1656         /* Line 1464 of yacc.c  */
1657 #line 234 "parser.y"
1658         {
1659             (yyval.expr) = (yyvsp[(2) - (3)].expr);
1660             ;
1661         }
1662         break;
1663 
1664     case 25:
1665 
1666         /* Line 1464 of yacc.c  */
1667 #line 241 "parser.y"
1668         {
1669             (yyval.step) = new Step(Step::DescendantOrSelfAxis, "node()");
1670             ;
1671         }
1672         break;
1673 
1674     case 26:
1675 
1676         /* Line 1464 of yacc.c  */
1677 #line 248 "parser.y"
1678         {
1679             (yyval.step) = new Step(Step::SelfAxis, "node()");
1680             ;
1681         }
1682         break;
1683 
1684     case 27:
1685 
1686         /* Line 1464 of yacc.c  */
1687 #line 253 "parser.y"
1688         {
1689             (yyval.step) = new Step(Step::ParentAxis, "node()");
1690             ;
1691         }
1692         break;
1693 
1694     case 28:
1695 
1696         /* Line 1464 of yacc.c  */
1697 #line 260 "parser.y"
1698         {
1699             (yyval.expr) = new VariableReference(*(yyvsp[(1) - (1)].str));
1700             delete(yyvsp[(1) - (1)].str);
1701             ;
1702         }
1703         break;
1704 
1705     case 29:
1706 
1707         /* Line 1464 of yacc.c  */
1708 #line 266 "parser.y"
1709         {
1710             (yyval.expr) = (yyvsp[(2) - (3)].expr);
1711             ;
1712         }
1713         break;
1714 
1715     case 30:
1716 
1717         /* Line 1464 of yacc.c  */
1718 #line 271 "parser.y"
1719         {
1720             (yyval.expr) = new String(*(yyvsp[(1) - (1)].str));
1721             delete(yyvsp[(1) - (1)].str);
1722             ;
1723         }
1724         break;
1725 
1726     case 31:
1727 
1728         /* Line 1464 of yacc.c  */
1729 #line 277 "parser.y"
1730         {
1731             (yyval.expr) = new Number((yyvsp[(1) - (1)].str)->toFloat());
1732             delete(yyvsp[(1) - (1)].str);
1733             ;
1734         }
1735         break;
1736 
1737     case 33:
1738 
1739         /* Line 1464 of yacc.c  */
1740 #line 287 "parser.y"
1741         {
1742             Function *f = FunctionLibrary::self().getFunction(*(yyvsp[(1) - (3)].str));
1743             delete(yyvsp[(1) - (3)].str);
1744             if (!f) {
1745                 xpathParseException = XPathException::toCode(INVALID_EXPRESSION_ERR);
1746                 YYABORT;
1747             }
1748 
1749             (yyval.expr) = f;
1750             ;
1751         }
1752         break;
1753 
1754     case 34:
1755 
1756         /* Line 1464 of yacc.c  */
1757 #line 299 "parser.y"
1758         {
1759             Function *f = FunctionLibrary::self().getFunction(*(yyvsp[(1) - (4)].str), *(yyvsp[(3) - (4)].argList));
1760             delete(yyvsp[(1) - (4)].str);
1761             delete(yyvsp[(3) - (4)].argList);
1762             if (!f) {
1763                 xpathParseException = XPathException::toCode(INVALID_EXPRESSION_ERR);
1764                 YYABORT;
1765             }
1766             (yyval.expr) = f;
1767             ;
1768         }
1769         break;
1770 
1771     case 35:
1772 
1773         /* Line 1464 of yacc.c  */
1774 #line 313 "parser.y"
1775         {
1776             (yyval.argList) = new QList<Expression *>;
1777             (yyval.argList)->append((yyvsp[(1) - (1)].expr));
1778             ;
1779         }
1780         break;
1781 
1782     case 36:
1783 
1784         /* Line 1464 of yacc.c  */
1785 #line 319 "parser.y"
1786         {
1787             (yyval.argList)->append((yyvsp[(3) - (3)].expr));
1788             ;
1789         }
1790         break;
1791 
1792     case 39:
1793 
1794         /* Line 1464 of yacc.c  */
1795 #line 333 "parser.y"
1796         {
1797             (yyval.expr) = new Union;
1798             (yyval.expr)->addSubExpression((yyvsp[(1) - (3)].expr));
1799             (yyval.expr)->addSubExpression((yyvsp[(3) - (3)].expr));
1800             ;
1801         }
1802         break;
1803 
1804     case 40:
1805 
1806         /* Line 1464 of yacc.c  */
1807 #line 342 "parser.y"
1808         {
1809             (yyval.expr) = (yyvsp[(1) - (1)].locationPath);
1810             ;
1811         }
1812         break;
1813 
1814     case 41:
1815 
1816         /* Line 1464 of yacc.c  */
1817 #line 347 "parser.y"
1818         {
1819             (yyval.expr) = (yyvsp[(1) - (1)].expr);
1820             ;
1821         }
1822         break;
1823 
1824     case 42:
1825 
1826         /* Line 1464 of yacc.c  */
1827 #line 352 "parser.y"
1828         {
1829             (yyval.expr) = new Path(static_cast<Filter *>((yyvsp[(1) - (3)].expr)), (yyvsp[(3) - (3)].locationPath));
1830             ;
1831         }
1832         break;
1833 
1834     case 43:
1835 
1836         /* Line 1464 of yacc.c  */
1837 #line 357 "parser.y"
1838         {
1839             (yyvsp[(3) - (3)].locationPath)->m_steps.prepend((yyvsp[(2) - (3)].step));
1840             (yyval.expr) = new Path(static_cast<Filter *>((yyvsp[(1) - (3)].expr)), (yyvsp[(3) - (3)].locationPath));
1841             ;
1842         }
1843         break;
1844 
1845     case 44:
1846 
1847         /* Line 1464 of yacc.c  */
1848 #line 365 "parser.y"
1849         {
1850             (yyval.expr) = (yyvsp[(1) - (1)].expr);
1851             ;
1852         }
1853         break;
1854 
1855     case 45:
1856 
1857         /* Line 1464 of yacc.c  */
1858 #line 370 "parser.y"
1859         {
1860             (yyval.expr) = new Filter((yyvsp[(1) - (2)].expr), *(yyvsp[(2) - (2)].predList));
1861             ;
1862         }
1863         break;
1864 
1865     case 47:
1866 
1867         /* Line 1464 of yacc.c  */
1868 #line 379 "parser.y"
1869         {
1870             (yyval.expr) = new LogicalOp(LogicalOp::OP_Or, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
1871             ;
1872         }
1873         break;
1874 
1875     case 49:
1876 
1877         /* Line 1464 of yacc.c  */
1878 #line 388 "parser.y"
1879         {
1880             (yyval.expr) = new LogicalOp(LogicalOp::OP_And, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
1881             ;
1882         }
1883         break;
1884 
1885     case 51:
1886 
1887         /* Line 1464 of yacc.c  */
1888 #line 397 "parser.y"
1889         {
1890             (yyval.expr) = new RelationOp((yyvsp[(2) - (3)].num), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
1891             ;
1892         }
1893         break;
1894 
1895     case 53:
1896 
1897         /* Line 1464 of yacc.c  */
1898 #line 406 "parser.y"
1899         {
1900             (yyval.expr) = new RelationOp((yyvsp[(2) - (3)].num), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
1901             ;
1902         }
1903         break;
1904 
1905     case 55:
1906 
1907         /* Line 1464 of yacc.c  */
1908 #line 415 "parser.y"
1909         {
1910             (yyval.expr) = new NumericOp(NumericOp::OP_Add, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
1911             ;
1912         }
1913         break;
1914 
1915     case 56:
1916 
1917         /* Line 1464 of yacc.c  */
1918 #line 420 "parser.y"
1919         {
1920             (yyval.expr) = new NumericOp(NumericOp::OP_Sub, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
1921             ;
1922         }
1923         break;
1924 
1925     case 58:
1926 
1927         /* Line 1464 of yacc.c  */
1928 #line 429 "parser.y"
1929         {
1930             (yyval.expr) = new NumericOp((yyvsp[(2) - (3)].num), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr));
1931             ;
1932         }
1933         break;
1934 
1935     case 60:
1936 
1937         /* Line 1464 of yacc.c  */
1938 #line 438 "parser.y"
1939         {
1940             (yyval.expr) = new Negative;
1941             (yyval.expr)->addSubExpression((yyvsp[(2) - (2)].expr));
1942             ;
1943         }
1944         break;
1945 
1946         /* Line 1464 of yacc.c  */
1947 #line 1953 "parser.tab.c"
1948     default: break;
1949     }
1950     YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1951 
1952     YYPOPSTACK(yylen);
1953     yylen = 0;
1954     YY_STACK_PRINT(yyss, yyssp);
1955 
1956     *++yyvsp = yyval;
1957 
1958     /* Now `shift' the result of the reduction.  Determine what state
1959        that goes to, based on the state we popped back to and the rule
1960        number reduced by.  */
1961 
1962     yyn = yyr1[yyn];
1963 
1964     yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1965     if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) {
1966         yystate = yytable[yystate];
1967     } else {
1968         yystate = yydefgoto[yyn - YYNTOKENS];
1969     }
1970 
1971     goto yynewstate;
1972 
1973     /*------------------------------------.
1974     | yyerrlab -- here on detecting error |
1975     `------------------------------------*/
1976 yyerrlab:
1977     /* If not already recovering from an error, report this error.  */
1978     if (!yyerrstatus) {
1979         ++yynerrs;
1980 #if ! YYERROR_VERBOSE
1981         yyerror(YY_("syntax error"));
1982 #else
1983         {
1984             YYSIZE_T yysize = yysyntax_error(0, yystate, yychar);
1985             if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) {
1986                 YYSIZE_T yyalloc = 2 * yysize;
1987                 if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) {
1988                     yyalloc = YYSTACK_ALLOC_MAXIMUM;
1989                 }
1990                 if (yymsg != yymsgbuf) {
1991                     YYSTACK_FREE(yymsg);
1992                 }
1993                 yymsg = (char *) YYSTACK_ALLOC(yyalloc);
1994                 if (yymsg) {
1995                     yymsg_alloc = yyalloc;
1996                 } else {
1997                     yymsg = yymsgbuf;
1998                     yymsg_alloc = sizeof yymsgbuf;
1999                 }
2000             }
2001 
2002             if (0 < yysize && yysize <= yymsg_alloc) {
2003                 (void) yysyntax_error(yymsg, yystate, yychar);
2004                 yyerror(yymsg);
2005             } else {
2006                 yyerror(YY_("syntax error"));
2007                 if (yysize != 0) {
2008                     goto yyexhaustedlab;
2009                 }
2010             }
2011         }
2012 #endif
2013     }
2014 
2015     if (yyerrstatus == 3) {
2016         /* If just tried and failed to reuse lookahead token after an
2017         error, discard it.  */
2018 
2019         if (yychar <= YYEOF) {
2020             /* Return failure if at end of input.  */
2021             if (yychar == YYEOF) {
2022                 YYABORT;
2023             }
2024         } else {
2025             yydestruct("Error: discarding",
2026                        yytoken, &yylval);
2027             yychar = YYEMPTY;
2028         }
2029     }
2030 
2031     /* Else will try to reuse lookahead token after shifting the error
2032        token.  */
2033     goto yyerrlab1;
2034 
2035     /*---------------------------------------------------.
2036     | yyerrorlab -- error raised explicitly by YYERROR.  |
2037     `---------------------------------------------------*/
2038 yyerrorlab:
2039 
2040     /* Pacify compilers like GCC when the user code never invokes
2041        YYERROR and the label yyerrorlab therefore never appears in user
2042        code.  */
2043     if (/*CONSTCOND*/ 0) {
2044         goto yyerrorlab;
2045     }
2046 
2047     /* Do not reclaim the symbols of the rule which action triggered
2048        this YYERROR.  */
2049     YYPOPSTACK(yylen);
2050     yylen = 0;
2051     YY_STACK_PRINT(yyss, yyssp);
2052     yystate = *yyssp;
2053     goto yyerrlab1;
2054 
2055     /*-------------------------------------------------------------.
2056     | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2057     `-------------------------------------------------------------*/
2058 yyerrlab1:
2059     yyerrstatus = 3;  /* Each real token shifted decrements this.  */
2060 
2061     for (;;) {
2062         yyn = yypact[yystate];
2063         if (yyn != YYPACT_NINF) {
2064             yyn += YYTERROR;
2065             if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
2066                 yyn = yytable[yyn];
2067                 if (0 < yyn) {
2068                     break;
2069                 }
2070             }
2071         }
2072 
2073         /* Pop the current state because it cannot handle the error token.  */
2074         if (yyssp == yyss) {
2075             YYABORT;
2076         }
2077 
2078         yydestruct("Error: popping",
2079                    yystos[yystate], yyvsp);
2080         YYPOPSTACK(1);
2081         yystate = *yyssp;
2082         YY_STACK_PRINT(yyss, yyssp);
2083     }
2084 
2085     *++yyvsp = yylval;
2086 
2087     /* Shift the error token.  */
2088     YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp);
2089 
2090     yystate = yyn;
2091     goto yynewstate;
2092 
2093     /*-------------------------------------.
2094     | yyacceptlab -- YYACCEPT comes here.  |
2095     `-------------------------------------*/
2096 yyacceptlab:
2097     yyresult = 0;
2098     goto yyreturn;
2099 
2100     /*-----------------------------------.
2101     | yyabortlab -- YYABORT comes here.  |
2102     `-----------------------------------*/
2103 yyabortlab:
2104     yyresult = 1;
2105     goto yyreturn;
2106 
2107 #if !defined(yyoverflow) || YYERROR_VERBOSE
2108     /*-------------------------------------------------.
2109     | yyexhaustedlab -- memory exhaustion comes here.  |
2110     `-------------------------------------------------*/
2111 yyexhaustedlab:
2112     yyerror(YY_("memory exhausted"));
2113     yyresult = 2;
2114     /* Fall through.  */
2115 #endif
2116 
2117 yyreturn:
2118     if (yychar != YYEMPTY)
2119         yydestruct("Cleanup: discarding lookahead",
2120                    yytoken, &yylval);
2121     /* Do not reclaim the symbols of the rule which action triggered
2122        this YYABORT or YYACCEPT.  */
2123     YYPOPSTACK(yylen);
2124     YY_STACK_PRINT(yyss, yyssp);
2125     while (yyssp != yyss) {
2126         yydestruct("Cleanup: popping",
2127                    yystos[*yyssp], yyvsp);
2128         YYPOPSTACK(1);
2129     }
2130 #ifndef yyoverflow
2131     if (yyss != yyssa) {
2132         YYSTACK_FREE(yyss);
2133     }
2134 #endif
2135 #if YYERROR_VERBOSE
2136     if (yymsg != yymsgbuf) {
2137         YYSTACK_FREE(yymsg);
2138     }
2139 #endif
2140     /* Make sure YYID is used.  */
2141     return YYID(yyresult);
2142 }
2143 
2144 /* Line 1684 of yacc.c  */
2145 #line 444 "parser.y"
2146 
2147 namespace khtml
2148 {
2149 namespace XPath
2150 {
2151 
khtmlParseXPathStatement(const DOM::DOMString & statement,int & ec)2152 Expression *khtmlParseXPathStatement(const DOM::DOMString &statement, int &ec)
2153 {
2154 //  qCDebug(KHTML_LOG) << "Parsing " << statement;
2155     xpathParseException = 0;
2156     _topExpr = nullptr;
2157     initTokenizer(statement);
2158     yyparse();
2159 
2160     if (xpathParseException) {
2161         ec = xpathParseException;
2162     }
2163     return _topExpr;
2164 }
2165 
khtmlxpathyyerror(const char * str)2166 void khtmlxpathyyerror(const char *str)
2167 {
2168     // XXX Clean xpathyylval.str up to avoid leaking it.
2169     fprintf(stderr, "error: %s\n", str);
2170     xpathParseException = XPathException::toCode(INVALID_EXPRESSION_ERR);
2171 }
2172 
2173 } // namespace XPath
2174 } // namespace khtml
2175 
2176