Skip to content

Commit 3d2c519

Browse files
authored
Update parser (RustPython#5012)
1 parent 5c81649 commit 3d2c519

File tree

6 files changed

+188
-188
lines changed

6 files changed

+188
-188
lines changed

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ rustpython-pylib = { path = "pylib" }
2929
rustpython-stdlib = { path = "stdlib" }
3030
rustpython-doc = { git = "https://github.com/RustPython/__doc__", branch = "main" }
3131

32-
rustpython-literal = { git = "https://github.com/RustPython/Parser.git", rev = "b2f95e284852cb25d6e510c127260d03573d9f0c" }
33-
rustpython-parser-core = { git = "https://github.com/RustPython/Parser.git", rev = "b2f95e284852cb25d6e510c127260d03573d9f0c" }
34-
rustpython-parser = { git = "https://github.com/RustPython/Parser.git", rev = "b2f95e284852cb25d6e510c127260d03573d9f0c" }
35-
rustpython-ast = { git = "https://github.com/RustPython/Parser.git", rev = "b2f95e284852cb25d6e510c127260d03573d9f0c" }
36-
rustpython-format = { git = "https://github.com/RustPython/Parser.git", rev = "b2f95e284852cb25d6e510c127260d03573d9f0c" }
32+
rustpython-literal = { git = "https://github.com/RustPython/Parser.git", rev = "69d27d924c877b6f2fa5dc75c9589ab505d5b3f1" }
33+
rustpython-parser-core = { git = "https://github.com/RustPython/Parser.git", rev = "69d27d924c877b6f2fa5dc75c9589ab505d5b3f1" }
34+
rustpython-parser = { git = "https://github.com/RustPython/Parser.git", rev = "69d27d924c877b6f2fa5dc75c9589ab505d5b3f1" }
35+
rustpython-ast = { git = "https://github.com/RustPython/Parser.git", rev = "69d27d924c877b6f2fa5dc75c9589ab505d5b3f1" }
36+
rustpython-format = { git = "https://github.com/RustPython/Parser.git", rev = "69d27d924c877b6f2fa5dc75c9589ab505d5b3f1" }
3737
# rustpython-literal = { path = "../RustPython-parser/literal" }
3838
# rustpython-parser-core = { path = "../RustPython-parser/core" }
3939
# rustpython-parser = { path = "../RustPython-parser/parser" }

compiler/codegen/src/compile.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ impl Compiler {
10101010
fn compile_try_statement(
10111011
&mut self,
10121012
body: &[located_ast::Stmt],
1013-
handlers: &[located_ast::Excepthandler],
1013+
handlers: &[located_ast::ExceptHandler],
10141014
orelse: &[located_ast::Stmt],
10151015
finalbody: &[located_ast::Stmt],
10161016
) -> CompileResult<()> {
@@ -1044,8 +1044,8 @@ impl Compiler {
10441044
self.switch_to_block(handler_block);
10451045
// Exception is on top of stack now
10461046
for handler in handlers {
1047-
let located_ast::Excepthandler::ExceptHandler(
1048-
located_ast::ExcepthandlerExceptHandler {
1047+
let located_ast::ExceptHandler::ExceptHandler(
1048+
located_ast::ExceptHandlerExceptHandler {
10491049
type_, name, body, ..
10501050
},
10511051
) = &handler;
@@ -1142,7 +1142,7 @@ impl Compiler {
11421142
fn compile_try_star_statement(
11431143
&mut self,
11441144
_body: &[located_ast::Stmt],
1145-
_handlers: &[located_ast::Excepthandler],
1145+
_handlers: &[located_ast::ExceptHandler],
11461146
_orelse: &[located_ast::Stmt],
11471147
_finalbody: &[located_ast::Stmt],
11481148
) -> CompileResult<()> {
@@ -1499,7 +1499,7 @@ impl Compiler {
14991499

15001500
fn compile_with(
15011501
&mut self,
1502-
items: &[located_ast::Withitem],
1502+
items: &[located_ast::WithItem],
15031503
body: &[located_ast::Stmt],
15041504
is_async: bool,
15051505
) -> CompileResult<()> {
@@ -1641,7 +1641,7 @@ impl Compiler {
16411641
fn compile_chained_comparison(
16421642
&mut self,
16431643
left: &located_ast::Expr,
1644-
ops: &[located_ast::Cmpop],
1644+
ops: &[located_ast::CmpOp],
16451645
exprs: &[located_ast::Expr],
16461646
) -> CompileResult<()> {
16471647
assert!(!ops.is_empty());
@@ -1651,19 +1651,19 @@ impl Compiler {
16511651

16521652
use bytecode::ComparisonOperator::*;
16531653
use bytecode::TestOperator::*;
1654-
let compile_cmpop = |c: &mut Self, op: &located_ast::Cmpop| match op {
1655-
located_ast::Cmpop::Eq => emit!(c, Instruction::CompareOperation { op: Equal }),
1656-
located_ast::Cmpop::NotEq => emit!(c, Instruction::CompareOperation { op: NotEqual }),
1657-
located_ast::Cmpop::Lt => emit!(c, Instruction::CompareOperation { op: Less }),
1658-
located_ast::Cmpop::LtE => emit!(c, Instruction::CompareOperation { op: LessOrEqual }),
1659-
located_ast::Cmpop::Gt => emit!(c, Instruction::CompareOperation { op: Greater }),
1660-
located_ast::Cmpop::GtE => {
1654+
let compile_cmpop = |c: &mut Self, op: &located_ast::CmpOp| match op {
1655+
located_ast::CmpOp::Eq => emit!(c, Instruction::CompareOperation { op: Equal }),
1656+
located_ast::CmpOp::NotEq => emit!(c, Instruction::CompareOperation { op: NotEqual }),
1657+
located_ast::CmpOp::Lt => emit!(c, Instruction::CompareOperation { op: Less }),
1658+
located_ast::CmpOp::LtE => emit!(c, Instruction::CompareOperation { op: LessOrEqual }),
1659+
located_ast::CmpOp::Gt => emit!(c, Instruction::CompareOperation { op: Greater }),
1660+
located_ast::CmpOp::GtE => {
16611661
emit!(c, Instruction::CompareOperation { op: GreaterOrEqual })
16621662
}
1663-
located_ast::Cmpop::In => emit!(c, Instruction::TestOperation { op: In }),
1664-
located_ast::Cmpop::NotIn => emit!(c, Instruction::TestOperation { op: NotIn }),
1665-
located_ast::Cmpop::Is => emit!(c, Instruction::TestOperation { op: Is }),
1666-
located_ast::Cmpop::IsNot => emit!(c, Instruction::TestOperation { op: IsNot }),
1663+
located_ast::CmpOp::In => emit!(c, Instruction::TestOperation { op: In }),
1664+
located_ast::CmpOp::NotIn => emit!(c, Instruction::TestOperation { op: NotIn }),
1665+
located_ast::CmpOp::Is => emit!(c, Instruction::TestOperation { op: Is }),
1666+
located_ast::CmpOp::IsNot => emit!(c, Instruction::TestOperation { op: IsNot }),
16671667
};
16681668

16691669
// a == b == c == d
@@ -1951,7 +1951,7 @@ impl Compiler {
19511951
match &expression {
19521952
located_ast::Expr::BoolOp(located_ast::ExprBoolOp { op, values, .. }) => {
19531953
match op {
1954-
located_ast::Boolop::And => {
1954+
located_ast::BoolOp::And => {
19551955
if condition {
19561956
// If all values are true.
19571957
let end_block = self.new_block();
@@ -1972,7 +1972,7 @@ impl Compiler {
19721972
}
19731973
}
19741974
}
1975-
located_ast::Boolop::Or => {
1975+
located_ast::BoolOp::Or => {
19761976
if condition {
19771977
// If any of the values is true.
19781978
for value in values {
@@ -1996,7 +1996,7 @@ impl Compiler {
19961996
}
19971997
}
19981998
located_ast::Expr::UnaryOp(located_ast::ExprUnaryOp {
1999-
op: located_ast::Unaryop::Not,
1999+
op: located_ast::UnaryOp::Not,
20002000
operand,
20012001
..
20022002
}) => {
@@ -2029,7 +2029,7 @@ impl Compiler {
20292029
/// This means, that the last value remains on the stack.
20302030
fn compile_bool_op(
20312031
&mut self,
2032-
op: &located_ast::Boolop,
2032+
op: &located_ast::BoolOp,
20332033
values: &[located_ast::Expr],
20342034
) -> CompileResult<()> {
20352035
let after_block = self.new_block();
@@ -2039,15 +2039,15 @@ impl Compiler {
20392039
self.compile_expression(value)?;
20402040

20412041
match op {
2042-
located_ast::Boolop::And => {
2042+
located_ast::BoolOp::And => {
20432043
emit!(
20442044
self,
20452045
Instruction::JumpIfFalseOrPop {
20462046
target: after_block,
20472047
}
20482048
);
20492049
}
2050-
located_ast::Boolop::Or => {
2050+
located_ast::BoolOp::Or => {
20512051
emit!(
20522052
self,
20532053
Instruction::JumpIfTrueOrPop {
@@ -2122,10 +2122,10 @@ impl Compiler {
21222122

21232123
// Perform operation:
21242124
let op = match op {
2125-
Unaryop::UAdd => bytecode::UnaryOperator::Plus,
2126-
Unaryop::USub => bytecode::UnaryOperator::Minus,
2127-
Unaryop::Not => bytecode::UnaryOperator::Not,
2128-
Unaryop::Invert => bytecode::UnaryOperator::Invert,
2125+
UnaryOp::UAdd => bytecode::UnaryOperator::Plus,
2126+
UnaryOp::USub => bytecode::UnaryOperator::Minus,
2127+
UnaryOp::Not => bytecode::UnaryOperator::Not,
2128+
UnaryOp::Invert => bytecode::UnaryOperator::Invert,
21292129
};
21302130
emit!(self, Instruction::UnaryOperation { op });
21312131
}

compiler/codegen/src/symboltable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ impl SymbolTableBuilder {
832832
}) => {
833833
self.scan_statements(body)?;
834834
for handler in handlers {
835-
let Excepthandler::ExceptHandler(ast::ExcepthandlerExceptHandler {
835+
let ExceptHandler::ExceptHandler(ast::ExceptHandlerExceptHandler {
836836
type_,
837837
name,
838838
body,

extra_tests/snippets/syntax_non_utf8.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# TODO: RUSTPYTHON. At some point snippets will fail and it will look confusing
99
# and out of the blue. This is going to be the cause and it's going to happen when
1010
# the github worker for MacOS starts using Python 3.11.4.
11-
if platform.python_implementation == "CPython" and platform.system() == 'Darwin':
11+
if platform.python_implementation() == "CPython" and platform.system() == 'Darwin':
1212
expectedException = ValueError
1313
else:
1414
expectedException = SyntaxError

0 commit comments

Comments
 (0)