Commit c1293f6d authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[4093] Addressed review comments.

parent b070bb9c
......@@ -235,16 +235,10 @@ Option::toHexString(const bool include_header) {
const uint8_t* option_data = static_cast<const uint8_t*>(buf.getData());
std::vector<uint8_t> option_vec;
// Exclude header.
if (!include_header) {
if (buf.getLength() > getHeaderLen()) {
option_vec.assign(option_data + getHeaderLen(),
option_data + buf.getLength());
}
} else {
option_vec.assign(option_data, option_data + buf.getLength());
}
// Assign option data to a vector, with or without option header depending
// on the value of "include_header" flag.
option_vec.assign(option_data + (include_header ? 0 : getHeaderLen()),
option_data + buf.getLength());
// Return hexadecimal representation prepended with 0x or empty string
// if option has no payload and the header fields are excluded.
......
......@@ -80,12 +80,12 @@
14. TokenPtr hex(new TokenHexString($1));
15. ctx.expression.push_back(hex);
16. }
17. | OPTION '[' INTEGER ']' DOTTEXT
17. | OPTION '[' INTEGER ']' DOT TEXT
18. {
19. TokenPtr opt(new TokenOption($3, TokenOption::TEXTUAL));
20. ctx.expression.push_back(opt);
21. }
22. | OPTION '[' INTEGER ']' DOTHEX
22. | OPTION '[' INTEGER ']' DOT HEX
23. {
24. TokenPtr opt(new TokenOption($3, TokenOption::HEXADECIMAL));
25. ctx.expression.push_back(opt);
......
......@@ -460,8 +460,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 19
#define YY_END_OF_BUFFER 20
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
......@@ -471,10 +471,10 @@ struct yy_trans_info
};
static yyconst flex_int16_t yy_accept[52] =
{ 0,
0, 0, 19, 17, 1, 2, 17, 12, 13, 16,
17, 17, 5, 5, 17, 14, 15, 17, 17, 17,
1, 2, 0, 3, 5, 0, 0, 0, 6, 0,
0, 0, 0, 0, 4, 11, 0, 0, 9, 0,
0, 0, 20, 18, 1, 2, 18, 13, 14, 17,
18, 12, 5, 5, 18, 15, 16, 18, 18, 18,
18, 18, 1, 2, 0, 3, 5, 0, 6, 0,
0, 0, 0, 0, 4, 11, 9, 0, 0, 0,
0, 0, 8, 0, 0, 7, 0, 0, 0, 10,
0
} ;
......@@ -521,60 +521,61 @@ static yyconst flex_int32_t yy_meta[32] =
static yyconst flex_int16_t yy_base[54] =
{ 0,
0, 0, 74, 75, 71, 69, 67, 75, 75, 75,
22, 13, 25, 27, 58, 75, 75, 46, 42, 37,
64, 62, 60, 75, 30, 44, 43, 0, 75, 38,
31, 40, 24, 23, 0, 75, 31, 24, 75, 22,
25, 20, 75, 24, 20, 75, 24, 21, 24, 75,
75, 56, 40
0, 0, 72, 73, 69, 67, 65, 73, 73, 73,
22, 73, 24, 26, 56, 73, 73, 44, 47, 39,
34, 44, 60, 58, 56, 73, 29, 0, 73, 36,
26, 25, 35, 21, 0, 73, 73, 29, 22, 20,
23, 18, 73, 22, 18, 73, 22, 19, 22, 73,
73, 55, 38
} ;
static yyconst flex_int16_t yy_def[54] =
{ 0,
51, 1, 51, 51, 51, 51, 52, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 52, 51, 51, 51, 51, 53, 51, 51,
51, 51, 51, 51, 52, 51, 51, 53, 51, 51,
51, 51, 51, 51, 53, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
0, 51, 51
} ;
static yyconst flex_int16_t yy_nxt[107] =
static yyconst flex_int16_t yy_nxt[105] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 4, 4, 16, 17, 18, 4, 4, 4,
4, 4, 4, 4, 19, 4, 4, 20, 4, 4,
4, 25, 25, 26, 25, 25, 25, 25, 28, 25,
25, 27, 35, 50, 49, 48, 47, 46, 45, 44,
43, 42, 41, 40, 39, 28, 23, 38, 23, 37,
36, 34, 33, 24, 22, 21, 32, 31, 30, 29,
24, 22, 21, 51, 3, 51, 51, 51, 51, 51,
19, 4, 4, 4, 20, 4, 4, 21, 22, 4,
4, 27, 27, 27, 27, 27, 27, 28, 27, 27,
35, 50, 49, 48, 47, 46, 45, 44, 43, 42,
41, 40, 39, 38, 28, 25, 37, 25, 36, 26,
24, 23, 34, 33, 32, 31, 30, 29, 26, 24,
23, 51, 3, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51
51, 51, 51, 51
} ;
static yyconst flex_int16_t yy_chk[107] =
static yyconst flex_int16_t yy_chk[105] =
{ 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, 11, 11, 12, 13, 13, 14, 14, 13, 25,
25, 12, 53, 49, 48, 47, 45, 44, 42, 41,
40, 38, 37, 34, 33, 13, 52, 32, 52, 31,
30, 27, 26, 23, 22, 21, 20, 19, 18, 15,
7, 6, 5, 3, 51, 51, 51, 51, 51, 51,
1, 11, 11, 13, 13, 14, 14, 13, 27, 27,
53, 49, 48, 47, 45, 44, 42, 41, 40, 39,
38, 34, 33, 32, 13, 52, 31, 52, 30, 25,
24, 23, 22, 21, 20, 19, 18, 15, 7, 6,
5, 3, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51
51, 51, 51, 51
} ;
/* 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[20] =
{ 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, 0, 0,
};
static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;
......@@ -582,10 +583,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[19] =
{ 0,
83, 87, 93, 103, 109, 123, 124, 125, 126, 127,
128, 129, 130, 131, 132, 133, 135
128, 129, 130, 131, 132, 133, 134, 136
} ;
/* The intent behind this definition is that it'll catch
......@@ -652,7 +653,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 656 "lexer.cc"
#line 657 "lexer.cc"
#define INITIAL 0
......@@ -900,7 +901,7 @@ YY_DECL
loc.step();
#line 904 "lexer.cc"
#line 905 "lexer.cc"
if ( !(yy_init) )
{
......@@ -998,13 +999,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 < 19 )
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 == 19 )
fprintf( stderr, "--accepting default rule (\"%s\")\n",
yytext );
else if ( yy_act == 19 )
else if ( yy_act == 20 )
fprintf( stderr, "--(end of buffer or a NUL)\n" );
else
fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
......@@ -1090,12 +1091,12 @@ return isc::eval::EvalParser::make_OPTION(loc);
case 8:
YY_RULE_SETUP
#line 125 "lexer.ll"
return isc::eval::EvalParser::make_DOTTEXT(loc);
return isc::eval::EvalParser::make_TEXT(loc);
YY_BREAK
case 9:
YY_RULE_SETUP
#line 126 "lexer.ll"
return isc::eval::EvalParser::make_DOTHEX(loc);
return isc::eval::EvalParser::make_HEX(loc);
YY_BREAK
case 10:
YY_RULE_SETUP
......@@ -1110,43 +1111,48 @@ return isc::eval::EvalParser::make_ALL(loc);
case 12:
YY_RULE_SETUP
#line 129 "lexer.ll"
return isc::eval::EvalParser::make_LPAREN(loc);
return isc::eval::EvalParser::make_DOT(loc);
YY_BREAK
case 13:
YY_RULE_SETUP
#line 130 "lexer.ll"
return isc::eval::EvalParser::make_RPAREN(loc);
return isc::eval::EvalParser::make_LPAREN(loc);
YY_BREAK
case 14:
YY_RULE_SETUP
#line 131 "lexer.ll"
return isc::eval::EvalParser::make_LBRACKET(loc);
return isc::eval::EvalParser::make_RPAREN(loc);
YY_BREAK
case 15:
YY_RULE_SETUP
#line 132 "lexer.ll"
return isc::eval::EvalParser::make_RBRACKET(loc);
return isc::eval::EvalParser::make_LBRACKET(loc);
YY_BREAK
case 16:
YY_RULE_SETUP
#line 133 "lexer.ll"
return isc::eval::EvalParser::make_COMA(loc);
return isc::eval::EvalParser::make_RBRACKET(loc);
YY_BREAK
case 17:
YY_RULE_SETUP
#line 135 "lexer.ll"
#line 134 "lexer.ll"
return isc::eval::EvalParser::make_COMA(loc);
YY_BREAK
case 18:
YY_RULE_SETUP
#line 136 "lexer.ll"
driver.error (loc, "Invalid character: " + std::string(yytext));
YY_BREAK
case YY_STATE_EOF(INITIAL):
#line 136 "lexer.ll"
#line 137 "lexer.ll"
return isc::eval::EvalParser::make_END(loc);
YY_BREAK
case 18:
case 19:
YY_RULE_SETUP
#line 137 "lexer.ll"
#line 138 "lexer.ll"
ECHO;
YY_BREAK
#line 1150 "lexer.cc"
#line 1156 "lexer.cc"
case YY_END_OF_BUFFER:
{
......@@ -2243,7 +2249,7 @@ void yyfree (void * ptr )
/* %ok-for-header */
#line 137 "lexer.ll"
#line 138 "lexer.ll"
......
......@@ -122,10 +122,11 @@ blank [ \t]
"==" return isc::eval::EvalParser::make_EQUAL(loc);
"option" return isc::eval::EvalParser::make_OPTION(loc);
".text" return isc::eval::EvalParser::make_DOTTEXT(loc);
".hex" return isc::eval::EvalParser::make_DOTHEX(loc);
"text" return isc::eval::EvalParser::make_TEXT(loc);
"hex" return isc::eval::EvalParser::make_HEX(loc);
"substring" return isc::eval::EvalParser::make_SUBSTRING(loc);
"all" return isc::eval::EvalParser::make_ALL(loc);
"." return isc::eval::EvalParser::make_DOT(loc);
"(" return isc::eval::EvalParser::make_LPAREN(loc);
")" return isc::eval::EvalParser::make_RPAREN(loc);
"[" return isc::eval::EvalParser::make_LBRACKET(loc);
......
......@@ -52,7 +52,7 @@
#line 39 "parser.yy" // lalr1.cc:413
# include "eval_context.h"
#line 66 "parser.yy" // lalr1.cc:413
#line 67 "parser.yy" // lalr1.cc:413
namespace {
......@@ -277,10 +277,10 @@ namespace isc { namespace eval {
{
switch (that.type_get ())
{
case 14: // "constant string"
case 15: // "integer"
case 16: // "constant hexstring"
case 17: // TOKEN
case 15: // "constant string"
case 16: // "integer"
case 17: // "constant hexstring"
case 18: // TOKEN
value.move< std::string > (that.value);
break;
......@@ -299,10 +299,10 @@ namespace isc { namespace eval {
state = that.state;
switch (that.type_get ())
{
case 14: // "constant string"
case 15: // "integer"
case 16: // "constant hexstring"
case 17: // TOKEN
case 15: // "constant string"
case 16: // "integer"
case 17: // "constant hexstring"
case 18: // TOKEN
value.copy< std::string > (that.value);
break;
......@@ -342,30 +342,30 @@ namespace isc { namespace eval {
<< yysym.location << ": ";
switch (yytype)
{
case 14: // "constant string"
case 15: // "constant string"
#line 63 "parser.yy" // lalr1.cc:636
#line 64 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< std::string > (); }
#line 350 "parser.cc" // lalr1.cc:636
break;
case 15: // "integer"
case 16: // "integer"
#line 63 "parser.yy" // lalr1.cc:636
#line 64 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< std::string > (); }
#line 357 "parser.cc" // lalr1.cc:636
break;
case 16: // "constant hexstring"
case 17: // "constant hexstring"
#line 63 "parser.yy" // lalr1.cc:636
#line 64 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< std::string > (); }
#line 364 "parser.cc" // lalr1.cc:636
break;
case 17: // TOKEN
case 18: // TOKEN
#line 63 "parser.yy" // lalr1.cc:636
#line 64 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< std::string > (); }
#line 371 "parser.cc" // lalr1.cc:636
break;
......@@ -567,10 +567,10 @@ namespace isc { namespace eval {
when using variants. */
switch (yyr1_[yyn])
{
case 14: // "constant string"
case 15: // "integer"
case 16: // "constant hexstring"
case 17: // TOKEN
case 15: // "constant string"
case 16: // "integer"
case 17: // "constant hexstring"
case 18: // TOKEN
yylhs.value.build< std::string > ();
break;
......@@ -592,7 +592,7 @@ namespace isc { namespace eval {
switch (yyn)
{
case 3:
#line 104 "parser.yy" // lalr1.cc:859
#line 105 "parser.yy" // lalr1.cc:859
{
TokenPtr eq(new TokenEqual());
ctx.expression.push_back(eq);
......@@ -601,7 +601,7 @@ namespace isc { namespace eval {
break;
case 4:
#line 111 "parser.yy" // lalr1.cc:859
#line 112 "parser.yy" // lalr1.cc:859
{
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(str);
......@@ -610,7 +610,7 @@ namespace isc { namespace eval {
break;
case 5:
#line 116 "parser.yy" // lalr1.cc:859
#line 117 "parser.yy" // lalr1.cc:859
{
TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(hex);
......@@ -619,9 +619,9 @@ namespace isc { namespace eval {
break;
case 6:
#line 121 "parser.yy" // lalr1.cc:859
#line 122 "parser.yy" // lalr1.cc:859
{
uint16_t numeric_code = convert_option_code(yystack_[2].value.as< std::string > (), yystack_[2].location, ctx);
uint16_t numeric_code = convert_option_code(yystack_[3].value.as< std::string > (), yystack_[3].location, ctx);
TokenPtr opt(new TokenOption(numeric_code, TokenOption::TEXTUAL));
ctx.expression.push_back(opt);
}
......@@ -629,9 +629,9 @@ namespace isc { namespace eval {
break;
case 7:
#line 127 "parser.yy" // lalr1.cc:859
#line 128 "parser.yy" // lalr1.cc:859
{
uint16_t numeric_code = convert_option_code(yystack_[2].value.as< std::string > (), yystack_[2].location, ctx);
uint16_t numeric_code = convert_option_code(yystack_[3].value.as< std::string > (), yystack_[3].location, ctx);
TokenPtr opt(new TokenOption(numeric_code, TokenOption::HEXADECIMAL));
ctx.expression.push_back(opt);
}
......@@ -639,7 +639,7 @@ namespace isc { namespace eval {
break;
case 8:
#line 133 "parser.yy" // lalr1.cc:859
#line 134 "parser.yy" // lalr1.cc:859
{
TokenPtr sub(new TokenSubstring());
ctx.expression.push_back(sub);
......@@ -648,7 +648,7 @@ namespace isc { namespace eval {
break;
case 10:
#line 142 "parser.yy" // lalr1.cc:859
#line 143 "parser.yy" // lalr1.cc:859
{
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(str);
......@@ -657,7 +657,7 @@ namespace isc { namespace eval {
break;
case 11:
#line 149 "parser.yy" // lalr1.cc:859
#line 150 "parser.yy" // lalr1.cc:859
{
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(str);
......@@ -666,7 +666,7 @@ namespace isc { namespace eval {
break;
case 12:
#line 154 "parser.yy" // lalr1.cc:859
#line 155 "parser.yy" // lalr1.cc:859
{
TokenPtr str(new TokenString("all"));
ctx.expression.push_back(str);
......@@ -930,73 +930,73 @@ namespace isc { namespace eval {
}
const signed char EvalParser::yypact_ninf_ = -9;
const signed char EvalParser::yypact_ninf_ = -10;
const signed char EvalParser::yytable_ninf_ = -1;
const signed char
EvalParser::yypact_[] =
{
-4, -8, -2, -9, -9, -9, 11, -9, 12, -1,
-4, -9, -4, 3, 8, -9, 0, 4, -9, -9,
-9, 9, -6, -9, -9, 10, -9
-4, -9, -3, -10, -10, -10, 9, -10, 12, 1,
-4, -10, -4, -2, 6, -10, 10, 2, 0, -10,
11, -10, -10, -6, -10, -10, 8, -10
};
const unsigned char
EvalParser::yydefact_[] =
{
0, 0, 0, 4, 5, 9, 0, 2, 0, 0,
0, 1, 0, 0, 0, 3, 0, 0, 6, 7,
10, 0, 0, 12, 11, 0, 8
0, 1, 0, 0, 0, 3, 0, 0, 0, 10,
0, 6, 7, 0, 12, 11, 0, 8
};
const signed char
EvalParser::yypgoto_[] =
{
-9, -9, -9, -7, -9, -9
-10, -10, -10, -7, -10, -10
};
const signed char
EvalParser::yydefgoto_[] =
{
-1, 6, 7, 8, 21, 25
-1, 6, 7, 8, 20, 26
};
const unsigned char
EvalParser::yytable_[] =
{
1, 2, 23, 14, 9, 15, 18, 19, 10, 24,
3, 11, 4, 5, 13, 12, 16, 17, 22, 20,
0, 26
1, 2, 24, 14, 9, 15, 21, 22, 10, 11,
25, 3, 16, 4, 5, 12, 17, 13, 19, 18,
27, 23
};
const signed char
const unsigned char
EvalParser::yycheck_[] =
{
4, 5, 8, 10, 12, 12, 6, 7, 10, 15,
14, 0, 16, 17, 15, 3, 13, 9, 9, 15,
-1, 11
4, 5, 8, 10, 13, 12, 6, 7, 11, 0,
16, 15, 14, 17, 18, 3, 10, 16, 16, 9,
12, 10
};
const unsigned char
EvalParser::yystos_[] =
{
0, 4, 5, 14, 16, 17, 19, 20, 21, 12,
10, 0, 3, 15, 21, 21, 13, 9, 6, 7,
15, 22, 9, 8, 15, 23, 11
0, 4, 5, 15, 17, 18, 20, 21, 22, 13,
11, 0, 3, 16, 22, 22, 14, 10, 9, 16,
23, 6, 7, 10, 8, 16, 24, 12
};
const unsigned char
EvalParser::yyr1_[] =
{
0, 18, 19, 20, 21, 21, 21, 21, 21, 21,
22, 23, 23
0, 19, 20, 21, 22, 22, 22, 22, 22, 22,
23, 24, 24
};
const unsigned char
EvalParser::yyr2_[] =
{
0, 2, 1, 3, 1, 1, 5, 5, 8, 1,
0, 2, 1, 3, 1, 1, 6, 6, 8, 1,
1, 1, 1
};
......@@ -1008,8 +1008,8 @@ namespace isc { namespace eval {
const EvalParser::yytname_[] =
{
"\"end of file\"", "error", "$undefined", "\"==\"", "\"option\"",
"\"substring\"", "\".text\"", "\".hex\"", "\"all\"", "\",\"", "\"(\"",
"\")\"", "\"[\"", "\"]\"", "\"constant string\"", "\"integer\"",
"\"substring\"", "\"text\"", "\"hex\"", "\"all\"", "\".\"", "\",\"",
"\"(\"", "\")\"", "\"[\"", "\"]\"", "\"constant string\"", "\"integer\"",
"\"constant hexstring\"", "TOKEN", "$accept", "expression", "bool_expr",
"string_expr", "start_expr", "length_expr", YY_NULLPTR
};
......@@ -1018,8 +1018,8 @@ namespace isc { namespace eval {
const unsigned char
EvalParser::yyrline_[] =
{
0, 100, 100, 103, 110, 115, 120, 126, 132, 137,
141, 148, 153
0, 101, 101, 104, 111, 116, 121, 127, 133, 138,
142, 149, 154
};
// Print the state stack on the debug stream.
......@@ -1055,7 +1055,7 @@ namespace isc { namespace eval {
#line 21 "parser.yy" // lalr1.cc:1167
} } // isc::eval
#line 1058 "parser.cc" // lalr1.cc:1167
#line 160 "parser.yy" // lalr1.cc:1168
#line 161 "parser.yy" // lalr1.cc:1168
void