mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-22 21:57:32 +02:00
b2/: introduce unit pattern (##), for dimensionless values
This commit is contained in:
parent
e93ff0e683
commit
cc895fe7fc
@ -48,7 +48,7 @@ static char *canonicalize(const char *s, char unit)
|
|||||||
return stralloc(s);
|
return stralloc(s);
|
||||||
res = stralloc("");
|
res = stralloc("");
|
||||||
while (*s) {
|
while (*s) {
|
||||||
if (*s == unit) {
|
if (*s == unit && unit != '#') {
|
||||||
assert(!seen_unit);
|
assert(!seen_unit);
|
||||||
if (!s[1])
|
if (!s[1])
|
||||||
break;
|
break;
|
||||||
@ -82,7 +82,8 @@ static char *canonicalize(const char *s, char unit)
|
|||||||
res_len--;
|
res_len--;
|
||||||
if (mult)
|
if (mult)
|
||||||
append_char(&res, &res_len, mult);
|
append_char(&res, &res_len, mult);
|
||||||
append_char(&res, &res_len, unit);
|
if (unit != '#')
|
||||||
|
append_char(&res, &res_len, unit);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,9 +55,11 @@ static struct subst *alloc_subst(enum subst_type type)
|
|||||||
static void unit_expr(char **res, int *res_len, char unit)
|
static void unit_expr(char **res, int *res_len, char unit)
|
||||||
{
|
{
|
||||||
append(res, res_len, "(-?[0-9]+\\.?[0-9]*[" MULT_CHARS "]?");
|
append(res, res_len, "(-?[0-9]+\\.?[0-9]*[" MULT_CHARS "]?");
|
||||||
append_char(res, res_len, unit);
|
if (unit != '#')
|
||||||
|
append_char(res, res_len, unit);
|
||||||
append(res, res_len, "?|-?[0-9]+[");
|
append(res, res_len, "?|-?[0-9]+[");
|
||||||
append_char(res, res_len, unit);
|
if (unit != '#')
|
||||||
|
append_char(res, res_len, unit);
|
||||||
append(res, res_len, MULT_CHARS "][0-9]*)");
|
append(res, res_len, MULT_CHARS "][0-9]*)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +92,8 @@ static char *prepare_re(const char *re, char *units)
|
|||||||
case '(':
|
case '(':
|
||||||
parens++;
|
parens++;
|
||||||
if (re[1] == '#' && re[2]) {
|
if (re[1] == '#' && re[2]) {
|
||||||
if ((!isalpha(re[2]) && re[2] != '%') ||
|
if ((!isalpha(re[2]) &&
|
||||||
|
re[2] != '%' && re[2] != '#') ||
|
||||||
re[3] != ')')
|
re[3] != ')')
|
||||||
yyerrorf("invalid (#unit) syntax");
|
yyerrorf("invalid (#unit) syntax");
|
||||||
units[parens-1] = re[2];
|
units[parens-1] = re[2];
|
||||||
|
Loading…
Reference in New Issue
Block a user