1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <boost/preprocessor/tuple/to_seq.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/cat.hpp>
#define TOKEN_TYPE_SEQ BOOST_PP_TUPLE_TO_SEQ(13, ( \
\
Symbol, \
String, \
If, \
FuncDecl, \
\
OpenScope, \
CloseScope, \
OpenParenth, \
ClosingParenth, \
\
\
AssignOp, \
AdditionOp, \
SubtractOp, \
DivideOp, \
MultiplyOp))
#define ENUM_ELEM(r, data, elem) elem,
#define TYPEDEF(r, data, elem) typedef Token<TokenType::elem> BOOST_PP_CAT(elem, Token);
namespace qq
{
enum TokenType
{
BOOST_PP_SEQ_FOR_EACH(ENUM_ELEM, _, TOKEN_TYPE_SEQ)
};
template <TokenType TType>
struct Token
{
TokenType Type;
char* Value;
Token() : Type(TType){}
};
BOOST_PP_SEQ_FOR_EACH(TYPEDEF, _, TOKEN_TYPE_SEQ)
}
int main() { }
|