mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-16 18:51:53 +02:00
b2/: add "ignore" keyword for substitution rules
This allows us to decide in the project-specific rules how to indicate DNP/NC/DNS/... parts. In the original BOOM, F1 == NC was hard-coded.
This commit is contained in:
parent
2014e6053e
commit
d2171eba47
4
b2/SUBST
4
b2/SUBST
@ -1,10 +1,12 @@
|
||||
FN=DNP { ignore }
|
||||
|
||||
REF=R[0-9]* {
|
||||
T=R
|
||||
VAL=(#R) { R=$1 }
|
||||
TOL <= 5%
|
||||
FN=*% { TOL<=$$ }
|
||||
break REF
|
||||
// end break again
|
||||
// end break again ignore
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -48,7 +48,10 @@ static void do_substitutions(void)
|
||||
const struct param *var;
|
||||
const struct part **parts, **p;
|
||||
|
||||
out = substitute(substitutions, vars);
|
||||
if (!substitute(substitutions, vars, &out)) {
|
||||
fprintf(stderr, "ignore\n");
|
||||
return;
|
||||
}
|
||||
if (select_parts) {
|
||||
parts = select_parametric(out, &hierarchy);
|
||||
if (!parts) {
|
||||
|
@ -613,9 +613,12 @@ block:
|
||||
}
|
||||
| WORD
|
||||
{
|
||||
if (strcmp($1, "end"))
|
||||
yyerrorf("unknown keyword \"%s\"", $1);
|
||||
if (!strcmp($1, "end"))
|
||||
$$ = subst_end();
|
||||
else if (!strcmp($1, "ignore"))
|
||||
$$ = subst_ignore();
|
||||
else
|
||||
yyerrorf("unknown keyword \"%s\"", $1);
|
||||
}
|
||||
;
|
||||
|
||||
|
14
b2/subex.c
14
b2/subex.c
@ -30,9 +30,9 @@
|
||||
|
||||
static const char *fn = NULL, *f[FIELDS];
|
||||
|
||||
/* Jump target that can never be reached. */
|
||||
/* Jump targets that can never be reached. */
|
||||
static struct subst jump_end;
|
||||
|
||||
static struct subst jump_ignore;
|
||||
|
||||
|
||||
static char *canonicalize(const char *s, char unit)
|
||||
@ -206,6 +206,8 @@ static const struct subst *recurse_sub(const struct subst *sub,
|
||||
break;
|
||||
case st_end:
|
||||
return &jump_end;
|
||||
case st_ignore:
|
||||
return &jump_ignore;
|
||||
case st_break:
|
||||
sub = sub->u.jump->next;
|
||||
continue;
|
||||
@ -221,9 +223,9 @@ static const struct subst *recurse_sub(const struct subst *sub,
|
||||
}
|
||||
|
||||
|
||||
struct param *substitute(const struct subst *sub, const struct param *in)
|
||||
int substitute(const struct subst *sub, const struct param *in,
|
||||
struct param **out)
|
||||
{
|
||||
struct param *out = NULL;
|
||||
int i;
|
||||
char tmp[4];
|
||||
|
||||
@ -234,6 +236,6 @@ struct param *substitute(const struct subst *sub, const struct param *in)
|
||||
f[i] = unique(tmp);
|
||||
}
|
||||
}
|
||||
recurse_sub(sub, in, NULL, NULL, NULL, &out);
|
||||
return out;
|
||||
*out = NULL;
|
||||
return recurse_sub(sub, in, NULL, NULL, NULL, out) != &jump_ignore;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "subst.h"
|
||||
|
||||
|
||||
struct param *substitute(const struct subst *sub, const struct param *in);
|
||||
int substitute(const struct subst *sub, const struct param *in,
|
||||
struct param **out);
|
||||
|
||||
#endif /* !SUBEX_H */
|
||||
|
11
b2/subst.c
11
b2/subst.c
@ -245,6 +245,12 @@ struct subst *subst_end(void)
|
||||
}
|
||||
|
||||
|
||||
struct subst *subst_ignore(void)
|
||||
{
|
||||
return alloc_subst(st_ignore);
|
||||
}
|
||||
|
||||
|
||||
struct subst *subst_break(const char *block)
|
||||
{
|
||||
struct subst *sub;
|
||||
@ -357,6 +363,8 @@ static void recurse_fin(struct subst *sub, const struct parent *parent)
|
||||
break;
|
||||
case st_end:
|
||||
break;
|
||||
case st_ignore:
|
||||
break;
|
||||
case st_break:
|
||||
case st_again:
|
||||
sub->u.jump = resolve_jump(sub->u.tmp, parent);
|
||||
@ -425,6 +433,9 @@ static void recurse_dump(FILE *file, const struct subst *sub, int level)
|
||||
case st_end:
|
||||
fprintf(file, "end\n");
|
||||
break;
|
||||
case st_ignore:
|
||||
fprintf(file, "ignore\n");
|
||||
break;
|
||||
case st_break:
|
||||
fprintf(file, "break %s\n", sub->u.jump->u.match.src);
|
||||
break;
|
||||
|
12
b2/subst.h
12
b2/subst.h
@ -37,11 +37,12 @@ struct chunk {
|
||||
};
|
||||
|
||||
enum subst_type {
|
||||
st_match,
|
||||
st_assign,
|
||||
st_end,
|
||||
st_break,
|
||||
st_again,
|
||||
st_match, /* try to match a variable */
|
||||
st_assign, /* assign to a variable */
|
||||
st_end, /* end the substitutions, accepting the part */
|
||||
st_ignore, /* ignore the part */
|
||||
st_break, /* jump to an outer block */
|
||||
st_again, /* repeat an outer block */
|
||||
};
|
||||
|
||||
struct subst {
|
||||
@ -73,6 +74,7 @@ struct subst {
|
||||
struct subst *subst_match(const char *src, const char *re);
|
||||
struct subst *subst_assign(const char *dst, enum relop op, const char *pat);
|
||||
struct subst *subst_end(void);
|
||||
struct subst *subst_ignore(void);
|
||||
struct subst *subst_break(const char *block);
|
||||
struct subst *subst_again(const char *block);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user