haku: a very shitty tree-walk interpreter

This commit is contained in:
りき萌 2024-07-24 23:43:05 +02:00
parent d813675d47
commit b505c1bcfe
8 changed files with 403 additions and 26 deletions

View file

@ -42,8 +42,16 @@ function tokenize(text, syntax) {
for (let i = 1; i < match.indices.length; ++i) {
let [start, end] = match.indices[i];
if (match.indices[i] != null) {
pushToken(tokens, pattern.is.default, text.substring(lastMatchEnd, start));
pushToken(tokens, pattern.is.captures[i], text.substring(start, end));
pushToken(
tokens,
pattern.is.default,
text.substring(lastMatchEnd, start),
);
pushToken(
tokens,
pattern.is.captures[i - 1],
text.substring(start, end),
);
}
}
} else {