Remove Int wrapper type from parser (#7577)

## Summary

This is only used for the `level` field in relative imports (e.g., `from
..foo import bar`). It seems unnecessary to use a wrapper here, so this
PR changes to a `u32` directly.
This commit is contained in:
Charlie Marsh 2023-09-21 13:01:44 -04:00 committed by GitHub
parent 6c3378edb1
commit 4d6f5ff0a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 75 additions and 101 deletions

View file

@ -253,18 +253,18 @@ ImportStatement: ast::Stmt = {
},
};
ImportFromLocation: (Option<ast::Int>, Option<ast::Identifier>) = {
ImportFromLocation: (Option<u32>, Option<ast::Identifier>) = {
<dots: ImportDots*> <name:DottedName> => {
(Some(ast::Int::new(dots.iter().map(ast::Int::to_u32).sum())), Some(name))
(Some(dots.iter().sum()), Some(name))
},
<dots: ImportDots+> => {
(Some(ast::Int::new(dots.iter().map(ast::Int::to_u32).sum())), None)
(Some(dots.iter().sum()), None)
},
};
ImportDots: ast::Int = {
"..." => ast::Int::new(3),
"." => ast::Int::new(1),
ImportDots: u32 = {
"..." => 3,
"." => 1,
};
ImportAsNames: Vec<ast::Alias> = {