parsing of lisp files is working

This commit is contained in:
Chris Cochrun 2024-12-06 11:42:14 -06:00
parent 87a26642fa
commit 9695c8670f
3 changed files with 22 additions and 5 deletions

View file

@ -2,8 +2,8 @@ default:
just --list just --list
build: build:
RUST_LOG=debug cargo build RUST_LOG=debug cargo build
run ui=' ' file='~/dev/lumina-iced/testypres.lisp': run ui=' ' file='~/dev/lumina-iced/test_presentation.lisp':
RUST_LOG=debug cargo run -- {{ui}} {{file}} RUST_LOG=debug cargo run -- -i {{ui}} {{file}}
clean: clean:
RUST_LOG=debug cargo clean RUST_LOG=debug cargo clean
test: test:

View file

@ -1,3 +1,5 @@
use std::{fs::read_to_string, path::PathBuf};
use crisp::types::{Symbol, Value}; use crisp::types::{Symbol, Value};
use tracing::error; use tracing::error;
@ -21,7 +23,20 @@ pub fn parse_lisp(value: Value) -> Vec<Slide> {
} }
} }
Value::Symbol(Symbol(s)) if s == "load" => { Value::Symbol(Symbol(s)) if s == "load" => {
vec![Slide::default()] let Ok(path) = PathBuf::from(String::from(&vec[1]))
.canonicalize()
else {
return vec![Slide::default()];
};
let lisp = read_to_string(path).expect("oops");
let lisp_value = crisp::reader::read(&lisp);
match lisp_value {
Value::List(value) => value
.into_iter()
.flat_map(|v| parse_lisp(v))
.collect(),
_ => panic!("Should not be"),
}
} }
_ => todo!(), _ => todo!(),
}, },
@ -77,6 +92,8 @@ mod test {
assert_eq!(first_lisp_slide, &test_vec[0]); assert_eq!(first_lisp_slide, &test_vec[0]);
assert_eq!(second_lisp_slide, &test_vec[1]); assert_eq!(second_lisp_slide, &test_vec[1]);
assert_eq!(third_lisp_slide, &test_vec[2]); assert_eq!(third_lisp_slide, &test_vec[2]);
assert_eq!(slide_vec, test_vec);
} }
_ => panic!("this should be a lisp"), _ => panic!("this should be a lisp"),
} }

View file

@ -98,9 +98,9 @@ And my life began"))
(song :author "Jordan Feliz" :ccli 97987 (song :author "Jordan Feliz" :ccli 97987
:font "Quicksand" :font-size 80 :font "Quicksand" :font-size 80
:title "The River" :title "The River"
:background (video :source "./coolerbg.mkv" :fit cover) :background (video :source "~/vids/test/camprules2024theo.mp4" :fit cover)
:verse-order (v1 c1 v2 c1) :verse-order (v1 c1 v2 c1)
(v1 "I'm going down to the river") (v1 "I'm going down to the river")
(c1 "Down to the river") (c1 "Down to the river")
(v2 "Down to the river to pray ay ay!")) (v2 "Down to the river to pray ay ay!"))
(load "./10000-reasons.lisp") (load "./test_song.lisp")