refactor(rules): simplify nested block detection by removing @ prefix requirement

Changes the nested block syntax detection from requiring `@`
as the first non-space character on a line to using a line-ending brace heuristic.

The parser now recognizes nested blocks when a line ends with an unquoted `{`,
simplifying the syntax and removing the mandatory `@` prefix while maintaining the same functionality.
This commit is contained in:
yusing
2026-02-24 01:30:32 +08:00
parent 5ba475c489
commit 5b20bbeb6f
5 changed files with 131 additions and 26 deletions

View File

@@ -79,7 +79,7 @@ header Host example.com {
name: "same condition with terminating handler inside if block",
rules: `
header Host example.com {
@default {
default {
error 404 "not found"
}
}
@@ -94,7 +94,7 @@ header Host example.com {
name: "same condition with terminating handler across if else block",
rules: `
header Host example.com {
@method GET {
method GET {
error 404 "not found"
} else {
redirect https://example.com
@@ -111,7 +111,7 @@ header Host example.com {
name: "same condition with non terminating if branch in if else block",
rules: `
header Host example.com {
@method GET {
method GET {
set resp_header X-Test first
} else {
error 404 "not found"