use std::path::{PathBuf,Path}; use std::collections::HashMap; use core::error::Error; mod lexer; pub struct Tx { fragments: HashMap, } enum FragmentSource { File { path: PathBuf, loaded: usize, } } struct Fragment { name: String, source: FragmentSource, sections: HashMap, } struct Section { name: String, ast_root: Token, } type Properties = HashMap; enum Token { Root(Vec), Fragment(String,Properties,Vec), Section(String,Properties,Vec), Text(String), } struct State { } impl Tx { pub fn new() -> Self { Self { fragments: HashMap::new(), } } pub fn load(path: &Path) -> Result<(),Box::> { Ok(()) } pub fn parse(data: String) -> Result<(),Box::> { Ok(()) } } #[cfg(test)] mod tests { use super::*; #[test] fn lexing() { let data = r#"Leading comment: [|fragment "basic"|>Hello there <|fragment|] Trailing text"#; let ll = lexer::Lexer::new( &data ); for sym in ll { if let lexer::Symbol::Error{line,row,what} = sym { println!("Error {}:{}: {}", line, row, what ); break; } else { println!("Symbol: {:?}", sym ); } } } }