fix bug with implementation of wildcard: we don't want to match a wildcard if the character we are getting follow-positions for has an ASCII code of 0, because we are using that as an endmarker

This commit is contained in:
2025-10-06 12:12:23 +01:00
parent ea01f1689c
commit e05c690548

View File

@@ -305,7 +305,12 @@ struct
{sawConcat = false, follows = [], charIsMatch = true}
else
{sawConcat = false, follows = [], charIsMatch = false}
| WILDCARD _ => {sawConcat = false, follows = [], charIsMatch = true}
| WILDCARD _ =>
(* we are treating a char that has ASCII code 0
* as an end marker which will not appear anywhere else.
* So we don't want to match it, but the wildcard can match
* any other character that has a different ASCII code. *)
{sawConcat = false, follows = [], charIsMatch = curChr <> 0}
| ALTERNATION {l, r, leftMaxState, rightMaxState} =>
let val nodeToFollow = if pos <= leftMaxState then l else r
in getFollowsForPositionAndChar (nodeToFollow, pos, curChr)