-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
55 lines (49 loc) · 1.03 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
program = import* decl* call_expr?
import = 'import' qualified_ident* 'from' STRING
qualified_ident = IDENT ('.' IDENT)*
decl = 'public'? (namespace | type | binding)
namespace = 'namespace' qualified_ident decl_block
decl_block = '{' decl* '}'
type = 'type' qualified_ident '=' type_cases decl_block?
type_cases = IDENT+ ('|' IDENT+)*
binding = 'let' pattern '=' block
pattern = const_literal |
wildcard_pattern |
name_pattern |
list_pattern |
type_pattern |
wildcard_pattern = '_'
name_pattern = IDENT
list_pattern = '[' pattern+ ']'
type_pattern = '(' qualified_ident pattern+ ')'
block = binding* expr
expr = call_expr | qualified_ident | lambda | list_expr | const_literal
call_expr = '(' ('.' | expr) expr* ')'
lambda = '{' pattern* '->' block '}'
list_expr = '[' block+ ']'
const_literal = NUMBER | STRING | '()' | '[]'
IDENT = [^\(\)\[\]\.]+
NUMBER = \d+(\.\d*)?
STRING = \'[^\n\r]*?\'|\"[^\n\r]*?\"
COMMENT = #.*?(?=\n|$)
KEYWORDS:
import
from
public
namespace
type
let
method
impl
SYMBOLS:
.
{
}
()
(
)
[]
[
]
=
->