don't parse bracketed non-operators as functor terms (#2033)
This commit is contained in:
@@ -34,6 +34,7 @@ pub const FY: u32 = 0x0080;
|
||||
pub const DELIMITER: u32 = 0x0100;
|
||||
pub const TERM: u32 = 0x1000;
|
||||
pub const LTERM: u32 = 0x3000;
|
||||
pub const BTERM: u32 = 0x11000;
|
||||
|
||||
pub const NEGATIVE_SIGN: u32 = 0x0200;
|
||||
|
||||
|
||||
@@ -612,6 +612,10 @@ impl<'a, R: CharRead> Parser<'a, R> {
|
||||
ref mut unfold_bounds,
|
||||
}) = self.stack.last_mut()
|
||||
{
|
||||
if *spec == BTERM {
|
||||
return false;
|
||||
}
|
||||
|
||||
*tt = TokenType::Term;
|
||||
*priority = 0;
|
||||
*spec = TERM;
|
||||
@@ -878,7 +882,7 @@ impl<'a, R: CharRead> Parser<'a, R> {
|
||||
.push(Term::Literal(Cell::default(), Literal::Atom(atom)));
|
||||
}
|
||||
|
||||
self.stack[idx].spec = TERM;
|
||||
self.stack[idx].spec = if self.stack[idx].priority > 0 { TERM } else { BTERM };
|
||||
self.stack[idx].tt = TokenType::Term;
|
||||
self.stack[idx].priority = 0;
|
||||
|
||||
|
||||
@@ -467,13 +467,14 @@ test_195_205_196_197 :-
|
||||
setup_call_cleanup(op(100,xf,''),
|
||||
( read_from_chars("(0 '') = ''(X).", T0),
|
||||
call(T0),
|
||||
T0 = (_ = ('')(0)),
|
||||
writeq_term_to_chars(T0, C0),
|
||||
C0 == "0 ''=0 ''",
|
||||
read_from_chars("0 ''.", T1),
|
||||
writeq_term_to_chars(T1, C0),
|
||||
C0 == "0 ''",
|
||||
writeq_term_to_chars(T1, C1),
|
||||
C1 == "0 ''",
|
||||
read_from_chars("0''.", T2),
|
||||
writeq_term_to_chars(T2, C1),
|
||||
C1 == "0 ''" ),
|
||||
writeq_term_to_chars(T2, C2),
|
||||
C2 == "0 ''" ),
|
||||
op(0,xf,'')).
|
||||
|
||||
test_118_119_120 :-
|
||||
|
||||
Reference in New Issue
Block a user