Root/b2/SUBST

1FN=DNP { ignore }
2
3FN=X(*) { $=$1 }
4
5/* iteration demo */
6FOO=abcde
7BAR=x /* BAR= wouldn't be syntactically correct. We need a non-empty value */
8FOO=(*)(?) {
9    BAR=$BAR$2
10    FOO=$1
11    continue
12}
13BAR=x(*) { $=$1 } /* remove the "x" */
14
15REF=R[0-9]* {
16    T=R
17    VAL=(#R) { R=$1 }
18    TOL <= 5%
19    FN=*% { TOL<=$$ }
20    break REF
21// end break continue ignore
22}
23
24/*
25pattern:
26  () | like in RE
27  * ? like in glob
28  (#U) expect a numeric value of unit U (use substring to get canonical value)
29
30subst: $1 ... $field
31
32substring:
33  $1, $2, ...
34variable:
35  $foo, ...
36with curly braces:
37  ${foo}, ...
38input variable (in pattern):
39  $$
40
41the input variable ($) can also be used as LHS for matches, assignments, and
42as break/continue target.
43
44  Caveat:
45
46  Wrong: FN=* { X=$FN } there is no variable called FN
47  Right: FN=* { X=$$ } yields the Fn field selected by FN
48
49  Wrong: VAL=(#R) { R=$VAL } yields literal value
50  Wrong: VAL=(#R) { R=$$ } yields literal value
51  Right: VAL=(#R) { R=$1 } yield canonicalized value
52*/
53

Archive Download this file

Branches:
master



interactive