Skip to content

Commit f8776c2

Browse files
committed
logg
1 parent e07ea2a commit f8776c2

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

src/parser.y

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ typedef struct {
7575
#include <stdlib.h>
7676
#include <unictype.h>
7777

78+
#include "logging.h"
7879
#include "shape.h"
7980
#include "tools.h"
8081
#include "parsing.h"
@@ -199,10 +200,8 @@ config_file: config_file design_or_error | design_or_error | config_file parent_
199200
design_or_error: design | error
200201
{
201202
/* reset alias list, as those are collected even when speedmode is on */
202-
#ifdef PARSER_DEBUG
203-
fprintf (stderr, " Parser: Discarding token [skipping=%s, speeding=%s]\n",
203+
log_debug(__FILE__, PARSER, " Parser: Discarding token [skipping=%s, speeding=%s]\n",
204204
bison_args->skipping ? "true" : "false", bison_args->speeding ? "true" : "false");
205-
#endif
206205
if (curdes.aliases[0] != NULL) {
207206
BFREE(curdes.aliases);
208207
curdes.aliases = (char **) calloc(1, sizeof(char *));
@@ -268,10 +267,10 @@ entry: KEYWORD STRING
268267
yyerror(bison_args, "string expected");
269268
YYERROR;
270269
}
271-
else {
272-
#ifdef PARSER_DEBUG
273-
fprintf (stderr, " Parser: Discarding entry [%s = %s].\n", "parent", bxs_to_output(filename));
274-
#endif
270+
else if (is_debug_logging(PARSER)) {
271+
char *out_filename = bxs_to_output(filename);
272+
log_debug(__FILE__, PARSER, " Parser: Discarding entry [%s = %s].\n", "parent", out_filename);
273+
BFREE(out_filename);
275274
}
276275
}
277276

@@ -284,9 +283,11 @@ entry: KEYWORD STRING
284283

285284
| BXWORD STRING | ASCII_ID STRING
286285
{
287-
#ifdef PARSER_DEBUG
288-
fprintf (stderr, " Parser: Discarding entry [%s = %s].\n", $1, bxs_to_output($2));
289-
#endif
286+
if (is_debug_logging(PARSER)) {
287+
char *out_string = bxs_to_output($2);
288+
log_debug(__FILE__, PARSER, " Parser: Discarding entry [%s = %s].\n", $1, out_string);
289+
BFREE(out_string);
290+
}
290291
}
291292
;
292293

@@ -323,10 +324,8 @@ block: YSAMPLE STRING YENDSAMPLE
323324

324325
| YPADDING '{' wlist '}'
325326
{
326-
#ifdef PARSER_DEBUG
327-
fprintf (stderr, "Padding set to (l%d o%d r%d u%d)\n",
327+
log_debug(__FILE__, PARSER, "Padding set to (l%d o%d r%d u%d)\n",
328328
curdes.padding[BLEF], curdes.padding[BTOP], curdes.padding[BRIG], curdes.padding[BBOT]);
329-
#endif
330329
}
331330
;
332331

@@ -347,9 +346,7 @@ elist: elist ',' elist_entry | elist_entry;
347346

348347
elist_entry: SHAPE
349348
{
350-
#ifdef PARSER_DEBUG
351-
fprintf (stderr, "Marked \'%s\' shape as elastic\n", shape_name[(int) $1]);
352-
#endif
349+
log_debug(__FILE__, PARSER, "Marked \'%s\' shape as elastic\n", shape_name[(int) $1]);
353350
curdes.shape[$1].elastic = 1;
354351
}
355352
;
@@ -360,10 +357,8 @@ slist: slist slist_entry | slist_entry;
360357

361358
slist_entry: SHAPE shape_def
362359
{
363-
#ifdef PARSER_DEBUG
364-
fprintf (stderr, "Adding shape spec for \'%s\' (width %d "
365-
"height %d)\n", shape_name[$1], (int) $2.width, (int) $2.height);
366-
#endif
360+
log_debug(__FILE__, PARSER, "Adding shape spec for \'%s\' (width %d height %d)\n",
361+
shape_name[$1], (int) $2.width, (int) $2.height);
367362

368363
if (isempty (curdes.shape + $1)) {
369364
curdes.shape[$1] = $2;

0 commit comments

Comments
 (0)