Skip to content

more parser/codegen separation #4121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ concurrency:
env:
CARGO_ARGS: --no-default-features --features stdlib,zlib,importlib,encodings,ssl,jit
NON_WASM_PACKAGES: >-
-p rustpython-bytecode
-p rustpython-common
-p rustpython-compiler-core
-p rustpython-compiler
-p rustpython-codegen
-p rustpython-parser
-p rustpython-vm
-p rustpython-stdlib
Expand Down
49 changes: 27 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include = ["LICENSE", "Cargo.toml", "src/**/*.rs"]
[workspace]
resolver = "2"
members = [
"compiler", "compiler/ast", "compiler/bytecode", "compiler/codegen", "compiler/parser",
"compiler", "compiler/ast", "compiler/core", "compiler/codegen", "compiler/parser",
".", "common", "derive", "jit", "vm", "vm/pylib-crate", "stdlib", "wasm/lib",
]

Expand All @@ -33,28 +33,28 @@ ssl = ["rustpython-stdlib/ssl"]
ssl-vendor = ["rustpython-stdlib/ssl-vendor"]

[dependencies]
log = "0.4.16"
env_logger = { version = "0.9.0", default-features = false, features = ["atty", "termcolor"] }
clap = "2.34"
rustpython-compiler = { path = "compiler", version = "0.1.1" }
rustpython-parser = { path = "compiler/parser", version = "0.1.1" }
rustpython-vm = { path = "vm", version = "0.1.1", default-features = false, features = ["compiler"] }
rustpython-stdlib = {path = "stdlib", optional = true, default-features = false}
dirs = { package = "dirs-next", version = "2.0.0" }
num-traits = "0.2.14"
cfg-if = "1.0.0"
libc = "0.2.126"
rustpython-vm = { path = "vm", version = "0.1.1", default-features = false, features = ["compiler"] }

cfg-if = "1.0.0"
clap = "2.34"
dirs = { package = "dirs-next", version = "2.0.0" }
env_logger = { version = "0.9.0", default-features = false, features = ["atty", "termcolor"] }
flame = { version = "0.2.2", optional = true }
flamescope = { version = "0.1.2", optional = true }
libc = "0.2.126"
log = "0.4.16"
num-traits = "0.2.14"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rustyline = "10.0.0"

[dev-dependencies]
cpython = "0.7.0"
python3-sys = "0.7.0"
criterion = "0.3.5"
python3-sys = "0.7.0"

[[bench]]
name = "execution"
Expand Down
8 changes: 2 additions & 6 deletions Lib/test/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,6 @@ def test_parse(self):
b = compile('foo(1 + 1)', '<unknown>', 'exec', ast.PyCF_ONLY_AST)
self.assertEqual(ast.dump(a), ast.dump(b))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_parse_in_error(self):
try:
1/0
Expand Down Expand Up @@ -1101,8 +1099,6 @@ def test_literal_eval_malformed_dict_nodes(self):
malformed = ast.Dict(keys=[ast.Constant(1)], values=[ast.Constant(2), ast.Constant(3)])
self.assertRaises(ValueError, ast.literal_eval, malformed)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_literal_eval_trailing_ws(self):
self.assertEqual(ast.literal_eval(" -1"), -1)
self.assertEqual(ast.literal_eval("\t\t-1"), -1)
Expand All @@ -1121,8 +1117,6 @@ def test_literal_eval_malformed_lineno(self):
with self.assertRaisesRegex(ValueError, msg):
ast.literal_eval(node)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_literal_eval_syntax_errors(self):
with self.assertRaisesRegex(SyntaxError, "unexpected indent"):
ast.literal_eval(r'''
Expand Down Expand Up @@ -1767,6 +1761,8 @@ def test_stdlib_validates(self):
ast.MatchMapping([], [], rest="_"),
]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_match_validation_pattern(self):
name_x = ast.Name('x', ast.Load())
for pattern in self._MATCH_PATTERNS:
Expand Down
2 changes: 1 addition & 1 deletion benches/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn benchmark_file_execution(
pub fn benchmark_file_parsing(group: &mut BenchmarkGroup<WallTime>, name: &str, contents: &str) {
group.throughput(Throughput::Bytes(contents.len() as u64));
group.bench_function(BenchmarkId::new("rustpython", name), |b| {
b.iter(|| parse_program(contents).unwrap())
b.iter(|| parse_program(contents, name).unwrap())
});
group.bench_function(BenchmarkId::new("cpython", name), |b| {
let gil = cpython::Python::acquire_gil();
Expand Down
22 changes: 11 additions & 11 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ edition = "2021"
threading = ["parking_lot"]

[dependencies]
ascii = "1.0"
cfg-if = "1.0"
hexf-parse = "0.2.1"
lexical-parse-float = { version = "0.8.0", features = ["format"] }
libc = "0.2.126"
lock_api = "0.4"
parking_lot = { version = "0.12.0", optional = true }
num-traits = "0.2"
num-complex = "0.4.0"
num-bigint = "0.4.2"
lexical-parse-float = { version = "0.8.0", features = ["format"] }
hexf-parse = "0.2.1"
cfg-if = "1.0"
num-complex = "0.4.0"
num-traits = "0.2"
once_cell = "1.4.1"
siphasher = "0.3"
rand = "0.8"
volatile = "0.3"
parking_lot = { version = "0.12.0", optional = true }
radium = "0.7"
libc = "0.2.126"
ascii = "1.0"
rand = "0.8"
siphasher = "0.3"
unic-ucd-category = "0.9"
volatile = "0.3"

[target.'cfg(windows)'.dependencies]
widestring = "0.5.1"
5 changes: 3 additions & 2 deletions compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ authors = ["RustPython Team"]
edition = "2021"

[dependencies]
thiserror = "1.0"
rustpython-compiler-core = { path = "core" }
rustpython-codegen = { path = "codegen" }
rustpython-parser = { path = "parser" }
rustpython-bytecode = { path = "bytecode" }

thiserror = "1.0"
2 changes: 1 addition & 1 deletion compiler/ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ unparse = ["rustpython-common"]

[dependencies]
num-bigint = "0.4.3"
rustpython-compiler-core = { path = "../core" }
rustpython-common = { path = "../../common", optional = true }
rustpython-bytecode = { path = "../bytecode"}
2 changes: 1 addition & 1 deletion compiler/ast/asdl_rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def write_ast_def(mod, typeinfo, f):
#![allow(clippy::derive_partial_eq_without_eq)]

pub use crate::constant::*;
pub use crate::location::Location;
pub use crate::Location;

type Ident = String;
\n
Expand Down
2 changes: 1 addition & 1 deletion compiler/ast/src/ast_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![allow(clippy::derive_partial_eq_without_eq)]

pub use crate::constant::*;
pub use crate::location::Location;
pub use crate::Location;

type Ident = String;

Expand Down
2 changes: 1 addition & 1 deletion compiler/ast/src/constant.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use num_bigint::BigInt;
pub use rustpython_bytecode::ConversionFlag;
pub use rustpython_compiler_core::ConversionFlag;

#[derive(Debug, PartialEq)]
pub enum Constant {
Expand Down
3 changes: 1 addition & 2 deletions compiler/ast/src/fold_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::constant;
use crate::fold::Fold;
use crate::{constant, fold::Fold};

pub(crate) trait Foldable<T, U> {
type Mapped;
Expand Down
3 changes: 1 addition & 2 deletions compiler/ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ mod constant;
#[cfg(feature = "fold")]
mod fold_helpers;
mod impls;
mod location;
#[cfg(feature = "unparse")]
mod unparse;

pub use ast_gen::*;
pub use location::Location;
pub use rustpython_compiler_core::Location;

pub type Suite<U = ()> = Vec<Stmt<U>>;
79 changes: 0 additions & 79 deletions compiler/ast/src/location.rs

This file was deleted.

Loading