mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-08-28 09:45:17 +00:00
fix(parser): allow empty final macro arguments (#948)
Treat a trailing comma as an empty parameter.
This commit is contained in:
@@ -933,7 +933,8 @@ void DefinesStreamProxy::ContinueMacroParameters(
|
|||||||
}
|
}
|
||||||
else if (state.m_parameter_state == ParameterState::AFTER_COMMA)
|
else if (state.m_parameter_state == ParameterState::AFTER_COMMA)
|
||||||
{
|
{
|
||||||
throw ParsingException(CreatePos(line, linePos), "Cannot close macro parameters after comma");
|
state.m_parameters.emplace_back();
|
||||||
|
state.m_parameter_state = ParameterState::NOT_IN_PARAMETERS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -761,6 +761,24 @@ namespace test::parsing::impl::defines_stream_proxy
|
|||||||
REQUIRE(proxy.Eof());
|
REQUIRE(proxy.Eof());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("DefinesStreamProxy: Ensure can use empty final parameter value in nested macro", "[parsing][parsingstream]")
|
||||||
|
{
|
||||||
|
const std::vector<std::string> lines{
|
||||||
|
"#define inner(param1, param2) param1+param2+end",
|
||||||
|
"#define outer(param1) inner(param1, )",
|
||||||
|
"outer(begin)",
|
||||||
|
};
|
||||||
|
|
||||||
|
MockParserLineStream mockStream(lines);
|
||||||
|
DefinesStreamProxy proxy(&mockStream);
|
||||||
|
|
||||||
|
ExpectLine(&proxy, 1, "");
|
||||||
|
ExpectLine(&proxy, 2, "");
|
||||||
|
ExpectLine(&proxy, 3, "begin++end");
|
||||||
|
|
||||||
|
REQUIRE(proxy.Eof());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("DefinesStreamProxy: Ensure throws error on unclosed parenthesis in params", "[parsing][parsingstream]")
|
TEST_CASE("DefinesStreamProxy: Ensure throws error on unclosed parenthesis in params", "[parsing][parsingstream]")
|
||||||
{
|
{
|
||||||
const std::vector<std::string> lines{
|
const std::vector<std::string> lines{
|
||||||
|
|||||||
Reference in New Issue
Block a user