mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 12:04:21 +01:00
this PR converts generate code in `turso_parser`'s `build.rs` into macro
for reusability. `match_ignore_ascii_case` will generate trie-like tree
matching from normal match expression.
example:
```rust
match_ignore_ascii_case!(match input {
b"AB" => TokenType::TK_ABORT,
b"AC" => TokenType::TK_ACTION,
_ => TokenType::TK_ID,
})
```
will generate:
```rust
match input.get(0) {
Some(b'A') | Some(b'a') => match input.get(1) {
Some(b'B') | Some(b'b') => match input.get(2) {
None => TokenType::TK_ABORT,
_ => TokenType::TK_ID,
},
Some(b'C') | Some(b'c') => match input.get(2) {
None => TokenType::TK_ACTION,
_ => TokenType::TK_ID,
},
_ => TokenType::TK_ID,
},
_ => TokenType::TK_ID,
}
```
Closes #2865
TODO