753 self assert: parser parse: 'abc' to: #($a $b $c) end: 3. |
754 self assert: parser parse: 'abc' to: #($a $b $c) end: 3. |
754 self assert: parser parse: 'abcd' to: #( $a $b $c ) end: 3. |
755 self assert: parser parse: 'abcd' to: #( $a $b $c ) end: 3. |
755 self assert: parser fail: 'ab'. |
756 self assert: parser fail: 'ab'. |
756 ! |
757 ! |
757 |
758 |
|
759 testSequenceOptInlined1 |
|
760 | a b bOpt | |
|
761 |
|
762 a := $a asParser asCompilerNode. |
|
763 b := $b asParser asCompilerNode. |
|
764 bOpt := PPCOptionalNode new |
|
765 child: b ; |
|
766 markForInline; |
|
767 yourself. |
|
768 node := PPCSequenceNode new |
|
769 children: { a . bOpt }; |
|
770 yourself. |
|
771 self compileTree: node. |
|
772 |
|
773 self assert: parser parse: 'ab' to: #($a $b ) end: 2. |
|
774 self assert: parser parse: 'a' to: #( $a nil ) end: 1. |
|
775 |
|
776 "Created: / 22-05-2015 / 11:47:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
777 ! |
|
778 |
|
779 testSequenceOptInlined2 |
|
780 | a b bOpt | |
|
781 |
|
782 a := $a asParser asCompilerNode. |
|
783 a markForInline. |
|
784 b := $b asParser asCompilerNode. |
|
785 b markForInline. |
|
786 bOpt := PPCOptionalNode new |
|
787 child: b ; |
|
788 markForInline; |
|
789 yourself. |
|
790 node := PPCSequenceNode new |
|
791 children: { a . bOpt }; |
|
792 yourself. |
|
793 self compileTree: node. |
|
794 |
|
795 self assert: parser parse: 'ab' to: #($a $b ) end: 2. |
|
796 self assert: parser parse: 'a' to: #( $a nil ) end: 1. |
|
797 |
|
798 "Created: / 22-05-2015 / 11:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
799 ! |
|
800 |
758 testStarAnyNode |
801 testStarAnyNode |
759 arguments cacheFirstFollow: false. |
802 arguments cacheFirstFollow: false. |
760 node := PPCStarAnyNode new |
803 node := PPCStarAnyNode new |
761 child: PPCNilNode new; |
804 child: PPCNilNode new; |
762 yourself. |
805 yourself. |