Skip to content
Newer
Older
100644 631 lines (560 sloc) 20.3 KB
9df5a91 some parsing
Kyle Maxwell authored Nov 20, 2008
1 %{
c4d90d2 parsing nothing
Kyle Maxwell authored Nov 20, 2008
2 #include <math.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
e22f309 cleaned up parser.y warnings
Kyle Maxwell authored Mar 9, 2009
6 #include "parsed_xpath.h"
df15251 remote html works, some function aliases work
Kyle Maxwell authored Dec 30, 2008
7 #include <libxml/hash.h>
c4d90d2 parsing nothing
Kyle Maxwell authored Nov 21, 2008
8
4abf321 progress
Kyle Maxwell authored Nov 24, 2008
9 #ifndef PARSER_Y_H_INCLUDED
10 #define PARSER_Y_H_INCLUDED
11
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
12 static pxpathPtr parsed_answer;
7d153fd progress
Kyle Maxwell authored Nov 22, 2008
13
c4d90d2 parsing nothing
Kyle Maxwell authored Nov 21, 2008
14 int yylex (void);
15 void yyerror (char const *);
16
a7f68e6 progress
Kyle Maxwell authored Nov 20, 2008
17 void prepare_parse(char*);
18 void cleanup_parse(void);
6d3efd0 unknown progress
Kyle Maxwell authored Nov 20, 2008
19 void start_debugging(void);
c4d90d2 parsing nothing
Kyle Maxwell authored Nov 21, 2008
20
df15251 remote html works, some function aliases work
Kyle Maxwell authored Dec 31, 2008
21 static xmlHashTablePtr alias_hash;
22
23 char* xpath_alias(char*);
24 void init_xpath_alias();
25
c4d90d2 parsing nothing
Kyle Maxwell authored Nov 21, 2008
26 int yyparse(void);
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
27 pxpathPtr myparse(char*);
28 void answer(pxpathPtr);
29
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
30 #define LIT_BIN_OP(A, B, C) pxpath_cat_literals(3, A, LIT(B), C)
31 #define BIN_OP(A, B, C) pxpath_cat_paths(3, A, OP(B), C)
32 #define PREP_OP(A, B) pxpath_cat_paths(2, OP(A), B)
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
33 #define PXP(A) pxpath_new_path(1, A)
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
34 #define LIT(A) pxpath_new_literal(1, A)
35 #define OP(A) pxpath_new_operator(1, A)
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
36 #define APPEND(A, S) pxpath_cat_paths(2, A, PXP(S));
37 #define PREPEND(A, S) pxpath_cat_paths(2, PXP(S), A);
38 #define PXPWRAP(A, B, C) pxpath_cat_paths(3, PXP(A), B, PXP(C))
39 #define P4E(A, B, C, D) pxpath_cat_paths(4, A, PXP(B), C, PXP(D))
40 #define P4O(A, B, C, D) pxpath_cat_paths(4, PXP(A), B, PXP(C), D)
41 #define P6E(A, B, C, D, E, F) pxpath_cat_paths(6, A, PXP(B), C, PXP(D), E, PXP(F));
42 #define INPUT_TYPE(A, S) APPEND(A, "[lower-case(name())='input' and lower-case(@type)='" #S "']")
4c102cc WIP, compiles bad XSLT
Kyle Maxwell authored Mar 10, 2009
43 #define TRACE(A, B) fprintf(stderr, "trace(%s): ", A); fprintf(stderr, "%s\n", pxpath_to_string(B));
4abf321 progress
Kyle Maxwell authored Nov 25, 2008
44
45 #endif
9df5a91 some parsing
Kyle Maxwell authored Nov 21, 2008
46
47 %}
48
c4d90d2 parsing nothing
Kyle Maxwell authored Nov 21, 2008
49 %glr-parser
50 %token_table
6d3efd0 unknown progress
Kyle Maxwell authored Nov 21, 2008
51 %debug
c4d90d2 parsing nothing
Kyle Maxwell authored Nov 21, 2008
52
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 8, 2009
53 %union {
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
54 int empty;
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
55 char* string;
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
56 pxpathPtr node;
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
57 }
9df5a91 some parsing
Kyle Maxwell authored Nov 21, 2008
58
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
59 %token <string> NUMBER
60 %token <string> S
61 %token <string> AT
62 %token <string> LPAREN
63 %token <string> RPAREN
64 %token <string> PIPE
65 %token <string> LT
66 %token <string> SLASH
67 %token <string> DBLSLASH
68 %token <string> BANG
69 %token <string> COLON
70 %token <string> DBLCOLON
71 %token <string> QUERY
72 %token <string> HASH
73 %token <string> COMMA
74 %token <string> DOT
75 %token <string> DBLDOT
76 %token <string> GT
77 %token <string> LBRA
78 %token <string> RBRA
79 %token <string> TILDE
80 %token <string> SPLAT
81 %token <string> PLUS
82 %token <string> DASH
83 %token <string> EQ
84 %token <string> LTE
85 %token <string> GTE
86 %token <string> DOLLAR
87 %token <string> BSLASHLIT
88 %token <string> OTHER
89 %token <string> XANCESTOR
90 %token <string> XANCESTORSELF
91 %token <string> XATTR
92 %token <string> XCHILD
93 %token <string> XDESC
94 %token <string> XDESCSELF
95 %token <string> XFOLLOW
96 %token <string> XFOLLOWSIB
97 %token <string> XNS
98 %token <string> XPARENT
99 %token <string> XPRE
100 %token <string> XPRESIB
101 %token <string> XSELF
102 %token <string> XOR
103 %token <string> XAND
104 %token <string> XDIV
105 %token <string> XMOD
106 %token <string> XCOMMENT
107 %token <string> XTEXT
108 %token <string> XPI
109 %token <string> XNODE
110 %token <string> CXEQUATION
111 %token <string> CXOPHE
112 %token <string> CXOPNE
113 %token <string> CXOPSTARTEQ
114 %token <string> CXOPENDEQ
115 %token <string> CXOPCONTAINS
116 %token <string> CXOPCONTAINS2
117 %token <string> CXFIRST
118 %token <string> CXLAST
119 %token <string> CXNOT
120 %token <string> CXEVEN
121 %token <string> CXODD
122 %token <string> CXEQ
123 %token <string> CXGT
124 %token <string> CXLT
00282c5 @fizx :content() pseudo-selector
authored Jun 10, 2009
125 %token <string> CXCONTENT
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
126 %token <string> CXHEADER
127 %token <string> CXCONTAINS
128 %token <string> CXEMPTY
129 %token <string> CXHAS
130 %token <string> CXPARENT
131 %token <string> CXNTHCH
132 %token <string> CXNTHLASTCH
133 %token <string> CXNTHTYPE
134 %token <string> CXNTHLASTTYPE
135 %token <string> CXFIRSTCH
136 %token <string> CXLASTCH
137 %token <string> CXFIRSTTYPE
138 %token <string> CXLASTTYPE
139 %token <string> CXONLYCH
140 %token <string> CXONLYTYPE
141 %token <string> CXINPUT
142 %token <string> CXTEXT
143 %token <string> CXPASSWORD
144 %token <string> CXRADIO
145 %token <string> CXCHECKBOX
146 %token <string> CXSUBMIT
147 %token <string> CXIMAGE
148 %token <string> CXRESET
149 %token <string> CXBUTTON
150 %token <string> CXFILE
151 %token <string> CXENABLED
152 %token <string> CXDISABLED
153 %token <string> CXCHECKED
154 %token <string> CXSELECTED
155 %token <string> NAME
156 %token <string> STRING
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
157 %type <node> Root
158 %type <empty> OptS
159 %type <node> LocationPath
160 %type <node> AbsoluteLocationPath
161 %type <node> RelativeLocationPath
162 %type <node> Step
163 %type <node> AxisSpecifier
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
164 %type <string> AxisName
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
165 %type <node> NodeTest
06d1a2d now allowing multiple predicates (passing) [0.589151]
Kyle Maxwell authored Mar 31, 2009
166 %type <node> Predicates
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
167 %type <node> Predicate
168 %type <node> PredicateExpr
169 %type <node> AbbreviatedAbsoluteLocationPath
170 %type <node> AbbreviatedRelativeLocationPath
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
171 %type <string> AbbreviatedStep
172 %type <string> AbbreviatedAxisSpecifier
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
173 %type <node> Expr
174 %type <node> NumberLike
175 %type <node> PrimaryExpr
176 %type <node> FunctionCall
177 %type <node> Arguments
178 %type <node> ArgumentSet
179 %type <node> PrefixedName
180 %type <node> Argument
181 %type <node> UnionExpr
182 %type <node> PathExpr
183 %type <node> FunctionName
184 %type <node> FilterExpr
185 %type <node> OrExpr
186 %type <node> AndExpr
187 %type <node> EqualityExpr
188 %type <node> RelationalExpr
189 %type <node> AdditiveExpr
190 %type <node> MultiplicativeExpr
191 %type <node> UnaryExpr
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
192 %type <string> Literal
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
193 %type <node> Number
194 %type <node> simple_selector_anchor
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
195 %type <string> MultiplyOperator
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
196 %type <node> VariableReference
197 %type <node> NameTest
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
198 %type <string> NodeType
199 %type <string> UnprefixedName
200 %type <string> combinator
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
201 %type <node> possibly_empty_sequence
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
202 %type <string> keyword
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
203 %type <node> StringLike
204 %type <node> selectors_group
205 %type <node> QName
262584b WIP, moved parser to %union
Kyle Maxwell authored Mar 9, 2009
206 %type <string> NCName
207 %type <string> Prefix
208 %type <string> LocalPart
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
209 %type <node> attribute_extended_selector
210 %type <node> Ident
211 %type <node> universal
212 %type <node> selector
213 %type <node> namespace_prefix
214 %type <node> type_selector
215 %type <node> element_name
216 %type <node> simple_selector_sequence
9df5a91 some parsing
Kyle Maxwell authored Nov 21, 2008
217 %%
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
218
219 Root
4c102cc WIP, compiles bad XSLT
Kyle Maxwell authored Mar 10, 2009
220 : Expr OptS { answer($1); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
221 ;
222
223 LocationPath
fc71b61 functions working
Kyle Maxwell authored Dec 30, 2008
224 : RelativeLocationPath %dprec 1
06d1a2d now allowing multiple predicates (passing) [0.589151]
Kyle Maxwell authored Apr 1, 2009
225 | AbsoluteLocationPath %dprec 2
fc71b61 functions working
Kyle Maxwell authored Dec 30, 2008
226 | selectors_group %dprec 3
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
227 ;
228
229 AbsoluteLocationPath
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
230 : SLASH RelativeLocationPath { $$ = PREP_OP($1, $2); }
231 | SLASH { $$ = PXP($1); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
232 | AbbreviatedAbsoluteLocationPath
233 ;
234
235 RelativeLocationPath
236 : Step
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
237 | RelativeLocationPath SLASH Step { $$ = BIN_OP($1, $2, $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
238 | AbbreviatedRelativeLocationPath
239 ;
240
241 Step
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
242 : AxisSpecifier NodeTest { $$ = pxpath_cat_paths(2, $1, $2); }
06d1a2d now allowing multiple predicates (passing) [0.589151]
Kyle Maxwell authored Apr 1, 2009
243 | AxisSpecifier NodeTest Predicates { $$ = pxpath_cat_paths(3, $1, $2, $3); }
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
244 | AbbreviatedStep { $$ = PXP($1); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
245 ;
246
247 AxisSpecifier
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
248 : AxisName DBLCOLON { $$ = pxpath_new_path(2, $1, $2); }
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
249 | AbbreviatedAxisSpecifier { $$ = PXP($1); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
250 ;
251 AxisName
252 : XANCESTOR
253 | XANCESTORSELF
254 | XATTR
255 | XCHILD
256 | XDESC
257 | XDESCSELF
258 | XFOLLOW
259 | XFOLLOWSIB
260 | XNS
261 | XPARENT
262 | XPRE
263 | XPRESIB
264 | XSELF
265 ;
266
267 NodeTest
268 : NameTest
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
269 | NodeType LPAREN RPAREN { $$ = pxpath_new_path(3, $1, $2, $3); }
270 | XPI LPAREN Literal RPAREN { $$ = pxpath_new_path(4, $1, $2, $3, $4); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
271 ;
272
06d1a2d now allowing multiple predicates (passing) [0.589151]
Kyle Maxwell authored Apr 1, 2009
273 Predicates
274 : Predicates Predicate { $$ = pxpath_cat_paths(2, $1, $2); }
275 | Predicate
276 ;
277
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
278 Predicate
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
279 : LBRA PredicateExpr RBRA { $$ = PXPWRAP($1, $2, $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
280 ;
281
282 PredicateExpr
283 : Expr
284 ;
285
286 AbbreviatedAbsoluteLocationPath
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
287 : DBLSLASH RelativeLocationPath { $$ = PREP_OP($1, $2); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
288 ;
289
290 AbbreviatedRelativeLocationPath
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
291 : RelativeLocationPath DBLSLASH Step { $$ = BIN_OP($1, $2, $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
292 ;
293
294 AbbreviatedStep
295 : DOT
296 | DBLDOT
297 ;
298
299 AbbreviatedAxisSpecifier
300 : AT
301 | { $$ = ""; }
302 ;
303 Expr
a9308ab @fizx whitespace in selector fix
authored Jun 10, 2009
304 : LPAREN Argument RPAREN %dprec 2 { $$ = PXPWRAP($1, $2, $3); }
4c102cc WIP, compiles bad XSLT
Kyle Maxwell authored Mar 10, 2009
305 | OrExpr %dprec 1
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
306 ;
307 PrimaryExpr
308 : VariableReference
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
309 | LPAREN Expr RPAREN { $$ = PXPWRAP($1, $2, $3); }
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
310 | Literal { $$ = LIT($1); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
311 | Number
312 | FunctionCall
313 ;
314
315 FunctionCall
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
316 : FunctionName LPAREN Arguments RPAREN { $$ = pxpath_new_func(xpath_alias(pxpath_to_string($1)), $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
317 ;
318 Arguments
319 : ArgumentSet
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
320 | { $$ = NULL; }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
321 ;
322 ArgumentSet
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
323 : Argument COMMA ArgumentSet %dprec 2 { $$ = $1; $1->next = $3; }
5c63719 fix parser bugs
Kyle Maxwell authored Dec 27, 2008
324 | Argument %dprec 1
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
325 ;
326 Argument
5c63719 fix parser bugs
Kyle Maxwell authored Dec 27, 2008
327 : OptS Expr OptS { $$ = $2; }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
328 ;
329 UnionExpr
330 : PathExpr
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
331 | UnionExpr PIPE PathExpr { $$ = BIN_OP($1, $2, $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
332 ;
333
334 PathExpr
335 : LocationPath
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
336 | FilterExpr
337 | FilterExpr SLASH RelativeLocationPath { $$ = BIN_OP($1, $2, $3); }
338 | FilterExpr DBLSLASH RelativeLocationPath { $$ = BIN_OP($1, $2, $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
339 ;
340
341 FilterExpr
342 : PrimaryExpr
06d1a2d now allowing multiple predicates (passing) [0.589151]
Kyle Maxwell authored Apr 1, 2009
343 | FilterExpr Predicates { $$ = pxpath_cat_paths(2, $1, $2); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
344 ;
345
346 OrExpr
347 : AndExpr
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
348 | OrExpr XOR AndExpr { $$ = LIT_BIN_OP($1, $2, $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
349 ;
350
351 AndExpr
352 : EqualityExpr
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
353 | AndExpr XAND EqualityExpr { $$ = LIT_BIN_OP($1, $2, $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
354 ;
355
356 EqualityExpr
357 : RelationalExpr
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
358 | EqualityExpr EQ RelationalExpr { $$ = LIT_BIN_OP($1, $2, $3); }
359 | EqualityExpr CXOPNE RelationalExpr { $$ = LIT_BIN_OP($1, $2, $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
360 ;
361
362 RelationalExpr
28229d5 math ambiguity fixes (passing) [0.608195]
Kyle Maxwell authored Jun 11, 2009
363 : AdditiveExpr %dprec 2
908fbda @fizx regression for ambiguous plus chain
authored Jul 13, 2009
364 | RelationalExpr OptS LT OptS AdditiveExpr %dprec 3 { $$ = LIT_BIN_OP($1, $3, $5); }
28229d5 math ambiguity fixes (passing) [0.608195]
Kyle Maxwell authored Jun 11, 2009
365 | RelationalExpr OptS GT OptS AdditiveExpr %dprec 1 { $$ = LIT_BIN_OP($1, $3, $5); }
908fbda @fizx regression for ambiguous plus chain
authored Jul 13, 2009
366 | RelationalExpr OptS LTE OptS AdditiveExpr %dprec 3 { $$ = LIT_BIN_OP($1, $3, $5); }
367 | RelationalExpr OptS GTE OptS AdditiveExpr %dprec 3 { $$ = LIT_BIN_OP($1, $3, $5); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
368 ;
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
369
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
370 AdditiveExpr
908fbda @fizx regression for ambiguous plus chain
authored Jul 13, 2009
371 : MultiplicativeExpr %dprec 3
28229d5 math ambiguity fixes (passing) [0.608195]
Kyle Maxwell authored Jun 11, 2009
372 | AdditiveExpr OptS PLUS OptS MultiplicativeExpr %dprec 1 { $$ = LIT_BIN_OP($1, $3, $5); }
373 | AdditiveExpr OptS DASH OptS MultiplicativeExpr %dprec 2 { $$ = LIT_BIN_OP($1, $3, $5); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
374 ;
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
375
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
376 MultiplicativeExpr
cbfabf9 @fizx dynamic precedence sets the DIV XPath math operator less than the CSS…
authored Jun 10, 2009
377 : UnaryExpr %dprec 2
378 | MultiplicativeExpr OptS MultiplyOperator OptS UnaryExpr %dprec 2 { $$ = LIT_BIN_OP($1, $3, $5); }
379 | MultiplicativeExpr OptS XDIV OptS UnaryExpr %dprec 1 { $$ = LIT_BIN_OP($1, $3, $5); }
380 | MultiplicativeExpr OptS XMOD OptS UnaryExpr %dprec 2 { $$ = LIT_BIN_OP($1, $3, $5); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
381 ;
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
382
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
383 UnaryExpr
384 : UnionExpr
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
385 | DASH UnaryExpr { $$ = PREP_OP($1, $2); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
386 ;
387
388 Literal
389 : STRING
390 ;
391 Number
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
392 : NUMBER { $$ = LIT($1); }
393 | NUMBER DOT { $$ = pxpath_new_literal(2, $1, $2); }
394 | NUMBER DOT NUMBER { $$ = pxpath_new_literal(3, $1, $2, $3); }
395 | DOT NUMBER { $$ = pxpath_new_literal(2, $1, $2); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
396 ;
397
398 MultiplyOperator
399 : SPLAT
400 ;
401
402 VariableReference
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
403 : DOLLAR QName { $$ = PREP_OP($1, $2); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
404 ;
405
406 NameTest
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
407 : SPLAT { $$ = PXP($1); }
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
408 | NCName COLON SPLAT { $$ = pxpath_new_path(3, $1, $2, $3); }
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
409 | QName
410 ;
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
411
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
412 NodeType
413 : XCOMMENT
414 | XTEXT
415 | XPI
416 | XNODE
417 ;
418
419 FunctionName
87bc58d figured out magic grouping
Kyle Maxwell authored Dec 20, 2008
420 : QName
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
421 ;
422
423 QName
687216b WIP
Kyle Maxwell authored Mar 9, 2009
424 : PrefixedName
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
425 | UnprefixedName { $$ = PXP($1); }
87bc58d figured out magic grouping
Kyle Maxwell authored Dec 21, 2008
426 ;
427
428 PrefixedName
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
429 : Prefix COLON LocalPart { $$ = pxpath_new_path(3, $1, $2, $3); }
87bc58d figured out magic grouping
Kyle Maxwell authored Dec 21, 2008
430 ;
431
432 UnprefixedName
433 : LocalPart
434 ;
435
436 Prefix
437 : NCName
438 ;
439
440 LocalPart
441 : NCName
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
442 ;
443
444 NCName
445 : NAME
73db545 fixed calculations and //keyword
Kyle Maxwell authored Apr 1, 2009
446 | keyword
bb73d6c the whole thing might just work
Kyle Maxwell authored Nov 21, 2008
447 ;
448
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
449 selectors_group
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
450 : attribute_extended_selector COMMA OptS selectors_group { $$ = pxpath_cat_paths(4, pxpath_new_literal(1, ".//"), $1, pxpath_new_literal(1, "|"), $4); }
451 | attribute_extended_selector { $$ = pxpath_cat_paths(2, pxpath_new_literal(1, ".//"), $1); }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
452 ;
453
48680ad added css attribute extension
Kyle Maxwell authored Feb 19, 2009
454 attribute_extended_selector
455 : selector
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
456 | selector S AT NAME { $$ = pxpath_cat_paths(3, $1, PXP("/@"), PXP($4)); }
48680ad added css attribute extension
Kyle Maxwell authored Feb 20, 2009
457 ;
458
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
459 selector
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
460 : simple_selector_sequence combinator selector { $$ = pxpath_cat_paths(3, $1, PXP($2), $3); }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
461 | simple_selector_sequence
462 ;
463
464 combinator
908fbda @fizx regression for ambiguous plus chain
authored Jul 13, 2009
465 : OptS PLUS OptS { $$ = "/following-sibling::*[1]/self::"; }
466 | OptS GT OptS { $$ = "/"; }
467 | OptS TILDE OptS { $$ = "/following-sibling::*/self::"; }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
468 | S { $$ = "//"; }
469 ;
470
471 simple_selector_sequence
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
472 : simple_selector_anchor
473 | possibly_empty_sequence LBRA type_selector OptS CXOPHE OptS StringLike OptS RBRA { $$ = pxpath_cat_paths(10, $1, PXP("[@"), $3, PXP(" = "), $7, PXP(" or starts-with(@"), $3, PXP(", concat("), $7, PXP(", '-' ))]")); }
474 | possibly_empty_sequence CXNOT LPAREN selectors_group RPAREN { $$ = pxpath_cat_paths(5, PXP("set-difference("), $1, PXP(", "), $4, PXP(")")); }
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
475 | possibly_empty_sequence HASH Ident { $$ = P4E($1, "[@id='", $3, "']"); }
476 | possibly_empty_sequence DOT Ident { $$ = P4E($1, "[contains(concat( ' ', @class, ' ' ), concat( ' ', '", $3, "', ' ' ))]"); }
477 | possibly_empty_sequence LBRA type_selector RBRA { $$ = P4E($1, "[@", $3, "]"); }
478 | possibly_empty_sequence CXEQ LPAREN NumberLike RPAREN { $$ = P4E($1, "[position() = ", $3, "]"); }
479 | possibly_empty_sequence CXGT LPAREN NumberLike RPAREN { $$ = P4E($1, "[position() > ", $3, "]"); }
480 | possibly_empty_sequence CXLT LPAREN NumberLike RPAREN { $$ = P4E($1, "[position() < ", $3, "]"); }
dc5f3ff @fizx contains
authored Jun 11, 2009
481 | possibly_empty_sequence CXCONTAINS LPAREN StringLike RPAREN { $$ = P4E($1, "[contains(., ", $4, ")]"); }
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
482 | possibly_empty_sequence CXHAS LPAREN selectors_group RPAREN { $$ = P4E($1, "[", $3, "]"); }
483 | possibly_empty_sequence CXNTHTYPE LPAREN NumberLike RPAREN { $$ = P4E($1, "[position() = ", $3, "]"); }
484 | possibly_empty_sequence CXNTHLASTTYPE LPAREN NumberLike RPAREN { $$ = P4E($1, "[position() = last() - ", $3, "]"); }
4c102cc WIP, compiles bad XSLT
Kyle Maxwell authored Mar 10, 2009
485 | possibly_empty_sequence LBRA type_selector OptS EQ OptS StringLike OptS RBRA { $$ = P6E($1, "[@", $3, " = ", $7, "]"); }
486 | possibly_empty_sequence LBRA type_selector OptS CXOPNE OptS StringLike OptS RBRA { $$ = P6E($1, "[@", $3, " != ", $7, "]"); }
487 | possibly_empty_sequence LBRA type_selector OptS CXOPSTARTEQ OptS StringLike OptS RBRA { $$ = P6E($1, "[starts-with(@", $3, ", ", $7, ")]"); }
488 | possibly_empty_sequence LBRA type_selector OptS CXOPENDEQ OptS StringLike OptS RBRA { $$ = P6E($1, "[ends-with(@", $3, ", ", $7, ")]"); }
489 | possibly_empty_sequence LBRA type_selector OptS CXOPCONTAINS OptS StringLike OptS RBRA { $$ = P6E($1, "[contains(@", $3, ", ", $7, ")]"); }
490 | possibly_empty_sequence LBRA type_selector OptS CXOPCONTAINS2 OptS StringLike OptS RBRA { $$ = P6E($1, "[contains(@", $3, ", ", $7, ")]"); }
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
491 | possibly_empty_sequence CXNTHCH LPAREN NumberLike RPAREN { $$ = P4O("*[", $4, "]/self::", $1); }
492 | possibly_empty_sequence CXNTHLASTCH LPAREN NumberLike RPAREN { $$ = P4O("*[last() - ", $4, "]/self::", $1); }
493 | possibly_empty_sequence CXFIRST { $$ = APPEND($1, "[1]"); }
494 | possibly_empty_sequence CXLAST { $$ = APPEND($1, "[last()]"); }
495 | possibly_empty_sequence CXEVEN { $$ = APPEND($1, "[position() % 2 = 0]"); }
496 | possibly_empty_sequence CXODD { $$ = APPEND($1, "[position() % 2 = 1]"); }
bd457a4 @fizx non-breaking space fixes
authored Jun 11, 2009
497 | possibly_empty_sequence CXCONTENT LPAREN StringLike RPAREN { $$ = P4E($1, "[translate(normalize-space(.), $nbsp, ' ')=", $4, "]"); }
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
498 | possibly_empty_sequence CXHEADER { $$ = APPEND($1, "[contains('h1 h2 h3 h4 h5 h6', lower-case(local-name()))]"); }
499 | possibly_empty_sequence CXEMPTY { $$ = APPEND($1, "[not(node())]"); }
500 | possibly_empty_sequence CXPARENT { $$ = APPEND($1, "[node()]"); }
501 | possibly_empty_sequence CXFIRSTTYPE { $$ = APPEND($1, "[1]"); }
502 | possibly_empty_sequence CXLASTTYPE { $$ = APPEND($1, "[last()]"); }
503 | possibly_empty_sequence CXONLYTYPE { $$ = APPEND($1, "[count()=1]"); }
504 | possibly_empty_sequence CXINPUT { $$ = APPEND($1, "[lower-case(name())='input']"); }
505 | possibly_empty_sequence CXENABLED { $$ = APPEND($1, "[lower-case(name())='input' and not(@disabled)]"); }
506 | possibly_empty_sequence CXDISABLED { $$ = APPEND($1, "[lower-case(name())='input' and @disabled]"); }
507 | possibly_empty_sequence CXCHECKED { $$ = APPEND($1, "[@checked]"); }
508 | possibly_empty_sequence CXSELECTED { $$ = APPEND($1, "[@selected]"); }
509 | possibly_empty_sequence CXFIRSTCH { $$ = PREPEND($1, "*[1]/self::"); }
510 | possibly_empty_sequence CXLASTCH { $$ = PREPEND($1, "*[last()]/self::"); }
511 | possibly_empty_sequence CXONLYCH { $$ = PREPEND($1, "*[count()=1]/self::"); }
512 | possibly_empty_sequence CXTEXT { $$ = INPUT_TYPE($1, text); }
513 | possibly_empty_sequence CXPASSWORD { $$ = INPUT_TYPE($1, password); }
514 | possibly_empty_sequence CXRADIO { $$ = INPUT_TYPE($1, radio); }
515 | possibly_empty_sequence CXCHECKBOX { $$ = INPUT_TYPE($1, checkbox); }
516 | possibly_empty_sequence CXSUBMIT { $$ = INPUT_TYPE($1, submit); }
517 | possibly_empty_sequence CXIMAGE { $$ = INPUT_TYPE($1, image); }
518 | possibly_empty_sequence CXRESET { $$ = INPUT_TYPE($1, reset); }
519 | possibly_empty_sequence CXBUTTON { $$ = INPUT_TYPE($1, button); }
520 | possibly_empty_sequence CXFILE { $$ = INPUT_TYPE($1, file); }
6641105 simple selectors check out
Kyle Maxwell authored Nov 21, 2008
521 ;
522
523 possibly_empty_sequence
524 : simple_selector_sequence
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
525 | { $$ = PXP("*"); }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
526 ;
527
528 simple_selector_anchor
529 : type_selector
530 | universal
531 ;
532
533 type_selector
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
534 : namespace_prefix element_name { $$ = pxpath_cat_paths(3, $1, PXP(":"), $2); }
7d153fd progress
Kyle Maxwell authored Nov 22, 2008
535 | element_name
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
536 ;
537
538 namespace_prefix
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
539 : SPLAT PIPE { $$ = PXP("*"); }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
540 | Ident PIPE { $$ = $1; }
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
541 | PIPE { $$ = PXP("*"); }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
542 ;
543
544 element_name
4c102cc WIP, compiles bad XSLT
Kyle Maxwell authored Mar 10, 2009
545 : Ident { $$ = $1; }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
546 ;
547
548 universal
687216b WIP
Kyle Maxwell authored Mar 10, 2009
549 : namespace_prefix SPLAT { $$ = pxpath_cat_paths(3, $1, PXP(":"), PXP($2)); }
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
550 | SPLAT { $$ = PXP($1); }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
551 ;
9df5a91 some parsing
Kyle Maxwell authored Nov 21, 2008
552
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
553 NumberLike
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
554 : NUMBER { $$ = PXP($1); }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
555 ;
556
557 Ident
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
558 : NAME { $$ = PXP($1); }
559 | BSLASHLIT { $$ = PXP($1 + 1); }
4c102cc WIP, compiles bad XSLT
Kyle Maxwell authored Mar 10, 2009
560 | NAME Ident { $$ = pxpath_cat_paths(2, PXP($1), $2); }
561 | BSLASHLIT Ident { $$ = pxpath_cat_paths(2, PXP($1 + 1), $2); }
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
562 | keyword { $$ = PXP($1); }
4a1e5f0 fix css keyword bug
Kyle Maxwell authored Nov 21, 2008
563 ;
564
565 keyword
566 : XANCESTOR
567 | XANCESTORSELF
568 | XATTR
569 | XCHILD
570 | XDESC
571 | XDESCSELF
572 | XFOLLOW
573 | XFOLLOWSIB
574 | XNS
575 | XPARENT
576 | XPRE
577 | XPRESIB
578 | XSELF
579 | XOR
580 | XAND
581 | XDIV
582 | XMOD
583 | XCOMMENT
584 | XTEXT
585 | XPI
586 | XNODE
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
587 ;
588
589 StringLike
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
590 : Ident
591 | STRING { $$ = pxpath_new_literal(1, $1); }
81b87f1 css parsing?
Kyle Maxwell authored Nov 21, 2008
592 ;
593
594 OptS
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
595 : S { $$ = 0; }
596 | { $$ = 0; }
a7f68e6 progress
Kyle Maxwell authored Nov 21, 2008
597 ;
598
9df5a91 some parsing
Kyle Maxwell authored Nov 21, 2008
599 %%
600
df15251 remote html works, some function aliases work
Kyle Maxwell authored Dec 31, 2008
601 char* xpath_alias(char* key) {
602 char* value = (char*) xmlHashLookup(alias_hash, key);
603 return value == NULL ? key : value;
604 }
605
606 void init_xpath_alias() {
607 alias_hash = xmlHashCreate(100);
712f3a6 tentative rename, etc
Kyle Maxwell authored Mar 3, 2009
608 xmlHashAddEntry(alias_hash, "html", "lib:html-document");
9691541 status
Kyle Maxwell authored Dec 31, 2008
609 xmlHashAddEntry(alias_hash, "match", "regexp:match");
610 xmlHashAddEntry(alias_hash, "replace", "regexp:replace");
611 xmlHashAddEntry(alias_hash, "test", "regexp:test");
06d1a2d now allowing multiple predicates (passing) [0.589151]
Kyle Maxwell authored Apr 1, 2009
612 xmlHashAddEntry(alias_hash, "with-newlines", "lib:nl");
df15251 remote html works, some function aliases work
Kyle Maxwell authored Dec 31, 2008
613 }
614
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
615 pxpathPtr myparse(char* string){
2cb3f54 test for div and calculations (failing) [0.592115]
Kyle Maxwell authored Mar 31, 2009
616 // start_debugging();
629bd49 WIP, tests pass, some memory leaks out
Kyle Maxwell authored Mar 12, 2009
617 parsed_answer = NULL;
a7f68e6 progress
Kyle Maxwell authored Nov 21, 2008
618 prepare_parse(string);
619 yyparse();
620 cleanup_parse();
4c102cc WIP, compiles bad XSLT
Kyle Maxwell authored Mar 10, 2009
621 return parsed_answer;
7d153fd progress
Kyle Maxwell authored Nov 22, 2008
622 }
623
19b3d0e WIP, many tests now pass
Kyle Maxwell authored Mar 9, 2009
624 void answer(pxpathPtr a){
7d153fd progress
Kyle Maxwell authored Nov 22, 2008
625 parsed_answer = a;
a7f68e6 progress
Kyle Maxwell authored Nov 21, 2008
626 }
627
6d3efd0 unknown progress
Kyle Maxwell authored Nov 21, 2008
628 void start_debugging(){
629 yydebug = 1;
630 return;
4e5efd0 WIP, tentative reworking of parser
Kyle Maxwell authored Mar 9, 2009
631 }
Something went wrong with that request. Please try again.