Add option for output format

This commit is contained in:
Patrick Lühne 2020-02-03 22:51:19 +01:00
parent c953b465e9
commit 9f4b7946f5
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
3 changed files with 51 additions and 2 deletions

View File

@ -1,7 +1,7 @@
#![feature(trait_alias)]
pub mod error;
pub(crate) mod output;
pub mod output;
pub mod translate;
pub use error::Error;

View File

@ -10,6 +10,10 @@ enum Command
/// ASP input program (one or multiple files)
#[structopt(parse(from_os_str), required(true))]
input: Vec<std::path::PathBuf>,
/// 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)
{

View File

@ -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<Self, Self::Err>
{
match s
{
"human-readable" => Ok(Format::HumanReadable),
"tptp" => Ok(Format::TPTP),
_ => Err(InvalidFormatError),
}
}
}