OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright 2005 Frerich Raabe <raabe@kde.org> |
3 * Copyright (C) 2006 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006 Apple Inc. All rights reserved. |
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 #define YYMALLOC yyFastMalloc | 44 #define YYMALLOC yyFastMalloc |
45 #define YYFREE WTF::Partitions::FastFree | 45 #define YYFREE WTF::Partitions::FastFree |
46 | 46 |
47 #define YYENABLE_NLS 0 | 47 #define YYENABLE_NLS 0 |
48 #define YYLTYPE_IS_TRIVIAL 1 | 48 #define YYLTYPE_IS_TRIVIAL 1 |
49 #define YYDEBUG 0 | 49 #define YYDEBUG 0 |
50 #define YYMAXDEPTH 10000 | 50 #define YYMAXDEPTH 10000 |
51 | 51 |
52 using namespace blink; | 52 using blink::XPath::Step; |
53 using namespace XPath; | |
54 | |
55 %} | 53 %} |
56 | 54 |
57 %pure-parser | 55 %pure-parser |
58 %parse-param { blink::XPath::Parser* parser } | 56 %parse-param { blink::XPath::Parser* parser } |
59 | 57 |
60 %union | 58 %union |
61 { | 59 { |
62 blink::XPath::Step::Axis axis; | 60 blink::XPath::Step::Axis axis; |
63 blink::XPath::Step::NodeTest* nodeTest; | 61 blink::XPath::Step::NodeTest* nodeTest; |
64 blink::XPath::NumericOp::Opcode numop; | 62 blink::XPath::NumericOp::Opcode numop; |
65 blink::XPath::EqTestOp::Opcode eqop; | 63 blink::XPath::EqTestOp::Opcode eqop; |
66 String* str; | 64 String* str; |
67 blink::XPath::Expression* expr; | 65 blink::XPath::Expression* expr; |
68 blink::HeapVector<blink::Member<blink::XPath::Predicate>>* predList; | 66 blink::HeapVector<blink::Member<blink::XPath::Predicate>>* predList; |
69 blink::HeapVector<blink::Member<blink::XPath::Expression>>* argList; | 67 blink::HeapVector<blink::Member<blink::XPath::Expression>>* argList; |
70 blink::XPath::Step* step; | 68 blink::XPath::Step* step; |
71 blink::XPath::LocationPath* locationPath; | 69 blink::XPath::LocationPath* locationPath; |
72 } | 70 } |
73 | 71 |
74 %{ | 72 %{ |
75 | 73 |
76 static int xpathyylex(YYSTYPE* yylval) { return Parser::Current()->Lex(yylval);
} | 74 static int xpathyylex(YYSTYPE* yylval) { return blink::XPath::Parser::Current()-
>Lex(yylval); } |
77 static void xpathyyerror(void*, const char*) { } | 75 static void xpathyyerror(void*, const char*) { } |
78 | 76 |
79 %} | 77 %} |
80 | 78 |
81 %left <numop> MULOP | 79 %left <numop> MULOP |
82 %left <eqop> EQOP RELOP | 80 %left <eqop> EQOP RELOP |
83 %left PLUS MINUS | 81 %left PLUS MINUS |
84 %left OR AND | 82 %left OR AND |
85 %token <axis> AXISNAME | 83 %token <axis> AXISNAME |
86 %token <str> NODETYPE PI FUNCTIONNAME LITERAL | 84 %token <str> NODETYPE PI FUNCTIONNAME LITERAL |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | | 131 | |
134 AbsoluteLocationPath | 132 AbsoluteLocationPath |
135 { | 133 { |
136 $$->SetAbsolute(true); | 134 $$->SetAbsolute(true); |
137 } | 135 } |
138 ; | 136 ; |
139 | 137 |
140 AbsoluteLocationPath: | 138 AbsoluteLocationPath: |
141 '/' | 139 '/' |
142 { | 140 { |
143 $$ = new LocationPath; | 141 $$ = new blink::XPath::LocationPath; |
144 } | 142 } |
145 | | 143 | |
146 '/' RelativeLocationPath | 144 '/' RelativeLocationPath |
147 { | 145 { |
148 $$ = $2; | 146 $$ = $2; |
149 } | 147 } |
150 | | 148 | |
151 DescendantOrSelf RelativeLocationPath | 149 DescendantOrSelf RelativeLocationPath |
152 { | 150 { |
153 $$ = $2; | 151 $$ = $2; |
154 $$->InsertFirstStep($1); | 152 $$->InsertFirstStep($1); |
155 } | 153 } |
156 ; | 154 ; |
157 | 155 |
158 RelativeLocationPath: | 156 RelativeLocationPath: |
159 Step | 157 Step |
160 { | 158 { |
161 $$ = new LocationPath; | 159 $$ = new blink::XPath::LocationPath; |
162 $$->AppendStep($1); | 160 $$->AppendStep($1); |
163 } | 161 } |
164 | | 162 | |
165 RelativeLocationPath '/' Step | 163 RelativeLocationPath '/' Step |
166 { | 164 { |
167 $$->AppendStep($3); | 165 $$->AppendStep($3); |
168 } | 166 } |
169 | | 167 | |
170 RelativeLocationPath DescendantOrSelf Step | 168 RelativeLocationPath DescendantOrSelf Step |
171 { | 169 { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 { | 265 { |
268 $$ = 0; | 266 $$ = 0; |
269 } | 267 } |
270 | | 268 | |
271 PredicateList | 269 PredicateList |
272 ; | 270 ; |
273 | 271 |
274 PredicateList: | 272 PredicateList: |
275 Predicate | 273 Predicate |
276 { | 274 { |
277 $$ = new blink::HeapVector<blink::Member<Predicate>>; | 275 $$ = new blink::HeapVector<blink::Member<blink::XPath::Predicate>>; |
278 $$->push_back(new Predicate($1)); | 276 $$->push_back(new blink::XPath::Predicate($1)); |
279 } | 277 } |
280 | | 278 | |
281 PredicateList Predicate | 279 PredicateList Predicate |
282 { | 280 { |
283 $$->push_back(new Predicate($2)); | 281 $$->push_back(new blink::XPath::Predicate($2)); |
284 } | 282 } |
285 ; | 283 ; |
286 | 284 |
287 Predicate: | 285 Predicate: |
288 '[' Expr ']' | 286 '[' Expr ']' |
289 { | 287 { |
290 $$ = $2; | 288 $$ = $2; |
291 } | 289 } |
292 ; | 290 ; |
293 | 291 |
(...skipping 12 matching lines...) Expand all Loading... |
306 | | 304 | |
307 DOTDOT | 305 DOTDOT |
308 { | 306 { |
309 $$ = new Step(Step::kParentAxis, Step::NodeTest(Step::NodeTest::kAnyNode
Test)); | 307 $$ = new Step(Step::kParentAxis, Step::NodeTest(Step::NodeTest::kAnyNode
Test)); |
310 } | 308 } |
311 ; | 309 ; |
312 | 310 |
313 PrimaryExpr: | 311 PrimaryExpr: |
314 VARIABLEREFERENCE | 312 VARIABLEREFERENCE |
315 { | 313 { |
316 $$ = new VariableReference(*$1); | 314 $$ = new blink::XPath::VariableReference(*$1); |
317 parser->DeleteString($1); | 315 parser->DeleteString($1); |
318 } | 316 } |
319 | | 317 | |
320 '(' Expr ')' | 318 '(' Expr ')' |
321 { | 319 { |
322 $$ = $2; | 320 $$ = $2; |
323 } | 321 } |
324 | | 322 | |
325 LITERAL | 323 LITERAL |
326 { | 324 { |
327 $$ = new StringExpression(*$1); | 325 $$ = new blink::XPath::StringExpression(*$1); |
328 parser->DeleteString($1); | 326 parser->DeleteString($1); |
329 } | 327 } |
330 | | 328 | |
331 NUMBER | 329 NUMBER |
332 { | 330 { |
333 $$ = new Number($1->ToDouble()); | 331 $$ = new blink::XPath::Number($1->ToDouble()); |
334 parser->DeleteString($1); | 332 parser->DeleteString($1); |
335 } | 333 } |
336 | | 334 | |
337 FunctionCall | 335 FunctionCall |
338 ; | 336 ; |
339 | 337 |
340 FunctionCall: | 338 FunctionCall: |
341 FUNCTIONNAME '(' ')' | 339 FUNCTIONNAME '(' ')' |
342 { | 340 { |
343 $$ = CreateFunction(*$1); | 341 $$ = blink::XPath::CreateFunction(*$1); |
344 if (!$$) | 342 if (!$$) |
345 YYABORT; | 343 YYABORT; |
346 parser->DeleteString($1); | 344 parser->DeleteString($1); |
347 } | 345 } |
348 | | 346 | |
349 FUNCTIONNAME '(' ArgumentList ')' | 347 FUNCTIONNAME '(' ArgumentList ')' |
350 { | 348 { |
351 $$ = CreateFunction(*$1, *$3); | 349 $$ = blink::XPath::CreateFunction(*$1, *$3); |
352 if (!$$) | 350 if (!$$) |
353 YYABORT; | 351 YYABORT; |
354 parser->DeleteString($1); | 352 parser->DeleteString($1); |
355 } | 353 } |
356 ; | 354 ; |
357 | 355 |
358 ArgumentList: | 356 ArgumentList: |
359 Argument | 357 Argument |
360 { | 358 { |
361 $$ = new blink::HeapVector<blink::Member<Expression>>; | 359 $$ = new blink::HeapVector<blink::Member<blink::XPath::Expression>>; |
362 $$->push_back($1); | 360 $$->push_back($1); |
363 } | 361 } |
364 | | 362 | |
365 ArgumentList ',' Argument | 363 ArgumentList ',' Argument |
366 { | 364 { |
367 $$->push_back($3); | 365 $$->push_back($3); |
368 } | 366 } |
369 ; | 367 ; |
370 | 368 |
371 Argument: | 369 Argument: |
372 Expr | 370 Expr |
373 ; | 371 ; |
374 | 372 |
375 UnionExpr: | 373 UnionExpr: |
376 PathExpr | 374 PathExpr |
377 | | 375 | |
378 UnionExpr '|' PathExpr | 376 UnionExpr '|' PathExpr |
379 { | 377 { |
380 $$ = new Union; | 378 $$ = new blink::XPath::Union; |
381 $$->AddSubExpression($1); | 379 $$->AddSubExpression($1); |
382 $$->AddSubExpression($3); | 380 $$->AddSubExpression($3); |
383 } | 381 } |
384 ; | 382 ; |
385 | 383 |
386 PathExpr: | 384 PathExpr: |
387 LocationPath | 385 LocationPath |
388 { | 386 { |
389 $$ = $1; | 387 $$ = $1; |
390 } | 388 } |
(...skipping 21 matching lines...) Expand all Loading... |
412 { | 410 { |
413 $$ = new blink::XPath::Filter($1, *$2); | 411 $$ = new blink::XPath::Filter($1, *$2); |
414 } | 412 } |
415 ; | 413 ; |
416 | 414 |
417 OrExpr: | 415 OrExpr: |
418 AndExpr | 416 AndExpr |
419 | | 417 | |
420 OrExpr OR AndExpr | 418 OrExpr OR AndExpr |
421 { | 419 { |
422 $$ = new LogicalOp(LogicalOp::kOP_Or, $1, $3); | 420 $$ = new blink::XPath::LogicalOp(blink::XPath::LogicalOp::kOP_Or, $1, $3
); |
423 } | 421 } |
424 ; | 422 ; |
425 | 423 |
426 AndExpr: | 424 AndExpr: |
427 EqualityExpr | 425 EqualityExpr |
428 | | 426 | |
429 AndExpr AND EqualityExpr | 427 AndExpr AND EqualityExpr |
430 { | 428 { |
431 $$ = new LogicalOp(LogicalOp::kOP_And, $1, $3); | 429 $$ = new blink::XPath::LogicalOp(blink::XPath::LogicalOp::kOP_And, $1, $
3); |
432 } | 430 } |
433 ; | 431 ; |
434 | 432 |
435 EqualityExpr: | 433 EqualityExpr: |
436 RelationalExpr | 434 RelationalExpr |
437 | | 435 | |
438 EqualityExpr EQOP RelationalExpr | 436 EqualityExpr EQOP RelationalExpr |
439 { | 437 { |
440 $$ = new EqTestOp($2, $1, $3); | 438 $$ = new blink::XPath::EqTestOp($2, $1, $3); |
441 } | 439 } |
442 ; | 440 ; |
443 | 441 |
444 RelationalExpr: | 442 RelationalExpr: |
445 AdditiveExpr | 443 AdditiveExpr |
446 | | 444 | |
447 RelationalExpr RELOP AdditiveExpr | 445 RelationalExpr RELOP AdditiveExpr |
448 { | 446 { |
449 $$ = new EqTestOp($2, $1, $3); | 447 $$ = new blink::XPath::EqTestOp($2, $1, $3); |
450 } | 448 } |
451 ; | 449 ; |
452 | 450 |
453 AdditiveExpr: | 451 AdditiveExpr: |
454 MultiplicativeExpr | 452 MultiplicativeExpr |
455 | | 453 | |
456 AdditiveExpr PLUS MultiplicativeExpr | 454 AdditiveExpr PLUS MultiplicativeExpr |
457 { | 455 { |
458 $$ = new NumericOp(NumericOp::kOP_Add, $1, $3); | 456 $$ = new blink::XPath::NumericOp(blink::XPath::NumericOp::kOP_Add, $1, $
3); |
459 } | 457 } |
460 | | 458 | |
461 AdditiveExpr MINUS MultiplicativeExpr | 459 AdditiveExpr MINUS MultiplicativeExpr |
462 { | 460 { |
463 $$ = new NumericOp(NumericOp::kOP_Sub, $1, $3); | 461 $$ = new blink::XPath::NumericOp(blink::XPath::NumericOp::kOP_Sub, $1, $
3); |
464 } | 462 } |
465 ; | 463 ; |
466 | 464 |
467 MultiplicativeExpr: | 465 MultiplicativeExpr: |
468 UnaryExpr | 466 UnaryExpr |
469 | | 467 | |
470 MultiplicativeExpr MULOP UnaryExpr | 468 MultiplicativeExpr MULOP UnaryExpr |
471 { | 469 { |
472 $$ = new NumericOp($2, $1, $3); | 470 $$ = new blink::XPath::NumericOp($2, $1, $3); |
473 } | 471 } |
474 ; | 472 ; |
475 | 473 |
476 UnaryExpr: | 474 UnaryExpr: |
477 UnionExpr | 475 UnionExpr |
478 | | 476 | |
479 MINUS UnaryExpr | 477 MINUS UnaryExpr |
480 { | 478 { |
481 $$ = new Negative; | 479 $$ = new blink::XPath::Negative; |
482 $$->AddSubExpression($2); | 480 $$->AddSubExpression($2); |
483 } | 481 } |
484 ; | 482 ; |
485 | 483 |
486 %% | 484 %% |
OLD | NEW |