feat(rules): support multiline or |

treat lines ending with unquoted `|` or `&` as continued
conditions in `do` block headers so nested blocks parse correctly
across line breaks.

update `on` condition splitting to avoid breaking on newlines that
follow an unescaped trailing pipe, while still respecting quotes,
escapes, and bracket nesting.

add coverage for multiline `|`/`&` continuations in `do` parsing,
`splitAnd`, `parseOn`, and HTTP flow nested block behavior.
This commit is contained in:
yusing
2026-02-26 16:38:54 +08:00
parent c002055892
commit a0adc51269
6 changed files with 217 additions and 80 deletions

View File

@@ -309,7 +309,8 @@ nested_block := on_expr ws* '{' do_body '}'
Notes:
- A nested block is recognized when a line ends with an unquoted `{` (ignoring trailing whitespace).
- A nested block is recognized when a logical header ends with an unquoted `{`.
- Logical headers can continue to the next line when the current line ends with `|` or `&`.
- `on_expr` uses the same syntax as rule `on` (supports `|`, `&`, quoting/backticks, matcher functions, etc.).
- The nested block executes **in sequence**, at the point where it appears in the parent `do` list.
- Nested blocks are evaluated in the same phase the parent rule runs (no special phase promotion).
@@ -424,6 +425,15 @@ path !glob("/public/*")
# OR within a line
method GET | method POST
# OR across multiple lines (line continuation)
method GET |
method POST |
method PUT
# AND across multiple lines
header Connection Upgrade &
header Upgrade websocket
```
### Variable Substitution