home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-07-24 | 103.8 KB | 2,687 lines |
-
- TOY Prolog ST V3.3 1 Documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
- TTTTTT OOOO YY YY PPPPP RRRRR OOOO LL OOOO GGGGG
- TT OO OO YY YY PP PP RR RR OO OO LL OO OO GG
- TT OO OO YY YY PP PP RR RR OO OO LL OO OO GG
- TT OO OO YYYY PPPPP RRRRR OO OO LL OO OO GG
- TT OO OO YY PP RR RR OO OO LL OO OO GG GGG
- TT OO OO YY PP RR RR OO OO LL OO OO GG GG
- TT OOOO YY PP RR RR OOOO LLLLLL OOOO GGGGG
-
-
-
-
-
- TOY Prolog ST, Version 3
- ========================
-
- Manual
- ======
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Translated from the German documentation by Martin Willson
-
- for the ST Club, 9 Sutton Place, 49 Stoney Street
-
- Nottingham, NG1 1LX, UK
-
-
- September 1988
-
- TOY Prolog ST 2 Contents
-
-
-
-
- CONTENTS
-
- 1 Copyrights 3
- 2 Syntax and User Interface 3
- 2.1 The Syntax of TOY Prolog 3
- 2.2 The User Interface 7
- 3 System Functions and Predefined Predicates 8
- 3.1 General 8
- 3.2 Description of the system functions and predefined
- predicates 9
- 3.2.1 General predicates 10
- 3.2.2 Arithmetic with integer numbers 10
- 3.2.3 Comparison of numbers or names 11
- 3.2.4 Comparison of terms 12
- 3.2.5 Input and Output 13
- 3.2.5.1 Data streams 13
- 3.2.5.2 Switching input/output streams 14
- 3.2.5.3 Input aids 16
- 3.2.5.4 Input/output of terms; operators 17
- 3.2.5.5 Single characters 19
- 3.2.5.6 Input/output of single characters 20
- 3.2.6 Type testing 21
- 3.2.7 Access to the term structure 22
- 3.2.8 Access to predicates in the data bank 24
- 3.2.9 Control of the course of the program 27
- 3.2.10 Aids for the testing of programs 29
- 3.2.11 Working on grammatical rules 30
- 3.2.12 Miscellaneous functions 30
- 3.3 The GEM Functions 32
- 3.3.1 Control functions 32
- 3.3.2 Graphic output 32
- 3.3.3 Attribute functions 33
- 3.3.4 Functions for mouse control 35
- 3.3.5 Display of an alert message 36
- 3.4 Names of the system functions 36
- 4 The Auxiliary Programs 37
- 4.1 The translator for the User Interface 37
- 4.2 The Editor 38
- 4.3 The Program Structure Analyzer 39
- 5 The Demonstration Programs 40
- 5.1 ALPHA 40
- 5.2 TOYSEQUEL (relational database) 41
- 5.3 Noughts and Crosses 42
-
- APPENDICES
- A1 Construction of the Interpreter 43
- A2 Syntax of the Inner Interpreter 44
- A3 The System File 46
- A4 Implementation of the User Interface 47
- A5 Future Developments 48
-
- TOY Prolog ST 3 Copyrights - Syntax
-
-
-
-
- 1. COPYRIGHTS
- ----------
-
- The program is based on an implementation of Prolog published by
- Feliks Kluzniak and Stanislaw Szpakowicz in their book "Prolog
- for Programmers" (Academic Press, London, 1985).
-
- The rights for the Atari version lie with Jens Kilian, Bensheim.
-
- The program is released for public distribution under the
- condition that none of the notices on the existing copyrights in
- the various files is removed or altered, however it may not be
- sold for profit.
-
- This file is a translation of the German documentation and is
- copyright © Martin Willson 1988 for the translation. It likewise
- may not be sold for profit.
-
- Atari, 520 ST and TOS are trademarks of the Atari Corporation.
-
- GEM is a trademark of Digital Research, Inc.
-
-
- 2. SYNTAX AND USER INTERFACE
- -------------------------
-
- The dialect used is very similar to the dialect Prolog-10 used in
- "Programming in Prolog" (Clocksin & Mellish, Springer-Verlag,
- Berlin & Heidelberg 1981). Some of the differences will be stated
- further on.
-
- 2.1. The Syntax of TOY Prolog
- ------------------------
- The notation used is BNF. The lower case words and the following
- syntax description symbols are non-terminal symbols (i.e. do not
- appear in actual programs).
- ::- means 'is defined as', 'consists of'
- | separates alternatives
- { s } means that the symbol-sequence s can be repeated
- as often as required (or not at all).
- *** indicates a comment.
-
- It is assumed that the normal operator declarations are in force.
-
- clause ::= definition | grammatical_rule | directive
- definition ::= rule | fact
- rule ::= head :- body
- fact ::= head
- *** The principal functor of head is not :- / 2
- head ::= functor_term
- body ::= alternative_body { ; alternative_body }
- alternative_body ::= call { , call }
-
- TOY Prolog ST 4 Syntax
-
-
- call ::= functor_term | variable | ( body )
- functor_term ::= term
- *** Not a variable and not an integer; a formal definition
- *** would be quite costly
- grammatical_rule ::= lefthand_side --> righthand_side
- lefthand_side ::= non_terminal context | non_terminal
- non_terminal ::= functor_term
- context ::= terminal_symbol
- righthand_side ::= alternatives
- alternatives ::= alternative { ; alternative }
- alternative ::= rule_element { , rule_element }
- rule_element ::= non_terminal | terminal_symbol |
- condition | ! | ( alternatives )
- terminal_symbol ::= list | character_string
- *** Only 'closed' lists are allowed
- condition ::= bracket_term
- directive ::= command | query
- command ::= :- body
- query ::= body
- *** The principal functor of body is not :- / 1
-
- term ::= term1200
- termN ::= opfx,N termN-1 | opfy,N termN |
- termN-1 opxf,N | termN opyf,N |
- termN-1 opxfx,N termN-1 |
- termN-1 opxfy,N termN |
- termN opyfx,N termN-1 |
- termN opyfy,N termN | termN-1
- *** 1 ≤ N ≤ 1200; opT,N is an operator of type T and
- *** precedence N; termN can be called 'term of precedence N'
- term0 ::= variable | integer | character_string |
- list | non_operator |
- non_operator ( term { , term } ) |
- ( term ) | bracket_term
- bracket_term ::= { term }
- non_operator ::= functor
- opT,N ::= functor
- *** T ∈ { fx, fy, xf, yf, xfx, xfy, yfx, yfy }, 1 ≤ N ≤ 1200
- *** see also remark 1
- list ::= [] | [ term999 { , term999 } ] |
- [ term999 { , term999 } | term ]
- *** Terms of precedence 999 can be linked by commas without
- *** brackets ( , / 2 has precedence 1000)
- functor ::= word | q_name | symbol | solo_char
- word ::= word_initial { alphanumeric }
- word_initial ::= small_letter
- alphanumeric ::= small_letter | capital_letter | digit | _
- q_name ::= ' { q_character } '
- q_character ::= '' | not_'
- *** not_' is any character other than '
- symbol ::= symbol_char { symbol_char }
- variable ::= variable_initial { alphanum }
- variable_initial ::= capital_letter | _
- integer ::= - digit { digit } | digit { digit }
-
- TOY Prolog ST 5 Syntax
-
-
- character_string ::= " { string_char } "
- *** In TOY a character_string means a list of the names of
- *** the characters, in Prolog-10 a list of their ASCII-codes
- string_char ::= "" | not_"
- *** not_" is any character other than "
- small_letter ::= a | b | c | d | e | f | g | h | i |
- j | k | l | m | n | o | p | q | r |
- s | t | u | v | w | x | y | z | ü |
- é | â | ä | à | å | ç | ê | ë | è |
- ï | î | ì | æ | ô | ö | ò | û | ù |
- ÿ | ß | ƒ | á | í | ó | ú | ñ | ª |
- º | ã | õ | ø | œ | ij
- capital_letter ::= A | B | C | D | E | F | G | H | I |
- J | K | L | M | N | O | P | Q | R |
- S | T | U | V | W | X | Y | Z | Ç |
- Ä | Å | É | Æ | Ö | Ü | Ñ | Ø | Œ |
- À | Ã | Õ | IJ
- digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
- symbol_char ::= # | $ | & | * | + | - | . | / | : |
- < | = | > | ? | @ | \ | ^ | ' | ~ |
- | ¢ | £ | ¥ | ¿ | ⌐ | ¬ | ¡ | « |
- » | § | ∧ | ∞ | ≡ | ± | ≥ | ≤ | ÷ |
- ≈ | ¯
- *** An isolated dot, followed by a space,
- *** is not a symbol_char but a full_stop.
- solo_char ::= , | ; | !
- character_group ::= functor | variable | integer |
- character_string | bracket_or_slash
- *** Character_groups are used in Remark 6, see below.
- bracket_or_slash ::= ( | ) | [ | ] | { | } | |
- comment ::= % { not_end_of_line } end_of_line
- *** end_of_line is a character that indicates the end of a
- *** line, not_end_of_line is any other character.
- *** TOY Prolog converts all end_of_lines into single CRs.
- space ::= { control_char }
- *** control_char is 'SPACE' or 'TAB' or end_of_line or
- *** any unprintable character (ASCII-Code < 32).
- full_stop ::= . control_char
-
- Remarks
- ~~~~~~~
- (1) Mixed operators are not included in the description, but the
- rules for them all have the same form, e.g.
-
- termN ::= op[xfy,fx],N termN-1
-
- (There are 11 additional rules for mixed operators.)
-
- In TOY Prolog a mixed operator can have at the most one
- unary and one binary type, both with the same precedence.
-
- (2) There are many ambiguous combinations of connected
- operators, which are not included in this description.
-
-
- TOY Prolog ST 6 Syntax
-
-
- (3) Not all functors (e.g. names in apostrophes) can be
- declared as operators.
-
- (4) In the description of the body we have been able to omit
- separate consideration of , / 2 and ; / 2, as both are
- normally declared as infix-operators. The rule
-
- body ::= functor_term
-
- has however disguised the structure of a body that occurs as
- a rule.
-
- (5) The syntax for directives (commands and queries) is oriented
- towards the user interface employed in TOY Prolog.
-
- (6) Comments and spaces can be inserted as desired before and
- after character_groups, but not inside a character_group. A
- comment extends only up to the next end_of_line.
-
- (7) Between a minus sign that must be treated as a functor and
- an unsigned integer there must be a space. A minus sign
- directly preceding a numeral sequence will be regarded as
- its sign.
-
- (8) An entered term must be closed with a full_stop (outside an
- apostrophised name, a character_string or a comment).
-
- (9) TOY Prolog uses a simple unification algorithm without
- 'occurrence check'. By this means, for example, the terms X
- and f(X) can be unified. In the process there result
- cyclical data structures, which by careless programming can
- lead the interpreter into an endless loop during output or
- unification. Thus care is needed with such structures.
-
- TOY Prolog ST 7 User Interface
-
-
-
-
- 2.2. The User Interface
- ------------------
- The user interface of TOY Prolog is written in Prolog itself. An
- intermediate code is used, which shows only slight restrictions
- compared with the complete syntax, but can be translated easily
- into the code used by the inner interpreter. For details on this,
- see the appendices.
-
- The inner interpreter calls the predicate ear / 0, as soon as it
- has to read from the 'user' input stream. This predicate calls
- the main loop of the outer interpreter; its name is loop / 0.
- In the loop the user is asked by the prompt
- ?-
- to enter a term, which after that is executed as follows:
-
- (1) Variables or incorrect terms are ignored.
- (2) Numbers generate an error message.
- (3) Terms of the form "head :- body" or "LHS --> RHS" are
- adopted into the data bank as rules (grammatical_rules with
- '-->' will be translated beforehand).
- (4) Terms of the form ":- body" are regarded as commands and
- executed deterministically.
- (5) A list is regarded as a list of filenames. For analysis of
- the list, the predicate 'consultall' will be called.
- (6) All other terms are handled as queries: an attempt is made
- to satisfy the goal described. If it succeeds, the resulting
- variable instantiations will be printed out, and the inter-
- preter will wait for the input of a character. If the
- character is ';', it will be attempted to satisfy the query
- again.
- If the query contains no variables, 'yes' will be
- output on success; if it fails, 'no' is printed out.
-
- When the predicate 'stop' is called, the program is interrupted.
-
- TOY Prolog ST 8 Builtin functions & predicates
-
-
-
-
- 3. SYSTEM FUNCTIONS AND PREDEFINED PREDICATES
- ------------------------------------------
-
- 3.1. General
- -------
- System functions are functions that are implemented in the actual
- (inner) interpreter; predefined predicates are written in Prolog
- and are read after the start of the interpreter from the system
- file 'SYSFILE.TOY' (see Appendix A3).
-
- The basic functions of Prolog-10 are covered by these two groups.
- In the Atari version, many additional system functions are
- implemented, which enable access to the special features of the
- ST (GEM graphics routines and realtime clock).
-
- A system function can produce three different results: it can
- fail, succeed, or produce a system error. If a system function
- succeeds, side-effects usually occur (e.g. output functions).
-
- An error occurring can have the consequence that the attempt to
- satisfy the current goal is entirely broken off; it can even
- (through a memory overflow) go as far as stopping the inter-
- preter. Such a serious error is announced by the message "fatal
- error : ...". After such an error the interpreter starts indepen-
- dently the predicate ear / 0, if it is not reading in a file just
- then. In the event of an error while opening or closing a file,
- input and output are diverted beforehand back to the keyboard or
- screen.
-
- Normally, however, an error is provoked by other circumstances,
- e.g. by an incorrect parameter in the call of a system function.
- In this case, satisfaction of the current goal is not stopped; it
- is continued as if the term provoking the error were a call of
- the predicate error / 1. The argument of error(...) is here the
- incorrect call itself.
- error / 1 is written in Prolog and is in the system file;
- the user can write his/her own error routines. error(...) can
- also be called explicitly. In the existing version error(Call)
- prints out a message of the form "System call error: Call" when
- the principal functor of Call denotes a system function, other-
- wise simply "Error : Call". After printing out, error / 1 fails.
-
- TOY Prolog ST 9 Builtin functions & predicates
-
-
-
-
- 3.2. Description of the system functions & predefined predicates
- -----------------------------------------------------------
- Remark: In the following descriptions, statements will be made
- ~~~~~~ such as "Predicate tries to unify two terms," when the
- predicate fails or succeeds depending on the result of unifica-
- tion. The terms are unified after success.
- "Predicate tests a condition" means that it fails or
- succeeds depending on the result of the condition.
-
- Parameters will be denoted in the following descriptions as:
-
- TERM any term
- INTEGER an integer-number
- VAR a variable
- VARINT an integer-number or a variable
- F_TERM a term with functor and zero or more arguments
- CALL see F_TERM (but in the sense of a goal to be
- satisfied)
- ATOM a functor without arguments
- NAME see ATOM (but the function considered refers to
- the printable name of the functor)
- CHAR a NAME consisting of a single character
- FILENAME the name of a standard input/output stream (see
- the functions see/tell etc.), or a specification
- for a TOS disk file, e.g.
- 'B:\FOLDER.1\PROLOG\DATA.PRO'
- CALL_LIST a (possibly empty) list of CALLs
- CHAR_LIST a (possibly empty) list of CHARs
- NUM_LIST a CHAR_LIST of numeral characters
-
- The parameters of the predicate being described are denoted
- PAR_1, PAR_2, etc.
-
- In TOY Prolog there exist predefined operators, of which some are
- the names of predicates. There is a list in the description of
- op / 3 in section 3.2.5.4.
-
- TOY Prolog ST 10 General predicates
-
-
-
-
- 3.2.1. General predicates
- ------------------
- true
- always succeeds
-
- fail
- always fails
-
- not CALL
- succeeds whenever CALL fails
-
- CALL, CALL
- succeeds whenever both parameters can succeed
-
- CALL; CALL
- succeeds whenever one of the parameters can
- succeed
-
- check( CALL )
- succeeds whenever the parameter can succeed, but
- does not instantiate any variables
-
- side_effects( CALL )
- equivalent to check(CALL); should be used so as to
- emphasize that the side-effects of CALL are
- important
-
- once( CALL )
- tries to satisfy CALL deterministically (just once)
-
-
- 3.2.2. Arithmetic with integer numbers
- -------------------------------
- sum( INTEGER, INTEGER, INTEGER )
- succeeds whenever PAR_1+PAR_2 = PAR_3.
-
- sum( INTEGER, INTEGER, VAR )
- succeeds after unifying PAR_3 with the value of
- PAR_1+PAR_2.
-
- sum( INTEGER, VAR, INTEGER )
- succeeds after unifying PAR_2 with the value of
- PAR_3-PAR_1.
-
- sum( VAR, INTEGER, INTEGER )
- succeeds after unifying PAR_1 with the value of
- PAR_3-PAR_2.
-
- prod( INTEGER, INTEGER, INTEGER, INTEGER )
- succeeds whenever PAR_1*PAR_2+PAR_3 = PAR_4.
-
-
- TOY Prolog ST 11 Integer arithmetic
-
-
- prod( INTEGER, INTEGER, INTEGER, VAR )
- succeeds after unifying PAR_4 with the value of
- PAR_1*PAR_2+PAR_3.
-
- prod( INTEGER, INTEGER, VAR, INTEGER )
- succeeds after unifying PAR_3 with the value of
- PAR_4-PAR_1*PAR_2.
-
- prod( INTEGER, VAR, VAR, INTEGER )
- succeeds after unifying PAR_2 with the value of
- PAR_4 div PAR_1 and PAR_3 with the value of
- PAR_4 mod PAR_1.
-
- prod( VAR, INTEGER, VAR, INTEGER )
- as the previous case, but PAR_1 and PAR_2 inter-
- changed.
-
- prod( INTEGER, VAR, INTEGER, INTEGER )
- fails when (PAR_4-PAR_3) mod PAR_1 is not equal to
- 0; otherwise it succeeds after unifying PAR_2 with
- the value of (PAR_4-PAR_3) div PAR_1.
-
- prod( VAR, INTEGER, INTEGER, INTEGER )
- as the previous case, but PAR_1 and PAR_2 inter-
- changed.
-
-
- TERM is TERM
- It is assumed that PAR_2 is an arithmetic expres-
- sion composed of INTEGERs and the standard opera-
- tors +, - (either binary or unary), *, / and mod;
- if not, the predicate fails (a system error can
- also occur, if PAR_2 contains free variables).
- If PAR_2 is an expression, its value is com-
- puted and it is attempted to unify PAR_1 with it.
- is can also compute a list of the form
- [ INTEGER ] as the value of this integer-number
- (in accordance with the conventions of Prolog-10).
- is is used by other predicates that regard
- their arguments as expressions, e.g. the
- following.
-
-
- 3.2.3. Comparison of numbers or names
- ------------------------------
- less( INTEGER, INTEGER )
- succeeds when PAR_1 < PAR_2.
-
- TERM =:= TERM ( =:= )
- succeeds when PAR_1 and PAR_2 are arithmetic
- expressions that have the same value.
-
-
- TOY Prolog ST 12 Comparison operators
-
-
- TERM =\= TERM ( =\= )
- as =:=, but checks whether the values are
- different.
-
- TERM < TERM ( < )
- as =:=, but checks whether the value of PAR_1 is
- less than the value of PAR_2.
-
- TERM =< TERM ( =< )
- as <, but checks for "less than or equal".
-
- TERM > TERM ( > )
- as <, but checks for "greater than".
-
- TERM >= TERM ( >= )
- as <, but checks for "greater than or equal".
-
-
- NAME @< NAME ( @< )
- succeeds whenever PAR_1 comes before PAR_2 in the
- lexicographic order defined by the extended ASCII
- character set of the Atari ST.
-
- NAME @=< NAME ( @=< )
- as @<, but checks for "less than or equal".
-
- NAME @> NAME ( @> )
- as @<, but checks for "greater than".
-
- NAME @>= NAME ( @>= )
- as @<, but checks for "greater than or equal".
-
-
- 3.2.4. Comparison of terms
- -------------------
- TERM = TERM ( = )
- attempts to unify PAR_1 and PAR_2.
-
- eqvar(VAR, VAR)
- succeeds when PAR_1 and PAR_2 are two instances of
- the same, non-anonymous variable.
-
- TERM == TERM ( == )
- succeeds when PAR_1 and PAR_2 are two instances of
- the same term.
-
- TERM \== TERM ( \== )
- succeeds when PAR_1 and PAR_2 are not two
- instances of the same term.
-
- TOY Prolog ST 13 Data streams
-
-
-
-
- 3.2.5. Input and Output
- ----------------
- 3.2.5.1. Data streams
- ------------
- Input and output in TOY Prolog ST are data-stream oriented. A
- data stream is (from the user's point of view) the name or the
- complete specification of a disk file, or the predefined name of
- a special input or output device.
-
- A disk file can be accessed for reading and writing, provided it
- is not protected by the operating system against overwriting and
- is not on a write-protected disk. Names of file streams can be
- for example:
- editor (one of the auxiliary programs)
- 'sysfile.toy' (the system file)
- 'b:\folder.1\data' (a file named 'data' on a disk in
- drive B in folder 'folder.1')
- Either upper or lower case can be used for file streams.
- A file stream can be opened only in one direction, read-only
- or write-only. Opening a file stream several times in the
- same direction has no effect.
-
- The predefined data streams are available for communicating with
- other devices or components of the computer. They cannot always
- be accessed for reading and writing, but a predefined data stream
- for which read and write access are allowed can be opened in both
- directions at the same time.
- The predefined data streams and the types of access allowed
- are tabulated below. Their names can be written in either upper
- or lower case (don't forget the apostrophes in upper case.)
-
- Name | Read access | Write access
- ------------|------------------------|---------------------
- user | standard user input | standard user output
- | (keyboard, buffered) | (screen)
- | |
- keybd | user input | output to the
- | (keyboard, single char)| keyboard controller
- | |
- modem | read RS232 interface | write RS232
- | |
- midi | read MIDI interface | write MIDI
- | |
- printer | not allowed ! | Centronics interface
- ------------+------------------------+---------------------
-
- TOY Prolog ST 14 Switching i/o streams
-
-
-
-
- 3.2.5.2. Switching input/output streams
- ------------------------------
- Up to 16 file streams can be open at the same time.
-
- see( FILENAME )
- the given data stream becomes the current input
- stream; if it refers to a file not yet opened,
- this is opened for reading.
-
- seeing( TERM )
- attempts to unify the parameter with the current
- input stream.
-
- seen
- If the current input stream is a file, it is
- closed. The predefined data stream 'user' becomes
- the current input stream.
-
- tell( FILENAME )
- the given data stream becomes the current output
- stream; if it refers to a file not yet opened,
- this is generated on the disk (any existing file
- of the same name will be deleted!) and opened for
- writing.
-
- telling( TERM )
- attempts to unify the parameter with the current
- output stream.
-
- told
- If the current output stream is a file, it is
- closed. The predefined data stream 'user' becomes
- the current output stream.
-
-
- Access to disk directories is enabled by the following system
- functions, implemented in Version 3.3:
-
- disk_dir( VAR )
- instantiates PAR_1 with the name of the current
- directory, i.e. drive descriptor and pathname.
-
- disk_dir( NAME )
- makes the directory given in PAR_1 the current
- directory. The drive descriptor can be absent; in
- this case the current drive is used. If PAR_1 is
- incorrect, a system call error is generated.
-
- disk_search( NAME, INTEGER, TERM, TERM )
- PAR_1 and PAR_2 are parameters for the operating
- system call 'Fsfirst': the first file in the
- current directory (or in a directory determined by
-
- TOY Prolog ST 15 File streams
-
-
- a pathname present in PAR_1) is sought, that
- corresponds to the search pattern in PAR_1, and
- whose attributes correspond to the search
- attributes PAR_2. The search pattern is given as a
- filename; though the 'wild cards' '#' and '?' can
- be used here. There must be no 'wild cards' in the
- pathname.
- The search attributes are given bitwise in
- PAR_2:
- 0 Normal file access allowed
- 1 File is write-protected
- 2 File is 'hidden'
- 4 File is a 'system file' (also hidden)
- 8 Not a file, but the name of the disk
- 16 Not a file, but a subdirectory
- 32 File has been written & closed (???)
- If no corresponding file is found, the call fails;
- otherwise an attempt is made to unify PAR_3 with
- the name and PAR_4 with the attributes of the file
- found.
-
- disk_search( TERM, TERM )
- seeks the next file whose name and attributes fit
- those in the last call of disk_search/4, and
- attempts to unify PAR_1 with the filename and
- PAR_2 with the attributes belonging to it. If no
- further file that fits is found, the call fails.
-
-
- If a critical error occurs during a disk operation - change of
- disk, wrong disk in drive, etc. - the message results,
- There was a critical error. (A)bort, (R)etry or (I)gnore?
- Entering 'A' leads to an abort, with an error message; 'R' gives
- rise to a new trial, and with 'I' the error is ignored
- (careful!).
-
- TOY Prolog ST 16 Input aids
-
-
-
-
- 3.2.5.3. Input aids
- ----------
- TOY Prolog has the ability to print out on the screen for
- checking characters that have been read in from a file stream or
- a peripheral device.
-
- echo
- switches checking printout on.
-
- noecho
- switches checking printout off.
-
-
- Version 3.3 allows character strings to be assigned to the
- function keys (F1 to F10) and the cursor key block, so that when
- the appropriate key is pressed during entry from the keyboard
- (data streams 'user' and 'keybd') it is as if the string had been
- entered from the keyboard.
- The following system function serves for this:
-
- set_fstring( INTEGER, NAME )
- PAR_1 must be an integer in the range 0 to 27,
- which selects the desired function key (see
- below). The character string given by the name in
- PAR_2 is assigned to the selected function key
- (PAR_2 must be a functor without arguments).
- The function keys are denoted as follows:
- 0 F1 10 Shift-F1 20 Clr/Home
- 1 F2 11 Shift-F2 21 Cursor up
- 2 F3 12 Shift-F3 22 Cursor left
- 3 F4 13 Shift-F4 23 Cursor right
- 4 F5 14 Shift-F5 24 Cursor down
- 5 F6 15 Shift-F6 25 Insert
- 6 F7 16 Shift-F7 26 Undo
- 7 F8 17 Shift-F8 27 Help
- 8 F9 18 Shift-F9
- 9 F10 19 Shift-F10
-
- This special feature applies to the character
- string: if there is a '\' in the string, the
- following character is interpreted as if the key
- concerned had been typed together with 'Control'.
- Exception: if the character following is another
- '\', it counts (as usual) as a single '\'. E.g.:
- \G - 'Bell', \H - 'Backspace', \M - 'Return'.
-
- TOY Prolog ST 17 I/o of terms - Operators
-
-
-
-
- 3.2.5.4. Input/output of terms; operators
- --------------------------------
- display( TERM )
- outputs TERM in standard form to the current
- output stream: functors will be output in prefix
- form with brackets; names will not be placed in
- apostrophes; variables will be output as _N, where
- N is a number.
-
- write( TERM )
- outputs TERM to the current output stream; the
- present operator declarations will be followed,
- but names will not be placed in apostrophes.
- Variables will be output in the form XN, where N
- is a number; the numbering begins with 1.
- Warning: in TOY Prolog a predicate is used
- for the output of variables that numbers them,
- binding them to terms of the form 'V'(N). For this
- reason, terms of the form 'V'(N) will not be
- output correctly, when N is an integer number.
-
- writeq( TERM )
- As 'write', but names that do not constitute well-
- formed words or are in conflict with a present
- operator declaration will be placed in apostro-
- phes. Terms that have been output with 'writeq'
- can be read in again with 'read'.
-
- read( TERM )
- reads a term, concluded with a full stop, from the
- current input stream; succeeds only when this term
- can be unified with PAR_1. The present operator
- declarations are followed. If the input term
- contains a syntactical error, the message
- "Bad term on input. Text skipped:"
- is output, and the input text as far as the next
- full stop outside a comment or quotation marks is
- skipped (if there is no full stop, the user must
- enter one). After that, it attempts to unify PAR_1
- with 'e r r'.
- At the end of a file stream, input is
- switched to 'user'.
-
- op( INTEGER, ATOM, ATOM )
- declares PAR_3 as an operator with type specifier
- PAR_2 and precedence number PAR_1. Operators with
- lower precedence numbers are evaluated first. The
- precedence must be in the range 1 ≤ PAR_1 ≤ 1200,
- and should be less than 1000 to avoid conflict
- with the operators ',', ';', ':-' and '-->'.
- PAR_2 must be chosen from the set { xf, yf,
- fx, fy, xfx, xfy, yfx, yfy }. PAR_3 must be
-
- TOY Prolog ST 18 Operators
-
-
- printable without apostrophes.
- If an operator declaration already exists for
- PAR_3, it is modified in accordance with the
- instructions of PAR_1 and PAR_2: the new
- precedence replaces the old and the new unary (or
- binary) type replaces the old unary (or binary)
- type. In TOY Prolog an operator can have only one
- unary and one binary type at the same time, both
- with the same precedence.
-
- delop( ATOM )
- deletes the operator declaration for PAR_1. PAR_1
- should be placed in apostrophes, as it is still an
- operator up to the moment of entry of 'delop'.
-
- The following standard operators are declared already:
-
- Operator Type Precedence
- :- xfx, fx 1200
- --> xfx 1200
- ; xfy 1100
- , xfy 1000
- not fy 900
- = xfx 700
- is xfx 700
- =:= xfx 700
- =\= xfx 700
- < xfx 700
- =< xfx 700
- > xfx 700
- >= xfx 700
- @< xfx 700
- @=< xfx 700
- @> xfx 700
- @>= xfx 700
- == xfx 700
- \== xfx 700
- =.. xfx 700
- + yfx, fx 500
- - yfx, fx 500
- * yfx 400
- / yfx 400
- mod xfx 300
-
- TOY Prolog ST 19 Single characters
-
-
-
-
- 3.2.5.5. Single characters
- -----------------
- In TOY Prolog, unlike Prolog-10, single characters are represen-
- ted by atoms, whose names consist of exactly one character (in
- Prolog-10, as their ASCII-representation, i.e. as numbers).
- TOY Prolog ST supports the extended character set of GEM;
- hence German, French, Spanish etc. letters are actually recog-
- nized as letters (!).
- For character strings there exists a special represen-
- tational form. Character strings are treated as lists of
- single characters (not, as in Prolog-10, as lists of ASCII
- codes); the notation for character strings uses quotation marks
- (") to enclose a string. As usual, a doubled quotation mark ("")
- inside a character string denotes a single " included in the
- string.
-
- The following predicates are provided for working on single
- characters.
-
- ordchr( INTEGER, CHAR )
- succeeds whenever PAR_1 is the ordinal number of
- the character PAR_2.
-
- ordchr( VAR, CHAR )
- succeeds after unifying PAR_1 with the ordinal
- number of PAR_2.
-
- ordchr( INTEGER, VAR )
- succeeds after unifying PAR_2 with the character
- whose ordinal number PAR_1 mod 256 is.
-
- iseoln( TERM )
- attempts to unify PAR_1 with the end_of_line
- character. TOY Prolog converts every end_of_line
- to a single 'CR'.
-
- smalletter( TERM )
- tests whether PAR_1 is a lower-case letter.
-
- bigletter( TERM )
- tests whether PAR_1 is a capital letter.
-
- letter( TERM )
- tests whether PAR_1 is a letter.
-
- digit( TERM )
- tests whether PAR_1 is a decimal digit.
-
- alphanum( TERM )
- tests whether PAR_1 is a letter, digit or under-
- score (_).
-
-
- TOY Prolog ST 20 Single characters
-
-
- bracket( TERM )
- tests whether PAR_1 is one of the characters ( ) [
- ] { }
-
- solochar( TERM )
- tests whether PAR_1 is one of the characters ! , ;
-
- symch( TERM )
- tests whether PAR_1 is a symbol_char.
-
-
- 3.2.5.6. Input/output of single characters
- ---------------------------------
- For the input and output of single characters there are a number
- of special predicates. These do not work - as in Prolog-10 - with
- ASCII codes. The predicates of Prolog-10 that deal with i/o of
- single characters can be defined roughly as follows (not fully
- compatible):
-
- get0(Ord) :- rch, lastch(Ch), ordchr(Ord, Ch).
- get(Ord) :- rch, skipbl, lastch(Ch), ordchr(Ord, Ch).
- skip(X) :- repeat, get0(X), !.
- put(Ord) :- ordchr(Ord, Ch), wch(Ch).
-
- The main difference between TOY Prolog and Prolog-10 in the
- handling of single characters lies in the fact that TOY Prolog
- maintains a buffer for the last character input; hence in TOY
- Prolog an entered character can be accessed repeatedly, even
- after possible backtracking.
-
- If an end_of_line is reached during input, it is written into the
- input buffer ("last_char") as a single 'CR'. If the end of a file
- stream is reached, the interpreter automatically executes the
- predicate 'seen'; the following character will be read from the
- user stream. This event will be reported to the user by a
- message.
-
- The predicates for i/o of single characters:
-
- rch
- succeeds after writing the next character from the
- current input stream into last_char.
-
- skipbl
- succeeds after ensuring that last_char contains a
- printable character (ASCII code > 32). If such a
- character is already present in last_char, nothing
- is done, otherwise 'rch' is executed.
-
- lastch( TERM )
- attempts to unify PAR_1 with last_char.
-
-
- TOY Prolog ST 21 Single chars - Type testing
-
-
- rdch( TERM )
- reads the next character from the input stream and
- writes it into last_char; makes a copy of
- last_char, in which unprintable characters are
- replaced by spaces; and attempts to unify the copy
- with PAR_1.
-
- rdchsk( TERM )
- as 'rdch', but 'skipbl' is executed first.
-
- wch( CHAR )
- writes the character into the current output
- stream. 'CR' is interpreted as a line-separator.
-
- nl
- ends the current line (outputs 'CR').
-
- bell
- outputs the character 'BEL'; on output to the user
- stream this character produces a bell sound.
-
- The Atari ST interprets the character 'Esc' (Escape) as a special
- control character: when 'Esc' is output to the user stream, the
- next 1-3 characters produce a change of the parameters of the
- screen output. There exist special predicates for the output of
- escape sequences:
-
- escape
- outputs 'Esc'.
-
- cls
- outputs 'Esc', 'E'; this erases the screen
- contents.
-
-
-
-
-
-
- 3.2.6. Type testing
- ------------
- var( TERM )
- succeeds whenever PAR_1 is a free variable.
-
- integer( TERM )
- succeeds whenever PAR_1 is an integer number.
-
- nonvarint( TERM )
- succeeds whenever PAR_1 is an F_TERM.
-
- atom( TERM )
- succeeds whenever PAR_1 is an atom.
-
- TOY Prolog ST 22 The term structure
-
-
-
-
- 3.2.7. Access to the term structure
- ----------------------------
- pname( NAME, TERM )
- generates a list of the individual characters of
- PAR_1 and attempts to unify this list with PAR_2.
-
- pname( VAR, CHAR_LIST )
- succeeds after unifying PAR_1 with a NAME that
- consists of the individual characters of PAR_2.
-
- pnamei( INTEGER, TERM )
- generates a list of digits that form the decimal
- representation of PAR_1, and attempts to unify
- this list with PAR_2. PAR_1 must not be negative.
-
- pnamei( VAR, NUM_LIST )
- succeeds after unifying PAR_1 with the integer
- number whose decimal representation is the
- characters of PAR_2. Even with correct parameters,
- an error can occur if the number exceeds the
- biggest representable integer. In this implementa-
- tion numbers up to 32767 ( = 2**15 - 1) are
- representable.
-
- 'pname' and 'pnamei' replace the function 'name' of Prolog-10,
- which in fact works similarly, but uses ASCII codes instead of
- the character representation used in TOY Prolog.
-
- functor( VAR, INTEGER, 0 )
- PAR_3 is the number 0; this call succeeds after
- unifying PAR_1 with PAR_2.
-
- functor( VAR, NAME, INTEGER )
- succeeds after unifying PAR_1 with an F_TERM whose
- functor has the name and arity determined by PAR_2
- and PAR_3 and whose arguments are various free
- variables. PAR_3 must not be negative.
-
- functor( INTEGER, TERM, TERM )
- attempts to unify PAR_2 with PAR_1 and PAR_3 with
- the number 0.
-
- functor( F_TERM, TERM, TERM )
- attempts to unify PAR_2 with the name and PAR_3
- with the arity of the principal functor of PAR_1.
-
- arg( INTEGER, F_TERM, TERM )
- fails if PAR_1 is less than 1 or greater than the
- arity of the principal functor of PAR_2; otherwise
- it attempts to unify PAR_3 with the PAR_1th
- argument of PAR_2.
-
-
- TOY Prolog ST 23 The term structure
-
-
- VAR =.. [INTEGER]
- succeeds after unifying PAR_1 with the number in
- PAR_2.
-
- VAR =.. [NAME | TERM]
- If the TERM in PAR_2 is not a 'closed' list,
- generates an error in the predicate length / 2
- ('=..' uses 'length'). Otherwise generates a term
- whose functor is NAME and whose argument list is
- TERM; this term will be unified with PAR_1.
-
- INTEGER =.. TERM
- attempts to unify PAR_2 with [PAR_1].
-
- F_TERM =.. TERM
- generates a list whose head is the principal
- functor of PAR_1 and whose body the argument list
- of PAR_1; attempts to unify this list with PAR_2.
-
- TOY Prolog ST 24 The Prolog data bank
-
-
-
-
- 3.2.8. Access to predicates in the data bank
- -------------------------------------
- protect( NAME, INTEGER )
- protects the predicate with name PAR_1 and arity
- PAR_2 against alteration by the predicates de-
- clared further on.
-
- protect
- protects all the predicates present in the data
- bank.
-
- unprotect( NAME, INTEGER )
- removes the protection for the predicate with name
- PAR_1 and arity PAR_2.
-
- unprotect
- removes the protection from all predicates.
-
- The data bank can be altered through the following predicates:
-
- assert( F_TERM, CALL_LIST, INTEGER )
- PAR_1 will be regarded as the head of a clause and
- PAR_2 as its body; this clause will be inserted in
- the data bank directly after the nth clause of the
- relevant procedure ( n = PAR_3, if the clause with
- this number exists; the number of the last clause,
- if there are < PAR_3 clauses; or 0, if no clauses
- exist or PAR_3 < 1 ).
-
- retract( NAME, INTEGER, INTEGER )
- PAR_2 must not be negative. PAR_1 and PAR_2
- indicate the name and arity of a predicate; if the
- relevant predicate has no clause with the number
- PAR_3, 'retract' fails; otherwise the relevant
- clause will be removed from the data bank and
- 'retract' will succeed.
- Warning: if instances of the deleted clause
- are still active at the moment of deletion, in the
- great majority of cases catastrophic errors will
- occur!
-
- clause( NAME, INTEGER, INTEGER, TERM, TERM )
- PAR_2 must not be negative. PAR_1 and PAR_2
- indicate the name and arity of a predicate; if the
- relevant predicate has no clause with the number
- PAR_3, 'clause' fails; otherwise it attempts to
- unify PAR_4 with its head and PAR_5 with its body.
-
-
- TOY Prolog ST 25 The Prolog data bank
-
-
- asserta( F_TERM )
- treats PAR_1 as a clause; if the principal functor
- is ':-' and its first argument not an F_TERM, an
- error is generated. The clause will be inserted in
- the data bank as the first clause of the relevant
- predicate.
-
- assertz( F_TERM )
- As 'asserta', but inserts the clause in the
- data bank as the last clause of the relevant
- predicate.
-
- assert( F_TERM )
- a synonym for 'asserta'.
-
- retract( F_TERM )
- treats PAR_1 as a clause; if its principal functor
- is ':-' and its first argument not an F_TERM, an
- error is generated. The first clause that can be
- unified with PAR_1 will be removed from the data
- bank (if PAR_1 has the form F_TERM :- VAR, it can
- only be unified with clauses whose body consists
- of a single variable-call!). If 'retract' should
- be resatisfied, the next clause unifiable with
- PAR_1 will be removed, and so on.
-
- clause( F_TERM, TERM )
- finds the first clause whose head can be unified
- with PAR_1 and whose body with PAR_2; succeeds
- after successful unification. If 'clause' is
- resatisfied, the next clause is looked for, and so
- on.
-
- redefine
- is needed for the implementation of 'reconsult'
- (it should not be called directly). Between two
- calls to 'redefine', 'assert' behaves differently
- from normal: if a clause is saved with 'assert'
- that does not belong to the predicate last saved
- with 'assert', the entire predicate to which the
- new clause belongs will first be deleted.
-
- abolish( NAME, INTEGER )
- PAR_2 must not be negative. The predicate with
- name PAR_1 and arity PAR_2 will be entirely
- deleted.
-
- predefined( NAME, INTEGER )
- PAR_2 must not be negative; 'predefined' tests
- whether the predicate with name PAR_1 and
- arity PAR_2 is a system function.
-
-
- TOY Prolog ST 26 The Prolog data bank
-
-
- consult( FILENAME )
- switches the current input stream and reads
- clauses, which it then saves with 'assertz'. There
- are two exceptions to this: the term 'end' ends
- the read-in mode and restores the old input
- stream; terms with the functor ':-'/1 are regarded
- as commands and executed accordingly.
-
- reconsult( FILENAME )
- as 'consult', but before and after reading in
- 'redefine' is called, so that connected conse-
- quences of the clauses of a predicate replace the
- old predicate, instead of supplementing it.
-
- consultall( TERM )
- PAR_1 must be a list of FILENAMEs or terms of the
- form '- FILENAME' (also mixed); it will call
- 'consult' for each simple FILENAME and 'reconsult'
- for each FILENAME with '-'/1. This predicate is
- called by the user interface when a list of
- commands is entered.
-
- listing( F_TERM )
- PAR_1 must be an ATOM, or a term of the form
- ATOM/INTEGER, or a (possibly complex) list of such
- terms; each ATOM is regarded as the name and each
- number as the arity of a predicate. All clauses
- belonging to the pertinent predicate will be
- output to the current output stream.
-
- listing
- as listing/1, but outputs all predicates,
- including the predefined predicates. The sequence
- is fixed by the 'hash' function of the inner
- interpreter and cannot be altered.
-
- proc( TERM )
- attempts to unify PAR_1 with an F_TERM that has
- the name and arity of the first predicate in the
- data bank; should 'proc' be resatisfied, the next
- predicate is used each time; fails if there is no
- further such predicate there. For the sequence of
- the predicates, see listing/0.
-
- TOY Prolog ST 27 Program course control
-
-
-
-
- 3.2.9. Control of the course of the program
- ------------------------------------
- When the call of a predicate activates a clause that is not the
- last one of this predicate, a pointer is assigned to this clause
- in the data bank. This pointer is used when the goal called has
- to be resatisfied.
- The direct descendants of a call A are the calls in the
- clause activated by A. The direct ancestor of A is the call
- activated by the clause in which A occurs. An ancestor of A is
- the direct ancestor or an ancestor of the direct ancestor; a
- descendant of A is a direct descendant or one of its descendants.
-
- ! ('cut', sometimes also 'slash')
- succeeds after finding the next ancestor that is
- not call/1, tag/1, ,/2 or ;/2. All data-bank
- pointers that belong to this ancestor and all its
- descendants are removed.
-
- repeat
- succeeds, and can be resatisfied as often as you
- like.
-
- call( CALL )
- behaves as though PAR_1 stood in the place of the
- call of 'call'; though when 'call' is used, an
- incorrect parameter is first recognised at the run
- time of the program. In the outer interpreter a
- variable can occur in place of a predicate as call
- in a clause; such a variable-call is converted by
- the outer interpreter into a call of 'call'.
-
- tag( CALL )
- another form of call(CALL); a call of 'tag' can be
- accessed with the predicates 'tagfail', 'tagexit',
- 'tagcut' and 'ancestor'. PAR_1 is called the
- marked ancestor of its descendants.
- A call of 'tag' is recognized by 'tagfail'
- etc. only when it stands explicitly in a clause,
- e.g. call(tag(A)) is not recognised.
-
- ancestor( TERM )
- seeks the next marked ancestor that can be unified
- with PAR_1; if none is found, 'ancestor' fails,
- otherwise the ancestor and PAR_1 are unified and
- 'ancestor' succeeds.
-
- tagcut( TERM )
- as 'ancestor', but on success all the data-bank
- pointers belonging to the ancestor found and its
- descendants are removed.
-
-
- TOY Prolog ST 28 Program course control
-
-
- tagfail( TERM )
- seeks the next marked ancestor that can be unified
- with PAR_1; fails if none is found. If a marked
- ancestor is found, this fails at once.
-
- tagexit( TERM )
- seeks the next marked ancestor that can be unified
- with PAR_1; fails if none is found. If a marked
- ancestor is found, it is unified with PAR_1 and
- succeeds at once (i.e. the call after tag(...) is
- considered as the next).
-
- halt( ATOM )
- outputs PAR_1 and ends the inner interpreter.
-
- stop
- ends the main loop of the outer interpreter;
- normally 'halt' is called and the inner interpre-
- ter ended as well. Exceptions are possible (e.g.
- in the editor).
-
- sysload( FILENAME )
- ends the outer interpreter and switches the
- current input stream to the given file. This file
- should contain a program in the syntax of the
- inner interpreter (see Appendix 2). After a
- 'seen', or on reaching the end of the file, the
- outer interpreter is restarted.
-
- TOY Prolog ST 29 Program testing
-
-
-
-
- 3.2.10. Aids for the testing of programs
- --------------------------------
- In the ST version of TOY Prolog there is the possibility of
- interrupting the course of a program by pressing the key
- combination ShiftAlternateHelp. The present goal is output in the
- form
- INTR: .......
- and the user has the opportunity to alter the course of the
- program. For this s/he can select the following options:
-
- A (Abort) The entire goal being carried out is broken off
- (including the outer interpreter).
- B (Backtrace) The ancestors of the present goal are reported.
- C (Continue) The present goal is worked on.
- D (Debug ON/OFF) Test mode is switched on or off (see 'debug').
- F (Fail) The present goal fails.
- S (Step ON/OFF) Single-step mode is switched on or off; if it
- is switched on, the program is automatically
- interrupted before working on the next goal.
-
- Pressing the key combination 'Control-C' often has the same
- effect as ShiftAltHelp followed by selecting option A: the outer
- interpreter is immediately stopped. The inner interpreter is not
- stopped; if no file is being read in just then, the outer
- interpreter is restarted.
-
- In addition there exist some predicates that should make program
- testing easier:
-
- interrupt
- interrupts the course of the program (as if the
- user had pressed the 'Help' key).
-
- debug
- switches test mode on. In test mode, each goal to
- be worked on is printed out with information
- reporting whether the goal
- - is being called for the first time (CALL:...)
- - is to be resatisfied (REDO:...)
- - has been successfully completed (EXIT:...)
- - or has failed (FAIL:...)
-
- nodebug
- switches test mode off.
-
- nonexistent
- switches on monitoring of calls of undefined
- predicates. After 'nonexistent', in case of a call
- of an undefined predicate a message will be
- output.
-
-
- TOY Prolog ST 30 Program testing, etc.
-
-
- nononexistent
- switches these messages off again.
-
- The following two predicates switch test mode on selectively for
- set calls:
-
- spy( NAME, INTEGER )
- PAR_2 must not be negative. Test mode is switched
- on for the predicate with name PAR_1 and arity
- PAR_2.
-
- spy( NAME, VAR )
- ditto, but for all predicates with this name; the
- variable is not instantiated.
-
- spy( VAR, INTEGER )
- ditto, but for all predicates with the given
- arity.
-
- spy( VAR, VAR )
- ditto, but for all predicates. The effect is the
- same as with 'debug', but cannot be switched off
- again with 'nodebug' (!). As the variables are not
- instantiated, the same variable can be used twice.
-
- nospy( PAR1, PAR2 )
- switches off the selective test mode. All the call
- patterns of 'spy' can be used in the same way as
- there. 'nospy' cannot switch off the general test
- mode switched on with 'debug'.
-
- spied( NAME, INTEGER )
- tests whether the selective test mode is switched
- on for the predicate with name PAR_1 and arity
- PAR_2.
-
- Note: at present test mode does not function correctly - FAIL is
- often reported when it should not be, and EXIT not always
- reported when it should be. See Appendix 5.
-
-
- 3.2.11. Working on grammatical rules
- ----------------------------
- phrase( CALL, TERM )
- treats PAR_1 as a non-terminal symbol of a gramma-
- tical rule and arranges for the processing of
- PAR_2 using PAR_1 as start symbol.
-
-
- 3.2.12. Miscellaneous functions
- -----------------------
- length( F_TERM, TERM )
- computes the length of PAR_1, which must be a
- 'closed' list, and attempts to unify the result
-
- TOY Prolog ST 31 Miscellaneous functions
-
-
- with PAR_2.
-
- isclosedlist( TERM )
- tests whether PAR_1 is a 'closed' list.
-
- numbervars( TERM )
- instantiates the variables that occur in PAR_1
- with 'V'(1), 'V'(2), ... . Variables that have
- been bound together are instantiated with the same
- 'V'(n).
-
- member( TERM, TERM )
- tests whether PAR_1 is an element of the list
- PAR_2. If PAR_2 is an 'open' list that does not
- contain PAR_1, 'member' succeeds after the list
- has been extended to include PAR_1.
-
- bagof( TERM, CALL, TERM )
- attempts to unify PAR_3 with a list of the
- instantiations established for PAR_1 after all
- possible computations of PAR_2.
-
- status
- gives an overview of present memory occupancy.
-
- The following predicates use the Atari ST's clock:
-
- date( VARINT, VARINT, VARINT )
- attempts to unify PAR_1, PAR_2 and PAR_3 with
- numbers giving the date in the form "day, month,
- year".
-
- set_date( INTEGER, INTEGER, INTEGER )
- sets the date: PAR_1 day, PAR_2 month, PAR_3 year.
-
- time( VARINT, VARINT, VARINT )
- attempts to unify PAR_1, PAR_2 and PAR_3 with
- numbers giving the time of day in the form "hours,
- minutes, seconds".
-
- set_time( INTEGER, INTEGER, INTEGER )
- sets the time: PAR_1 hours, PAR_2 minutes, PAR_3
- seconds.
-
- 'time' and 'set_time' work in units of 2 seconds.
-
-
- translate( FILENAME, FILENAME )
- switches input to PAR_1 and output to PAR_2 and
- translates the program read from PAR_1 into the
- syntax of the inner interpreter. The result is a
- file that can be read with 'sysload'.
- See also the sections on 'consult' and
- 'sysload', as well as the Appendix.
-
- TOY Prolog ST 32 GEM graphics functions
-
-
-
-
- 3.3. The GEM Functions
- -----------------
- TOY Prolog ST can access some of the functions of the VDI and
- AES. Details of these functions cannot be given here.
-
- In the following brief descriptions, all parameters are INTEGER
- numbers unless otherwise stated.
-
- 3.3.1. Control functions
- -----------------
- grf_clip( Flag, X1, Y1, X2, Y2 )
- If Flag = 0, clipping is switched off, otherwise
- on. (X1, Y1) and (X2, Y2) are diagonally opposite
- corners of the clipping rectangle.
-
- grf_wrmode( Mode )
- sets the write mode:
- 0 Replace mode
- 1 Transparent mode
- 2 XOR mode
- 3 Reverse-transparent mode
-
- grf_colour( Index, Red, Green, Blue )
- sets the colour combination for the colour with
- the given index number. Red, Green and Blue lie in
- the range 1 - 1000.
-
- grf_mode
- switches graphic mode on.
-
- txt_mode
- switches text mode on.
-
-
- 3.3.2. Graphic output
- --------------
- grf_pline( coordinate-list )
- PAR_1 must be a list of an even number of
- INTEGERs. Each pair of list elements is regarded
- as coordinates and a polyline (multiple line
- segments) is drawn.
-
- grf_pmarker( coordinate-list )
- draws a number of markers at the coordinates given
- by PAR_1.
-
- grf_poly( coordinate-list )
- draws a filled polygon.
-
-
- TOY Prolog ST 33 GEM graphics functions
-
-
- grf_fill( X, Y, Index )
- fills an area up to its boundary, starting from
- the point (X, Y). Index is the original colour
- index of the area (i.e. of the boundary).
-
- grf_box( X1, Y1, X2, Y2 )
- draws a filled rectangular area; (X1, Y1) and
- (X2, Y2) are opposite corners.
-
- grf_bar( X1, Y1, X2, Y2 )
- ditto, but with perimeter.
-
- grf_arc( X, Y, R, Alpha, Omega )
- draws a circular arc with centre (X, Y), radius R,
- start angle Alpha and end angle Omega.
-
- grf_pie( X, Y, R, Alpha, Omega )
- ditto, but a filled sector of a circle.
-
- grf_circle( X, Y, R )
- draws a filled circle with centre (X, Y) and
- radius R.
-
- grf_ellipse( X, Y, Xrad, Yrad )
- draws a filled ellipse with centre (X, Y) and
- semi-axes Xrad and Yrad.
-
- grf_rbox( X1, Y1, X2, Y2 )
- draws an unfilled rectangle with rounded corners.
-
- grf_rfbox( X1, Y1, X2, Y2 )
- as 'grf_rbox', but filled.
-
- grf_text( X, Y, Text )
- Text is a NAME, which is output as graphic text at
- the position (X, Y).
-
-
- 3.3.3. Attribute functions
- -------------------
- grf_l_colour( Index )
- sets the line colour.
-
- grf_l_type( Style )
- sets the line type:
- 1 solid
- 2 - 6 broken
- 7 user-defined
-
- grf_l_udstyle( Pattern )
- sets the user-defined line style. Pattern is an
- INTEGER number whose 16 bits define the pattern.
-
-
- TOY Prolog ST 34 GEM graphics functions
-
-
- grf_l_width( Width )
- sets the line width.
-
- grf_l_ends( Begin, End )
- sets the shapes of the start and end of lines:
- 0 squared
- 1 arrow
- 2 rounded
-
- grf_m_colour( Index )
- sets the colour of markers.
-
- grf_m_type( Type )
- sets the marker type:
- 1 dot
- 2 cross
- 3 asterisk
- 4 square
- 5 diagonal cross
- 6 diamond
-
- grf_m_height( Height )
- sets the height of markers.
-
- grf_t_height( Height )
- sets the height of text.
-
- grf_t_point( Height )
- sets the text height in points.
-
- grf_t_rotation( Angle )
- sets the angle to which the character baseline is
- rotated.
-
- grf_t_colour( Index )
- sets the text colour.
-
- grf_t_effects( Effects )
- sets the text effects. Effects contains the sum of
- the effects required:
- 1 Thickened
- 2 Light
- 4 Skewed
- 8 Underlined
- 16 Outlined
-
- grf_t_align( Hor, Vert )
- sets the text alignment horizontally (Hor) and
- vertically (Vert):
- Hor: 0 left Vert: 0 baseline
- 1 centred 1 half line
- 2 right 2 ascent line
- 3 bottom line
- 4 descent line
-
- TOY Prolog ST 35 GEM graphics functions
-
-
- 5 top line
-
- grf_f_colour( Index )
- sets the fill colour.
-
- grf_f_type( Type )
- sets the interior-fill type:
- 0 hollow
- 1 solid
- 2 patterned
- 3 hatched
- 4 user-defined
-
- grf_f_style( Style )
- sets the fill style for fill types 2 and 3.
-
- grf_f_perim( Flag )
- switches perimeter for filled areas on (Flag = 1)
- or off (Flag = 0).
-
- grf_f_udpat( Pattern )
- Pattern must be a list of exactly 16 INTEGER
- numbers. They will be used as a pattern for fill
- type 4.
-
-
- 3.3.4. Functions for mouse control
- ---------------------------
- grf_mse_hide
- switches the mouse cursor off.
-
- grf_mse_show( Flag )
- If Flag = 0, switches the mouse on again at once;
- otherwise switches it on when 'grf_mse_show' has
- been called as many times as 'grf_mse_hide' has
- been previously.
-
- grf_mse_form( Form )
- switches on a predefined mouse form:
- 0 arrow
- 1 text cursor
- 2 bee
- 3 pointing hand
- 4 flat hand
- 5 thin crosshairs
- 6 thick crosshairs
- 7 outlined crosshairs
- 255 pencil
-
- grf_mse_form( Xhot, Yhot, Mask, Data, Pattern )
- switches on a user-defined mouse form: Xhot, Yhot
- are the coordinates of the action point within the
- 16x16 grid, Mask and Data are the background and
- foreground colours; Pattern must be a list of
-
- TOY Prolog ST 36 GEM functions; system fns
-
-
- exactly 32 INTEGER numbers, the first 16 giving
- the raster for the mask and the last 16 that for
- the mouse form itself.
-
- grf_mse_state( Button, X, Y )
- The parameters must be variables or INTEGER
- numbers. It attempts to unify Button with the
- present state of the mouse buttons and X, Y with
- the current position of the graphic cursor.
-
-
- 3.3.5. Display of an alert message
- ---------------------------
- alert( Defbutton, Alert, Exbutton )
- Alert must be a NAME; the characters of the name
- are treated as a character-string.
- Calls the AES function 'form_alert' and
- attempts to unify the value this returns with
- Exbutton. Exbutton must be an INTEGER or a
- variable.
-
-
-
-
-
-
-
-
- 3.4. Names of the system functions
- -----------------------------
- The names of the system functions can be altered, by altering the
- descriptions in the second section of the system file (see
- Appendix 3). In this one must take care that neither the sequence
- nor the number of the names is altered, and that the arities are
- preserved.
-
- It is recommended to produce before an alteration a new version
- of the user interface, as after an alteration the previous
- version is probably no longer runnable. The same holds for all
- other programs.
-
- The names of the predefined predicates can only be altered by
- altering their definitions in the system file or (with predicates
- that belong to the user interface) in the source text. The advice
- above applies here too.
-
- TOY Prolog ST 37 Translator for user interface
-
-
-
-
- 4. THE AUXILIARY PROGRAMS OF TOY PROLOG
- ------------------------------------
-
- 4.1. The translator for the User Interface
- -------------------------------------
- Source code and intermediate code: 'BOOTER.TOY'.
-
- The program 'BOOTER.TOY' is needed to provide a new version of
- the system file after changes to the user interface. The user
- interface is not written in complete Prolog but in a 'slimmed-
- down' version, which allows easy translation into the syntax of
- the inner interpreter. This is the job the translator takes care
- of.
-
- Use of the translator
- ~~~~~~~~~~~~~~~~~~~~~
- To translate a new version of the user interface,the translator
- is loaded with 'sysload'. The call takes place in the form
-
- transl( Input_file, Output_file ).
-
- thus analogous to the predefined predicate 'translate' (3.2.12).
- '#' is used as the end-of-file character for the input file;
- if there is not one at the end of the input file it must be
- entered by hand.
-
- The translator can produce error messages; in the process it
- gives the name of the predicate the error was detected in, with
- the incorrect characters and the rest of the input as far as the
- next full stop.
-
- If the translation runs without error, the output file will
- contain the intermediate code of the new version of the user
- interface; this code - preferably after removing the comments -
- can be inserted with a text editor in place of the old
- intermediate code in the system file. It is advisable to make a
- copy of the old (working!) user interface beforehand, as it can
- very well happen that the new version is incorrect. Popular
- errors are the interchange of upper and lower case letters,
- especially in variable names, e.g. NextCh - Nextch - NextChar -
- NextChr etc.
-
- TOY Prolog ST 38 Editor
-
-
-
-
- 4.2. The Editor
- ----------
- Source: '\SOURCE\EDITOR'.
- Intermediate code: 'EDITOR.TOY'.
-
- This is a matter of a simple editor for predicates. It is called
- with
-
- edit( Name/Arity ).
-
- The editor shows at any time the current clause together with its
- number; at the beginning it is at clause 0, i.e. before the first
- clause. After any command the (new) clause is shown.
-
- The editor understands the following commands:
-
- e Name/Arity calls a new incarnation of the editor. Another
- predicate can be worked on.
-
- x (eXit) leaves the present incarnation of the
- editor.
-
- + shows the next clause, if there is one.
-
- <CR> (blankspace) as +.
-
- - shows the previous clause (if there is one).
-
- t (Top) goes to clause 0.
-
- b (Bottom) goes to the last clause.
-
- l Lists the entire predicate.
-
- d Deletes the present clause and goes to the next
- one (or to the last one, if the one before the
- last has been deleted).
-
- i (Insert mode) Clauses entered in the following
- lines will be inserted after the present clause.
- 'end.' ends insert mode.
-
- f Filename as 'i', but the clauses are read from the given
- file.
-
- p calls a new incarnation of Prolog(!). When 'stop'
- is executed, carries on in the editor. In the
- encapsulated incarnation of Prolog 'sysload' must
- not be used.
-
- An entered command must end after the last character. Where blank
- spaces are given, exactly one must be entered.
-
- TOY Prolog ST 39 Program structure analyzer
-
-
-
-
- 4.3. The Program Structure Analyzer
- ------------------------------
- Source: '\SOURCE\CALLTREE'.
- Intermediate code: 'CALLTREE.TOY'.
-
- The program structure analyzer is called with
-
- calltree( Name/Arity ).
-
- to analyse the predicate with the given name and given arity. It
- produces a list of the calls that are regarded as subgoals during
- the course of the program.
- Subgoals are provided in the line in which they first appear
- with a number, by which they are referred to in subsequent
- occurrences. The encapsulation depth is shown by varying
- indentation of the lines.
-
- The program structure analyzer should not be interrupted with
- 'Help', nor run in test mode, as in most cases cyclical data
- structures will be generated during the course of the program.
- Such data structures also result when, for example, the terms X
- and f(X) are unified. As you see, TOY Prolog contains no
- 'occurrence check': the terms are unified and no more. Any
- attempt to output the resulting expression will certainly lead to
- an endless output loop, leading to a crash of the interpreter.
- Such structures will be generated in the program analyzer when
- recursive predicates are analyzed.
-
- TOY Prolog ST 40 ALPHA
-
-
-
-
- 5. THE DEMONSTRATION PROGRAMS
- --------------------------
-
- 5.1. ALPHA
- -----
- Source code: '\SOURCE\ALPHA'.
-
- ALPHA is an example for the development of interactive programs.
- After reading in it is called with 'go.'.
-
- ALPHA understands three forms of sentence. The following is an
- example dialogue:
-
- go.
- ( ... )
- John is a man.
- OK
- A man is a person.
- OK
- Is John a person?
- Yes.
- Is Mary a person?
- I don't know!
- Bye.
- ( ... )
-
- ALPHA reads the sentences in with a predicate that reads
- individual characters and combines them into words. The resulting
- list of words is then examined with the aid of grammatical rules
- and translated into Prolog instructions. The entries above, for
- example, will lead to the following clauses being adopted into
- the data bank:
-
- man(john).
- person(X) :- man(X).
-
- TOY Prolog ST 41 TOYSEQUEL
-
-
-
-
- 5.2. TOYSEQUEL (relational database)
- ------------------------------
- Source: '\SOURCE\TOYSEQ'
-
- TOYSEQUEL (© 1983 Kluzniak & Szpakowicz) is a considerably larger
- example on the use of grammatical rules for the implementation of
- a command language. TOYSEQUEL represents a relational database.
- An exact description of its commands is found in "Prolog for
- Programmers". Here only the basics can be gone into, in fact with
- examples.
-
- Call of TOYSEQUEL:
- :- toysequel.
-
- Generating a few relations:
- create Employee < string name, integer salary, integer
- deptno >.
- create Dept < integer deptno, string manager >.
- create Board < string name, integer function >.
-
- Entry of data tuples:
- into Employee insert <"Smith", 1000, 1>, <"Jones", 1200, 2>,
- <"Robinson", 600, 1>.
- into Dept insert <1, "Murdoch">, <2, "Chamberlain">.
-
- Queries on relations:
- relations.
- Board
- Dept
- Employee
-
- relation Employee.
- string name
- integer salary
- integer deptno
-
- Examination of tuples with particular properties:
- select from Employee tuples <name, salary> where deptno = 1.
- Smith 1000
- Robinson 600
-
- Entry of selected tuples:
- into Employee insert select from Dept tuples <manager, 1000,
- deptno>.
-
- Alteration of tuples:
- update Employee so that salary = 1200 where
- name = "Murdoch".
-
- from Employee delete tuples where name = "Chamberlain".
-
-
- TOY Prolog ST 42 TOYSEQUEL - Noughts & crosses
-
-
- The program's capabilities go considerably farther; there are
- various possibilities for comparison of any complicated
- arithmetic expression; if a name occurs in several relations, it
- can be fixed unambiguously by qualifications; a relation needed
- several times in one command can be given 'alias' names, etc.
-
- Three important commands:
- dump to FILENAME.
- saves the relations in the given file.
-
- load from FILENAME.
- loads a file.
-
- stop.
- returns to TOY Prolog.
-
-
- 5.3. Noughts and Crosses
- -------------------
- Source: '\SOURCE\TICTAC.TOE'.
- Intermediate code: 'TICTAC.TOY'.
-
- Noughts and Crosses should demonstrate the use of TOY Prolog's
- graphics functions.
-
- It is called by
-
- tictactoe.
-
- The user plays against the computer (the program is rather slow,
- so the computer cannot lose). A move is carried out by the user
- pointing the mouse pointer at a free square of the board and
- clicking the left button. If the mouse button is clicked while
- the pointer is on the 'STOP' button, the program is ended.
-
- TOY Prolog ST 43 The interpreter
-
-
-
-
- APPENDICES
- ==========
-
- A1. THE CONSTRUCTION OF THE INTERPRETER
- -----------------------------------
- TOY Prolog consists of two parts: the inner and the outer
- interpreter. The inner interpreter is written in C and 68000
- Assembler, the outer in Prolog itself. The advantage of this kind
- of implementation is that many parts of the interpreter are much
- easier to formulate in Prolog than in other programming
- languages.
- An example of this is the predicate 'repeat'. In Prolog it
- is defined as follows:
-
- repeat.
- repeat :- repeat.
-
- An implementation of 'repeat' in C would require the data
- structures used by the inner interpreter to be extended; the
- resulting cost increase would be considerable.
-
- The technique used naturally has disadvantages too. The biggest
- is undoubtedly the lower speed. The entire parser of TOY Prolog
- is implemented in the outer interpreter, and on the basis of the
- complex syntax (TOY Prolog is supposed to be largely compatible
- with Prolog-10) the parser is very lavish. One notices this
- particularly painfully when reading in files with 'consult', etc.
-
- The program's low speed on reading in can be got round in a
- simple way. As soon as you have a correct program available, you
- can translate it into the syntax of the inner interpreter. The
- speed with which such intermediate code can be read in far
- surpasses the reading speed of the outer interpreter.
-
- The outer interpreter consists essentially of a program loop
- (loop / 0), which reads in terms with 'read' and evaluates them.
- This loop can also be called from user programs with 'tag(loop)';
- it is interrupted by means of the predicate 'stop'. This
- possibility is used for example in the editor.
-
- The type and manner of implementation demand that the outer
- interpreter is read in after the start of the program. For this
- there is in TOY Prolog a system file called 'SYSFILE.TOY'. It
- contains besides the intermediate code for the outer interpreter
- other important data, in particular the names and arities of the
- system functions and the definitions of the predefined
- predicates. The construction of the system file is explained in
- Appendix 3.
-
- TOY Prolog ST 44 Syntax of inner interpreter
-
-
-
-
- A2. THE SYNTAX OF THE INNER INTERPRETER
- -----------------------------------
- The syntax description follows, analogous to the description of
- the complete syntax in section 2.
-
- clause ::= rule | goal
- rule ::= f_term : call_list
- goal ::= : call_list #
- call_list ::= { call . } []
- call ::= f_term
-
- f_term ::= functor | functor ( arguments )
- functor ::= name | q_name | [] | !
- arguments ::= term { , term }
- term ::= ( term ) | variable | number | f_term |
- term . term
- variable ::= anonymous_variable | numbered_variable
- anonymous_variable ::= _
- numbered_variable ::= : number
-
- number ::= sign digit { digit }
- name ::= small_letter { alphanumeric }
- q_name ::= ' q_character { q_character } '
- q_character ::= '' | not_'
- *** not_' is any character other than '
- alphanumeric ::= small_letter | capital_letter | digit | _
- sign ::= + | | -
- *** The sign can also be absent.
- *** small_letter, capital_letter, digit : see section 2.
-
-
- Comments
- ~~~~~~~~
- (1) The inner interpreter reads in only rules and goals, where a
- syntactical goal is a headless rule. Facts must be
- represented as rules in which the call-list is just []. A
- goal is terminated by the character '#', which informs the
- interpreter that it should start on the evaluation of the
- goal (i.e. on the attempt to satisfy the goal). No report on
- the success or failure of the goal is output.
-
- (2) If the inner interpreter reads from the 'user' data stream,
- it behaves as if it had read in the goal
-
- : ear . [] #
-
- This goal is the call of the outer interpreter and must
- exist as a predicate. In case another predicate than 'ear'
- has been entered in the system file (see Appendix 3), it
- works the same way.
-
-
- TOY Prolog ST 45 Syntax of inner interpreter
-
-
- (3) Anonymous variables read in by the inner interpreter behave
- differently from anonymous variables read in from the outer
- interpreter. The inner interpreter generates 'true'
- anonymous variables, which cannot be instantiated with
- values. The outer interpreter generates instead single
- instances of 'normal' variables. The difference is normally
- insignificant; one should not rely, however, on e.g.
- 'numbervars' really instantiating all variables.
-
- (4) When reading in 'numbered' variables, the inner interpreter
- generates a table by means of which it sees how many
- different variables a term contains. Thus the term
- 'f( :1, :100)' requires only two variables, not 100. The
- number allotted to a variable on input has nothing to do
- with the variable-number given by 'display' or 'write':
- 'display' uses the internal representation of variables,
- 'write' their sequence in the term.
-
- TOY Prolog ST 46 System file
-
-
-
-
- A3. THE SYSTEM FILE
- ---------------
- The system file 'SYSFILE.TOY' consists of three parts:
-
- - the names and arities of the fixed functors the inner
- interpreter needs for special purposes. They are ';' and ','
- (needed for the implementation of the 'cut'), 'tag' and
- 'call', '[]', '.', 'error' (for the handling of call
- errors), 'user' (for i/o), the operator types and 'ear' (the
- goal that is called by the inner interpreter).
- The descriptions of these functors must not be altered;
- an exception to this is 'ear', which can be altered so as to
- let another goal be called by the inner interpreter.
-
- - The names and arities of the system functions. The names of
- the system functions can be changed at will, but their
- arities must be preserved. If the name of a system function
- is altered, the change must be carried through in all
- programs, especially the outer interpreter, otherwise
- programs requiring the function in question will no longer
- run!
-
- - The system library. This contains (in the syntax of the
- inner interpreter) the definitions of the predefined
- predicates and the intermediate code of the outer
- interpreter. What we said above about changing names applies
- here too; changing the definitions does not have such far-
- reaching results, but it can quite well lead to programs not
- running any more, including the auxiliary programs.
- More will be said about changes to the user interface
- in Appendix 4.
-
- The descriptions of the special functors and system functions are
- used upon initialization of the inner interpreter; they are read
- in after AES, VDI and the memory sector of the interpreter have
- been initialized.
- The system library is read in directly after initialization
- of the inner interpreter; at the end of the file there is a
- 'seen', so that after the reading in the outer interpreter is
- started.
-
- TOY Prolog ST 47 User interface
-
-
-
-
- A4. THE IMPLEMENTATION OF THE USER INTERFACE
- ----------------------------------------
- The syntax of the inner interpreter is actually very simple,
- hence programs in this form are understandable only with
- difficulty; a program on the scale of the outer interpreter can
- therefore not be developed directly in intermediate code. For
- this reason the user interface is written in a subset of the
- language being implemented. This "half-language" is restricted in
- the following points compared with the complete syntax:
-
- - Operator notation and the use of grammatical rules are not
- allowed.
-
- - List notation is slightly restricted: in a term of the form
-
- [ A, B, C ... | X ]
-
- X must be a variable.
-
- - The comma in a rule and the symbol ':-' are treated as
- separating characters, not as operators. ';' must not be
- used in a rule as a separating character, but as a functor.
-
- The auxiliary program 'BOOTER.TOY' can translate this notation
- practically 1:1 into intermediate code.
-
- The source code for the user interface is in the file
- 'MONITOR.PRO'; after translation you should remove all comments
- fom the resulting intermediate code, as they take up quite a lot
- of space. Here you should be careful, since many predicates that
- recognise or generate comments (in the present version they are
- 'skip', 'absorbtoken' and 'nextline') use the character '%'; one
- should therefore not simply delete all the lines in which '%'
- occurs.
-
- We cannot talk here about the methods used in the design of the
- outer interpreter, and its construction; a detailed description
- can be found in "Prolog for Programmers".
-
- TOY Prolog ST 48 Future developments
-
-
-
-
- A5. FUTURE DEVELOPMENTS
- -------------------
- (1) The reporting of subgoals in test mode ("CALL", "REDO",
- "EXIT", "FAIL") still does not function correctly. "FAIL" is
- signalled at each fault, also before a 'backtrack', not only (as
- would be correct) after final failure of the subgoal. "EXIT", by
- contrast, is not signalled at every successfully satisfied goal.
- It is doubtful whether these defects will be (can be?) got
- over just yet. The "FAIL" error is a nuisance during program
- testing and will probably be eradicated soon, but the "EXIT"
- error is sometimes caused by the optimized (!) execution of
- recursive predicates and cannot - at least in this situation - be
- prevented.
- (TOY Prolog follows a 'tail recursion optimization' (TRO),
- which means that the 'activation records' of predicates can be
- destroyed if this saves memory. The name comes from recursive
- predicates in which the recursive call is the last in its clause;
- though TRO also applies to other situations, e.g. to the 'cut'.)
-
- (2) Integration of programs in other languages (C, Pascal,
- Assembler).
- (If I ever get round to it, have to think of a basis and a
- way of proceeding ... )
-
- [Translator's note: the other material originally in this appen-
- dix has been redistributed to more convenient places.]
-
-
- TOY Prolog ST 49 General index
-
-
-
-
- GENERAL INDEX
- =============
-
- (The names of predicates, system functions etc. are normally
- followed by their arities; for the predefined operators, the type
- specifier is also given.)
-
-
- , /2 (xfy) 10, 18; 3, 4, 6, @>= /2 (xfx) 12, 18
- 17, 27, 44, 46
- , (in user interface) 47 ::- (syntax descr. sym.) 3
- ; /2 (xfy) 10, 18; 3, 6, 17, | (syntax descr. sym.) 3
- 27, 46 | (in lists) 4, 5
- ';' (resatisfy) 7 { } (syntax descr. sym.) 3
- ; (in user interface) 47 { } (bracket_term) 4, 5
- :- /1 (fx) 3, 4, 7, 17-18, 26 *** (syntax descr. sym.) 3
- :- /2 (xfx) 3, 7, 17-18, 25
- :- (in user interface) 47 abolish /2 25
- --> /2 (xfx) 4, 7, 17-18 abort 29
- ! /0 ('cut') 27, 44, 46, 48 'absorbtoken' 47
- ' (with functors) 4, 44 activation record 48
- " (with strings) 4, 19 AES 32, 36, 46
- % 5, 47 alert /3 36
- [ ] (list notation) 4, 47 ALPHA 40
- [] (empty list) 4, 44, 46 alphanum /1 19
- _ (anonymous variable) 4, 44 alphanumeric 4, 44
- . (in int. code) 44, 46 ancestor 27
- : (in int. code) 44 ancestor /1 27
- # (in int. code) 44 anonymous_variable 44-45
- arg /3 22
- + (arith. op., yfx, fx) 11, 18 arguments 44
- + (sign) 44 arithmetic expression 11
- - (arith. op., yfx, fx) 6, ASCII 19-20
- 11, 18 assert /1 25
- - /1 (with filename) 26 assert /3 24
- - (sign) 4, 6, 44 asserta /1 25
- * (arith. op., yfx) 11, 18 assertz /1 25
- / (arith. op., yfx) 11, 18 ATOM 9
- atom /1 21
- = /2 (xfx) 12, 18
- == /2 (xfx) 12, 18 backtrace 29
- =:= /2 (xfx) 11, 18 backtrack 48
- =\= /2 (xfx) 12, 18 bagof /3 31
- =< /2 (xfx) 12, 18 bell /0 21
- =.. /2 (xfx) 18, 23 bigletter /1 19
- \== /2 (xfx) 12, 18 BNF 3
- < /2 (xfx) 12, 18 body 3, 6
- > /2 (xfx) 12, 18 BOOTER.TOY 37, 48
- >= /2 (xfx) 12, 18 bracket /1 20
- @=< /2 (xfx) 12, 18 bracket_term 4
- @< /2 (xfx) 12, 18 buffer, input 20
- @> /2 (xfx) 12, 18 bugs 48
-
- TOY Prolog ST 50 General index
-
-
- call 4, 44 end_of_line 5, 6, 19, 20
- CALL 9 eqvar /2 12
- call /1 27, 46 'e r r' 17
- CALL: 29, 48 error /1 8, 46
- call_list 44 escape /0 21
- CALL_LIST 9 EXIT: 29, 48
- CALLTREE 39
- capital_letter 5 fact 3; (in int. code) 44
- CHAR 9 fail /0 10
- character_group 5, 6 FAIL: 29, 48
- characters, single 19-21 FILENAME 9
- character string 5, 19 file streams 13-16
- CHAR_LIST 9 fill functions 35
- check /1 10 f_term 44
- clause 3, 24-27, 38, 44 F_TERM 9
- clause /2 25 full_stop 5, 6
- clause /5 24 function key assignment 16
- clear screen 21 functor 4, 44; fixed 46
- clock, access to 31 functor /3 22
- Clocksin & Mellish 3 functor_term 4
- cls /0 21
- command 4, 6, 7 get /1 (Prolog-10) 20
- command language 41 get0 /1 (Prolog-10) 20
- comment 5, 6, 47 'go.' 40
- condition 4 goal 7, 44
- consult /1 26; speed of 43 grammatical_rule 4, 30, 41,
- consultall /1 26; 7 47
- cut 27; see also ! graphic output 32-33
- cyclical data structures 6, graphics example 42
- 39 grf_arc /5 33
- grf_bar /4 33
- data bank 24-28 grf_box /4 33
- database, relational 41-42 grf_circle /3 33
- data streams 13-15 grf_clip /5 32
- date /3 31 grf_colour /4 32
- debug /0 29 grf_ellipse /4 33
- debug option 29 grf_f_colour /1 35
- definition 3 grf_fill /3 33
- delop /1 18 grf_f_perim /1 35
- descendant 27 grf_f_style /1 35
- digit 5 grf_f_type /1 35
- digit /1 19 grf_f_udpat /1 35
- directive 4, 6 grf_l_colour /1 33
- directory access 14-15 grf_l_ends /2 34
- disk_dir /1 14 grf_l_type /1 33
- disk error 15 grf_l_udstyle /1 33
- disk_search /2 15 grf_l_width /1 34
- disk_search /4 14-15 grf_m_colour /1 34
- display /1 17, 45 grf_m_height /1 34
- grf_mode /0 32
- ear /0 7, 8, 44, 46 grf_mse_form /1 35
- echo /0 16 grf_mse_form /5 35-36
- editor 38 grf_mse_hide /0 35
- 'end' 26, 38 grf_mse_show /1 35
-
- TOY Prolog ST 51 General Index
-
-
- grf_mse_state /3 36 markers 32, 34
- grf_m_type /1 34 member /1 31
- grf_pie /5 33 memory occupancy 31
- grf_pline /1 32 'midi' 13
- grf_pmarker /1 32 mod (arith. op., xfx) 11, 18
- grf_poly /1 32 'modem' 13
- grf_rbox /4 33 MONITOR.PRO 47
- grf_rfbox /4 33 mouse control 35-36
- grf_t_align /2 34
- grf_t_colour /1 34 name 44
- grf_t_effects /1 34 NAME 9
- grf_text /3 33 name /2 (Prolog-10) 22
- grf_t_height /1 34 'nextline' 47
- grf_t_point /1 34 nl /0 21
- grf_t_rotation /1 34 nodebug /0 29
- grf_wrmode /1 32 noecho /0 16
- nonexistent /0 29
- halt /1 28 nononexistent /0 30
- head 3 non_operator 4
- Help key 29, 39 non_terminal symbol 3, 4, 30
- nonvarint /1 21
- inner interpreter 7, 28, 43- nospy /2 30
- 47; syntax of 31, 37, 43-47 not /1 (fy) 10, 18
- integer 4 noughts and crosses 42
- INTEGER 9 number 44
- integer /1 21 numbered_variable 44-45
- integer, biggest 22 numbervars /1 31
- integers, arithmetic of 10 'numbervars' 45
- intermediate code 7, 43, 46-47 NUM_LIST 9
- interpreter, see inner i.,
- outer i. occurrence check 6, 39
- interpreter, construction of once /1 10
- 43 op /3 17-18
- interrupt 29 operator 4-6, 17-18
- interrupt /0 29 operator, mixed 5
- INTR: 29 operator notation 47
- is /2 (xfx) 11, 18 operator types 46
- isclosedlist /1 31 ordchr /2 19
- iseoln /1 19 outer interpreter 7, 28, 43-47
-
- 'keybd' 13, 16 parser 43
- Kluzniak & Szpakowicz 3 phrase /2 30
- pname /2 22
- lastch /1 20 pnamei /2 22
- last_char (input buffer) 20-21 pointer (in data bank) 27
- length /2 30; 23 precedence 4, 17-18
- less /2 11 predefined /2 25
- letter /1 19 predefined data stream 13
- line functions 32, 33-34 predefined operators 9
- list 4, 7, 47; functions predefined predicates 8, 46
- 30-31 'printer' 13
- listing /0 26 proc /1 26
- listing /1 26 prod /4 10-11
- loop /0 7, 43
-
- TOY Prolog ST 52 General index
-
-
- program, control of course of syntax 3-6; of inner inter-