Files
luma/Sources/LumaCore/Patterns/PatternLexer.swift
Ole André Vadla Ravnås 465d8f1b92 core: Lex and describe pattern sources for editing
Give the lexer a keyword set and a regex switch, and add a pattern
flavour on top of it. Let the decoder describe text that is not yet a
file.
2026-10-01 20:49:11 +02:00

16 lines
802 B
Swift

import Foundation
public enum PatternLexer {
public static func tokenize(_ text: String) -> [TypeScriptToken] {
TypeScriptLexer.tokenize(text, keywords: keywords, allowsRegex: false)
}
private static let keywords: Set<String> = [
"struct", "union", "enum", "bitfield", "fn", "namespace", "using", "import", "as", "if", "else", "while", "for",
"match", "return", "break", "continue", "try", "catch", "in", "out", "ref", "auto", "const", "let", "padding",
"null", "true", "false", "parent", "this", "sizeof", "addressof", "typenameof", "be", "le", "signed", "unsigned",
"u8", "u16", "u24", "u32", "u48", "u64", "u96", "u128", "s8", "s16", "s24", "s32", "s48", "s64", "s96", "s128",
"float", "double", "bool", "char", "char16", "str",
]
}