InterpDoc.tioga
Copyright Ó 1990 by Xerox Corporation. All rights reserved.
Demers, January 30, 1990 5:11:26 pm PST
THE INTERIM CEDAR INTERPRETER
THE INTERIM CEDAR INTERPRETER
PCEDAR 2.0 —
PCEDAR 2.0 —
Interim Cedar Interpreter
© Copyright 1990 Xerox Corporation. All rights reserved.
Abstract: This document is a user's guide for the Interim Interpreter in PCedar 2.0.
XEROX Xerox Corporation
Palo Alto Research Center
3333 Coyote Hill Road
Palo Alto, California 94304
News
This package is new, and probably will be replaced by Cirio facilities in the very near future, but for now I couldn't live without something like this. (January 30, 1990)
Bugs
This package is written almost entirely in C.
The main source file, Interp.c, lives in the interp subdirectory of /pseudo/xrhome, and is not under df control.
There's a reasonable program interface (near the end of Interp.c) but no header file describing it.
Undoubtedly many other bugs.
Synopsis
Interp <expression> [ ; <expression> ] ...
Description
This is a quick-and-dirty prefix expression interpreter patterned inspired by (but nowhere near as sophisticated as) the D-machine expression interpreter. It has &-variables, the ability to examine and modify storage using a few primitive (C) data types, the ability to call procedures, and a few other goodies described below. The interpreter variable space is shared among all command tools; this is a feature that I might be talked out of.
The effect of an Interp command is to evaluate the given sequence of expressions and assign the rightmost one to a new interpreter variable.
The syntax of expressions is very primitive. All tokens must be separated by spaces (it's a really dumb scanner). The following description is excerpted from the source code:
<expression> ::= <number>
Evaluates the number.
Legal numeric constants include 17, 010, 0x5c, but NOT -3
<expression> ::= <string>
Evaluates the string.
Legal string constants include "foo", "bar", but NOT "hello\n".
<expression> ::= <char>
Evaluates the character.
Legal char constants include 'x', '0', but NOT `\n`.
<expression> ::= @ <expression1> <expression2>
Evaluates the expressions, prints the value of <expression2> according
to the type of <expression1>.
Example: interp @ "" 0x126a4c might be used to pring a string.
<expression> ::= <binop> <expression1> <expression2>
Evaluates the <expression>s, combines them according to <op>.
Recognized <op>s are +, -, *, /.
<expression> ::= ^ <expression>
Evaluates the <expression>, interprets it as an address and returns
the word value stored there.
<expression> ::= < <variable> <expression>
Assign the value of <expression> to the specified interpreter <variable>
<expression> ::= [ <expression0> <expression1> ... <expressionk> ]
Function call: <expression0> should evaluate to the address of a function;
that function is called in a separate thread with the values of
<expression1> ... <expressionk> as arguments. The call times out after
awhile; the timeout interval (in msec) is controlled by the global variable
interpCallTimeout, which can be changed using the interpreter ...
<expression> ::= [! <expression0> <expression1> ... <expressionk> ]
[! is just like [ except the call is done in the interpreter's thread,
and can never time out.
<expression> ::= <variable>
An interpreter variable, which may be assigned to or evaluated.
Undefined variables are initially 0.
<expression> := <symbol>
The value of an external symbol in the loadstate. Numerous grotty
heuristics are applied during symbol lookup, such as appending a leading
underscore for C externals. For example,
pcr: interp XR←Msg
&11: 0x1a4f0 ...
The loadstate keeps internal text symbols, but not internal data or bss
symbols.
<expression> ::= <symbol>.<symbol>
The first symbol is expected to be a file or module name, the second
to be a text in that module. As above, heuristics are applied to
the file/module name (appending ".o") and the text symbol (prepending
an underscore, and some really arcane transformations related to the
procedure names generated by our Cedar/Mesa to C compiler). Example:
pcr: interp Interp.XR←GetSaveForInterp
&12: 0x60bf08 ...
An expression like this usually appears in the function position of a
call.
<variable> ::= &<number>
The result of each eval call is stored in a numbered variable, which
is accessible in later calls.
<variable> ::= &<symbol>
Variables can be named as well as numbered. Example:
interp + < &foo 17 &foo
&13: 34 ...
Note that foo is assigned to before it's evaluated ...
<variable> ::= &
& is the name of the most-recently-created numeric interpreter variable.
There are also a few built-in procedures intended to be called from the interpreter. These include:
interp [ wpoke addr word1 ... wordk ]
-- store word1 ... wordk in conscutive locations starting at addr
interp [ bpoke addr byte1 ... bytek ]
-- store byte1 ... bytek in conscutive locations starting at addr
interp [ wpeek addr nwords ]
-- print contents of nwords memory words starting at addr
interp [ bpeek addr nbytes ]
-- print contents of nbytes memory bytes starting at addr
interp [ XR𡤌harStarFromRope <rope-valued-expression> ]
-- convert a Cedar ROPE to a Unix string
interp [ XR𡤌harStarFromRope <string-valued-expression> ]
-- convert a Unix string to a Cedar ROPE