feat(rt_interp): enable file locations for include

This commit is contained in:
2026-04-01 00:36:03 +02:00
parent 48d4039c31
commit 5ffc390d2c
2 changed files with 20 additions and 49 deletions

View File

@@ -1,40 +1,4 @@
(set 'red (include "./materials.lisp")
(material
(color 1 0 0)
(color 1 0 0)
(color 0.5 0 0)
50 0.25))
(set 'blue
(material
(color 0 0 1)
(color 0 0 1)
(color 0 0 0.6)
50 0.25))
(set 'green
(material
(color 0 1 0)
(color 0 1 0)
(color 0 0.6 0)
50 0.25))
(set 'white
(material
(color 1 1 1)
(color 1 1 1)
(color 0.6 0.6 0.6)
100 0.5))
(set 'black
(material
(color 0 0 0)
(color 0 0 0)
(color 0.6 0.6 0.6)
100 0.5))
(set 'dark-mirror
(material
(color 0 0 0)
(color 0 0 0)
(color 0.2 0.2 0.2)
20 0.6))
(set 's1 (set 's1
(sphere (sphere

View File

@@ -17,20 +17,27 @@ fn main() {
mk_prelude(&mut layer); mk_prelude(&mut layer);
mk_raytrace(&mut layer); mk_raytrace(&mut layer);
let environment = Environment::from_layer(layer); let mut environment = Environment::from_layer(layer);
for (i, r) in for (program, path) in programs.iter().zip(program_paths) {
ExpressionStream::from_char_stream(programs.iter().map(|p| p.chars()).flatten()).enumerate() environment.set("FILE".to_string(), path.clone().into());
{
match r { for (i, r) in ExpressionStream::from_char_stream(program.chars()).enumerate() {
Err(err) => { match r {
println!("ParserError in Expression {}: {:?}", i + 1, err); Err(err) => {
break; println!(
"ParserError in File {} Expression {}: {:?}",
path,
i + 1,
err
);
break;
}
Ok(expr) => match eval(&environment, expr) {
Ok(_) => {}
Err(e) => println!("Error evaluating Expression {}: {}", i + 1, e),
},
} }
Ok(expr) => match eval(&environment, expr) {
Ok(_) => {}
Err(e) => println!("Error evaluating Expression {}: {}", i + 1, e),
},
} }
} }