Move code into cli directory

This commit is contained in:
Max Brunsfeld 2019-01-04 16:50:52 -08:00
parent b8dd5d2640
commit 5b0e12ea33
29 changed files with 32 additions and 26 deletions

24
cli/src/error.rs Normal file
View file

@ -0,0 +1,24 @@
#[derive(Debug)]
pub struct Error(pub String);
pub type Result<T> = std::result::Result<T, Error>;
impl Error {
pub fn grammar(message: &str) -> Self {
Error(format!("Grammar error: {}", message))
}
pub fn regex(message: &str) -> Self {
Error(format!("Regex error: {}", message))
}
pub fn undefined_symbol(name: &str) -> Self {
Error(format!("Undefined symbol `{}`", name))
}
}
impl From<serde_json::Error> for Error {
fn from(error: serde_json::Error) -> Self {
Error(error.to_string())
}
}