Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
#ifndef ML99_UTIL_H
#define ML99_UTIL_H
#include <metalang99/priv/util.h>
#include <metalang99/ident.h> // For backwards compatibility.
#include <metalang99/lang.h>
#define ML99_catEval(a, b) ML99_call(ML99_catEval, a, b)
#define ML99_cat(a, b) ML99_call(ML99_cat, a, b)
#define ML99_cat3(a, b, c) ML99_call(ML99_cat3, a, b, c)
#define ML99_cat4(a, b, c, d) ML99_call(ML99_cat4, a, b, c, d)
#define ML99_stringify(...) ML99_call(ML99_stringify, __VA_ARGS__)
#define ML99_empty(...) ML99_callUneval(ML99_empty, )
#define ML99_id(...) ML99_call(ML99_id, __VA_ARGS__)
#define ML99_const(x, a) ML99_call(ML99_const, x, a)
#define ML99_flip(f) ML99_call(ML99_flip, f)
#define ML99_uncomma(...) ML99_call(ML99_uncomma, __VA_ARGS__)
#define ML99_reify(f) ML99_call(ML99_reify, f)
#define ML99_todo(f) ML99_call(ML99_todo, f)
#define ML99_todoWithMsg(f, message) ML99_call(ML99_todoWithMsg, f, message)
#define ML99_unimplemented(f) ML99_call(ML99_unimplemented, f)
#define ML99_unimplementedWithMsg(f, message) ML99_call(ML99_unimplementedWithMsg, f, message)
#ifdef __COUNTER__
#define ML99_GEN_SYM(prefix, id) ML99_CAT4(prefix, id, _, __COUNTER__)
#endif // __COUNTER__
#define ML99_TRAILING_SEMICOLON(...) struct ml99_priv_trailing_semicolon
#define ML99_CAT_PRIMITIVE(a, b) a##b
#define ML99_CAT3_PRIMITIVE(a, b, c) a##b##c
#define ML99_CAT4_PRIMITIVE(a, b, c, d) a##b##c##d
#define ML99_STRINGIFY_PRIMITIVE(...) #__VA_ARGS__
#define ML99_LPAREN(...) (
#define ML99_RPAREN(...) )
#define ML99_COMMA(...) ,
#define ML99_GCC_PRAGMA(str) ML99_PRIV_GCC_PRAGMA(str)
#define ML99_CLANG_PRAGMA(str) ML99_PRIV_CLANG_PRAGMA(str)
#define ML99_CAT(a, b) ML99_CAT_PRIMITIVE(a, b)
#define ML99_CAT3(a, b, c) ML99_CAT3_PRIMITIVE(a, b, c)
#define ML99_CAT4(a, b, c, d) ML99_CAT4_PRIMITIVE(a, b, c, d)
#define ML99_STRINGIFY(...) ML99_STRINGIFY_PRIMITIVE(__VA_ARGS__)
#define ML99_EMPTY(...)
#define ML99_ID(...) __VA_ARGS__
#ifndef DOXYGEN_IGNORE
#define ML99_catEval_IMPL(a, b) a##b
#define ML99_cat_IMPL(a, b) v(a##b)
#define ML99_cat3_IMPL(a, b, c) v(a##b##c)
#define ML99_cat4_IMPL(a, b, c, d) v(a##b##c##d)
#define ML99_stringify_IMPL(...) v(ML99_STRINGIFY(__VA_ARGS__))
#define ML99_empty_IMPL(...) v(ML99_EMPTY())
#define ML99_id_IMPL(...) v(ML99_ID(__VA_ARGS__))
#define ML99_const_IMPL(x, _a) v(x)
#define ML99_flip_IMPL(f) ML99_appl_IMPL(ML99_PRIV_flip, f)
#define ML99_PRIV_flip_IMPL(f, a, b) ML99_appl2_IMPL(f, b, a)
#define ML99_uncomma_IMPL(...) __VA_ARGS__
#define ML99_reify_IMPL(f) ML99_appl_IMPL(ML99_PRIV_reify, f)
#define ML99_PRIV_reify_IMPL(f, ...) v(f(__VA_ARGS__))
// clang-format off
#define ML99_todo_IMPL(f) ML99_fatal(f, not yet implemented)
#define ML99_todoWithMsg_IMPL(f, message) ML99_fatal(f, not yet implemented: message)
#define ML99_unimplemented_IMPL(f) ML99_fatal(f, not implemented)
#define ML99_unimplementedWithMsg_IMPL(f, message) ML99_fatal(f, not implemented: message)
// clang-format on
#if defined(__GNUC__) && !defined(__clang__)
#define ML99_PRIV_GCC_PRAGMA(str) _Pragma(str)
#else
#define ML99_PRIV_GCC_PRAGMA(str)
#endif
#if defined(__clang__)
#define ML99_PRIV_CLANG_PRAGMA(str) _Pragma(str)
#else
#define ML99_PRIV_CLANG_PRAGMA(str)
#endif
// Arity specifiers {
#define ML99_catEval_ARITY 2
#define ML99_cat_ARITY 2
#define ML99_cat3_ARITY 3
#define ML99_cat4_ARITY 4
#define ML99_stringify_ARITY 1
#define ML99_empty_ARITY 1
#define ML99_id_ARITY 1
#define ML99_const_ARITY 2
#define ML99_flip_ARITY 1
#define ML99_uncomma_ARITY 1
#define ML99_reify_ARITY 1
#define ML99_todo_ARITY 1
#define ML99_todoWithMsg_ARITY 2
#define ML99_unimplemented_ARITY 1
#define ML99_unimplementedWithMsg_ARITY 2
#define ML99_PRIV_flip_ARITY 3
#define ML99_PRIV_reify_ARITY 2
// } (Arity specifiers)
#endif // DOXYGEN_IGNORE
#endif // ML99_UTIL_H
ident.h
Identifiers: [a-zA-Z0-9_]+.
lang.h
The core metalanguage.