4 releases

0.1.3 Mar 1, 2025
0.1.2 Jul 6, 2023
0.1.1 May 24, 2023
0.1.0 May 24, 2023

#2133 in Parser implementations

Download history 17/week @ 2024-12-08 2/week @ 2024-12-15 4/week @ 2025-02-16 76/week @ 2025-02-23 110/week @ 2025-03-02

190 downloads per month
Used in 2 crates (via syntastica-query-preproce…)

GPL-3.0-only

44KB
896 lines

lua-pattern

Parser for Lua patterns and conversion to regular expressions.

This crate provides a basic parser for Lua patterns, and, with the to-regex feature enabled, conversion to standard regular expressions as usable by the regex or fancy-regex crate.


lib.rs:

Usage

  • Lua patterns can be parsed to a tree with parse.
  • Parsed patterns can be converted to regex strings with try_to_regex.

For example:

use lua_pattern::{Class, PatternObject};

let tree = lua_pattern::parse("%l").unwrap();
assert_eq!(tree, [PatternObject::Class(Class::Lowercase)]);
#[cfg(feature = "to-regex")]
assert_eq!(
    lua_pattern::try_to_regex(&tree, false, false).unwrap(),
    "[a-z]"
);

Dependencies

~235–710KB
~16K SLoC