Commit 39919c3b authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[5036] Code cleanup

parent 4204443a
...@@ -102,29 +102,28 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -102,29 +102,28 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
if (start_token_flag) { if (start_token_flag) {
start_token_flag = false; start_token_flag = false;
switch (start_token_value) { switch (start_token_value) {
case Parser6Context::PARSER_GENERIC_JSON: case Parser6Context::SUBPARSER_JSON:
default: default:
return isc::dhcp::Dhcp6Parser::make_TOPLEVEL_GENERIC_JSON(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_JSON(driver.loc_);
// return isc::dhcp::Dhcp6Parser::make_TOPLEVEL_GENERIC_JSON(driver.loc_);
case Parser6Context::PARSER_DHCP6: case Parser6Context::PARSER_DHCP6:
return isc::dhcp::Dhcp6Parser::make_TOPLEVEL_DHCP6(driver.loc_); return isc::dhcp::Dhcp6Parser::make_TOPLEVEL_DHCP6(driver.loc_);
case Parser6Context::SUBPARSER_DHCP6: case Parser6Context::SUBPARSER_DHCP6:
return isc::dhcp::Dhcp6Parser::make_SUB_DHCP6(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_DHCP6(driver.loc_);
case Parser6Context::SUBPARSER_INTERFACES6: case Parser6Context::PARSER_INTERFACES:
return isc::dhcp::Dhcp6Parser::make_SUB_INTERFACES6(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_INTERFACES6(driver.loc_);
case Parser6Context::SUBPARSER_SUBNET6: case Parser6Context::PARSER_SUBNET6:
return isc::dhcp::Dhcp6Parser::make_SUB_SUBNET6(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_SUBNET6(driver.loc_);
case Parser6Context::SUBPARSER_POOL6: case Parser6Context::PARSER_POOL6:
return isc::dhcp::Dhcp6Parser::make_SUB_POOL6(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_POOL6(driver.loc_);
case Parser6Context::SUBPARSER_PD_POOL: case Parser6Context::PARSER_PD_POOL:
return isc::dhcp::Dhcp6Parser::make_SUB_PD_POOL(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_PD_POOL(driver.loc_);
case Parser6Context::SUBPARSER_HOST_RESERVATION6: case Parser6Context::PARSER_HOST_RESERVATION:
return isc::dhcp::Dhcp6Parser::make_SUB_RESERVATION(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_RESERVATION(driver.loc_);
case Parser6Context::SUBPARSER_OPTION_DATA: case Parser6Context::PARSER_OPTION_DATA:
return isc::dhcp::Dhcp6Parser::make_SUB_OPTION_DATA(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_OPTION_DATA(driver.loc_);
case Parser6Context::SUBPARSER_HOOKS_LIBRARY: case Parser6Context::PARSER_HOOKS_LIBRARY:
return isc::dhcp::Dhcp6Parser::make_SUB_HOOKS_LIBRARY(driver.loc_); return isc::dhcp::Dhcp6Parser::make_SUB_HOOKS_LIBRARY(driver.loc_);
case Parser6Context::SUBPARSER_JSON:
return isc::dhcp::Dhcp6Parser::make_SUB_JSON(driver.loc_);
} }
} }
%} %}
......
...@@ -39,6 +39,7 @@ using namespace std; ...@@ -39,6 +39,7 @@ using namespace std;
%define api.token.prefix {TOKEN_} %define api.token.prefix {TOKEN_}
// Tokens in an order which makes sense and related to the intented use. // Tokens in an order which makes sense and related to the intented use.
// Actual regexps for tokens are defined in dhcp6_lexer.ll.
%token %token
END 0 "end of file" END 0 "end of file"
COMMA "," COMMA ","
......
...@@ -57,12 +57,8 @@ void configure(const std::string& file_name) { ...@@ -57,12 +57,8 @@ void configure(const std::string& file_name) {
} }
// Read contents of the file and parse it as JSON // Read contents of the file and parse it as JSON
#if 0
json = isc::data::Element::fromJSONFile(file_name, true);
#else
Parser6Context parser; Parser6Context parser;
json = parser.parseFile(file_name, Parser6Context::PARSER_DHCP6); json = parser.parseFile(file_name, Parser6Context::PARSER_DHCP6);
#endif
if (!json) { if (!json) {
isc_throw(isc::BadValue, "no configuration found"); isc_throw(isc::BadValue, "no configuration found");
} }
......
...@@ -23,6 +23,8 @@ namespace isc { ...@@ -23,6 +23,8 @@ namespace isc {
namespace dhcp { namespace dhcp {
/// @brief Evaluation error exception raised when trying to parse. /// @brief Evaluation error exception raised when trying to parse.
///
/// @todo: This probably should be common for Dhcp4 and Dhcp6.
class Dhcp6ParseError : public isc::Exception { class Dhcp6ParseError : public isc::Exception {
public: public:
Dhcp6ParseError(const char* file, size_t line, const char* what) : Dhcp6ParseError(const char* file, size_t line, const char* what) :
...@@ -35,26 +37,53 @@ class Parser6Context ...@@ -35,26 +37,53 @@ class Parser6Context
{ {
public: public:
/// @brief Defines currently support the content supported /// @brief Defines currently supported scopes
///
/// Dhcp6Parser is able to parse several types of scope. Usually, when it
/// parses a config file, it expects the data to have a map with Dhcp6 in it
/// and all the parameters within that Dhcp6 map. However, sometimes the
/// parser is expected to parse only a subset of that information. For example,
/// it may be asked to parse a structure that is host-reservation only, without
/// the global 'Dhcp6' or 'reservations' around it. In such case the parser
/// is being told to start parsing as SUBPARSER_HOST_RESERVATION6.
typedef enum { typedef enum {
PARSER_GENERIC_JSON, // This will parse the content as generic JSON /// This parser will parse the content as generic JSON.
PARSER_DHCP6, // This will parse the content as DHCP6 config //PARSER_GENERIC_JSON,
// DHCP6 config subparsers
SUBPARSER_JSON,
/// This parser will parse the content as Dhcp6 config wrapped in a map (that's
/// the regular config file)
PARSER_DHCP6,
/// This parser will parse the content of Dhcp6. It is mostly used
/// in unit-tests as most of the unit-tests do not define the outer
/// map and Dhcp6 entity, just the contents of it.
SUBPARSER_DHCP6, SUBPARSER_DHCP6,
SUBPARSER_INTERFACES6,
SUBPARSER_SUBNET6, /// This will parse the conde as Subnet6 content.
SUBPARSER_POOL6, PARSER_SUBNET6,
SUBPARSER_PD_POOL,
SUBPARSER_HOST_RESERVATION6, /// This parser will parse pool6 content.
// Common DHCP subparsers PARSER_POOL6,
SUBPARSER_OPTION_DEF,
SUBPARSER_OPTION_DATA, /// This parser will parse the interfaces content.
SUBPARSER_HOOKS_LIBRARY, PARSER_INTERFACES,
// SUBPARSER_CONTROL_SOCKET,
// SUBPARSER_D2_CLIENT, /// This parser will parse the content as pd-pool.
// SUBPARSER_LEASE_EXPIRATION, PARSER_PD_POOL,
// JSON value subparser
SUBPARSER_JSON /// This parser will parse the content as host-reservation
PARSER_HOST_RESERVATION,
/// This parser will parse the content as option definition.
PARSER_OPTION_DEF,
/// This parser will parse the content as option data.
PARSER_OPTION_DATA,
/// This parser will parse the content as hooks-library
PARSER_HOOKS_LIBRARY
} ParserType; } ParserType;
/// @brief Default constructor. /// @brief Default constructor.
...@@ -108,7 +137,7 @@ public: ...@@ -108,7 +137,7 @@ public:
/// Used by YY_FATAL_ERROR macro so required to be static. /// Used by YY_FATAL_ERROR macro so required to be static.
static void fatal(const std::string& what); static void fatal(const std::string& what);
/// @brief Convert position /// @brief Converts bison's position to one understandable by isc::data::Element
/// ///
/// Convert a bison location into an element position /// Convert a bison location into an element position
/// (take the begin, the end is lost) /// (take the begin, the end is lost)
...@@ -166,7 +195,7 @@ public: ...@@ -166,7 +195,7 @@ public:
std::vector<isc::dhcp::location> locs_; std::vector<isc::dhcp::location> locs_;
/// @brief Lexer state stack /// @brief Lexer state stack
std::vector<struct yy_buffer_state*> states_;; std::vector<struct yy_buffer_state*> states_;
/// @brief sFile (aka FILE) /// @brief sFile (aka FILE)
FILE* sfile_; FILE* sfile_;
......
...@@ -644,7 +644,7 @@ inline isc::data::ConstElementPtr ...@@ -644,7 +644,7 @@ inline isc::data::ConstElementPtr
parseJSON(const std::string& in) parseJSON(const std::string& in)
{ {
isc::dhcp::Parser6Context ctx; isc::dhcp::Parser6Context ctx;
return (ctx.parseString(in, isc::dhcp::Parser6Context::PARSER_GENERIC_JSON)); return (ctx.parseString(in, isc::dhcp::Parser6Context::SUBPARSER_JSON));
} }
// For parser testing (DHCP6) // For parser testing (DHCP6)
...@@ -669,7 +669,7 @@ parseOPTION_DEF(const std::string& in) ...@@ -669,7 +669,7 @@ parseOPTION_DEF(const std::string& in)
{ {
try { try {
isc::dhcp::Parser6Context ctx; isc::dhcp::Parser6Context ctx;
return (ctx.parseString(in, isc::dhcp::Parser6Context::SUBPARSER_OPTION_DEF)); return (ctx.parseString(in, isc::dhcp::Parser6Context::PARSER_OPTION_DEF));
} }
catch (const std::exception& ex) { catch (const std::exception& ex) {
#ifdef ENABLE_DEBUG #ifdef ENABLE_DEBUG
......
...@@ -65,7 +65,7 @@ void testParser2(const std::string& txt, Parser6Context::ParserType parser_type) ...@@ -65,7 +65,7 @@ void testParser2(const std::string& txt, Parser6Context::ParserType parser_type)
TEST(ParserTest, mapInMap) { TEST(ParserTest, mapInMap) {
string txt = "{ \"xyzzy\": { \"foo\": 123, \"baz\": 456 } }"; string txt = "{ \"xyzzy\": { \"foo\": 123, \"baz\": 456 } }";
testParser(txt, Parser6Context::PARSER_GENERIC_JSON); testParser(txt, Parser6Context::SUBPARSER_JSON);
} }
TEST(ParserTest, listInList) { TEST(ParserTest, listInList) {
...@@ -76,7 +76,7 @@ TEST(ParserTest, listInList) { ...@@ -76,7 +76,7 @@ TEST(ParserTest, listInList) {
TEST(ParserTest, nestedMaps) { TEST(ParserTest, nestedMaps) {
string txt = "{ \"europe\": { \"UK\": { \"London\": { \"street\": \"221B Baker\" }}}}"; string txt = "{ \"europe\": { \"UK\": { \"London\": { \"street\": \"221B Baker\" }}}}";
testParser(txt, Parser6Context::PARSER_GENERIC_JSON); testParser(txt, Parser6Context::SUBPARSER_JSON);
} }
TEST(ParserTest, nestedLists) { TEST(ParserTest, nestedLists) {
...@@ -87,7 +87,7 @@ TEST(ParserTest, nestedLists) { ...@@ -87,7 +87,7 @@ TEST(ParserTest, nestedLists) {
TEST(ParserTest, listsInMaps) { TEST(ParserTest, listsInMaps) {
string txt = "{ \"constellations\": { \"orion\": [ \"rigel\", \"betelguese\" ], " string txt = "{ \"constellations\": { \"orion\": [ \"rigel\", \"betelguese\" ], "
"\"cygnus\": [ \"deneb\", \"albireo\"] } }"; "\"cygnus\": [ \"deneb\", \"albireo\"] } }";
testParser(txt, Parser6Context::PARSER_GENERIC_JSON); testParser(txt, Parser6Context::SUBPARSER_JSON);
} }
TEST(ParserTest, mapsInLists) { TEST(ParserTest, mapsInLists) {
...@@ -103,7 +103,7 @@ TEST(ParserTest, types) { ...@@ -103,7 +103,7 @@ TEST(ParserTest, types) {
"\"map\": { \"foo\": \"bar\" }," "\"map\": { \"foo\": \"bar\" },"
"\"list\": [ 1, 2, 3 ]," "\"list\": [ 1, 2, 3 ],"
"\"null\": null }"; "\"null\": null }";
testParser(txt, Parser6Context::PARSER_GENERIC_JSON); testParser(txt, Parser6Context::SUBPARSER_JSON);
} }
TEST(ParserTest, keywordJSON) { TEST(ParserTest, keywordJSON) {
...@@ -111,7 +111,7 @@ TEST(ParserTest, keywordJSON) { ...@@ -111,7 +111,7 @@ TEST(ParserTest, keywordJSON) {
"\"type\": \"password\"," "\"type\": \"password\","
"\"user\": \"name\"," "\"user\": \"name\","
"\"password\": \"type\" }"; "\"password\": \"type\" }";
testParser(txt, Parser6Context::PARSER_GENERIC_JSON); testParser(txt, Parser6Context::SUBPARSER_JSON);
} }
TEST(ParserTest, keywordDhcp6) { TEST(ParserTest, keywordDhcp6) {
...@@ -267,148 +267,142 @@ void testError(const std::string& txt, ...@@ -267,148 +267,142 @@ void testError(const std::string& txt,
// Check errors // Check errors
TEST(ParserTest, errors) { TEST(ParserTest, errors) {
// no input // no input
testError("", testError("", Parser6Context::SUBPARSER_JSON,
Parser6Context::PARSER_GENERIC_JSON, "<string>:1.1: syntax error, unexpected end of file");
"<string>:1.1: syntax error, unexpected end of file, " testError(" ", Parser6Context::SUBPARSER_JSON,
"expecting {"); "<string>:1.2: syntax error, unexpected end of file");
testError(" ", testError("\n", Parser6Context::SUBPARSER_JSON,
Parser6Context::PARSER_GENERIC_JSON, "<string>:2.1: syntax error, unexpected end of file");
"<string>:1.2: syntax error, unexpected end of file, "
"expecting {");
testError("\n",
Parser6Context::PARSER_GENERIC_JSON,
"<string>:2.1: syntax error, unexpected end of file, "
"expecting {");
// comments // comments
testError("# nothing\n", testError("# nothing\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file, "
"expecting {"); "expecting {");
testError(" #\n", testError(" #\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file, "
"expecting {"); "expecting {");
testError("// nothing\n", testError("// nothing\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file, "
"expecting {"); "expecting {");
testError("/* nothing */\n", testError("/* nothing */\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file, "
"expecting {"); "expecting {");
testError("/* no\nthing */\n", testError("/* no\nthing */\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:3.1: syntax error, unexpected end of file, " "<string>:3.1: syntax error, unexpected end of file, "
"expecting {"); "expecting {");
testError("/* no\nthing */\n\n", testError("/* no\nthing */\n\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:4.1: syntax error, unexpected end of file, " "<string>:4.1: syntax error, unexpected end of file, "
"expecting {"); "expecting {");
testError("/* nothing\n", testError("/* nothing\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"Comment not closed. (/* in line 1"); "Comment not closed. (/* in line 1");
testError("\n\n\n/* nothing\n", testError("\n\n\n/* nothing\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"Comment not closed. (/* in line 4"); "Comment not closed. (/* in line 4");
testError("{ /* */*/ }\n", testError("{ /* */*/ }\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.3-8: Invalid character: *"); "<string>:1.3-8: Invalid character: *");
testError("{ /* // *// }\n", testError("{ /* // *// }\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.3-11: Invalid character: /"); "<string>:1.3-11: Invalid character: /");
testError("{ /* // */// }\n", testError("{ /* // */// }\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file, "
"expecting }"); "expecting }");
// includes // includes
testError("<?\n", testError("<?\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"Directive not closed."); "Directive not closed.");
testError("<?include\n", testError("<?include\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"Directive not closed."); "Directive not closed.");
string file = string(CFG_EXAMPLES) + "/" + "stateless.json"; string file = string(CFG_EXAMPLES) + "/" + "stateless.json";
testError("<?include \"" + file + "\"\n", testError("<?include \"" + file + "\"\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"Directive not closed."); "Directive not closed.");
testError("<?include \"/foo/bar\" ?>/n", testError("<?include \"/foo/bar\" ?>/n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"Can't open include file /foo/bar"); "Can't open include file /foo/bar");
// numbers // numbers
testError("123", testError("123",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-3: syntax error, unexpected integer, " "<string>:1.1-3: syntax error, unexpected integer, "
"expecting {"); "expecting {");
testError("-456", testError("-456",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-4: syntax error, unexpected integer, " "<string>:1.1-4: syntax error, unexpected integer, "
"expecting {"); "expecting {");
testError("-0001", testError("-0001",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-5: syntax error, unexpected integer, " "<string>:1.1-5: syntax error, unexpected integer, "
"expecting {"); "expecting {");
testError("1234567890123456789012345678901234567890", testError("1234567890123456789012345678901234567890",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-40: Failed to convert " "<string>:1.1-40: Failed to convert "
"1234567890123456789012345678901234567890" "1234567890123456789012345678901234567890"
" to an integer."); " to an integer.");
testError("-3.14e+0", testError("-3.14e+0",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-8: syntax error, unexpected floating point, " "<string>:1.1-8: syntax error, unexpected floating point, "
"expecting {"); "expecting {");
testError("1e50000", testError("1e50000",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-7: Failed to convert 1e50000 " "<string>:1.1-7: Failed to convert 1e50000 "
"to a floating point."); "to a floating point.");
// strings // strings
testError("\"aabb\"", testError("\"aabb\"",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-6: syntax error, unexpected constant string, " "<string>:1.1-6: syntax error, unexpected constant string, "
"expecting {"); "expecting {");
testError("{ \"aabb\"err", testError("{ \"aabb\"err",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.9: Invalid character: e"); "<string>:1.9: Invalid character: e");
testError("{ err\"aabb\"", testError("{ err\"aabb\"",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.3: Invalid character: e"); "<string>:1.3: Invalid character: e");
testError("\"a\n\tb\"", testError("\"a\n\tb\"",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-6: Invalid control in \"a\n\tb\""); "<string>:1.1-6: Invalid control in \"a\n\tb\"");
testError("\"a\\n\\tb\"", testError("\"a\\n\\tb\"",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-8: syntax error, unexpected constant string, " "<string>:1.1-8: syntax error, unexpected constant string, "
"expecting {"); "expecting {");
testError("\"a\\x01b\"", testError("\"a\\x01b\"",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-8: Bad escape in \"a\\x01b\""); "<string>:1.1-8: Bad escape in \"a\\x01b\"");
testError("\"a\\u0062\"", testError("\"a\\u0062\"",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-9: Unsupported unicode escape in \"a\\u0062\""); "<string>:1.1-9: Unsupported unicode escape in \"a\\u0062\"");
testError("\"a\\u062z\"", testError("\"a\\u062z\"",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-9: Bad escape in \"a\\u062z\""); "<string>:1.1-9: Bad escape in \"a\\u062z\"");
testError("\"abc\\\"", testError("\"abc\\\"",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1-6: Overflow escape in \"abc\\\""); "<string>:1.1-6: Overflow escape in \"abc\\\"");
// from data_unittest.c // from data_unittest.c
testError("\\a", testError("\\a",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1: Invalid character: \\"); "<string>:1.1: Invalid character: \\");
testError("\\", testError("\\",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1: Invalid character: \\"); "<string>:1.1: Invalid character: \\");
testError("\\\"\\\"", testError("\\\"\\\"",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1: Invalid character: \\"); "<string>:1.1: Invalid character: \\");
// want a map // want a map
testError("[]\n", testError("[]\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.1: syntax error, unexpected [, " "<string>:1.1: syntax error, unexpected [, "
"expecting {"); "expecting {");
testError("[]\n", testError("[]\n",
...@@ -416,14 +410,14 @@ TEST(ParserTest, errors) { ...@@ -416,14 +410,14 @@ TEST(ParserTest, errors) {
"<string>:1.1: syntax error, unexpected [, " "<string>:1.1: syntax error, unexpected [, "
"expecting {"); "expecting {");
testError("{ 123 }\n", testError("{ 123 }\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.3-5: syntax error, unexpected integer, " "<string>:1.3-5: syntax error, unexpected integer, "
"expecting }"); "expecting }");
testError("{ 123 }\n", testError("{ 123 }\n",
Parser6Context::PARSER_DHCP6, Parser6Context::PARSER_DHCP6,
"<string>:1.3-5: syntax error, unexpected integer"); "<string>:1.3-5: syntax error, unexpected integer");
testError("{ \"foo\" }\n", testError("{ \"foo\" }\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.9: syntax error, unexpected }, " "<string>:1.9: syntax error, unexpected }, "
"expecting :"); "expecting :");
testError("{ \"foo\" }\n", testError("{ \"foo\" }\n",
...@@ -442,21 +436,21 @@ TEST(ParserTest, errors) { ...@@ -442,21 +436,21 @@ TEST(ParserTest, errors) {
"<string>:2.1: syntax error, unexpected end of file, " "<string>:2.1: syntax error, unexpected end of file, "
"expecting \",\" or }"); "expecting \",\" or }");
testError("{}{}\n", testError("{}{}\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.3: syntax error, unexpected {, " "<string>:1.3: syntax error, unexpected {, "
"expecting end of file"); "expecting end of file");
// bad commas // bad commas
testError("{ , }\n", testError("{ , }\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.3: syntax error, unexpected \",\", " "<string>:1.3: syntax error, unexpected \",\", "
"expecting }"); "expecting }");
testError("{ , \"foo\":true }\n", testError("{ , \"foo\":true }\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.3: syntax error, unexpected \",\", " "<string>:1.3: syntax error, unexpected \",\", "
"expecting }"); "expecting }");
testError("{ \"foo\":true, }\n", testError("{ \"foo\":true, }\n",
Parser6Context::PARSER_GENERIC_JSON, Parser6Context::SUBPARSER_JSON,
"<string>:1.15: syntax error, unexpected }, " "<string>:1.15: syntax error, unexpected }, "
"expecting constant string"); "expecting constant string");
......
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