3 releases

0.1.2 Jul 6, 2023
0.1.1 May 24, 2023
0.1.0 May 24, 2023

#1870 in Parser implementations

40 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

~300–790KB
~18K SLoC