aboutsummaryrefslogtreecommitdiffstats
path: root/cppawk-case.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-03-29 07:02:37 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-03-29 07:02:37 -0700
commit4955c31e0b97fa5d0ac866df2db08bb390845a30 (patch)
treec1677eb5a2ecc541dedbac516f8910097140ff9f /cppawk-case.1
parentc2287bfb8bdf1648ec2683b1a8e96547fcb43513 (diff)
downloadcppawk-4955c31e0b97fa5d0ac866df2db08bb390845a30.tar.gz
cppawk-4955c31e0b97fa5d0ac866df2db08bb390845a30.tar.bz2
cppawk-4955c31e0b97fa5d0ac866df2db08bb390845a30.zip
case: add mixed clause.
Diffstat (limited to 'cppawk-case.1')
-rw-r--r--cppawk-case.119
1 files changed, 16 insertions, 3 deletions
diff --git a/cppawk-case.1 b/cppawk-case.1
index c542dc7..f048ff6 100644
--- a/cppawk-case.1
+++ b/cppawk-case.1
@@ -19,6 +19,8 @@ case \- macro for portable switch statement
print "regex case"
cbreak
+ mixed (("def", "ghi"), (/regex4/, /regex5/))
+
otherwise
print "default case"
}
@@ -40,9 +42,10 @@ cases, requiring an explicit break.
The clauses of
.BI case
are labeled with the identifiers
-.BI of
-and
+.BI of,
.BI matching,
+or
+.BI mixed
which take arguments, and are followed by one or more statements. The last one
of those statements must always be a
.BI cbreak,
@@ -55,7 +58,9 @@ Regular expression keys must use the
.BI matching
label; ordinary keys compared for equality must use the
.BI of
-label.
+label. The
+.BI mixed
+label allows for both keys to be included in one case.
The
.BI of
@@ -69,6 +74,14 @@ construct:
of (3, 4) print "3 or 4"; cbreak // correct
+The
+.BI mixed
+macro takes exactly two arguments, which are parenthesized lists of
+keys. The left list must be a list of ordinary value keys, and the
+second of regular expression literals:
+
+ mixed ((1, 2, "a"), (/xyz$/, /^\et/))
+
Each clause must specify how it terminates: whether it breaks out of the
.BI case
statement, "falls through" to the next case, or returns from the surrounding