diff options
author | Francis Dupont <fdupont@isc.org> | 2016-11-21 21:42:18 +0100 |
---|---|---|
committer | Tomek Mrugalski <tomasz@isc.org> | 2016-11-29 19:57:33 +0100 |
commit | 8fa1747f1ecc94226c5873bd0263799fb6433601 (patch) | |
tree | 363d4a015686223db1c86343944cb11ef1810322 /src | |
parent | [5014] Added 2 unit tests about keywords (diff) | |
download | kea-8fa1747f1ecc94226c5873bd0263799fb6433601.tar.xz kea-8fa1747f1ecc94226c5873bd0263799fb6433601.zip |
[5014] Cleaned up (indent, factor, etc)
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/dhcp6/dhcp6.dox | 2 | ||||
-rw-r--r-- | src/bin/dhcp6/dhcp6_lexer.ll | 18 | ||||
-rw-r--r-- | src/bin/dhcp6/dhcp6_parser.yy | 81 |
3 files changed, 43 insertions, 58 deletions
diff --git a/src/bin/dhcp6/dhcp6.dox b/src/bin/dhcp6/dhcp6.dox index a7a5885e9d..58fd731181 100644 --- a/src/bin/dhcp6/dhcp6.dox +++ b/src/bin/dhcp6/dhcp6.dox @@ -305,7 +305,7 @@ SubnetConfigParser::getParam(const std::string& name) { isc_throw(DhcpConfigError, "Mandatory parameter " << name << " missing (no global default and no subnet-" << "specific value)"); - } + } } return (Triplet<uint32_t>(value)); diff --git a/src/bin/dhcp6/dhcp6_lexer.ll b/src/bin/dhcp6/dhcp6_lexer.ll index 5473a7e9ba..a26734868c 100644 --- a/src/bin/dhcp6/dhcp6_lexer.ll +++ b/src/bin/dhcp6/dhcp6_lexer.ll @@ -162,6 +162,7 @@ JSONString \"{JSONStringCharacter}*\" loc.step(); } + \"Dhcp6\" { switch(driver.ctx_) { case isc::dhcp::Parser6Context::CONFIG: @@ -740,12 +741,12 @@ JSONString \"{JSONStringCharacter}*\" return isc::dhcp::Dhcp6Parser::make_STRING(tmp, loc); } -"[" { return isc::dhcp::Dhcp6Parser::make_LSQUARE_BRACKET(loc); } -"]" { return isc::dhcp::Dhcp6Parser::make_RSQUARE_BRACKET(loc); } -"{" { return isc::dhcp::Dhcp6Parser::make_LCURLY_BRACKET(loc); } -"}" { return isc::dhcp::Dhcp6Parser::make_RCURLY_BRACKET(loc); } -"," { return isc::dhcp::Dhcp6Parser::make_COMMA(loc); } -":" { return isc::dhcp::Dhcp6Parser::make_COLON(loc); } +"[" { return isc::dhcp::Dhcp6Parser::make_LSQUARE_BRACKET(loc); } +"]" { return isc::dhcp::Dhcp6Parser::make_RSQUARE_BRACKET(loc); } +"{" { return isc::dhcp::Dhcp6Parser::make_LCURLY_BRACKET(loc); } +"}" { return isc::dhcp::Dhcp6Parser::make_RCURLY_BRACKET(loc); } +"," { return isc::dhcp::Dhcp6Parser::make_COMMA(loc); } +":" { return isc::dhcp::Dhcp6Parser::make_COLON(loc); } {int} { // An integer was found. @@ -764,6 +765,7 @@ JSONString \"{JSONStringCharacter}*\" // The parser needs the string form as double conversion is no lossless return isc::dhcp::Dhcp6Parser::make_INTEGER(integer, loc); } + [-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)? { // A floating point was found. std::string tmp(yytext); @@ -790,9 +792,9 @@ null { return isc::dhcp::Dhcp6Parser::make_NULL_TYPE(loc); } -. driver.error (loc, "Invalid character: " + std::string(yytext)); +. driver.error (loc, "Invalid character: " + std::string(yytext)); -<<EOF>> { +<<EOF>> { if (states.empty()) { return isc::dhcp::Dhcp6Parser::make_END(loc); } diff --git a/src/bin/dhcp6/dhcp6_parser.yy b/src/bin/dhcp6/dhcp6_parser.yy index 4128a6bfd2..5a8e714a4e 100644 --- a/src/bin/dhcp6/dhcp6_parser.yy +++ b/src/bin/dhcp6/dhcp6_parser.yy @@ -156,14 +156,14 @@ start: TOPLEVEL_GENERIC_JSON { ctx.ctx_ = ctx.NO_KEYWORD; } map2 // Note that ctx_ is NO_KEYWORD here // Values rule -value : INTEGER { $$ = ElementPtr(new IntElement($1)); } - | FLOAT { $$ = ElementPtr(new DoubleElement($1)); } - | BOOLEAN { $$ = ElementPtr(new BoolElement($1)); } - | STRING { $$ = ElementPtr(new StringElement($1)); } - | NULL_TYPE { $$ = ElementPtr(new NullElement()); } - | map2 { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); } - | list_generic { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); } - ; +value: INTEGER { $$ = ElementPtr(new IntElement($1)); } + | FLOAT { $$ = ElementPtr(new DoubleElement($1)); } + | BOOLEAN { $$ = ElementPtr(new BoolElement($1)); } + | STRING { $$ = ElementPtr(new StringElement($1)); } + | NULL_TYPE { $$ = ElementPtr(new NullElement()); } + | map2 { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); } + | list_generic { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); } + ; map2: LCURLY_BRACKET { // This code is executed when we're about to start parsing @@ -392,8 +392,8 @@ host: HOST { name: NAME { ctx.enter(ctx.NO_KEYWORD); } COLON STRING { - ElementPtr n(new StringElement($4)); - ctx.stack_.back()->set("name", n); + ElementPtr name(new StringElement($4)); + ctx.stack_.back()->set("name", name); ctx.leave(); }; @@ -421,16 +421,20 @@ mac_sources_list: mac_sources_value | mac_sources_list COMMA mac_sources_value ; -mac_sources_value: DUID { - ElementPtr duid(new StringElement("duid")); - ctx.stack_.back()->add(duid); - } - | STRING { - ElementPtr duid(new StringElement($1)); - ctx.stack_.back()->add(duid); - } +mac_sources_value: duid_id + | string_id ; +duid_id : DUID { + ElementPtr duid(new StringElement("duid")); + ctx.stack_.back()->add(duid); +}; + +string_id : STRING { + ElementPtr duid(new StringElement($1)); + ctx.stack_.back()->add(duid); +}; + host_reservation_identifiers: HOST_RESERVATION_IDENTIFIERS { ElementPtr l(new ListElement()); ctx.stack_.back()->set("host-reservation-identifiers", l); @@ -445,16 +449,15 @@ host_reservation_identifiers_list: host_reservation_identifier | host_reservation_identifiers_list COMMA host_reservation_identifier ; -host_reservation_identifier: DUID { - ElementPtr duid(new StringElement("duid")); - ctx.stack_.back()->add(duid); - } - | HW_ADDRESS { - ElementPtr hwaddr(new StringElement("hw-address")); - ctx.stack_.back()->add(hwaddr); - } +host_reservation_identifier: duid_id + | hw_address_id ; +hw_address_id : HW_ADDRESS { + ElementPtr hwaddr(new StringElement("hw-address")); + ctx.stack_.back()->add(hwaddr); +}; + relay_supplied_options: RELAY_SUPPLIED_OPTIONS { ElementPtr l(new ListElement()); ctx.stack_.back()->set("relay-supplied-options", l); @@ -662,13 +665,7 @@ option_data_param: %empty ; -option_data_name: NAME { - ctx.enter(ctx.NO_KEYWORD); -} COLON STRING { - ElementPtr name(new StringElement($4)); - ctx.stack_.back()->set("name", name); - ctx.leave(); -}; +option_data_name: name; option_data_data: DATA { ctx.enter(ctx.NO_KEYWORD); @@ -926,13 +923,7 @@ client_class_param: %empty | option_data_list ; -client_class_name: NAME { - ctx.enter(ctx.NO_KEYWORD); -} COLON STRING { - ElementPtr name(new StringElement($4)); - ctx.stack_.back()->set("name", name); - ctx.leave(); -}; +client_class_name: name; client_class_test: TEST { ctx.enter(ctx.NO_KEYWORD); @@ -1054,20 +1045,12 @@ logger_params: logger_param | logger_params COMMA logger_param ; -logger_param: logger_name +logger_param: name | output_options_list | debuglevel | severity ; -logger_name: NAME { - ctx.enter(ctx.NO_KEYWORD); -} COLON STRING { - ElementPtr name(new StringElement($4)); - ctx.stack_.back()->set("name", name); - ctx.leave(); -}; - debuglevel: DEBUGLEVEL COLON INTEGER { ElementPtr dl(new IntElement($3)); ctx.stack_.back()->set("debuglevel", dl); |