Commit 0182dcff authored by Francis Dupont's avatar Francis Dupont
Browse files

[4204fd] Fixed newline handling

parent 5759a4db
......@@ -543,12 +543,12 @@ static yyconst flex_int32_t yy_meta[34] =
static yyconst flex_int16_t yy_base[60] =
{ 0,
0, 0, 114, 115, 111, 109, 107, 115, 115, 115,
24, 115, 26, 28, 98, 38, 115, 115, 58, 22,
17, 19, 27, 107, 105, 103, 115, 39, 0, 115,
51, 52, 81, 115, 79, 32, 33, 42, 38, 0,
76, 72, 48, 49, 53, 55, 56, 71, 60, 63,
66, 65, 68, 73, 45, 115, 98, 101, 57
0, 0, 119, 120, 116, 114, 112, 120, 120, 120,
24, 120, 26, 28, 103, 58, 120, 120, 75, 19,
17, 18, 26, 112, 110, 108, 120, 38, 0, 120,
50, 54, 86, 120, 85, 21, 33, 43, 37, 0,
80, 76, 48, 44, 55, 57, 56, 66, 63, 65,
60, 71, 72, 77, 40, 120, 102, 105, 51
} ;
static yyconst flex_int16_t yy_def[60] =
......@@ -561,50 +561,52 @@ static yyconst flex_int16_t yy_def[60] =
19, 19, 19, 19, 19, 0, 56, 56, 56
} ;
static yyconst flex_int16_t yy_nxt[149] =
static yyconst flex_int16_t yy_nxt[154] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 16, 16, 17, 18, 4, 19, 16,
16, 16, 20, 16, 16, 16, 21, 16, 16, 22,
23, 16, 16, 28, 28, 28, 28, 28, 28, 31,
29, 33, 36, 33, 37, 32, 33, 39, 28, 28,
38, 33, 31, 56, 34, 32, 33, 33, 29, 31,
40, 44, 33, 43, 42, 32, 33, 34, 56, 33,
45, 46, 33, 33, 34, 32, 33, 33, 47, 33,
33, 49, 35, 48, 33, 51, 50, 33, 53, 33,
33, 52, 33, 54, 55, 33, 33, 33, 26, 26,
33, 26, 33, 41, 33, 33, 27, 25, 24, 30,
27, 25, 24, 56, 3, 56, 56, 56, 56, 56,
23, 16, 16, 28, 28, 28, 28, 28, 28, 36,
29, 33, 33, 33, 37, 33, 39, 28, 28, 38,
33, 31, 31, 42, 40, 56, 56, 33, 29, 31,
31, 33, 44, 43, 33, 32, 34, 33, 33, 45,
56, 46, 33, 47, 34, 32, 31, 31, 33, 33,
33, 33, 32, 49, 33, 48, 50, 33, 51, 33,
33, 34, 32, 52, 53, 33, 33, 54, 55, 35,
33, 33, 26, 26, 33, 26, 33, 33, 33, 41,
33, 27, 25, 24, 30, 27, 25, 24, 56, 3,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56
} ;
static yyconst flex_int16_t yy_chk[149] =
static yyconst flex_int16_t yy_chk[154] =
{ 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, 11, 11, 13, 13, 14, 14, 16,
13, 21, 20, 22, 21, 16, 20, 23, 28, 28,
22, 23, 31, 32, 16, 16, 36, 37, 13, 19,
59, 38, 39, 37, 36, 19, 38, 31, 32, 55,
39, 43, 43, 44, 19, 19, 32, 45, 44, 46,
47, 46, 19, 45, 49, 49, 47, 50, 52, 52,
51, 50, 53, 53, 54, 48, 42, 54, 57, 57,
41, 57, 58, 35, 58, 33, 26, 25, 24, 15,
7, 6, 5, 3, 56, 56, 56, 56, 56, 56,
1, 1, 1, 11, 11, 13, 13, 14, 14, 20,
13, 21, 22, 20, 21, 36, 23, 28, 28, 22,
23, 31, 31, 36, 59, 32, 32, 37, 13, 16,
16, 39, 38, 37, 55, 16, 31, 38, 44, 39,
32, 43, 43, 44, 16, 16, 19, 19, 32, 45,
47, 46, 19, 46, 51, 45, 47, 49, 49, 50,
48, 19, 19, 50, 52, 52, 53, 53, 54, 19,
42, 54, 57, 57, 41, 57, 58, 58, 58, 35,
33, 26, 25, 24, 15, 7, 6, 5, 3, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56
56, 56, 56
} ;
/* Table of booleans, true if rule could match eol. */
static yyconst flex_int32_t yy_rule_can_match_eol[21] =
{ 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, };
extern int yy_flex_debug;
......@@ -695,7 +697,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 699 "lexer.cc"
#line 701 "lexer.cc"
#define INITIAL 0
......@@ -984,7 +986,7 @@ YY_DECL
loc.step();
#line 988 "lexer.cc"
#line 990 "lexer.cc"
while ( 1 ) /* loops until end-of-file is reached */
{
......@@ -1155,6 +1157,7 @@ YY_RULE_SETUP
}
YY_BREAK
case 6:
/* rule 6 can match eol */
YY_RULE_SETUP
#line 123 "lexer.ll"
{
......@@ -1238,7 +1241,7 @@ YY_RULE_SETUP
#line 145 "lexer.ll"
ECHO;
YY_BREAK
#line 1242 "lexer.cc"
#line 1245 "lexer.cc"
case YY_END_OF_BUFFER:
{
......
......@@ -120,7 +120,7 @@ blank [ \t]
return isc::eval::EvalParser::make_INTEGER(tmp, loc);
}
[A-Za-z]([-_A-Za-z0-9]*[A-Za-z0-9])?/{blank}*] {
[A-Za-z]([-_A-Za-z0-9]*[A-Za-z0-9])?/({blank}|\n)*] {
// This string specifies option name starting with a letter
// and further containing letters, digits, hyphens and
// underscores and finishing by letters or digits.
......
......@@ -227,6 +227,18 @@ TEST_F(EvalContextTest, optionWithNameAndWhitespace) {
checkTokenOption(eval.expression.at(0), 12);
}
// Test checking that newlines can surround option name.
TEST_F(EvalContextTest, optionWithNameAndNewline) {
EvalContext eval(Option::V4);
// Option 'host-name' is a standard DHCPv4 option defined in the libdhcp++.
EXPECT_NO_THROW(parsed_ =
eval.parseString("option[\n host-name \n ].text == \n'foo'"));
EXPECT_TRUE(parsed_);
ASSERT_EQ(3, eval.expression.size());
checkTokenOption(eval.expression.at(0), 12);
}
// Test parsing of an option represented as hexadecimal string.
TEST_F(EvalContextTest, optionHex) {
EvalContext eval(Option::V4);
......@@ -297,6 +309,8 @@ TEST_F(EvalContextTest, scanParseErrors) {
"<string>:1.9-10: syntax error, unexpected option name, "
"expecting ]");
checkError("option[ab_].hex", "<string>:1.8: Invalid character: a");
checkError("option[\nhost-name\n].hex =\n= 'foo'",
"<string>:3.7: Invalid character: =");
checkError("substring('foo',12345678901234567890,1)",
"<string>:1.17-36: Failed to convert 12345678901234567890 "
"to an integer.");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment