2023-08-30 20:15:24 -05:00
|
|
|
// Rhea
|
|
|
|
|
|
|
|
use logos::Logos;
|
2023-08-31 17:50:25 -05:00
|
|
|
use memory::{Variable, VariableHashmap, VariableType};
|
|
|
|
|
|
|
|
mod memory;
|
2023-08-30 20:15:24 -05:00
|
|
|
|
|
|
|
#[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() {
|
2023-08-31 17:50:25 -05:00
|
|
|
let mut memmap = Vec::new();
|
|
|
|
let mut varmap: VariableHashmap = hashbrown::HashMap::new();
|
|
|
|
|
|
|
|
let variable_name = "abcd".to_string();
|
|
|
|
let variable_type = Some(memory::VariableType::Signed);
|
|
|
|
let constant = false;
|
|
|
|
let length = 8;
|
|
|
|
let abc = Variable::new(&mut memmap, variable_type, constant, length);
|
|
|
|
|
|
|
|
varmap.insert(variable_name, abc);
|
|
|
|
|
2023-08-30 20:15:24 -05:00
|
|
|
let mut lex = Token::lexer(include_str!("../assets/examples/library.rhea"));
|
|
|
|
for x in lex {
|
|
|
|
println!("{:?}", x);
|
|
|
|
}
|
2023-08-31 17:50:25 -05:00
|
|
|
|
|
|
|
//todo compile to hb
|
2023-08-30 20:15:24 -05:00
|
|
|
}
|