@@ -50,6 +50,7 @@ static INTVAL nqpdebflags_i = 0;
50
50
#define EDGE_CHARLIST_NEG 7
51
51
#define EDGE_CODEPOINT_I 9
52
52
#define EDGE_CODEPOINT_I_NEG 10
53
+ #define EDGE_DBA 12
53
54
54
55
/* Objects we use every time we run an NFA; since we always run one NFA
55
56
* at a time, we can re-use these. */
@@ -143,7 +144,7 @@ quicksort(INTVAL *arr, INTVAL elements) {
143
144
144
145
/* Does a run of the NFA. Produces a list of integers indicating the
145
146
* chosen ordering. */
146
- static INTVAL * nqp_nfa_run(PARROT_INTERP, PMC *states, STRING *target, INTVAL offset, INTVAL *total_fates_out) {
147
+ static INTVAL * nqp_nfa_run(PARROT_INTERP, PMC *states, STRING *target, INTVAL offset, INTVAL *total_fates_out, PMC *high_expect ) {
147
148
INTVAL eos = Parrot_str_length(interp, target);
148
149
INTVAL gen = 1;
149
150
PMC *curst = nfa_curst;
@@ -219,6 +220,12 @@ static INTVAL * nqp_nfa_run(PARROT_INTERP, PMC *states, STRING *target, INTVAL o
219
220
else if (act == EDGE_EPSILON && to < num_states && done[to] != gen) {
220
221
VTABLE_push_integer(interp, curst, to);
221
222
}
223
+ else if (act == EDGE_DBA) {
224
+ if (!PMC_IS_NULL(high_expect))
225
+ VTABLE_push_pmc(interp, high_expect,
226
+ VTABLE_get_pmc_keyed_int(interp, edge_info, i + 1));
227
+ VTABLE_push_integer(interp, curst, to);
228
+ }
222
229
else if (offset >= eos) {
223
230
/* Can't match, so drop state. */
224
231
}
@@ -2257,14 +2264,14 @@ Pushes a label onto a list.
2257
2264
2258
2265
=cut
2259
2266
2260
- =item nqp_nfa_run_protoregex(fatepos, states, target, offset)
2267
+ =item nqp_nfa_run_protoregex(fatepos, states, target, offset, high_expect )
2261
2268
2262
2269
Takes a set of states in $2, a target string in $3 and an offset in $4.
2263
2270
Runs the NFA and puts the order to try the fates into $1.
2264
2271
2265
2272
=cut
2266
2273
2267
- =item nqp_nfa_run_alternation(states, target, offset, bstack, cstack)
2274
+ =item nqp_nfa_run_alternation(states, target, offset, bstack, cstack, high_expect )
2268
2275
2269
2276
Takes a set of states in $1, a target string in $2 and an offset in $3.
2270
2277
Updates the bstack in $4 with backtracking points to try the alternation
@@ -2331,7 +2338,7 @@ inline op nqp_push_label(invar PMC, in LABEL) :base_core {
2331
2338
inline op nqp_nfa_run_protoregex(out PMC, invar PMC, in STR, in INT) :base_core {
2332
2339
/* Run the NFA. */
2333
2340
INTVAL total_fates, i;
2334
- INTVAL *fates = nqp_nfa_run(interp, $2, $3, $4, &total_fates);
2341
+ INTVAL *fates = nqp_nfa_run(interp, $2, $3, $4, &total_fates, PMCNULL );
2335
2342
2336
2343
/* Copy results into an RIA. */
2337
2344
PMC *fatepmc = Parrot_pmc_new(interp, enum_class_ResizableIntegerArray);
@@ -2352,7 +2359,7 @@ inline op nqp_nfa_run_alternation(invar PMC, in STR, in INT, invar PMC, invar PM
2352
2359
2353
2360
/* Run the NFA. */
2354
2361
INTVAL total_fates, i;
2355
- INTVAL *fates = nqp_nfa_run(interp, states, target, offset, &total_fates);
2362
+ INTVAL *fates = nqp_nfa_run(interp, states, target, offset, &total_fates, PMCNULL );
2356
2363
2357
2364
/* Push the results onto the bstack. */
2358
2365
INTVAL caps = VTABLE_defined(interp, cstack) ? VTABLE_elements(interp, cstack) : 0;
@@ -2366,6 +2373,44 @@ inline op nqp_nfa_run_alternation(invar PMC, in STR, in INT, invar PMC, invar PM
2366
2373
free(fates);
2367
2374
}
2368
2375
2376
+ inline op nqp_nfa_run_protoregex(out PMC, invar PMC, in STR, in INT, invar PMC) :base_core {
2377
+ /* Run the NFA. */
2378
+ INTVAL total_fates, i;
2379
+ INTVAL *fates = nqp_nfa_run(interp, $2, $3, $4, &total_fates, $5);
2380
+
2381
+ /* Copy results into an RIA. */
2382
+ PMC *fatepmc = Parrot_pmc_new(interp, enum_class_ResizableIntegerArray);
2383
+ for (i = 0; i < total_fates; i++)
2384
+ VTABLE_set_integer_keyed_int(interp, fatepmc, i, fates[i]);
2385
+ free(fates);
2386
+
2387
+ $1 = fatepmc;
2388
+ }
2389
+
2390
+ inline op nqp_nfa_run_alternation(invar PMC, in STR, in INT, invar PMC, invar PMC, invar PMC, invar PMC) :base_core {
2391
+ PMC *states = $1;
2392
+ STRING *target = $2;
2393
+ INTVAL offset = $3;
2394
+ PMC *bstack = $4;
2395
+ PMC *cstack = $5;
2396
+ PMC *labels = $6;
2397
+ PMC *highex = $7;
2398
+
2399
+ /* Run the NFA. */
2400
+ INTVAL total_fates, i;
2401
+ INTVAL *fates = nqp_nfa_run(interp, states, target, offset, &total_fates, highex);
2402
+
2403
+ /* Push the results onto the bstack. */
2404
+ INTVAL caps = VTABLE_defined(interp, cstack) ? VTABLE_elements(interp, cstack) : 0;
2405
+ for (i = 0; i < total_fates; i++) {
2406
+ VTABLE_push_integer(interp, bstack,
2407
+ VTABLE_get_integer_keyed_int(interp, labels, fates[i]));
2408
+ VTABLE_push_integer(interp, bstack, offset);
2409
+ VTABLE_push_integer(interp, bstack, 0);
2410
+ VTABLE_push_integer(interp, bstack, caps);
2411
+ }
2412
+ free(fates);
2413
+ }
2369
2414
2370
2415
/*
2371
2416
0 commit comments