mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-03 18:29:04 +00:00
Merge pull request #4552 from charliermarsh/charlie/loc
Limit match range to end of last statement
This commit is contained in:
commit
f43e5b72e2
4 changed files with 109 additions and 85 deletions
|
@ -358,7 +358,15 @@ CompoundStatement: ast::Stmt = {
|
|||
};
|
||||
|
||||
MatchStatement: ast::Stmt = {
|
||||
<location:@L> "match" <subject:TestOrStarNamedExpr> ":" "\n" Indent <cases:MatchCase+> Dedent <end_location:@R> => {
|
||||
<location:@L> "match" <subject:TestOrStarNamedExpr> ":" "\n" Indent <cases:MatchCase+> Dedent => {
|
||||
let end_location = cases
|
||||
.last()
|
||||
.unwrap()
|
||||
.body
|
||||
.last()
|
||||
.unwrap()
|
||||
.end_location
|
||||
.unwrap();
|
||||
ast::Stmt {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
|
@ -369,7 +377,15 @@ MatchStatement: ast::Stmt = {
|
|||
}
|
||||
}
|
||||
},
|
||||
<location:@L> "match" <subject:TestOrStarNamedExpr> "," ":" "\n" Indent <cases:MatchCase+> Dedent <end_location:@R> => {
|
||||
<location:@L> "match" <subject:TestOrStarNamedExpr> "," ":" "\n" Indent <cases:MatchCase+> Dedent => {
|
||||
let end_location = cases
|
||||
.last()
|
||||
.unwrap()
|
||||
.body
|
||||
.last()
|
||||
.unwrap()
|
||||
.end_location
|
||||
.unwrap();
|
||||
ast::Stmt {
|
||||
location,
|
||||
end_location: Some(end_location),
|
||||
|
@ -380,7 +396,15 @@ MatchStatement: ast::Stmt = {
|
|||
}
|
||||
}
|
||||
},
|
||||
<location:@L> "match" <subject:TestOrStarNamedExpr> "," <subjects:OneOrMore<TestOrStarNamedExpr>> ","? ":" "\n" Indent <cases:MatchCase+> Dedent <end_location:@R> => {
|
||||
<location:@L> "match" <subject:TestOrStarNamedExpr> "," <subjects:OneOrMore<TestOrStarNamedExpr>> ","? ":" "\n" Indent <cases:MatchCase+> Dedent => {
|
||||
let end_location = cases
|
||||
.last()
|
||||
.unwrap()
|
||||
.body
|
||||
.last()
|
||||
.unwrap()
|
||||
.end_location
|
||||
.unwrap();
|
||||
let mut subjects = subjects;
|
||||
subjects.insert(0, subject);
|
||||
ast::Stmt {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue