ziplex

    ZipLex: lexicon-driven lexical engine per paper specification.

    Download zip
    Version
    0.1.1
    License
    Apache-2.0
    Last updated
    1 hour ago
    Downloads
    13

    No dependencies

    #huanguan-Q/ziplex-mbt

    #Provenance & License

    • 出处:ZipLex: arXiv:2510.18479 — 详见 EXTRACTION.md
    • 独立实现声明与判据来源详见同目录 EXTRACTION.md;许可证随仓库根 LICENSE(MIT)。

    Regex

    pub enum Regex {
    REmpty
    REps
    RChar(Char)
    RRange(Char, Char)
    RUnion(Array[Regex])
    RConcat(Regex, Regex)
    RStar(Regex)
    } derive(Eq, Hash,
    Debug
    )

    Regex::equal

    fn Regex::equal(Regex, Regex) -> Bool

    Regex::hash

    fn Regex::hash(self : Regex) -> Int

    Regex::hash_combine

    fn Regex::hash_combine(Regex, Hasher) -> Unit

    Regex::not_equal

    fn Regex::not_equal(x : Regex, y : Regex) -> Bool

    Regex::to_repr

    Rule

    pub struct Rule {
    name : String
    re : Regex
    }

    A lexical rule: name plus the regular language it accepts.

    Rule::new

    fn Rule::new(name : String, re : Regex) -> Rule

    Construct a rule (priority = position in the rule list).

    Token

    pub struct Token {
    rule : String
    lexeme : String
    }

    A lexed token: rule name plus the exact matched substring.

    alt

    fn alt(rs : Array[Regex]) -> Regex

    Union (alternation) of several regexes.

    chars

    fn chars(s : String) -> Regex

    Union of the single characters in s.

    concat

    fn concat(r1 : Regex, r2 : Regex) -> Regex

    Concatenation of two regexes.

    lex

    fn lex(rules : Array[Rule], input : String) -> Result[Array[Token], String]

    Lex input under rules with maximal munch (longest match) semantics; ties at equal length are resolved by earlier rule position. Err when some position cannot start any rule.

    plus

    fn plus(r : Regex) -> Regex

    One or more: r · r*.

    print

    fn print(tokens : Array[Token]) -> String

    Print tokens back to text: exact inverse of lex for covered inputs (ZipLex invertibility, simplified via lexeme retention).

    range

    fn range(lo : Char, hi : Char) -> Regex

    str

    fn str(s : String) -> Regex

    Concatenation of single characters: the exact literal string.