Skip to content

lalrpop as default but optional dependency #4129

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
if: runner.os == 'macOS'
- uses: Swatinem/rust-cache@v1
- name: run rust tests
run: cargo test --workspace --exclude rustpython_wasm --verbose --features threading ${{ env.CARGO_ARGS }} ${{ env.NON_WASM_PACKAGES }}
run: cargo test --workspace --exclude rustpython_wasm --verbose --features threading,rustpython-parser ${{ env.CARGO_ARGS }} ${{ env.NON_WASM_PACKAGES }}
- name: check compilation without threading
run: cargo check ${{ env.CARGO_ARGS }}

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ ssl = ["rustpython-stdlib/ssl"]
ssl-vendor = ["rustpython-stdlib/ssl-vendor"]

[dependencies]
rustpython-compiler = { path = "compiler", version = "0.1.1" }
rustpython-parser = { path = "compiler/parser", version = "0.1.1" }
rustpython-compiler = { path = "compiler", version = "0.1.1", default-features = false }
rustpython-parser = { path = "compiler/parser", version = "0.1.1", optional = true, default-features = false }
rustpython-stdlib = {path = "stdlib", optional = true, default-features = false}
rustpython-vm = { path = "vm", version = "0.1.1", default-features = false, features = ["compiler"] }

Expand Down
7 changes: 5 additions & 2 deletions compiler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[package]
name = "rustpython-compiler"
version = "0.1.2"
description = "A usability wrapper around rustpython-parser and rustpython-compiler-core"
description = "A usability wrapper around rustpython-parser and rustpython-codegen"
authors = ["RustPython Team"]
edition = "2021"

[features]
default = ["rustpython-parser/lalrpop"]

[dependencies]
rustpython-compiler-core = { path = "core" }
rustpython-codegen = { path = "codegen" }
rustpython-parser = { path = "parser" }
rustpython-parser = { path = "parser", default-features = false }

thiserror = "1.0"
2 changes: 1 addition & 1 deletion compiler/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ num-traits = "0.2.14"
thiserror = "1.0"

[dev-dependencies]
rustpython-parser = { path = "../parser" }
rustpython-parser = { path = "../parser", default-features = false }

insta = "1.14.0"
3 changes: 3 additions & 0 deletions compiler/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository = "https://github.com/RustPython/RustPython"
license = "MIT"
edition = "2021"

[features]
default = ["lalrpop"]

[build-dependencies]
anyhow = "1.0.45"
lalrpop = { version = "0.19.8", optional = true }
Expand Down
6 changes: 6 additions & 0 deletions compiler/parser/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ impl fmt::Display for ParseErrorType {
}

impl ParseErrorType {
pub fn is_eof_error(&self) -> bool {
matches!(
self,
ParseErrorType::Lexical(LexicalErrorType::Eof) | ParseErrorType::Eof
)
}
pub fn is_indentation_error(&self) -> bool {
match self {
ParseErrorType::Lexical(LexicalErrorType::IndentationError) => true,
Expand Down
2 changes: 1 addition & 1 deletion derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ proc-macro = true

[dependencies]
rustpython-codegen = { path = "../compiler/codegen", version = "0.1.1" }
rustpython-compiler = { path = "../compiler", version = "0.1.1" }
rustpython-compiler = { path = "../compiler", version = "0.1.1", default-features = false }
rustpython-compiler-core = { path = "../compiler/core", version = "0.1.1" }
rustpython-doc = { git = "https://github.com/RustPython/__doc__", branch = "main" }

Expand Down
13 changes: 2 additions & 11 deletions src/shell.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mod helper;

use rustpython_parser::error::{LexicalErrorType, ParseErrorType};
use rustpython_vm::{
builtins::PyBaseExceptionRef,
compiler::{self, CompileError, CompileErrorBody, CompileErrorType},
Expand All @@ -24,19 +23,11 @@ fn shell_exec(vm: &VirtualMachine, source: &str, scope: Scope) -> ShellExecResul
Err(CompileError {
body:
CompileErrorBody {
error: CompileErrorType::Parse(ParseErrorType::Lexical(LexicalErrorType::Eof)),
error: CompileErrorType::Parse(parse_error),
..
},
..
})
| Err(CompileError {
body:
CompileErrorBody {
error: CompileErrorType::Parse(ParseErrorType::Eof),
..
},
..
}) => ShellExecResult::Continue,
}) if parse_error.is_eof_error() => ShellExecResult::Continue,
Err(err) => ShellExecResult::PyErr(vm.new_syntax_error(&err)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ssl-vendor = ["ssl", "openssl/vendored", "openssl-probe"]
[dependencies]
# rustpython crates
rustpython-derive = { path = "../derive" }
rustpython-vm = { path = "../vm" }
rustpython-vm = { path = "../vm", default-features = false }
rustpython-common = { path = "../common" }

# random
Expand Down
6 changes: 3 additions & 3 deletions vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
include = ["src/**/*.rs", "Cargo.toml", "build.rs", "Lib/**/*.py"]

[features]
default = ["compiler"]
default = ["compiler", "rustpython-parser?/lalrpop"]
importlib = []
encodings = ["importlib"]
vm-tracing-logging = []
Expand All @@ -23,9 +23,9 @@ codegen = ["rustpython-codegen", "ast"]
parser = ["rustpython-parser", "ast"]

[dependencies]
rustpython-compiler = { path = "../compiler", optional = true, version = "0.1.2" }
rustpython-compiler = { path = "../compiler", optional = true, version = "0.1.2", default-features = false }
rustpython-ast = { path = "../compiler/ast", optional = true, version = "0.1" }
rustpython-parser = { path = "../compiler/parser", optional = true, version = "0.1.2" }
rustpython-parser = { path = "../compiler/parser", optional = true, version = "0.1.2", default-features = false }
rustpython-codegen = { path = "../compiler/codegen", optional = true, version = "0.1.2" }
rustpython-compiler-core = { path = "../compiler/core", version = "0.1.2" }
rustpython-common = { path = "../common" }
Expand Down
5 changes: 3 additions & 2 deletions wasm/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]

[features]
default = ["freeze-stdlib", "rustpython-stdlib"]
default = ["freeze-stdlib", "stdlib", "rustpython-parser/lalrpop"]
stdlib = ["rustpython-stdlib"]
freeze-stdlib = ["rustpython-vm/freeze-stdlib"]
no-start-func = []

[dependencies]
rustpython-common = { path = "../../common" }
rustpython-parser = { path = "../../compiler/parser" }
rustpython-parser = { path = "../../compiler/parser", default-features = false }
rustpython-stdlib = { path = "../../stdlib", default-features = false, optional = true }
# make sure no threading! otherwise wasm build will fail
rustpython-vm = { path = "../../vm", default-features = false, features = ["compiler", "encodings"] }
Expand Down