🚧 extend API
This commit is contained in:
parent
e9bfcf7255
commit
74520d8bb0
5 changed files with 148 additions and 66 deletions
|
|
@ -837,6 +837,7 @@ class lexer : public lexer_base<BasicJsonType>
|
|||
{
|
||||
switch (get())
|
||||
{
|
||||
// single-line comments skip input until a newline or EOF is read
|
||||
case '/':
|
||||
{
|
||||
while (true)
|
||||
|
|
@ -845,6 +846,8 @@ class lexer : public lexer_base<BasicJsonType>
|
|||
{
|
||||
case '\n':
|
||||
case '\r':
|
||||
case std::char_traits<char_type>::eof():
|
||||
case '\0':
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
|
@ -853,6 +856,7 @@ class lexer : public lexer_base<BasicJsonType>
|
|||
}
|
||||
}
|
||||
|
||||
// multi-line comments skip input until */ is read
|
||||
case '*':
|
||||
{
|
||||
while (true)
|
||||
|
|
@ -877,10 +881,14 @@ class lexer : public lexer_base<BasicJsonType>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unexpected character after reading '/'
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,11 @@ class parser
|
|||
/// a parser reading from an input adapter
|
||||
explicit parser(InputAdapterType&& adapter,
|
||||
const parser_callback_t<BasicJsonType> cb = nullptr,
|
||||
const bool allow_exceptions_ = true)
|
||||
: callback(cb), m_lexer(std::move(adapter)), allow_exceptions(allow_exceptions_)
|
||||
const bool allow_exceptions_ = true,
|
||||
const bool skip_comments = false)
|
||||
: callback(cb)
|
||||
, m_lexer(std::move(adapter), skip_comments)
|
||||
, allow_exceptions(allow_exceptions_)
|
||||
{
|
||||
// read first token
|
||||
get_token();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue