Index: head/sys/ddb/db_lex.h =================================================================== --- head/sys/ddb/db_lex.h +++ head/sys/ddb/db_lex.h @@ -58,17 +58,26 @@ /* * Flag bit powers of two for db_read_token_flags. * The low 2 bits are reserved for radix selection. + * + * WSPACE: Yield explicit tWSPACE tokens when one or more whitespace characters + * is consumed. + * HEX: Allow tNUMBER tokens to start with 'A'-'F' without explicit "0x" + * prefix. */ enum { _DRT_WSPACE = 2, + _DRT_HEX, }; #ifndef BIT #define BIT(n) (1ull << (n)) #endif enum { DRT_WSPACE = BIT(_DRT_WSPACE), + DRT_HEX = BIT(_DRT_HEX), }; -#define DRT_VALID_FLAGS_MASK ((int)DRT_RADIX_MASK | DRT_WSPACE) +#define DRT_VALID_FLAGS_MASK ((int)DRT_RADIX_MASK | \ + DRT_WSPACE | \ + DRT_HEX) void db_flush_lex(void); char *db_get_line(void); @@ -123,5 +132,7 @@ #define tQUESTION 33 #define tBIT_NOT 34 #define tWSPACE 35 +#define tCOLON 36 +#define tCOLONCOLON 37 #endif /* !_DDB_DB_LEX_H_ */ Index: head/sys/ddb/db_lex.c =================================================================== --- head/sys/ddb/db_lex.c +++ head/sys/ddb/db_lex.c @@ -163,7 +163,7 @@ db_lex(int flags) { int c, n, radix_mode; - bool lex_wspace; + bool lex_wspace, lex_hex_numbers; switch (flags & DRT_RADIX_MASK) { case DRT_DEFAULT_RADIX: @@ -181,6 +181,7 @@ } lex_wspace = ((flags & DRT_WSPACE) != 0); + lex_hex_numbers = ((flags & DRT_HEX) != 0); c = db_read_char(); for (n = 0; c <= ' ' || c > '~'; n++) { @@ -193,13 +194,16 @@ return (tWSPACE); } - if (c >= '0' && c <= '9') { + if ((c >= '0' && c <= '9') || + (lex_hex_numbers && + ((c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F')))) { /* number */ int r, digit = 0; if (radix_mode != -1) r = radix_mode; - else if (c > '0') + else if (c != '0') r = db_radix; else { c = db_read_char(); @@ -328,6 +332,12 @@ } db_unread_char(c); return (tEXCL); + case ':': + c = db_read_char(); + if (c == ':') + return (tCOLONCOLON); + db_unread_char(c); + return (tCOLON); case ';': return (tSEMI); case '&':