2 '<expr>' [ DEFUN | DEFMACRO | DEFVAR | TERM ] * '</expr>'
4 TERM = [ INT | STRING | SYMBOL | LIST | ERROR | VAR | FUNCALL ]
7 '<defun fname="' FNAME ? ">'
13 '<defmacro fname="' FNAME ? ">'
19 '<args>' FIXED * OPTIONAL * REST ? '</args>'
22 '<fixed vname="' VNAME '">'
25 '<optional vname="' VNAME '">'
28 '<rest vname="' VNAME '">'
30 DEFVAR = DEFVAR-INT DEFVAR-STR DEFVAR-SYM
33 '<defvar vname="' VNAME '">'
35 [ INT POSSIBLE-INT-VALUE ? ] ?
39 <possible-value> [ INT | '<range>' INT INT '</range>' ] + </possible-value>
42 '<defvar vname"' VNAME '">'
44 [ STR DEFVAR-STR_VALUE ? ] ?
48 <possible-value> STR + </possible-value>
51 '<defvar vname"' VNAME '">'
53 [ SYMBOL POSSIBLE-SYM-VALUE ? ] ?
57 <possible-value> SYMBOL + </possible-value>
60 '<description>' [ TEXT | GETTEXT ] '</description>'
63 '<gettext>' TEXT '</gettext>'
66 '<integer>' INTEGER '</integer>'
68 '<string>' STRING '</string>'
70 '<symbol>' NAME '</symbol>'
72 '<list>' TERM * '</list>'
74 [ '<error>' | '<error ename="' ENAME '">"' ] STRING '</error>'
77 '<varref vname="' VNAME '"/>'
80 '<funcall fname="' FNAME '">' TERM * '</funcall>'
85 | AND | OR | NOT | EQ | NOTEQ | EQUAL | MATCH
87 | ADD | SUB | MUL | DIV | MOD
88 | LOGAND | LOGIOR | LOGXOR | LSH
89 | APPEND | CONCAT | LENGTH | NTH | COPY | INS | DEL
90 | PROGN | IF | WHEN | COND
91 | LOOP | WHILE | FOREACH | BREAK | RETURN | CATCH | THROW
94 ;; TERM contains an object, and is evaluated to a TERM as below.
95 ;; INT contains an integer, and is evaluated to itself .
96 ;; Two integers of the same value are regarded as the same object.
97 ;; STRING contains a string, and is evaluated to itself.
98 ;; SYMBOL contains a named symbol, and is evaluated to itself.
99 ;; Two symbols of the same name are reguarded as the same object.
100 ;; LIST contains a list and, is evaluated to itself.
101 ;; ERROR contains an error type symbol and an error message (optional).
102 ;; VARREF contains a variable, and is evalued to the value of that variable.
103 ;; FUNCALL contains a function and arguments to it, and is evalued to the
104 ;; value of function called with those arguments.
106 INTTERM = INT | VAR (value is INT) | FUNCALL (return INT)
107 STRTERM = STR | VAR (value is STR) | FUNCALL (return STR)
108 SYMTERM = SYMBOL | VAR (value is SYMBOL) | FUNCALL (return SYMBOL)
109 LISTTERM = LIST | VAR (value is LIST) | FUNCALL (return LIST)
112 ;; Here after, when an argument written as TERM, it is given to a
113 ;; function without being evaluted. Otherwise, an evaluated term is
114 ;; given. "the value is NUM" means "the value is
115 ;; <integer>NUM</integer>".
117 SET = '<set vname="' VNAME '">' XXXTERM '</set>'
119 ;; Set the value of the variable VNAME to XXXTERM, and the value is
122 ADD = '<add>' INTTERM + '</add>'
123 | '<add vname="' VNAME '">' INTTERM + '</add>'
124 SUB = '<sub>' INTTERM + '</sub>'
125 | '<sub vname="' VNAME '">' INTTERM + '</sub>'
126 MUL = '<mul>' INTTERM + '</mul>'
127 | '<mul vname="' VNAME '">' INTTERM + '</mul>'
128 DIB = '<div>' INTTERM + '</div>'
129 | '<div vname="' VNAME '">' INTTERM + '</div>'
130 MOD = '<mod>' INTTERM INTTERM '</mod>'
131 | '<mod vname="' VNAME '">' INTTERM '</div>'
132 LOGAND = '<logand> INTTERM + '</logand>'
133 | '<logand vname="' VNAME '">' INTTERM + '</logand>'
134 LOGIOR = '<logior> INTTERM + '</logior>'
135 | '<logior vname="' VNAME '">' INTTERM + '</logior>'
136 LOGXOR = '<logxor> INTTERM + '</logxor>'
137 | '<logxor vname="' VNAME '">' INTTERM + '</logxor>'
138 LSH = '<lsh>' INTTERM INTTERM '</lsh>'
139 | '<lsh vname="' VNAME '">' INTTERM '</mul>'
140 LT = '<lt>' INTTERM INTTERM '</lt>'
141 LE = '<le>' INTTERM INTTERM '</le>'
143 EQ = '<eq>' XXXTERM + '</eq>'
145 ;; If XXXTERMs have the same object, the value is 1. Otherwise the
148 NOTEQ = '<noteq>' XXXTERM XXXTERM '</noteq>'
150 ;; If XXXTERMs have the same object, the value is 0. Othersise the
153 GE = '<ge>' INTTERM INTTERM '</ge>'
154 GT ='<gt>' INTTERM INTTERM '</gt>'
156 APPEND = '<append>' XXXTERM + '</append>'
157 | '<append vname=" VNAME '">' XXXTERM + '</append>'
159 ;; In the first form, the value is a LIST made by concatinating all
160 ;; elements of XXXTERM (if it is a LIST) or XXXTERM itself (if it is
161 ;; not a LIST) in the specified order.
163 ;; In the second form, the value of the variable VNAME must be a LIST,
164 ;; and that LIST is modified destructively by concatinating ANYterms
165 ;; in the same manner as the previous case. The value is the
168 CONCAT = '<concat>' [ STRTERM | INTTERM | LISTTERM ] + '</concat>'
169 | '<concat vname=" VNAME '">' [ STRTERM | INTTERM | LISTTERM ] + '</concat>'
171 ;; In the first form, the value is a STR made by concatinating all
172 ;; strings made from the arguments as below:
173 ;; STRTERM gives a string contained in it.
174 ;; INTTERM gives a string of a character whose code is INTTERM's integer.
175 ;; LSTTERM must contain only INTTERMs, and give a string containing
176 ;; characters whose codes are INTTERM's integer.
178 ;; In the second form, the value of the variable VNAM must be a STR,
179 ;; and that STR is modified destructively by concatinating the
180 ;; arguments in the same manner as the previous case. The value is
181 ;; the resulting STR.
183 LENGTH = '<length>' [ STRTERM | LISTTERM ] '</length>'
184 NTH = '<nth>' INTTERM [ STRTERM | LISTTERM ] '</nth>'
185 COPY = '<copy>' LISTTERM '</nth>'
186 INS = '<ins vname="' VNAME '">' INTTERM [ STRTERM | LISTTERM ] '</ins>'
187 DEL = '<del vname="' VNAME '">' INTTERM INTTERM '</ins>'
189 AND = '<and>' TERM + '</and>'
191 ;; Evaluates TERMs one by one until one is evaluated to 0. If none is
192 ;; evaluated to 0, the value is 1. Othersise the value is 0.
194 OR = '<or>' TERM + '</or>'
196 ;; Evaluates TERMs one by one until one is evaluated not to 0. If
197 ;; none is evaluated not to 0, the value is 0. Othersise the value is
200 NOT = '<not>' XXXTERM '</not>'
202 ;; If XXX is 0, the value is 1. Othersise the value is 0.
204 EQUAL = '<equal>' XXXTERM1 XXXTERM2 '</equal>'
206 ;; If XXX1 equals to XXX2, the value is 1. Otherwise the value is 0.
207 ;; The equality of terms are decided as below:
208 ;; INT: INT1 equals to INT2 iff they contain the same integer values.
209 ;; STR: STR1 equals to STR2 iff they contain strings of the same characters.
210 ;; SYM: SYM1 equals to SSYM2 iff they contain the same symbol.
211 ;; LIST: LIST1 equals to LIST2 iff they have the same length, and
212 ;; the Nth element of LIST1 equals to the Nth element of LIST2.
214 MATCH = '<match>' XXXTERM1 XXXTERM2 <'/match>'
216 ;; If XXX1 matches with XXX2, the value is 1. Otherwise the value is
217 ;; 0. Two terms match as below:
218 ;; INT: INT1 matches with INT2 iff they contain the same integer values.
219 ;; STR: STR1 matches with STR2 iff STR1's string is a valid regular
220 ;; expression matching with STR2's string
221 ;; SYM: SYM1 matches with SSYM2 iff they contain the same symbol.
222 ;; LIST: LIST1 matches with LIST2 iff LIST1 is not longer than
223 ;; LIST2, and Nth element of LIST1 equals to Nth element of LIST2.
224 ;; ERROR: ERROR1 matches with ERROR2 iff ERROR1's error type is
225 ;; <symbol/> or is the same as ERROR2's error type.
227 PROGN = '<progn>' TERM * '</progn>'
228 IF = '<if>' TERM TERM TERM ? '</if>'
229 WHEN = '<when>' TERM TERM * '</when>'
230 COND = '<cond>' LIST + '</cond>'
231 LOOP = '<loop>' TERM + '</loop>'
232 WHILE = '<while>' TERM + '</while>'
233 FOREACH = '<foreach vname="' VNAME '">' TERM + '</foreach>'
234 BREAK = '<break>' TERM ? '</break>'
235 RETURN = '<return>' TERM ? '</return>'
236 QUOTE = '<quote>' TERM '</quote>'
238 CATCH = '<catch>' [ SYMBOL | ERROR ] TERM + '</catch>'
239 | '<catch vname="' VNAME '">' [ SYMBOL | ERROR ] TERM + '</catch>'
241 ;; Evaluate TERMs one by one until a term matching with the specified
242 ;; SYMBOL or ERROR is thrown by <throw/>. If thrown, the value is 1,
243 ;; otherwise the value is 0. If VNAME is specified, its value is set
244 ;; to the last evaluated term. It is the value of <throw/> if thrown.
246 THROW = '<throw>' SYMBOL XXXTERM ? '</throw>'
247 | '<throw>' ERROR '</throw>'
249 ;; Throw to the catch for SYMBOL or ERROR. The value is XXXTERM (if
250 ;; any) or SYMBOL in the first form, and ERROR in the second form.
252 EVAL = '<eval>' TERM '</eval>'
254 TYPE = '<type>' XXXTERM '</type>'
256 ;; The value is SYM representing the type of XXXTERM as below:
257 ;; INT: the type is <symbol>integer</symbol>
258 ;; STR: the type is <symbol>string</symbol>
259 ;; SYM: the type is <symbol>symbol</symbol>
260 ;; LIST: the type is <symbol>list</symbol>
261 ;; ERROR: the type is <symbol>error</symbol>