Repository navigation
Expand file tree
/
Copy pathjavaish.grammer
More file actions
172 lines (136 loc) · 2.38 KB
/
Copy pathjavaish.grammer
File metadata and controls
172 lines (136 loc) · 2.38 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@top
Program {
(Declaration | Mutation | FunctionDeclaration | FunctionCall | Loop | Conditional )*
}
Declaration {
"let" Type Identifier "=" Expression "."
}
Type {
"int" | "float" | "String" | "bool" | "int[]" | "float[]" | "String[]" | "bool[]"
}
Expression {
Number |
StringLiteral |
Variable |
FunctionCall |
BinaryExpression |
ParenthesizedExpression |
ListSubscript |
Condition |
List
}
Number {
Integer | Float
}
Integer {
/[0-9]+/
}
Float {
/[0-9]+\.[0-9]+/
}
StringLiteral {
/".*?"/
}
Variable {
Identifier
}
Mutation {
AddMutation | SubtractMutation | MultiplyMutation | DivideMutation |
RemoveMutation | RemoveAllMutation | RemoveAtMutation
}
AddMutation {
"add" Expression "to" Variable "."
}
SubtractMutation {
"subtract" Expression "from" Variable "."
}
MultiplyMutation {
"multiply" Variable "by" Expression "."
}
DivideMutation {
"divide" Variable "by" Expression "."
}
RemoveMutation {
"remove" Expression "from" Variable "."
}
RemoveAllMutation {
"removeAll" Expression "from" Variable "."
}
RemoveAtMutation {
"removeAt" ListSubscript "."
}
FunctionDeclaration {
"function" Identifier "(" (Parameter ("," Parameter)*)? ")" Block
}
Parameter {
Type Identifier
}
Block {
"{" (Statement)* "}"
}
FunctionCall {
Identifier "(" (Expression ("," Expression)*)? ")"
}
Loop {
WhileLoop | ForEachLoop | ForWhenLoop
}
WhileLoop {
"while" Expression Block
}
ForEachLoop {
"for" "each" Identifier "in" Expression Block
}
ForWhenLoop {
"for" "when" Expression "increment" Identifier "by" Expression Block
}
Conditional {
"if" Condition Block (ElseIfClause)* ("else" Block)?
}
ElseIfClause {
"else" "if" Condition Block
}
BinaryExpression {
Expression BinaryOperator Expression
}
BinaryOperator {
"+" | "-" | "*" | "/" | "==" | "!=" | "<" | ">" | "<=" | ">=" | "&&" | "||"
}
ParenthesizedExpression {
"(" Expression ")"
}
ArrayElement {
Expression
}
List {
"[" ArrayElement ("," ArrayElement)* "]"
}
ListSubscript {
Variable "sub" Expression
}
Condition {
Expression ConditionOperator Expression
}
ConditionOperator {
"==" |
"!=" |
"<" |
">" |
"<=" |
">=" |
"&&" |
"||" |
"equals" |
"not equals" |
"greater than" |
"less than" |
"greater than or eqaul to" |
"less than or equal to" |
"and" |
"or"
}
Comment {
/\/\/.*/
}
Identifier {
/[a-zA-Z_][a-zA-Z0-9_]*/
}