Created
February 4, 2017 09:57
-
-
Save pandaman64/7fd2998d874a1f3ba3b411a65d1cd2ce to your computer and use it in GitHub Desktop.
MyML Grammar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// '\'はPEGの分岐,'?'はオプショナル, '*'は0回以上の繰り返し | |
Expr := LetRec \ Let \ If \ Literal \ Apply \ Identifier | |
LetRec := "let rec" Identifier Identifier? "=" Expr "in" Expr | |
Let := "let" Identifier Identifier? "=" Expr "in" Expr | |
If := "if" Expr "then" Expr "else" Expr | |
Literal := ライブラリの整数パースする奴使ってる | |
Apply := Value Value* | |
Value := "(" Expr ")" \ Primitive | |
Primitive := LetRec \ Let \ If \ Literal \ Ident // <- Apply := Expr Expr* ってするとApplyが左再帰するのでこんなんやってる | |
Identifier := [a-zA-Z] [a-zA-Z0-9!?]* (但し予約語ではない) | |
予約語 := "if" \ "then" \ "else" \ "let" \ "in" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment