Merge pull request #2110 from fitzgen/peepmatic-parse-nesting-depth
Peepmatic: Implement maximum nesting level in parser
This commit is contained in:
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -392,7 +392,7 @@ dependencies = [
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
"thiserror",
|
||||
"wast 15.0.0",
|
||||
"wast 22.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1303,7 +1303,7 @@ dependencies = [
|
||||
"peepmatic-test-operator",
|
||||
"peepmatic-traits",
|
||||
"serde",
|
||||
"wast 15.0.0",
|
||||
"wast 22.0.0",
|
||||
"z3",
|
||||
]
|
||||
|
||||
@@ -1331,7 +1331,7 @@ dependencies = [
|
||||
"peepmatic-traits",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"wast 15.0.0",
|
||||
"wast 22.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1356,7 +1356,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_test",
|
||||
"thiserror",
|
||||
"wast 15.0.0",
|
||||
"wast 22.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1377,7 +1377,7 @@ version = "0.66.0"
|
||||
dependencies = [
|
||||
"peepmatic-traits",
|
||||
"serde",
|
||||
"wast 15.0.0",
|
||||
"wast 22.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2667,18 +2667,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wast"
|
||||
version = "15.0.0"
|
||||
version = "21.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a10df5277f68adee65bba117b40235f07a4cb3d59e5ec9aa86dbee180fb1bc04"
|
||||
checksum = "0b1844f66a2bc8526d71690104c0e78a8e59ffa1597b7245769d174ebb91deb5"
|
||||
dependencies = [
|
||||
"leb128",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wast"
|
||||
version = "21.0.0"
|
||||
version = "22.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b1844f66a2bc8526d71690104c0e78a8e59ffa1597b7245769d174ebb91deb5"
|
||||
checksum = "fe1220ed7f824992b426a76125a3403d048eaf0f627918e97ade0d9b9d510d20"
|
||||
dependencies = [
|
||||
"leb128",
|
||||
]
|
||||
|
||||
@@ -29,7 +29,7 @@ peepmatic = { path = "../peepmatic", optional = true, version = "0.66.0" }
|
||||
peepmatic-traits = { path = "../peepmatic/crates/traits", optional = true, version = "0.66.0" }
|
||||
peepmatic-runtime = { path = "../peepmatic/crates/runtime", optional = true, version = "0.66.0" }
|
||||
regalloc = "0.0.28"
|
||||
wast = { version = "15.0.0", optional = true }
|
||||
wast = { version = "22.0.0", optional = true }
|
||||
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.
|
||||
# Please don't add any unless they are essential to the task of creating binary
|
||||
# machine code. Integration tests that need external dependencies can be
|
||||
|
||||
@@ -15,7 +15,7 @@ peepmatic-macro = { version = "0.66.0", path = "crates/macro" }
|
||||
peepmatic-runtime = { version = "0.66.0", path = "crates/runtime", features = ["construct"] }
|
||||
peepmatic-traits = { version = "0.66.0", path = "crates/traits" }
|
||||
serde = { version = "1.0.105", features = ["derive"] }
|
||||
wast = "15.0.0"
|
||||
wast = "22.0.0"
|
||||
z3 = { version = "0.6.0", features = ["static-link-z3"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -21,4 +21,4 @@ peepmatic-test-operator = { path = "../test-operator" }
|
||||
peepmatic-traits = { path = "../traits" }
|
||||
rand = { version = "0.7.3", features = ["small_rng"] }
|
||||
serde = "1.0.106"
|
||||
wast = "15.0.0"
|
||||
wast = "22.0.0"
|
||||
|
||||
@@ -16,7 +16,7 @@ peepmatic-automata = { version = "0.66.0", path = "../automata", features = ["se
|
||||
peepmatic-traits = { version = "0.66.0", path = "../traits" }
|
||||
serde = { version = "1.0.105", features = ["derive"] }
|
||||
thiserror = "1.0.15"
|
||||
wast = { version = "15.0.0", optional = true }
|
||||
wast = { version = "22.0.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
peepmatic-test-operator = { version = "0.66.0", path = "../test-operator" }
|
||||
|
||||
@@ -9,4 +9,4 @@ edition = "2018"
|
||||
[dependencies]
|
||||
peepmatic-traits = { version = "0.66.0", path = "../traits" }
|
||||
serde = { version = "1.0.105", features = ["derive"] }
|
||||
wast = "15.0.0"
|
||||
wast = "22.0.0"
|
||||
|
||||
@@ -429,6 +429,13 @@ where
|
||||
DynAstRef<'a, TOperator>: From<&'a TOperand>,
|
||||
{
|
||||
fn parse(p: Parser<'a>) -> ParseResult<Self> {
|
||||
// Don't blow the stack with this recursive parser. We don't expect
|
||||
// nesting to ever get very deep, so it isn't worth refactoring this
|
||||
// code to be non-recursive.
|
||||
if p.parens_depth() > 25 {
|
||||
return Err(p.error("module nesting too deep"));
|
||||
}
|
||||
|
||||
let span = p.cur_span();
|
||||
p.parens(|p| {
|
||||
let operator = p.parse()?;
|
||||
@@ -816,6 +823,9 @@ mod test {
|
||||
"$var",
|
||||
"$CONST",
|
||||
"(ishl $x $(log2 $C))",
|
||||
|
||||
// Nesting too deep.
|
||||
"(iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd (iadd))))))))))))))))))))))))))))))))))))))))))))))))))",
|
||||
}
|
||||
}
|
||||
parse_operation_rhs<Operation<TestOperator, Rhs<TestOperator>>> {
|
||||
|
||||
Reference in New Issue
Block a user