forked from AbleOS/ableos
21 lines
420 B
Rust
21 lines
420 B
Rust
|
use logos::Logos;
|
||
|
|
||
|
#[derive(Logos, Debug, PartialEq)]
|
||
|
#[logos(skip r"[ \t\n\f]+")] // Ignore this regex pattern between tokens
|
||
|
enum Token {
|
||
|
// Tokens can be literal strings, of any length.
|
||
|
#[token("protocol")]
|
||
|
Protocol,
|
||
|
|
||
|
#[token(".")]
|
||
|
Period,
|
||
|
|
||
|
// Or regular expressions.
|
||
|
#[regex("[a-zA-Z]+")]
|
||
|
Text,
|
||
|
}
|
||
|
|
||
|
pub fn main() {
|
||
|
let mut lex = Token::lexer("Create ridiculously fast Lexers.");
|
||
|
}
|