-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrammar.bnf
59 lines (47 loc) · 2.05 KB
/
grammar.bnf
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
<identifier> ::= <identifier_start> <identifier_part>*
<identifier_start> ::= [A-Za-z_$]
<identifier_part> ::= <identifier_start> | <digit>
<digit> ::= [0-9]
<program> ::= <import>* <non_import_declaration>*
<import> ::= "import" ( <dart_import> | <package_import> )
<dart_import> ::= "@" <import_identifier>
<package_import> ::= <import_identifier>
<import_identifier> ::= <identifier> ( "/" <identifier> )*
<non_import_declaration> ::= <type_definition>
| <let_function_declaration>
| <let_variable_declaration>
<type_definition> ::= "type" <identifier> ( "(" <named_type_literal> ( "," <named_type_literal> )* ")" )? "=" <type_variation> ( "+" <type_variation> )*
<type_variant> ::= <identifier> <struct_literal>?
<let_function_declaration> ::= "let" <identifier> <struct_literal> "=" <expression>
<let_variable_declaration> ::= "let" <identifier> "=" <expression>
<type_literal> ::= <top_type_literal>
| <bottom_type_literal>
| <list_type_literal>
| <set_type_literal>
| <map_type_literal>
| <option_type_literal>
| <identifier>
<top_type_literal> ::= "⊤"
<bottom_type_literal> ::= "⊥"
<list_type_literal> ::= "[" <type_literal> "]"
<set_type_literal> ::= "{" <type_literal> "}"
<map_type_literal> ::= "{" <type_literal> ":" <type_literal> "}"
<option_type_literal> ::= <type_literal> "?"
<invocation> ::= <identifier> <expression>
<digit_separator> ::= "_"
<string_character> ::= ~( '"' | '\n' | '\r')
<expression> ::= <bool_literal>
| <integer_literal>
| <string_literal>
| <struct_literal>
| <symbol_literal>
| <unit_literal>
| <invocation>
| <identifier>
<bool_literal> ::= "true" | "false"
<double_literal> ::= <integer_literal> "." <integer_literal>
<integer_literal> ::= <digit> (<digit_separator>* <digit>+)*
<struct_literal> ::= "(" <struct_literal_member> ("," <struct_literal_member>?)* ")"
<struct_literal_member> ::= (<symbol_literal>? <expression>?)
<string_literal> ::= '"' + <string_character>* + '"'
<symbol_literal> ::= ":" <identifier>