-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemeScript.ohm
More file actions
115 lines (92 loc) · 4.51 KB
/
MemeScript.ohm
File metadata and controls
115 lines (92 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
MemeScript {
Program = Block
Block = (Stmnt)+
Stmnt = ConstInit
| VarInit
| VarDec
| FunDec
| ObjDec
| If
| While
| For
| TryCatch
| TryCatchFinally
| Switch
| Call ";" -- funcall
| Assignment ";" -- assign
| Return
| Print
| Error
| Alert
Body = "{" Block? "}"
ConstInit = "overlyattachedgirlfriend.jpg" id "=" Exp ";"
VarInit = "ermahgerd" id "=" Exp ";"
VarDec = "ermahgerd" id ";"
ObjDec = "wow" id "{" ObjConst ObjMethods* "}"
ObjConst = "such" "(" Params ")" Body
ObjMethods = "so" id "(" Params ")" Body
ObjInit = "very" id "(" Args ")"
FunDec = "you:" id "(" Params ")" "me, an intellectual:" Body
If = "I don't always" "(" Exp ")" "but when I do" Body (ElseIf)* (Else)?
ElseIf = "but sometimes I" "(" Exp ")" Body
Else = "otherwise I do" Body
While = "yo, I'mma let you finish" "(" Exp ")" "but" Body
For = "one does not simply" Body "without" "(" VarInit Exp ";" Assignment ")"
TryCatch = "Chuck Norris doesn't" Body "he" "(" id ")" Body
TryCatchFinally = "Chuck Norris doesn't" Body "or" "(" id ")" Body "he" Body
Switch = "this is bill" "(" Exp ")" "{" (SwitchCase)* SwitchDefault "}"
SwitchCase = ("bill has a" | "bill is a") Literal "{" Block? "be like bill;" "}"
SwitchDefault = "bill is smart" "{" Block? "be like bill;" "}"
Return = "i can haz" Exp ";"
Print = "dicks.out" "(" Exp ")" ";"
Error = "RIP" "(" Exp ")" ";"
Alert = "here comes dat boi" "(" Exp ")" ";"
Exp = Exp "||" Exp1 -- binary
| Exp1
Exp1 = Exp1 "&&" Exp2 -- binary
| Exp2
Exp2 = Exp2 relop Exp3 -- binary
| Exp3
Exp3 = Exp3 addop Exp4 -- binary
| Exp4
Exp4 = Exp4 mulop Exp5 -- binary
| Exp5
Exp5 = prefixop Exp6 -- unary
| Exp6
Exp6 = Literal
| Var
| "(" Exp ")" -- parens
Literal = "null" -- null
| boollit -- bool
| ("\"" char* "\"" | "'" char* "'") -- str
| (digit* "." digit+) -- float
| intlit -- int
Assignment = id "=" Exp
Call = id "(" Args ")"
Args = (Exp ("," Exp)*)?
Var = Var "[" Exp "]" -- subscript
| Var "." id -- select
| Call
| ObjInit
| id
Params = ((OptionalParam | SplatParam | Param) ("," (OptionalParam | SplatParam | Param))*)?
Param = id
OptionalParam = id "=" Exp
SplatParam = id "..."
mulop = "*" | "/" | "%"
prefixop = "!" | "-"
relop = "<=" | "<" | "===" | "==" | "!=" | ">=" | ">"
addop = "+" | "-"
char = escape
| ~"\n" ~"\"" ~"'" any
strlit = "\"" char* "\"" | "'" char* "'"
intlit = digit+
floatlit = digit* "." digit+
numlit = floatlit | intlit
boollit = "true" | "false"
escape = "\\n" | "\\\"" | "\\'"
keyword = ("you" | "but" | "without" | "ermahgerd" | "he" | "wow" | "such" | "very"
| "so" | "much" | "dicks" | "false" | "true" | "null" | "undefined" | "RIP") ~idrest
id = ~keyword letter idrest*
idrest = "_" | alnum
}