File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ def current_node():
10
10
return {'type' : 'current' , 'children' : []}
11
11
12
12
13
+ def root_node ():
14
+ return {'type' : 'root' , 'children' : []}
15
+
16
+
13
17
def expref (expression ):
14
18
return {'type' : 'expref' , 'children' : [expression ]}
15
19
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ class Parser(object):
46
46
'rbrace' : 0 ,
47
47
'number' : 0 ,
48
48
'current' : 0 ,
49
+ 'root' : 0 ,
49
50
'expref' : 0 ,
50
51
'colon' : 0 ,
51
52
'pipe' : 1 ,
@@ -239,6 +240,9 @@ def _parse_slice_expression(self):
239
240
def _token_nud_current (self , token ):
240
241
return ast .current_node ()
241
242
243
+ def _token_nud_root (self , token ):
244
+ return ast .root_node ()
245
+
242
246
def _token_nud_expref (self , token ):
243
247
expression = self ._expression (self .BINDING_POWER ['expref' ])
244
248
return ast .expref (expression )
Original file line number Diff line number Diff line change @@ -106,6 +106,17 @@ def test_function_call_with_and_statement(self):
106
106
'type' : 'function_expression' ,
107
107
'value' : 'f' })
108
108
109
+ def test_root_node (self ):
110
+ self .assert_parsed_ast (
111
+ '$[0]' ,
112
+ {
113
+ 'type' : 'index_expression' ,
114
+ 'children' : [
115
+ {'type' : 'root' , 'children' : []},
116
+ {'type' : 'index' , 'value' : 0 , 'children' : []}
117
+ ]
118
+ })
119
+
109
120
110
121
class TestErrorMessages (unittest .TestCase ):
111
122
You can’t perform that action at this time.
0 commit comments