root/attic/minid.txt

Revision 20, 7.2 kB (checked in by JarrettBillingsley, 2 years ago)

Moved remotely

Line 
1 // Lexical
2
3 WhiteSpace:
4     Space {Space}
5
6 Space:
7     ' '
8     '\t'
9     '\v'
10     '\u000C'
11     EndOfLine
12     Comment
13    
14 EndOfLine:
15     '\r'
16     '\n'
17     '\r\n'
18     EndOfFile
19
20 EndOfFile:
21     physical end of file
22     '\0'
23
24 Comment:
25     '/*' characters '*/'
26     '//' characters EndOfLine
27
28 Token:
29     Identifier
30     Keyword
31     CharLiteral
32     BoolLiteral
33     StringLiteral
34     IntLiteral
35     FloatLiteral
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     is
74     EOF
75
76 Identifier:
77     IdentifierStart {IdentifierChar}
78
79 IdentifierStart:
80     _
81     Letter
82
83 IdentifierChar:
84     IdentifierStart
85     DecimalDigit
86
87 Keyword:
88     assert
89
90     bool
91     break
92
93     case
94     cast
95     char
96     class
97     closure
98     continue
99
100     def
101     default
102     delete
103     do
104
105     else
106
107     float
108     for
109     foreach
110     function
111    
112     if
113     import
114     int
115
116     main
117     module
118
119     namespace
120     new
121     null
122
123     return
124
125     super
126     switch
127
128     this
129
130     vararg
131     void
132
133     while
134    
135 BoolLiteral:
136     true
137     false
138    
139 CharLiteral:
140     "'" (Character | EscapeSequence) "'"
141
142 StringLiteral:
143     RegularString
144     WysiwygString
145     AltWysiwygString
146
147 RegularString:
148     '"' {Character | EscapeSequence | EndOfLine} '"'
149
150 EscapeSequence:
151     '\''
152     '\"'
153     '\\'
154     '\a'
155     '\b'
156     '\f'
157     '\n'
158     '\r'
159     '\t'
160     '\v'
161     \DecimalDigit [DecimalDigit [DecimalDigit]]
162    
163 WysiwygString:
164     'r"' {Character | EndOfLine} '"'
165
166 AltWysiwygString:
167     '`' {Character | EndOfLine} '`'
168
169 IntLiteral:
170     Decimal
171     Binary
172     Octal
173     Hexadecimal
174    
175 Decimal:
176     DecimalDigit {DecimalDigit | '_'}
177
178 DecimalDigit:
179     0
180     1
181     2
182     3
183     4
184     5
185     6
186     7
187     8
188     9
189
190 Binary:
191     '0b' BinaryDigit {BinaryDigit | '_'}
192
193 BinaryDigit:
194     0
195     1
196
197 Octal:
198     '0c' OctalDigit {OctalDigit | '_'}
199
200 OctalDigit:
201     0
202     1
203     2
204     3
205     4
206     5
207     6
208     7
209
210 Hexadecimal:
211     '0x' HexadecimalDigit {HexadecimalDigit | '_'}
212
213 HexadecimalDigit:
214     0
215     1
216     2
217     3
218     4
219     5
220     6
221     7
222     8
223     9
224     A
225     a
226     B
227     b
228     C
229     c
230     D
231     d
232     E
233     e
234     F
235     f
236    
237 FloatLiteral:
238     [DecimalDigit {DecimalDigit | '_'}] '.' DecimalDigit {DecimalDigit | '_'} [Exponent]
239     DecimalDigit {DecimalDigit | '_'} [Exponent]
240
241 Exponent:
242     ('e' | 'E')['+' | '-'] DecimalDigit {DecimalDigit | '_'}
243
244 // -----------------------------------------------------------------------------------------------------------------
245 // -----------------------------------------------------------------------------------------------------------------
246 // -----------------------------------------------------------------------------------------------------------------
247
248 // Syntax
249
250 Module:
251     ModuleDeclaration {ImportDeclaration} {DeclDef} [MainDeclaration]
252
253 ModuleDeclaration:
254     'module' Identifier {'.' Identifier} ';'
255
256 DeclDef:
257     ClassDeclaration
258     ModuleNamespaceDeclaration
259     Declaration
260
261 ImportDeclaration:
262     'import' ModuleName ';'
263
264 MainDeclaration:
265     'main' '(' [Identifier] ')' BlockStatement
266
267 ClassDeclaration:
268     'class' Identifier [':' Identifier {'.' Identifier}] '{' {ClassElem} '}'
269
270 ClassElem:
271     CtorDeclaration
272     DtorDeclaration
273     ClassNamespaceDeclaration
274     Declaration
275    
276 CtorDeclaration:
277     'this' Parameters FunctionBody
278
279 DtorDeclaration:
280     '~' 'this' '(' ')' FunctionBody
281    
282 ClassNamespaceDeclaration:
283     'namespace' Identifier '{' {ClassNamespaceDeclaration | Declaration} '}'
284
285 ModuleNamespaceDeclaration:
286     'namespace' Identifier '{' {DeclDef} '}'
287
288 Declaration:
289     VariableDeclaration
290     FunctionDeclaration
291
292 VariableDeclaration:
293     'def' Type Identifier ['=' Initializer]
294
295 Initializer:
296     AssignExpression
297
298 FunctionDeclaration:
299     'def' Type Identifier Parameters FunctionBody
300
301 Type:
302     BasicType {ExtendedType}
303     'vararg'
304
305 BasicType:
306     'void'
307     'bool'
308     'char'
309     'int'
310     'float'
311     Identifier
312    
313 ExtendedType:
314     '[' ']'
315     '[' Type ']'
316     'function' SimpleParameters
317
318 SimpleParameters:
319     '(' [Type {',' Type}] ')'
320
321 Parameters:
322     '(' [Parameter {',' Parameter}] ')'
323
324 Parameter:
325     Type Identifier ['=' AssignExpression]
326
327 Expression:
328     AssignExpression
329    
330 AssignExpression:
331     OrOrExpression
332     OrOrExpression = AssignExpression
333     OrOrExpression += AssignExpression
334     OrOrExpression -= AssignExpression
335     OrOrExpression *= AssignExpression
336     OrOrExpression /= AssignExpression
337     OrOrExpression %= AssignExpression
338     OrOrExpression ^= AssignExpression
339     OrOrExpression ~= AssignExpression
340
341 OrOrExpression:
342     AndAndExpression
343     OrOrExpression || AndAndExpression
344
345 AndAndExpression:
346     EqualExpression
347     AndAndExpression && EqualExpression
348
349 EqualExpression:
350     RelExpression
351     EqualExpression == RelExpression
352     EqualExpression != RelExpression
353     EqualExpression is RelExpression
354     EqualExpression !is RelExpression
355    
356 RelExpression:
357     AddExpression
358     RelExpression < AddExpression
359     RelExpression <= AddExpression
360     RelExpression > AddExpression
361     RelExpression >= AddExpression
362
363 AddExpression:
364     MulExpression
365     AddExpression + MulExpression
366     AddExpression - MulExpression
367     AddExpression ~ MulExpression
368    
369 MulExpression:
370     PowerExpression
371     MulExpression * PowerExpression
372     MulExpression / PowerExpression
373     MulExpression % PowerExpression
374
375 PowerExpression:
376     UnaryExpression
377     PowerExpression ^ UnaryExpression
378    
379 UnaryExpression:
380     PostfixExpression
381     ++ UnaryExpression
382     -- UnaryExpression
383     - UnaryExpression
384     ! UnaryExpression
385     'delete' UnaryExpression
386     NewExpression
387     'cast' '(' Type ')' UnaryExpression
388
389 NewExpression:
390     'new' Type ['(' [ArgumentList] ')']
391
392 PostfixExpression:
393     PrimaryExpression
394     PostfixExpression '.' Identifier
395     PostfixExpression '.' '(' Type {',' Type} ')'
396     PostfixExpression '(' [ArgumentList] ')'
397     PostfixExpression '[' ArgumentList ']'
398     SliceExpression
399    
400 ArgumentList:
401     AssignExpression {, AssignExpression}
402
403 SliceExpression:
404     PostfixExpression '[' ']'
405     PostfixExpression '[' AssignExpression '..' AssignExpression ']'
406    
407 PrimaryExpression:
408     Identifier
409     'this'
410     'super'
411     'null'
412     CharLiteral
413     BoolLiteral
414     IntLiteral
415     FloatLiteral
416     StringLiteral
417     'closure' (Identifier | FunctionLiteral)
418     'function' Type Parameters FunctionBody
419     'assert' '(' AssignExpression [, StringLiteral] ')'
420     ( Expression )
421
422 FunctionBody:
423     BlockStatement
424    
425 Statement:
426     BlockStatement
427     ExpressionStatement
428     DeclarationStatement
429     IfStatement
430     WhileStatement
431     DoWhileStatement
432     ForStatement
433     ForeachStatement
434     SwitchStatement
435     CaseStatement
436     DefaultStatement
437     ContinueStatement
438     BreakStatement
439     ReturnStatement
440    
441 BlockStatement:
442     '{' {Statement} '}'
443    
444 ExpressionStatement:
445     Expression ';'
446
447 DeclarationStatement:
448     VariableDeclaration ';'
449     FunctionDeclaration
450
451 IfStatement:
452     'if' '(' Expression ')' Statement ['else' Statement]
453
454 WhileStatement:
455     'while' '(' Expression ')' Statement
456
457 DoWhileStatement:
458     'do' Statement 'while' '(' Expression ')'
459
460 ForStatement:
461     'for' '(' [(Expression | VariableDeclaration)] ';' [Expression] ';' [Expression] ')' Statement
462
463 ForeachStatement:
464     'foreach' '(' Type Identifier {',' Type Identifier} ';' Expression ')' Statement
465
466 SwitchStatement:
467     'switch' '(' Expression ')' '{' {CaseStatement} [DefaultStatement] '}'
468
469 CaseStatement:
470     'case' Expression {',' Expression} ':' {Statement}
471
472 DefaultStatement:
473     'default' ':' {Statement}
474    
475 ContinueStatement:
476     'continue' ';'
477
478 BreakStatement:
479     'break' ';'
480    
481 ReturnStatement:
482     'return' [Expression] ';'
Note: See TracBrowser for help on using the browser.