contents index next

13. The Command Interpreter

The FSA command interpreter provides line-based interaction with the FSA functionality. The command interpreter provides a history mechanism, escape to the operating system, escape to Prolog and on-line help information. All startup options for fsa are also available as commands in the command interpreter.

13.1. Syntax

A command is typed in by the user as one line of text; it's tokenized as a sequence of `words', where spaces and tabs are treated as separators. Each word is treated as an atomic (Prolog atom or Prolog integer), unless it is written within { and }. In the latter case the `word' is parsed as a Prolog term (in the latter case spaces and tabs are not interpreted as separators).

|: flag jan jan(a,b,c)

is equivalent to the Prolog goal

?- fsa_globals:fsa_global_set(jan,'jan(a,b,c)')


|: flag jan {jan(a,b,c)}

is equivalent to the Prolog goal

?- fsa_globals:fsa_global_set(jan,jan(a,b,c))

Variables occuring in such terms have scope over the full command-line!

13.2. Alias and History

The command-interpreter has an alias mechanism which subsumes a history mechanism as well. All occurences of $word are replaced by the definition of the alias word. The alias command itself can be used to define aliases:

19 |: alias hallo ! cat hallo
20 |: $hallo

so command number 20 will have the same effect as typing

33 |: ! cat hallo

and if this command had indeed been typed as command number 33 then typing

35 |: $33

gives also the same result. The special meaning of $ can be turned off by prefixing it with another $, e.g.:

|: cd $$HOME

Moreover, if no alias has been defined, then it will apply the last command that started with the name of the alias:

66 |: parse john kisses mary
67 |: $parse

will have the same meaning (in this order) if the macro parse is not defined.

13.3. Prolog goals

It is also possible to issue Prolog commands; however some restrictions apply.

39 |: p {member(X,[X|T])}

Note that this may succeed, but 'yes' or 'no' and variable bindings will NOT be printed.

13.4. Starting and Stopping the command interpreter

If no action option is provided, then the system runs in interactive mode. If the variable interpreter is set to on, then fsa runs in interactive mode after the action indicated by the action option has been performed. If the flag interactive has been set to cmdint, then fsa runs the FSA command interpreter. The command interpreter can be started any time from the Prolog prompt using the command r/0:

| ?- r.
*** Welcome to the FSA Command Interpreter (type ? for help) ***
5 |:

You can stop the command interpreter using the p command:

5 |: p
*** execution interrupted ***
| ?-

You can quit FSA entirely using the quit command. Note that you can also use the command interpreter together with the graphical user interface.

13.5. p[rolog]

Stops the command interpreter.

13.6. % Words

ignores Words (comment). Note that there needs to be a space after %.

13.7. fc Files


13.8. um Files


13.9. el Files


13.10. c Files


13.11. rc Files


13.12. ld Files


13.13. libum Files

for each File, use_module(library(File)).

13.14. librc Files

for each File, reconsult(library(File)).

13.15. libc Files

for each File, compile(library(File)).

13.16. libel Files

for each File, ensure_loaded(library(File)).

13.17. libld Files

for each File, load(library(File)).

13.18. version

displays version information.

13.19. quit

quits FSA.

13.20. b

break; enters Prolog prompt at next break level.

13.21. d


13.22. nd


13.23. p [Goal]

without Goal: quits command interpreter -- falls back to Prolog prompt with Goal: calls Goal. Normally you will need {} around the Goal. For example:

4 |: p { member(X,[a,b,c]), write(X), nl }

13.24. ! Command

Command is executed by the shell. Note that the space between ! and Command is required.

13.25. alias [Name [Val]]

No args: lists all aliases; one arg: displays alias Name; two args: defines an alias Name with meaning Val.

13.26. help [Module [Class [Key]]]

displays help on Module-Class-Key; use ? to get help on commands only.

13.27. ? [Cmd]

displays help on Cmd; without Cmd prints list of commands.

13.28. spy [Module] Pred

set spypoint on Module:Pred; Pred can either be Fun or Fun/Ar.

13.29. cd [Dir]

change working directory to Dir; without argument cd to home directory.

13.30. pwd

print working directory.

13.31. ls

listing of directory contents

13.32. <any FSA startup option>

Any valid option you can give to the fsa command is a valid command for the command interpreter. For instance:

|: -d a.nd a.d
|: -m a.d a.m
|: -aux File
|: -tk
|: -r [[a,b]+,c]+

contents index next