From 2d7f3ffa770b6eb698566b6566d7e37f10193744 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Tue, 29 Jun 2021 16:38:09 +0000 Subject: Parse , and make xfy do what it should --- example.pl | 11 ++++++++++- parser.c | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/example.pl b/example.pl index 8037d1c..dce8533 100644 --- a/example.pl +++ b/example.pl @@ -2,4 +2,13 @@ math(A,B,C,D) :- D is A + B + C * A. -true. \ No newline at end of file +true. + +likes(bob, ice). +likes(sam, text). +likes(sam, ice). + +could_be_friends(Person1, Person2) :- + likes(Person1, Thing1), + likes(Person2, Thing2), + Thing1 = Thing2. \ No newline at end of file diff --git a/parser.c b/parser.c index 4e88013..9e4edf1 100644 --- a/parser.c +++ b/parser.c @@ -158,6 +158,10 @@ term(void) result = mknumber(NumberFloat, 0, lookahead.dval); match(FloatTok); break; + case CommaTok: + result = mkatom(L","); + match(CommaTok); + break; default: print("Cant parse term of token type %d\n", lookahead.tag); syntaxerror("term"); @@ -219,7 +223,7 @@ parseoperators(Term *list) for(i = 0; i < length; i++){ if(infos[i].type == 0) continue; - if(infos[i].level == lowest && infos[i].type == Xfy && i == index+1) + if(infos[i].level == lowest && infos[i].type == Xfy) index = i; else if(infos[i].level < lowest){ index = i; -- cgit v1.2.3