diff options
Diffstat (limited to 'crates/driver/src/context.rs')
-rw-r--r-- | crates/driver/src/context.rs | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/crates/driver/src/context.rs b/crates/driver/src/context.rs index ccb8581..bd8d985 100644 --- a/crates/driver/src/context.rs +++ b/crates/driver/src/context.rs @@ -8,16 +8,13 @@ use std::{ result, }; -use lazy_static::lazy_static; -use regex::Regex; - use common::{ error::{self, Contextualizable}, string_hash::ArchiveHash, types::TaskID, }; -use crate::{args::*, paths, pin::Pins, task::*}; +use crate::{args::*, parse, paths, pin::Pins, task::*}; #[derive(Debug, Clone, Copy)] pub enum ErrorKind<'ctx> { @@ -347,16 +344,10 @@ impl Context { } pub fn parse<'ctx>(&'ctx self, s: &str) -> error::Result<TaskRef> { - lazy_static! { - static ref RE: Regex = Regex::new( - r"^(?P<recipe>[[:word:]-]+):(?P<task>[[:word:]-]+)(?:/(?P<host>[[:word:]-]+)?(?::(?P<target>[[:word:]-]+))?)?$", - ).unwrap(); - } - - let cap = RE.captures(s).context("Invalid task syntax")?; + let parsed = parse::parse_task(s).context("Invalid task syntax")?; - let recipe = cap["recipe"].to_string(); - let task = cap["task"].to_string(); + let recipe = parsed.recipe.to_string(); + let task = parsed.task.to_string(); let id = TaskID { recipe, task }; let (ctx_id, _) = self @@ -366,19 +357,19 @@ impl Context { let mut args = self.globals.clone(); - if let Some(host) = cap.name("host") { + if let Some(host) = parsed.host { let plat = self .platforms - .get(host.as_str()) - .with_context(|| format!("Platform '{}' not found", host.as_str()))?; + .get(host) + .with_context(|| format!("Platform '{}' not found", host))?; args.set("host", Some(plat)); args.set("target", Some(plat)); } - if let Some(target) = cap.name("target") { + if let Some(target) = parsed.target { let plat = self .platforms - .get(target.as_str()) - .with_context(|| format!("Platform '{}' not found", target.as_str()))?; + .get(target) + .with_context(|| format!("Platform '{}' not found", target))?; args.set("target", Some(plat)); } |