[language] Mazy(i) BNF 第一稿

Lich_Ray 2007-09-08
我设计的 Mazy 语言第三版,意淫了一下,把 BNF 给磨出来了。28条 plain-BNF,即使算上语法分析的额外要求也不算多。

Digits :: [0-9]+
Identifier :: [a-zA-Z]+_*'*
Comment :: ".*?"
Program :: 
	Sentence
	Sentence \n Program
Sentence :: 
	FunctionDefinition
	PatternMatching
FunctionDefinition :: 
	Identifier Pattern = Experssion
	Identifier Pattern = \n Clause .
	Identifier Pattern = \n Clause ; WhereBlock .
	Identifier Pattern = \n Program Clause ; WhereBlock .
WhereBlock :: 
	PatternMatching
	PatternMatching \n WhereBlock
PatternMatching :: 
	Pattern = Experssion
Expression ::
	Number
	List
	Identifier
	Operation
	Condition
	Lambda
	( Expression )
Number :: 
	Digits
	Digits.Digits
	Digits_Digits
	Digits.Digits_Digits
List :: 
	( )
	( Expression , )
	( Sequence )
	Comprehension
Comprehension :: ( Expression => Sequence )
Sequence :: 
	Expression
	Expression , Sequence
Operation :: 
	Expression Expression
	Prefix Expression
	Expression Midfix Expression
	Expression Postfix
Condition :: 
	[Clause]
	[Expression ; WhereBlock]
	[Clause ; WhereBlock]
Clause :: 
	SubClause
	SubClause \n Expression
SubClause :: 
	Expression , Expression
	Expression , Expression \n SubClause
Lambda :: 
	\ Pattern -> Expression .
	\ Pattern -> Expression ; WhereBlock .
Prefix :: oneof
	+ - ~ #
Midfix :: oneof
	+ - * / % ^ ** // : ++ -- = ~= < > >= <= & | ! !! $ .. <-
Postfix :: oneof
	++ -- !

Pattern :: 
	PatternAtom
	PatternList
	Pattern : PatternList
	PatternPreOpt Pattern
	Pattern PatternMidOpt PatternAtom
	PatternAtom PatternMidOpt Pattern
	Pattern PatternPostOpt
PatternList :: 
	( )
	( PatternAtom , )
	( PatternSequence )
PatternSequence :: 
	PatternAtom
	PatternAtom \n PatternSequence
PatternAtom :: oneof
	Identifier Number _
PatternPreOpt :: oneof
	- ~
PatternMidOpt :: oneof
	+ - * / ^ ** // :
PatternPostOpt :: oneof
	++ --

新语言想设计成为基于模式匹配的语言,于是进行了模式匹配完备化的努力,最后搞出了一个带有推导功能的东西,这样函数就可以只接受一个参数,同时满足了参数之间“关系”表达的要求——终于找到可以超过 Haskell 的地方了
加入了 Lambda 表达式,且带有作用域的语法都有了一个 WhereBlock,但功能其实相当于 Scheme 中的 let* 而不是 Haskell 中的 where;
列表相当于 tuple 和 list 二者的结合,列表领悟也有了;
其它一些纯属使语言更“漂亮”的小改动不值一提,感兴趣的自己看吧。
Lich_Ray 2007-09-10
丫的漏洞百出,我还是静下心来好好想想吧~`
Lich_Ray 2007-09-13
Mazy(i) plain-BNF 修订稿:http://let-in.blogspot.com/2007/09/mazyi-plain-bnf.html
Spike 2007-09-13
很好奇地问一下

你是高中生?
Lich_Ray 2007-09-13
是滴~`不过这个月不上学在家准备出国考试~`
PS: 私事私聊,to all.
roger 2007-09-18
同Spike
忒强的小伙
Lich_Ray 2007-09-19
丫的不讨论FP讨论这个~`跟自己五脏六腑讨论去。首页最新回帖很金贵滴~`
对CPS问题的回帖:http://wfp.group.iteye.com/group/post/17573
Global site tag (gtag.js) - Google Analytics