]> Repositorios git - scryer-prolog.git/commitdiff
don't parse bracketed non-operators as functor terms (#2033)
authorMark <[email protected]>
Sat, 23 Sep 2023 20:26:28 +0000 (14:26 -0600)
committerMark <[email protected]>
Sat, 23 Sep 2023 20:26:28 +0000 (14:26 -0600)
src/parser/ast.rs
src/parser/parser.rs
tests-pl/iso-conformity-tests.pl

index a03602df078d1d56e29a73fbabf4ea1dad94d7df..f1f150801a26da028dd688fe7945ddef6935f586 100644 (file)
@@ -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;
 
index 57193239fc06cdb148e5759ff25f3de39c40b3d3..f2de37bc6343fb0dc85dabbecf9197be36615fec 100644 (file)
@@ -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;
 
index 324820ac1a2de9342f55855a1c6f71ba9ad4cf30..2f8adec164ba60f807fe1e45f7ab53a5d480d752 100644 (file)
@@ -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 :-