52 lines
1.4 KiB
C
52 lines
1.4 KiB
C
|
#pragma once
|
||
|
|
||
|
#include "libsyntax.h"
|
||
|
#include <concepts>
|
||
|
|
||
|
namespace lib_composit {
|
||
|
template<typename... TYPES> class TypeList;
|
||
|
|
||
|
template<> class TypeList<> {
|
||
|
public:
|
||
|
static QList<std::shared_ptr<const lib_syntax::IBasicRule>> getRules() {
|
||
|
return QList<std::shared_ptr<const lib_syntax::IBasicRule>>();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
template<typename T, typename... Rets>
|
||
|
requires std::derived_from<T, lib_syntax::IBasicRule>
|
||
|
class TypeList<T, Rets...> : public TypeList<Rets...> {
|
||
|
public:
|
||
|
static QList<std::shared_ptr<const lib_syntax::IBasicRule>> getRules() {
|
||
|
auto list = TypeList<Rets...>::getRules();
|
||
|
list.prepend(std::make_shared<const T>());
|
||
|
return list;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
template<typename... TYPES>
|
||
|
class AnyR : public lib_syntax::Any, public TypeList<TYPES...> {
|
||
|
public:
|
||
|
AnyR() : Any(TypeList<TYPES...>::getRules()){ }
|
||
|
};
|
||
|
|
||
|
template<typename... TYPES>
|
||
|
class SeqsR : public lib_syntax::Seqs, public TypeList<TYPES...> {
|
||
|
public:
|
||
|
SeqsR() : Seqs(TypeList<TYPES...>::getRules()){ }
|
||
|
};
|
||
|
|
||
|
template<typename TYPE, int min, int max>
|
||
|
class ReptR : public lib_syntax::Rept {
|
||
|
public:
|
||
|
ReptR() : Rept(std::make_shared<TYPE>(), min, max){ }
|
||
|
};
|
||
|
|
||
|
template<typename E, typename T, lib_token::TokenProcs<E> xproc = nullptr>
|
||
|
requires std::derived_from<E, ast_basic::IExprInstance> && std::derived_from<T, lib_token::ITokenProcess>
|
||
|
class TokenR : public lib_syntax::TokenMatch<E, xproc> {
|
||
|
public:
|
||
|
TokenR() : TokenMatch<E, xproc>(std::make_shared<T>()){ }
|
||
|
};
|
||
|
}
|