From 83ab8c67beecfc05684c9400e29f7d77225d3af9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 7 Jun 2026 16:37:28 -0700 Subject: Cleaned up a lot of parsing code. --- src/lib.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 7d0e7f2..5e912cf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,8 +2,6 @@ use std::path::{PathBuf,Path}; use std::collections::HashMap; use core::error::Error; use std::time::SystemTime; -use std::fs::File; -use std::io::Read; mod lexer; mod parser; @@ -57,6 +55,14 @@ enum Token { Fragment(String,Properties,Vec), Section(String,Properties,Vec), Text(String), + Literal(String), + /* + Tag{ + name: String, + params: Vec, + props: Properties, + children: Vec + },*/ } struct State { @@ -97,14 +103,14 @@ impl Crimtag { }; let mut p = parser::Parser::new(); - p.parse( self, &String::from_utf8( std::fs::read( path )? )? ); + p.parse( &String::from_utf8( std::fs::read( path )? )? ); Ok(()) } pub fn load_static(&mut self, data: &str) -> Result<(),Box::> { let mut p = parser::Parser::new(); - p.parse( self, &data ); + p.parse( &data ); Ok(()) } @@ -137,8 +143,12 @@ mod tests { #[test] fn parsing() { let mut ct = Crimtag::new(); - ct.load_static(r#"Here is a sample -[|frament "index" theme="standard"|>Hi<|fragment|] -That was fun!"#); + if let Err(e) = ct.load_static(r#"Here is a sample +[|fragment "index" theme="standard"|>Hi<|fragment|] +That was fun!"#) { + println!("Error: {:?}", e ); + } else { + println!("It finished"); + } } } -- cgit v1.2.3