Skip to content

Commit 17f7efe

Browse files
committed
Fix FormattedValue location
1 parent b1db1be commit 17f7efe

22 files changed

+2195
-355
lines changed

compiler/parser/python.lalrpop

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,18 +1339,11 @@ OneOrMore<T>: Vec<T> = {
13391339
};
13401340

13411341
Constant: ast::Constant = {
1342-
<b:bytes+> => ast::Constant::Bytes(b.into_iter().flatten().collect()),
13431342
<value:int> => ast::Constant::Int(value),
13441343
<value:float> => ast::Constant::Float(value),
13451344
<s:complex> => ast::Constant::Complex { real: s.0, imag: s.1 },
13461345
};
13471346

1348-
Bytes: Vec<u8> = {
1349-
<s:bytes+> => {
1350-
s.into_iter().flatten().collect::<Vec<u8>>()
1351-
},
1352-
};
1353-
13541347
Identifier: String = <s:name> => s;
13551348

13561349
// Hook external lexer:
@@ -1448,8 +1441,11 @@ extern {
14481441
int => lexer::Tok::Int { value: <BigInt> },
14491442
float => lexer::Tok::Float { value: <f64> },
14501443
complex => lexer::Tok::Complex { real: <f64>, imag: <f64> },
1451-
string => lexer::Tok::String { value: <String>, kind: <StringKind> },
1452-
bytes => lexer::Tok::Bytes { value: <Vec<u8>> },
1444+
string => lexer::Tok::String {
1445+
value: <String>,
1446+
kind: <StringKind>,
1447+
triple_quoted: <bool>
1448+
},
14531449
name => lexer::Tok::Name { name: <String> },
14541450
"\n" => lexer::Tok::Newline,
14551451
";" => lexer::Tok::Semi,

compiler/parser/src/error.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ pub enum FStringErrorType {
9090
UnterminatedString,
9191
}
9292

93+
impl FStringErrorType {
94+
pub fn to_lexical_error(self, location: Location) -> LexicalError {
95+
LexicalError {
96+
error: LexicalErrorType::FStringError(self),
97+
location,
98+
}
99+
}
100+
}
101+
93102
impl fmt::Display for FStringErrorType {
94103
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
95104
match self {

compiler/parser/src/fstring.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// We no longer need this file
12
use self::FStringErrorType::*;
23
use crate::{
34
ast::{Constant, ConversionFlag, Expr, ExprKind, Location},

0 commit comments

Comments
 (0)