/home/travis/build/MoarVM/MoarVM/src/6model/reprs/NFA.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* NFA constants that are part of the NFA REPR API. */ |
2 | 3.12M | #define MVM_NFA_EDGE_FATE 0 |
3 | 12.9M | #define MVM_NFA_EDGE_EPSILON 1 |
4 | 2.61M | #define MVM_NFA_EDGE_CODEPOINT 2 |
5 | 6 | #define MVM_NFA_EDGE_CODEPOINT_NEG 3 |
6 | 1.09M | #define MVM_NFA_EDGE_CHARCLASS 4 |
7 | 110k | #define MVM_NFA_EDGE_CHARCLASS_NEG 5 |
8 | 2.17M | #define MVM_NFA_EDGE_CHARLIST 6 |
9 | 21.1k | #define MVM_NFA_EDGE_CHARLIST_NEG 7 |
10 | 0 | #define MVM_NFA_EDGE_SUBRULE 8 |
11 | 0 | #define MVM_NFA_EDGE_CODEPOINT_I 9 |
12 | 0 | #define MVM_NFA_EDGE_CODEPOINT_I_NEG 10 |
13 | | #define MVM_NFA_EDGE_GENERIC_VAR 11 |
14 | 12.3k | #define MVM_NFA_EDGE_CHARRANGE 12 |
15 | 0 | #define MVM_NFA_EDGE_CHARRANGE_NEG 13 |
16 | 1.57M | #define MVM_NFA_EDGE_CODEPOINT_LL 14 |
17 | 0 | #define MVM_NFA_EDGE_CODEPOINT_I_LL 15 |
18 | 6 | #define MVM_NFA_EDGE_CODEPOINT_M 16 |
19 | 6 | #define MVM_NFA_EDGE_CODEPOINT_M_NEG 17 |
20 | | #define MVM_NFA_EDGE_CODEPOINT_M_LL 18 |
21 | 0 | #define MVM_NFA_EDGE_CODEPOINT_IM 19 |
22 | 0 | #define MVM_NFA_EDGE_CODEPOINT_IM_NEG 20 |
23 | | #define MVM_NFA_EDGE_CODEPOINT_IM_LL 21 |
24 | 0 | #define MVM_NFA_EDGE_CHARRANGE_M 22 |
25 | 0 | #define MVM_NFA_EDGE_CHARRANGE_M_NEG 23 |
26 | | |
27 | | /* A synthetic edge we use to let us more optimally handle nodes with a fanout |
28 | | * of many codepoints. We sort the edges of type CODEPOINT and CODEPOINT_LL to |
29 | | * the start of the state out edges list, and insert this node before, which |
30 | | * indicates how many CODEPOINT and CODEPOINT_LL edges there are. We can then |
31 | | * binary search them for the current codepoint, and skip over the rest. This |
32 | | * is especially useful in huge categories, such as infix, prefix, etc. */ |
33 | 388k | #define MVM_NFA_EDGE_SYNTH_CP_COUNT 64 |
34 | | |
35 | | /* State entry. */ |
36 | | struct MVMNFAStateInfo { |
37 | | MVMint64 act; |
38 | | MVMint64 to; |
39 | | union { |
40 | | MVMGrapheme32 g; |
41 | | MVMint64 i; |
42 | | MVMString *s; |
43 | | struct { |
44 | | MVMGrapheme32 uc; |
45 | | MVMGrapheme32 lc; |
46 | | } uclc; |
47 | | } arg; |
48 | | }; |
49 | | |
50 | | /* Body of an NFA. */ |
51 | | struct MVMNFABody { |
52 | | MVMObject *fates; |
53 | | MVMint64 num_states; |
54 | | MVMint64 *num_state_edges; |
55 | | MVMNFAStateInfo **states; |
56 | | }; |
57 | | |
58 | | struct MVMNFA { |
59 | | MVMObject common; |
60 | | MVMNFABody body; |
61 | | }; |
62 | | |
63 | | /* Function for REPR setup. */ |
64 | | const MVMREPROps * MVMNFA_initialize(MVMThreadContext *tc); |
65 | | |
66 | | /* Other NFA related functions. */ |
67 | | MVMObject * MVM_nfa_from_statelist(MVMThreadContext *tc, MVMObject *states, MVMObject *nfa_type); |
68 | | MVMObject * MVM_nfa_run_proto(MVMThreadContext *tc, MVMObject *nfa, MVMString *target, MVMint64 offset); |
69 | | void MVM_nfa_run_alt(MVMThreadContext *tc, MVMObject *nfa, MVMString *target, |
70 | | MVMint64 offset, MVMObject *bstack, MVMObject *cstack, MVMObject *labels); |