Re: It seems that I found prolog in prolog
- From: Joachim Schimpf <j.schimpf@xxxxxxxxxxxxxxx>
- Date: Tue, 23 May 2006 14:59:33 GMT
newser.bbs@xxxxxxxxxxxxxxxxx wrote:
Cesar Rabak wrote:Did you read what's written in these pages:> http://www2.info.ucl.ac.be/people/PVR/aquarius.htmlhttp://www.info.ucl.ac.be/people/PVR/user_manual.ps
http://www2.info.ucl.ac.be/people/PVR/Peter.thesis/Peter.thesis.html
Not completely. I'd like to and check the interpreter part of the
source
codes , for the input buffer . Because I want to find the way of
auto-key-in , as I mentioned before.
You are seriously confused if you are worrying about input buffers.
Try to learn to distinguish these 3 things:
1. sequences of characters (in a file, or typed in by a user)
2. Prolog data structures (compound terms, lists, numbers, ...)
3. fragments of Prolog programs (goals, clauses, queries)
You go from (1) to (2) using a Prolog parser. Every Prolog system
comes with a parser, and the read-family of predicates is an
interface to this parser, so you don't need to worry about it.
You go from (2) to (1) using the write-family of predicates.
You go from (2) to (3) by using either the call/1 predicate
(which turns a data structure into a goal), or the likes of
assert (which turns a data structure into a program clause).
To a limited extent, you can go from (3) to (2) using clause/2,
but you will hardly ever need this.
Armed with this background, you may try to understand how a
Prolog toplevel-loop can be implemented:
toplevel :-
write('?- '),
read_term(Query, [variable_names(NameVarPairs)]),
(
call(Query),
write(NameVarPairs),
get_char(Command),
Command \= (;)
->
write(yes)
;
write(no)
),
nl,
toplevel.
-- Joachim
[PS: yes, I know this is normally done with a failure-driven loop]
.
- Follow-Ups:
- Re: It seems that I found prolog in prolog
- From: newser . bbs
- Re: It seems that I found prolog in prolog
- References:
- It seems that I found prolog in prolog
- From: newser . bbs
- Re: It seems that I found prolog in prolog
- From: Cesar Rabak
- Re: It seems that I found prolog in prolog
- From: newser . bbs
- It seems that I found prolog in prolog
- Prev by Date: Re: Prolog + C
- Next by Date: String is not string in SWI prolog , part/2.
- Previous by thread: Re: It seems that I found prolog in prolog
- Next by thread: Re: It seems that I found prolog in prolog
- Index(es):
Relevant Pages
|
|