-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathast_types.yml
More file actions
144 lines (118 loc) · 3.51 KB
/
Copy pathast_types.yml
File metadata and controls
144 lines (118 loc) · 3.51 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
supertypes:
expr:
- name_expr
- int_literal
- string_literal
- binary_expr
- unary_expr
- call_expr
- member_access_expr
- lambda_expr
- unsupported_node
stmt:
- empty_stmt
- block_stmt
- expr_stmt
- if_stmt
- variable_declaration_stmt
- guard_if_stmt
- unsupported_node
condition:
- expr_condition
- let_pattern_condition
- sequence_condition
- unsupported_node
pattern:
- var_pattern
- apply_pattern
- tuple_pattern
- ignore_pattern
- unsupported_node
named:
# Top-level is the root node, currently containing a list of expressions
top_level:
body*: [expr, stmt]
# An identifier used in the context of an expression
name_expr:
identifier: identifier
# An integer literal
int_literal:
# A string literal
string_literal:
# Application of a binary operator, such as `a + b`
binary_expr:
left: expr
operator: operator
right: expr
# Application of a unary operator, such as `!x`
unary_expr:
operand: expr
operator: operator
# A function or method call, such as `f(x)` or `obj.m(x)`. Method calls
# are represented as a call whose `function` is a `member_access_expr`.
call_expr:
function: expr
argument*: expr
# Member access, such as `obj.member`.
member_access_expr:
target: expr
member: identifier
lambda_expr:
parameter*: parameter
body: [expr, stmt]
# A parameter
parameter:
pattern: pattern
empty_stmt:
block_stmt:
body*: stmt
expr_stmt:
expr: expr
if_stmt:
condition: condition
then?: stmt
else?: stmt
variable_declaration_stmt:
variable_declarator+: variable_declarator
# A variable declaration, or assignment to a pattern.
# The initializer is optional (but typically only possible in combination with a simple variable pattern).
variable_declarator:
pattern: pattern
value?: expr
# Evaluate 'condition', and if false, execute 'else' which must break from the enclosing block scope (return, break, etc).
# Any variables bound by 'condition' will be in scope for the remainder of the enclosing block scope
# (which differs from how if_stmt works).
guard_if_stmt:
condition: condition
else: stmt
# Evaluates the given condition and interprets it as a boolean (by language conventions)
expr_condition:
expr: expr
# A series of statements that are executed before evaluating the trailing condition.
# Useful for languages where a conditional clause may be preceded by side-effecting
# syntactic elements (e.g. binding clauses) that don't themselves form a condition.
sequence_condition:
stmt*: stmt
condition: condition
# Evaluate 'expr' and match its result against 'pattern', and return true if it matches.
# Variables bound by the pattern will be in scope within the 'true' branch controlled by this condition.
let_pattern_condition:
pattern: pattern
value: expr
# A pattern matching anything, binding its value to the given variable
var_pattern:
identifier: identifier
# A pattern matching anything, binding no variables, usually using the syntax "_"
ignore_pattern:
# A pattern such as `Some(x)` where `Some` is the constructor and `x` is an argument
apply_pattern:
constructor: expr
argument*: pattern
# A tuple pattern such as `(a, b)` in `let (a, b) = pair`.
tuple_pattern:
element*: pattern
# An simple unqualified identifier token
identifier:
# A node that we don't yet translate
unsupported_node:
operator: