From: Yann Ylavic expr
.
- However, a few directives like cond
.
+ Directives like string
.
@@ -335,6 +376,21 @@ listfunction ::= listfuncname "(" word ")"-expr ::= "true" | "false" - | "!" expr - | expr "&&" expr - | expr "||" expr - | "(" expr ")" +expr ::= cond + | string + +string ::= substring + | string substring + +cond ::= "true" + | "false" + | "!" cond + | cond "&&" cond + | cond "||" cond | comp + | "(" cond ")" comp ::= stringcomp | integercomp | unaryop word | word binaryop word - | word "in" "{" wordlist "}" - | word "in" listfunction + | word "in" listfunc | word "=~" regex | word "!~" regex + | word "in" "{" list "}" stringcomp ::= word "==" word @@ -118,35 +130,64 @@ integercomp ::= word "-eq" word | word "eq" wo | word "-gt" word | word "gt" word | word "-ge" word | word "ge" word -wordlist ::= word - | wordlist "," word - -word ::= word "." word - | digit +word ::= digits | "'" string "'" - | """ string """ + | '"' string '"' + | word "." word | variable - | rebackref + | sub + | join | function + | "(" word ")" -string ::= stringpart - | string stringpart +list ::= split + | listfunc + | "{" words "}" + | "(" list ")" -stringpart ::= cstring +substring ::= cstring | variable - | rebackref - -cstring ::= ... -digit ::= [0-9]+ variable ::= "%{" varname "}" | "%{" funcname ":" funcargs "}" + | "%{:" word ":}" + | "%{:" cond ":}" + | rebackref + +sub ::= "sub" ["("] regsub "," word [")"] + +join ::= "join" ["("] list [")"] + | "join" ["("] list "," word [")"] + +split ::= "split" ["("] regany "," list [")"] + | "split" ["("] regany "," word [")"] + +function ::= funcname "(" words ")" -rebackref ::= "$" [0-9] +listfunc ::= listfuncname "(" words ")" -function ::= funcname "(" wordlist ")" +words ::= word + | word "," list -listfunction ::= listfuncname "(" word ")" +regex ::= "/" regpattern "/" [regflags] + | "m" regsep regpattern regsep [regflags] + +regsub ::= "s" regsep regpattern regsep string regsep [regflags] + +regany ::= regex | regsub + +regsep ::= "/" | "#" | "$" | "%" | "^" | "|" | "?" | "!" | "'" | '"' | "," | ";" | ":" | "." | "_" | "-" + +regflags ::= 1*("i" | "s" | "m" | "g") +regpattern ::= cstring ; except enclosing regsep + +rebackref ::= "$" DIGIT + +digits ::= 1*(DIGIT) +cstring ::= 0*(TEXT) + +TEXT ::= <any OCTET except CTLs> +DIGIT ::= <any US-ASCII digit "0".."9">
Some modules register additional variables, see e.g.
Any variable can be embedded in a string, both in quoted + strings from boolean expressions but also in string expressions, + resulting in the concatenation of the constant and dynamic parts as + expected.
+ +There exists another form of variables (temporaries) expressed like
+ %{:word:}
and which allow embedding of the more
+ powerful word syntax (and constructs) in both type of expressions,
+ without colliding with the constant part of such strings. They are mainly
+ useful in string expressions though, since the word is directly
+ available in boolean expressions already. By using this form of variables,
+ one can evaluate regexes, substitutions, join and/or split strings and
+ lists in the scope of string expressions, hence construct complex strings
+ dynamically.
In addition to string-valued functions, there are also
list-valued functions which take one string as argument and return a
- wordlist, i.e. a list of strings. The wordlist can be used with the
+ list, i.e. a list of strings. The list can be used with the
special -in
operator. Functions names are not case
sensitive. Modules may register additional functions.
-in
in
/regexp/
m#regexp#