* yymore_really_used - whether to treat yymore() as really used, regardless
* of what we think based on references to it in the user's actions.
* reject_really_used - same for REJECT
+ * trace_hex - use hexadecimal numbers in trace/debug outputs instead of octals
*/
extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn,
extern int yymore_used, reject, real_reject, continued_action, in_rule;
extern int yymore_really_used, reject_really_used;
-
+extern int trace_hex;
/* Variables used in the flex input routines:
* datapos - characters on current output line
int reentrant, bison_bridge_lval, bison_bridge_lloc;
int yymore_used, reject, real_reject, continued_action, in_rule;
int yymore_really_used, reject_really_used;
+int trace_hex = 0;
int datapos, dataline, linenum;
FILE *skelfile = NULL;
int skel_ind = 0;
//buf_strdefine (&userdef_buf, "YY_NO_SET_LLOC", "1");
buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0);
break;
-
+ case OPT_HEX:
+ trace_hex = 1;
} /* switch */
} /* while scanopt() */
" -T, --trace %s should run in trace mode\n"
" -w, --nowarn do not generate warnings\n"
" -v, --verbose write summary of scanner statistics to stdout\n"
+ " --hex use hexadecimal numbers instead of octal in debug outputs\n"
"\n" "Files:\n"
" -o, --outfile=FILE specify output filename\n"
" -S, --skel=FILE specify skeleton file\n"
char *readable_form (c)
register int c;
{
- static char rform[10];
+ static char rform[20];
if ((c >= 0 && c < 32) || c >= 127) {
switch (c) {
#endif
default:
- snprintf (rform, sizeof(rform), "\\%.3o", (unsigned int) c);
+ if(trace_hex)
+ snprintf (rform, sizeof(rform), "\\x%.2x", (unsigned int) c);
+ else
+ snprintf (rform, sizeof(rform), "\\%.3o", (unsigned int) c);
return rform;
}
}
,
{"--help", OPT_HELP, 0}
, /* Produce this help message. */
+ {"--hex", OPT_HEX, 0}
+ , /* Use hexadecimals in debug/trace outputs */
{"-I", OPT_INTERACTIVE, 0}
,
{"--interactive", OPT_INTERACTIVE, 0}
OPT_FULL,
OPT_HEADER_FILE,
OPT_HELP,
+ OPT_HEX,
OPT_INTERACTIVE,
OPT_LEX_COMPAT,
OPT_POSIX_COMPAT,
break;
default:
- if (!isascii (yylval) || !isprint (yylval))
- fprintf (stderr,
- "\\%.3o",
- (unsigned int) yylval);
- else
+ if (!isascii (yylval) || !isprint (yylval)) {
+ if(trace_hex)
+ fprintf (stderr, "\\x%02x", (unsigned int) yylval);
+ else
+ fprintf (stderr, "\\%.3o", (unsigned int) yylval);
+ } else
(void) putc (yylval, stderr);
break;
}