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