Commit 524c847
authored
Fix parsing parenthesized xpath (#322)
Fixes #316
Also fixes bug parsing `(1+2)*3`
```ruby
REXML::Parsers::XPathParser.new.parse("(a|b)/c")
#=> REXML::ParseException (before)
#=> [:group, [:union, [:child, :qname, "", "a"], [:child, :qname, "", "b"]], :child, :qname, "", "c"] (after)
REXML::Parsers::XPathParser.new.parse("(1+2) * 3")
#=> [:mult, [:plus, [:literal, 1], [:literal, 2]], [:literal, 3]]
REXML::Parsers::XPathParser.new.parse("(1+2)*3")
#=> REXML::ParseException (before)
#=> [:mult, [:plus, [:literal, 1], [:literal, 2]], [:literal, 3]] (after)
```
Source code comment:
```ruby
#| LocationPath
#| FilterExpr ('/' | '//') RelativeLocationPath
```
Actual implementation was:
```ruby
#| LocationPath
#| FilterExpr (RelativeLocationPath if this_part.start_with?('/'))
#| FilterExpr (RelativeLocationPath if this_part.start_with?('/')) LocationPath
#| FilterExpr LocationPath
# Note that RelativeLocationPath never accepts string starting with `/`
```
With this pull request, the implementation will match to its source code
comment.1 parent a98066c commit 524c847
3 files changed
Lines changed: 52 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
591 | | - | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
592 | 602 | | |
593 | | - | |
594 | | - | |
595 | 603 | | |
596 | 604 | | |
597 | | - | |
598 | 605 | | |
599 | 606 | | |
600 | 607 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
132 | 145 | | |
133 | 146 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
619 | 646 | | |
620 | 647 | | |
621 | 648 | | |
| |||
0 commit comments