Merge pull request #2110 from fitzgen/peepmatic-parse-nesting-depth
Peepmatic: Implement maximum nesting level in parser
This commit is contained in:
@@ -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