parse wildcard . character for NFA too

This commit is contained in:
2025-09-30 14:05:39 +01:00
parent 5fa784b4c6
commit b52b5ff28c

View File

@@ -10,6 +10,7 @@ struct
| ZERO_OR_MORE of regex * state
| ONE_OR_MORE of regex * state
| GROUP of regex * state
| WILDCARD of state
fun getState regex =
case regex of
@@ -20,6 +21,7 @@ struct
| ZERO_OR_MORE (_, state) => state
| ONE_OR_MORE (_, state) => state
| GROUP (_, state) => state
| WILDCARD state => state
structure NfaMatch =
struct
@@ -321,9 +323,12 @@ struct
if level < concatLevel then
SOME (pos, lhs)
else
case
climb (pos + 1, str, CHAR_LITERAL (chr, UNTESTED), concatLevel)
of
let
val currentState =
if chr = #"." then WILDCARD UNTESTED
else CHAR_LITERAL (chr, UNTESTED)
in
case climb (pos + 1, str, currentState, concatLevel) of
SOME (pos, rhs) =>
let
val result =
@@ -334,6 +339,7 @@ struct
SOME (pos, result)
end
| NONE => NONE
end
and loop (pos, str, ast) =
if pos = String.size str then