This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new f51b5c7cb0 HRW4U: Allow repeated sections within a section (#12287)
f51b5c7cb0 is described below

commit f51b5c7cb012b4cd01f4cee59a200b8bf206f566
Author: Leif Hedstrom <[email protected]>
AuthorDate: Wed Jun 18 09:12:48 2025 -0500

    HRW4U: Allow repeated sections within a section (#12287)
---
 tools/hrw4u/grammar/hrw4u.g4                       | 11 ++---
 tools/hrw4u/src/visitor.py                         | 48 +++++++++++++++-------
 tools/hrw4u/tests/data/conds/access.ast.txt        |  2 +-
 tools/hrw4u/tests/data/conds/cache.ast.txt         |  2 +-
 tools/hrw4u/tests/data/conds/capture.ast.txt       |  2 +-
 tools/hrw4u/tests/data/conds/cidr.ast.txt          |  2 +-
 tools/hrw4u/tests/data/conds/cookie.ast.txt        |  2 +-
 tools/hrw4u/tests/data/conds/from-url.ast.txt      |  2 +-
 tools/hrw4u/tests/data/conds/geo.ast.txt           |  2 +-
 tools/hrw4u/tests/data/conds/http-cntl.ast.txt     |  2 +-
 tools/hrw4u/tests/data/conds/inbound.ast.txt       |  2 +-
 tools/hrw4u/tests/data/conds/internal.ast.txt      |  2 +-
 tools/hrw4u/tests/data/conds/ip.ast.txt            |  2 +-
 tools/hrw4u/tests/data/conds/method.ast.txt        |  2 +-
 tools/hrw4u/tests/data/conds/multi-if.ast.txt      |  1 +
 tools/hrw4u/tests/data/conds/multi-if.input.txt    | 15 +++++++
 tools/hrw4u/tests/data/conds/multi-if.output.txt   | 13 ++++++
 tools/hrw4u/tests/data/conds/now.ast.txt           |  2 +-
 tools/hrw4u/tests/data/conds/outbound.ast.txt      |  2 +-
 tools/hrw4u/tests/data/conds/split-if.ast.txt      |  1 +
 tools/hrw4u/tests/data/conds/split-if.input.txt    | 10 +++++
 tools/hrw4u/tests/data/conds/split-if.output.txt   | 10 +++++
 tools/hrw4u/tests/data/conds/to-url.ast.txt        |  2 +-
 tools/hrw4u/tests/data/conds/true_false.ast.txt    |  2 +-
 tools/hrw4u/tests/data/conds/txn-count.ast.txt     |  2 +-
 .../hrw4u/tests/data/examples/add-cc-path.ast.txt  |  2 +-
 tools/hrw4u/tests/data/examples/conn-drain.ast.txt |  2 +-
 tools/hrw4u/tests/data/examples/dbg-req.ast.txt    |  2 +-
 tools/hrw4u/tests/data/examples/hdr-exists.ast.txt |  2 +-
 tools/hrw4u/tests/data/examples/hsts.ast.txt       |  2 +-
 tools/hrw4u/tests/data/examples/int-header.ast.txt |  2 +-
 .../tests/data/examples/meth-resp-hdr.ast.txt      |  2 +-
 .../hrw4u/tests/data/examples/norm_status.ast.txt  |  2 +-
 tools/hrw4u/tests/data/examples/path-ext.ast.txt   |  2 +-
 .../hrw4u/tests/data/examples/rem_org_auth.ast.txt |  2 +-
 tools/hrw4u/tests/data/examples/rm-cc-out.ast.txt  |  2 +-
 tools/hrw4u/tests/data/examples/rm-int-hdr.ast.txt |  2 +-
 tools/hrw4u/tests/data/examples/rm-query.ast.txt   |  2 +-
 tools/hrw4u/tests/data/examples/run-plugin.ast.txt |  2 +-
 tools/hrw4u/tests/data/examples/teapots.ast.txt    |  2 +-
 tools/hrw4u/tests/data/examples/useless.ast.txt    |  2 +-
 tools/hrw4u/tests/data/examples/uuid.ast.txt       |  2 +-
 tools/hrw4u/tests/data/examples/x-debug.ast.txt    |  2 +-
 tools/hrw4u/tests/data/hooks/read_response.ast.txt |  2 +-
 tools/hrw4u/tests/data/hooks/remap.ast.txt         |  2 +-
 tools/hrw4u/tests/data/hooks/send_request.ast.txt  |  2 +-
 tools/hrw4u/tests/data/hooks/send_response.ast.txt |  2 +-
 tools/hrw4u/tests/data/ops/dscp.ast.txt            |  2 +-
 tools/hrw4u/tests/data/ops/expansion.ast.txt       |  2 +-
 tools/hrw4u/tests/data/ops/no-op.ast.txt           |  2 +-
 tools/hrw4u/tests/data/ops/redirect.ast.txt        |  2 +-
 tools/hrw4u/tests/data/ops/set-body.ast.txt        |  2 +-
 tools/hrw4u/tests/data/ops/set-conf.ast.txt        |  2 +-
 tools/hrw4u/tests/data/ops/skip-remap.ast.txt      |  2 +-
 tools/hrw4u/tests/data/ops/status.ast.txt          |  2 +-
 tools/hrw4u/tests/data/vars/assign.ast.txt         |  2 +-
 tools/hrw4u/tests/data/vars/bool.ast.txt           |  2 +-
 tools/hrw4u/tests/data/vars/int16.ast.txt          |  2 +-
 tools/hrw4u/tests/data/vars/int8.ast.txt           |  2 +-
 59 files changed, 141 insertions(+), 70 deletions(-)

diff --git a/tools/hrw4u/grammar/hrw4u.g4 b/tools/hrw4u/grammar/hrw4u.g4
index 68a56e6905..7b6d744012 100644
--- a/tools/hrw4u/grammar/hrw4u.g4
+++ b/tools/hrw4u/grammar/hrw4u.g4
@@ -91,13 +91,18 @@ program
 
 section
     : varSection
-    | name=IDENT LBRACE (conditional | statementList) RBRACE
+    | name=IDENT LBRACE sectionBody+ RBRACE
     ;
 
 varSection
     : VARS LBRACE variables RBRACE
     ;
 
+sectionBody
+    : statement
+    | conditional
+    ;
+
 variables
     : variableDecl+
     ;
@@ -106,10 +111,6 @@ variableDecl
     : name=IDENT COLON typeName=IDENT SEMICOLON
     ;
 
-statementList
-    : statement+
-    ;
-
 statement
     : BREAK SEMICOLON
     | functionCall SEMICOLON
diff --git a/tools/hrw4u/src/visitor.py b/tools/hrw4u/src/visitor.py
index ca1307490e..09fd55f749 100644
--- a/tools/hrw4u/src/visitor.py
+++ b/tools/hrw4u/src/visitor.py
@@ -148,20 +148,37 @@ class HRW4UVisitor(hrw4uVisitor):
         if ctx.varSection():
             return self.visitVarSection(ctx.varSection())
 
-        label = ctx.getChild(0).getText()
-        self.current_section = label
+        section = ctx.name.text
+        self.current_section = section
         try:
-            hook = self.symbol_resolver.map_hook(label)
-            self._debug(f"`{label}' -> `{hook}'")
-            self.emit_condition(f"cond %{{{hook}}} [AND]", final=True)
-
-            if ctx.conditional():
-                self.visit(ctx.conditional())
-            elif ctx.statementList():
-                self._stmt_indent += 1
-                for stmt in ctx.statementList().statement():
-                    self.visit(stmt)
-                self._stmt_indent -= 1
+            hook = self.symbol_resolver.map_hook(section)
+            self._debug(f"`{section}' -> `{hook}'")
+            emitted = False
+            after_conditional = False
+
+            for body in ctx.sectionBody():
+                if body.conditional():
+                    if emitted:
+                        self._flush_condition()
+                        self.output.append("")
+                    self.emit_condition(f"cond %{{{hook}}} [AND]", final=True)
+                    self.visit(body)
+                    emitted = True
+                    after_conditional = True
+
+                elif body.statement():
+                    if emitted and after_conditional:
+                        self._flush_condition()
+                        self.output.append("")
+                        emitted = False
+                    if not emitted:
+                        self.emit_condition(f"cond %{{{hook}}} [AND]", 
final=True)
+                        emitted = True
+                    self._stmt_indent += 1
+                    self.visit(body)
+                    self._stmt_indent -= 1
+                    after_conditional = False
+
         except Exception as e:
             raise hrw4u_error(self.filename, ctx, e)
         self._debug_exit("visitSection")
@@ -184,7 +201,10 @@ class HRW4UVisitor(hrw4uVisitor):
 
             if ctx.functionCall():
                 func, args = self._parse_function_call(ctx.functionCall())
-                symbol = self.symbol_resolver.resolve_statement_func(func, 
args)
+                subst_args = [
+                    self._substitute_strings(arg, ctx) if arg.startswith('"') 
and arg.endswith('"') else arg for arg in args
+                ]
+                symbol = self.symbol_resolver.resolve_statement_func(func, 
subst_args)
                 self.emit_statement(symbol)
                 return
 
diff --git a/tools/hrw4u/tests/data/conds/access.ast.txt 
b/tools/hrw4u/tests/data/conds/access.ast.txt
index cfaa37d4c7..8eb7c37b5e 100644
--- a/tools/hrw4u/tests/data/conds/access.ast.txt
+++ b/tools/hrw4u/tests/data/conds/access.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (functionCall access ( (argumentList (value "/tmp/bar")) )))))) 
(block { (statement inbound.req.X-Remap = (value "exists") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (functionCall access ( (argumentList (value 
"/tmp/bar")) )))))) (block { (statement inbound.req.X-Remap = (value "exists") 
;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/cache.ast.txt 
b/tools/hrw4u/tests/data/conds/cache.ast.txt
index ff2b526fca..82eaad794b 100644
--- a/tools/hrw4u/tests/data/conds/cache.ast.txt
+++ b/tools/hrw4u/tests/data/conds/cache.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable (functionCall cache ( ))) in (set [ 
(value "hit-stale") , (value "hit-fresh") ])))))) (block { (statement 
inbound.req.X-Cache = (value "hit") ;) }))) }) (section REMAP { (conditional 
(ifStatement if (condition (expression (term (factor (comparison (comparable 
(functionCall cache ( ))) == (value "hit-stale")))))) (block { (statement 
inbound.req.X-Cache-Specific = (value "hit [...]
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable (functionCall cache ( ))) in 
(set [ (value "hit-stale") , (value "hit-fresh") ])))))) (block { (statement 
inbound.req.X-Cache = (value "hit") ;) })))) }) (section REMAP { (sectionBody 
(conditional (ifStatement if (condition (expression (term (factor (comparison 
(comparable (functionCall cache ( ))) == (value "hit-stale")))))) (block { 
(statement inbound.req.X-C [...]
diff --git a/tools/hrw4u/tests/data/conds/capture.ast.txt 
b/tools/hrw4u/tests/data/conds/capture.ast.txt
index bb81a3401d..0827cb15db 100644
--- a/tools/hrw4u/tests/data/conds/capture.ast.txt
+++ b/tools/hrw4u/tests/data/conds/capture.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (term (factor (comparison (comparable inbound.url.path) ~ (regex 
/some_path_(.+)_/)))) && (factor (comparison (comparable capture.1) in (set [ 
(value "foo") , (value "bar") ])))))) (block { (statement 
inbound.req.X-Path-Capture = (value "{capture.1}") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (term (factor (comparison (comparable inbound.url.path) ~ 
(regex /some_path_(.+)_/)))) && (factor (comparison (comparable capture.1) in 
(set [ (value "foo") , (value "bar") ])))))) (block { (statement 
inbound.req.X-Path-Capture = (value "{capture.1}") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/cidr.ast.txt 
b/tools/hrw4u/tests/data/conds/cidr.ast.txt
index 782c40474d..211135c397 100644
--- a/tools/hrw4u/tests/data/conds/cidr.ast.txt
+++ b/tools/hrw4u/tests/data/conds/cidr.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable (functionCall cidr ( (argumentList (value 
8) , (value 64)) ))) in (iprange { (ip (ipv4 8.0.0.0/8)) , (ip (ipv6 
6860:d4ff:fe8b:b5c7/64)) })))))) (block { (statement inbound.req.X-CIDR = 
(value "allowed") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable (functionCall cidr ( 
(argumentList (value 8) , (value 64)) ))) in (iprange { (ip (ipv4 8.0.0.0/8)) , 
(ip (ipv6 6860:d4ff:fe8b:b5c7/64)) })))))) (block { (statement 
inbound.req.X-CIDR = (value "allowed") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/cookie.ast.txt 
b/tools/hrw4u/tests/data/conds/cookie.ast.txt
index 0e2a54b652..e7e8943660 100644
--- a/tools/hrw4u/tests/data/conds/cookie.ast.txt
+++ b/tools/hrw4u/tests/data/conds/cookie.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable cookie.foobar) ~ (regex /foo/)))))) 
(block { (statement inbound.req.X-Cookie = (value "there") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable cookie.foobar) ~ (regex 
/foo/)))))) (block { (statement inbound.req.X-Cookie = (value "there") ;) })))) 
}) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/from-url.ast.txt 
b/tools/hrw4u/tests/data/conds/from-url.ast.txt
index 262dfa7a0f..8c99a67f98 100644
--- a/tools/hrw4u/tests/data/conds/from-url.ast.txt
+++ b/tools/hrw4u/tests/data/conds/from-url.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable from.url.path) ~ (regex /foo/)))))) 
(block { (statement inbound.req.From-URL = (value "allowed") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable from.url.path) ~ (regex 
/foo/)))))) (block { (statement inbound.req.From-URL = (value "allowed") ;) 
})))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/geo.ast.txt 
b/tools/hrw4u/tests/data/conds/geo.ast.txt
index 6e0e2f2e4f..c2880c48de 100644
--- a/tools/hrw4u/tests/data/conds/geo.ast.txt
+++ b/tools/hrw4u/tests/data/conds/geo.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable geo.COUNTRY) == (value 
"US")))))) (block { (statement inbound.resp.ATS-Geo-Country = (value 
"{geo.COUNTRY}") ;) (statement inbound.resp.ATS-Geo-Country-ISO = (value 
"{geo.COUNTRY-ISO}") ;) (statement inbound.resp.ATS-Geo-ASN = (value 
"{geo.ASN}") ;) (statement inbound.resp.ATS-Geo-ASN-NAME = (value 
"{geo.ASN-NAME}") ;) }))) }) <EOF>)
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable geo.COUNTRY) == 
(value "US")))))) (block { (statement inbound.resp.ATS-Geo-Country = (value 
"{geo.COUNTRY}") ;) (statement inbound.resp.ATS-Geo-Country-ISO = (value 
"{geo.COUNTRY-ISO}") ;) (statement inbound.resp.ATS-Geo-ASN = (value 
"{geo.ASN}") ;) (statement inbound.resp.ATS-Geo-ASN-NAME = (value 
"{geo.ASN-NAME}") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/http-cntl.ast.txt 
b/tools/hrw4u/tests/data/conds/http-cntl.ast.txt
index 1767ece3b0..ed3d5a4b38 100644
--- a/tools/hrw4u/tests/data/conds/http-cntl.ast.txt
+++ b/tools/hrw4u/tests/data/conds/http-cntl.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor http.cntl.LOGGING)))) (block { (statement 
inbound.resp.X-Foo = (value "Logging on") ;) (statement http.cntl.LOGGING = 
(value false) ;) }))) }) <EOF>)
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor http.cntl.LOGGING)))) (block { (statement 
inbound.resp.X-Foo = (value "Logging on") ;) (statement http.cntl.LOGGING = 
(value false) ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/inbound.ast.txt 
b/tools/hrw4u/tests/data/conds/inbound.ast.txt
index 878c1b00a6..ae3a79e5c1 100644
--- a/tools/hrw4u/tests/data/conds/inbound.ast.txt
+++ b/tools/hrw4u/tests/data/conds/inbound.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.conn.TLS) != (value 
"")))))) (block { (statement inbound.resp.X-LOCAL-ADDR = (value 
"{inbound.conn.LOCAL-ADDR}") ;) (statement inbound.resp.X-LOCAL-PORT = (value 
"{inbound.conn.LOCAL-PORT}") ;) (statement inbound.resp.X-REMOTE-ADDR = (value 
"{inbound.conn.REMOTE-ADDR}") ;) (statement inbound.resp.X-REMOTE-PORT = (value 
"{inbound.conn.REMOTE-PORT}") ;) (state [...]
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable inbound.conn.TLS) 
!= (value "")))))) (block { (statement inbound.resp.X-LOCAL-ADDR = (value 
"{inbound.conn.LOCAL-ADDR}") ;) (statement inbound.resp.X-LOCAL-PORT = (value 
"{inbound.conn.LOCAL-PORT}") ;) (statement inbound.resp.X-REMOTE-ADDR = (value 
"{inbound.conn.REMOTE-ADDR}") ;) (statement inbound.resp.X-REMOTE-PORT = (value 
"{inbound.conn.REMOTE-PORT [...]
diff --git a/tools/hrw4u/tests/data/conds/internal.ast.txt 
b/tools/hrw4u/tests/data/conds/internal.ast.txt
index 74be9a95c9..61446f4aa6 100644
--- a/tools/hrw4u/tests/data/conds/internal.ast.txt
+++ b/tools/hrw4u/tests/data/conds/internal.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (functionCall internal ( )))))) (block { (statement 
inbound.req.X-Foo = (value "Is Internal") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (functionCall internal ( )))))) (block { (statement 
inbound.req.X-Foo = (value "Is Internal") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/ip.ast.txt 
b/tools/hrw4u/tests/data/conds/ip.ast.txt
index 53445a15f8..99aac3ac35 100644
--- a/tools/hrw4u/tests/data/conds/ip.ast.txt
+++ b/tools/hrw4u/tests/data/conds/ip.ast.txt
@@ -1 +1 @@
-(program (section SEND_REQUEST { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.ip) in (iprange { (ip 
(ipv4 192.168.0.0/16)) , (ip (ipv4 10.0.0.0/8)) })))))) (block { (statement 
outbound.req.Client-IP = (value "{inbound.ip}") ;) (statement 
outbound.req.ATS-Inbound-IP = (value "{inbound.server}") ;) (statement 
outbound.req.Server-IP = (value "{outbound.ip}") ;) (statement 
outbound.req.ATS-Outbound-IP = (value "{outbound.server}") ;) })))  [...]
+(program (section SEND_REQUEST { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable inbound.ip) in 
(iprange { (ip (ipv4 192.168.0.0/16)) , (ip (ipv4 10.0.0.0/8)) })))))) (block { 
(statement outbound.req.Client-IP = (value "{inbound.ip}") ;) (statement 
outbound.req.ATS-Inbound-IP = (value "{inbound.server}") ;) (statement 
outbound.req.Server-IP = (value "{outbound.ip}") ;) (statement 
outbound.req.ATS-Outbound-IP = (value "{outbound.serve [...]
diff --git a/tools/hrw4u/tests/data/conds/method.ast.txt 
b/tools/hrw4u/tests/data/conds/method.ast.txt
index 957d52c4e1..3152fa501d 100644
--- a/tools/hrw4u/tests/data/conds/method.ast.txt
+++ b/tools/hrw4u/tests/data/conds/method.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable inbound.method) in (set [ (value "GET") , 
(value "HEAD") ])))))) (block { (statement inbound.req.@X-Method = (value 
"{inbound.method}") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.method) in (set [ 
(value "GET") , (value "HEAD") ])))))) (block { (statement 
inbound.req.@X-Method = (value "{inbound.method}") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/multi-if.ast.txt 
b/tools/hrw4u/tests/data/conds/multi-if.ast.txt
new file mode 100644
index 0000000000..4cccdcd6f8
--- /dev/null
+++ b/tools/hrw4u/tests/data/conds/multi-if.ast.txt
@@ -0,0 +1 @@
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.url.path) == (value 
"favicon.ico")))))) (block { (statement inbound.req.X-Foo = (value "bar") ;) 
})))) (sectionBody (conditional (ifStatement if (condition (expression (term 
(factor (comparison (comparable geo.COUNTRY) == (value "KR")))))) (block { 
(statement inbound.req.X-Something-Else = (value "miles") ;) })) (elseClause 
else (block { (statement inbo [...]
diff --git a/tools/hrw4u/tests/data/conds/multi-if.input.txt 
b/tools/hrw4u/tests/data/conds/multi-if.input.txt
new file mode 100644
index 0000000000..59f522d560
--- /dev/null
+++ b/tools/hrw4u/tests/data/conds/multi-if.input.txt
@@ -0,0 +1,15 @@
+REMAP {
+    if inbound.url.path == "favicon.ico" {
+        inbound.req.X-Foo = "bar";
+    }
+
+    if geo.COUNTRY == "KR" {
+         inbound.req.X-Something-Else = "miles";
+    } else {
+         inbound.req.X-Something-Else = "leif";
+    }
+
+    if inbound.url.path in ["foo", "bar"] with PRE {
+        inbound.req.X-Path = "yes";
+    }
+}
diff --git a/tools/hrw4u/tests/data/conds/multi-if.output.txt 
b/tools/hrw4u/tests/data/conds/multi-if.output.txt
new file mode 100644
index 0000000000..23ab84a5f1
--- /dev/null
+++ b/tools/hrw4u/tests/data/conds/multi-if.output.txt
@@ -0,0 +1,13 @@
+cond %{REMAP_PSEUDO_HOOK} [AND]
+cond %{CLIENT-URL:PATH} ="favicon.ico"
+    set-header X-Foo "bar"
+
+cond %{REMAP_PSEUDO_HOOK} [AND]
+cond %{GEO:COUNTRY} ="KR"
+    set-header X-Something-Else "miles"
+else
+    set-header X-Something-Else "leif"
+
+cond %{REMAP_PSEUDO_HOOK} [AND]
+cond %{CLIENT-URL:PATH} ("foo","bar") [PRE]
+    set-header X-Path "yes"
diff --git a/tools/hrw4u/tests/data/conds/now.ast.txt 
b/tools/hrw4u/tests/data/conds/now.ast.txt
index 70c3a8d527..3d8c99231e 100644
--- a/tools/hrw4u/tests/data/conds/now.ast.txt
+++ b/tools/hrw4u/tests/data/conds/now.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.ip) in (iprange { (ip 
(ipv4 192.168.0.0/16)) , (ip (ipv4 10.0.0.0/8)) })))))) (block { (statement 
inbound.resp.X-Now = (value "{now}") ;) (statement inbound.resp.X-Year = (value 
"{now.year}") ;) (statement inbound.resp.X-Month = (value "{now.month}") ;) 
(statement inbound.resp.X-Day = (value "{now.day}") ;) (statement 
inbound.resp.X-Hour = (value "{now.hour} [...]
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable inbound.ip) in 
(iprange { (ip (ipv4 192.168.0.0/16)) , (ip (ipv4 10.0.0.0/8)) })))))) (block { 
(statement inbound.resp.X-Now = (value "{now}") ;) (statement 
inbound.resp.X-Year = (value "{now.year}") ;) (statement inbound.resp.X-Month = 
(value "{now.month}") ;) (statement inbound.resp.X-Day = (value "{now.day}") ;) 
(statement inbound.resp.X-Hour = (valu [...]
diff --git a/tools/hrw4u/tests/data/conds/outbound.ast.txt 
b/tools/hrw4u/tests/data/conds/outbound.ast.txt
index a975a9533b..45df654662 100644
--- a/tools/hrw4u/tests/data/conds/outbound.ast.txt
+++ b/tools/hrw4u/tests/data/conds/outbound.ast.txt
@@ -1 +1 @@
-(program (section SEND_REQUEST { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable outbound.url.host) ~ (regex 
/foo|bar/)))))) (block { (statement outbound.req.X-Valid = (value 
"{outbound.url.port}") ;) }))) }) <EOF>)
+(program (section SEND_REQUEST { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable outbound.url.host) 
~ (regex /foo|bar/)))))) (block { (statement outbound.req.X-Valid = (value 
"{outbound.url.port}") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/split-if.ast.txt 
b/tools/hrw4u/tests/data/conds/split-if.ast.txt
new file mode 100644
index 0000000000..8baad8f62a
--- /dev/null
+++ b/tools/hrw4u/tests/data/conds/split-if.ast.txt
@@ -0,0 +1 @@
+(program (section REMAP { (sectionBody (statement inbound.req.X-Miles = (value 
"miles") ;)) (sectionBody (statement inbound.req.X-Miles-Rank = (value "IV") 
;)) (sectionBody (conditional (ifStatement if (condition (expression (term 
(factor (comparison (comparable inbound.url.path) == (value "favicon.ico")))))) 
(block { (statement inbound.req.X-Foo = (value "bar") ;) })))) (sectionBody 
(statement inbound.req.X-Leif = (value "leif") ;)) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/split-if.input.txt 
b/tools/hrw4u/tests/data/conds/split-if.input.txt
new file mode 100644
index 0000000000..2fd00935dd
--- /dev/null
+++ b/tools/hrw4u/tests/data/conds/split-if.input.txt
@@ -0,0 +1,10 @@
+REMAP {
+    inbound.req.X-Miles = "miles";
+    inbound.req.X-Miles-Rank = "IV";
+
+    if inbound.url.path == "favicon.ico" {
+        inbound.req.X-Foo = "bar";
+    }
+
+    inbound.req.X-Leif = "leif";
+}
diff --git a/tools/hrw4u/tests/data/conds/split-if.output.txt 
b/tools/hrw4u/tests/data/conds/split-if.output.txt
new file mode 100644
index 0000000000..3d67e0be91
--- /dev/null
+++ b/tools/hrw4u/tests/data/conds/split-if.output.txt
@@ -0,0 +1,10 @@
+cond %{REMAP_PSEUDO_HOOK} [AND]
+    set-header X-Miles "miles"
+    set-header X-Miles-Rank "IV"
+
+cond %{REMAP_PSEUDO_HOOK} [AND]
+cond %{CLIENT-URL:PATH} ="favicon.ico"
+    set-header X-Foo "bar"
+
+cond %{REMAP_PSEUDO_HOOK} [AND]
+    set-header X-Leif "leif"
diff --git a/tools/hrw4u/tests/data/conds/to-url.ast.txt 
b/tools/hrw4u/tests/data/conds/to-url.ast.txt
index 876a3f82b2..18f4ce90ea 100644
--- a/tools/hrw4u/tests/data/conds/to-url.ast.txt
+++ b/tools/hrw4u/tests/data/conds/to-url.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable to.url.path) ~ (regex /foo/)))))) (block 
{ (statement inbound.req.To-URL = (value "allowed") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable to.url.path) ~ (regex 
/foo/)))))) (block { (statement inbound.req.To-URL = (value "allowed") ;) })))) 
}) <EOF>)
diff --git a/tools/hrw4u/tests/data/conds/true_false.ast.txt 
b/tools/hrw4u/tests/data/conds/true_false.ast.txt
index 3496a10f91..346878564d 100644
--- a/tools/hrw4u/tests/data/conds/true_false.ast.txt
+++ b/tools/hrw4u/tests/data/conds/true_false.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (expression (term (factor true))) || (term (factor false)))) (block 
{ (statement inbound.resp.X-foo = (value "bar") ;) }))) }) <EOF>)
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (expression (term (factor true))) || (term (factor 
false)))) (block { (statement inbound.resp.X-foo = (value "bar") ;) })))) }) 
<EOF>)
diff --git a/tools/hrw4u/tests/data/conds/txn-count.ast.txt 
b/tools/hrw4u/tests/data/conds/txn-count.ast.txt
index db04e0e16c..940a076881 100644
--- a/tools/hrw4u/tests/data/conds/txn-count.ast.txt
+++ b/tools/hrw4u/tests/data/conds/txn-count.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (term (factor (comparison (comparable from.url.path) ~ (regex /foo/)))) 
&& (factor (comparison (comparable (functionCall txn-count ( ))) > (value 
10)))))) (block { (statement inbound.req.@Client-Txn-Count = (value 
"{txn-count()}") ;) }))) }) (section SEND_RESPONSE { (conditional (ifStatement 
if (condition (expression (term (term (factor (comparison (comparable 
from.url.path) ~ (regex /foo/)))) && (factor  [...]
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (term (factor (comparison (comparable from.url.path) ~ (regex 
/foo/)))) && (factor (comparison (comparable (functionCall txn-count ( ))) > 
(value 10)))))) (block { (statement inbound.req.@Client-Txn-Count = (value 
"{txn-count()}") ;) })))) }) (section SEND_RESPONSE { (sectionBody (conditional 
(ifStatement if (condition (expression (term (term (factor (comparison 
(comparable from.url.path) ~ ( [...]
diff --git a/tools/hrw4u/tests/data/examples/add-cc-path.ast.txt 
b/tools/hrw4u/tests/data/examples/add-cc-path.ast.txt
index 36079647f9..930407e050 100644
--- a/tools/hrw4u/tests/data/examples/add-cc-path.ast.txt
+++ b/tools/hrw4u/tests/data/examples/add-cc-path.ast.txt
@@ -1 +1 @@
-(program (section READ_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.url.path) ~ (regex 
/examplepath1/)))))) (block { (statement outbound.resp.Cache-Control = (value 
"max-age=3600") ;) (statement break ;) }))) }) (section READ_RESPONSE { 
(conditional (ifStatement if (condition (expression (term (factor (comparison 
(comparable inbound.url.path) ~ (regex /examplepath2\/examplepath3\/.*/)))))) 
(block { (statement outbound.resp.C [...]
+(program (section READ_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable inbound.url.path) 
~ (regex /examplepath1/)))))) (block { (statement outbound.resp.Cache-Control = 
(value "max-age=3600") ;) (statement break ;) })))) }) (section READ_RESPONSE { 
(sectionBody (conditional (ifStatement if (condition (expression (term (factor 
(comparison (comparable inbound.url.path) ~ (regex 
/examplepath2\/examplepath3\/.*/)))))) (block { [...]
diff --git a/tools/hrw4u/tests/data/examples/conn-drain.ast.txt 
b/tools/hrw4u/tests/data/examples/conn-drain.ast.txt
index ef81dacb35..4019b44770 100644
--- a/tools/hrw4u/tests/data/examples/conn-drain.ast.txt
+++ b/tools/hrw4u/tests/data/examples/conn-drain.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor ! (factor (functionCall access ( (argumentList (value 
"/path/to/the/healthcheck/file.txt}")) ))))))) (block { (statement 
inbound.resp.Connection = (value "close") ;) }))) }) <EOF>)
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor ! (factor (functionCall access ( 
(argumentList (value "/path/to/the/healthcheck/file.txt}")) ))))))) (block { 
(statement inbound.resp.Connection = (value "close") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/dbg-req.ast.txt 
b/tools/hrw4u/tests/data/examples/dbg-req.ast.txt
index 4d307bd3ec..5e1184c094 100644
--- a/tools/hrw4u/tests/data/examples/dbg-req.ast.txt
+++ b/tools/hrw4u/tests/data/examples/dbg-req.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable inbound.req.X-Debug) == (value 
"supersekret")))))) (block { (statement (functionCall set-debug ( )) ;) }))) }) 
<EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.req.X-Debug) == 
(value "supersekret")))))) (block { (statement (functionCall set-debug ( )) ;) 
})))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/hdr-exists.ast.txt 
b/tools/hrw4u/tests/data/examples/hdr-exists.ast.txt
index 6d8e83b5a4..54e01dd495 100644
--- a/tools/hrw4u/tests/data/examples/hdr-exists.ast.txt
+++ b/tools/hrw4u/tests/data/examples/hdr-exists.ast.txt
@@ -1 +1 @@
-(program (section READ_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (term (term (factor (comparison (comparable 
outbound.resp.Cache-Control) == (value "")))) && (factor (comparison 
(comparable outbound.status) > (value 199)))) && (factor (comparison 
(comparable outbound.status) < (value 300)))))) (block { (statement 
outbound.resp.Cache-Control = (value "max-age=600, public") ;) }))) }) <EOF>)
+(program (section READ_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (term (term (factor (comparison (comparable 
outbound.resp.Cache-Control) == (value "")))) && (factor (comparison 
(comparable outbound.status) > (value 199)))) && (factor (comparison 
(comparable outbound.status) < (value 300)))))) (block { (statement 
outbound.resp.Cache-Control = (value "max-age=600, public") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/hsts.ast.txt 
b/tools/hrw4u/tests/data/examples/hsts.ast.txt
index 42084fdc83..d9b2866618 100644
--- a/tools/hrw4u/tests/data/examples/hsts.ast.txt
+++ b/tools/hrw4u/tests/data/examples/hsts.ast.txt
@@ -1 +1 @@
-(program (section READ_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (term (factor (comparison (comparable 
outbound.resp.Strict-Transport-Security) == (value "")))) && (factor 
(comparison (comparable inbound.conn.TLS) != (value "")))))) (block { 
(statement outbound.resp.Strict-Transport-Security = (value "max-age=63072000; 
includeSubDomains; preload") ;) }))) }) <EOF>)
+(program (section READ_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (term (factor (comparison (comparable 
outbound.resp.Strict-Transport-Security) == (value "")))) && (factor 
(comparison (comparable inbound.conn.TLS) != (value "")))))) (block { 
(statement outbound.resp.Strict-Transport-Security = (value "max-age=63072000; 
includeSubDomains; preload") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/int-header.ast.txt 
b/tools/hrw4u/tests/data/examples/int-header.ast.txt
index b7e9086987..4d0e33c608 100644
--- a/tools/hrw4u/tests/data/examples/int-header.ast.txt
+++ b/tools/hrw4u/tests/data/examples/int-header.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (statementList (statement inbound.req.@PropertyName 
= (value "someproperty") ;)) }) <EOF>)
+(program (section REMAP { (sectionBody (statement inbound.req.@PropertyName = 
(value "someproperty") ;)) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/meth-resp-hdr.ast.txt 
b/tools/hrw4u/tests/data/examples/meth-resp-hdr.ast.txt
index 0aacf3475d..184dc63010 100644
--- a/tools/hrw4u/tests/data/examples/meth-resp-hdr.ast.txt
+++ b/tools/hrw4u/tests/data/examples/meth-resp-hdr.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (statementList (statement 
inbound.resp.X-Original-Method = (value "{inbound.method}") ;)) }) <EOF>)
+(program (section SEND_RESPONSE { (sectionBody (statement 
inbound.resp.X-Original-Method = (value "{inbound.method}") ;)) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/norm_status.ast.txt 
b/tools/hrw4u/tests/data/examples/norm_status.ast.txt
index d9cd795a03..e2f42071e6 100644
--- a/tools/hrw4u/tests/data/examples/norm_status.ast.txt
+++ b/tools/hrw4u/tests/data/examples/norm_status.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (term (factor (comparison (comparable inbound.status) > 
(value 399)))) && (factor (comparison (comparable inbound.status) < (value 
500)))))) (block { (statement inbound.status = (value 404) ;) }))) }) <EOF>)
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (term (factor (comparison (comparable 
inbound.status) > (value 399)))) && (factor (comparison (comparable 
inbound.status) < (value 500)))))) (block { (statement inbound.status = (value 
404) ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/path-ext.ast.txt 
b/tools/hrw4u/tests/data/examples/path-ext.ast.txt
index 93ea3ef521..68d371da71 100644
--- a/tools/hrw4u/tests/data/examples/path-ext.ast.txt
+++ b/tools/hrw4u/tests/data/examples/path-ext.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable inbound.url.path) == (value "php") 
(modifier with (modifierList EXT , NOCASE))))))) (block { (statement 
inbound.status = (value 403) ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.url.path) == (value 
"php") (modifier with (modifierList EXT , NOCASE))))))) (block { (statement 
inbound.status = (value 403) ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/rem_org_auth.ast.txt 
b/tools/hrw4u/tests/data/examples/rem_org_auth.ast.txt
index 1d896bf078..05c3f048a3 100644
--- a/tools/hrw4u/tests/data/examples/rem_org_auth.ast.txt
+++ b/tools/hrw4u/tests/data/examples/rem_org_auth.ast.txt
@@ -1 +1 @@
-(program (section READ_RESPONSE { (statementList (statement 
outbound.resp.Set-Cookie = (value "") ;) (statement 
outbound.resp.WWW-Authenticate = (value "") ;)) }) <EOF>)
+(program (section READ_RESPONSE { (sectionBody (statement 
outbound.resp.Set-Cookie = (value "") ;)) (sectionBody (statement 
outbound.resp.WWW-Authenticate = (value "") ;)) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/rm-cc-out.ast.txt 
b/tools/hrw4u/tests/data/examples/rm-cc-out.ast.txt
index 28d8e590ef..b0524dead2 100644
--- a/tools/hrw4u/tests/data/examples/rm-cc-out.ast.txt
+++ b/tools/hrw4u/tests/data/examples/rm-cc-out.ast.txt
@@ -1 +1 @@
-(program (section SEND_REQUEST { (statementList (statement 
outbound.req.Cache-Control = (value "") ;) (statement outbound.req.Pragma = 
(value "") ;)) }) <EOF>)
+(program (section SEND_REQUEST { (sectionBody (statement 
outbound.req.Cache-Control = (value "") ;)) (sectionBody (statement 
outbound.req.Pragma = (value "") ;)) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/rm-int-hdr.ast.txt 
b/tools/hrw4u/tests/data/examples/rm-int-hdr.ast.txt
index aa504bfdfb..17f825e973 100644
--- a/tools/hrw4u/tests/data/examples/rm-int-hdr.ast.txt
+++ b/tools/hrw4u/tests/data/examples/rm-int-hdr.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable inbound.req.X-Debug) != (value 
"keep")))))) (block { (statement inbound.req.X-Debug-Foo = (value "") ;) 
(statement inbound.req.X-Debug-Bar = (value "") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.req.X-Debug) != 
(value "keep")))))) (block { (statement inbound.req.X-Debug-Foo = (value "") ;) 
(statement inbound.req.X-Debug-Bar = (value "") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/rm-query.ast.txt 
b/tools/hrw4u/tests/data/examples/rm-query.ast.txt
index 19b242dc94..c125ddaad8 100644
--- a/tools/hrw4u/tests/data/examples/rm-query.ast.txt
+++ b/tools/hrw4u/tests/data/examples/rm-query.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (statementList (statement inbound.url.query = (value 
"") ;)) }) (section REMAP { (statementList (statement (functionCall 
remove_query ( (argumentList (value "foo,bar")) )) ;)) }) (section REMAP { 
(statementList (statement (functionCall keep_query ( (argumentList (value 
"foo,bar")) )) ;)) }) <EOF>)
+(program (section REMAP { (sectionBody (statement inbound.url.query = (value 
"") ;)) }) (section REMAP { (sectionBody (statement (functionCall remove_query 
( (argumentList (value "foo,bar")) )) ;)) }) (section REMAP { (sectionBody 
(statement (functionCall keep_query ( (argumentList (value "foo,bar")) )) ;)) 
}) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/run-plugin.ast.txt 
b/tools/hrw4u/tests/data/examples/run-plugin.ast.txt
index 71614ab69b..0e88af83c6 100644
--- a/tools/hrw4u/tests/data/examples/run-plugin.ast.txt
+++ b/tools/hrw4u/tests/data/examples/run-plugin.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable inbound.req.Some-Special-Header) == 
(value "yes")))))) (block { (statement (functionCall run-plugin ( (argumentList 
(value "/opt/ats/libexec/trafficserver/rate_limit.so") , (value "--limit=300") 
, (value "--error=429")) )) ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable 
inbound.req.Some-Special-Header) == (value "yes")))))) (block { (statement 
(functionCall run-plugin ( (argumentList (value 
"/opt/ats/libexec/trafficserver/rate_limit.so") , (value "--limit=300") , 
(value "--error=429")) )) ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/teapots.ast.txt 
b/tools/hrw4u/tests/data/examples/teapots.ast.txt
index 9e13e5e5d8..04f281e414 100644
--- a/tools/hrw4u/tests/data/examples/teapots.ast.txt
+++ b/tools/hrw4u/tests/data/examples/teapots.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable outbound.status) == (value 
418)))))) (block { (statement (functionCall counter ( (argumentList (value 
"plugin.header_rewrite.teapots")) )) ;) }))) }) <EOF>)
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable outbound.status) 
== (value 418)))))) (block { (statement (functionCall counter ( (argumentList 
(value "plugin.header_rewrite.teapots")) )) ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/useless.ast.txt 
b/tools/hrw4u/tests/data/examples/useless.ast.txt
index 3122fa9da6..b2bb7a5c62 100644
--- a/tools/hrw4u/tests/data/examples/useless.ast.txt
+++ b/tools/hrw4u/tests/data/examples/useless.ast.txt
@@ -1 +1 @@
-(program (section READ_RESPONSE { (conditional (ifStatement if (condition 
(expression (expression (term (term (term (term (factor (comparison (comparable 
inbound.url.port) == (value 8090)))) && (factor (comparison (comparable 
inbound.method) == (value "HEAD")))) && (factor (comparison (comparable 
inbound.req.Accept-Language) !~ (regex /es-py/)))) && (factor (comparison 
(comparable outbound.status) == (value 304))))) || (term (factor (comparison 
(comparable (functionCall random ( (argumen [...]
+(program (section READ_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (expression (term (term (term (term (factor (comparison 
(comparable inbound.url.port) == (value 8090)))) && (factor (comparison 
(comparable inbound.method) == (value "HEAD")))) && (factor (comparison 
(comparable inbound.req.Accept-Language) !~ (regex /es-py/)))) && (factor 
(comparison (comparable outbound.status) == (value 304))))) || (term (factor 
(comparison (comparable (functionCall rand [...]
diff --git a/tools/hrw4u/tests/data/examples/uuid.ast.txt 
b/tools/hrw4u/tests/data/examples/uuid.ast.txt
index 23c9fe19ff..0135f561bc 100644
--- a/tools/hrw4u/tests/data/examples/uuid.ast.txt
+++ b/tools/hrw4u/tests/data/examples/uuid.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (expression (term (factor (comparison (comparable 
inbound.resp.ATS-SRVR-UUID) == (value ""))))) || (term (factor (comparison 
(comparable (functionCall cache ( ))) == (value "hit-fresh")))))) (block { 
(statement inbound.resp.ATS-SRVR-UUID = (value "{id.UNIQUE}") ;) }))) }) <EOF>)
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (expression (term (factor (comparison (comparable 
inbound.resp.ATS-SRVR-UUID) == (value ""))))) || (term (factor (comparison 
(comparable (functionCall cache ( ))) == (value "hit-fresh")))))) (block { 
(statement inbound.resp.ATS-SRVR-UUID = (value "{id.UNIQUE}") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/examples/x-debug.ast.txt 
b/tools/hrw4u/tests/data/examples/x-debug.ast.txt
index 58c61661d4..0ede75379b 100644
--- a/tools/hrw4u/tests/data/examples/x-debug.ast.txt
+++ b/tools/hrw4u/tests/data/examples/x-debug.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.resp.All-Cache) != 
(value "")))))) (block { (statement inbound.resp.All-Cache = (value 
"{inbound.resp.All-Cache} {cache()}") ;) }))) }) (section SEND_RESPONSE { 
(conditional (ifStatement if (condition (expression (term (factor (comparison 
(comparable inbound.resp.All-Cache) == (value "")))))) (block { (statement 
inbound.resp.All-Cache = (value "{cache()}") ; [...]
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable 
inbound.resp.All-Cache) != (value "")))))) (block { (statement 
inbound.resp.All-Cache = (value "{inbound.resp.All-Cache} {cache()}") ;) })))) 
}) (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable 
inbound.resp.All-Cache) == (value "")))))) (block { (statement 
inbound.resp.All-Ca [...]
diff --git a/tools/hrw4u/tests/data/hooks/read_response.ast.txt 
b/tools/hrw4u/tests/data/hooks/read_response.ast.txt
index e33600f78e..2b74d05332 100644
--- a/tools/hrw4u/tests/data/hooks/read_response.ast.txt
+++ b/tools/hrw4u/tests/data/hooks/read_response.ast.txt
@@ -1 +1 @@
-(program (section READ_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable 
outbound.resp.X-Read-Response) == (value "yes")))))) (block { (statement 
outbound.resp.X-Read-Response = (value "") ;) }))) }) <EOF>)
+(program (section READ_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable 
outbound.resp.X-Read-Response) == (value "yes")))))) (block { (statement 
outbound.resp.X-Read-Response = (value "") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/hooks/remap.ast.txt 
b/tools/hrw4u/tests/data/hooks/remap.ast.txt
index b52e0dab57..8b6128a24c 100644
--- a/tools/hrw4u/tests/data/hooks/remap.ast.txt
+++ b/tools/hrw4u/tests/data/hooks/remap.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable inbound.req.X-Remap) == (value 
"yes")))))) (block { (statement inbound.req.X-Remap = (value "") ;) })) 
(elseClause else (block { (statement inbound.req.X-Remap = (value "It was not 
yes") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.req.X-Remap) == 
(value "yes")))))) (block { (statement inbound.req.X-Remap = (value "") ;) })) 
(elseClause else (block { (statement inbound.req.X-Remap = (value "It was not 
yes") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/hooks/send_request.ast.txt 
b/tools/hrw4u/tests/data/hooks/send_request.ast.txt
index a7a371feae..b1fddcf382 100644
--- a/tools/hrw4u/tests/data/hooks/send_request.ast.txt
+++ b/tools/hrw4u/tests/data/hooks/send_request.ast.txt
@@ -1 +1 @@
-(program (section SEND_REQUEST { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable outbound.req.X-Send-Request) 
== (value "yes")))))) (block { (statement outbound.req.X-Send-Request = (value 
"") ;) }))) }) <EOF>)
+(program (section SEND_REQUEST { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable 
outbound.req.X-Send-Request) == (value "yes")))))) (block { (statement 
outbound.req.X-Send-Request = (value "") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/hooks/send_response.ast.txt 
b/tools/hrw4u/tests/data/hooks/send_response.ast.txt
index 98871e0e56..5258f7809e 100644
--- a/tools/hrw4u/tests/data/hooks/send_response.ast.txt
+++ b/tools/hrw4u/tests/data/hooks/send_response.ast.txt
@@ -1 +1 @@
-(program (section SEND_RESPONSE { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.resp.X-Send-Response) 
== (value "yes")))))) (block { (statement outbound.resp.X-Send-Response = 
(value "") ;) }))) }) <EOF>)
+(program (section SEND_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable 
inbound.resp.X-Send-Response) == (value "yes")))))) (block { (statement 
outbound.resp.X-Send-Response = (value "") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/ops/dscp.ast.txt 
b/tools/hrw4u/tests/data/ops/dscp.ast.txt
index 55ac7768a7..d01628c2b4 100644
--- a/tools/hrw4u/tests/data/ops/dscp.ast.txt
+++ b/tools/hrw4u/tests/data/ops/dscp.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor true)))) (block { (statement inbound.conn.dscp = (value 17) ;) 
}))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor true)))) (block { (statement inbound.conn.dscp = 
(value 17) ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/ops/expansion.ast.txt 
b/tools/hrw4u/tests/data/ops/expansion.ast.txt
index 29b2f6018f..5c4e52d5da 100644
--- a/tools/hrw4u/tests/data/ops/expansion.ast.txt
+++ b/tools/hrw4u/tests/data/ops/expansion.ast.txt
@@ -1 +1 @@
-(program (section (varSection VARS { (variables (variableDecl foo : int8 ;)) 
})) (section REMAP { (statementList (statement foo = (value 17) ;)) }) (section 
SEND_RESPONSE { (statementList (statement inbound.resp.X-Foo = (value "Foo is 
{foo}") ;) (statement inbound.resp.X-Random = (value "Random is {random(100)}") 
;) (statement inbound.resp.X-Hdr = (value "Header is {inbound.req.X-Hdr}") ;)) 
}) <EOF>)
+(program (section (varSection VARS { (variables (variableDecl foo : int8 ;)) 
})) (section REMAP { (sectionBody (statement foo = (value 17) ;)) }) (section 
SEND_RESPONSE { (sectionBody (statement inbound.resp.X-Foo = (value "Foo is 
{foo}") ;)) (sectionBody (statement inbound.resp.X-Random = (value "Random is 
{random(100)}") ;)) (sectionBody (statement inbound.resp.X-Hdr = (value "Header 
is {inbound.req.X-Hdr}") ;)) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/ops/no-op.ast.txt 
b/tools/hrw4u/tests/data/ops/no-op.ast.txt
index 3edac62191..34cd2dec66 100644
--- a/tools/hrw4u/tests/data/ops/no-op.ast.txt
+++ b/tools/hrw4u/tests/data/ops/no-op.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (statementList (statement (functionCall no-op ( )) 
;)) }) <EOF>)
+(program (section REMAP { (sectionBody (statement (functionCall no-op ( )) ;)) 
}) <EOF>)
diff --git a/tools/hrw4u/tests/data/ops/redirect.ast.txt 
b/tools/hrw4u/tests/data/ops/redirect.ast.txt
index d19afb8671..75c534cd53 100644
--- a/tools/hrw4u/tests/data/ops/redirect.ast.txt
+++ b/tools/hrw4u/tests/data/ops/redirect.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable inbound.req.X-Auth-Me) !~ (regex 
/foo/)))))) (block { (statement (functionCall set-redirect ( (argumentList 
(value 302) , (value "https://example.com/foo";)) )) ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.req.X-Auth-Me) !~ 
(regex /foo/)))))) (block { (statement (functionCall set-redirect ( 
(argumentList (value 302) , (value "https://example.com/foo";)) )) ;) })))) }) 
<EOF>)
diff --git a/tools/hrw4u/tests/data/ops/set-body.ast.txt 
b/tools/hrw4u/tests/data/ops/set-body.ast.txt
index 5719269fb4..1d8f844dbc 100644
--- a/tools/hrw4u/tests/data/ops/set-body.ast.txt
+++ b/tools/hrw4u/tests/data/ops/set-body.ast.txt
@@ -1 +1 @@
-(program (section (varSection VARS { (variables (variableDecl myFlag : bool 
;)) })) (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable inbound.req.X-Foo) == (value "bar")))))) 
(block { (statement inbound.resp.body = (value "This is a response body") ;) 
})) (elseClause else (block { (statement myFlag = (value true) ;) }))) }) 
(section READ_RESPONSE { (conditional (ifStatement if (condition (expression 
(term (factor myFlag)))) (block  [...]
+(program (section (varSection VARS { (variables (variableDecl myFlag : bool 
;)) })) (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.req.X-Foo) == (value 
"bar")))))) (block { (statement inbound.resp.body = (value "This is a response 
body") ;) })) (elseClause else (block { (statement myFlag = (value true) ;) 
})))) }) (section READ_RESPONSE { (sectionBody (conditional (ifStatement if 
(condition (expression (term [...]
diff --git a/tools/hrw4u/tests/data/ops/set-conf.ast.txt 
b/tools/hrw4u/tests/data/ops/set-conf.ast.txt
index 9ce6b263fb..b612814871 100644
--- a/tools/hrw4u/tests/data/ops/set-conf.ast.txt
+++ b/tools/hrw4u/tests/data/ops/set-conf.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor true)))) (block { (statement (functionCall set-config ( 
(argumentList (value "proxy.config.http.cache.http") , (value 0)) )) ;) }))) }) 
<EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor true)))) (block { (statement (functionCall set-config 
( (argumentList (value "proxy.config.http.cache.http") , (value 0)) )) ;) })))) 
}) <EOF>)
diff --git a/tools/hrw4u/tests/data/ops/skip-remap.ast.txt 
b/tools/hrw4u/tests/data/ops/skip-remap.ast.txt
index 260282e3f7..22a23d4e92 100644
--- a/tools/hrw4u/tests/data/ops/skip-remap.ast.txt
+++ b/tools/hrw4u/tests/data/ops/skip-remap.ast.txt
@@ -1 +1 @@
-(program (section SEND_REQUEST { (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.req.path) ~ (regex 
/foo/)))))) (block { (statement (functionCall skip-remap ( (argumentList (value 
True)) )) ;) }))) }) <EOF>)
+(program (section SEND_REQUEST { (sectionBody (conditional (ifStatement if 
(condition (expression (term (factor (comparison (comparable inbound.req.path) 
~ (regex /foo/)))))) (block { (statement (functionCall skip-remap ( 
(argumentList (value True)) )) ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/ops/status.ast.txt 
b/tools/hrw4u/tests/data/ops/status.ast.txt
index ac896c3928..4a35f055df 100644
--- a/tools/hrw4u/tests/data/ops/status.ast.txt
+++ b/tools/hrw4u/tests/data/ops/status.ast.txt
@@ -1 +1 @@
-(program (section (varSection VARS { (variables (variableDecl goAway : bool 
;)) })) (section REMAP { (conditional (ifStatement if (condition (expression 
(term (factor (comparison (comparable inbound.req.X-Allow) == (value 
"yes")))))) (block { (statement http.status = (value 403) ;) (statement goAway 
= (value true) ;) }))) }) (section SEND_RESPONSE { (conditional (ifStatement if 
(condition (expression (term (factor goAway)))) (block { (statement 
http.status.reason = (value "Go Away") ;) } [...]
+(program (section (varSection VARS { (variables (variableDecl goAway : bool 
;)) })) (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable inbound.req.X-Allow) == 
(value "yes")))))) (block { (statement http.status = (value 403) ;) (statement 
goAway = (value true) ;) })))) }) (section SEND_RESPONSE { (sectionBody 
(conditional (ifStatement if (condition (expression (term (factor goAway)))) 
(block { (statement http.status.reas [...]
diff --git a/tools/hrw4u/tests/data/vars/assign.ast.txt 
b/tools/hrw4u/tests/data/vars/assign.ast.txt
index 0f1ee77477..4a296bebdd 100644
--- a/tools/hrw4u/tests/data/vars/assign.ast.txt
+++ b/tools/hrw4u/tests/data/vars/assign.ast.txt
@@ -1 +1 @@
-(program (section (varSection VARS { (variables (variableDecl foo : bool ;) 
(variableDecl bar : bool ;)) })) (section REMAP { (statementList (statement bar 
= (value foo) ;)) }) <EOF>)
+(program (section (varSection VARS { (variables (variableDecl foo : bool ;) 
(variableDecl bar : bool ;)) })) (section REMAP { (sectionBody (statement bar = 
(value foo) ;)) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/vars/bool.ast.txt 
b/tools/hrw4u/tests/data/vars/bool.ast.txt
index e15338bba7..b74ec875b6 100644
--- a/tools/hrw4u/tests/data/vars/bool.ast.txt
+++ b/tools/hrw4u/tests/data/vars/bool.ast.txt
@@ -1 +1 @@
-(program (section (varSection VARS { (variables (variableDecl Flag : bool ;)) 
})) (section REMAP { (conditional (ifStatement if (condition (expression (term 
(factor Flag)))) (block { (statement inbound.req.X-foo = (value "bar") ;) }))) 
}) <EOF>)
+(program (section (varSection VARS { (variables (variableDecl Flag : bool ;)) 
})) (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor Flag)))) (block { (statement inbound.req.X-foo = 
(value "bar") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/vars/int16.ast.txt 
b/tools/hrw4u/tests/data/vars/int16.ast.txt
index d8877c7149..fcdb5f1018 100644
--- a/tools/hrw4u/tests/data/vars/int16.ast.txt
+++ b/tools/hrw4u/tests/data/vars/int16.ast.txt
@@ -1 +1 @@
-(program (section (varSection VARS { (variables (variableDecl Num : int16 ;)) 
})) (section REMAP { (conditional (ifStatement if (condition (expression (term 
(factor (comparison (comparable Num) > (value 12345)))))) (block { (statement 
inbound.req.X-foo = (value "bar") ;) }))) }) <EOF>)
+(program (section (varSection VARS { (variables (variableDecl Num : int16 ;)) 
})) (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable Num) > (value 12345)))))) 
(block { (statement inbound.req.X-foo = (value "bar") ;) })))) }) <EOF>)
diff --git a/tools/hrw4u/tests/data/vars/int8.ast.txt 
b/tools/hrw4u/tests/data/vars/int8.ast.txt
index a056211d10..8a7b6a1180 100644
--- a/tools/hrw4u/tests/data/vars/int8.ast.txt
+++ b/tools/hrw4u/tests/data/vars/int8.ast.txt
@@ -1 +1 @@
-(program (section (varSection VARS { (variables (variableDecl Num : int8 ;)) 
})) (section REMAP { (conditional (ifStatement if (condition (expression (term 
(factor (comparison (comparable Num) > (value 123)))))) (block { (statement 
inbound.req.X-foo = (value "bar") ;) }))) }) <EOF>)
+(program (section (varSection VARS { (variables (variableDecl Num : int8 ;)) 
})) (section REMAP { (sectionBody (conditional (ifStatement if (condition 
(expression (term (factor (comparison (comparable Num) > (value 123)))))) 
(block { (statement inbound.req.X-foo = (value "bar") ;) })))) }) <EOF>)

Reply via email to