rhea/src/main.rs

46 lines
671 B
Rust
Raw Normal View History

2023-08-30 20:15:24 -05:00
// Rhea
use logos::Logos;
#[derive(Logos, Debug, PartialEq)]
#[logos(skip r"[ \t\n\f]+")] // Ignore this regex pattern between tokens
enum Token {
#[token(".")]
Period,
#[token("(")]
LeftParen,
#[token("{")]
LeftBrace,
#[token(")")]
RightParen,
#[token("}")]
RightBrace,
#[token("include")]
Include,
#[token("=")]
Equals,
#[token(";")]
Semicolon,
#[token("\"")]
Quote,
// Or regular expressions.
#[regex("[a-zA-Z]+")]
Text,
}
fn main() {
let mut lex = Token::lexer(include_str!("../assets/examples/library.rhea"));
for x in lex {
println!("{:?}", x);
}
}