Commit 55c462ce authored by Francis Dupont's avatar Francis Dupont
Browse files

[5351] Fixed syntax

parent 4d8719d3
......@@ -2340,13 +2340,15 @@ namespace isc { namespace dhcp {
#line 1381 "dhcp4_parser.yy" // lalr1.cc:859
{
ElementPtr parent = ctx.stack_.back();
ElementPtr s(new StringElement(yystack_[0].value.as< std::string > ()));
ConstElementPtr old = parent->get("user-context");
if (old) {
old->set("comment", yystack_[0].value.as< std::string > ());
ElementPtr mutable_old = boost::const_pointer_cast<Element>(old);
mutable_old->set("comment", s);
} else {
ElementPtr e(new MapElement(ctx.loc2pos(yystack_[3].location)));
e->set("comment", yystack_[0].value.as< std::string > ());
top->set("user-context", e);
e->set("comment", s);
parent->set("user-context", e);
}
ctx.leave();
}
......
......@@ -1363,13 +1363,17 @@ user_context: USER_CONTEXT {
ElementPtr parent = ctx.stack_.back();
ElementPtr user_context = $4;
ConstElementPtr old = parent->get("user-context");
// Handle already existing user context
if (old) {
// Check if it was a comment or a duplicate
if ((old->size() != 1) || !old->contains("comment")) {
std::stringstream msg;
msg << "duplicate user-context entries (previous at "
<< old->getPosition().str() << ")";
error(@1, msg.str());
}
// Merge the comment
user_context->set("comment", old->get("comment"));
}
parent->set("user-context", user_context);
......@@ -1380,13 +1384,22 @@ comment: COMMENT {
ctx.enter(ctx.NO_KEYWORD);
} COLON STRING {
ElementPtr parent = ctx.stack_.back();
ElementPtr e(new MapElement(ctx.loc2pos(@1)));
ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
e->set("comment", s);
// Handle already existing user context
ConstElementPtr old = parent->get("user-context");
if (old) {
old->set("comment", $4);
} else {
ElementPtr e(new MapElement(ctx.loc2pos(@1)));
e->set("comment", $4);
top->set("user-context", e);
// Check for duplicate comment
if (old->contains("comment") {
std::stringstream msg;
msg << "duplicate user-context/comment entries (previous at "
<< old->getPosition().str() << ")";
error(@1, msg.str());
}
// Merge the user context in the comment
merge(e, old);
}
ctx.leave();
};
......
......@@ -2241,13 +2241,15 @@ namespace isc { namespace dhcp {
#line 1344 "dhcp6_parser.yy" // lalr1.cc:859
{
ElementPtr parent = ctx.stack_.back();
ElementPtr s(new StringElement(yystack_[0].value.as< std::string > ()));
ConstElementPtr old = parent->get("user-context");
if (old) {
old->set("comment", yystack_[0].value.as< std::string > ());
ElementPtr mutable_old = boost::const_pointer_cast<Element>(old);
mutable_old->set("comment", s);
} else {
ElementPtr e(new MapElement(ctx.loc2pos(yystack_[3].location)));
e->set("comment", yystack_[0].value.as< std::string > ());
top->set("user-context", e);
e->set("comment", s);
parent->set("user-context", e);
}
ctx.leave();
}
......
......@@ -1326,13 +1326,17 @@ user_context: USER_CONTEXT {
ElementPtr parent = ctx.stack_.back();
ElementPtr user_context = $4;
ConstElementPtr old = parent->get("user-context");
// Handle already existing user context
if (old) {
// Check if it was a comment or a duplicate
if ((old->size() != 1) || !old->contains("comment")) {
std::stringstream msg;
msg << "duplicate user-context entries (previous at "
<< old->getPosition().str() << ")";
error(@1, msg.str());
}
// Merge the comment
user_context->set("comment", old->get("comment"));
}
parent->set("user-context", user_context);
......@@ -1343,13 +1347,22 @@ comment: COMMENT {
ctx.enter(ctx.NO_KEYWORD);
} COLON STRING {
ElementPtr parent = ctx.stack_.back();
ElementPtr e(new MapElement(ctx.loc2pos(@1)));
ElementPtr s(new StringElement($4, ctx.loc2pos(@4)));
e->set("comment", s);
// Handle already existing user context
ConstElementPtr old = parent->get("user-context");
if (old) {
old->set("comment", $4);
} else {
ElementPtr e(new MapElement(ctx.loc2pos(@1)));
e->set("comment", $4);
top->set("user-context", e);
// Check for duplicate comment
if (old->contains("comment") {
std::stringstream msg;
msg << "duplicate user-context/comment entries (previous at "
<< old->getPosition().str() << ")";
error(@1, msg.str());
}
// Merge the user context in the comment
merge(e, old);
}
ctx.leave();
};
......
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