File tree Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -218,14 +218,19 @@ ImportStatement: ast::LocatedStatement = {
218
218
};
219
219
220
220
ImportFromLocation: (usize, Option<String>) = {
221
- <dots: "." *> <name:DottedName> => {
222
- (dots.len (), Some(name))
221
+ <dots: ImportDots *> <name:DottedName> => {
222
+ (dots.iter().sum (), Some(name))
223
223
},
224
- <dots: "." +> => {
225
- (dots.len (), None)
224
+ <dots: ImportDots +> => {
225
+ (dots.iter().sum (), None)
226
226
},
227
227
};
228
228
229
+ ImportDots: usize = {
230
+ "..." => 3,
231
+ "." => 1,
232
+ };
233
+
229
234
ImportAsNames: Vec<ast::ImportSymbol> = {
230
235
<i:Comma<ImportPart<Identifier>>> => i,
231
236
"(" <i:Comma<ImportPart<Identifier>>> ")" => i,
Original file line number Diff line number Diff line change @@ -28,3 +28,13 @@ def foo():
28
28
assert 'Gt' in str (n .body [0 ].value .ops [1 ])
29
29
assert n .body [0 ].value .comparators [0 ].n == 4
30
30
assert n .body [0 ].value .comparators [1 ].n == 5
31
+
32
+
33
+ n = ast .parse ('from ... import a\n ' )
34
+ print (n )
35
+ i = n .body [0 ]
36
+ assert i .level == 3
37
+ assert i .module is None
38
+ assert i .names [0 ].name == 'a'
39
+ assert i .names [0 ].asname is None
40
+
Original file line number Diff line number Diff line change @@ -222,8 +222,8 @@ fn statement_to_ast(
222
222
223
223
fn alias_to_ast ( vm : & VirtualMachine , alias : & ast:: ImportSymbol ) -> PyResult < AstNodeRef > {
224
224
Ok ( node ! ( vm, alias, {
225
- symbol => vm. ctx. new_str( alias. symbol. to_string( ) ) ,
226
- alias => optional_string_to_py_obj( vm, & alias. alias)
225
+ name => vm. ctx. new_str( alias. symbol. to_string( ) ) ,
226
+ asname => optional_string_to_py_obj( vm, & alias. alias)
227
227
} ) )
228
228
}
229
229
You can’t perform that action at this time.
0 commit comments