1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2025-04-21 12:27:27 +03:00

b2/: finish unit handling and move most of its processing to the match side

The ${foo#unit} syntax didn't really make sense because it created
a large number of potential error conditions on the assignment side
and didn't help with finding compatible fields.

With all this moved to the match side, an invalid syntax simply causes
a mismatch.
This commit is contained in:
Werner Almesberger
2012-05-20 21:55:54 -03:00
parent adecef8d4a
commit 99e5777448
4 changed files with 124 additions and 55 deletions

View File

@@ -1,14 +1,18 @@
REF=R[0-9]* {
T=R
VAL=* { R=$$#R }
VAL=(#R) { R=$1 }
TOL = 5%
FN=*% { TOL=${$#%} }
FN=*% { TOL=$$ }
break REF
// end break again
}
/*
pattern: () * ? .
pattern:
() | like in RE
* ? like in glob
(#U) expect a numeric value of unit U (use substring to get canonical value)
subst: $1 ... $field
substring:
@@ -17,9 +21,15 @@ variable:
$foo, ...
with curly braces:
${foo}, ...
unit conversion:
$foo#V
${1#R}
input variable:
$$
Caveat:
Wrong: FN=* { X=$FN } there is no variable called FN
Right: FN=* { X=$$ } yields the Fn field selected by FN
Wrong: VAL=(#R) { R=$VAL } yields literal value
Wrong: VAL=(#R) { R=$$ } yields literal value
Right: VAL=(#R) { R=$1 } yield canonicalized value
*/