@@ -2,6 +2,7 @@ package codes.quine.labs.resyntax.ir
22
33import codes .quine .labs .resyntax .ast .AssertNameStyle
44import codes .quine .labs .resyntax .ast .BacktrackControlKind
5+ import codes .quine .labs .resyntax .ast .BacktrackStrategy ._
56import codes .quine .labs .resyntax .ast .CommandKind
67import codes .quine .labs .resyntax .ast .ConditionalTest
78import codes .quine .labs .resyntax .ast .Dialect
@@ -12,6 +13,7 @@ import codes.quine.labs.resyntax.ast.NameStyle
1213import codes .quine .labs .resyntax .ast .Node
1314import codes .quine .labs .resyntax .ast .NodeData
1415import codes .quine .labs .resyntax .ir .IRNodeData ._
16+ import codes .quine .labs .resyntax .ir .IRQuantifier ._
1517import codes .quine .labs .resyntax .parser .Parser
1618
1719class IRBuilderSuite extends munit.FunSuite {
@@ -35,6 +37,37 @@ class IRBuilderSuite extends munit.FunSuite {
3537 check(" " , " " , All : _* )(Empty )
3638 check(" (?:)(?:)" , " " , All : _* )(Sequence (Empty , Empty ))
3739
40+ // Repeat
41+ check(" (?:)*" , " " , All : _* )(Repeat (Empty , Unbounded (0 , Greedy )))
42+ check(" (?:)*?" , " " , All : _* )(Repeat (Empty , Unbounded (0 , Lazy )))
43+ check(" (?:)*+" , " " , Java , PCRE , Perl , Ruby )(Repeat (Empty , Unbounded (0 , Possessive )))
44+ check(" (?:)+" , " " , All : _* )(Repeat (Empty , Unbounded (1 , Greedy )))
45+ check(" (?:)+?" , " " , All : _* )(Repeat (Empty , Unbounded (1 , Lazy )))
46+ check(" (?:)++" , " " , Java , PCRE , Perl , Ruby )(Repeat (Empty , Unbounded (1 , Possessive )))
47+ check(" (?:)?" , " " , All : _* )(Repeat (Empty , Bounded (0 , 1 , Greedy )))
48+ check(" (?:)??" , " " , All : _* )(Repeat (Empty , Bounded (0 , 1 , Lazy )))
49+ check(" (?:)?+" , " " , Java , PCRE , Perl , Ruby )(Repeat (Empty , Bounded (0 , 1 , Possessive )))
50+ check(" (?:){4}" , " " , All : _* )(Repeat (Empty , Exact (4 )))
51+ check(" (?:){4}?" , " " , DotNet , Java , JavaScript , PCRE , Perl , Python )(Repeat (Empty , Exact (4 )))
52+ check(" (?:){4}?" , " " , Ruby )(Repeat (Repeat (Empty , Exact (4 )), Bounded (0 , 1 , Greedy )))
53+ check(" (?:){4}+" , " " , Java , PCRE , Perl )(Repeat (Empty , Exact (4 )))
54+ check(" (?:){4}+" , " " , Ruby )(Repeat (Repeat (Empty , Exact (4 )), Unbounded (1 , Greedy )))
55+ check(" (?:){2,3}" , " " , All : _* )(Repeat (Empty , Bounded (2 , 3 , Greedy )))
56+ check(" (?:){2,2}" , " " , All : _* )(Repeat (Empty , Exact (2 )))
57+ check(" (?:){2,3}?" , " " , All : _* )(Repeat (Empty , Bounded (2 , 3 , Lazy )))
58+ check(" (?:){2,2}?" , " " , All : _* )(Repeat (Empty , Exact (2 )))
59+ check(" (?:){2,3}+" , " " , Java , PCRE , Perl , Ruby )(Repeat (Empty , Bounded (2 , 3 , Possessive )))
60+ check(" (?:){2,2}+" , " " , Java , PCRE , Perl , Ruby )(Repeat (Empty , Exact (2 )))
61+ check(" (?:){,1}" , " " , Perl , Python , Ruby )(Repeat (Empty , Bounded (0 , 1 , Greedy )))
62+ check(" (?:){,0}" , " " , Perl , Python , Ruby )(Repeat (Empty , Exact (0 )))
63+ check(" (?:){,1}?" , " " , Perl , Python , Ruby )(Repeat (Empty , Bounded (0 , 1 , Lazy )))
64+ check(" (?:){,0}?" , " " , Perl , Python , Ruby )(Repeat (Empty , Exact (0 )))
65+ check(" (?:){,1}+" , " " , Perl , Ruby )(Repeat (Empty , Bounded (0 , 1 , Possessive )))
66+ check(" (?:){,0}+" , " " , Perl , Ruby )(Repeat (Empty , Exact (0 )))
67+ check(" (?:){2,}" , " " , All : _* )(Repeat (Empty , Unbounded (2 , Greedy )))
68+ check(" (?:){2,}?" , " " , All : _* )(Repeat (Empty , Unbounded (2 , Lazy )))
69+ check(" (?:){2,}+" , " " , Java , PCRE , Perl , Ruby )(Repeat (Empty , Unbounded (2 , Possessive )))
70+
3871 // Command
3972 check(" (?R)" , " " , PCRE , Perl )(Unsupported (NodeData .Command (CommandKind .RCall )))
4073 check(" (?1)" , " " , PCRE , Perl )(Unsupported (NodeData .Command (CommandKind .IndexedCall (1 ))))
0 commit comments