306 lines
106 KiB
Plaintext
306 lines
106 KiB
Plaintext
Copyright (c) 1986 Xerox Corporation. All rights reserved.
|
||
|
||
2
|
||
|
||
21.9 CLISP Internal Conventions
|
||
1
|
||
|
||
CLISP is almost entirely table driven by the property lists of the corresponding infix or prefix operators. For example, much of the information used for translating the + infix operator is stored on the property list of the litatom "+". Thus it is relatively easy to add new infix or prefix operators or change old ones, simply by adding or changing selected property values. (There is some built in information for handling minus, :, ', and ~, i.e., the user could not himself add such "special" operators, although he can disable or redefine them.)
|
||
Global declarations operate by changing the LISPFN and CLISPINFIX properties of the appropriate operators.
|
||
CLISPTYPE [Property Name]
|
||
1
|
||
|
||
The property value of the property CLISPTYPE is the precedence number of the operator: higher values have higher precedence, i.e., are tighter. Note that the actual value is unimportant, only the value relative to other operators. For example, CLISPTYPE for :, ^, and * are 14, 6, and 4 respectively. Operators with the same precedence group left to right, e.g., / also has precedence 4, so A/B*C is (A/B)*C.
|
||
An operator can have a different left and right precedence by making the value of CLISPTYPE be a dotted pair of two numbers, e.g., CLISPTYPE of _ is (8 . -12). In this case, CAR is the left precedence, and CDR the right, i.e., CAR is used when comparing with operators on the left, and CDR with operators on the right. For example, A*B_C+D is parsed as A*(B_(C+D)) because the left precedence of _ is 8, which is higher than that of *, which is 4. The right precedence of _ is -12, which is lower than that of +, which is 2.
|
||
If the CLISPTYPE property for any operator is removed, the corresponding CLISP transformation is disabled, as well as the inverse CLISPIFY transformation.
|
||
1
|
||
|
||
UNARYOP [Property Name]
|
||
1
|
||
|
||
The value of property UNARYOP must be T for unary operators or brackets. The operand is always on the right, i.e., unary operators or brackets are always prefix operators.
|
||
1
|
||
|
||
BROADSCOPE [Property Name]
|
||
1
|
||
|
||
The value of property BROADSCOPE is T if the operator has lower precedence than Interlisp forms, e.g., LT, EQUAL, AND, etc. For example, (FOO X AND Y) parses as ((FOO X) AND Y). If the BROADSCOPE property were removed from the property list of AND, (FOO X AND Y) would parse as (FOO (X AND Y)).
|
||
1
|
||
|
||
LISPFN [Property Name]
|
||
1
|
||
|
||
The value of the property LISPFN is the name of the function to which the infix operator translates. For example, the value of LISPFN for ^ is EXPT, for ' QUOTE, etc. If the value of the property LISPFN is NIL, the infix operator itself is also the function, e.g., AND, OR, EQUAL.
|
||
1
|
||
|
||
SETFN [Property Name]
|
||
1
|
||
|
||
If FOO has a SETFN property FIE, then (FOO --)_X translates to (FIE -- X). For example, if the user makes ELT be an infix operator, e.g. #, by putting appropriate CLISPTYPE and LISPFN properties on the property list of # then he can also make # followed by _ translate to SETA, e.g., X#N_Y to (SETA X N Y), by putting SETA on the property list of ELT under the property SETFN. Putting the list (ELT) on the property list of SETA under property SETFN will enable SETA forms to CLISPIFY back to ELT's.
|
||
1
|
||
|
||
CLISPINFIX [Property Name]
|
||
1
|
||
|
||
The value of this property is the CLISP infix to be used in CLISPIFYing. This property is stored on the property list of the corresponding Interlisp function, e.g., the value of property CLISPINFIX for EXPT is ^, for QUOTE is ' etc.
|
||
1
|
||
|
||
CLISPWORD [Property Name]
|
||
1
|
||
|
||
Appears on the property list of clisp operators which can appear as CAR of a form, such as FETCH, REPLACE, IF, iterative statement operators, etc. Value of property is of the form (KEYWORD . NAME), where NAME is the lowercase version of the operator, and KEYWORD is its type, e.g. FORWORD, IFWORD, RECORDWORD, etc.
|
||
KEYWORD can also be the name of a function. When the atom appears as CAR of a form, the function is applied to the form and the result taken as the correct form. In this case, the function should either physically change the form, or call CLISPTRAN (("CLISPTRAN" . Function)) to store the translation.
|
||
1
|
||
|
||
As an example, to make & be an infix character operator meaning OR, the user could do the following:
|
||
_(PUTPROP '& 'CLISPTYPE (GETPROP 'OR 'CLISPTYPE))
|
||
_(PUTPROP '& 'LISPFN 'OR)
|
||
_(PUTPROP '& 'BROADSCOPE T)
|
||
_(PUTPROP 'OR 'CLISPINFIX '&)
|
||
_(SETQ CLISPCHARS (CONS '& CLISPCHARS))
|
||
_(SETQ CLISPCHARRAY (MAKEBITTABLE CLISPCHARS))
|
||
|