mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 05:27:55 +00:00
[4088fd] cleanup grammar (indent, no untyped)
This commit is contained in:
parent
b233a68984
commit
01b370bd9d
@ -65,32 +65,34 @@
|
||||
@code
|
||||
01. %start expression;
|
||||
02.
|
||||
03. expression:
|
||||
04. token EQUAL token
|
||||
05. | token;
|
||||
03. expression : token EQUAL token
|
||||
04. | token
|
||||
05. ;
|
||||
06.
|
||||
07. token:
|
||||
08. STRING {
|
||||
09. TokenPtr str(new TokenString($1));
|
||||
10. ctx.expression.push_back(str);
|
||||
11.}
|
||||
12. HEXSTRING {
|
||||
13. TokenPtr hex(new TokenHexString($1));
|
||||
14. ctx.expression.push_back(hex);
|
||||
15.}
|
||||
16.| OPTION {
|
||||
17. TokenPtr opt(new TokenOption($1));
|
||||
18. ctx.expression.push_back(opt);
|
||||
19.}
|
||||
20.;
|
||||
07. token : STRING
|
||||
08. {
|
||||
09. TokenPtr str(new TokenString($1));
|
||||
10. ctx.expression.push_back(str);
|
||||
11. }
|
||||
12. | HEXSTRING
|
||||
13. {
|
||||
14. TokenPtr hex(new TokenHexString($1));
|
||||
15. ctx.expression.push_back(hex);
|
||||
16. }
|
||||
17. | OPTION '[' INTEGER ']'
|
||||
18. {
|
||||
19. TokenPtr opt(new TokenOption($3));
|
||||
20. ctx.expression.push_back(opt);
|
||||
21. }
|
||||
22. ;
|
||||
@endcode
|
||||
|
||||
This code determines that the grammar starts from expression (line 1).
|
||||
The actual definition of expression (lines 3-5) may either be a
|
||||
single token or an expression "token == token" (EQUAL has been defined as
|
||||
"==" elsewhere). Token is further
|
||||
defined in lines 7-15: it may either be a string (lines 8-11),
|
||||
a hex string (lines 12-15) or option (lines 16-19).
|
||||
defined in lines 7-22: it may either be a string (lines 7-11),
|
||||
a hex string (lines 12-16) or option (lines 17-21).
|
||||
When the actual case is determined, the respective C++ action
|
||||
is executed. For example, if the token is a string, the TokenString class is
|
||||
instantiated with the appropriate value and put onto the expression vector.
|
||||
|
@ -469,8 +469,8 @@ static void yy_fatal_error (yyconst char msg[] );
|
||||
(yy_c_buf_p) = yy_cp;
|
||||
|
||||
/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
|
||||
#define YY_NUM_RULES 18
|
||||
#define YY_END_OF_BUFFER 19
|
||||
#define YY_NUM_RULES 17
|
||||
#define YY_END_OF_BUFFER 18
|
||||
/* This struct is not used in this scanner,
|
||||
but its presence is necessary. */
|
||||
struct yy_trans_info
|
||||
@ -478,14 +478,13 @@ struct yy_trans_info
|
||||
flex_int32_t yy_verify;
|
||||
flex_int32_t yy_nxt;
|
||||
};
|
||||
static yyconst flex_int16_t yy_accept[56] =
|
||||
static yyconst flex_int16_t yy_accept[48] =
|
||||
{ 0,
|
||||
0, 0, 19, 17, 1, 2, 17, 12, 13, 16,
|
||||
17, 7, 7, 17, 14, 15, 17, 17, 17, 1,
|
||||
2, 0, 5, 0, 0, 0, 7, 0, 8, 0,
|
||||
0, 0, 3, 0, 6, 0, 0, 0, 0, 0,
|
||||
0, 0, 4, 0, 0, 0, 9, 0, 0, 0,
|
||||
0, 0, 11, 10, 0
|
||||
0, 0, 18, 16, 1, 2, 16, 11, 12, 15,
|
||||
16, 7, 7, 16, 13, 14, 16, 16, 1, 2,
|
||||
0, 5, 0, 0, 0, 7, 0, 8, 0, 0,
|
||||
3, 0, 6, 0, 0, 0, 0, 0, 4, 0,
|
||||
0, 9, 0, 0, 0, 10, 0
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_ec[256] =
|
||||
@ -495,15 +494,15 @@ static yyconst flex_int32_t yy_ec[256] =
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 1, 1, 1, 1, 1, 1, 4, 5,
|
||||
6, 1, 1, 7, 8, 1, 1, 9, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 11, 1, 1,
|
||||
12, 1, 1, 1, 13, 13, 13, 13, 13, 13,
|
||||
10, 10, 10, 10, 10, 10, 10, 1, 1, 1,
|
||||
11, 1, 1, 1, 12, 12, 12, 12, 12, 12,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 14, 1, 1,
|
||||
15, 1, 16, 1, 1, 1, 17, 18, 13, 19,
|
||||
1, 1, 1, 1, 1, 1, 1, 13, 1, 1,
|
||||
14, 1, 15, 1, 1, 1, 16, 17, 12, 12,
|
||||
|
||||
20, 13, 21, 1, 22, 1, 1, 23, 1, 24,
|
||||
25, 26, 1, 27, 28, 29, 30, 1, 1, 14,
|
||||
31, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
12, 12, 18, 1, 19, 1, 1, 20, 1, 21,
|
||||
22, 23, 1, 24, 25, 26, 27, 1, 1, 13,
|
||||
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,
|
||||
@ -520,72 +519,67 @@ static yyconst flex_int32_t yy_ec[256] =
|
||||
1, 1, 1, 1, 1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_meta[32] =
|
||||
static yyconst flex_int32_t yy_meta[28] =
|
||||
{ 0,
|
||||
1, 1, 2, 1, 1, 1, 1, 1, 3, 3,
|
||||
1, 1, 3, 1, 1, 1, 3, 3, 3, 3,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1
|
||||
1, 3, 1, 1, 1, 3, 3, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_base[58] =
|
||||
static yyconst flex_int16_t yy_base[50] =
|
||||
{ 0,
|
||||
0, 0, 86, 87, 83, 81, 28, 87, 87, 87,
|
||||
24, 30, 32, 71, 87, 87, 56, 51, 56, 77,
|
||||
75, 73, 87, 39, 42, 31, 46, 0, 87, 47,
|
||||
57, 45, 87, 43, 0, 51, 44, 40, 66, 43,
|
||||
36, 38, 87, 39, 35, 41, 87, 38, 40, 34,
|
||||
46, 32, 87, 87, 87, 66, 47
|
||||
0, 0, 75, 76, 72, 70, 24, 76, 76, 76,
|
||||
20, 26, 28, 61, 76, 76, 48, 43, 66, 62,
|
||||
60, 76, 37, 39, 38, 35, 0, 76, 37, 45,
|
||||
76, 46, 0, 42, 35, 55, 35, 30, 76, 34,
|
||||
30, 76, 34, 31, 33, 76, 76, 66, 28
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_def[58] =
|
||||
static yyconst flex_int16_t yy_def[50] =
|
||||
{ 0,
|
||||
55, 1, 55, 55, 55, 55, 56, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 56, 55, 56, 56, 56, 55, 57, 55, 55,
|
||||
55, 55, 55, 56, 57, 55, 55, 55, 56, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 0, 55, 55
|
||||
47, 1, 47, 47, 47, 47, 48, 47, 47, 47,
|
||||
47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
48, 47, 48, 48, 48, 47, 49, 47, 47, 47,
|
||||
47, 48, 49, 47, 47, 48, 47, 47, 47, 47,
|
||||
47, 47, 47, 47, 47, 47, 0, 47, 47
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_nxt[119] =
|
||||
static yyconst flex_int16_t yy_nxt[104] =
|
||||
{ 0,
|
||||
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||
4, 14, 4, 4, 15, 16, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 17, 4, 4, 18, 4, 19,
|
||||
4, 23, 27, 27, 23, 24, 25, 25, 27, 27,
|
||||
27, 27, 23, 28, 26, 33, 23, 25, 25, 35,
|
||||
25, 25, 54, 34, 27, 27, 53, 52, 51, 50,
|
||||
49, 48, 47, 46, 45, 39, 22, 44, 22, 43,
|
||||
42, 41, 40, 38, 37, 36, 23, 21, 20, 32,
|
||||
31, 30, 29, 21, 20, 55, 3, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
14, 4, 4, 15, 16, 4, 4, 4, 4, 4,
|
||||
4, 17, 4, 4, 18, 4, 4, 22, 26, 26,
|
||||
33, 23, 24, 24, 26, 26, 26, 26, 27, 25,
|
||||
22, 22, 31, 26, 26, 24, 24, 24, 24, 22,
|
||||
46, 45, 44, 43, 42, 41, 40, 32, 39, 38,
|
||||
37, 35, 34, 22, 20, 36, 21, 19, 21, 30,
|
||||
29, 28, 20, 19, 47, 3, 47, 47, 47, 47,
|
||||
47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55
|
||||
47, 47, 47
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_chk[119] =
|
||||
static yyconst flex_int16_t yy_chk[104] =
|
||||
{ 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, 7, 11, 11, 26, 7, 7, 7, 12, 12,
|
||||
13, 13, 24, 12, 7, 25, 34, 24, 24, 57,
|
||||
25, 25, 52, 26, 27, 27, 51, 50, 49, 48,
|
||||
46, 45, 44, 42, 41, 34, 56, 40, 56, 39,
|
||||
38, 37, 36, 32, 31, 30, 22, 21, 20, 19,
|
||||
18, 17, 14, 6, 5, 3, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
1, 1, 1, 1, 1, 1, 1, 7, 11, 11,
|
||||
49, 7, 7, 7, 12, 12, 13, 13, 12, 7,
|
||||
23, 25, 24, 26, 26, 23, 23, 24, 24, 32,
|
||||
45, 44, 43, 41, 40, 38, 37, 25, 36, 35,
|
||||
34, 30, 29, 21, 20, 32, 48, 19, 48, 18,
|
||||
17, 14, 6, 5, 3, 47, 47, 47, 47, 47,
|
||||
47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
|
||||
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55
|
||||
47, 47, 47
|
||||
} ;
|
||||
|
||||
/* Table of booleans, true if rule could match eol. */
|
||||
static yyconst flex_int32_t yy_rule_can_match_eol[19] =
|
||||
static yyconst flex_int32_t yy_rule_can_match_eol[18] =
|
||||
{ 0,
|
||||
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
|
||||
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
|
||||
|
||||
static yy_state_type yy_last_accepting_state;
|
||||
static char *yy_last_accepting_cpos;
|
||||
@ -593,10 +587,10 @@ static char *yy_last_accepting_cpos;
|
||||
extern int yy_flex_debug;
|
||||
int yy_flex_debug = 1;
|
||||
|
||||
static yyconst flex_int16_t yy_rule_linenum[18] =
|
||||
static yyconst flex_int16_t yy_rule_linenum[17] =
|
||||
{ 0,
|
||||
83, 87, 93, 101, 107, 117, 123, 137, 138, 139,
|
||||
140, 141, 142, 143, 144, 145, 147
|
||||
140, 141, 142, 143, 144, 146
|
||||
} ;
|
||||
|
||||
/* The intent behind this definition is that it'll catch
|
||||
@ -663,7 +657,7 @@ static isc::eval::location loc;
|
||||
// by moving it ahead by yyleng bytes. yyleng specifies the length of the
|
||||
// currently matched token.
|
||||
#define YY_USER_ACTION loc.columns(yyleng);
|
||||
#line 667 "lexer.cc"
|
||||
#line 661 "lexer.cc"
|
||||
|
||||
#define INITIAL 0
|
||||
|
||||
@ -946,7 +940,7 @@ YY_DECL
|
||||
loc.step();
|
||||
|
||||
|
||||
#line 950 "lexer.cc"
|
||||
#line 944 "lexer.cc"
|
||||
|
||||
while ( 1 ) /* loops until end-of-file is reached */
|
||||
{
|
||||
@ -975,13 +969,13 @@ yy_match:
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 56 )
|
||||
if ( yy_current_state >= 48 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
while ( yy_current_state != 55 );
|
||||
while ( yy_current_state != 47 );
|
||||
yy_cp = (yy_last_accepting_cpos);
|
||||
yy_current_state = (yy_last_accepting_state);
|
||||
|
||||
@ -1010,13 +1004,13 @@ do_action: /* This label is used only to access EOF actions. */
|
||||
{
|
||||
if ( yy_act == 0 )
|
||||
fprintf( stderr, "--scanner backing up\n" );
|
||||
else if ( yy_act < 18 )
|
||||
else if ( yy_act < 17 )
|
||||
fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
|
||||
(long)yy_rule_linenum[yy_act], yytext );
|
||||
else if ( yy_act == 18 )
|
||||
else if ( yy_act == 17 )
|
||||
fprintf( stderr, "--accepting default rule (\"%s\")\n",
|
||||
yytext );
|
||||
else if ( yy_act == 19 )
|
||||
else if ( yy_act == 18 )
|
||||
fprintf( stderr, "--(end of buffer or a NUL)\n" );
|
||||
else
|
||||
fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
|
||||
@ -1127,48 +1121,43 @@ return isc::eval::EvalParser::make_SUBSTRING(loc);
|
||||
case 11:
|
||||
YY_RULE_SETUP
|
||||
#line 140 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_UNTYPED(loc);
|
||||
return isc::eval::EvalParser::make_LPAREN(loc);
|
||||
YY_BREAK
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
#line 141 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_LPAREN(loc);
|
||||
return isc::eval::EvalParser::make_RPAREN(loc);
|
||||
YY_BREAK
|
||||
case 13:
|
||||
YY_RULE_SETUP
|
||||
#line 142 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_RPAREN(loc);
|
||||
return isc::eval::EvalParser::make_LBRACKET(loc);
|
||||
YY_BREAK
|
||||
case 14:
|
||||
YY_RULE_SETUP
|
||||
#line 143 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_LBRACKET(loc);
|
||||
return isc::eval::EvalParser::make_RBRACKET(loc);
|
||||
YY_BREAK
|
||||
case 15:
|
||||
YY_RULE_SETUP
|
||||
#line 144 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_RBRACKET(loc);
|
||||
return isc::eval::EvalParser::make_COMA(loc);
|
||||
YY_BREAK
|
||||
case 16:
|
||||
YY_RULE_SETUP
|
||||
#line 145 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_COMA(loc);
|
||||
YY_BREAK
|
||||
case 17:
|
||||
YY_RULE_SETUP
|
||||
#line 147 "lexer.ll"
|
||||
#line 146 "lexer.ll"
|
||||
driver.error (loc, "Invalid character: " + std::string(yytext));
|
||||
YY_BREAK
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
#line 148 "lexer.ll"
|
||||
#line 147 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_END(loc);
|
||||
YY_BREAK
|
||||
case 18:
|
||||
case 17:
|
||||
YY_RULE_SETUP
|
||||
#line 149 "lexer.ll"
|
||||
#line 148 "lexer.ll"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 1172 "lexer.cc"
|
||||
#line 1161 "lexer.cc"
|
||||
|
||||
case YY_END_OF_BUFFER:
|
||||
{
|
||||
@ -1481,7 +1470,7 @@ static int yy_get_next_buffer (void)
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 56 )
|
||||
if ( yy_current_state >= 48 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
@ -1514,11 +1503,11 @@ static int yy_get_next_buffer (void)
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 56 )
|
||||
if ( yy_current_state >= 48 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_is_jam = (yy_current_state == 55);
|
||||
yy_is_jam = (yy_current_state == 47);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
}
|
||||
@ -2256,7 +2245,7 @@ void yyfree (void * ptr )
|
||||
|
||||
/* %ok-for-header */
|
||||
|
||||
#line 149 "lexer.ll"
|
||||
#line 148 "lexer.ll"
|
||||
|
||||
|
||||
|
||||
|
@ -137,7 +137,6 @@ blank [ \t]
|
||||
"==" return isc::eval::EvalParser::make_EQUAL(loc);
|
||||
"option" return isc::eval::EvalParser::make_OPTION(loc);
|
||||
"substring" return isc::eval::EvalParser::make_SUBSTRING(loc);
|
||||
"untyped:" return isc::eval::EvalParser::make_UNTYPED(loc);
|
||||
"(" return isc::eval::EvalParser::make_LPAREN(loc);
|
||||
")" return isc::eval::EvalParser::make_RPAREN(loc);
|
||||
"[" return isc::eval::EvalParser::make_LBRACKET(loc);
|
||||
|
@ -251,14 +251,14 @@ namespace isc { namespace eval {
|
||||
{
|
||||
switch (that.type_get ())
|
||||
{
|
||||
case 16: // "integer"
|
||||
case 15: // "integer"
|
||||
value.move< int > (that.value);
|
||||
break;
|
||||
|
||||
case 12: // "a number in a constant string"
|
||||
case 13: // "the all constant string"
|
||||
case 14: // "constant string"
|
||||
case 15: // "constant hexstring"
|
||||
case 11: // "a number in a constant string"
|
||||
case 12: // "the all constant string"
|
||||
case 13: // "constant string"
|
||||
case 14: // "constant hexstring"
|
||||
value.move< std::string > (that.value);
|
||||
break;
|
||||
|
||||
@ -277,14 +277,14 @@ namespace isc { namespace eval {
|
||||
state = that.state;
|
||||
switch (that.type_get ())
|
||||
{
|
||||
case 16: // "integer"
|
||||
case 15: // "integer"
|
||||
value.copy< int > (that.value);
|
||||
break;
|
||||
|
||||
case 12: // "a number in a constant string"
|
||||
case 13: // "the all constant string"
|
||||
case 14: // "constant string"
|
||||
case 15: // "constant hexstring"
|
||||
case 11: // "a number in a constant string"
|
||||
case 12: // "the all constant string"
|
||||
case 13: // "constant string"
|
||||
case 14: // "constant hexstring"
|
||||
value.copy< std::string > (that.value);
|
||||
break;
|
||||
|
||||
@ -324,37 +324,37 @@ namespace isc { namespace eval {
|
||||
<< yysym.location << ": ";
|
||||
switch (yytype)
|
||||
{
|
||||
case 12: // "a number in a constant string"
|
||||
case 11: // "a number in a constant string"
|
||||
|
||||
#line 59 "parser.yy" // lalr1.cc:636
|
||||
#line 58 "parser.yy" // lalr1.cc:636
|
||||
{ yyoutput << yysym.value.template as< std::string > (); }
|
||||
#line 332 "parser.cc" // lalr1.cc:636
|
||||
break;
|
||||
|
||||
case 13: // "the all constant string"
|
||||
case 12: // "the all constant string"
|
||||
|
||||
#line 59 "parser.yy" // lalr1.cc:636
|
||||
#line 58 "parser.yy" // lalr1.cc:636
|
||||
{ yyoutput << yysym.value.template as< std::string > (); }
|
||||
#line 339 "parser.cc" // lalr1.cc:636
|
||||
break;
|
||||
|
||||
case 14: // "constant string"
|
||||
case 13: // "constant string"
|
||||
|
||||
#line 59 "parser.yy" // lalr1.cc:636
|
||||
#line 58 "parser.yy" // lalr1.cc:636
|
||||
{ yyoutput << yysym.value.template as< std::string > (); }
|
||||
#line 346 "parser.cc" // lalr1.cc:636
|
||||
break;
|
||||
|
||||
case 15: // "constant hexstring"
|
||||
case 14: // "constant hexstring"
|
||||
|
||||
#line 59 "parser.yy" // lalr1.cc:636
|
||||
#line 58 "parser.yy" // lalr1.cc:636
|
||||
{ yyoutput << yysym.value.template as< std::string > (); }
|
||||
#line 353 "parser.cc" // lalr1.cc:636
|
||||
break;
|
||||
|
||||
case 16: // "integer"
|
||||
case 15: // "integer"
|
||||
|
||||
#line 59 "parser.yy" // lalr1.cc:636
|
||||
#line 58 "parser.yy" // lalr1.cc:636
|
||||
{ yyoutput << yysym.value.template as< int > (); }
|
||||
#line 360 "parser.cc" // lalr1.cc:636
|
||||
break;
|
||||
@ -556,14 +556,14 @@ namespace isc { namespace eval {
|
||||
when using variants. */
|
||||
switch (yyr1_[yyn])
|
||||
{
|
||||
case 16: // "integer"
|
||||
case 15: // "integer"
|
||||
yylhs.value.build< int > ();
|
||||
break;
|
||||
|
||||
case 12: // "a number in a constant string"
|
||||
case 13: // "the all constant string"
|
||||
case 14: // "constant string"
|
||||
case 15: // "constant hexstring"
|
||||
case 11: // "a number in a constant string"
|
||||
case 12: // "the all constant string"
|
||||
case 13: // "constant string"
|
||||
case 14: // "constant hexstring"
|
||||
yylhs.value.build< std::string > ();
|
||||
break;
|
||||
|
||||
@ -584,175 +584,105 @@ namespace isc { namespace eval {
|
||||
{
|
||||
switch (yyn)
|
||||
{
|
||||
case 4:
|
||||
#line 73 "parser.yy" // lalr1.cc:859
|
||||
case 3:
|
||||
#line 70 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr eq(new TokenEqual());
|
||||
ctx.expression.push_back(eq);
|
||||
}
|
||||
TokenPtr eq(new TokenEqual());
|
||||
ctx.expression.push_back(eq);
|
||||
}
|
||||
#line 594 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 6:
|
||||
#line 81 "parser.yy" // lalr1.cc:859
|
||||
case 4:
|
||||
#line 77 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 603 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 7:
|
||||
#line 85 "parser.yy" // lalr1.cc:859
|
||||
case 5:
|
||||
#line 82 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 612 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 8:
|
||||
#line 89 "parser.yy" // lalr1.cc:859
|
||||
case 6:
|
||||
#line 87 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 621 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 9:
|
||||
#line 93 "parser.yy" // lalr1.cc:859
|
||||
case 7:
|
||||
#line 92 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(hex);
|
||||
}
|
||||
TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(hex);
|
||||
}
|
||||
#line 630 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 10:
|
||||
case 8:
|
||||
#line 97 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
int n = yystack_[1].value.as< int > ();
|
||||
if (n < 0 || n > 65535) {
|
||||
std::ostringstream oss;
|
||||
oss << "Option code has invalid value in " << n
|
||||
<< ". Allowed range: 0..65535";
|
||||
ctx.error(yystack_[1].location, oss.str());
|
||||
}
|
||||
TokenPtr opt(new TokenOption(static_cast<uint16_t>(n)));
|
||||
ctx.expression.push_back(opt);
|
||||
}
|
||||
int n = yystack_[1].value.as< int > ();
|
||||
if (n < 0 || n > 65535) {
|
||||
std::ostringstream oss;
|
||||
oss << "Option code has invalid value in " << n
|
||||
<< ". Allowed range: 0..65535";
|
||||
ctx.error(yystack_[1].location, oss.str());
|
||||
}
|
||||
TokenPtr opt(new TokenOption(static_cast<uint16_t>(n)));
|
||||
ctx.expression.push_back(opt);
|
||||
}
|
||||
#line 646 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 11:
|
||||
#line 108 "parser.yy" // lalr1.cc:859
|
||||
case 9:
|
||||
#line 109 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr sub(new TokenSubstring());
|
||||
ctx.expression.push_back(sub);
|
||||
}
|
||||
TokenPtr sub(new TokenSubstring());
|
||||
ctx.expression.push_back(sub);
|
||||
}
|
||||
#line 655 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 12:
|
||||
#line 115 "parser.yy" // lalr1.cc:859
|
||||
case 10:
|
||||
#line 116 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr eq(new TokenEqual());
|
||||
ctx.expression.push_back(eq);
|
||||
}
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 664 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 13:
|
||||
#line 122 "parser.yy" // lalr1.cc:859
|
||||
case 11:
|
||||
#line 123 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 673 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 14:
|
||||
#line 126 "parser.yy" // lalr1.cc:859
|
||||
case 12:
|
||||
#line 128 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 682 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 15:
|
||||
#line 130 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 691 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 16:
|
||||
#line 134 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(hex);
|
||||
}
|
||||
#line 700 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 17:
|
||||
#line 138 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
int n = yystack_[1].value.as< int > ();
|
||||
if (n < 0 || n > 65535) {
|
||||
std::ostringstream oss;
|
||||
oss << "Option code has invalid value in " << n
|
||||
<< ". Allowed range: 0..65535";
|
||||
ctx.error(yystack_[1].location, oss.str());
|
||||
}
|
||||
TokenPtr opt(new TokenOption(static_cast<uint16_t>(n)));
|
||||
ctx.expression.push_back(opt);
|
||||
}
|
||||
#line 716 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 18:
|
||||
#line 149 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr sub(new TokenSubstring());
|
||||
ctx.expression.push_back(sub);
|
||||
}
|
||||
#line 725 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 19:
|
||||
#line 156 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 734 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 20:
|
||||
#line 163 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 743 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 21:
|
||||
#line 167 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 752 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
|
||||
#line 756 "parser.cc" // lalr1.cc:859
|
||||
#line 686 "parser.cc" // lalr1.cc:859
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1007,86 +937,74 @@ namespace isc { namespace eval {
|
||||
}
|
||||
|
||||
|
||||
const signed char EvalParser::yypact_ninf_ = -27;
|
||||
const signed char EvalParser::yypact_ninf_ = -10;
|
||||
|
||||
const signed char EvalParser::yytable_ninf_ = -1;
|
||||
|
||||
const signed char
|
||||
EvalParser::yypact_[] =
|
||||
{
|
||||
0, -3, 1, 14, -27, -27, -27, -27, 8, -27,
|
||||
13, 5, 18, 15, 16, -27, -27, -27, -27, -27,
|
||||
31, -27, 18, 24, 29, 21, 14, 14, -27, -27,
|
||||
26, 28, 33, -27, -27, 34, -27, 14, -10, 35,
|
||||
-27, -27, 36, 14, -27, 37, -27
|
||||
-4, 2, 5, -10, -10, -10, -10, 3, -10, 10,
|
||||
-1, -4, -10, -4, 6, 9, -10, -10, 7, -10,
|
||||
11, -6, -10, -10, 12, -10
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yydefact_[] =
|
||||
{
|
||||
0, 0, 0, 0, 14, 15, 13, 16, 0, 3,
|
||||
0, 0, 0, 0, 0, 7, 8, 6, 9, 2,
|
||||
5, 1, 0, 0, 0, 0, 0, 0, 12, 17,
|
||||
0, 0, 0, 4, 19, 0, 10, 0, 0, 0,
|
||||
20, 21, 0, 0, 18, 0, 11
|
||||
0, 0, 0, 5, 6, 4, 7, 0, 2, 0,
|
||||
0, 0, 1, 0, 0, 0, 3, 8, 0, 10,
|
||||
0, 0, 11, 12, 0, 9
|
||||
};
|
||||
|
||||
const signed char
|
||||
EvalParser::yypgoto_[] =
|
||||
{
|
||||
-27, -27, -27, -26, -27, -2, -27, -27
|
||||
-10, -10, -10, -9, -10, -10
|
||||
};
|
||||
|
||||
const signed char
|
||||
EvalParser::yydefgoto_[] =
|
||||
{
|
||||
-1, 8, 19, 20, 9, 10, 35, 42
|
||||
-1, 7, 8, 9, 20, 24
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yytable_[] =
|
||||
{
|
||||
32, 33, 40, 41, 1, 2, 3, 11, 21, 12,
|
||||
24, 39, 4, 5, 6, 7, 22, 45, 13, 14,
|
||||
28, 23, 1, 2, 26, 25, 15, 16, 17, 18,
|
||||
4, 5, 6, 7, 27, 29, 30, 31, 34, 36,
|
||||
37, 38, 43, 0, 0, 44, 46
|
||||
1, 2, 15, 12, 16, 22, 23, 3, 4, 5,
|
||||
6, 10, 11, 13, 14, 18, 17, 21, 19, 0,
|
||||
25
|
||||
};
|
||||
|
||||
const signed char
|
||||
EvalParser::yycheck_[] =
|
||||
{
|
||||
26, 27, 12, 13, 4, 5, 6, 10, 0, 8,
|
||||
12, 37, 12, 13, 14, 15, 3, 43, 4, 5,
|
||||
22, 16, 4, 5, 8, 10, 12, 13, 14, 15,
|
||||
12, 13, 14, 15, 3, 11, 7, 16, 12, 11,
|
||||
7, 7, 7, -1, -1, 9, 9
|
||||
4, 5, 11, 0, 13, 11, 12, 11, 12, 13,
|
||||
14, 9, 7, 3, 15, 6, 10, 6, 11, -1,
|
||||
8
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yystos_[] =
|
||||
{
|
||||
0, 4, 5, 6, 12, 13, 14, 15, 18, 21,
|
||||
22, 10, 8, 4, 5, 12, 13, 14, 15, 19,
|
||||
20, 0, 3, 16, 22, 10, 8, 3, 22, 11,
|
||||
7, 16, 20, 20, 12, 23, 11, 7, 7, 20,
|
||||
12, 13, 24, 7, 9, 20, 9
|
||||
0, 4, 5, 11, 12, 13, 14, 17, 18, 19,
|
||||
9, 7, 0, 3, 15, 19, 19, 10, 6, 11,
|
||||
20, 6, 11, 12, 21, 8
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yyr1_[] =
|
||||
{
|
||||
0, 17, 18, 18, 19, 19, 20, 20, 20, 20,
|
||||
20, 20, 21, 22, 22, 22, 22, 22, 22, 23,
|
||||
24, 24
|
||||
0, 16, 17, 18, 19, 19, 19, 19, 19, 19,
|
||||
20, 21, 21
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yyr2_[] =
|
||||
{
|
||||
0, 2, 2, 1, 3, 1, 1, 1, 1, 1,
|
||||
4, 8, 3, 1, 1, 1, 1, 4, 8, 1,
|
||||
1, 1
|
||||
0, 2, 1, 3, 1, 1, 1, 1, 4, 8,
|
||||
1, 1, 1
|
||||
};
|
||||
|
||||
|
||||
@ -1097,11 +1015,10 @@ namespace isc { namespace eval {
|
||||
const EvalParser::yytname_[] =
|
||||
{
|
||||
"\"end of file\"", "error", "$undefined", "\"==\"", "\"option\"",
|
||||
"\"substring\"", "\"untyped:\"", "\",\"", "\"(\"", "\")\"", "\"[\"",
|
||||
"\"]\"", "\"a number in a constant string\"",
|
||||
"\"the all constant string\"", "\"constant string\"",
|
||||
"\"constant hexstring\"", "\"integer\"", "$accept", "expression",
|
||||
"untyped_expr", "token", "bool_expr", "string_expr", "start_expr",
|
||||
"\"substring\"", "\",\"", "\"(\"", "\")\"", "\"[\"", "\"]\"",
|
||||
"\"a number in a constant string\"", "\"the all constant string\"",
|
||||
"\"constant string\"", "\"constant hexstring\"", "\"integer\"",
|
||||
"$accept", "expression", "bool_expr", "string_expr", "start_expr",
|
||||
"length_expr", YY_NULLPTR
|
||||
};
|
||||
|
||||
@ -1109,9 +1026,8 @@ namespace isc { namespace eval {
|
||||
const unsigned char
|
||||
EvalParser::yyrline_[] =
|
||||
{
|
||||
0, 68, 68, 69, 73, 77, 81, 85, 89, 93,
|
||||
97, 108, 115, 122, 126, 130, 134, 138, 149, 156,
|
||||
163, 167
|
||||
0, 66, 66, 69, 76, 81, 86, 91, 96, 108,
|
||||
115, 122, 127
|
||||
};
|
||||
|
||||
// Print the state stack on the debug stream.
|
||||
@ -1146,8 +1062,8 @@ namespace isc { namespace eval {
|
||||
|
||||
#line 21 "parser.yy" // lalr1.cc:1167
|
||||
} } // isc::eval
|
||||
#line 1150 "parser.cc" // lalr1.cc:1167
|
||||
#line 173 "parser.yy" // lalr1.cc:1168
|
||||
#line 1066 "parser.cc" // lalr1.cc:1167
|
||||
#line 134 "parser.yy" // lalr1.cc:1168
|
||||
|
||||
void
|
||||
isc::eval::EvalParser::error(const location_type& loc,
|
||||
|
@ -327,17 +327,16 @@ namespace isc { namespace eval {
|
||||
TOKEN_EQUAL = 258,
|
||||
TOKEN_OPTION = 259,
|
||||
TOKEN_SUBSTRING = 260,
|
||||
TOKEN_UNTYPED = 261,
|
||||
TOKEN_COMA = 262,
|
||||
TOKEN_LPAREN = 263,
|
||||
TOKEN_RPAREN = 264,
|
||||
TOKEN_LBRACKET = 265,
|
||||
TOKEN_RBRACKET = 266,
|
||||
TOKEN_NUMBER = 267,
|
||||
TOKEN_ALL = 268,
|
||||
TOKEN_STRING = 269,
|
||||
TOKEN_HEXSTRING = 270,
|
||||
TOKEN_INTEGER = 271
|
||||
TOKEN_COMA = 261,
|
||||
TOKEN_LPAREN = 262,
|
||||
TOKEN_RPAREN = 263,
|
||||
TOKEN_LBRACKET = 264,
|
||||
TOKEN_RBRACKET = 265,
|
||||
TOKEN_NUMBER = 266,
|
||||
TOKEN_ALL = 267,
|
||||
TOKEN_STRING = 268,
|
||||
TOKEN_HEXSTRING = 269,
|
||||
TOKEN_INTEGER = 270
|
||||
};
|
||||
};
|
||||
|
||||
@ -462,10 +461,6 @@ namespace isc { namespace eval {
|
||||
symbol_type
|
||||
make_SUBSTRING (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_UNTYPED (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_COMA (const location_type& l);
|
||||
@ -711,12 +706,12 @@ namespace isc { namespace eval {
|
||||
enum
|
||||
{
|
||||
yyeof_ = 0,
|
||||
yylast_ = 46, ///< Last index in yytable_.
|
||||
yynnts_ = 8, ///< Number of nonterminal symbols.
|
||||
yyfinal_ = 21, ///< Termination state number.
|
||||
yylast_ = 20, ///< Last index in yytable_.
|
||||
yynnts_ = 6, ///< Number of nonterminal symbols.
|
||||
yyfinal_ = 12, ///< Termination state number.
|
||||
yyterror_ = 1,
|
||||
yyerrcode_ = 256,
|
||||
yyntokens_ = 17 ///< Number of tokens.
|
||||
yyntokens_ = 16 ///< Number of tokens.
|
||||
};
|
||||
|
||||
|
||||
@ -760,9 +755,9 @@ namespace isc { namespace eval {
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
|
||||
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16
|
||||
15
|
||||
};
|
||||
const unsigned int user_token_number_max_ = 271;
|
||||
const unsigned int user_token_number_max_ = 270;
|
||||
const token_number_type undef_token_ = 2;
|
||||
|
||||
if (static_cast<int>(t) <= yyeof_)
|
||||
@ -795,14 +790,14 @@ namespace isc { namespace eval {
|
||||
{
|
||||
switch (other.type_get ())
|
||||
{
|
||||
case 16: // "integer"
|
||||
case 15: // "integer"
|
||||
value.copy< int > (other.value);
|
||||
break;
|
||||
|
||||
case 12: // "a number in a constant string"
|
||||
case 13: // "the all constant string"
|
||||
case 14: // "constant string"
|
||||
case 15: // "constant hexstring"
|
||||
case 11: // "a number in a constant string"
|
||||
case 12: // "the all constant string"
|
||||
case 13: // "constant string"
|
||||
case 14: // "constant hexstring"
|
||||
value.copy< std::string > (other.value);
|
||||
break;
|
||||
|
||||
@ -823,14 +818,14 @@ namespace isc { namespace eval {
|
||||
(void) v;
|
||||
switch (this->type_get ())
|
||||
{
|
||||
case 16: // "integer"
|
||||
case 15: // "integer"
|
||||
value.copy< int > (v);
|
||||
break;
|
||||
|
||||
case 12: // "a number in a constant string"
|
||||
case 13: // "the all constant string"
|
||||
case 14: // "constant string"
|
||||
case 15: // "constant hexstring"
|
||||
case 11: // "a number in a constant string"
|
||||
case 12: // "the all constant string"
|
||||
case 13: // "constant string"
|
||||
case 14: // "constant hexstring"
|
||||
value.copy< std::string > (v);
|
||||
break;
|
||||
|
||||
@ -889,14 +884,14 @@ namespace isc { namespace eval {
|
||||
// Type destructor.
|
||||
switch (yytype)
|
||||
{
|
||||
case 16: // "integer"
|
||||
case 15: // "integer"
|
||||
value.template destroy< int > ();
|
||||
break;
|
||||
|
||||
case 12: // "a number in a constant string"
|
||||
case 13: // "the all constant string"
|
||||
case 14: // "constant string"
|
||||
case 15: // "constant hexstring"
|
||||
case 11: // "a number in a constant string"
|
||||
case 12: // "the all constant string"
|
||||
case 13: // "constant string"
|
||||
case 14: // "constant hexstring"
|
||||
value.template destroy< std::string > ();
|
||||
break;
|
||||
|
||||
@ -923,14 +918,14 @@ namespace isc { namespace eval {
|
||||
super_type::move(s);
|
||||
switch (this->type_get ())
|
||||
{
|
||||
case 16: // "integer"
|
||||
case 15: // "integer"
|
||||
value.move< int > (s.value);
|
||||
break;
|
||||
|
||||
case 12: // "a number in a constant string"
|
||||
case 13: // "the all constant string"
|
||||
case 14: // "constant string"
|
||||
case 15: // "constant hexstring"
|
||||
case 11: // "a number in a constant string"
|
||||
case 12: // "the all constant string"
|
||||
case 13: // "constant string"
|
||||
case 14: // "constant hexstring"
|
||||
value.move< std::string > (s.value);
|
||||
break;
|
||||
|
||||
@ -990,7 +985,7 @@ namespace isc { namespace eval {
|
||||
yytoken_number_[] =
|
||||
{
|
||||
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
|
||||
265, 266, 267, 268, 269, 270, 271
|
||||
265, 266, 267, 268, 269, 270
|
||||
};
|
||||
return static_cast<token_type> (yytoken_number_[type]);
|
||||
}
|
||||
@ -1019,12 +1014,6 @@ namespace isc { namespace eval {
|
||||
return symbol_type (token::TOKEN_SUBSTRING, l);
|
||||
}
|
||||
|
||||
EvalParser::symbol_type
|
||||
EvalParser::make_UNTYPED (const location_type& l)
|
||||
{
|
||||
return symbol_type (token::TOKEN_UNTYPED, l);
|
||||
}
|
||||
|
||||
EvalParser::symbol_type
|
||||
EvalParser::make_COMA (const location_type& l)
|
||||
{
|
||||
@ -1088,7 +1077,7 @@ namespace isc { namespace eval {
|
||||
|
||||
#line 21 "parser.yy" // lalr1.cc:392
|
||||
} } // isc::eval
|
||||
#line 1092 "parser.h" // lalr1.cc:392
|
||||
#line 1081 "parser.h" // lalr1.cc:392
|
||||
|
||||
|
||||
|
||||
|
@ -44,7 +44,6 @@ using namespace isc::eval;
|
||||
EQUAL "=="
|
||||
OPTION "option"
|
||||
SUBSTRING "substring"
|
||||
UNTYPED "untyped:"
|
||||
COMA ","
|
||||
LPAREN "("
|
||||
RPAREN ")"
|
||||
@ -64,111 +63,73 @@ using namespace isc::eval;
|
||||
|
||||
// Expression can either be a single token or a (something == something) expression
|
||||
|
||||
expression:
|
||||
UNTYPED untyped_expr
|
||||
| bool_expr
|
||||
;
|
||||
expression : bool_expr
|
||||
;
|
||||
|
||||
untyped_expr:
|
||||
token EQUAL token {
|
||||
TokenPtr eq(new TokenEqual());
|
||||
ctx.expression.push_back(eq);
|
||||
}
|
||||
| token
|
||||
;
|
||||
bool_expr : string_expr EQUAL string_expr
|
||||
{
|
||||
TokenPtr eq(new TokenEqual());
|
||||
ctx.expression.push_back(eq);
|
||||
}
|
||||
;
|
||||
|
||||
token:
|
||||
STRING {
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| NUMBER {
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| ALL {
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| HEXSTRING {
|
||||
TokenPtr hex(new TokenHexString($1));
|
||||
ctx.expression.push_back(hex);
|
||||
}
|
||||
| OPTION "[" INTEGER "]" {
|
||||
int n = $3;
|
||||
if (n < 0 || n > 65535) {
|
||||
std::ostringstream oss;
|
||||
oss << "Option code has invalid value in " << n
|
||||
<< ". Allowed range: 0..65535";
|
||||
ctx.error(@3, oss.str());
|
||||
}
|
||||
TokenPtr opt(new TokenOption(static_cast<uint16_t>(n)));
|
||||
ctx.expression.push_back(opt);
|
||||
}
|
||||
| SUBSTRING "(" token "," token "," token ")" {
|
||||
TokenPtr sub(new TokenSubstring());
|
||||
ctx.expression.push_back(sub);
|
||||
}
|
||||
;
|
||||
string_expr : STRING
|
||||
{
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| NUMBER
|
||||
{
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| ALL
|
||||
{
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| HEXSTRING
|
||||
{
|
||||
TokenPtr hex(new TokenHexString($1));
|
||||
ctx.expression.push_back(hex);
|
||||
}
|
||||
| OPTION "[" INTEGER "]"
|
||||
{
|
||||
int n = $3;
|
||||
if (n < 0 || n > 65535) {
|
||||
std::ostringstream oss;
|
||||
oss << "Option code has invalid value in " << n
|
||||
<< ". Allowed range: 0..65535";
|
||||
ctx.error(@3, oss.str());
|
||||
}
|
||||
TokenPtr opt(new TokenOption(static_cast<uint16_t>(n)));
|
||||
ctx.expression.push_back(opt);
|
||||
}
|
||||
| SUBSTRING "(" string_expr "," start_expr "," length_expr ")"
|
||||
{
|
||||
TokenPtr sub(new TokenSubstring());
|
||||
ctx.expression.push_back(sub);
|
||||
}
|
||||
;
|
||||
|
||||
bool_expr:
|
||||
string_expr EQUAL string_expr {
|
||||
TokenPtr eq(new TokenEqual());
|
||||
ctx.expression.push_back(eq);
|
||||
}
|
||||
;
|
||||
start_expr : NUMBER
|
||||
{
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
;
|
||||
|
||||
string_expr:
|
||||
STRING {
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| NUMBER {
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| ALL {
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| HEXSTRING {
|
||||
TokenPtr hex(new TokenHexString($1));
|
||||
ctx.expression.push_back(hex);
|
||||
}
|
||||
| OPTION "[" INTEGER "]" {
|
||||
int n = $3;
|
||||
if (n < 0 || n > 65535) {
|
||||
std::ostringstream oss;
|
||||
oss << "Option code has invalid value in " << n
|
||||
<< ". Allowed range: 0..65535";
|
||||
ctx.error(@3, oss.str());
|
||||
}
|
||||
TokenPtr opt(new TokenOption(static_cast<uint16_t>(n)));
|
||||
ctx.expression.push_back(opt);
|
||||
}
|
||||
| SUBSTRING "(" string_expr "," start_expr "," length_expr ")" {
|
||||
TokenPtr sub(new TokenSubstring());
|
||||
ctx.expression.push_back(sub);
|
||||
}
|
||||
;
|
||||
|
||||
start_expr:
|
||||
NUMBER {
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
;
|
||||
|
||||
length_expr:
|
||||
NUMBER {
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| ALL {
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
;
|
||||
length_expr : NUMBER
|
||||
{
|
||||
TokenPtr str(new TokenString($1));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
| ALL
|
||||
{
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
;
|
||||
|
||||
%%
|
||||
void
|
||||
|
@ -109,29 +109,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief checks if the given expression raises the expected message
|
||||
/// when it is parsed by the strongly typed parser but is accepted
|
||||
/// by the untyped one.
|
||||
void checkTyped(const string& expr, const string& msg) {
|
||||
EvalContext eval;
|
||||
parsed_ = false;
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("untyped:" + expr));
|
||||
EXPECT_TRUE(parsed_);
|
||||
parsed_ = false;
|
||||
try {
|
||||
parsed_ = eval.parseString(expr);
|
||||
FAIL() << "Expected EvalParseError but nothing was raised";
|
||||
}
|
||||
catch (const EvalParseError& ex) {
|
||||
EXPECT_EQ(msg, ex.what());
|
||||
EXPECT_FALSE(parsed_);
|
||||
}
|
||||
catch (...) {
|
||||
FAIL() << "Expected EvalParseError but something else was raised";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool parsed_; ///< Parsing status
|
||||
};
|
||||
|
||||
@ -148,14 +125,16 @@ TEST_F(EvalContextTest, basic) {
|
||||
TEST_F(EvalContextTest, string) {
|
||||
EvalContext eval;
|
||||
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("untyped: 'foo'"));
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("'foo' == 'bar'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
|
||||
ASSERT_EQ(1, eval.expression.size());
|
||||
ASSERT_EQ(3, eval.expression.size());
|
||||
|
||||
TokenPtr tmp = eval.expression.at(0);
|
||||
TokenPtr tmp1 = eval.expression.at(0);
|
||||
TokenPtr tmp2 = eval.expression.at(1);
|
||||
|
||||
checkTokenString(tmp, "foo");
|
||||
checkTokenString(tmp1, "foo");
|
||||
checkTokenString(tmp2, "bar");
|
||||
}
|
||||
|
||||
// Test the parsing of a basic expression with a constant string holding
|
||||
@ -167,21 +146,16 @@ TEST_F(EvalContextTest, number) {
|
||||
EXPECT_NO_THROW(parsed_ =
|
||||
eval.parseString("substring(option[123], '0', '2') == '42'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
parsed_ = false;
|
||||
EXPECT_NO_THROW(parsed_ =
|
||||
eval.parseString("untyped: substring(option[123], '0', '2') == '42'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
|
||||
}
|
||||
|
||||
// Test the parsing of a hexstring terminal
|
||||
TEST_F(EvalContextTest, hexstring) {
|
||||
EvalContext eval;
|
||||
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("untyped: 0x666f6f"));
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("0x666f6f == 'foo'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
|
||||
ASSERT_EQ(1, eval.expression.size());
|
||||
ASSERT_EQ(3, eval.expression.size());
|
||||
|
||||
TokenPtr tmp = eval.expression.at(0);
|
||||
|
||||
@ -193,10 +167,10 @@ TEST_F(EvalContextTest, hexstring) {
|
||||
TEST_F(EvalContextTest, oddHexstring) {
|
||||
EvalContext eval;
|
||||
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("untyped: 0X7"));
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("0X7 == 'foo'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
|
||||
ASSERT_EQ(1, eval.expression.size());
|
||||
ASSERT_EQ(3, eval.expression.size());
|
||||
|
||||
TokenPtr tmp = eval.expression.at(0);
|
||||
|
||||
@ -225,9 +199,9 @@ TEST_F(EvalContextTest, equal) {
|
||||
TEST_F(EvalContextTest, option) {
|
||||
EvalContext eval;
|
||||
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("untyped: option[123]"));
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("option[123] == 'foo'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
ASSERT_EQ(1, eval.expression.size());
|
||||
ASSERT_EQ(3, eval.expression.size());
|
||||
checkTokenOption(eval.expression.at(0), 123);
|
||||
}
|
||||
|
||||
@ -236,10 +210,10 @@ TEST_F(EvalContextTest, substring) {
|
||||
EvalContext eval;
|
||||
|
||||
EXPECT_NO_THROW(parsed_ =
|
||||
eval.parseString("untyped: substring('foobar','2','3')"));
|
||||
eval.parseString("substring('foobar','2','3') == 'oba'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
|
||||
ASSERT_EQ(4, eval.expression.size());
|
||||
ASSERT_EQ(6, eval.expression.size());
|
||||
|
||||
TokenPtr tmp1 = eval.expression.at(0);
|
||||
TokenPtr tmp2 = eval.expression.at(1);
|
||||
@ -260,8 +234,6 @@ TEST_F(EvalContextTest, scanErrors) {
|
||||
checkError("0x123h", "<string>:1.6: Invalid character: h");
|
||||
checkError("=", "<string>:1.1: Invalid character: =");
|
||||
checkError("subtring", "<string>:1.1: Invalid character: s");
|
||||
checkError("untype: 'abc'", "<string>:1.1: Invalid character: u");
|
||||
checkError("untyped 'abc'", "<string>:1.1: Invalid character: u");
|
||||
checkError("foo", "<string>:1.1: Invalid character: f");
|
||||
checkError(" bar", "<string>:1.2: Invalid character: b");
|
||||
}
|
||||
@ -269,8 +241,7 @@ TEST_F(EvalContextTest, scanErrors) {
|
||||
// Tests some scanner/parser error cases
|
||||
TEST_F(EvalContextTest, scanParseErrors) {
|
||||
checkError("", "<string>:1.1: syntax error, unexpected end of file");
|
||||
checkError("untyped:",
|
||||
"<string>:1.9: syntax error, unexpected end of file");
|
||||
checkError(" ", "<string>:1.2: syntax error, unexpected end of file");
|
||||
checkError("0x", "<string>:1.1: syntax error, unexpected integer");
|
||||
checkError("0abc",
|
||||
"<string>:1.1: syntax error, unexpected integer");
|
||||
@ -286,9 +257,6 @@ TEST_F(EvalContextTest, scanParseErrors) {
|
||||
|
||||
// Tests some parser error cases
|
||||
TEST_F(EvalContextTest, parseErrors) {
|
||||
checkError("untyped:'foo''bar'",
|
||||
"<string>:1.14-18: syntax error, unexpected "
|
||||
"constant string, expecting end of file");
|
||||
checkError("'foo''bar'",
|
||||
"<string>:1.6-10: syntax error, unexpected constant string, "
|
||||
"expecting ==");
|
||||
@ -321,17 +289,17 @@ TEST_F(EvalContextTest, parseErrors) {
|
||||
|
||||
// Tests some type error cases (caught only by the strongly typed parser)
|
||||
TEST_F(EvalContextTest, typeErrors) {
|
||||
checkTyped("'foobar'",
|
||||
checkError("'foobar'",
|
||||
"<string>:1.9: syntax error, unexpected end of file, "
|
||||
"expecting ==");
|
||||
checkTyped("substring('foobar','a','1') == 'foo'",
|
||||
checkError("substring('foobar','a','1') == 'foo'",
|
||||
"<string>:1.20-22: syntax error, unexpected constant string, "
|
||||
"expecting a number in a constant string");
|
||||
checkTyped("substring('foobar','1','a') == 'foo'",
|
||||
checkError("substring('foobar','1','a') == 'foo'",
|
||||
"<string>:1.24-26: syntax error, unexpected constant string, "
|
||||
"expecting a number in a constant string or the all constant "
|
||||
"string");
|
||||
checkTyped("substring('foobar',0x32,'1') == 'foo'",
|
||||
checkError("substring('foobar',0x32,'1') == 'foo'",
|
||||
"<string>:1.20-23: syntax error, unexpected constant "
|
||||
"hexstring, expecting a number in a constant string");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user