1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-09-29 01:25:06 +03:00

b2/: add parsing of supplemental symbol information (option -X)

This commit is contained in:
Werner Almesberger 2012-05-23 17:26:35 -03:00
parent a537cc5503
commit f22378937d
6 changed files with 43 additions and 1 deletions

View File

@ -46,7 +46,7 @@ struct bom *bom_parse_line(const char *s)
s++;
for (t = s+1; *t && !isspace(*t); t++);
if (!*t)
yyerror("invalid BOM record (1)\n");
yyerror("invalid BOM record");
ref = unique_n(s, t-s);
if (bom_find(ref))
@ -86,3 +86,16 @@ struct bom *bom_parse_line(const char *s)
}
return b;
}
void bom_set_sym(const char *ref, const char *sym)
{
struct bom *b;
b = bom_find(ref);
if (!b)
yyerrorf("cannot find component reference \"%s\"", ref);
if (b->sym)
yyerrorf("symbol is already set in \"%s\"", ref);
b->sym = sym;
}

View File

@ -30,5 +30,6 @@ extern int n_bom;
struct bom *bom_parse_line(const char *s);
void bom_set_sym(const char *ref, const char *sym);
#endif /* !BOM_H */

View File

@ -83,6 +83,7 @@ static void usage(const char *name)
" -p providers\n"
" -s substitutions\n"
" -b KiCad eeschema BOM\n"
" -X symbols (BOM supplement)\n"
" -q var=value ... run substitutions with the specified inputs\n"
" -Q var=value ... run substitutions and then do parametric search\n"
, name);
@ -110,6 +111,8 @@ int main(int argc, char **argv)
process = parse_substitutions;
else if (!strcmp(argv[i], "-b"))
process = parse_kicad_bom;
else if (!strcmp(argv[i], "-X"))
process = parse_symbols;
else if (!strcmp(argv[i], "-q"))
process = add_var;
else if (!strcmp(argv[i], "-Q")) {

View File

@ -29,6 +29,7 @@ void parse_currencies(const char *name);
void parse_providers(const char *name);
void parse_substitutions(const char *name);
void parse_kicad_bom(const char *name);
void parse_symbols(const char *name);
void yywarnf(const char *fmt, ...);
void __attribute__((noreturn)) yyerrorf(const char *fmt, ...);

View File

@ -97,6 +97,12 @@ void parse_substitutions(const char *name)
do_parse(name, START_SUBST, 0, 1);
}
void parse_symbols(const char *name)
{
do_parse(name, START_SYMBOLS, 1, 0);
}
%}

View File

@ -102,6 +102,7 @@ static struct subst *parse_jump(const char *keyword, const char *target)
%token START_HIERARCHY START_CHAR START_INVENTORY
%token START_EXCHANGE START_PROVIDERS START_SUBST START_BOM
%token START_SYMBOLS
%token BOM_EESCHEMA
%token TOK_LE TOK_GE TOK_NL
%token <s> WORD PATTERN
@ -140,6 +141,7 @@ all:
substitutions = $2;
}
| START_BOM bom
| START_SYMBOLS symbols
;
@ -669,3 +671,19 @@ bom:
* bom.c
*/
;
/* ----- Symbols (BOM supplement) ------------------------------------------ */
symbols:
| TOK_NL
| symbol symbols
;
symbol:
WORD WORD TOK_NL
{
bom_set_sym($1, $2);
}
;