Date:2012-05-30 17:58:29 (11 years 9 months ago)
Author:Werner Almesberger
Commit:59d21e65fa9e31b597cc0412c492d69024142cb9
Message:new option -v to control verbosity level; move hierarchy dump from parser to boom.c

Files: b2/Makefile (1 diff)
b2/boom.c (5 diffs)
b2/lang.y (1 diff)
b2/test/Common (1 diff)

Change Details

b2/Makefile
9191# ----- Experiments -----------------------------------------------------------
9292
9393try:
94    $(VALGRIND) ./boom HIERARCHY -c CHAR -x CURR -p PROVIDER -i INV \
94    $(VALGRIND) ./boom -v HIERARCHY -c CHAR -x CURR -p PROVIDER -i INV \
9595      -s SUBST
9696
9797# ----- Tests -----------------------------------------------------------------
b2/boom.c
1717#include "util.h"
1818#include "lang.h"
1919#include "param.h"
20#include "chr.h"
2021#include "subex.h"
2122#include "db.h"
2223
2324
2425static struct param *vars = NULL, **last_var = &vars;
2526static int select_parts = 0;
27static int verbose = 0;
2628
2729
2830static void add_var(const char *arg)
...... 
7274}
7375
7476
77static void dump_hierarchy(struct action act)
78{
79    fields_dump(stderr, act.fields);
80    if (act.fields)
81        fprintf(stderr, "\n");
82    rules_dump(stderr, act.rules);
83}
84
85
7586static void usage(const char *name)
7687{
7788    fprintf(stderr,
78"usage: %s file [[-N name] [-type] file ...] [(-q|-Q) var=value ...] ...\n\n"
89"usage: %s file [-v] [[-N name] [-type] file ...] [(-q|-Q) var=value ...] ...\n\n"
7990" file types:\n"
8091" -c characteristics\n"
8192" -i inventory\n"
...... 
8596" -b KiCad eeschema BOM\n"
8697" -X symbols (BOM supplement)\n"
8798" other options:\n"
99" -v ... increase verbosity level\n"
88100" -N name for the next file, override the name in diagnostics\n"
89101" -q var=value ... run substitutions with the specified inputs\n"
90102" -Q var=value ... run substitutions and then do parametric search\n"
...... 
104116            if (!strcmp(argv[i], "-N")) {
105117                i++;
106118                file_name_override = argv[i];
107            } else if (!strcmp(argv[i], "-c"))
119            } else if (!strcmp(argv[i], "-v"))
120                verbose++;
121            else if (!strcmp(argv[i], "-c"))
108122                process = parse_characteristics;
109123            else if (!strcmp(argv[i], "-i"))
110124                process = parse_inventory;
...... 
127141                usage(*argv);
128142        } else {
129143            process(argv[i]);
144            if (verbose && process == parse_hierarchy)
145                dump_hierarchy(hierarchy);
130146        }
131147    }
132148    if (vars)
b2/lang.y
156156    | action
157157        {
158158            $$ = $1;
159            fields_dump(stderr, $1.fields);
160            if ($1.fields)
161                fprintf(stderr, "\n");
162            rules_dump(stderr, $1.rules);
163159        }
164160    ;
165161
b2/test/Common
2020            args="$args -$n <(sed -n '1,/^!-$n/d;/^!-/q;p' _in)"
2121        fi
2222    done
23    eval $VALGRIND ../boom "$args" "$@"
23    eval $VALGRIND ../boom -v "$args" "$@"
2424}
2525
2626

Archive Download the corresponding diff file

Branches:
master



interactive