Class: Nokogiri::CSS::GeneratedParser
- Inherits:
-
Racc::Parser
- Object
- Racc::Parser
- Nokogiri::CSS::GeneratedParser
- Defined in:
- lib/nokogiri/css/generated_parser.rb
Direct Known Subclasses
Constant Summary collapse
- Racc_arg =
[ racc_action_table, racc_action_check, racc_action_default, racc_action_pointer, racc_goto_table, racc_goto_check, racc_goto_default, racc_goto_pointer, racc_nt_base, racc_reduce_table, racc_token_table, racc_shift_n, racc_reduce_n, racc_use_result_var ]
- Racc_token_to_s_table =
[ "$end", "error", "FUNCTION", "INCLUDES", "DASHMATCH", "LBRACE", "HASH", "PLUS", "GREATER", "S", "STRING", "IDENT", "COMMA", "NUMBER", "PREFIXMATCH", "SUFFIXMATCH", "SUBSTRINGMATCH", "TILDE", "NOT_EQUAL", "SLASH", "DOUBLESLASH", "NOT", "EQUAL", "RPAREN", "LSQUARE", "RSQUARE", "HAS", "\".\"", "\"|\"", "\"*\"", "\":\"", "$start", "selector", "simple_selector_1toN", "combinator", "simple_selector", "element_name", "hcap_0toN", "hcap_1toN", "negation", "function", "attrib", "class", "namespace", "attrib_val_0or1", "expr", "an_plus_b", "pseudo", "attribute_id", "eql_incl_dash", "negation_arg" ]
- Racc_debug_parser =
false
Instance Method Summary collapse
-
#_reduce_1(val, _values, result) ⇒ Object
reduce 0 omitted.
- #_reduce_10(val, _values, result) ⇒ Object
- #_reduce_11(val, _values, result) ⇒ Object
-
#_reduce_13(val, _values, result) ⇒ Object
reduce 12 omitted.
- #_reduce_14(val, _values, result) ⇒ Object
- #_reduce_15(val, _values, result) ⇒ Object
- #_reduce_16(val, _values, result) ⇒ Object
-
#_reduce_18(val, _values, result) ⇒ Object
reduce 17 omitted.
- #_reduce_19(val, _values, result) ⇒ Object
- #_reduce_2(val, _values, result) ⇒ Object
- #_reduce_20(val, _values, result) ⇒ Object
- #_reduce_21(val, _values, result) ⇒ Object
- #_reduce_22(val, _values, result) ⇒ Object
-
#_reduce_24(val, _values, result) ⇒ Object
reduce 23 omitted.
- #_reduce_25(val, _values, result) ⇒ Object
- #_reduce_26(val, _values, result) ⇒ Object
- #_reduce_27(val, _values, result) ⇒ Object
- #_reduce_28(val, _values, result) ⇒ Object
- #_reduce_29(val, _values, result) ⇒ Object
- #_reduce_3(val, _values, result) ⇒ Object
- #_reduce_30(val, _values, result) ⇒ Object
- #_reduce_31(val, _values, result) ⇒ Object
- #_reduce_32(val, _values, result) ⇒ Object
- #_reduce_33(val, _values, result) ⇒ Object
- #_reduce_34(val, _values, result) ⇒ Object
-
#_reduce_37(val, _values, result) ⇒ Object
reduce 36 omitted.
- #_reduce_38(val, _values, result) ⇒ Object
- #_reduce_39(val, _values, result) ⇒ Object
- #_reduce_4(val, _values, result) ⇒ Object
- #_reduce_40(val, _values, result) ⇒ Object
- #_reduce_41(val, _values, result) ⇒ Object
- #_reduce_42(val, _values, result) ⇒ Object
-
#_reduce_45(val, _values, result) ⇒ Object
reduce 44 omitted.
- #_reduce_46(val, _values, result) ⇒ Object
- #_reduce_47(val, _values, result) ⇒ Object
- #_reduce_48(val, _values, result) ⇒ Object
- #_reduce_5(val, _values, result) ⇒ Object
-
#_reduce_53(val, _values, result) ⇒ Object
reduce 52 omitted.
- #_reduce_54(val, _values, result) ⇒ Object
- #_reduce_55(val, _values, result) ⇒ Object
-
#_reduce_57(val, _values, result) ⇒ Object
reduce 56 omitted.
- #_reduce_58(val, _values, result) ⇒ Object
- #_reduce_59(val, _values, result) ⇒ Object
- #_reduce_6(val, _values, result) ⇒ Object
- #_reduce_60(val, _values, result) ⇒ Object
- #_reduce_61(val, _values, result) ⇒ Object
- #_reduce_62(val, _values, result) ⇒ Object
- #_reduce_63(val, _values, result) ⇒ Object
- #_reduce_64(val, _values, result) ⇒ Object
- #_reduce_7(val, _values, result) ⇒ Object
- #_reduce_8(val, _values, result) ⇒ Object
- #_reduce_9(val, _values, result) ⇒ Object
-
#_reduce_none(val, _values, result) ⇒ Object
reduce 65 omitted.
Instance Method Details
#_reduce_1(val, _values, result) ⇒ Object
reduce 0 omitted
283 284 285 286 287 |
# File 'lib/nokogiri/css/generated_parser.rb', line 283 def _reduce_1(val, _values, result) result = [val.first, val.last].flatten result end |
#_reduce_10(val, _values, result) ⇒ Object
334 335 336 337 338 339 340 341 342 343 |
# File 'lib/nokogiri/css/generated_parser.rb', line 334 def _reduce_10(val, _values, result) result = Node.new(:CONDITIONAL_SELECTOR, [ val.first, Node.new(:COMBINATOR, [val[1], val.last]) ] ) result end |
#_reduce_11(val, _values, result) ⇒ Object
345 346 347 348 349 |
# File 'lib/nokogiri/css/generated_parser.rb', line 345 def _reduce_11(val, _values, result) result = Node.new(:CONDITIONAL_SELECTOR, val) result end |
#_reduce_13(val, _values, result) ⇒ Object
reduce 12 omitted
353 354 355 356 357 |
# File 'lib/nokogiri/css/generated_parser.rb', line 353 def _reduce_13(val, _values, result) result = Node.new(:CONDITIONAL_SELECTOR, val) result end |
#_reduce_14(val, _values, result) ⇒ Object
359 360 361 362 363 364 365 366 367 368 |
# File 'lib/nokogiri/css/generated_parser.rb', line 359 def _reduce_14(val, _values, result) result = Node.new(:CONDITIONAL_SELECTOR, [ Node.new(:ELEMENT_NAME, ['*']), Node.new(:COMBINATOR, val) ] ) result end |
#_reduce_15(val, _values, result) ⇒ Object
370 371 372 373 374 375 376 |
# File 'lib/nokogiri/css/generated_parser.rb', line 370 def _reduce_15(val, _values, result) result = Node.new(:CONDITIONAL_SELECTOR, [Node.new(:ELEMENT_NAME, ['*']), val.first] ) result end |
#_reduce_16(val, _values, result) ⇒ Object
378 379 380 381 382 |
# File 'lib/nokogiri/css/generated_parser.rb', line 378 def _reduce_16(val, _values, result) result = Node.new(val[1], [val.first, val.last]) result end |
#_reduce_18(val, _values, result) ⇒ Object
reduce 17 omitted
386 387 388 389 |
# File 'lib/nokogiri/css/generated_parser.rb', line 386 def _reduce_18(val, _values, result) result = Node.new(:CLASS_CONDITION, [val[1]]) result end |
#_reduce_19(val, _values, result) ⇒ Object
391 392 393 394 395 396 397 |
# File 'lib/nokogiri/css/generated_parser.rb', line 391 def _reduce_19(val, _values, result) result = Node.new(:ELEMENT_NAME, [[val.first, val.last].compact.join(':')] ) result end |
#_reduce_2(val, _values, result) ⇒ Object
289 290 291 292 |
# File 'lib/nokogiri/css/generated_parser.rb', line 289 def _reduce_2(val, _values, result) result = val.flatten result end |
#_reduce_20(val, _values, result) ⇒ Object
399 400 401 402 403 404 |
# File 'lib/nokogiri/css/generated_parser.rb', line 399 def _reduce_20(val, _values, result) name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first result = Node.new(:ELEMENT_NAME, [name]) result end |
#_reduce_21(val, _values, result) ⇒ Object
406 407 408 409 |
# File 'lib/nokogiri/css/generated_parser.rb', line 406 def _reduce_21(val, _values, result) result = Node.new(:ELEMENT_NAME, val) result end |
#_reduce_22(val, _values, result) ⇒ Object
411 412 413 414 |
# File 'lib/nokogiri/css/generated_parser.rb', line 411 def _reduce_22(val, _values, result) result = val[0] result end |
#_reduce_24(val, _values, result) ⇒ Object
reduce 23 omitted
418 419 420 421 422 423 424 |
# File 'lib/nokogiri/css/generated_parser.rb', line 418 def _reduce_24(val, _values, result) result = Node.new(:ATTRIBUTE_CONDITION, [Node.new(:ELEMENT_NAME, [val[1]])] + (val[2] || []) ) result end |
#_reduce_25(val, _values, result) ⇒ Object
426 427 428 429 430 431 432 |
# File 'lib/nokogiri/css/generated_parser.rb', line 426 def _reduce_25(val, _values, result) result = Node.new(:ATTRIBUTE_CONDITION, [val[1]] + (val[2] || []) ) result end |
#_reduce_26(val, _values, result) ⇒ Object
434 435 436 437 438 439 440 441 |
# File 'lib/nokogiri/css/generated_parser.rb', line 434 def _reduce_26(val, _values, result) # Non standard, but hpricot supports it. result = Node.new(:PSEUDO_CLASS, [Node.new(:FUNCTION, ['nth-child(', val[1]])] ) result end |
#_reduce_27(val, _values, result) ⇒ Object
443 444 445 446 447 |
# File 'lib/nokogiri/css/generated_parser.rb', line 443 def _reduce_27(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip]) result end |
#_reduce_28(val, _values, result) ⇒ Object
449 450 451 452 453 |
# File 'lib/nokogiri/css/generated_parser.rb', line 449 def _reduce_28(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten) result end |
#_reduce_29(val, _values, result) ⇒ Object
455 456 457 458 459 |
# File 'lib/nokogiri/css/generated_parser.rb', line 455 def _reduce_29(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten) result end |
#_reduce_3(val, _values, result) ⇒ Object
294 295 296 297 |
# File 'lib/nokogiri/css/generated_parser.rb', line 294 def _reduce_3(val, _values, result) result = :DIRECT_ADJACENT_SELECTOR result end |
#_reduce_30(val, _values, result) ⇒ Object
461 462 463 464 465 |
# File 'lib/nokogiri/css/generated_parser.rb', line 461 def _reduce_30(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten) result end |
#_reduce_31(val, _values, result) ⇒ Object
467 468 469 470 471 |
# File 'lib/nokogiri/css/generated_parser.rb', line 467 def _reduce_31(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten) result end |
#_reduce_32(val, _values, result) ⇒ Object
473 474 475 476 |
# File 'lib/nokogiri/css/generated_parser.rb', line 473 def _reduce_32(val, _values, result) result = [val.first, val.last] result end |
#_reduce_33(val, _values, result) ⇒ Object
478 479 480 481 |
# File 'lib/nokogiri/css/generated_parser.rb', line 478 def _reduce_33(val, _values, result) result = [val.first, val.last] result end |
#_reduce_34(val, _values, result) ⇒ Object
483 484 485 486 |
# File 'lib/nokogiri/css/generated_parser.rb', line 483 def _reduce_34(val, _values, result) result = [val.first, val.last] result end |
#_reduce_37(val, _values, result) ⇒ Object
reduce 36 omitted
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/nokogiri/css/generated_parser.rb', line 492 def _reduce_37(val, _values, result) if val[0] == 'even' val = ["2","n","+","0"] result = Node.new(:AN_PLUS_B, val) elsif val[0] == 'odd' val = ["2","n","+","1"] result = Node.new(:AN_PLUS_B, val) else # This is not CSS standard. It allows us to support this: # assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)')) # assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)')) # assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)')) result = val end result end |
#_reduce_38(val, _values, result) ⇒ Object
510 511 512 513 514 515 516 517 518 |
# File 'lib/nokogiri/css/generated_parser.rb', line 510 def _reduce_38(val, _values, result) if val[1] == 'n' result = Node.new(:AN_PLUS_B, val) else raise Racc::ParseError, "parse error on IDENT '#{val[1]}'" end result end |
#_reduce_39(val, _values, result) ⇒ Object
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/nokogiri/css/generated_parser.rb', line 520 def _reduce_39(val, _values, result) # n+3, -n+3 if val[0] == 'n' val.unshift("1") result = Node.new(:AN_PLUS_B, val) elsif val[0] == '-n' val[0] = 'n' val.unshift("-1") result = Node.new(:AN_PLUS_B, val) else raise Racc::ParseError, "parse error on IDENT '#{val[1]}'" end result end |
#_reduce_4(val, _values, result) ⇒ Object
299 300 301 302 |
# File 'lib/nokogiri/css/generated_parser.rb', line 299 def _reduce_4(val, _values, result) result = :CHILD_SELECTOR result end |
#_reduce_40(val, _values, result) ⇒ Object
536 537 538 539 540 541 542 543 544 545 546 |
# File 'lib/nokogiri/css/generated_parser.rb', line 536 def _reduce_40(val, _values, result) if val[1] == 'n' val << "+" val << "0" result = Node.new(:AN_PLUS_B, val) else raise Racc::ParseError, "parse error on IDENT '#{val[1]}'" end result end |
#_reduce_41(val, _values, result) ⇒ Object
548 549 550 551 552 |
# File 'lib/nokogiri/css/generated_parser.rb', line 548 def _reduce_41(val, _values, result) result = Node.new(:PSEUDO_CLASS, [val[1]]) result end |
#_reduce_42(val, _values, result) ⇒ Object
554 555 556 557 |
# File 'lib/nokogiri/css/generated_parser.rb', line 554 def _reduce_42(val, _values, result) result = Node.new(:PSEUDO_CLASS, [val[1]]) result end |
#_reduce_45(val, _values, result) ⇒ Object
reduce 44 omitted
563 564 565 566 567 |
# File 'lib/nokogiri/css/generated_parser.rb', line 563 def _reduce_45(val, _values, result) result = Node.new(:COMBINATOR, val) result end |
#_reduce_46(val, _values, result) ⇒ Object
569 570 571 572 573 |
# File 'lib/nokogiri/css/generated_parser.rb', line 569 def _reduce_46(val, _values, result) result = Node.new(:COMBINATOR, val) result end |
#_reduce_47(val, _values, result) ⇒ Object
575 576 577 578 579 |
# File 'lib/nokogiri/css/generated_parser.rb', line 575 def _reduce_47(val, _values, result) result = Node.new(:COMBINATOR, val) result end |
#_reduce_48(val, _values, result) ⇒ Object
581 582 583 584 585 |
# File 'lib/nokogiri/css/generated_parser.rb', line 581 def _reduce_48(val, _values, result) result = Node.new(:COMBINATOR, val) result end |
#_reduce_5(val, _values, result) ⇒ Object
304 305 306 307 |
# File 'lib/nokogiri/css/generated_parser.rb', line 304 def _reduce_5(val, _values, result) result = :PRECEDING_SELECTOR result end |
#_reduce_53(val, _values, result) ⇒ Object
reduce 52 omitted
595 596 597 598 |
# File 'lib/nokogiri/css/generated_parser.rb', line 595 def _reduce_53(val, _values, result) result = Node.new(:ID, val) result end |
#_reduce_54(val, _values, result) ⇒ Object
600 601 602 603 |
# File 'lib/nokogiri/css/generated_parser.rb', line 600 def _reduce_54(val, _values, result) result = [val.first, val[1]] result end |
#_reduce_55(val, _values, result) ⇒ Object
605 606 607 608 |
# File 'lib/nokogiri/css/generated_parser.rb', line 605 def _reduce_55(val, _values, result) result = [val.first, val[1]] result end |
#_reduce_57(val, _values, result) ⇒ Object
reduce 56 omitted
612 613 614 615 |
# File 'lib/nokogiri/css/generated_parser.rb', line 612 def _reduce_57(val, _values, result) result = :equal result end |
#_reduce_58(val, _values, result) ⇒ Object
617 618 619 620 |
# File 'lib/nokogiri/css/generated_parser.rb', line 617 def _reduce_58(val, _values, result) result = :prefix_match result end |
#_reduce_59(val, _values, result) ⇒ Object
622 623 624 625 |
# File 'lib/nokogiri/css/generated_parser.rb', line 622 def _reduce_59(val, _values, result) result = :suffix_match result end |
#_reduce_6(val, _values, result) ⇒ Object
309 310 311 312 |
# File 'lib/nokogiri/css/generated_parser.rb', line 309 def _reduce_6(val, _values, result) result = :DESCENDANT_SELECTOR result end |
#_reduce_60(val, _values, result) ⇒ Object
627 628 629 630 |
# File 'lib/nokogiri/css/generated_parser.rb', line 627 def _reduce_60(val, _values, result) result = :substring_match result end |
#_reduce_61(val, _values, result) ⇒ Object
632 633 634 635 |
# File 'lib/nokogiri/css/generated_parser.rb', line 632 def _reduce_61(val, _values, result) result = :not_equal result end |
#_reduce_62(val, _values, result) ⇒ Object
637 638 639 640 |
# File 'lib/nokogiri/css/generated_parser.rb', line 637 def _reduce_62(val, _values, result) result = :includes result end |
#_reduce_63(val, _values, result) ⇒ Object
642 643 644 645 |
# File 'lib/nokogiri/css/generated_parser.rb', line 642 def _reduce_63(val, _values, result) result = :dash_match result end |
#_reduce_64(val, _values, result) ⇒ Object
647 648 649 650 651 |
# File 'lib/nokogiri/css/generated_parser.rb', line 647 def _reduce_64(val, _values, result) result = Node.new(:NOT, [val[1]]) result end |
#_reduce_7(val, _values, result) ⇒ Object
314 315 316 317 |
# File 'lib/nokogiri/css/generated_parser.rb', line 314 def _reduce_7(val, _values, result) result = :DESCENDANT_SELECTOR result end |
#_reduce_8(val, _values, result) ⇒ Object
319 320 321 322 |
# File 'lib/nokogiri/css/generated_parser.rb', line 319 def _reduce_8(val, _values, result) result = :CHILD_SELECTOR result end |
#_reduce_9(val, _values, result) ⇒ Object
324 325 326 327 328 329 330 331 332 |
# File 'lib/nokogiri/css/generated_parser.rb', line 324 def _reduce_9(val, _values, result) result = if val[1].nil? val.first else Node.new(:CONDITIONAL_SELECTOR, [val.first, val[1]]) end result end |
#_reduce_none(val, _values, result) ⇒ Object
reduce 65 omitted
655 656 657 |
# File 'lib/nokogiri/css/generated_parser.rb', line 655 def _reduce_none(val, _values, result) val[0] end |