Class: Oga::XPath::Parser Private
- Inherits:
-
LL::Driver
- Object
- LL::Driver
- Oga::XPath::Parser
- Defined in:
- lib/oga/xpath/parser.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- CONFIG =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
LL::DriverConfig.new
- CACHE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
LRU.new
Class Method Summary collapse
Instance Method Summary collapse
- #_rule_0(val) ⇒ Object private
- #_rule_1(val) ⇒ Object private
- #_rule_10(val) ⇒ Object private
- #_rule_11(val) ⇒ Object private
- #_rule_12(val) ⇒ Object private
- #_rule_13(val) ⇒ Object private
- #_rule_14(val) ⇒ Object private
- #_rule_15(val) ⇒ Object private
- #_rule_16(val) ⇒ Object private
- #_rule_17(val) ⇒ Object private
- #_rule_18(val) ⇒ Object private
- #_rule_19(val) ⇒ Object private
- #_rule_2(val) ⇒ Object private
- #_rule_20(val) ⇒ Object private
- #_rule_21(val) ⇒ Object private
- #_rule_22(val) ⇒ Object private
- #_rule_23(val) ⇒ Object private
- #_rule_24(val) ⇒ Object private
- #_rule_25(val) ⇒ Object private
- #_rule_26(val) ⇒ Object private
- #_rule_27(val) ⇒ Object private
- #_rule_28(val) ⇒ Object private
- #_rule_29(val) ⇒ Object private
- #_rule_3(val) ⇒ Object private
- #_rule_30(val) ⇒ Object private
- #_rule_31(val) ⇒ Object private
- #_rule_32(val) ⇒ Object private
- #_rule_33(val) ⇒ Object private
- #_rule_34(val) ⇒ Object private
- #_rule_35(val) ⇒ Object private
- #_rule_36(val) ⇒ Object private
- #_rule_37(val) ⇒ Object private
- #_rule_38(val) ⇒ Object private
- #_rule_39(val) ⇒ Object private
- #_rule_4(val) ⇒ Object private
- #_rule_40(val) ⇒ Object private
- #_rule_41(val) ⇒ Object private
- #_rule_42(val) ⇒ Object private
- #_rule_43(val) ⇒ Object private
- #_rule_44(val) ⇒ Object private
- #_rule_45(val) ⇒ Object private
- #_rule_46(val) ⇒ Object private
- #_rule_47(val) ⇒ Object private
- #_rule_48(val) ⇒ Object private
- #_rule_49(val) ⇒ Object private
- #_rule_5(val) ⇒ Object private
- #_rule_50(val) ⇒ Object private
- #_rule_51(val) ⇒ Object private
- #_rule_52(val) ⇒ Object private
- #_rule_53(val) ⇒ Object private
- #_rule_54(val) ⇒ Object private
- #_rule_55(val) ⇒ Object private
- #_rule_56(val) ⇒ Object private
- #_rule_57(val) ⇒ Object private
- #_rule_58(val) ⇒ Object private
- #_rule_59(val) ⇒ Object private
- #_rule_6(val) ⇒ Object private
- #_rule_60(val) ⇒ Object private
- #_rule_61(val) ⇒ Object private
- #_rule_62(val) ⇒ Object private
- #_rule_63(val) ⇒ Object private
- #_rule_64(val) ⇒ Object private
- #_rule_65(val) ⇒ Object private
- #_rule_66(val) ⇒ Object private
- #_rule_67(val) ⇒ Object private
- #_rule_7(val) ⇒ Object private
- #_rule_8(val) ⇒ Object private
- #_rule_9(val) ⇒ Object private
- #combine_operators(val) ⇒ Object private
- #combine_optional_operator(val) ⇒ Object private
-
#each_token {|| ... } ⇒ Object
private
Yields the next token from the lexer.
-
#initialize(data) ⇒ Parser
constructor
private
A new instance of Parser.
-
#s(type, *children) ⇒ AST::Node
private
Creates a new XPath node.
Constructor Details
#initialize(data) ⇒ Parser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Parser.
261 262 263 |
# File 'lib/oga/xpath/parser.rb', line 261 def initialize(data) @lexer = Lexer.new(data) end |
Class Method Details
.parse_with_cache(data) ⇒ AST::Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
254 255 256 |
# File 'lib/oga/xpath/parser.rb', line 254 def self.parse_with_cache(data) return CACHE.get_or_set(data) { new(data).parse } end |
Instance Method Details
#_rule_0(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
317 318 319 |
# File 'lib/oga/xpath/parser.rb', line 317 def _rule_0(val) val[0] end |
#_rule_1(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
321 322 323 |
# File 'lib/oga/xpath/parser.rb', line 321 def _rule_1(val) combine_operators(val) end |
#_rule_10(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
357 358 359 |
# File 'lib/oga/xpath/parser.rb', line 357 def _rule_10(val) [:gt, val[1]] end |
#_rule_11(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
361 362 363 |
# File 'lib/oga/xpath/parser.rb', line 361 def _rule_11(val) [:lte, val[1]] end |
#_rule_12(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
365 366 367 |
# File 'lib/oga/xpath/parser.rb', line 365 def _rule_12(val) [:gte, val[1]] end |
#_rule_13(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
369 370 371 |
# File 'lib/oga/xpath/parser.rb', line 369 def _rule_13(val) combine_operators(val) end |
#_rule_14(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
373 374 375 |
# File 'lib/oga/xpath/parser.rb', line 373 def _rule_14(val) [:add, val[1]] end |
#_rule_15(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
377 378 379 |
# File 'lib/oga/xpath/parser.rb', line 377 def _rule_15(val) [:sub, val[1]] end |
#_rule_16(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
381 382 383 |
# File 'lib/oga/xpath/parser.rb', line 381 def _rule_16(val) combine_optional_operator(val) end |
#_rule_17(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
385 386 387 |
# File 'lib/oga/xpath/parser.rb', line 385 def _rule_17(val) [:div, val[1]] end |
#_rule_18(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
389 390 391 |
# File 'lib/oga/xpath/parser.rb', line 389 def _rule_18(val) [:mod, val[1]] end |
#_rule_19(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
393 394 395 |
# File 'lib/oga/xpath/parser.rb', line 393 def _rule_19(val) [:mul, val[1]] end |
#_rule_2(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
325 326 327 |
# File 'lib/oga/xpath/parser.rb', line 325 def _rule_2(val) [:or, val[1]] end |
#_rule_20(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
397 398 399 |
# File 'lib/oga/xpath/parser.rb', line 397 def _rule_20(val) combine_operators(val) end |
#_rule_21(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
401 402 403 |
# File 'lib/oga/xpath/parser.rb', line 401 def _rule_21(val) [:pipe, val[1]] end |
#_rule_22(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
405 406 407 |
# File 'lib/oga/xpath/parser.rb', line 405 def _rule_22(val) val[0] end |
#_rule_23(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
409 410 411 |
# File 'lib/oga/xpath/parser.rb', line 409 def _rule_23(val) val[0] end |
#_rule_24(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
413 414 415 |
# File 'lib/oga/xpath/parser.rb', line 413 def _rule_24(val) val[0] end |
#_rule_25(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
417 418 419 |
# File 'lib/oga/xpath/parser.rb', line 417 def _rule_25(val) val[0] end |
#_rule_26(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
421 422 423 |
# File 'lib/oga/xpath/parser.rb', line 421 def _rule_26(val) val[0] end |
#_rule_27(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
425 426 427 |
# File 'lib/oga/xpath/parser.rb', line 425 def _rule_27(val) val[1] end |
#_rule_28(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
429 430 431 |
# File 'lib/oga/xpath/parser.rb', line 429 def _rule_28(val) val[0].length > 1 ? s(:path, *val[0]) : val[0][0] end |
#_rule_29(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
433 434 435 |
# File 'lib/oga/xpath/parser.rb', line 433 def _rule_29(val) [val[0], *val[1]] end |
#_rule_3(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
329 330 331 |
# File 'lib/oga/xpath/parser.rb', line 329 def _rule_3(val) combine_operators(val) end |
#_rule_30(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
437 438 439 |
# File 'lib/oga/xpath/parser.rb', line 437 def _rule_30(val) val[1] end |
#_rule_31(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
441 442 443 |
# File 'lib/oga/xpath/parser.rb', line 441 def _rule_31(val) s(:absolute_path, *val[1]) end |
#_rule_32(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
445 446 447 |
# File 'lib/oga/xpath/parser.rb', line 445 def _rule_32(val) val[0] end |
#_rule_33(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
449 450 451 |
# File 'lib/oga/xpath/parser.rb', line 449 def _rule_33(val) val[0] end |
#_rule_34(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/oga/xpath/parser.rb', line 453 def _rule_34(val) type = val[1][0] args = val[1][1] pred = val[1][2] if type.equal?(:test) # Whenever a bare test is used (e.g. just "A") this actually means # "child::A". Handling this on parser level is the easiest. if args node = s(:axis, 'child', s(:test, val[0], args)) else node = s(:axis, 'child', s(:test, nil, val[0])) end else node = s(type, val[0], *args) end if pred node = s(:predicate, node, pred) end node end |
#_rule_35(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
479 480 481 |
# File 'lib/oga/xpath/parser.rb', line 479 def _rule_35(val) s(:axis, 'child', val[0]) end |
#_rule_36(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
483 484 485 |
# File 'lib/oga/xpath/parser.rb', line 483 def _rule_36(val) [:call, val[1]] end |
#_rule_37(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
487 488 489 |
# File 'lib/oga/xpath/parser.rb', line 487 def _rule_37(val) [:test, val[1], val[2]] end |
#_rule_38(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
491 492 493 |
# File 'lib/oga/xpath/parser.rb', line 491 def _rule_38(val) [:test, nil, val[0]] end |
#_rule_39(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
495 496 497 |
# File 'lib/oga/xpath/parser.rb', line 495 def _rule_39(val) val[1] end |
#_rule_4(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
333 334 335 |
# File 'lib/oga/xpath/parser.rb', line 333 def _rule_4(val) [:and, val[1]] end |
#_rule_40(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
499 500 501 |
# File 'lib/oga/xpath/parser.rb', line 499 def _rule_40(val) s(:type_test, val[0]) end |
#_rule_41(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
503 504 505 506 507 |
# File 'lib/oga/xpath/parser.rb', line 503 def _rule_41(val) val[1] ? s(:test, val[0], val[1]) : s(:test, nil, val[0]) end |
#_rule_42(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
509 510 511 |
# File 'lib/oga/xpath/parser.rb', line 509 def _rule_42(val) val[1] end |
#_rule_43(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
513 514 515 |
# File 'lib/oga/xpath/parser.rb', line 513 def _rule_43(val) [val[0], *val[1]] end |
#_rule_44(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
517 518 519 |
# File 'lib/oga/xpath/parser.rb', line 517 def _rule_44(val) val end |
#_rule_45(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
521 522 523 |
# File 'lib/oga/xpath/parser.rb', line 521 def _rule_45(val) val[1] end |
#_rule_46(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/oga/xpath/parser.rb', line 525 def _rule_46(val) ret = s(:axis, val[0], val[1]) if val[2] ret = s(:predicate, ret, val[2]) end ret end |
#_rule_47(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
537 538 539 |
# File 'lib/oga/xpath/parser.rb', line 537 def _rule_47(val) val[0] end |
#_rule_48(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
541 542 543 |
# File 'lib/oga/xpath/parser.rb', line 541 def _rule_48(val) val[0] end |
#_rule_49(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
545 546 547 |
# File 'lib/oga/xpath/parser.rb', line 545 def _rule_49(val) s(:string, val[0]) end |
#_rule_5(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
337 338 339 |
# File 'lib/oga/xpath/parser.rb', line 337 def _rule_5(val) combine_operators(val) end |
#_rule_50(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
549 550 551 |
# File 'lib/oga/xpath/parser.rb', line 549 def _rule_50(val) s(:int, val[0]) end |
#_rule_51(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
553 554 555 |
# File 'lib/oga/xpath/parser.rb', line 553 def _rule_51(val) s(:float, val[0]) end |
#_rule_52(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
557 558 559 |
# File 'lib/oga/xpath/parser.rb', line 557 def _rule_52(val) s(:var, val[0]) end |
#_rule_53(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
561 562 563 |
# File 'lib/oga/xpath/parser.rb', line 561 def _rule_53(val) val[0] end |
#_rule_54(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
565 566 567 |
# File 'lib/oga/xpath/parser.rb', line 565 def _rule_54(val) val[0] end |
#_rule_55(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
569 570 571 |
# File 'lib/oga/xpath/parser.rb', line 569 def _rule_55(val) val[0] end |
#_rule_56(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
573 574 575 |
# File 'lib/oga/xpath/parser.rb', line 573 def _rule_56(val) val[0] end |
#_rule_57(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
577 578 579 |
# File 'lib/oga/xpath/parser.rb', line 577 def _rule_57(val) val[0] end |
#_rule_58(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
581 582 583 |
# File 'lib/oga/xpath/parser.rb', line 581 def _rule_58(val) val[0] end |
#_rule_59(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
585 586 587 |
# File 'lib/oga/xpath/parser.rb', line 585 def _rule_59(val) val[0] end |
#_rule_6(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
341 342 343 |
# File 'lib/oga/xpath/parser.rb', line 341 def _rule_6(val) [:eq, val[1]] end |
#_rule_60(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
589 590 591 |
# File 'lib/oga/xpath/parser.rb', line 589 def _rule_60(val) val[0] end |
#_rule_61(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
593 594 595 |
# File 'lib/oga/xpath/parser.rb', line 593 def _rule_61(val) val[0] end |
#_rule_62(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
597 598 599 |
# File 'lib/oga/xpath/parser.rb', line 597 def _rule_62(val) val[0] end |
#_rule_63(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
601 602 603 |
# File 'lib/oga/xpath/parser.rb', line 601 def _rule_63(val) val[0] end |
#_rule_64(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
605 606 607 |
# File 'lib/oga/xpath/parser.rb', line 605 def _rule_64(val) val[0] end |
#_rule_65(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
609 610 611 |
# File 'lib/oga/xpath/parser.rb', line 609 def _rule_65(val) val[0] end |
#_rule_66(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
613 614 615 |
# File 'lib/oga/xpath/parser.rb', line 613 def _rule_66(val) val[0] end |
#_rule_67(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
617 618 619 |
# File 'lib/oga/xpath/parser.rb', line 617 def _rule_67(val) val[0] end |
#_rule_7(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
345 346 347 |
# File 'lib/oga/xpath/parser.rb', line 345 def _rule_7(val) [:neq, val[1]] end |
#_rule_8(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
349 350 351 |
# File 'lib/oga/xpath/parser.rb', line 349 def _rule_8(val) combine_operators(val) end |
#_rule_9(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
353 354 355 |
# File 'lib/oga/xpath/parser.rb', line 353 def _rule_9(val) [:lt, val[1]] end |
#combine_operators(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
294 295 296 297 298 299 300 301 302 |
# File 'lib/oga/xpath/parser.rb', line 294 def combine_operators(val) ret = val[0] val[1].each do |expr| ret = s(expr[0], ret, expr[1]) end return ret end |
#combine_optional_operator(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
307 308 309 310 311 312 313 314 315 |
# File 'lib/oga/xpath/parser.rb', line 307 def combine_optional_operator(val) ret = val[0] if val[1] ret = s(val[1][0], ret, val[1][1]) end ret end |
#each_token {|| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Yields the next token from the lexer.
281 282 283 284 285 286 287 288 289 |
# File 'lib/oga/xpath/parser.rb', line 281 def each_token @lexer.advance do |type, value, line| @line = line if line yield [type, value] end yield [-1, -1] end |
#s(type, *children) ⇒ AST::Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new XPath node.
272 273 274 |
# File 'lib/oga/xpath/parser.rb', line 272 def s(type, *children) return AST::Node.new(type, children) end |