随笔-341  评论-2670  文章-0  trackbacks-0

ExpCmList  -> Expression ["," ExpList]
ArrCmList  -> [LeftValue "<-"] Expression ["," ArrList]
CaseList   -> LeftValue ":" Expression ";" [CaseList]
DoList     -> ([LeftValue "="]Expression | LeftValue "::" TypeDes ) ";" [DoList]
WhereList  -> (FuncHead | FuncBody) ";" [WhereList]

Exp0       -> <constant>
Exp0       -> FuncName
Exp0       -> "(" [ExpCmList] ")"
Exp0       -> "[" [ExpCmList] "]"
Exp0       -> "[" Expression "|" ArrCmList "]"
Exp0       -> "case" Expression "of" CaseList "end"
Exp0       -> "do" DoList "end"
Exp1       -> Exp0
Exp1       -> Exp1 Exp0
Exp2       -> Exp1
Exp2       -> Exp2 Operator Exp1 /*压缩*/
Exp3       -> Exp2
Exp3       -> Exp3 "'" <identifier> "'" Exp2
Expression -> Exp3
Expression -> Expression ["where" WhereList "end"]

LeftCmList -> LeftValue ["," LeftCmList]
Left0List  -> LeftValue0 [Left0List]
LeftValueA -> <identifier>
LeftValueB -> <constant>
LeftValueB -> "(" LeftCmList ")"
LeftValueB -> "[" LeftCmList "]"
LeftValue0 -> LeftValueA | LeftValueB
LeftValue1 -> LeftValueB
LeftValue1 -> LeftValueA [Left0List]
LeftValue  -> LeftValue1 [":" LeftValue]

Type0      -> "(" TypeDes ")"
Type0      -> <identifier>
Type1      -> Type0
Type1      -> Type1 Type0
Type2      -> Type1
Type2      -> Type2 "->" Type1
TypeDes    -> Type2
TypeDes    -> TypeDes "|" Type2

Prereq     -> <identifier> [<identifier>] "," [Prereq]
FuncHead   -> FuncName "::" [Prereq] TypeDes
FuncBody   -> FuncName Left0List "=" (Expression | "linking" <string>)
FuncName   -> <identifier>
FuncName   -> "(" Operator ")"
FnList     -> FuncName [FnList]
Operator   -> <operator>
Operator   -> "$" <identifier> "$"


IdDotList  -> <identifier> ["." IdDotList]
IdList     -> <identifier> [IdList]
ImportDecl -> "import" IdDotList
TypeDecl   -> "type" <identifier> [IdList]["=" TypeDes]
ClassDecl  -> "class" <identifier> <identifier> "where" WhereList "end"
InstDecl   -> "instance" <identifier> <identifier> ["where" WhereList "end"]
ModuleDecl -> "module" <identifier> "exports" FnList "where" DeclList "end"
Decl       -> (ImportDecl | TypeDecl | ClassDecl | InstDecl | ModuleDecl | FuncHead | FuncBody) ";"
DeclList   -> Decl [DeclList]
Program    -> ModuleDecl ";"

posted on 2008-04-20 20:50 陈梓瀚(vczh) 阅读(1856) 评论(3)  编辑 收藏 引用 所属分类: Vczh Lazy Script

评论:
# re: Vczh Lazy Script 上下文无关文法 2008-04-21 00:29 |
顶,跑到这里来写了,orz  回复  更多评论
  
# re: Vczh Lazy Script 上下文无关文法 2008-04-21 02:14 | 陈梓瀚(vczh)
你真是到处都有blog……  回复  更多评论
  
# re: Vczh Lazy Script 上下文无关文法[未登录] 2008-05-11 06:41 | rebol
so many production rules  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理