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 67 omitted.
Instance Method Details
#_reduce_1(val, _values, result) ⇒ Object
reduce 0 omitted
287 288 289 290 291 |
# File 'lib/nokogiri/css/generated_parser.rb', line 287 def _reduce_1(val, _values, result) result = [val.first, val.last].flatten result end |
#_reduce_10(val, _values, result) ⇒ Object
338 339 340 341 342 343 344 345 346 347 |
# File 'lib/nokogiri/css/generated_parser.rb', line 338 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
349 350 351 352 353 |
# File 'lib/nokogiri/css/generated_parser.rb', line 349 def _reduce_11(val, _values, result) result = Node.new(:CONDITIONAL_SELECTOR, val) result end |
#_reduce_13(val, _values, result) ⇒ Object
reduce 12 omitted
357 358 359 360 361 |
# File 'lib/nokogiri/css/generated_parser.rb', line 357 def _reduce_13(val, _values, result) result = Node.new(:CONDITIONAL_SELECTOR, val) result end |
#_reduce_14(val, _values, result) ⇒ Object
363 364 365 366 367 368 369 370 371 372 |
# File 'lib/nokogiri/css/generated_parser.rb', line 363 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
374 375 376 377 378 379 380 |
# File 'lib/nokogiri/css/generated_parser.rb', line 374 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
382 383 384 385 386 |
# File 'lib/nokogiri/css/generated_parser.rb', line 382 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
390 391 392 393 |
# File 'lib/nokogiri/css/generated_parser.rb', line 390 def _reduce_18(val, _values, result) result = Node.new(:CLASS_CONDITION, [val[1]]) result end |
#_reduce_19(val, _values, result) ⇒ Object
395 396 397 398 399 400 401 |
# File 'lib/nokogiri/css/generated_parser.rb', line 395 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
293 294 295 296 |
# File 'lib/nokogiri/css/generated_parser.rb', line 293 def _reduce_2(val, _values, result) result = val.flatten result end |
#_reduce_20(val, _values, result) ⇒ Object
403 404 405 406 407 408 |
# File 'lib/nokogiri/css/generated_parser.rb', line 403 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
410 411 412 413 |
# File 'lib/nokogiri/css/generated_parser.rb', line 410 def _reduce_21(val, _values, result) result = Node.new(:ELEMENT_NAME, val) result end |
#_reduce_22(val, _values, result) ⇒ Object
415 416 417 418 |
# File 'lib/nokogiri/css/generated_parser.rb', line 415 def _reduce_22(val, _values, result) result = val[0] result end |
#_reduce_24(val, _values, result) ⇒ Object
reduce 23 omitted
422 423 424 425 426 427 428 |
# File 'lib/nokogiri/css/generated_parser.rb', line 422 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
430 431 432 433 434 435 436 |
# File 'lib/nokogiri/css/generated_parser.rb', line 430 def _reduce_25(val, _values, result) result = Node.new(:ATTRIBUTE_CONDITION, [val[1]] + (val[2] || []) ) result end |
#_reduce_26(val, _values, result) ⇒ Object
438 439 440 441 442 443 444 445 |
# File 'lib/nokogiri/css/generated_parser.rb', line 438 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
447 448 449 450 451 |
# File 'lib/nokogiri/css/generated_parser.rb', line 447 def _reduce_27(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip]) result end |
#_reduce_28(val, _values, result) ⇒ Object
453 454 455 456 457 |
# File 'lib/nokogiri/css/generated_parser.rb', line 453 def _reduce_28(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten) result end |
#_reduce_29(val, _values, result) ⇒ Object
459 460 461 462 463 |
# File 'lib/nokogiri/css/generated_parser.rb', line 459 def _reduce_29(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten) result end |
#_reduce_3(val, _values, result) ⇒ Object
298 299 300 301 |
# File 'lib/nokogiri/css/generated_parser.rb', line 298 def _reduce_3(val, _values, result) result = :DIRECT_ADJACENT_SELECTOR result end |
#_reduce_30(val, _values, result) ⇒ Object
465 466 467 468 469 |
# File 'lib/nokogiri/css/generated_parser.rb', line 465 def _reduce_30(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten) result end |
#_reduce_31(val, _values, result) ⇒ Object
471 472 473 474 475 |
# File 'lib/nokogiri/css/generated_parser.rb', line 471 def _reduce_31(val, _values, result) result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten) result end |
#_reduce_32(val, _values, result) ⇒ Object
477 478 479 480 |
# File 'lib/nokogiri/css/generated_parser.rb', line 477 def _reduce_32(val, _values, result) result = [val.first, val.last] result end |
#_reduce_33(val, _values, result) ⇒ Object
482 483 484 485 |
# File 'lib/nokogiri/css/generated_parser.rb', line 482 def _reduce_33(val, _values, result) result = [val.first, val.last] result end |
#_reduce_34(val, _values, result) ⇒ Object
487 488 489 490 |
# File 'lib/nokogiri/css/generated_parser.rb', line 487 def _reduce_34(val, _values, result) result = [val.first, val.last] result end |
#_reduce_37(val, _values, result) ⇒ Object
reduce 36 omitted
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'lib/nokogiri/css/generated_parser.rb', line 496 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
514 515 516 517 518 519 520 521 522 |
# File 'lib/nokogiri/css/generated_parser.rb', line 514 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
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 |
# File 'lib/nokogiri/css/generated_parser.rb', line 524 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
303 304 305 306 |
# File 'lib/nokogiri/css/generated_parser.rb', line 303 def _reduce_4(val, _values, result) result = :CHILD_SELECTOR result end |
#_reduce_40(val, _values, result) ⇒ Object
540 541 542 543 544 545 546 547 548 549 550 |
# File 'lib/nokogiri/css/generated_parser.rb', line 540 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
552 553 554 555 556 |
# File 'lib/nokogiri/css/generated_parser.rb', line 552 def _reduce_41(val, _values, result) result = Node.new(:PSEUDO_CLASS, [val[1]]) result end |
#_reduce_42(val, _values, result) ⇒ Object
558 559 560 561 |
# File 'lib/nokogiri/css/generated_parser.rb', line 558 def _reduce_42(val, _values, result) result = Node.new(:PSEUDO_CLASS, [val[1]]) result end |
#_reduce_45(val, _values, result) ⇒ Object
reduce 44 omitted
567 568 569 570 571 |
# File 'lib/nokogiri/css/generated_parser.rb', line 567 def _reduce_45(val, _values, result) result = Node.new(:COMBINATOR, val) result end |
#_reduce_46(val, _values, result) ⇒ Object
573 574 575 576 577 |
# File 'lib/nokogiri/css/generated_parser.rb', line 573 def _reduce_46(val, _values, result) result = Node.new(:COMBINATOR, val) result end |
#_reduce_47(val, _values, result) ⇒ Object
579 580 581 582 583 |
# File 'lib/nokogiri/css/generated_parser.rb', line 579 def _reduce_47(val, _values, result) result = Node.new(:COMBINATOR, val) result end |
#_reduce_48(val, _values, result) ⇒ Object
585 586 587 588 589 |
# File 'lib/nokogiri/css/generated_parser.rb', line 585 def _reduce_48(val, _values, result) result = Node.new(:COMBINATOR, val) result end |
#_reduce_5(val, _values, result) ⇒ Object
308 309 310 311 |
# File 'lib/nokogiri/css/generated_parser.rb', line 308 def _reduce_5(val, _values, result) result = :PRECEDING_SELECTOR result end |
#_reduce_53(val, _values, result) ⇒ Object
reduce 52 omitted
599 600 601 602 |
# File 'lib/nokogiri/css/generated_parser.rb', line 599 def _reduce_53(val, _values, result) result = Node.new(:ID, val) result end |
#_reduce_54(val, _values, result) ⇒ Object
604 605 606 607 |
# File 'lib/nokogiri/css/generated_parser.rb', line 604 def _reduce_54(val, _values, result) result = [val.first, val[1]] result end |
#_reduce_55(val, _values, result) ⇒ Object
609 610 611 612 |
# File 'lib/nokogiri/css/generated_parser.rb', line 609 def _reduce_55(val, _values, result) result = [val.first, val[1]] result end |
#_reduce_57(val, _values, result) ⇒ Object
reduce 56 omitted
616 617 618 619 |
# File 'lib/nokogiri/css/generated_parser.rb', line 616 def _reduce_57(val, _values, result) result = :equal result end |
#_reduce_58(val, _values, result) ⇒ Object
621 622 623 624 |
# File 'lib/nokogiri/css/generated_parser.rb', line 621 def _reduce_58(val, _values, result) result = :prefix_match result end |
#_reduce_59(val, _values, result) ⇒ Object
626 627 628 629 |
# File 'lib/nokogiri/css/generated_parser.rb', line 626 def _reduce_59(val, _values, result) result = :suffix_match result end |
#_reduce_6(val, _values, result) ⇒ Object
313 314 315 316 |
# File 'lib/nokogiri/css/generated_parser.rb', line 313 def _reduce_6(val, _values, result) result = :DESCENDANT_SELECTOR result end |
#_reduce_60(val, _values, result) ⇒ Object
631 632 633 634 |
# File 'lib/nokogiri/css/generated_parser.rb', line 631 def _reduce_60(val, _values, result) result = :substring_match result end |
#_reduce_61(val, _values, result) ⇒ Object
636 637 638 639 |
# File 'lib/nokogiri/css/generated_parser.rb', line 636 def _reduce_61(val, _values, result) result = :not_equal result end |
#_reduce_62(val, _values, result) ⇒ Object
641 642 643 644 |
# File 'lib/nokogiri/css/generated_parser.rb', line 641 def _reduce_62(val, _values, result) result = :includes result end |
#_reduce_63(val, _values, result) ⇒ Object
646 647 648 649 |
# File 'lib/nokogiri/css/generated_parser.rb', line 646 def _reduce_63(val, _values, result) result = :dash_match result end |
#_reduce_64(val, _values, result) ⇒ Object
651 652 653 654 655 |
# File 'lib/nokogiri/css/generated_parser.rb', line 651 def _reduce_64(val, _values, result) result = Node.new(:NOT, [val[1]]) result end |
#_reduce_7(val, _values, result) ⇒ Object
318 319 320 321 |
# File 'lib/nokogiri/css/generated_parser.rb', line 318 def _reduce_7(val, _values, result) result = :DESCENDANT_SELECTOR result end |
#_reduce_8(val, _values, result) ⇒ Object
323 324 325 326 |
# File 'lib/nokogiri/css/generated_parser.rb', line 323 def _reduce_8(val, _values, result) result = :CHILD_SELECTOR result end |
#_reduce_9(val, _values, result) ⇒ Object
328 329 330 331 332 333 334 335 336 |
# File 'lib/nokogiri/css/generated_parser.rb', line 328 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 67 omitted
663 664 665 |
# File 'lib/nokogiri/css/generated_parser.rb', line 663 def _reduce_none(val, _values, result) val[0] end |