diff options
| author | EuAndreh <eu@euandre.org> | 2025-07-20 09:35:10 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2025-07-20 09:35:10 -0300 |
| commit | f694bda4e034b3d8e81e6989c14764591af4f46b (patch) | |
| tree | e40364e8e4aa68e64a3508ebbd4177bad6c60f0d | |
| parent | Add initial support for caret and dollar metacharacters (diff) | |
| download | paca-f694bda4e034b3d8e81e6989c14764591af4f46b.tar.gz paca-f694bda4e034b3d8e81e6989c14764591af4f46b.tar.xz | |
src/paca.mjs: Support returning multiple options from `performTransition()`
| -rw-r--r-- | src/paca.mjs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/paca.mjs b/src/paca.mjs index 21a28e8..f1e3e50 100644 --- a/src/paca.mjs +++ b/src/paca.mjs @@ -795,7 +795,7 @@ const allDirects = (stateID, nodes) => ).flat(), )].toSorted(); -const interpretMetacharacter = ({ op, to, matches, ranges }, char) => { +const interpretMetacharacter = ({ op, to, matches, ranges }, char, index, nodes) => { if (!op) { return null; } @@ -815,14 +815,15 @@ const interpretMetacharacter = ({ op, to, matches, ranges }, char) => { return op === "excludes" && to; }; -const performTransition = (nodes, char) => id => +const performTransition = (nodes, char, index) => id => nodes[id].transitions[char] || - interpretMetacharacter(nodes[id].meta || {}, char); + interpretMetacharacter(nodes[id].meta || {}, char, index, nodes); -const searchNFAStep = nodes => (directStates, char) => +const searchNFAStep = nodes => (directStates, char, index) => [...new Set( directStates - .map(performTransition(nodes, char)) + .map(performTransition(nodes, char, index)) + .flat() .filter(x => !!x) .map(id => allDirects(id, nodes)) .flat() |
