Take an initializer_list instead of variadic arguments in the nextAre lambda function
This commit is contained in:
parent
01a1e5d339
commit
fefa7b05c7
|
@ -4,7 +4,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "ParseComponents.hpp"
|
#include "ParseComponents.hpp"
|
||||||
#include "../Yerbacon.hpp"
|
#include "../Yerbacon.hpp"
|
||||||
#include <cstdarg>
|
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
|
|
||||||
namespace Parser {
|
namespace Parser {
|
||||||
|
@ -16,16 +15,14 @@ namespace Parser {
|
||||||
using namespace StandardComponents;
|
using namespace StandardComponents;
|
||||||
using enum tok::type;
|
using enum tok::type;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
const auto nextAre = [&i, &lexed](convertible_to<unsigned int> auto nextValues,...) {
|
const auto nextAre = [&i, &lexed]<convertible_to<unsigned int> T>(const initializer_list<T>& nextValues) {
|
||||||
va_list argumentsList;
|
unsigned int j = 1;
|
||||||
va_start(argumentsList, nextValues);
|
for (const T& nextValue: nextValues) {
|
||||||
for (decltype(nextValues) j = 1; j <= nextValues; ++j) {
|
if (!cmp_greater(lexed.size() - i, nextValues.size()) || lexed[i + j].toktype != nextValue) {
|
||||||
if (!cmp_greater(lexed.size() - i, nextValues) || lexed[i + j].toktype != va_arg(argumentsList, decltype(nextValues))) {
|
|
||||||
va_end(argumentsList);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
++j;
|
||||||
}
|
}
|
||||||
va_end(argumentsList);
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
for (;i < lexed.size(); ++i) {
|
for (;i < lexed.size(); ++i) {
|
||||||
|
@ -40,7 +37,7 @@ namespace Parser {
|
||||||
} else throw ParsingException((not next.toktext.empty()) ? '"' + next.toktext + "\" is not a valid class identifier" : "A class identifier is required", next.line);
|
} else throw ParsingException((not next.toktext.empty()) ? '"' + next.toktext + "\" is not a valid class identifier" : "A class identifier is required", next.line);
|
||||||
} else {
|
} else {
|
||||||
if ((lexed.size() - i) > 2) {
|
if ((lexed.size() - i) > 2) {
|
||||||
bool isFinalDefine = nextAre(2, TAG, DEFINE);
|
bool isFinalDefine = nextAre({TAG, DEFINE});
|
||||||
if (isFinalDefine || next.toktype == DEFINE) {
|
if (isFinalDefine || next.toktype == DEFINE) {
|
||||||
parseTree << Define(isFinalDefine, current.toktext);
|
parseTree << Define(isFinalDefine, current.toktext);
|
||||||
i += 1 + isFinalDefine;
|
i += 1 + isFinalDefine;
|
||||||
|
|
Loading…
Reference in New Issue