diff --git a/src/lib.rs b/src/lib.rs index 6c457ec..c772c5c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![feature(trait_alias)] pub mod error; -pub(crate) mod output; +pub mod output; pub mod translate; pub use error::Error; diff --git a/src/main.rs b/src/main.rs index 8bcb4d4..470c6ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,10 @@ enum Command /// ASP input program (one or multiple files) #[structopt(parse(from_os_str), required(true))] input: Vec, + + /// Output format (human-readable, tptp) + #[structopt(long, default_value = "human-readable")] + output_format: anthem::output::Format, } } @@ -21,7 +25,12 @@ fn main() match command { - Command::VerifyProgram{input} => + Command::VerifyProgram + { + input, + output_format, + } + => { if let Err(error) = anthem::translate::verify_properties::translate(&input) { diff --git a/src/output.rs b/src/output.rs index 09538d1..640d2fd 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1 +1,41 @@ pub(crate) mod tptp; + +#[derive(Debug)] +pub enum Format +{ + HumanReadable, + TPTP, +} + +pub struct InvalidFormatError; + +impl std::fmt::Debug for InvalidFormatError +{ + fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result + { + write!(formatter, "invalid output format") + } +} + +impl std::fmt::Display for InvalidFormatError +{ + fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result + { + write!(formatter, "{:?}", self) + } +} + +impl std::str::FromStr for Format +{ + type Err = InvalidFormatError; + + fn from_str(s: &str) -> Result + { + match s + { + "human-readable" => Ok(Format::HumanReadable), + "tptp" => Ok(Format::TPTP), + _ => Err(InvalidFormatError), + } + } +}