X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=xex.txt;h=055a0ebf768d46aa0afe8baae08cf394f5cbf97b;hb=1886ee749147f8dd59897f13a3f4501ff483565a;hp=609284751f6183ad734a8d43fb6fd37e90c0d2cb;hpb=b4d84e254382583a716e778edbc3884bf2d9c9bd;p=m17n%2Fm17n-lib-cs.git
diff --git a/xex.txt b/xex.txt
index 6092847..055a0eb 100644
--- a/xex.txt
+++ b/xex.txt
@@ -1,97 +1,260 @@
EXPR =
'' [ DEFUN | DEFMACRO | DEFVAR | TERM ] * ''
-TERM = [ VAR | DIRECT | FUNCALL ]
-
-TYPE = 'integer' | 'string' | 'boolean' | 'symbol' | 'list'
+TERM = [ INT | STRING | SYMBOL | LIST | ERROR | VARREF | FUNCALL ]
DEFUN =
- ''
+ ''
ARGS ?
TERM *
''
DEFMACRO =
- ''
+ ''
ARGS ?
TERM *
''
ARGS =
- '' SYMBOL * '' | ''
+ '' FIXED * OPTIONAL * REST ? ''
+
+FIXED =
+ ''
+
+OPTIONAL =
+ ''
-DEFVAR = DEFVAR-INT DEFVAR-STR DEFVAR-BOOL
+REST =
+ ''
+
+DEFVAR = DEFVAR-INT | DEFVAR-STR | DEFVAR-SYM
DEFVAR-INT =
- ''
+ ''
DESCRIPTION ?
- INT ?
- [ INT | '' INT INT '' ] *
+ [ INT POSSIBLE-INT-VALUE ? ] ?
''
+POSSIBLE-INT-VALUE =
+ [ INT | '' INT INT '' ] +
+
DEFVAR-STR =
- ''
+ ''
DESCRIPTION ?
- STR ?
- STR *
+ [ STR DEFVAR-STR_VALUE ? ] ?
''
-DEFVAR-BOOL =
- ''
+DEFVAR-STR_VALUE =
+ STR +
+
+DEFVAR-SYM =
+ ''
DESCRIPTION ?
- BOOL ?
- BOOL
+ [ SYMBOL POSSIBLE-SYM-VALUE ? ] ?
''
-DESCRIPTION =
- '' TEXT ''
+POSSIBLE-SYM-VALUE =
+ SYMBOL +
-VAR =
- ''
+DESCRIPTION =
+ '' [ TEXT | GETTEXT ] ''
-DIRECT = INT STR BOOL SYMBOL LIST
+GETTEXT =
+ '' TEXT ''
INT =
- '' INTEGER ''
+ '' INTEGER ''
STR =
- '' STRING ''
-BOOL =
- '' [ 'true' | 'false' ]
+ '' STRING ''
SYMBOL =
- '' NAME ''
+ '' NAME ''
LIST =
- '' DIRECT * '' |
+ '' TERM * '
'
+ERROR =
+ [ '' | '"' ] STRING ''
+
+VARREF =
+ ''
FUNCALL =
- '' TERM * ''
- | '' TERM * ''
- | '' TERM * ''
- | '<' PREDEFINED-FUNC-SYMBOL '>' TERM * '' PREDEFINED-FUNC-SYMBOL '>'
- | '<' PREDEFINED-MACRO-SYMBOL '>' TERM * '' PREDEFINED-MACRO-SYMBOL '>'
-
-PREDEFINED-FUNC-SYMBOL =
- 'set'
- | 'and' | 'or' | 'not'
- | 'lt' | 'le' | 'eq' | 'ge' | 'gt'
- | 'noteq'
- | 'add' | 'sub' | 'mul' | 'div' | 'mod'
- | 'add-set' | 'sub-set' | 'mul-set' | 'div-set' | 'mod-set'
- | 'logand' | 'logior' | 'logxor' | 'lsh'
- | 'logand-set' | 'logior-set' | 'logxor-set' | 'lsh-set'
- | 'append' | 'concat' | 'substr'
- | 'cons' | 'car' | 'cdr' | 'nth'
-
-PREDEFINED-FUNC-NAME =
- PREDEFINED-FUNC-SYMBOL
- | '='
- | '&&' | '||' | '!'
- | '<' | '<=' | '==' | '>=' | '>'
- | '!='
- | '+' | '-' | '*' | '/' | '%'
- | '+=' | '-=' | '*=' | '/=' | '%='
- | '&=' | '|=' | '~=' | '<<=' | '>>='
-
-PREDEFINED-MACRO-SYMBOL =
- 'case' | 'cond' | 'if' | 'progn' | 'when' | 'while'
-
-PREDEFINED-MACRO-NAME = PREDEFINED-MACRO-SYMBOL
+ '' TERM * ''
+ | PREDEFINED
+
+PREDEFINED =
+ SET
+ | AND | OR | NOT | EQ | NOTEQ | EQUAL | MATCH
+ | LT | LE | GE | GT
+ | ADD | SUB | MUL | DIV | MOD
+ | LOGAND | LOGIOR | LOGXOR | LSH
+ | APPEND | CONCAT | LENGTH | NTH | COPY | INS | DEL
+ | PROGN | IF | WHEN | COND
+ | LOOP | WHILE | FOREACH | BREAK | RETURN | CATCH | THROW
+ | QUOTE | EVAL | TYPE
+
+;; TERM contains an object, and is evaluated to a TERM as below.
+;; INT contains an integer, and is evaluated to itself .
+;; Two integers of the same value are regarded as the same object.
+;; STRING contains a string, and is evaluated to itself.
+;; SYMBOL contains a named symbol, and is evaluated to itself.
+;; Two symbols of the same name are reguarded as the same object.
+;; LIST contains a list and, is evaluated to itself.
+;; ERROR contains an error type symbol and an error message (optional).
+;; VARREF contains a variable, and is evalued to the value of that variable.
+;; FUNCALL contains a function and arguments to it, and is evalued to the
+;; value of function called with those arguments.
+
+INTTERM = INT | VAR (value is INT) | FUNCALL (return INT)
+STRTERM = STR | VAR (value is STR) | FUNCALL (return STR)
+SYMTERM = SYMBOL | VAR (value is SYMBOL) | FUNCALL (return SYMBOL)
+LISTTERM = LIST | VAR (value is LIST) | FUNCALL (return LIST)
+XXXTERM = TERM
+
+;; Here after, when an argument written as TERM, it is given to a
+;; function without being evaluted. Otherwise, an evaluated term is
+;; given. "the value is NUM" means "the value is
+;; NUM".
+
+SET = '' XXXTERM ''
+
+;; Set the value of the variable VNAME to XXXTERM, and the value is
+;; XXXTERM.
+
+ADD = '' INTTERM + ''
+ | '' INTTERM + ''
+SUB = '' INTTERM + ''
+ | '' INTTERM + ''
+MUL = '' INTTERM + ''
+ | '' INTTERM + ''
+DIB = '' INTTERM + '
'
+ | '' INTTERM + '
'
+MOD = '' INTTERM INTTERM ''
+ | '' INTTERM ''
+LOGAND = ' INTTERM + ''
+ | '' INTTERM + ''
+LOGIOR = ' INTTERM + ''
+ | '' INTTERM + ''
+LOGXOR = ' INTTERM + ''
+ | '' INTTERM + ''
+LSH = '' INTTERM INTTERM ''
+ | '' INTTERM ''
+LT = '' INTTERM INTTERM ''
+LE = '' INTTERM INTTERM ''
+GE = '' INTTERM INTTERM ''
+GT ='' INTTERM INTTERM ''
+
+EQ = '' XXXTERM + ''
+
+;; If XXXTERMs have the same object, the value is 1. Otherwise the
+;; value is 0.
+
+NOTEQ = '' XXXTERM XXXTERM ''
+
+;; If XXXTERMs have the same object, the value is 0. Othersise the
+;; value is 1.
+
+APPEND = '' XXXTERM + ''
+ | '' XXXTERM + ''
+
+;; In the first form, the value is a LIST made by concatinating all
+;; elements of XXXTERM (if it is a LIST) or XXXTERM itself (if it is
+;; not a LIST) in the specified order.
+
+;; In the second form, the value of the variable VNAME must be a LIST,
+;; and that LIST is modified destructively by concatinating ANYterms
+;; in the same manner as the previous case. The value is the
+;; resulting LIST.
+
+CONCAT = '' [ STRTERM | INTTERM | LISTTERM ] + ''
+ | '' [ STRTERM | INTTERM | LISTTERM ] + ''
+
+;; In the first form, the value is a STR made by concatinating all
+;; the strings made from the arguments as below:
+;; STRTERM gives a string contained in it.
+;; INTTERM gives a string of a character whose code is INTTERM's integer.
+;; LISTTERM must contain only INTTERMs, and give a string containing
+;; characters whose codes are INTTERM's integer.
+
+;; In the second form, the value of the variable VNAME must be a STR,
+;; and that STR is modified destructively by concatinating the
+;; arguments in the same manner as the previous case. The value is
+;; the resulting STR.
+
+LENGTH = '' [ STRTERM | LISTTERM ] ''
+NTH = '' INTTERM [ STRTERM | LISTTERM ] ''
+COPY = '' [ STRTERM | LISTTERM ] ''
+INS = '' INTTERM [ STRTERM | LISTTERM ] ''
+DEL = '' INTTERM INTTERM ''
+
+AND = '' TERM + ''
+
+;; Evaluates TERMs one by one until one is evaluated to 0. If none is
+;; evaluated to 0, the value is 1. Othersise the value is 0.
+
+OR = '' TERM + ''
+
+;; Evaluates TERMs one by one until one is evaluated not to 0. If
+;; none is evaluated not to 0, the value is 0. Othersise the value is
+;; 1.
+
+NOT = '' XXXTERM ''
+
+;; If XXX is 0, the value is 1. Othersise the value is 0.
+
+EQUAL = '' XXXTERM1 XXXTERM2 ''
+
+;; If XXX1 equals to XXX2, the value is 1. Otherwise the value is 0.
+;; The equality of terms is decided as below:
+;; INT: INT1 equals to INT2 iff they contain the same integer values.
+;; STR: STR1 equals to STR2 iff they contain strings of the same characters.
+;; SYM: SYM1 equals to SSYM2 iff they contain the same symbol.
+;; LIST: LIST1 equals to LIST2 iff they have the same length, and
+;; the Nth element of LIST1 equals to the Nth element of LIST2.
+
+MATCH = '' XXXTERM1 XXXTERM2 <'/match>'
+
+;; If XXX1 matches with XXX2, the value is 1. Otherwise the value is
+;; 0. Two terms match as below:
+;; INT: INT1 matches with INT2 iff they contain the same integer values.
+;; STR: STR1 matches with STR2 iff STR1's string is a valid regular
+;; expression matching with STR2's string
+;; SYM: SYM1 matches with SSYM2 iff they contain the same symbol.
+;; LIST: LIST1 matches with LIST2 iff LIST1 is not longer than
+;; LIST2, and Nth element of LIST1 equals to Nth element of LIST2.
+;; ERROR: ERROR1 matches with ERROR2 iff ERROR1's error type is
+;; or is the same as ERROR2's error type.
+
+PROGN = '' TERM * ''
+IF = '' TERM TERM TERM ? ''
+WHEN = '' TERM TERM * ''
+COND = '' LIST + ''
+LOOP = '' TERM + ''
+WHILE = '' TERM + ''
+FOREACH = '' [STRTERM | LISTTERM] TERM + ''
+BREAK = '' TERM ? ''
+RETURN = '' TERM ? ''
+QUOTE = '' TERM '
'
+
+CATCH = '' [ SYMBOL | ERROR ] TERM + ''
+ | '' [ SYMBOL | ERROR ] TERM + ''
+
+;; Evaluate TERMs one by one until a term matching with the specified
+;; SYMBOL or ERROR is thrown by . If thrown, the value is 1,
+;; otherwise the value is 0. If VNAME is specified, its value is set
+;; to the last evaluated term. It is the value of if thrown.
+
+THROW = '' SYMBOL XXXTERM ? ''
+ | '' ERROR ''
+
+;; Throw to the catch for SYMBOL or ERROR. The value is XXXTERM (if
+;; any) or SYMBOL in the first form, and ERROR in the second form.
+
+EVAL = '' TERM ''
+
+TYPE = '' XXXTERM ''
+
+;; The value is SYM representing the type of XXXTERM as below:
+;; INT: the type is integer
+;; STR: the type is string
+;; SYM: the type is symbol
+;; LIST: the type is list
+;; ERROR: the type is error