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.
22 lines
662 B
22 lines
662 B
5 years ago
|
use crate::parse::parse_instr::parse_instructions;
|
||
|
use crate::instr::Routine;
|
||
|
use crate::data::literal::RoutineName;
|
||
|
use sexp::Sexp;
|
||
|
use crate::error::Error;
|
||
|
use crate::parse::sexp_expect::{expect_list, expect_string_atom};
|
||
|
use crate::patches::TryRemove;
|
||
|
|
||
|
pub fn parse_routines(routines: Vec<Sexp>) -> Result<Vec<Routine>, Error> {
|
||
|
let mut parsed = vec![];
|
||
|
for rt in routines {
|
||
|
let mut def = expect_list(Some(rt), false)?;
|
||
|
let name = expect_string_atom(def.try_remove(0))?;
|
||
|
let body = parse_instructions(def)?;
|
||
|
parsed.push(Routine {
|
||
|
name: RoutineName(name),
|
||
|
body,
|
||
|
})
|
||
|
}
|
||
|
Ok(parsed)
|
||
|
}
|