Pixel-Composer/scripts/pseudo_regex/pseudo_regex.gml
2024-05-16 09:26:35 +07:00

28 lines
552 B
Plaintext

function regex_node(val, accept = false) constructor {
self.val = val;
self.accept = accept;
states = {};
static setNext = function(key, node) {
states[$ key] = node;
}
static consume = function(key) {
return struct_has(states, key)? states[$ key] : self;
}
}
function regex_tree(regx) constructor {
regs = string_splice(regx, ";", false, false);
static isMatch = function(str) {
for (var i = 0, n = array_length(regs); i < n; i++) {
var rgx = regs[i];
if(RegexMatch(str, rgx))
return true;
}
return false;
}
}