File tree Expand file tree Collapse file tree
main/kotlin/me/fan87/regbex Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -460,10 +460,20 @@ class Regbex {
460460 if (it is IntInsnNode ) {
461461 return @thenCustomCheck it.operand == number
462462 }
463+ if (it is LdcInsnNode ) {
464+ return @thenCustomCheck it.cst == number
465+ }
463466 return @thenCustomCheck false
464467 }
465468 }
466469
470+ /* *
471+ * Expect a Ldc node with value [any]
472+ */
473+ fun thenLdc (any : Any ) {
474+ thenCustomCheck { it is LdcInsnNode && it == any }
475+ }
476+
467477
468478}
469479
Original file line number Diff line number Diff line change @@ -57,4 +57,42 @@ class GreedyTest {
5757 assertTrue(matcher.next(0 ))
5858 }
5959
60+ @Test
61+ internal fun greedyTestC () {
62+ val instructions = InsnList ().apply {
63+ add(LdcInsnNode (" A" ))
64+ add(LdcInsnNode (" B" ))
65+ add(LdcInsnNode (" C" ))
66+ }
67+
68+ val matcher = RegbexPattern {
69+ thenLdcString()
70+ thenOptional {
71+ thenLdcStringEqual(" B" )
72+ }
73+ thenLdcString()
74+ }.matcher(instructions)
75+
76+ assertTrue(matcher.next(0 ))
77+ }
78+
79+ @Test
80+ internal fun greedyTestD () {
81+ val instructions = InsnList ().apply {
82+ add(LdcInsnNode (" A" ))
83+ add(LdcInsnNode (" B" ))
84+ add(LdcInsnNode (" C" ))
85+ }
86+
87+ val matcher = RegbexPattern {
88+ thenLdcString()
89+ thenOptional {
90+ thenLdcStringEqual(" C" )
91+ }
92+ thenLdcString()
93+ }.matcher(instructions)
94+
95+ assertTrue(matcher.next(0 ))
96+ }
97+
6098}
You can’t perform that action at this time.
0 commit comments