mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Fix not being able to use two multi-line macros after another
This commit is contained in:
parent
9c80332147
commit
3ad2414754
@ -7,6 +7,7 @@
|
|||||||
#include "Parsing/Simple/SimpleExpressionInterpreter.h"
|
#include "Parsing/Simple/SimpleExpressionInterpreter.h"
|
||||||
#include "Utils/ClassUtils.h"
|
#include "Utils/ClassUtils.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -581,9 +582,11 @@ void DefinesStreamProxy::ExtractParametersFromDefineUsage(const ParserLine& line
|
|||||||
if (line.m_line[parameterStart] != '(')
|
if (line.m_line[parameterStart] != '(')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_macro_parameters = std::vector<std::string>();
|
|
||||||
m_macro_bracket_depth = std::stack<char>();
|
|
||||||
m_macro_parameter_state = ParameterState::AFTER_OPEN;
|
m_macro_parameter_state = ParameterState::AFTER_OPEN;
|
||||||
|
m_macro_parameters = std::vector<std::string>();
|
||||||
|
m_current_macro_parameter.clear();
|
||||||
|
m_current_macro_parameter.str(std::string());
|
||||||
|
m_macro_bracket_depth = std::stack<char>();
|
||||||
parameterEnd = parameterStart + 1;
|
parameterEnd = parameterStart + 1;
|
||||||
|
|
||||||
ContinueMacroParameters(line, parameterEnd);
|
ContinueMacroParameters(line, parameterEnd);
|
||||||
|
@ -776,4 +776,58 @@ namespace test::parsing::impl::defines_stream_proxy
|
|||||||
|
|
||||||
REQUIRE(proxy.Eof());
|
REQUIRE(proxy.Eof());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("DefinesStreamProxy: Can use second macro after multi-line macro", "[parsing][parsingstream]")
|
||||||
|
{
|
||||||
|
const std::vector<std::string> lines{
|
||||||
|
"#define LOL HAHA",
|
||||||
|
"#define testMacro(a, b) a likes b",
|
||||||
|
"testMacro(",
|
||||||
|
"Peter,",
|
||||||
|
"Anna",
|
||||||
|
") LOL funny",
|
||||||
|
};
|
||||||
|
|
||||||
|
MockParserLineStream mockStream(lines);
|
||||||
|
DefinesStreamProxy proxy(&mockStream);
|
||||||
|
|
||||||
|
ExpectLine(&proxy, 1, "");
|
||||||
|
ExpectLine(&proxy, 2, "");
|
||||||
|
ExpectLine(&proxy, 3, "");
|
||||||
|
ExpectLine(&proxy, 4, "");
|
||||||
|
ExpectLine(&proxy, 5, "");
|
||||||
|
ExpectLine(&proxy, 6, "Peter likes Anna HAHA funny");
|
||||||
|
|
||||||
|
REQUIRE(proxy.Eof());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("DefinesStreamProxy: Can use second multi-line macro after multi-line macro", "[parsing][parsingstream]")
|
||||||
|
{
|
||||||
|
const std::vector<std::string> lines{
|
||||||
|
"#define LOL HAHA",
|
||||||
|
"#define testMacro(a, b) a likes b",
|
||||||
|
"testMacro(",
|
||||||
|
"Peter,",
|
||||||
|
"Anna",
|
||||||
|
") and testMacro(",
|
||||||
|
"Anna,",
|
||||||
|
"Peter",
|
||||||
|
")",
|
||||||
|
};
|
||||||
|
|
||||||
|
MockParserLineStream mockStream(lines);
|
||||||
|
DefinesStreamProxy proxy(&mockStream);
|
||||||
|
|
||||||
|
ExpectLine(&proxy, 1, "");
|
||||||
|
ExpectLine(&proxy, 2, "");
|
||||||
|
ExpectLine(&proxy, 3, "");
|
||||||
|
ExpectLine(&proxy, 4, "");
|
||||||
|
ExpectLine(&proxy, 5, "");
|
||||||
|
ExpectLine(&proxy, 6, "Peter likes Anna and ");
|
||||||
|
ExpectLine(&proxy, 7, "");
|
||||||
|
ExpectLine(&proxy, 8, "");
|
||||||
|
ExpectLine(&proxy, 9, "Anna likes Peter");
|
||||||
|
|
||||||
|
REQUIRE(proxy.Eof());
|
||||||
|
}
|
||||||
} // namespace test::parsing::impl::defines_stream_proxy
|
} // namespace test::parsing::impl::defines_stream_proxy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user