Default to 0-ary predicates when omitting arity
This commit is contained in:
parent
b6ecf37211
commit
ca5cca8701
@ -15,7 +15,7 @@ enum Command
|
||||
#[structopt(long, default_value = "human-readable")]
|
||||
output_format: anthem::output::Format,
|
||||
|
||||
/// Input predicates (examples: p/0, q/2)
|
||||
/// Input predicates (examples: p, q/2)
|
||||
#[structopt(long, parse(try_from_str = anthem::parse_predicate_declaration))]
|
||||
input_predicates: Vec<std::rc::Rc<foliage::PredicateDeclaration>>,
|
||||
|
||||
|
10
src/utils.rs
10
src/utils.rs
@ -52,11 +52,7 @@ pub fn parse_predicate_declaration(input: &str)
|
||||
{
|
||||
let mut parts = input.split("/");
|
||||
|
||||
let name = match parts.next()
|
||||
{
|
||||
Some(name) => name.to_string(),
|
||||
None => return Err(crate::Error::new_parse_predicate_declaration()),
|
||||
};
|
||||
let name = parts.next().ok_or(crate::Error::new_parse_predicate_declaration())?;
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
@ -64,7 +60,7 @@ pub fn parse_predicate_declaration(input: &str)
|
||||
{
|
||||
Some(arity)
|
||||
=> usize::from_str(arity).map_err(|_| crate::Error::new_parse_predicate_declaration())?,
|
||||
None => return Err(crate::Error::new_parse_predicate_declaration()),
|
||||
None => 0,
|
||||
};
|
||||
|
||||
if parts.next().is_some()
|
||||
@ -74,7 +70,7 @@ pub fn parse_predicate_declaration(input: &str)
|
||||
|
||||
Ok(std::rc::Rc::new(foliage::PredicateDeclaration
|
||||
{
|
||||
name,
|
||||
name: name.to_string(),
|
||||
arity,
|
||||
}))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user