20.3 Interpreting Commands from a File
For all practical purposes, any interpreter is pretty useless if it only
works interactively. I have added a `source' built-in command to
`sic_builtin.c' which takes lines of input from a file and
evaluates them using `sic_repl.c' in much the same way as lines
typed at the prompt are evaluated otherwise. Here is the built-in handler:
And the source function from `sic_repl.c':
The reason for separating the source function in this way, is
that it makes it easy for the startup sequence in main to
evaluate a startup file. In traditional Unix fashion, the startup file
is named `.sicrc', and is evaluated if it is present in the user's
home directory:
|