-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
78 lines (60 loc) · 1.75 KB
/
grammar.txt
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
Literal : INT FLOAT STRING
Operator : PLUS MINUS TIMES DIVBY POW SQRT NOT
Comparison : EQUALSEQ NOTEQ LSSTHN GRTTHN LSSTHNEQ GRTTHNEQ
Combiner : AND XOR OR
Type : TYPE:Str TYPE:Int TYPE:Float TYPE:Bool TYPE:Array TYPE:Func
notraceexpr:
- KEYWORD:var IDENTIFIER EQUALS expr
- IDENTIFIER EQUALS expr
- expr
expr:
- opexpr
opexpr:
- calltribute (calltribute (Operator|Comparison|Combiner) | opexpr | LSSTHN typeexpr GRTTHN)*
calltribute:
- factor ((LPAREN EOL* (expr (COMMA EOL* expr)*)? EOL* RPAREN) | (DOT IDENTIFIER))*
factor:
- (PLUS|MINUS) factor
- ifexpr
- forexpr
- whileexpr
- funcexpr
- atom
ifexpr:
- KEYWORD:if LPAREN EOL* expr EOL* RPAREN codeblock
(EOL* KEYWORD:elif LPAREN EOL* expr EOL* RPAREN codeblock)*
(EOL* KEYWORD:else codeblock)?
forexpr:
- KEYWORD:for IDENTIFIER KEYWORD:in LPAREN EOL* expr EOL* RPAREN codeblock
whileexpr:
- KEYWORD:while LPAREN EOL* expr EOL* RPAREN codeblock
funcexpr:
- KEYWORD:func LPAREN EOL* (IDENTIFIER COLON EOL* typeexpr (COMMA EOL* IDENTIFIER COLON EOL* typeexpr)*)? EOL* RPAREN
COLON typeexpr codeblock
atom:
- Literal
- IDENTIFIER
- arrayexpr
arrayexpr:
- LSQUARE EOL* (expr
(COMMA EOL* expr)*)? COMMA? EOL*
RSQUARE
typeexpr:
- TYPE:Str
- TYPE:Int
- TYPE:Float
- TYPE:Bool
- TYPE:Array LSSTHN INT COMMA typeexpr GRTTHN
//- TYPE:Seq LSSTHN typeexpr GRTTHN
//- TYPE:Uarray LSSTHN (typeexpr (COMMA typeexpr)*)? GRTTHN
//- TYPE:Table LSSTHN typeexpr COMMA typeexpr GRTTHN
//- TYPE:Enum
//- TYPE:Excep LSSTHN IDENTIFIER GRTTHN
//- TYPE:Mod LSSTHN IDENTIFIER GRTTHN
//- TYPE:Struct
//- TYPE:Impl
- TYPE:Func LSSTHN LSQUARE (type (COMMA type)*)? RSQUARE COMMA type GRTTHN
codeblock:
- LCURLY EOL*
(expr EOL*)*
RCURLY