diff --git a/src/parser/ast.rs b/src/parser/ast.rs index 82526ab45..7b3022eab 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -49,13 +49,13 @@ macro_rules! fixnum { macro_rules! is_term { ($x:expr) => { - ($x as u32 & $crate::parser::ast::TERM) != 0 + ($x as u32 & $crate::parser::ast::TERM) != 0 || is_negate!($x) }; } macro_rules! is_lterm { ($x:expr) => { - ($x as u32 & $crate::parser::ast::LTERM) != 0 + ($x as u32 & $crate::parser::ast::LTERM) != 0 || is_negate!($x) }; } diff --git a/src/parser/parser.rs b/src/parser/parser.rs index 3637df24f..47e829219 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -150,6 +150,7 @@ pub fn get_op_desc(name: Atom, op_dir: &CompositeOpDir) -> Option Parser<'a, R> { // expect a term or non-comma operator. if let TokenType::Comma = desc.tt { return None; - } else if is_term!(desc.spec) || is_op!(desc.spec) { + } else if is_term!(desc.spec) || is_op!(desc.spec) || is_negate!(desc.spec) { arity += 1; } else { return None; @@ -911,9 +912,6 @@ impl<'a, R: CharRead> Parser<'a, R> { // can't be prefix, so either inf == 0 // or post == 0. self.reduce_op(inf + post); - - // let fixity = if inf > 0 { Fixity::In } else { Fixity::Post }; - self.promote_atom_op(name, inf + post, spec & (XFX | XFY | YFX | YF | XF)); } _ => { @@ -927,12 +925,12 @@ impl<'a, R: CharRead> Parser<'a, R> { inf + post, spec & (XFX | XFY | YFX | XF | YF), ); - } else { - self.promote_atom_op(name, pre, spec & (FX | FY | NEGATIVE_SIGN)); + + return Ok(true); } - } else { - self.promote_atom_op(name, pre, spec & (FX | FY | NEGATIVE_SIGN)); } + + self.promote_atom_op(name, pre, spec & (FX | FY | NEGATIVE_SIGN)); } } } else { diff --git a/tests-pl/iso-conformity-tests.pl b/tests-pl/iso-conformity-tests.pl index dc08ce2d5..10b85c10d 100644 --- a/tests-pl/iso-conformity-tests.pl +++ b/tests-pl/iso-conformity-tests.pl @@ -230,13 +230,16 @@ test_62 :- atom(-/*.*/-). -test_63_180_64 :- setup_call_cleanup(( current_op(P,fy,-), - op(0,fy,-) - ), - ( integer(-1), - integer(- 1) - ), - op(P,fy,-)). +test_63_180_64_328 :- setup_call_cleanup(( current_op(P,fy,-), + op(0,fy,-) + ), + ( integer(-1), + integer(- 1), + read_from_chars("writeq_term_to_chars([-]).", Writer), + call(Writer, Cs), + Cs == "[-]" + ), + op(P,fy,-)). test_135 :- writeq_term_to_chars(-(1), Chars), Chars == "- (1)".