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