Running programs in Louden's Sample language
The program 'runSample' in our class directory can be used to compile and execute programs written in Louden's Sample language. This is a Prolog program, so start Prolog, and consult this file. Then to execute a program, enter the query 'go.'. You will be prompted for the pathname of a file containing a program in the Sample language, and this program will be scanned, compiled, and executed. The simple syntax should make finding errors easy, since the main error message is "no".
This program recognizes the following three additional statements not indicated in Louden:
* read identifier -- this prompts for an (integer) value that is typed on the keyboard with terminating '.', and assigns it to identifier
* write expr -- this prints the value of expr
* skip -- this command does nothing
You are encouraged to explore this program as an advanced Prolog example. It provides some illustrations of Prolog programming (as opposed to logic) facilities. Most notable are general file I/O, and Definite Clause Grammars, DCGs. DCGs allow us to enter BNF productions (more general in fact) directly into Prolog, and Prolog automatically generates the clauses to parse and build derivation trees.