From f694bda4e034b3d8e81e6989c14764591af4f46b Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 20 Jul 2025 09:35:10 -0300 Subject: src/paca.mjs: Support returning multiple options from `performTransition()` --- src/paca.mjs | 11 ++++++----- 1 file 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() -- cgit v1.2.3