Commit 751b714c authored by Francis Dupont's avatar Francis Dupont
Browse files

[4088fd] Changed the syntax to unquote integers

parent f2021d66
......@@ -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 17
#define YY_END_OF_BUFFER 18
#define YY_NUM_RULES 16
#define YY_END_OF_BUFFER 17
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
......@@ -478,13 +478,13 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[48] =
static yyconst flex_int16_t yy_accept[44] =
{ 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
0, 0, 17, 15, 1, 2, 15, 10, 11, 14,
15, 5, 5, 15, 12, 13, 15, 15, 15, 1,
2, 0, 3, 5, 0, 6, 0, 0, 0, 4,
9, 0, 0, 0, 0, 0, 0, 7, 0, 0,
0, 8, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
......@@ -526,60 +526,54 @@ static yyconst flex_int32_t yy_meta[28] =
1, 1, 1, 1, 1, 1, 1
} ;
static yyconst flex_int16_t yy_base[50] =
static yyconst flex_int16_t yy_base[46] =
{ 0,
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
0, 0, 62, 63, 59, 57, 55, 63, 63, 63,
19, 21, 23, 47, 63, 63, 37, 33, 28, 52,
50, 48, 63, 26, 0, 63, 31, 24, 32, 0,
63, 29, 22, 24, 19, 23, 19, 63, 23, 20,
22, 63, 63, 36, 35
} ;
static yyconst flex_int16_t yy_def[50] =
static yyconst flex_int16_t yy_def[46] =
{ 0,
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
43, 1, 43, 43, 43, 43, 44, 43, 43, 43,
43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
43, 44, 43, 43, 45, 43, 43, 43, 43, 45,
43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 0, 43, 43
} ;
static yyconst flex_int16_t yy_nxt[104] =
static yyconst flex_int16_t yy_nxt[91] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
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,
47, 47, 47
14, 4, 4, 15, 16, 17, 4, 4, 4, 4,
4, 18, 4, 4, 19, 4, 4, 24, 24, 24,
24, 24, 24, 25, 24, 24, 22, 30, 22, 42,
41, 40, 39, 38, 37, 36, 35, 34, 33, 32,
31, 23, 21, 20, 29, 28, 27, 26, 23, 21,
20, 43, 3, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 43, 43, 43, 43, 43, 43
} ;
static yyconst flex_int16_t yy_chk[104] =
static yyconst flex_int16_t yy_chk[91] =
{ 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, 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,
47, 47, 47
1, 1, 1, 1, 1, 1, 1, 11, 11, 12,
12, 13, 13, 12, 24, 24, 44, 45, 44, 41,
40, 39, 37, 36, 35, 34, 33, 32, 29, 28,
27, 22, 21, 20, 19, 18, 17, 14, 7, 6,
5, 3, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 43, 43, 43, 43, 43, 43
} ;
/* Table of booleans, true if rule could match eol. */
static yyconst flex_int32_t yy_rule_can_match_eol[18] =
static yyconst flex_int32_t yy_rule_can_match_eol[17] =
{ 0,
0, 1, 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, };
static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;
......@@ -587,10 +581,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[17] =
static yyconst flex_int16_t yy_rule_linenum[16] =
{ 0,
83, 87, 93, 108, 114, 124, 130, 144, 145, 146,
147, 148, 149, 150, 151, 153
83, 87, 93, 103, 109, 123, 124, 125, 126, 127,
128, 129, 130, 131, 133
} ;
/* The intent behind this definition is that it'll catch
......@@ -657,7 +651,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 661 "lexer.cc"
#line 655 "lexer.cc"
#define INITIAL 0
......@@ -940,7 +934,7 @@ YY_DECL
loc.step();
#line 944 "lexer.cc"
#line 938 "lexer.cc"
while ( 1 ) /* loops until end-of-file is reached */
{
......@@ -969,13 +963,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 >= 48 )
if ( yy_current_state >= 44 )
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 != 47 );
while ( yy_current_state != 43 );
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
......@@ -1004,13 +998,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 < 17 )
else if ( yy_act < 16 )
fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
(long)yy_rule_linenum[yy_act], yytext );
else if ( yy_act == 17 )
else if ( yy_act == 16 )
fprintf( stderr, "--accepting default rule (\"%s\")\n",
yytext );
else if ( yy_act == 18 )
else if ( yy_act == 17 )
fprintf( stderr, "--(end of buffer or a NUL)\n" );
else
fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
......@@ -1047,33 +1041,6 @@ YY_RULE_SETUP
case 3:
YY_RULE_SETUP
#line 93 "lexer.ll"
{
// A string containing a number. Quotes should be removed, see below.
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
try {
static_cast<void>(boost::lexical_cast<int>(tmp));
} catch (const boost::bad_lexical_cast &) {
// In fact it is not a valid number
return isc::eval::EvalParser::make_STRING(tmp, loc);
}
return isc::eval::EvalParser::make_NUMBER(tmp, loc);
}
YY_BREAK
case 4:
YY_RULE_SETUP
#line 108 "lexer.ll"
{
// A string containing the "all" keyword.
return isc::eval::EvalParser::make_ALL("all", loc);
}
YY_BREAK
case 5:
YY_RULE_SETUP
#line 114 "lexer.ll"
{
// A string has been matched. It contains the actual string and single quotes.
// We need to get those quotes out of the way and just use its content, e.g.
......@@ -1084,87 +1051,92 @@ YY_RULE_SETUP
return isc::eval::EvalParser::make_STRING(tmp, loc);
}
YY_BREAK
case 6:
case 4:
YY_RULE_SETUP
#line 124 "lexer.ll"
#line 103 "lexer.ll"
{
// A hex string has been matched. It contains the '0x' or '0X' header
// followed by at least one hexadecimal digit.
return isc::eval::EvalParser::make_HEXSTRING(yytext, loc);
}
YY_BREAK
case 7:
case 5:
YY_RULE_SETUP
#line 130 "lexer.ll"
#line 109 "lexer.ll"
{
// An integer was found.
std::string tmp(yytext);
int n;
try {
n = boost::lexical_cast<int>(tmp);
static_cast<void>(boost::lexical_cast<int>(tmp));
} catch (const boost::bad_lexical_cast &) {
driver.error(loc, "Failed to convert " + tmp + " to an integer.");
}
return isc::eval::EvalParser::make_INTEGER(n, loc);
// The parser needs the string form as double conversion is no lossless
return isc::eval::EvalParser::make_INTEGER(tmp, loc);
}
YY_BREAK
case 8:
case 6:
YY_RULE_SETUP
#line 144 "lexer.ll"
#line 123 "lexer.ll"
return isc::eval::EvalParser::make_EQUAL(loc);
YY_BREAK
case 9:
case 7:
YY_RULE_SETUP
#line 145 "lexer.ll"
#line 124 "lexer.ll"
return isc::eval::EvalParser::make_OPTION(loc);
YY_BREAK
case 10:
case 8:
YY_RULE_SETUP
#line 146 "lexer.ll"
#line 125 "lexer.ll"
return isc::eval::EvalParser::make_SUBSTRING(loc);
YY_BREAK
case 11:
case 9:
YY_RULE_SETUP
#line 126 "lexer.ll"
return isc::eval::EvalParser::make_ALL(loc);
YY_BREAK
case 10:
YY_RULE_SETUP
#line 147 "lexer.ll"
#line 127 "lexer.ll"
return isc::eval::EvalParser::make_LPAREN(loc);
YY_BREAK
case 12:
case 11:
YY_RULE_SETUP
#line 148 "lexer.ll"
#line 128 "lexer.ll"
return isc::eval::EvalParser::make_RPAREN(loc);
YY_BREAK
case 13:
case 12:
YY_RULE_SETUP
#line 149 "lexer.ll"
#line 129 "lexer.ll"
return isc::eval::EvalParser::make_LBRACKET(loc);
YY_BREAK
case 14:
case 13:
YY_RULE_SETUP
#line 150 "lexer.ll"
#line 130 "lexer.ll"
return isc::eval::EvalParser::make_RBRACKET(loc);
YY_BREAK
case 15:
case 14:
YY_RULE_SETUP
#line 151 "lexer.ll"
#line 131 "lexer.ll"
return isc::eval::EvalParser::make_COMA(loc);
YY_BREAK
case 16:
case 15:
YY_RULE_SETUP
#line 153 "lexer.ll"
#line 133 "lexer.ll"
driver.error (loc, "Invalid character: " + std::string(yytext));
YY_BREAK
case YY_STATE_EOF(INITIAL):
#line 154 "lexer.ll"
#line 134 "lexer.ll"
return isc::eval::EvalParser::make_END(loc);
YY_BREAK
case 17:
case 16:
YY_RULE_SETUP
#line 155 "lexer.ll"
#line 135 "lexer.ll"
ECHO;
YY_BREAK
#line 1168 "lexer.cc"
#line 1140 "lexer.cc"
case YY_END_OF_BUFFER:
{
......@@ -1477,7 +1449,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 >= 48 )
if ( yy_current_state >= 44 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
......@@ -1510,11 +1482,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 >= 48 )
if ( yy_current_state >= 44 )
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 == 47);
yy_is_jam = (yy_current_state == 43);
return yy_is_jam ? 0 : yy_current_state;
}
......@@ -2252,7 +2224,7 @@ void yyfree (void * ptr )
/* %ok-for-header */
#line 155 "lexer.ll"
#line 135 "lexer.ll"
......
......@@ -90,27 +90,6 @@ blank [ \t]
loc.step();
}
\'{int}\' {
// A string containing a number. Quotes should be removed, see below.
std::string tmp(yytext+1);
tmp.resize(tmp.size() - 1);
try {
static_cast<void>(boost::lexical_cast<int>(tmp));
} catch (const boost::bad_lexical_cast &) {
// In fact it is not a valid number
return isc::eval::EvalParser::make_STRING(tmp, loc);
}
return isc::eval::EvalParser::make_NUMBER(tmp, loc);
}
"'all'" {
// A string containing the "all" keyword.
return isc::eval::EvalParser::make_ALL("all", loc);
}
\'[^\'\n]*\' {
// A string has been matched. It contains the actual string and single quotes.
// We need to get those quotes out of the way and just use its content, e.g.
......@@ -131,19 +110,20 @@ blank [ \t]
// An integer was found.
std::string tmp(yytext);
int n;
try {
n = boost::lexical_cast<int>(tmp);
static_cast<void>(boost::lexical_cast<int>(tmp));
} catch (const boost::bad_lexical_cast &) {
driver.error(loc, "Failed to convert " + tmp + " to an integer.");
}
return isc::eval::EvalParser::make_INTEGER(n, loc);
// The parser needs the string form as double conversion is no lossless
return isc::eval::EvalParser::make_INTEGER(tmp, loc);
}
"==" return isc::eval::EvalParser::make_EQUAL(loc);
"option" return isc::eval::EvalParser::make_OPTION(loc);
"substring" return isc::eval::EvalParser::make_SUBSTRING(loc);
"all" return isc::eval::EvalParser::make_ALL(loc);
"(" return isc::eval::EvalParser::make_LPAREN(loc);
")" return isc::eval::EvalParser::make_RPAREN(loc);
"[" return isc::eval::EvalParser::make_LBRACKET(loc);
......
......@@ -49,7 +49,7 @@
#line 51 "parser.cc" // lalr1.cc:412
// Unqualified %code blocks.
#line 38 "parser.yy" // lalr1.cc:413
#line 39 "parser.yy" // lalr1.cc:413
# include "eval_context.h"
......@@ -251,14 +251,10 @@ namespace isc { namespace eval {
{
switch (that.type_get ())
{
case 15: // "integer"
value.move< int > (that.value);
break;
case 11: // "a number in a constant string"
case 12: // "the all constant string"
case 13: // "constant string"
case 12: // "constant string"
case 13: // "integer"
case 14: // "constant hexstring"
case 15: // TOKEN
value.move< std::string > (that.value);
break;
......@@ -277,14 +273,10 @@ namespace isc { namespace eval {
state = that.state;
switch (that.type_get ())
{
case 15: // "integer"
value.copy< int > (that.value);
break;
case 11: // "a number in a constant string"
case 12: // "the all constant string"
case 13: // "constant string"
case 12: // "constant string"
case 13: // "integer"
case 14: // "constant hexstring"
case 15: // TOKEN
value.copy< std::string > (that.value);
break;
......@@ -324,39 +316,32 @@ namespace isc { namespace eval {
<< yysym.location << ": ";
switch (yytype)
{
case 11: // "a number in a constant string"
case 12: // "constant string"
#line 58 "parser.yy" // lalr1.cc:636
#line 61 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< std::string > (); }
#line 332 "parser.cc" // lalr1.cc:636
#line 324 "parser.cc" // lalr1.cc:636
break;
case 12: // "the all constant string"
case 13: // "integer"
#line 58 "parser.yy" // lalr1.cc:636
#line 61 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< std::string > (); }
#line 339 "parser.cc" // lalr1.cc:636
break;
case 13: // "constant string"
#line 58 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< std::string > (); }
#line 346 "parser.cc" // lalr1.cc:636
#line 331 "parser.cc" // lalr1.cc:636
break;
case 14: // "constant hexstring"
#line 58 "parser.yy" // lalr1.cc:636
#line 61 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< std::string > (); }
#line 353 "parser.cc" // lalr1.cc:636
#line 338 "parser.cc" // lalr1.cc:636
break;
case 15: // "integer"
case 15: // TOKEN
#line 58 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< int > (); }
#line 360 "parser.cc" // lalr1.cc:636
#line 61 "parser.yy" // lalr1.cc:636
{ yyoutput << yysym.value.template as< std::string > (); }
#line 345 "parser.cc" // lalr1.cc:636
break;
......@@ -556,14 +541,10 @@ namespace isc { namespace eval {
when using variants. */
switch (yyr1_[yyn])
{
case 15: // "integer"
yylhs.value.build< int > ();
break;
case 11: // "a number in a constant string"
case 12: // "the all constant string"
case 13: // "constant string"
case 12: // "constant string"
case 13: // "integer"
case 14: // "constant hexstring"
case 15: // TOKEN
yylhs.value.build< std::string > ();
break;
......@@ -585,104 +566,92 @@ namespace isc { namespace eval {
switch (yyn)
{
case 3:
#line 70 "parser.yy" // lalr1.cc:859
#line 73 "parser.yy" // lalr1.cc:859
{
TokenPtr eq(new TokenEqual());
ctx.expression.push_back(eq);
}
#line 594 "parser.cc" // lalr1.cc:859
#line 575 "parser.cc" // lalr1.cc:859
break;
case 4:
#line 77 "parser.yy" // lalr1.cc:859
#line 80 "parser.yy" // lalr1.cc:859
{
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(str);
}
#line 603 "parser.cc" // lalr1.cc:859
#line 584 "parser.cc" // lalr1.cc:859
break;
case 5:
#line 82 "parser.yy" // lalr1.cc:859
{
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(str);
}
#line 612 "parser.cc" // lalr1.cc:859
break;
case 6:
#line 87 "parser.yy" // lalr1.cc:859
{
TokenPtr str(new TokenString("all"));
ctx.expression.push_back(str);
}
#line 621 "parser.cc" // lalr1.cc:859
break;
case 7:
#line 92 "parser.yy" // lalr1.cc:859
#line 85 "parser.yy" // lalr1.cc:859
{
TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(hex);
}
#line 630 "parser.cc" // lalr1.cc:859
#line 593 "parser.cc" // lalr1.cc:859
break;
case 8:
#line 97 "parser.yy" // lalr1.cc:859
case 6:
#line 90 "parser.yy" // lalr1.cc:859
{
int n = yystack_[1].value.as< int > ();
int n;
try {
n = boost::lexical_cast<int>(yystack_[1].value.as< std::string > ());
} catch (const boost::bad_lexical_cast &) {
// This can't happen...
ctx.error(yystack_[1].location,