Tholp's bespoke website generator
1use std::path::PathBuf; 2 3use crate::projectparse::ProjectContext; 4 5pub struct Token { 6 pub contents: String, 7 pub origin_file: usize, 8 pub line_number: u32, 9} 10 11pub struct InputFile { 12 pub file_input: PathBuf, 13 pub file_skidout: PathBuf, 14 pub file_htmlout: PathBuf, 15 pub tokens: Vec<Token>, 16 pub working_index: usize, 17} 18 19type MacroExpansion = 20 fn(&mut InputFile, usize, &mut ProjectContext, &Vec<String>, &[Token]) -> Vec<Token>; 21pub struct Macro<'a> { 22 pub symbol: &'a str, 23 pub expand: MacroExpansion, 24 pub has_scope: bool, //takes blocks of text input as well as parameters using {{...}} 25} 26 27impl InputFile { 28 pub fn new() -> InputFile { 29 InputFile { 30 file_input: "".into(), 31 file_skidout: "".into(), 32 file_htmlout: "".into(), 33 tokens: Vec::new(), 34 working_index: 0, 35 } 36 } 37} 38 39impl Token { 40 pub fn new(contents: String, origin_file: usize, line_number: u32) -> Token { 41 Token { 42 contents: contents, 43 origin_file: origin_file, 44 line_number: line_number, 45 } 46 } 47} 48 49impl ToString for Token { 50 fn to_string(&self) -> String { 51 return self.contents.clone(); 52 } 53} 54 55impl Clone for Token { 56 fn clone(&self) -> Self { 57 return Token::new( 58 self.contents.clone(), 59 self.origin_file.clone(), 60 self.line_number, 61 ); 62 } 63}