自从做好了
Vczh Free Script之后,对于λ-calculus的热情还在,对于未实现lazy evaluation也耿耿于怀。因此又设计了一门类似Haskell的语言来(在语法上模仿了不少),本意是既能享受到lazy evaluation所带来的优美的表现形式,又能将这门语言当脚本而不是单纯的程序语言使用。不过将来会演变成什么就暂时不管了。现在贴出该语言的语法的形式描述,做备忘录之用,或有恳请同行斧正之意。
LAZY_PROGRAM is
MODULE_DECLARATION
--------------------------------------
MODULE_DECLARATION is
module MODULE_NAME exports {FUNCTION_NAME}+ where {DECLARATION}+ end;
DECLARATION is
MODULE_DECLARATION
IMPORT_DECLARATION
TYPE_DECLARATION
CLASS_DECLARATION
INSTANE_DECLARATION
FUNCTION_HEAD_DECLARATION
FUNCTION_BODY_DECLARATION
--------------------------------------
IMPORT_DECLARATION is
import MODULE_NAME{.MODULE_NAME};
--------------------------------------
TYPE_DECLARATION is
type TYPE_NAME {TYPE_NAME}[= TYPE_DESCRIPTION];
SIMPLE_TYPE_DESCRIPTION is
"(" TYPE_DESCRIPTION ")"
TYPE_NAME
TYPE_DESCRIPTION is
"(" TYPE_DESCRPTION ")"
TYPE_NAME {SIMPLE_DESCRIPTION}
TYPE_CONSTRUCTOR {SIMPLE_TYPE_DESCRIPTION}+
TYPE_DESCRIPTION -> TYPE_DESCRIPTION
TYPE_DESCRIPTION "|" TYPE_DESCRIPTION
--------------------------------------
CLASS_DECLARATION is
class CLASS_NAME TYPE_NAME [inherits {CLASS_NAME}+] where {FUNCTION_HEAD_DECLARATION|FUNCTION_BODY_DECLARATION}+ end;
--------------------------------------
INSTANCE_DECLARATION is
instance CLASS_NAME TYPE_NAME [where {FUNCTION_BODY_DECLARATION}+ end];
--------------------------------------
FUNCTION_HEAD_DECLARATION is
FUNCTION_NAME :: {PREREQUISITE,}TYPE_DESCRIPTION;
PREREQUISITE is
[CLASS_NAME] TYPE_NAME
FUNCTION_BODY_DECLARATION is
FUNCTION_NAME {LEFT_VALUE} = (EXPRESSION | linking <string>);
--------------------------------------
LEFT_VALUE is
VALUE_NAME
LEFT_VALUE:VALUE_NAME
"(" LEFT_VALUE{,LEFT_VALUE} ")"
"[" [LEFT_VALUE{,LEFT_VALUE}] "]"
TYPE_CONSTRUCTOR {LEFT_VALUE}+
"(" LEFT_VALUE ")"
EXPRESSION is
VALUE
VALUE_NAME
EXPRESSION:EXPRESSION
"(" EXPRESSION{,EXPRESSION} ")"
"[" [EXPRESSION{,EXPRESSION}] "]"
TYPE_CONSTRUCTOR {EXPRESSION}+
EXPRESSION EXPRESSION
"(" OPERATOR_NAME EXPRESSION ")"
"(" EXPRESSION OPERATOR_NAME ")"
FUNCTION_NAME
EXPRESSION OPERATOR EXPRESSION
"[" EXPRESSION "|" [[LEFT_VALUE <- ]EXPRESSION{,[LEFT_VALUE <- ]EXPRESSION}] "]"
case EXPRESSION of {LEFT_VALUE:EXPRESSION}+ end
do {([LEFT_VALUE = ]EXPRESSION | LEFT_VALUE::TYPE_DESCRIPTION);}+ end
EXPRESSION [where {FUNCTION_HEAD_DECLARATION | FUNCTION_BODY_DECLARATION}+ end]
\{LEFT_VALUE}+ -> "(" EXPRESSION ")"
--------------------------------------
MODULE_NAME is
<identifier>
FUNCTION_NAME is
<identifier>
"(" OPERATOR ")"
TYPE_NAME is
<identifier>
TYPE_CONSTRUCTOR is
<identifier>
CLASS_NAME is
<identifier>
VALUE_NAME is
<identifier>
VALUE is
<identifier>
<constant>
OPERATOR_NAME is
"(" OPERATOR ")"
$ <identifier> $
OPERATOR is
+
-
*
/
\
%
&&
||
^
!
<
>
<=
>=
==
!=
>>=
>>
!!
posted on 2008-04-20 20:49
陈梓瀚(vczh) 阅读(2813)
评论(3) 编辑 收藏 引用 所属分类:
Vczh Lazy Script