Numbers patch for Xx and Zz. (Stefan Thiede)

This commit is contained in:
steve 1999-07-07 00:24:42 +00:00
parent 87dacbe83b
commit db07d18bcb
1 changed files with 25 additions and 24 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: lexor.lex,v 1.28 1999/07/03 21:27:22 steve Exp $" #ident "$Id: lexor.lex,v 1.29 1999/07/07 00:24:42 steve Exp $"
#endif #endif
//# define YYSTYPE lexval //# define YYSTYPE lexval
@ -153,23 +153,23 @@ static int comment_enter;
[0-9][0-9_]*[ \t]*\'d[ \t]*[0-9][0-9_]* { [0-9][0-9_]*[ \t]*\'d[ \t]*[0-9][0-9_]* {
yylval.number = make_sized_dec(yytext); yylval.number = make_sized_dec(yytext);
return NUMBER; } return NUMBER; }
[0-9][0-9_]*[ \t]*\'[bB][ \t]*[0-1xz_]+ { [0-9][0-9_]*[ \t]*\'[bB][ \t]*[0-1xzXZ_]+ {
yylval.number = make_sized_binary(yytext); yylval.number = make_sized_binary(yytext);
return NUMBER; } return NUMBER; }
[0-9][0-9_]*[ \t]*\'[oO][ \t]*[0-7xz_]+ { [0-9][0-9_]*[ \t]*\'[oO][ \t]*[0-7xzXZ_]+ {
yylval.number = make_sized_octal(yytext); yylval.number = make_sized_octal(yytext);
return NUMBER; } return NUMBER; }
[0-9][0-9_]*[ \t]*\'[hH][ \t]*[0-9a-fA-Fxz_]+ { [0-9][0-9_]*[ \t]*\'[hH][ \t]*[0-9a-fA-FxzXZ_]+ {
yylval.number = make_sized_hex(yytext); yylval.number = make_sized_hex(yytext);
return NUMBER; } return NUMBER; }
\'d[ \t]*[0-9][0-9_]* { yylval.number = make_unsized_dec(yytext); \'d[ \t]*[0-9][0-9_]* { yylval.number = make_unsized_dec(yytext);
return NUMBER; } return NUMBER; }
\'[bB][ \t]*[0-1xz_]+ { yylval.number = make_unsized_binary(yytext); \'[bB][ \t]*[0-1xzXZ_]+ { yylval.number = make_unsized_binary(yytext);
return NUMBER; } return NUMBER; }
\'[oO][ \t]*[0-7xz_]+ { yylval.number = make_unsized_octal(yytext); \'[oO][ \t]*[0-7xzXZ_]+ { yylval.number = make_unsized_octal(yytext);
return NUMBER; } return NUMBER; }
\'[hH][ \t]*[0-9a-fA-Fxz_]+ { yylval.number = make_unsized_hex(yytext); \'[hH][ \t]*[0-9a-fA-FxzXZ_]+ { yylval.number = make_unsized_hex(yytext);
return NUMBER; } return NUMBER; }
[0-9][0-9_]* { [0-9][0-9_]* {
@ -373,10 +373,10 @@ static verinum*make_binary_with_size(unsigned size, bool fixed, const char*ptr)
case '1': case '1':
bits[idx++] = verinum::V1; bits[idx++] = verinum::V1;
break; break;
case 'z': case 'z': case 'Z':
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
break; break;
case 'x': case 'x': case 'X':
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
break; break;
default: default:
@ -393,10 +393,10 @@ static verinum*make_binary_with_size(unsigned size, bool fixed, const char*ptr)
case '1': case '1':
bits[idx++] = verinum::V0; bits[idx++] = verinum::V0;
break; break;
case 'z': case 'z': case 'Z':
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
break; break;
case 'x': case 'x': case 'X':
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
break; break;
default: default:
@ -426,7 +426,7 @@ static verinum*make_unsized_binary(const char*txt)
assert(*ptr == '\''); assert(*ptr == '\'');
ptr += 1; ptr += 1;
assert(tolower(*ptr) == 'b'); assert(tolower(*ptr) == 'b');
while (*ptr && ((*ptr == ' ') || (*ptr == '\t'))) while (*ptr && ((*ptr == 'b') || (*ptr == ' ') || (*ptr == '\t')))
ptr += 1; ptr += 1;
unsigned size = 0; unsigned size = 0;
@ -453,6 +453,7 @@ static verinum*make_unsized_binary(const char*txt)
case '_': case '_':
break; break;
default: default:
fprintf(stderr, "%c\n", ptr[0]);
assert(0); assert(0);
} }
ptr += 1; ptr += 1;
@ -481,12 +482,12 @@ static verinum*make_sized_octal(const char*txt)
while ((eptr > ptr) && (idx < (size-3))) { while ((eptr > ptr) && (idx < (size-3))) {
switch (*eptr) { switch (*eptr) {
case 'x': case 'x': case 'X':
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
break; break;
case 'z': case 'z': case 'Z':
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
@ -504,10 +505,10 @@ static verinum*make_sized_octal(const char*txt)
// zero extend octal numbers // zero extend octal numbers
while (idx < size) switch (ptr[1]) { while (idx < size) switch (ptr[1]) {
case 'x': case 'x': case 'X':
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
break; break;
case 'z': case 'z': case 'Z':
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
break; break;
default: default:
@ -545,12 +546,12 @@ static verinum*make_unsized_octal(const char*txt)
bits[--idx] = (val&2) ? verinum::V1 : verinum::V0; bits[--idx] = (val&2) ? verinum::V1 : verinum::V0;
bits[--idx] = (val&1) ? verinum::V1 : verinum::V0; bits[--idx] = (val&1) ? verinum::V1 : verinum::V0;
break; break;
case 'x': case 'x': case 'X':
bits[--idx] = verinum::Vx; bits[--idx] = verinum::Vx;
bits[--idx] = verinum::Vx; bits[--idx] = verinum::Vx;
bits[--idx] = verinum::Vx; bits[--idx] = verinum::Vx;
break; break;
case 'z': case 'z': case 'Z':
bits[--idx] = verinum::Vz; bits[--idx] = verinum::Vz;
bits[--idx] = verinum::Vz; bits[--idx] = verinum::Vz;
bits[--idx] = verinum::Vz; bits[--idx] = verinum::Vz;
@ -589,13 +590,13 @@ static verinum*make_sized_hex(const char*txt)
while ((eptr >= ptr) && (idx <= (size-4))) { while ((eptr >= ptr) && (idx <= (size-4))) {
switch (*eptr) { switch (*eptr) {
case 'x': case 'x': case 'X':
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
break; break;
case 'z': case 'z': case 'Z':
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
@ -632,10 +633,10 @@ static verinum*make_sized_hex(const char*txt)
// zero extend octal numbers // zero extend octal numbers
while (idx < size) switch (ptr[1]) { while (idx < size) switch (ptr[1]) {
case 'x': case 'x': case 'X':
bits[idx++] = verinum::Vx; bits[idx++] = verinum::Vx;
break; break;
case 'z': case 'z': case 'Z':
bits[idx++] = verinum::Vz; bits[idx++] = verinum::Vz;
break; break;
default: default:
@ -682,13 +683,13 @@ static verinum*make_unsized_hex(const char*txt)
bits[--idx] = (val&2) ? verinum::V1 : verinum::V0; bits[--idx] = (val&2) ? verinum::V1 : verinum::V0;
bits[--idx] = (val&1) ? verinum::V1 : verinum::V0; bits[--idx] = (val&1) ? verinum::V1 : verinum::V0;
break; break;
case 'x': case 'x': case 'X':
bits[--idx] = verinum::Vx; bits[--idx] = verinum::Vx;
bits[--idx] = verinum::Vx; bits[--idx] = verinum::Vx;
bits[--idx] = verinum::Vx; bits[--idx] = verinum::Vx;
bits[--idx] = verinum::Vx; bits[--idx] = verinum::Vx;
break; break;
case 'z': case 'z': case 'Z':
bits[--idx] = verinum::Vz; bits[--idx] = verinum::Vz;
bits[--idx] = verinum::Vz; bits[--idx] = verinum::Vz;
bits[--idx] = verinum::Vz; bits[--idx] = verinum::Vz;