Commit e933a63
committed
Reverse the parse direction
Parse the rule from the head to prevent the parser from finding
aliases of the intended argument in the rule's heead.
String#slice! searches from the head of a string, so if the parser is
using it to iteratively search for strings ordered progressively further
from the back of a rule, each iteration is a new opportunity to find an
aliased substring in its head and completely moot the point of
generating an ordered parse list in the first place.
Additionally:
- Untie the logical knots that were required for reverse-parsing
- Don't use Enumerable#each to do absolutely everything by side effect
when an iterator could just return the constructed value directly
- Don't pre-define variables we don't need yet just so they can be
reassigned
- Freshen up pointlessly terse variable names that only exist in an
ephemeral scope anyway, this is already hard enough to follow
- Stop our value regex from capturing a second, nested group if we only
need the outer to avoid any later need to transpose the result
- Fix any remaining variables with misleading names (e.g., valrev is no
longer "values, reversed") or errant comments that no longer
accurately describe the operation of the code1 parent 63107de commit e933a63
1 file changed
+18
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
514 | | - | |
515 | | - | |
516 | 514 | | |
517 | 515 | | |
518 | 516 | | |
| |||
646 | 644 | | |
647 | 645 | | |
648 | 646 | | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
655 | 653 | | |
656 | 654 | | |
657 | 655 | | |
658 | 656 | | |
659 | 657 | | |
660 | | - | |
| 658 | + | |
| 659 | + | |
661 | 660 | | |
662 | | - | |
663 | | - | |
| 661 | + | |
| 662 | + | |
664 | 663 | | |
665 | 664 | | |
666 | 665 | | |
667 | 666 | | |
668 | 667 | | |
669 | 668 | | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
676 | 675 | | |
677 | 676 | | |
| 677 | + | |
| 678 | + | |
678 | 679 | | |
679 | 680 | | |
680 | 681 | | |
| |||
0 commit comments