Created
May 25, 2013 23:40
-
-
Save Chase-san/5651203 to your computer and use it in GitHub Desktop.
Coco/R is somewhat annoying...
This file contains hidden or 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
COMPILER CompilationUnit | |
CHARACTERS | |
tab = '\u0009' . | |
lf = '\u000a' . | |
cr = '\u000d' . | |
digit = "1234567890" . | |
letter = 'A' .. 'Z' + 'a' .. 'z' + '_'. | |
TOKENS | |
ident = letter { letter | digit }. | |
intLit = digit { digit } . | |
IGNORE lf + cr + tab | |
PRODUCTIONS | |
CompilationUnit = AssignExpr . | |
/* STATEMENTS */ | |
/* EXPRESSIONS */ | |
//with this... 2 + 2 = 16 = pi is possible... :( | |
AssignExpr = SumExpr { AssignOp SumExpr } . | |
SumExpr = ProductExpr { SumOp ProductExpr } . | |
ProductExpr = UnaryExpr { ProductOp UnaryExpr } . | |
UnaryExpr = [ UnaryOp ] PrimaryExpr . | |
PrimaryExpr | |
= | |
'(' AssignExpr ')' | |
| intLit | |
| ident | |
. | |
/* OPERATORS */ | |
AssignOp | |
= | |
'=' | |
| "+=" | |
| "-=" | |
| "*=" | |
| "/=" | |
| "&=" | |
| "|=" | |
| "^=" | |
| "%=" | |
| "<<=" | |
| ">>=" | |
. | |
SumOp | |
= | |
"+" | |
| "-" | |
| "|" | |
| "^" | |
. | |
ProductOp | |
= | |
"*" | |
| "/" | |
| "%" | |
| "<<" | |
| ">>" | |
| "&" | |
. | |
UnaryOp | |
= | |
"-" | |
| "~" | |
. | |
END CompilationUnit. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment