From 4955c31e0b97fa5d0ac866df2db08bb390845a30 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 29 Mar 2022 07:02:37 -0700 Subject: case: add mixed clause. --- cppawk-case.1 | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'cppawk-case.1') 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 -- cgit v1.2.3