diff --git a/src/analyzer.rs b/src/analyzer.rs index 24710f8..e4cef06 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -88,7 +88,7 @@ impl<'src> Analyzer<'src> { let root = paths.get(root).unwrap(); Ok(Justfile { - first: recipes + default: recipes .values() .filter(|recipe| recipe.name.path == root) .fold(None, |accumulator, next| match accumulator { diff --git a/src/compiler.rs b/src/compiler.rs index e7fb7cc..070748e 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -8,20 +8,19 @@ impl Compiler { loader: &'src Loader, root: &Path, ) -> RunResult<'src, Compilation<'src>> { - let mut srcs: HashMap = HashMap::new(); let mut asts: HashMap = HashMap::new(); let mut paths: HashMap = HashMap::new(); + let mut srcs: HashMap = HashMap::new(); let mut stack: Vec = Vec::new(); stack.push(root.into()); while let Some(current) = stack.pop() { let (relative, src) = loader.load(root, ¤t)?; - paths.insert(current.clone(), relative.into()); - let tokens = Lexer::lex(relative, src)?; let mut ast = Parser::parse(&tokens)?; + paths.insert(current.clone(), relative.into()); srcs.insert(current.clone(), src); for item in &mut ast.items { @@ -31,15 +30,11 @@ impl Compiler { message: "The !include directive is currently unstable.".into(), }); } - let include = current.parent().unwrap().join(relative).lexiclean(); - if srcs.contains_key(&include) { return Err(Error::CircularInclude { current, include }); } - *absolute = Some(include.clone()); - stack.push(include); } } diff --git a/src/justfile.rs b/src/justfile.rs index a4bbcc9..b08d431 100644 --- a/src/justfile.rs +++ b/src/justfile.rs @@ -4,8 +4,8 @@ use {super::*, serde::Serialize}; pub(crate) struct Justfile<'src> { pub(crate) aliases: Table<'src, Alias<'src>>, pub(crate) assignments: Table<'src, Assignment<'src>>, - #[serde(serialize_with = "keyed::serialize_option")] - pub(crate) first: Option>>, + #[serde(rename = "first", serialize_with = "keyed::serialize_option")] + pub(crate) default: Option>>, pub(crate) recipes: Table<'src, Rc>>, pub(crate) settings: Settings<'src>, pub(crate) warnings: Vec, @@ -190,7 +190,7 @@ impl<'src> Justfile<'src> { let argvec: Vec<&str> = if !arguments.is_empty() { arguments.iter().map(String::as_str).collect() - } else if let Some(recipe) = &self.first { + } else if let Some(recipe) = &self.default { let min_arguments = recipe.min_arguments(); if min_arguments > 0 { return Err(Error::DefaultRecipeRequiresArguments {