-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathCommonNodes.py
41 lines (37 loc) · 1.37 KB
/
CommonNodes.py
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
from Child import Child
from Node import Node # noqa: I201
COMMON_NODES = [
Node('Decl', kind='Syntax'),
Node('Expr', kind='Syntax'),
Node('Stmt', kind='Syntax'),
Node('Type', kind='Syntax'),
Node('Pattern', kind='Syntax'),
Node('UnknownDecl', kind='Decl'),
Node('UnknownExpr', kind='Expr'),
Node('UnknownStmt', kind='Stmt'),
Node('UnknownType', kind='Type'),
Node('UnknownPattern', kind='Pattern'),
# code-block-item = (decl | stmt | expr) ';'?
Node('CodeBlockItem', kind='Syntax',
children=[
Child('Item', kind='Syntax',
node_choices=[
Child('Decl', kind='Decl'),
Child('Stmt', kind='Stmt'),
Child('Expr', kind='Expr'),
]),
Child('Semicolon', kind='SemicolonToken',
is_optional=True),
]),
# code-block-item-list -> code-block-item code-block-item-list?
Node('CodeBlockItemList', kind='SyntaxCollection',
element='CodeBlockItem'),
# code-block -> '{' stmt-list '}'
Node('CodeBlock', kind='Syntax',
traits=['Braced', 'WithStatements'],
children=[
Child('LeftBrace', kind='LeftBraceToken'),
Child('Statements', kind='CodeBlockItemList'),
Child('RightBrace', kind='RightBraceToken'),
]),
]