/parser.h

http://github.com/fizx/parsley · C Header · 223 lines · 161 code · 26 blank · 36 comment · 2 complexity · 5bef5bc7c8e5b7e049a9dc2dd94ac8e2 MD5 · raw file

  1. /* A Bison parser, made by GNU Bison 2.3. */
  2. /* Skeleton interface for Bison GLR parsers in C
  3. Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA. */
  16. /* As a special exception, you may create a larger work that contains
  17. part or all of the Bison parser skeleton and distribute that work
  18. under terms of your choice, so long as that work isn't itself a
  19. parser generator using the skeleton or a modified version thereof
  20. as a parser skeleton. Alternatively, if you modify or redistribute
  21. the parser skeleton itself, you may (at your option) remove this
  22. special exception, which will cause the skeleton and the resulting
  23. Bison output files to be licensed under the GNU General Public
  24. License without this special exception.
  25. This special exception was added by the Free Software Foundation in
  26. version 2.2 of Bison. */
  27. /* Tokens. */
  28. #ifndef YYTOKENTYPE
  29. # define YYTOKENTYPE
  30. /* Put the tokens into the symbol table, so that GDB and other debuggers
  31. know about them. */
  32. enum yytokentype {
  33. NUMBER = 258,
  34. S = 259,
  35. AT = 260,
  36. LPAREN = 261,
  37. RPAREN = 262,
  38. PIPE = 263,
  39. LT = 264,
  40. SLASH = 265,
  41. DBLSLASH = 266,
  42. BANG = 267,
  43. COLON = 268,
  44. DBLCOLON = 269,
  45. QUERY = 270,
  46. HASH = 271,
  47. COMMA = 272,
  48. DOT = 273,
  49. DBLDOT = 274,
  50. GT = 275,
  51. LBRA = 276,
  52. RBRA = 277,
  53. TILDE = 278,
  54. SPLAT = 279,
  55. PLUS = 280,
  56. DASH = 281,
  57. EQ = 282,
  58. LTE = 283,
  59. GTE = 284,
  60. DOLLAR = 285,
  61. BSLASHLIT = 286,
  62. OTHER = 287,
  63. XANCESTOR = 288,
  64. XANCESTORSELF = 289,
  65. XATTR = 290,
  66. XCHILD = 291,
  67. XDESC = 292,
  68. XDESCSELF = 293,
  69. XFOLLOW = 294,
  70. XFOLLOWSIB = 295,
  71. XNS = 296,
  72. XPARENT = 297,
  73. XPRE = 298,
  74. XPRESIB = 299,
  75. XSELF = 300,
  76. XOR = 301,
  77. XAND = 302,
  78. XDIV = 303,
  79. XMOD = 304,
  80. XCOMMENT = 305,
  81. XTEXT = 306,
  82. XPI = 307,
  83. XNODE = 308,
  84. CXEQUATION = 309,
  85. CXOPHE = 310,
  86. CXOPNE = 311,
  87. CXOPSTARTEQ = 312,
  88. CXOPENDEQ = 313,
  89. CXOPCONTAINS = 314,
  90. CXOPCONTAINS2 = 315,
  91. CXFIRST = 316,
  92. CXLAST = 317,
  93. CXNOT = 318,
  94. CXEVEN = 319,
  95. CXODD = 320,
  96. CXEQ = 321,
  97. CXGT = 322,
  98. CXLT = 323,
  99. CXCONTENT = 324,
  100. CXHEADER = 325,
  101. CXCONTAINS = 326,
  102. CXEMPTY = 327,
  103. CXHAS = 328,
  104. CXPARENT = 329,
  105. CXNTHCH = 330,
  106. CXNTHLASTCH = 331,
  107. CXNTHTYPE = 332,
  108. CXNTHLASTTYPE = 333,
  109. CXFIRSTCH = 334,
  110. CXLASTCH = 335,
  111. CXFIRSTTYPE = 336,
  112. CXLASTTYPE = 337,
  113. CXONLYCH = 338,
  114. CXONLYTYPE = 339,
  115. CXINPUT = 340,
  116. CXTEXT = 341,
  117. CXPASSWORD = 342,
  118. CXRADIO = 343,
  119. CXCHECKBOX = 344,
  120. CXSUBMIT = 345,
  121. CXIMAGE = 346,
  122. CXRESET = 347,
  123. CXBUTTON = 348,
  124. CXFILE = 349,
  125. CXENABLED = 350,
  126. CXDISABLED = 351,
  127. CXCHECKED = 352,
  128. CXSELECTED = 353,
  129. NAME = 354,
  130. STRING = 355
  131. };
  132. #endif
  133. /* Copy the first part of user declarations. */
  134. #line 1 "parser.y"
  135. #include <math.h>
  136. #include <stdio.h>
  137. #include <stdlib.h>
  138. #include <string.h>
  139. #include "parsed_xpath.h"
  140. #include <libxml/hash.h>
  141. #ifndef PARSER_Y_H_INCLUDED
  142. #define PARSER_Y_H_INCLUDED
  143. static pxpathPtr parsed_answer;
  144. int yylex (void);
  145. void yyerror (char const *);
  146. void prepare_parse(char*);
  147. void cleanup_parse(void);
  148. void start_debugging(void);
  149. static xmlHashTablePtr alias_hash;
  150. char* xpath_alias(char*);
  151. void init_xpath_alias();
  152. int yyparse(void);
  153. pxpathPtr myparse(char*);
  154. void answer(pxpathPtr);
  155. #define LIT_BIN_OP(A, B, C) pxpath_cat_literals(3, A, LIT(B), C)
  156. #define BIN_OP(A, B, C) pxpath_cat_paths(3, A, OP(B), C)
  157. #define PREP_OP(A, B) pxpath_cat_paths(2, OP(A), B)
  158. #define PXP(A) pxpath_new_path(1, A)
  159. #define LIT(A) pxpath_new_literal(1, A)
  160. #define OP(A) pxpath_new_operator(1, A)
  161. #define APPEND(A, S) pxpath_cat_paths(2, A, PXP(S));
  162. #define PREPEND(A, S) pxpath_cat_paths(2, PXP(S), A);
  163. #define PXPWRAP(A, B, C) pxpath_cat_paths(3, PXP(A), B, PXP(C))
  164. #define P4E(A, B, C, D) pxpath_cat_paths(4, A, PXP(B), C, PXP(D))
  165. #define P4O(A, B, C, D) pxpath_cat_paths(4, PXP(A), B, PXP(C), D)
  166. #define P6E(A, B, C, D, E, F) pxpath_cat_paths(6, A, PXP(B), C, PXP(D), E, PXP(F));
  167. #define INPUT_TYPE(A, S) APPEND(A, "[lower-case(name())='input' and lower-case(@type)='" #S "']")
  168. #define TRACE(A, B) fprintf(stderr, "trace(%s): ", A); fprintf(stderr, "%s\n", pxpath_to_string(B));
  169. #endif
  170. #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
  171. typedef union YYSTYPE
  172. #line 53 "parser.y"
  173. {
  174. int empty;
  175. char* string;
  176. pxpathPtr node;
  177. }
  178. /* Line 2616 of glr.c. */
  179. #line 203 "parser.h"
  180. YYSTYPE;
  181. # define YYSTYPE_IS_DECLARED 1
  182. # define YYSTYPE_IS_TRIVIAL 1
  183. #endif
  184. #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
  185. typedef struct YYLTYPE
  186. {
  187. char yydummy;
  188. } YYLTYPE;
  189. # define YYLTYPE_IS_DECLARED 1
  190. # define YYLTYPE_IS_TRIVIAL 1
  191. #endif
  192. extern YYSTYPE yylval;