Crates.io | condex |
lib.rs | condex |
version | 1.0.0 |
source | src |
created_at | 2021-11-01 02:34:24.901858 |
updated_at | 2021-11-01 02:34:24.901858 |
description | Extract tokens by simple condition expression. |
homepage | https://github.com/just-do-halee/condex |
repository | https://github.com/just-do-halee/condex |
max_upload_size | |
id | 474987 |
size | 25,121 |
Condex
Extract tokens by simple condition expression.
| Docs | Latest Note |
[dependencies]
condex = "1.0.0"
#[derive(Debug, Clone, Copy, PartialEq)]
enum Token {
TagName,
NameType,
Value,
AllInOne,
}
impl TokenKind for Token {}
let mut builder = CondexBuilder::new(&[
(Token::TagName, &["@-("]),
(Token::NameType, &["[(,] - : - [,=]"]),
(Token::Value, &["=-[,)]"]),
(Token::AllInOne, &["@-(", "[(,] - : - [,=]", "=-[,)]"]),
]);
let source = "@hello-man(name: type = value, name2: type2, name3: type3 = value3)";
for (i, c) in source.char_indices() {
builder.test(c, i);
}
let finals = builder.finalize_with_source(source);
eprintln!("{:#?}", finals);