pub mod protocol; use std::io::Read; 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("{")] LBrace, #[token("}")] RBrace, #[regex("[a-zA-Z]+", |lex|{lex.slice().to_string()})] Text(String), #[regex(r#"@[a-zA-Z]+\(?[a-zA-Z]+\)?"#, |lex|{lex.slice().to_string()})] Decorator(String), } pub fn build_idl(name: String) { let contents = open_protocol(name); let lex = Token::lexer(&contents); for x in lex { println!("{:?}", x.unwrap()); } } fn open_protocol(name: String) -> String { let path = format!("sysdata/idl/{}/src/protocol.aidl", name); let mut file = std::fs::File::open(path).unwrap(); let mut contents = String::new(); file.read_to_string(&mut contents).unwrap(); contents }