"Constructive" expressions -- i.e., using only constructively defined types and ops -- can be evaluated directly from the Specware Shell. Evaluating an expression requires a "context" to be set, which is a spec containing the definitions of the relevant types and ops. For example, in the context of
spec
def f x = 2*x+1
def u = 6172
endspec |
The evaluation context can be set by the shell command
ctext [spec-term] |
Once a context has been set, a Metaslang expression can be evaluated by:
eval [expression] |
The command eval may be abbreviated to e.
Instead of using the built-in Metaslang interpreter, it is also possible to evaluate Metaslang expressions from the Specware Shell command line as translated into Lisp. Unless no user-defined types and ops are used (as in the expression 2+2), this requires that Lisp code has already been generated for the context spec (see the Section called Generating Lisp Code) and that the Lisp file has been loaded (see the Section called Auxiliary Commands for Lisp). The command is:
eval-lisp [expression] |