better range checking in grammar

This commit is contained in:
David Rose 2004-06-24 18:08:55 +00:00
parent 11634708c4
commit d86367d609
9 changed files with 975 additions and 842 deletions

View File

@ -300,30 +300,30 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
*yy_cp = '\0'; \ *yy_cp = '\0'; \
yy_c_buf_p = yy_cp; yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 47 #define YY_NUM_RULES 48
#define YY_END_OF_BUFFER 48 #define YY_END_OF_BUFFER 49
static yyconst short int yy_accept[187] = static yyconst short int yy_accept[188] =
{ 0, { 0,
0, 0, 48, 46, 2, 1, 43, 46, 46, 46, 0, 0, 49, 47, 2, 1, 44, 47, 47, 47,
40, 40, 44, 45, 45, 45, 45, 45, 45, 45, 40, 40, 45, 46, 46, 46, 46, 46, 46, 46,
45, 45, 45, 45, 45, 45, 1, 0, 40, 42, 46, 46, 46, 46, 46, 46, 1, 0, 41, 43,
4, 3, 42, 41, 45, 45, 45, 45, 45, 45, 4, 3, 43, 40, 42, 46, 46, 46, 46, 46,
35, 45, 45, 45, 45, 45, 45, 45, 45, 45, 46, 35, 46, 46, 46, 46, 46, 46, 46, 46,
45, 45, 45, 45, 0, 3, 41, 45, 45, 45, 46, 46, 46, 46, 46, 0, 3, 42, 46, 46,
45, 45, 45, 45, 45, 45, 45, 45, 45, 33, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
34, 45, 45, 45, 45, 45, 0, 42, 45, 22, 33, 34, 46, 46, 46, 46, 46, 0, 43, 46,
45, 11, 45, 45, 45, 45, 7, 45, 45, 45, 22, 46, 11, 46, 46, 46, 46, 7, 46, 46,
45, 12, 45, 45, 45, 45, 45, 45, 45, 45, 46, 46, 12, 46, 46, 46, 46, 46, 46, 46,
45, 45, 45, 45, 45, 45, 45, 13, 14, 15, 46, 46, 46, 46, 46, 46, 46, 46, 13, 14,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 15, 46, 46, 46, 46, 46, 46, 46, 46, 46,
16, 39, 23, 45, 37, 36, 5, 45, 8, 45, 46, 16, 39, 23, 46, 37, 36, 5, 46, 8,
45, 45, 45, 45, 21, 6, 10, 45, 17, 18, 46, 46, 46, 46, 46, 21, 6, 10, 46, 17,
19, 45, 45, 20, 45, 45, 45, 38, 45, 9, 18, 19, 46, 46, 20, 46, 46, 46, 38, 46,
45, 45, 45, 45, 45, 45, 45, 45, 31, 45, 9, 46, 46, 46, 46, 46, 46, 46, 46, 31,
45, 45, 45, 32, 45, 45, 24, 45, 45, 45, 46, 46, 46, 46, 32, 46, 46, 24, 46, 46,
45, 25, 26, 45, 45, 45, 27, 28, 29, 45, 46, 46, 25, 26, 46, 46, 46, 27, 28, 29,
45, 45, 45, 45, 30, 0 46, 46, 46, 46, 46, 30, 0
} ; } ;
static yyconst int yy_ec[256] = static yyconst int yy_ec[256] =
@ -364,125 +364,127 @@ static yyconst int yy_meta[44] =
5, 5, 5, 5, 5, 5, 1, 6, 6, 7, 5, 5, 5, 5, 5, 5, 1, 6, 6, 7,
6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7 7, 8, 7
} ; } ;
static yyconst short int yy_base[194] = static yyconst short int yy_base[196] =
{ 0, { 0,
0, 0, 223, 224, 224, 0, 224, 215, 0, 39, 0, 0, 230, 231, 231, 0, 231, 222, 0, 39,
38, 214, 224, 0, 191, 16, 27, 27, 23, 23, 38, 39, 231, 0, 199, 18, 28, 28, 23, 24,
178, 207, 35, 20, 174, 187, 0, 0, 208, 43, 186, 215, 36, 22, 182, 195, 0, 0, 216, 43,
224, 0, 0, 0, 0, 178, 180, 179, 174, 27, 231, 0, 0, 0, 0, 0, 186, 188, 187, 182,
0, 180, 176, 175, 173, 168, 173, 170, 172, 167, 28, 0, 188, 184, 183, 181, 176, 181, 178, 180,
165, 171, 165, 166, 191, 0, 0, 171, 173, 173, 175, 173, 179, 173, 174, 199, 0, 0, 179, 181,
168, 167, 166, 169, 168, 157, 154, 55, 149, 0, 181, 176, 175, 174, 177, 176, 165, 162, 57, 157,
0, 146, 37, 146, 158, 144, 175, 174, 156, 166, 0, 0, 154, 37, 154, 166, 152, 183, 182, 164,
153, 0, 153, 143, 137, 135, 0, 136, 156, 159, 174, 161, 0, 161, 151, 145, 143, 0, 144, 164,
156, 147, 142, 137, 133, 141, 140, 138, 62, 121, 167, 164, 155, 150, 145, 141, 149, 148, 146, 67,
149, 136, 118, 133, 119, 140, 116, 132, 131, 0, 129, 157, 144, 126, 141, 127, 148, 124, 140, 139,
115, 118, 113, 121, 109, 118, 120, 129, 132, 129, 0, 123, 126, 121, 129, 117, 126, 128, 137, 140,
120, 0, 0, 119, 0, 0, 0, 126, 0, 102, 137, 128, 0, 0, 127, 0, 0, 0, 134, 0,
101, 100, 111, 109, 0, 0, 0, 107, 111, 30, 110, 109, 108, 119, 117, 0, 0, 0, 115, 119,
0, 95, 93, 0, 93, 92, 106, 0, 102, 0, 31, 0, 103, 101, 0, 101, 100, 114, 0, 110,
89, 88, 94, 86, 83, 99, 98, 75, 0, 81, 0, 97, 96, 102, 94, 91, 107, 106, 83, 0,
80, 83, 93, 0, 70, 69, 0, 90, 89, 71, 89, 88, 91, 101, 0, 78, 77, 0, 98, 97,
65, 0, 0, 64, 63, 89, 0, 0, 0, 82, 79, 73, 0, 0, 71, 61, 81, 0, 0, 0,
58, 46, 58, 32, 0, 224, 80, 84, 68, 85, 75, 49, 42, 54, 31, 0, 231, 83, 88, 66,
92, 95, 99 90, 94, 102, 106, 110
} ; } ;
static yyconst short int yy_def[194] = static yyconst short int yy_def[196] =
{ 0, { 0,
186, 1, 186, 186, 186, 187, 186, 188, 189, 186, 187, 1, 187, 187, 187, 188, 187, 189, 190, 187,
188, 188, 186, 190, 190, 190, 190, 190, 190, 190, 191, 191, 187, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 187, 189, 188, 189, 192, 192, 192, 192, 192, 192, 188, 190, 189, 190,
186, 191, 30, 192, 190, 190, 190, 190, 190, 190, 187, 193, 30, 12, 194, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 193, 191, 192, 190, 190, 190, 192, 192, 192, 192, 192, 195, 193, 194, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 193, 193, 190, 190, 192, 192, 192, 192, 192, 192, 192, 195, 195, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
190, 190, 190, 190, 190, 0, 186, 186, 186, 186, 192, 192, 192, 192, 192, 192, 0, 187, 187, 187,
186, 186, 186 187, 187, 187, 187, 187
} ; } ;
static yyconst short int yy_nxt[268] = static yyconst short int yy_nxt[275] =
{ 0, { 0,
4, 5, 6, 7, 4, 8, 9, 10, 11, 12, 4, 5, 6, 7, 4, 8, 9, 10, 11, 12,
12, 12, 12, 12, 12, 12, 13, 14, 14, 14, 12, 12, 12, 12, 12, 12, 13, 14, 14, 14,
15, 16, 17, 18, 14, 19, 14, 14, 20, 14, 15, 16, 17, 18, 14, 19, 14, 14, 20, 14,
14, 14, 21, 22, 14, 23, 24, 25, 26, 14, 14, 14, 21, 22, 14, 23, 24, 25, 26, 14,
14, 14, 14, 31, 33, 37, 32, 39, 41, 42, 14, 14, 14, 31, 33, 33, 32, 38, 40, 42,
152, 38, 43, 45, 46, 49, 40, 51, 44, 50, 43, 153, 44, 39, 46, 47, 50, 41, 45, 52,
52, 55, 62, 63, 89, 95, 90, 55, 153, 91, 51, 56, 53, 63, 64, 96, 90, 56, 91, 154,
92, 118, 30, 119, 185, 96, 120, 121, 184, 34, 30, 92, 93, 186, 185, 97, 119, 184, 120, 35,
27, 183, 27, 27, 27, 27, 27, 29, 29, 35, 187, 121, 122, 27, 183, 27, 27, 27, 27, 27,
35, 35, 56, 182, 56, 56, 56, 56, 56, 57, 27, 29, 29, 34, 34, 182, 181, 34, 36, 36,
57, 78, 181, 78, 180, 179, 178, 177, 176, 175, 36, 36, 57, 180, 57, 57, 57, 57, 57, 57,
174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 58, 58, 79, 179, 79, 178, 177, 176, 175, 174,
164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164,
154, 151, 150, 149, 148, 147, 146, 145, 144, 143, 163, 162, 161, 160, 159, 158, 157, 156, 155, 152,
142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142,
132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132,
122, 117, 116, 115, 114, 113, 112, 111, 110, 109, 131, 130, 129, 128, 127, 126, 125, 124, 123, 118,
108, 107, 106, 105, 104, 103, 102, 101, 100, 186, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108,
186, 99, 98, 97, 94, 93, 88, 87, 86, 85, 107, 106, 105, 104, 103, 102, 101, 187, 187, 100,
84, 83, 82, 81, 80, 79, 77, 76, 75, 74, 99, 98, 95, 94, 89, 88, 87, 86, 85, 84,
73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 83, 82, 81, 80, 78, 77, 76, 75, 74, 73,
61, 60, 59, 58, 33, 54, 53, 48, 47, 36, 72, 71, 70, 69, 68, 67, 66, 65, 62, 61,
33, 28, 186, 3, 186, 186, 186, 186, 186, 186, 60, 59, 33, 55, 54, 49, 48, 37, 28, 187,
186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 3, 187, 187, 187, 187, 187, 187, 187, 187, 187,
186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
186, 186, 186, 186, 186, 186, 186 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187
} ; } ;
static yyconst short int yy_chk[268] = static yyconst short int yy_chk[275] =
{ 0, { 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 10, 11, 16, 10, 17, 18, 18, 1, 1, 1, 10, 11, 12, 10, 16, 17, 18,
140, 16, 19, 20, 20, 23, 17, 24, 19, 23, 18, 141, 19, 16, 20, 20, 23, 17, 19, 24,
24, 30, 40, 40, 68, 73, 68, 30, 140, 68, 23, 30, 24, 41, 41, 74, 69, 30, 69, 141,
68, 99, 189, 99, 184, 73, 99, 99, 183, 11, 190, 69, 69, 185, 184, 74, 100, 183, 100, 11,
187, 182, 187, 187, 187, 187, 187, 188, 188, 190, 12, 100, 100, 188, 182, 188, 188, 188, 188, 188,
190, 190, 191, 181, 191, 191, 191, 191, 191, 192, 188, 189, 189, 191, 191, 181, 177, 191, 192, 192,
192, 193, 180, 193, 176, 175, 174, 171, 170, 169, 192, 192, 193, 176, 193, 193, 193, 193, 193, 193,
168, 166, 165, 163, 162, 161, 160, 158, 157, 156, 194, 194, 195, 175, 195, 172, 171, 170, 169, 167,
155, 154, 153, 152, 151, 149, 147, 146, 145, 143, 166, 164, 163, 162, 161, 159, 158, 157, 156, 155,
142, 139, 138, 134, 133, 132, 131, 130, 128, 124, 154, 153, 152, 150, 148, 147, 146, 144, 143, 140,
121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 139, 135, 134, 133, 132, 131, 129, 125, 122, 121,
111, 109, 108, 107, 106, 105, 104, 103, 102, 101, 120, 119, 118, 117, 116, 115, 114, 113, 112, 110,
100, 98, 97, 96, 95, 94, 93, 92, 91, 90, 109, 108, 107, 106, 105, 104, 103, 102, 101, 99,
89, 88, 86, 85, 84, 83, 81, 80, 79, 78, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89,
77, 76, 75, 74, 72, 69, 67, 66, 65, 64, 87, 86, 85, 84, 82, 81, 80, 79, 78, 77,
63, 62, 61, 60, 59, 58, 55, 54, 53, 52, 76, 75, 73, 70, 68, 67, 66, 65, 64, 63,
51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 62, 61, 60, 59, 56, 55, 54, 53, 52, 51,
39, 38, 37, 36, 29, 26, 25, 22, 21, 15, 50, 49, 48, 47, 46, 45, 44, 43, 40, 39,
12, 8, 3, 186, 186, 186, 186, 186, 186, 186, 38, 37, 29, 26, 25, 22, 21, 15, 8, 3,
186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
186, 186, 186, 186, 186, 186, 186 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187
} ; } ;
static yy_state_type yy_last_accepting_state; static yy_state_type yy_last_accepting_state;
@ -797,7 +799,7 @@ inline void accept() {
col_number += yyleng; col_number += yyleng;
} }
#line 802 "lex.yy.c" #line 804 "lex.yy.c"
/* Macros after this point can all be overridden by user definitions in /* Macros after this point can all be overridden by user definitions in
* section 1. * section 1.
@ -948,7 +950,7 @@ YY_DECL
register char *yy_cp = NULL, *yy_bp = NULL; register char *yy_cp = NULL, *yy_bp = NULL;
register int yy_act; register int yy_act;
#line 307 "dcLexer.lxx" #line 308 "dcLexer.lxx"
@ -959,7 +961,7 @@ YY_DECL
} }
#line 964 "lex.yy.c" #line 966 "lex.yy.c"
if ( yy_init ) if ( yy_init )
{ {
@ -1010,13 +1012,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 187 ) if ( yy_current_state >= 188 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp; ++yy_cp;
} }
while ( yy_base[yy_current_state] != 224 ); while ( yy_base[yy_current_state] != 231 );
yy_find_action: yy_find_action:
yy_act = yy_accept[yy_current_state]; yy_act = yy_accept[yy_current_state];
@ -1044,7 +1046,7 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 317 "dcLexer.lxx" #line 318 "dcLexer.lxx"
{ {
// New line. Save a copy of the line so we can print it out for the // New line. Save a copy of the line so we can print it out for the
// benefit of the user in case we get an error. // benefit of the user in case we get an error.
@ -1061,7 +1063,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 331 "dcLexer.lxx" #line 332 "dcLexer.lxx"
{ {
// Eat whitespace. // Eat whitespace.
accept(); accept();
@ -1069,7 +1071,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 336 "dcLexer.lxx" #line 337 "dcLexer.lxx"
{ {
// Eat C++-style comments. // Eat C++-style comments.
accept(); accept();
@ -1077,7 +1079,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 341 "dcLexer.lxx" #line 342 "dcLexer.lxx"
{ {
// Eat C-style comments. // Eat C-style comments.
accept(); accept();
@ -1086,7 +1088,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 348 "dcLexer.lxx" #line 349 "dcLexer.lxx"
{ {
accept(); accept();
return KW_DCLASS; return KW_DCLASS;
@ -1094,7 +1096,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 353 "dcLexer.lxx" #line 354 "dcLexer.lxx"
{ {
accept(); accept();
return KW_STRUCT; return KW_STRUCT;
@ -1102,7 +1104,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 358 "dcLexer.lxx" #line 359 "dcLexer.lxx"
{ {
accept(); accept();
return KW_FROM; return KW_FROM;
@ -1110,7 +1112,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 363 "dcLexer.lxx" #line 364 "dcLexer.lxx"
{ {
accept(); accept();
return KW_IMPORT; return KW_IMPORT;
@ -1118,7 +1120,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 368 "dcLexer.lxx" #line 369 "dcLexer.lxx"
{ {
accept(); accept();
return KW_TYPEDEF; return KW_TYPEDEF;
@ -1126,7 +1128,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 373 "dcLexer.lxx" #line 374 "dcLexer.lxx"
{ {
accept(); accept();
return KW_SWITCH; return KW_SWITCH;
@ -1134,7 +1136,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 378 "dcLexer.lxx" #line 379 "dcLexer.lxx"
{ {
accept(); accept();
return KW_CASE; return KW_CASE;
@ -1142,7 +1144,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 383 "dcLexer.lxx" #line 384 "dcLexer.lxx"
{ {
accept(); accept();
return KW_INT8; return KW_INT8;
@ -1150,7 +1152,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 388 "dcLexer.lxx" #line 389 "dcLexer.lxx"
{ {
accept(); accept();
return KW_INT16; return KW_INT16;
@ -1158,7 +1160,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 393 "dcLexer.lxx" #line 394 "dcLexer.lxx"
{ {
accept(); accept();
return KW_INT32; return KW_INT32;
@ -1166,7 +1168,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 398 "dcLexer.lxx" #line 399 "dcLexer.lxx"
{ {
accept(); accept();
return KW_INT64; return KW_INT64;
@ -1174,7 +1176,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 403 "dcLexer.lxx" #line 404 "dcLexer.lxx"
{ {
accept(); accept();
return KW_UINT8; return KW_UINT8;
@ -1182,7 +1184,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 408 "dcLexer.lxx" #line 409 "dcLexer.lxx"
{ {
accept(); accept();
return KW_UINT16; return KW_UINT16;
@ -1190,7 +1192,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 413 "dcLexer.lxx" #line 414 "dcLexer.lxx"
{ {
accept(); accept();
return KW_UINT32; return KW_UINT32;
@ -1198,7 +1200,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
#line 418 "dcLexer.lxx" #line 419 "dcLexer.lxx"
{ {
accept(); accept();
return KW_UINT64; return KW_UINT64;
@ -1206,7 +1208,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 20: case 20:
YY_RULE_SETUP YY_RULE_SETUP
#line 423 "dcLexer.lxx" #line 424 "dcLexer.lxx"
{ {
accept(); accept();
return KW_FLOAT64; return KW_FLOAT64;
@ -1214,7 +1216,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
#line 428 "dcLexer.lxx" #line 429 "dcLexer.lxx"
{ {
accept(); accept();
return KW_STRING; return KW_STRING;
@ -1222,7 +1224,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 433 "dcLexer.lxx" #line 434 "dcLexer.lxx"
{ {
accept(); accept();
return KW_BLOB; return KW_BLOB;
@ -1230,7 +1232,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 438 "dcLexer.lxx" #line 439 "dcLexer.lxx"
{ {
accept(); accept();
return KW_BLOB32; return KW_BLOB32;
@ -1238,7 +1240,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 443 "dcLexer.lxx" #line 444 "dcLexer.lxx"
{ {
accept(); accept();
return KW_INT8ARRAY; return KW_INT8ARRAY;
@ -1246,7 +1248,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 448 "dcLexer.lxx" #line 449 "dcLexer.lxx"
{ {
accept(); accept();
return KW_INT16ARRAY; return KW_INT16ARRAY;
@ -1254,7 +1256,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 453 "dcLexer.lxx" #line 454 "dcLexer.lxx"
{ {
accept(); accept();
return KW_INT32ARRAY; return KW_INT32ARRAY;
@ -1262,7 +1264,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 458 "dcLexer.lxx" #line 459 "dcLexer.lxx"
{ {
accept(); accept();
return KW_UINT8ARRAY; return KW_UINT8ARRAY;
@ -1270,7 +1272,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
#line 463 "dcLexer.lxx" #line 464 "dcLexer.lxx"
{ {
accept(); accept();
return KW_UINT16ARRAY; return KW_UINT16ARRAY;
@ -1278,7 +1280,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
#line 468 "dcLexer.lxx" #line 469 "dcLexer.lxx"
{ {
accept(); accept();
return KW_UINT32ARRAY; return KW_UINT32ARRAY;
@ -1286,7 +1288,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
#line 473 "dcLexer.lxx" #line 474 "dcLexer.lxx"
{ {
accept(); accept();
return KW_UINT32UINT8ARRAY; return KW_UINT32UINT8ARRAY;
@ -1294,7 +1296,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 31: case 31:
YY_RULE_SETUP YY_RULE_SETUP
#line 478 "dcLexer.lxx" #line 479 "dcLexer.lxx"
{ {
accept(); accept();
return KW_REQUIRED; return KW_REQUIRED;
@ -1302,7 +1304,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 32: case 32:
YY_RULE_SETUP YY_RULE_SETUP
#line 483 "dcLexer.lxx" #line 484 "dcLexer.lxx"
{ {
accept(); accept();
return KW_BROADCAST; return KW_BROADCAST;
@ -1310,7 +1312,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 33: case 33:
YY_RULE_SETUP YY_RULE_SETUP
#line 488 "dcLexer.lxx" #line 489 "dcLexer.lxx"
{ {
accept(); accept();
return KW_P2P; return KW_P2P;
@ -1318,7 +1320,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
#line 493 "dcLexer.lxx" #line 494 "dcLexer.lxx"
{ {
accept(); accept();
return KW_RAM; return KW_RAM;
@ -1326,7 +1328,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
#line 498 "dcLexer.lxx" #line 499 "dcLexer.lxx"
{ {
accept(); accept();
return KW_DB; return KW_DB;
@ -1334,7 +1336,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 503 "dcLexer.lxx" #line 504 "dcLexer.lxx"
{ {
accept(); accept();
return KW_CLSEND; return KW_CLSEND;
@ -1342,7 +1344,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 508 "dcLexer.lxx" #line 509 "dcLexer.lxx"
{ {
accept(); accept();
return KW_CLRECV; return KW_CLRECV;
@ -1350,7 +1352,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 38: case 38:
YY_RULE_SETUP YY_RULE_SETUP
#line 513 "dcLexer.lxx" #line 514 "dcLexer.lxx"
{ {
accept(); accept();
return KW_OWNSEND; return KW_OWNSEND;
@ -1358,7 +1360,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 39: case 39:
YY_RULE_SETUP YY_RULE_SETUP
#line 518 "dcLexer.lxx" #line 519 "dcLexer.lxx"
{ {
accept(); accept();
return KW_AIRECV; return KW_AIRECV;
@ -1366,13 +1368,40 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 40: case 40:
YY_RULE_SETUP YY_RULE_SETUP
#line 523 "dcLexer.lxx" #line 524 "dcLexer.lxx"
{ {
// An integer number. // An unsigned integer number.
accept(); accept();
// atoll isn't fully portable, so we'll decode the integer by hand. // atoll isn't fully portable, so we'll decode the integer by hand.
dcyylval.u.integer = 0; dcyylval.str = dcyytext;
dcyylval.u.uint64 = 0;
const char *p = dcyytext;
while (*p != '\0') {
PN_uint64 next_value = dcyylval.u.uint64 * 10;
if (next_value < dcyylval.u.uint64) {
dcyyerror("Number out of range.");
dcyylval.u.uint64 = 1;
return UNSIGNED_INTEGER;
}
dcyylval.u.uint64 = next_value + (*p - '0');
++p;
}
return UNSIGNED_INTEGER;
}
YY_BREAK
case 41:
YY_RULE_SETUP
#line 547 "dcLexer.lxx"
{
// A signed integer number.
accept();
// atoll isn't fully portable, so we'll decode the integer by hand.
dcyylval.str = dcyytext;
bool neg = false; bool neg = false;
const char *p = dcyytext; const char *p = dcyytext;
if (*p == '-') { if (*p == '-') {
@ -1381,44 +1410,70 @@ YY_RULE_SETUP
} else if (*p == '+') { } else if (*p == '+') {
++p; ++p;
} }
PN_uint64 value = 0;
while (*p != '\0') { while (*p != '\0') {
dcyylval.u.integer = dcyylval.u.integer * 10 + (*p - '0'); PN_uint64 next_value = value * 10;
++p; if (next_value < value) {
} dcyyerror("Number out of range.");
if (neg) { dcyylval.u.int64 = 1;
dcyylval.u.integer = -dcyylval.u.integer; return SIGNED_INTEGER;
} }
dcyylval.str = dcyytext; value = next_value + (*p - '0');
return INTEGER; ++p;
}
if (neg) {
dcyylval.u.int64 = -(PN_int64)value;
if (dcyylval.u.int64 > 0) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
}
} else {
dcyylval.u.int64 = (PN_int64)value;
if (dcyylval.u.int64 < 0) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
}
}
return SIGNED_INTEGER;
} }
YY_BREAK YY_BREAK
case 41: case 42:
YY_RULE_SETUP YY_RULE_SETUP
#line 549 "dcLexer.lxx" #line 593 "dcLexer.lxx"
{ {
// A hexadecimal integer number. // A hexadecimal integer number.
accept(); accept();
// As above, we'll decode the hex string by hand. // As above, we'll decode the hex string by hand.
dcyylval.u.integer = 0; dcyylval.str = dcyytext;
dcyylval.u.uint64 = 0;
const char *p = dcyytext + 2; const char *p = dcyytext + 2;
while (*p != '\0') { while (*p != '\0') {
PN_uint64 next_value = dcyylval.u.uint64 * 16;
if (next_value < dcyylval.u.uint64) {
dcyyerror("Number out of range.");
dcyylval.u.uint64 = 1;
return UNSIGNED_INTEGER;
}
if (isalpha(*p)) { if (isalpha(*p)) {
dcyylval.u.integer = dcyylval.u.integer * 16 + (tolower(*p) - 'a' + 10); dcyylval.u.uint64 = next_value + (tolower(*p) - 'a' + 10);
} else { } else {
dcyylval.u.integer = dcyylval.u.integer * 16 + (*p - '0'); dcyylval.u.uint64 = next_value + (*p - '0');
} }
++p; ++p;
} }
dcyylval.str = dcyytext; return UNSIGNED_INTEGER;
return INTEGER;
} }
YY_BREAK YY_BREAK
case 42: case 43:
YY_RULE_SETUP YY_RULE_SETUP
#line 569 "dcLexer.lxx" #line 620 "dcLexer.lxx"
{ {
// A floating-point number. // A floating-point number.
accept(); accept();
@ -1427,9 +1482,9 @@ YY_RULE_SETUP
return REAL; return REAL;
} }
YY_BREAK YY_BREAK
case 43: case 44:
YY_RULE_SETUP YY_RULE_SETUP
#line 577 "dcLexer.lxx" #line 628 "dcLexer.lxx"
{ {
// Quoted string. // Quoted string.
accept(); accept();
@ -1437,9 +1492,9 @@ YY_RULE_SETUP
return STRING; return STRING;
} }
YY_BREAK YY_BREAK
case 44: case 45:
YY_RULE_SETUP YY_RULE_SETUP
#line 584 "dcLexer.lxx" #line 635 "dcLexer.lxx"
{ {
// Long hex string. // Long hex string.
accept(); accept();
@ -1447,9 +1502,9 @@ YY_RULE_SETUP
return HEX_STRING; return HEX_STRING;
} }
YY_BREAK YY_BREAK
case 45: case 46:
YY_RULE_SETUP YY_RULE_SETUP
#line 591 "dcLexer.lxx" #line 642 "dcLexer.lxx"
{ {
// Identifier. // Identifier.
accept(); accept();
@ -1457,21 +1512,21 @@ YY_RULE_SETUP
return IDENTIFIER; return IDENTIFIER;
} }
YY_BREAK YY_BREAK
case 46: case 47:
YY_RULE_SETUP YY_RULE_SETUP
#line 599 "dcLexer.lxx" #line 650 "dcLexer.lxx"
{ {
// Send any other printable character as itself. // Send any other printable character as itself.
accept(); accept();
return dcyytext[0]; return dcyytext[0];
} }
YY_BREAK YY_BREAK
case 47: case 48:
YY_RULE_SETUP YY_RULE_SETUP
#line 605 "dcLexer.lxx" #line 656 "dcLexer.lxx"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1476 "lex.yy.c" #line 1531 "lex.yy.c"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
yyterminate(); yyterminate();
@ -1763,7 +1818,7 @@ static yy_state_type yy_get_previous_state()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 187 ) if ( yy_current_state >= 188 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@ -1798,11 +1853,11 @@ yy_state_type yy_current_state;
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 187 ) if ( yy_current_state >= 188 )
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 186); yy_is_jam = (yy_current_state == 187);
return yy_is_jam ? 0 : yy_current_state; return yy_is_jam ? 0 : yy_current_state;
} }
@ -2352,4 +2407,4 @@ int main()
return 0; return 0;
} }
#endif #endif
#line 605 "dcLexer.lxx" #line 656 "dcLexer.lxx"

View File

@ -300,8 +300,9 @@ inline void accept() {
%} %}
INTEGERNUM ([+-]?([0-9]+)) UNSIGNED_INTEGERNUM ([0-9]+)
HEXNUM 0x[0-9a-fA-F]* SIGNED_INTEGERNUM ([+-]([0-9]+))
UNSIGNED_HEXNUM (0x[0-9a-fA-F]*)
REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
%% %%
@ -520,12 +521,36 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
return KW_AIRECV; return KW_AIRECV;
} }
{INTEGERNUM} { {UNSIGNED_INTEGERNUM} {
// An integer number. // An unsigned integer number.
accept(); accept();
// atoll isn't fully portable, so we'll decode the integer by hand. // atoll isn't fully portable, so we'll decode the integer by hand.
dcyylval.u.integer = 0; dcyylval.str = dcyytext;
dcyylval.u.uint64 = 0;
const char *p = dcyytext;
while (*p != '\0') {
PN_uint64 next_value = dcyylval.u.uint64 * 10;
if (next_value < dcyylval.u.uint64) {
dcyyerror("Number out of range.");
dcyylval.u.uint64 = 1;
return UNSIGNED_INTEGER;
}
dcyylval.u.uint64 = next_value + (*p - '0');
++p;
}
return UNSIGNED_INTEGER;
}
{SIGNED_INTEGERNUM} {
// A signed integer number.
accept();
// atoll isn't fully portable, so we'll decode the integer by hand.
dcyylval.str = dcyytext;
bool neg = false; bool neg = false;
const char *p = dcyytext; const char *p = dcyytext;
if (*p == '-') { if (*p == '-') {
@ -534,36 +559,62 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
} else if (*p == '+') { } else if (*p == '+') {
++p; ++p;
} }
PN_uint64 value = 0;
while (*p != '\0') { while (*p != '\0') {
dcyylval.u.integer = dcyylval.u.integer * 10 + (*p - '0'); PN_uint64 next_value = value * 10;
if (next_value < value) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
return SIGNED_INTEGER;
}
value = next_value + (*p - '0');
++p; ++p;
} }
if (neg) { if (neg) {
dcyylval.u.integer = -dcyylval.u.integer; dcyylval.u.int64 = -(PN_int64)value;
if (dcyylval.u.int64 > 0) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
}
} else {
dcyylval.u.int64 = (PN_int64)value;
if (dcyylval.u.int64 < 0) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
}
} }
dcyylval.str = dcyytext; return SIGNED_INTEGER;
return INTEGER;
} }
{HEXNUM} { {UNSIGNED_HEXNUM} {
// A hexadecimal integer number. // A hexadecimal integer number.
accept(); accept();
// As above, we'll decode the hex string by hand. // As above, we'll decode the hex string by hand.
dcyylval.u.integer = 0; dcyylval.str = dcyytext;
dcyylval.u.uint64 = 0;
const char *p = dcyytext + 2; const char *p = dcyytext + 2;
while (*p != '\0') { while (*p != '\0') {
PN_uint64 next_value = dcyylval.u.uint64 * 16;
if (next_value < dcyylval.u.uint64) {
dcyyerror("Number out of range.");
dcyylval.u.uint64 = 1;
return UNSIGNED_INTEGER;
}
if (isalpha(*p)) { if (isalpha(*p)) {
dcyylval.u.integer = dcyylval.u.integer * 16 + (tolower(*p) - 'a' + 10); dcyylval.u.uint64 = next_value + (tolower(*p) - 'a' + 10);
} else { } else {
dcyylval.u.integer = dcyylval.u.integer * 16 + (*p - '0'); dcyylval.u.uint64 = next_value + (*p - '0');
} }
++p; ++p;
} }
dcyylval.str = dcyytext; return UNSIGNED_INTEGER;
return INTEGER;
} }
{REALNUM} { {REALNUM} {

View File

@ -268,6 +268,13 @@ get_max(int n) const {
template <class NUM> template <class NUM>
INLINE void DCNumericRange<NUM>:: INLINE void DCNumericRange<NUM>::
output_minmax(ostream &out, Number divisor, const MinMax &range) const { output_minmax(ostream &out, Number divisor, const MinMax &range) const {
if (divisor == 1) {
if (range._min == range._max) {
out << range._min;
} else {
out << range._min << "-" << range._max;
}
} else {
if (range._min == range._max) { if (range._min == range._max) {
out << (double)range._min / (double)divisor; out << (double)range._min / (double)divisor;
} else { } else {
@ -275,4 +282,5 @@ output_minmax(ostream &out, Number divisor, const MinMax &range) const {
<< "-" << "-"
<< (double)range._max / (double)divisor; << (double)range._max / (double)divisor;
} }
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,49 @@
#ifndef BISON_Y_TAB_H #ifndef BISON_Y_TAB_H
# define BISON_Y_TAB_H # define BISON_Y_TAB_H
# define INTEGER 257 # define UNSIGNED_INTEGER 257
# define REAL 258 # define SIGNED_INTEGER 258
# define STRING 259 # define REAL 259
# define HEX_STRING 260 # define STRING 260
# define IDENTIFIER 261 # define HEX_STRING 261
# define KW_DCLASS 262 # define IDENTIFIER 262
# define KW_STRUCT 263 # define KW_DCLASS 263
# define KW_FROM 264 # define KW_STRUCT 264
# define KW_IMPORT 265 # define KW_FROM 265
# define KW_TYPEDEF 266 # define KW_IMPORT 266
# define KW_SWITCH 267 # define KW_TYPEDEF 267
# define KW_CASE 268 # define KW_SWITCH 268
# define KW_INT8 269 # define KW_CASE 269
# define KW_INT16 270 # define KW_INT8 270
# define KW_INT32 271 # define KW_INT16 271
# define KW_INT64 272 # define KW_INT32 272
# define KW_UINT8 273 # define KW_INT64 273
# define KW_UINT16 274 # define KW_UINT8 274
# define KW_UINT32 275 # define KW_UINT16 275
# define KW_UINT64 276 # define KW_UINT32 276
# define KW_FLOAT64 277 # define KW_UINT64 277
# define KW_STRING 278 # define KW_FLOAT64 278
# define KW_BLOB 279 # define KW_STRING 279
# define KW_BLOB32 280 # define KW_BLOB 280
# define KW_INT8ARRAY 281 # define KW_BLOB32 281
# define KW_INT16ARRAY 282 # define KW_INT8ARRAY 282
# define KW_INT32ARRAY 283 # define KW_INT16ARRAY 283
# define KW_UINT8ARRAY 284 # define KW_INT32ARRAY 284
# define KW_UINT16ARRAY 285 # define KW_UINT8ARRAY 285
# define KW_UINT32ARRAY 286 # define KW_UINT16ARRAY 286
# define KW_UINT32UINT8ARRAY 287 # define KW_UINT32ARRAY 287
# define KW_REQUIRED 288 # define KW_UINT32UINT8ARRAY 288
# define KW_BROADCAST 289 # define KW_REQUIRED 289
# define KW_P2P 290 # define KW_BROADCAST 290
# define KW_RAM 291 # define KW_P2P 291
# define KW_DB 292 # define KW_RAM 292
# define KW_CLSEND 293 # define KW_DB 293
# define KW_CLRECV 294 # define KW_CLSEND 294
# define KW_OWNSEND 295 # define KW_CLRECV 295
# define KW_AIRECV 296 # define KW_OWNSEND 296
# define START_DC 297 # define KW_AIRECV 297
# define START_PARAMETER_VALUE 298 # define START_DC 298
# define START_PARAMETER_VALUE 299
extern YYSTYPE dcyylval; extern YYSTYPE dcyylval;

View File

@ -64,7 +64,8 @@ dc_cleanup_parser() {
%} %}
%token <u.integer> INTEGER %token <u.uint64> UNSIGNED_INTEGER
%token <u.int64> SIGNED_INTEGER
%token <u.real> REAL %token <u.real> REAL
%token <str> STRING HEX_STRING IDENTIFIER %token <str> STRING HEX_STRING IDENTIFIER
@ -130,6 +131,9 @@ dc_cleanup_parser() {
%type <str> import_identifier %type <str> import_identifier
%type <str> slash_identifier %type <str> slash_identifier
%type <str> optional_name %type <str> optional_name
%type <u.s_uint> small_unsigned_integer
%type <u.int64> signed_integer
%type <u.uint64> unsigned_integer
%type <u.real> number %type <u.real> number
%% %%
@ -379,24 +383,24 @@ type_name:
} }
$$ = simple_param; $$ = simple_param;
} }
| type_token '/' INTEGER | type_token '/' small_unsigned_integer
{ {
DCSimpleParameter *simple_param = new DCSimpleParameter($1); DCSimpleParameter *simple_param = new DCSimpleParameter($1);
if ($3 == 0) { if ($3 == 0) {
yyerror("Invalid divisor."); yyerror("Invalid divisor.");
} else if (!simple_param->set_divisor((int)$3)) { } else if (!simple_param->set_divisor($3)) {
yyerror("A divisor is only valid on a numeric type."); yyerror("A divisor is only valid on a numeric type.");
} }
$$ = simple_param; $$ = simple_param;
} }
| type_token '/' INTEGER '(' double_range ')' | type_token '/' small_unsigned_integer '(' double_range ')'
{ {
DCSimpleParameter *simple_param = new DCSimpleParameter($1); DCSimpleParameter *simple_param = new DCSimpleParameter($1);
if ($3 == 0) { if ($3 == 0) {
yyerror("Invalid divisor."); yyerror("Invalid divisor.");
} else if (!simple_param->set_divisor((int)$3)) { } else if (!simple_param->set_divisor($3)) {
yyerror("A divisor is only valid on a numeric type."); yyerror("A divisor is only valid on a numeric type.");
} }
if (!simple_param->set_range(double_range)) { if (!simple_param->set_range(double_range)) {
@ -404,13 +408,13 @@ type_name:
} }
$$ = simple_param; $$ = simple_param;
} }
| type_token '(' double_range ')' '/' INTEGER | type_token '(' double_range ')' '/' small_unsigned_integer
{ {
DCSimpleParameter *simple_param = new DCSimpleParameter($1); DCSimpleParameter *simple_param = new DCSimpleParameter($1);
if ($6 == 0) { if ($6 == 0) {
yyerror("Invalid divisor."); yyerror("Invalid divisor.");
} else if (!simple_param->set_divisor((int)$6)) { } else if (!simple_param->set_divisor($6)) {
yyerror("A divisor is only valid on a numeric type."); yyerror("A divisor is only valid on a numeric type.");
} }
if (!simple_param->set_range(double_range)) { if (!simple_param->set_range(double_range)) {
@ -494,62 +498,29 @@ uint_range:
{ {
uint_range.clear(); uint_range.clear();
} }
| INTEGER | small_unsigned_integer
{
if ($1 < 0) {
yyerror("Nonnegative values only");
} else {
uint_range.clear();
if (!uint_range.add_range((unsigned int)$1, (unsigned int)$1)) {
yyerror("Overlapping range");
}
}
}
| INTEGER '-' INTEGER
{
if ($1 < 0 || $3 < 0) {
yyerror("Nonnegative values only");
} else {
uint_range.clear();
if (!uint_range.add_range((unsigned int)$1, (unsigned int)$3)) {
yyerror("Overlapping range");
}
}
}
| INTEGER INTEGER
{ {
uint_range.clear(); uint_range.clear();
if ($2 >= 0) { if (!uint_range.add_range($1, $1)) {
yyerror("Syntax error");
} else if ($1 < 0) {
yyerror("Nonnegative values only");
} else if (!uint_range.add_range((unsigned int)$1, (unsigned int)-$2)) {
yyerror("Overlapping range"); yyerror("Overlapping range");
} }
} }
| uint_range ',' INTEGER | small_unsigned_integer '-' small_unsigned_integer
{ {
if ($3 < 0) { uint_range.clear();
yyerror("Nonnegative values only"); if (!uint_range.add_range($1, $3)) {
} else if (!uint_range.add_range((unsigned int)$3, (unsigned int)$3)) {
yyerror("Overlapping range"); yyerror("Overlapping range");
} }
} }
| uint_range ',' INTEGER '-' INTEGER | uint_range ',' small_unsigned_integer
{ {
if ($3 < 0 || $5 < 0) { if (!uint_range.add_range($3, $3)) {
yyerror("Nonnegative values only");
} else if (!uint_range.add_range((unsigned int)$3, (unsigned int)$5)) {
yyerror("Overlapping range"); yyerror("Overlapping range");
} }
} }
| uint_range ',' INTEGER INTEGER | uint_range ',' small_unsigned_integer '-' small_unsigned_integer
{ {
if ($4 >= 0) { if (!uint_range.add_range($3, $5)) {
yyerror("Syntax error");
} else if ($3 < 0) {
yyerror("Nonnegative values only");
} else if (!uint_range.add_range((unsigned int)$3, (unsigned int)-$4)) {
yyerror("Overlapping range"); yyerror("Overlapping range");
} }
} }
@ -569,7 +540,7 @@ parameter_definition:
current_parameter->set_name($1); current_parameter->set_name($1);
$$ = current_parameter; $$ = current_parameter;
} }
| parameter_definition '/' INTEGER | parameter_definition '/' small_unsigned_integer
{ {
if ($3 == 0) { if ($3 == 0) {
yyerror("Invalid divisor."); yyerror("Invalid divisor.");
@ -578,7 +549,7 @@ parameter_definition:
yyerror("A divisor is only allowed on a primitive type."); yyerror("A divisor is only allowed on a primitive type.");
} else { } else {
if (!$1->as_simple_parameter()->set_divisor((int)$3)) { if (!$1->as_simple_parameter()->set_divisor($3)) {
yyerror("A divisor is only valid on a numeric type."); yyerror("A divisor is only valid on a numeric type.");
} }
} }
@ -589,8 +560,31 @@ parameter_definition:
} }
; ;
small_unsigned_integer:
UNSIGNED_INTEGER
{
$$ = (unsigned int)$1;
if ($$ != $1) {
yyerror("Number out of range.");
$$ = 1;
}
}
;
signed_integer:
SIGNED_INTEGER
;
unsigned_integer:
UNSIGNED_INTEGER
;
number: number:
INTEGER unsigned_integer
{
$$ = (double)$1;
}
| signed_integer
{ {
$$ = (double)$1; $$ = (double)$1;
} }
@ -598,9 +592,13 @@ number:
; ;
parameter_value: parameter_value:
INTEGER signed_integer
{ {
current_packer->pack_int64($1); current_packer->pack_int64($1);
}
| unsigned_integer
{
current_packer->pack_uint64($1);
} }
| REAL | REAL
{ {
@ -638,21 +636,27 @@ parameter_value:
{ {
current_packer->pop(); current_packer->pop();
} }
| INTEGER '*' INTEGER | signed_integer '*' small_unsigned_integer
{ {
for (int i = 0; i < $3; i++) { for (unsigned int i = 0; i < $3; i++) {
current_packer->pack_int64($1); current_packer->pack_int64($1);
} }
} }
| REAL '*' INTEGER | unsigned_integer '*' small_unsigned_integer
{ {
for (int i = 0; i < $3; i++) { for (unsigned int i = 0; i < $3; i++) {
current_packer->pack_uint64($1);
}
}
| REAL '*' small_unsigned_integer
{
for (unsigned int i = 0; i < $3; i++) {
current_packer->pack_double($1); current_packer->pack_double($1);
} }
} }
| HEX_STRING '*' INTEGER | HEX_STRING '*' small_unsigned_integer
{ {
for (int i = 0; i < $3; i++) { for (unsigned int i = 0; i < $3; i++) {
current_packer->pack_literal_value($1); current_packer->pack_literal_value($1);
} }
} }

View File

@ -45,7 +45,10 @@ int dcyyparse();
class DCTokenType { class DCTokenType {
public: public:
union U { union U {
PN_int64 integer; int s_int;
unsigned int s_uint;
PN_int64 int64;
PN_uint64 uint64;
double real; double real;
bool flag; bool flag;
DCClass *dclass; DCClass *dclass;

View File

@ -31,7 +31,7 @@ DCSimpleParameter::Uint32Uint8Type *DCSimpleParameter::_uint32uint8_type = NULL;
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
DCSimpleParameter:: DCSimpleParameter::
DCSimpleParameter(DCSubatomicType type, int divisor) : DCSimpleParameter(DCSubatomicType type, unsigned int divisor) :
_type(type), _type(type),
_divisor(1) _divisor(1)
{ {
@ -270,7 +270,7 @@ get_divisor() const {
// accept a divisor. // accept a divisor.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool DCSimpleParameter:: bool DCSimpleParameter::
set_divisor(int divisor) { set_divisor(unsigned int divisor) {
if (_pack_type == PT_string || divisor == 0) { if (_pack_type == PT_string || divisor == 0) {
return false; return false;
} }
@ -306,11 +306,11 @@ set_range(const DCDoubleRange &range) {
case ST_int8array: case ST_int8array:
_int_range.clear(); _int_range.clear();
for (i = 0; i < num_ranges; i++) { for (i = 0; i < num_ranges; i++) {
int min = (int)floor(range.get_min(i) * _divisor + 0.5); PN_int64 min = (PN_int64)floor(range.get_min(i) * _divisor + 0.5);
int max = (int)floor(range.get_max(i) * _divisor + 0.5); PN_int64 max = (PN_int64)floor(range.get_max(i) * _divisor + 0.5);
validate_int_limits(min, 8, range_error); validate_int64_limits(min, 8, range_error);
validate_int_limits(max, 8, range_error); validate_int64_limits(max, 8, range_error);
_int_range.add_range(min, max); _int_range.add_range((int)min, (int)max);
} }
break; break;
@ -318,11 +318,11 @@ set_range(const DCDoubleRange &range) {
case ST_int16array: case ST_int16array:
_int_range.clear(); _int_range.clear();
for (i = 0; i < num_ranges; i++) { for (i = 0; i < num_ranges; i++) {
int min = (int)floor(range.get_min(i) * _divisor + 0.5); PN_int64 min = (PN_int64)floor(range.get_min(i) * _divisor + 0.5);
int max = (int)floor(range.get_max(i) * _divisor + 0.5); PN_int64 max = (PN_int64)floor(range.get_max(i) * _divisor + 0.5);
validate_int_limits(min, 16, range_error); validate_int64_limits(min, 16, range_error);
validate_int_limits(max, 16, range_error); validate_int64_limits(max, 16, range_error);
_int_range.add_range(min, max); _int_range.add_range((int)min, (int)max);
} }
break; break;
@ -330,9 +330,11 @@ set_range(const DCDoubleRange &range) {
case ST_int32array: case ST_int32array:
_int_range.clear(); _int_range.clear();
for (i = 0; i < num_ranges; i++) { for (i = 0; i < num_ranges; i++) {
int min = (int)floor(range.get_min(i) * _divisor + 0.5); PN_int64 min = (PN_int64)floor(range.get_min(i) * _divisor + 0.5);
int max = (int)floor(range.get_max(i) * _divisor + 0.5); PN_int64 max = (PN_int64)floor(range.get_max(i) * _divisor + 0.5);
_int_range.add_range(min, max); validate_int64_limits(min, 32, range_error);
validate_int64_limits(max, 32, range_error);
_int_range.add_range((int)min, (int)max);
} }
break; break;
@ -349,11 +351,11 @@ set_range(const DCDoubleRange &range) {
case ST_uint8array: case ST_uint8array:
_uint_range.clear(); _uint_range.clear();
for (i = 0; i < num_ranges; i++) { for (i = 0; i < num_ranges; i++) {
unsigned int min = (unsigned int)floor(range.get_min(i) * _divisor + 0.5); PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
unsigned int max = (unsigned int)floor(range.get_max(i) * _divisor + 0.5); PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
validate_uint_limits(min, 8, range_error); validate_uint64_limits(min, 8, range_error);
validate_uint_limits(max, 8, range_error); validate_uint64_limits(max, 8, range_error);
_uint_range.add_range(min, max); _uint_range.add_range((unsigned int)min, (unsigned int)max);
} }
break; break;
@ -361,11 +363,11 @@ set_range(const DCDoubleRange &range) {
case ST_uint16array: case ST_uint16array:
_uint_range.clear(); _uint_range.clear();
for (i = 0; i < num_ranges; i++) { for (i = 0; i < num_ranges; i++) {
unsigned int min = (unsigned int)floor(range.get_min(i) * _divisor + 0.5); PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
unsigned int max = (unsigned int)floor(range.get_max(i) * _divisor + 0.5); PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
validate_uint_limits(min, 16, range_error); validate_uint64_limits(min, 16, range_error);
validate_uint_limits(max, 16, range_error); validate_uint64_limits(max, 16, range_error);
_uint_range.add_range(min, max); _uint_range.add_range((unsigned int)min, (unsigned int)max);
} }
break; break;
@ -373,9 +375,11 @@ set_range(const DCDoubleRange &range) {
case ST_uint32array: case ST_uint32array:
_uint_range.clear(); _uint_range.clear();
for (i = 0; i < num_ranges; i++) { for (i = 0; i < num_ranges; i++) {
unsigned int min = (unsigned int)floor(range.get_min(i) * _divisor + 0.5); PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
unsigned int max = (unsigned int)floor(range.get_max(i) * _divisor + 0.5); PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
_uint_range.add_range(min, max); validate_uint64_limits(min, 32, range_error);
validate_uint64_limits(max, 32, range_error);
_uint_range.add_range((unsigned int)min, (unsigned int)max);
} }
break; break;
@ -401,11 +405,11 @@ set_range(const DCDoubleRange &range) {
case ST_blob: case ST_blob:
_uint_range.clear(); _uint_range.clear();
for (i = 0; i < num_ranges; i++) { for (i = 0; i < num_ranges; i++) {
unsigned int min = (unsigned int)floor(range.get_min(i) * _divisor + 0.5); PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
unsigned int max = (unsigned int)floor(range.get_max(i) * _divisor + 0.5); PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
validate_uint_limits(min, 16, range_error); validate_uint64_limits(min, 16, range_error);
validate_uint_limits(max, 16, range_error); validate_uint64_limits(max, 16, range_error);
_uint_range.add_range(min, max); _uint_range.add_range((unsigned int)min, (unsigned int)max);
} }
if (_uint_range.has_one_value()) { if (_uint_range.has_one_value()) {
// If we now have a fixed-length string requirement, we don't // If we now have a fixed-length string requirement, we don't
@ -424,9 +428,11 @@ set_range(const DCDoubleRange &range) {
case ST_blob32: case ST_blob32:
_uint_range.clear(); _uint_range.clear();
for (i = 0; i < num_ranges; i++) { for (i = 0; i < num_ranges; i++) {
unsigned int min = (unsigned int)floor(range.get_min(i) * _divisor + 0.5); PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
unsigned int max = (unsigned int)floor(range.get_max(i) * _divisor + 0.5); PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
_uint_range.add_range(min, max); validate_uint64_limits(min, 32, range_error);
validate_uint64_limits(max, 32, range_error);
_uint_range.add_range((unsigned int)min, (unsigned int)max);
} }
if (_uint_range.has_one_value()) { if (_uint_range.has_one_value()) {
// If we now have a fixed-length string requirement, we don't // If we now have a fixed-length string requirement, we don't
@ -1952,7 +1958,7 @@ generate_hash(HashGenerator &hashgen) const {
// if it is not already created. // if it is not already created.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
DCSimpleParameter *DCSimpleParameter:: DCSimpleParameter *DCSimpleParameter::
create_nested_field(DCSubatomicType type, int divisor) { create_nested_field(DCSubatomicType type, unsigned int divisor) {
DivisorMap divisor_map = _nested_field_map[type]; DivisorMap divisor_map = _nested_field_map[type];
DivisorMap::iterator di; DivisorMap::iterator di;
di = divisor_map.find(divisor); di = divisor_map.find(divisor);

View File

@ -35,7 +35,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_DIRECT DCSimpleParameter : public DCParameter { class EXPCL_DIRECT DCSimpleParameter : public DCParameter {
public: public:
DCSimpleParameter(DCSubatomicType type, int divisor = 1); DCSimpleParameter(DCSubatomicType type, unsigned int divisor = 1);
DCSimpleParameter(const DCSimpleParameter &copy); DCSimpleParameter(const DCSimpleParameter &copy);
PUBLISHED: PUBLISHED:
@ -47,7 +47,7 @@ PUBLISHED:
int get_divisor() const; int get_divisor() const;
public: public:
bool set_divisor(int divisor); bool set_divisor(unsigned int divisor);
bool set_range(const DCDoubleRange &range); bool set_range(const DCDoubleRange &range);
virtual int calc_num_nested_fields(size_t length_bytes) const; virtual int calc_num_nested_fields(size_t length_bytes) const;
@ -87,12 +87,13 @@ public:
virtual void generate_hash(HashGenerator &hashgen) const; virtual void generate_hash(HashGenerator &hashgen) const;
private: private:
static DCSimpleParameter *create_nested_field(DCSubatomicType type, int divisor); static DCSimpleParameter *create_nested_field(DCSubatomicType type,
unsigned int divisor);
static DCPackerInterface *create_uint32uint8_type(); static DCPackerInterface *create_uint32uint8_type();
private: private:
DCSubatomicType _type; DCSubatomicType _type;
int _divisor; unsigned int _divisor;
DCSubatomicType _nested_type; DCSubatomicType _nested_type;
DCPackerInterface *_nested_field; DCPackerInterface *_nested_field;
@ -101,7 +102,7 @@ private:
// The rest of this is to maintain the static list of // The rest of this is to maintain the static list of
// DCPackerInterface objects for _nested_field, above. We allocate // DCPackerInterface objects for _nested_field, above. We allocate
// each possible object once, and don't delete it. // each possible object once, and don't delete it.
typedef pmap<int, DCSimpleParameter *> DivisorMap; typedef pmap<unsigned int, DCSimpleParameter *> DivisorMap;
typedef pmap<DCSubatomicType, DivisorMap> NestedFieldMap; typedef pmap<DCSubatomicType, DivisorMap> NestedFieldMap;
static NestedFieldMap _nested_field_map; static NestedFieldMap _nested_field_map;