Skip to content

Commit d6c059a

Browse files
committed
lalrpop as default but optional dependency
1 parent bd4b1a1 commit d6c059a

File tree

10 files changed

+28
-23
lines changed

10 files changed

+28
-23
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ ssl = ["rustpython-stdlib/ssl"]
3333
ssl-vendor = ["rustpython-stdlib/ssl-vendor"]
3434

3535
[dependencies]
36-
rustpython-compiler = { path = "compiler", version = "0.1.1" }
37-
rustpython-parser = { path = "compiler/parser", version = "0.1.1" }
36+
rustpython-compiler = { path = "compiler", version = "0.1.1", default-features = false }
37+
rustpython-parser = { path = "compiler/parser", version = "0.1.1", optional = true, default-features = false }
3838
rustpython-stdlib = {path = "stdlib", optional = true, default-features = false}
3939
rustpython-vm = { path = "vm", version = "0.1.1", default-features = false, features = ["compiler"] }
4040

compiler/Cargo.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
[package]
22
name = "rustpython-compiler"
33
version = "0.1.2"
4-
description = "A usability wrapper around rustpython-parser and rustpython-compiler-core"
4+
description = "A usability wrapper around rustpython-parser and rustpython-codegen"
55
authors = ["RustPython Team"]
66
edition = "2021"
77

8+
[features]
9+
default = ["rustpython-parser/lalrpop"]
10+
811
[dependencies]
912
rustpython-compiler-core = { path = "core" }
1013
rustpython-codegen = { path = "codegen" }
11-
rustpython-parser = { path = "parser" }
14+
rustpython-parser = { path = "parser", default-features = false }
1215

1316
thiserror = "1.0"

compiler/codegen/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ num-traits = "0.2.14"
2020
thiserror = "1.0"
2121

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

2525
insta = "1.14.0"

compiler/parser/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ repository = "https://github.com/RustPython/RustPython"
88
license = "MIT"
99
edition = "2021"
1010

11+
[features]
12+
default = ["lalrpop"]
13+
1114
[build-dependencies]
1215
anyhow = "1.0.45"
1316
lalrpop = { version = "0.19.8", optional = true }

compiler/parser/src/error.rs

+7
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ impl fmt::Display for ParseErrorType {
195195
}
196196

197197
impl ParseErrorType {
198+
pub fn is_eof(&self) -> bool {
199+
match self {
200+
ParseErrorType::Lexical(LexicalErrorType::Eof) => true,
201+
ParseErrorType::Eof => true,
202+
_ => false,
203+
}
204+
}
198205
pub fn is_indentation_error(&self) -> bool {
199206
match self {
200207
ParseErrorType::Lexical(LexicalErrorType::IndentationError) => true,

derive/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ proc-macro = true
1212

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

src/shell.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
mod helper;
22

3-
use rustpython_parser::error::{LexicalErrorType, ParseErrorType};
43
use rustpython_vm::{
54
builtins::PyBaseExceptionRef,
65
compiler::{self, CompileError, CompileErrorBody, CompileErrorType},
@@ -24,19 +23,11 @@ fn shell_exec(vm: &VirtualMachine, source: &str, scope: Scope) -> ShellExecResul
2423
Err(CompileError {
2524
body:
2625
CompileErrorBody {
27-
error: CompileErrorType::Parse(ParseErrorType::Lexical(LexicalErrorType::Eof)),
26+
error: CompileErrorType::Parse(parse_error),
2827
..
2928
},
3029
..
31-
})
32-
| Err(CompileError {
33-
body:
34-
CompileErrorBody {
35-
error: CompileErrorType::Parse(ParseErrorType::Eof),
36-
..
37-
},
38-
..
39-
}) => ShellExecResult::Continue,
30+
}) if parse_error.is_eof() => ShellExecResult::Continue,
4031
Err(err) => ShellExecResult::PyErr(vm.new_syntax_error(&err)),
4132
}
4233
}

stdlib/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ssl-vendor = ["ssl", "openssl/vendored", "openssl-probe"]
1515
[dependencies]
1616
# rustpython crates
1717
rustpython-derive = { path = "../derive" }
18-
rustpython-vm = { path = "../vm" }
18+
rustpython-vm = { path = "../vm", default-features = false }
1919
rustpython-common = { path = "../common" }
2020

2121
# random

vm/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2021"
99
include = ["src/**/*.rs", "Cargo.toml", "build.rs", "Lib/**/*.py"]
1010

1111
[features]
12-
default = ["compiler"]
12+
default = ["compiler", "rustpython-parser?/lalrpop"]
1313
importlib = []
1414
encodings = ["importlib"]
1515
vm-tracing-logging = []
@@ -23,9 +23,9 @@ codegen = ["rustpython-codegen", "ast"]
2323
parser = ["rustpython-parser", "ast"]
2424

2525
[dependencies]
26-
rustpython-compiler = { path = "../compiler", optional = true, version = "0.1.2" }
26+
rustpython-compiler = { path = "../compiler", optional = true, version = "0.1.2", default-features = false }
2727
rustpython-ast = { path = "../compiler/ast", optional = true, version = "0.1" }
28-
rustpython-parser = { path = "../compiler/parser", optional = true, version = "0.1.2" }
28+
rustpython-parser = { path = "../compiler/parser", optional = true, version = "0.1.2", default-features = false }
2929
rustpython-codegen = { path = "../compiler/codegen", optional = true, version = "0.1.2" }
3030
rustpython-compiler-core = { path = "../compiler/core", version = "0.1.2" }
3131
rustpython-common = { path = "../common" }

wasm/lib/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ edition = "2021"
1111
crate-type = ["cdylib", "rlib"]
1212

1313
[features]
14-
default = ["freeze-stdlib", "rustpython-stdlib"]
14+
default = ["freeze-stdlib", "stdlib", "rustpython-parser/lalrpop"]
15+
stdlib = ["rustpython-stdlib"]
1516
freeze-stdlib = ["rustpython-vm/freeze-stdlib"]
1617
no-start-func = []
1718

1819
[dependencies]
1920
rustpython-common = { path = "../../common" }
20-
rustpython-parser = { path = "../../compiler/parser" }
21+
rustpython-parser = { path = "../../compiler/parser", default-features = false }
2122
rustpython-stdlib = { path = "../../stdlib", default-features = false, optional = true }
2223
# make sure no threading! otherwise wasm build will fail
2324
rustpython-vm = { path = "../../vm", default-features = false, features = ["compiler", "encodings"] }

0 commit comments

Comments
 (0)