StatementInterpreterDoc.tioga
Spreitzer, May 10, 1986 4:39:28 pm PDT
StatementInterpreter
CEDAR 6.0 — FOR INTERNAL XEROX USE ONLY
StatementInterpreter
Mike Spreitzer
© Copyright 1985 Xerox Corporation. All rights reserved.
Abstract: The StatementInterpreter extends the Cedar interpreter's capabilities into the world of statements.
Keywords: Interpreter, Cedar, Statement, Interactive, Evaluate
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
1. StatementInterpreter
The StatementInterpreter implements one command-tool command, whose name is "{" (left curly brace):
name StatementInterpreter
syntax
{ OpenClause 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). Catch phrases in them will be handled.
Blocks, including the OpenClause, EnableClause, DeclarationSeries, StatementSeries, and ExitsClause.
Loops, also with the OpenClause, EnableClause, DeclarationSeries, StatementSeries, and LoopExitsClause.
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.
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/. Currently, FS won't allow a .load file named {.load, so you have to explicitly invoke StatementInterpreter.load:
& push ///Commands/
///Commands/
& Bringover -p [Cedar]<CedarChest6.0>Top>StatementInterpreter.DF
...
& pop
...
& StatementInterpreter
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 sometimes made with the EvalQuote hack, and thus aren't really procedure values that you can hand off to real Cedar code.
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