My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/apps/cassiopeia/src/format/mod.rs

25 lines
656 B

//! cassiopeia file format
mod lexer;
mod parser;
pub(crate) use lexer::{LineLexer, LineToken, Token};
pub(crate) use parser::LineCfg;
use crate::TimeFile;
use std::{fs::File, io::Read};
pub(crate) fn load_file(path: &str) {
let mut f = File::open(path).unwrap();
let mut content = String::new();
f.read_to_string(&mut content).unwrap();
let mut lines: Vec<String> = content.split("\n").map(|l| l.to_owned()).collect();
lines
.iter_mut()
.map(|line| lexer::lex(line))
.map(|lex| parser::parse(lex))
.filter(|line| line.valid())
.fold(TimeFile::default(), |file, line| file.append(line));
}