StatementInterpreterDoc.Tioga
Last Edited by: Spreitzer, January 7, 1985 2:00:04 pm PST
name StatementInterpreter
syntax
{ EnableClause DeclarationSeries StatementSeries ExitsClause}
Parse and interpret the command as a Cedar Block.
description
This is a command-line interface to an interpreter for a subset of the Cedar language. There is also a procedural interface (in StatementInterpreter.Mesa). This subset handles some of the Cedar statement constructs, and most of the expression constructs.
Currently, the expression subset is the same as you get with the left-arrow command (or the Interpreter.Mesa interface).
The following statement constructs are handled:
Statements that are expressions (e.g., assignment, call). A catch phrase in a call statement will be handled, but a catch phrase in call expression will not.
Blocks, including the EnableClause, DeclarationSeries, StatementSeries, and ExitsClause, but not the OpenClause.
Loops, also with the EnableClause, DeclarationSeries, StatementSeries, and LoopExitsClause, but not the OpenClause.
IF-THEN statements.
EXIT, LOOP, and GOTO statements.
Declarations (of things other than procedures) that use only type names, rather than more complicated type constructors.
Declarations of procedures whose names begin with "&", and which are given explicit type constructors, rather than type names.
To facilitate interacting development, the scoping rules have been slightly twisted. The top level scope of each command line is NOT nested inside the global scope of that command tool, but rather merged with it.
installation
Bringover the public part of StatementInterpreter.DF into ///Commands/. Included is StatementInterpreter.Load, which you should run with the current working directory set to commands:
& push ///Commands/
///Commands/
& Bringover -p [Indigo]<PostCedar5.2>Top>StatementInterpreter.DF
...
& @StatementInterpreter.Load
...
& pop
examples
& { i: INT ← 17701; {j: INT ← i - 834; i← j * j}}
& ← i
284495689
& ← j
Error: j: undefined
&
This example computes the sqare of 17701-834 the long way around. Note that "i" was added to the global scope, while "j" was not.
& { l: List; FOR l ← long, l.rest WHILE l # NIL DO IF l.first.key = goal THEN EXIT ENDLOOP}
This example searches a list for an element distinguished by a certain value.
warnings
The declarations in a block are processed serially, rather than "in parallel". This is one of the few differences from the language defined by the compiler.
The procedures are made with the EvalQuote hack, and thus aren't really procedure values that you can hand off to real Cedar code (are you listening, Eric Nickell?).
Because of a bad interaction between scoping and &-variables, assignments to &-variables in a nested scope will not be visible outside that scope.
stop/undo
STOP! button in the menu of the comand tool.
implementation
SIPackage.Config in StatementInterpreter.DF
contact
Spreitzer.pa
keyword hints
interpreter interpret statement Cedar language interactive evaluate
keywords
to be supplied by the Index Czar at the appropriate time in the future