3 releases
0.1.2 | Jul 6, 2023 |
---|---|
0.1.1 | May 24, 2023 |
0.1.0 | May 24, 2023 |
#55 in #regular
Used in 2 crates
(via syntastica-query-preproce…)
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
~255–740KB
~17K SLoC