Commit 2fe778e8 authored by Francis Dupont's avatar Francis Dupont

[5096] Updated flex/bison parsers for databases

parent fbb1008e
......@@ -243,6 +243,33 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"memfile\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DATABASE_TYPE:
return isc::dhcp::Dhcp4Parser::make_MEMFILE(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("memfile", driver.loc_);
}
}
\"mysql\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DATABASE_TYPE:
return isc::dhcp::Dhcp4Parser::make_MYSQL(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("mysql", driver.loc_);
}
}
\"postgresql\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DATABASE_TYPE:
return isc::dhcp::Dhcp4Parser::make_POSTGRESQL(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("postgresql", driver.loc_);
}
}
\"user\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
......@@ -293,6 +320,16 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"connect-timeout\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
case isc::dhcp::Parser4Context::HOSTS_DATABASE:
return isc::dhcp::Dhcp4Parser::make_CONNECT_TIMEOUT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("connect-timeout", driver.loc_);
}
}
\"valid-lifetime\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP4:
......
......@@ -63,12 +63,16 @@ using namespace std;
LEASE_DATABASE "lease-database"
HOSTS_DATABASE "hosts-database"
TYPE "type"
MEMFILE "memfile"
MYSQL "mysql"
POSTGRESQL "postgresql"
USER "user"
PASSWORD "password"
HOST "host"
PERSIST "persist"
LFC_INTERVAL "lfc-interval"
READONLY "readonly"
CONNECT_TIMEOUT "connect-timeout"
VALID_LIFETIME "valid-lifetime"
RENEW_TIMER "renew-timer"
......@@ -179,6 +183,7 @@ using namespace std;
%token <bool> BOOLEAN "boolean"
%type <ElementPtr> value
%type <ElementPtr> db_type
%printer { yyoutput << $$; } <*>;
......@@ -476,17 +481,22 @@ database_map_param: database_type
| persist
| lfc_interval
| readonly
| connect_timeout
| unknown_map_entry
;
database_type: TYPE {
ctx.enter(ctx.NO_KEYWORD);
} COLON STRING {
ElementPtr prf(new StringElement($4, ctx.loc2pos(@4)));
ctx.stack_.back()->set("type", prf);
ctx.enter(ctx.DATABASE_TYPE);
} COLON db_type {
ctx.stack_.back()->set("type", $4);
ctx.leave();
};
db_type: MEMFILE { $$ = ElementPtr(new StringElement("memfile", ctx.loc2pos(@1))); }
| MYSQL { $$ = ElementPtr(new StringElement("mysql", ctx.loc2pos(@1))); }
| POSTGRESQL { $$ = ElementPtr(new StringElement("postgresql", ctx.loc2pos(@1))); }
;
user: USER {
ctx.enter(ctx.NO_KEYWORD);
} COLON STRING {
......@@ -534,9 +544,9 @@ readonly: READONLY COLON BOOLEAN {
ctx.stack_.back()->set("readonly", n);
};
duid_id : DUID {
ElementPtr duid(new StringElement("duid", ctx.loc2pos(@1)));
ctx.stack_.back()->add(duid);
connect_timeout: CONNECT_TIMEOUT COLON INTEGER {
ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("connect-timeout", n);
};
host_reservation_identifiers: HOST_RESERVATION_IDENTIFIERS {
......@@ -559,6 +569,11 @@ host_reservation_identifier: duid_id
| client_id
;
duid_id : DUID {
ElementPtr duid(new StringElement("duid", ctx.loc2pos(@1)));
ctx.stack_.back()->add(duid);
};
hw_address_id : HW_ADDRESS {
ElementPtr hwaddr(new StringElement("hw-address", ctx.loc2pos(@1)));
ctx.stack_.back()->add(hwaddr);
......
......@@ -131,6 +131,8 @@ Parser4Context::contextName()
return ("lease-database");
case HOSTS_DATABASE:
return ("hosts-database");
case DATABASE_TYPE:
return ("database-type");
case HOST_RESERVATION_IDENTIFIERS:
return ("host-reservation-identifiers");
case HOOKS_LIBRARIES:
......
......@@ -199,6 +199,9 @@ public:
/// Used while parsing Dhcp4/hosts-database structures.
HOSTS_DATABASE,
/// Used while parsing Dhcp4/*-database/type.
DATABASE_TYPE,
/// Used while parsing Dhcp4/host-reservation-identifiers.
HOST_RESERVATION_IDENTIFIERS,
......
......@@ -237,6 +237,33 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"memfile\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DATABASE_TYPE:
return isc::dhcp::Dhcp6Parser::make_MEMFILE(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("memfile", driver.loc_);
}
}
\"mysql\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DATABASE_TYPE:
return isc::dhcp::Dhcp6Parser::make_MYSQL(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("mysql", driver.loc_);
}
}
\"postgresql\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DATABASE_TYPE:
return isc::dhcp::Dhcp6Parser::make_POSTGRESQL(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("postgresql", driver.loc_);
}
}
\"user\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::LEASE_DATABASE:
......@@ -288,6 +315,16 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"connect-timeout\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::LEASE_DATABASE:
case isc::dhcp::Parser6Context::HOSTS_DATABASE:
return isc::dhcp::Dhcp6Parser::make_CONNECT_TIMEOUT(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("connect-timeout", driver.loc_);
}
}
\"preferred-lifetime\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DHCP6:
......
......@@ -56,12 +56,16 @@ using namespace std;
LEASE_DATABASE "lease-database"
HOSTS_DATABASE "hosts-database"
TYPE "type"
MEMFILE "memfile"
MYSQL "mysql"
POSTGRESQL "postgresql"
USER "user"
PASSWORD "password"
HOST "host"
PERSIST "persist"
LFC_INTERVAL "lfc-interval"
READONLY "readonly"
CONNECT_TIMEOUT "connect-timeout"
PREFERRED_LIFETIME "preferred-lifetime"
VALID_LIFETIME "valid-lifetime"
......@@ -188,6 +192,7 @@ using namespace std;
%token <bool> BOOLEAN "boolean"
%type <ElementPtr> value
%type <ElementPtr> db_type
%type <ElementPtr> duid_type
%printer { yyoutput << $$; } <*>;
......@@ -466,17 +471,22 @@ database_map_param: database_type
| persist
| lfc_interval
| readonly
| connect_timeout
| unknown_map_entry
;
database_type: TYPE {
ctx.enter(ctx.NO_KEYWORD);
} COLON STRING {
ElementPtr prf(new StringElement($4, ctx.loc2pos(@4)));
ctx.stack_.back()->set("type", prf);
ctx.enter(ctx.DATABASE_TYPE);
} COLON db_type {
ctx.stack_.back()->set("type", $4);
ctx.leave();
};
db_type: MEMFILE { $$ = ElementPtr(new StringElement("memfile", ctx.loc2pos(@1))); }
| MYSQL { $$ = ElementPtr(new StringElement("mysql", ctx.loc2pos(@1))); }
| POSTGRESQL { $$ = ElementPtr(new StringElement("postgresql", ctx.loc2pos(@1))); }
;
user: USER {
ctx.enter(ctx.NO_KEYWORD);
} COLON STRING {
......@@ -524,6 +534,11 @@ readonly: READONLY COLON BOOLEAN {
ctx.stack_.back()->set("readonly", n);
};
connect_timeout: CONNECT_TIMEOUT COLON INTEGER {
ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("connect-timeout", n);
};
mac_sources: MAC_SOURCES {
ElementPtr l(new ListElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("mac-sources", l);
......
......@@ -131,6 +131,8 @@ Parser6Context::contextName()
return ("lease-database");
case HOSTS_DATABASE:
return ("hosts-database");
case DATABASE_TYPE:
return ("database-type");
case MAC_SOURCES:
return ("mac-sources");
case HOST_RESERVATION_IDENTIFIERS:
......
......@@ -202,6 +202,9 @@ public:
/// Used while parsing Dhcp6/hosts-database structures.
HOSTS_DATABASE,
/// Used while parsing Dhcp6/*-database/type.
DATABASE_TYPE,
/// Used while parsing Dhcp6/mac-sources structures.
MAC_SOURCES,
......
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