Skip to content

Commit

Permalink
fix: formatted value node end
Browse files Browse the repository at this point in the history
  • Loading branch information
Glyphack committed Jun 8, 2024
1 parent c98d2bf commit 8776006
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ thiserror = "1.0.40"
is-macro = "0.3.5"

[dev-dependencies]
codspeed-criterion-compat = "2.6.0"
codspeed-criterion-compat.workspace = true
criterion.workspace = true
insta.workspace = true
reqwest = { version= "0.12.4", features = ["blocking"] }
Expand Down
3 changes: 0 additions & 3 deletions parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ impl Lexer {
if self.peek() == Some('}') && self.double_peek() != Some('}') {
self.next();
self.inside_fstring_bracket -= 1;
// if self.fstring_format_spec_stack > 1 {
// self.fstring_format_spec_stack -= 1;
// }
return Some(Kind::RightBracket);
}
if self.peek() == Some(':') {
Expand Down
5 changes: 3 additions & 2 deletions parser/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3202,13 +3202,14 @@ impl Parser {
-1
};

let format_spec_node = self.start_node();
let format_spec = if self.eat(Kind::Colon) {
let mut specs = vec![];
while matches!(self.cur_kind(), Kind::FStringMiddle | Kind::LeftBracket) {
specs.push(self.parse_fstring_middle()?);
}
Some(Expression::JoinedStr(Box::new(JoinedStr {
node,
node: self.finish_node(format_spec_node),
values: specs,
})))
} else {
Expand All @@ -3217,7 +3218,7 @@ impl Parser {

self.expect(Kind::RightBracket)?;
Ok(Expression::FormattedValue(Box::new(FormattedValue {
node,
node: self.finish_node(node),
value: expr,
conversion,
format_spec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Module {
FormattedValue {
node: Node {
start: 8,
end: 0,
end: 11,
},
value: Name(
Name {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Module {
FormattedValue {
node: Node {
start: 8,
end: 0,
end: 11,
},
value: Name(
Name {
Expand Down Expand Up @@ -57,7 +57,7 @@ Module {
FormattedValue {
node: Node {
start: 12,
end: 0,
end: 15,
},
value: Name(
Name {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Module {
FormattedValue {
node: Node {
start: 8,
end: 0,
end: 11,
},
value: Name(
Name {
Expand Down Expand Up @@ -57,7 +57,7 @@ Module {
FormattedValue {
node: Node {
start: 12,
end: 0,
end: 15,
},
value: Name(
Name {
Expand Down Expand Up @@ -85,7 +85,7 @@ Module {
FormattedValue {
node: Node {
start: 16,
end: 0,
end: 19,
},
value: Name(
Name {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Module {
FormattedValue {
node: Node {
start: 131,
end: 0,
end: 156,
},
value: Attribute(
Attribute {
Expand Down Expand Up @@ -150,7 +150,7 @@ Module {
FormattedValue {
node: Node {
start: 157,
end: 0,
end: 176,
},
value: Call(
Call {
Expand Down Expand Up @@ -211,7 +211,7 @@ Module {
FormattedValue {
node: Node {
start: 182,
end: 0,
end: 192,
},
value: Name(
Name {
Expand All @@ -227,8 +227,8 @@ Module {
JoinedStr(
JoinedStr {
node: Node {
start: 182,
end: 0,
start: 186,
end: 191,
},
values: [
Constant(
Expand All @@ -250,7 +250,7 @@ Module {
FormattedValue {
node: Node {
start: 192,
end: 0,
end: 198,
},
value: Name(
Name {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Module {
FormattedValue {
node: Node {
start: 4,
end: 0,
end: 7,
},
value: Constant(
Constant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ Module {
FormattedValue {
node: Node {
start: 603,
end: 0,
end: 613,
},
value: Name(
Name {
Expand Down Expand Up @@ -872,7 +872,7 @@ Module {
FormattedValue {
node: Node {
start: 882,
end: 0,
end: 892,
},
value: Name(
Name {
Expand Down Expand Up @@ -1101,7 +1101,7 @@ Module {
FormattedValue {
node: Node {
start: 1078,
end: 0,
end: 1088,
},
value: Name(
Name {
Expand Down

0 comments on commit 8776006

Please sign in to comment.