File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ import (
1010 "github.com/tdewolff/parse/v2/buffer"
1111)
1212
13+ var NestedStmtLimit = 1000
14+ var NestedExprLimit = 1000
15+
1316type Options struct {
1417 WhileToFor bool
1518 Inline bool
@@ -223,7 +226,7 @@ func (p *Parser) parseModule() (module BlockStmt) {
223226
224227func (p * Parser ) parseStmt (allowDeclaration bool ) (stmt IStmt ) {
225228 p .stmtLevel ++
226- if 1000 < p .stmtLevel {
229+ if NestedStmtLimit < p .stmtLevel {
227230 p .failMessage ("too many nested statements" )
228231 return nil
229232 }
@@ -1613,7 +1616,7 @@ func (p *Parser) parseAsyncExpression(prec OpPrec, async []byte) IExpr {
16131616// parseExpression parses an expression that has a precedence of prec or higher.
16141617func (p * Parser ) parseExpression (prec OpPrec ) IExpr {
16151618 p .exprLevel ++
1616- if 1000 < p .exprLevel {
1619+ if NestedExprLimit < p .exprLevel {
16171620 p .failMessage ("too many nested expressions" )
16181621 return nil
16191622 }
You can’t perform that action at this time.
0 commit comments