-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree_2.grammar
More file actions
41 lines (29 loc) · 1.08 KB
/
Copy pathtree_2.grammar
File metadata and controls
41 lines (29 loc) · 1.08 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
source: package_decl {import_decl} {using_decl} {decl};
// Package
package_decl: $var_id ":" [$package] ":" $package "(" $string ")" [";"];
// Import
import_decl: $var_id ":" [$import] ":" $import "(" $string ")" [";"];
// Using
using_decl: $any_ids ":" [$using] ":" $using "(" $var_id ")" [";"];
// Declaration
decl: var_decl | any_type_decl | templ_decl;
// Variable
var_decl: ( $var_id ":" [$type_id] ":" $any_lit
| $var_id ":" $type_id
)
[";"];
// Type
any_type_decl: derived_type_decl | enum_decl | record_decl | union_decl;
// Derived type
derived_type_decl: type_ids ":" [$type] ":" $type "(" $type_id ")" [";"];
// Record
record_decl: type_ids ":" [$type] ":" $record "{" [var_decl {";" var_decl}] "}" [";"];
// Enum
enum_decl: type_ids ":" [$type] ":" $enum "{" [$var_id {";" $var_id}] "}" [";"];
// Union
union_decl: type_ids ":" [$type] ":" $union "{" [$type_id {"," $type_id}] "}" [";"];
// Template
templ_decl: $var_id ":" [$templ] ":" $templ "(" $type_id ")" "{" {$elements} "}" [";"];
// Utils
any_ids: $any_id {"," $any_id};
type_ids: $type_id {"," $type_id};