From 9799fbd9e8c7fd186365c628bf2024d458dafc75 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Tue, 29 Jun 2021 18:46:18 +0000 Subject: Understand :-initialization(Goal) directive --- parser.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'parser.c') diff --git a/parser.c b/parser.c index df05037..63da254 100644 --- a/parser.c +++ b/parser.c @@ -86,6 +86,7 @@ parse(int fd) print("Could not open file\n"); return nil; } + initgoals = nil; initoperators(); nexttoken(); @@ -105,8 +106,13 @@ prologtext(void) syntaxerror("prologtext"); if(t->tag == CompoundTerm && runestrcmp(t->text, L":-") == 0 && t->arity == 1){ - /* A Directive */ - print("Got directive: %S\n", prettyprint(t)); + Term *body = t->children; + print("Got directive: %S\n", prettyprint(body)); + if(body->tag == CompoundTerm && body->arity == 1 && runestrcmp(body->text, L"initialization") == 0){ + Term *tmp = initgoals; + initgoals = body->children; + initgoals->next = tmp; + } t = prologtext(); }else if(t->tag == CompoundTerm && runestrcmp(t->text, L":-") == 0 && t->arity == 2){ t->next = prologtext(); -- cgit v1.2.3