85 #ifndef LIB_DIFF_DIFF_LANGUAGE_H 86 #define LIB_DIFF_DIFF_LANGUAGE_H 109 template<
class I,
typename E>
110 using HandlerFun = void (I::*) (E
const&);
117 using Interpreter = I;
118 using Val =
typename I::Val;
119 using Handler = HandlerFun<I,Val>;
122 template<
template<
typename>
class IP,
typename E>
126 using Interpreter = IP<E>;
127 using Handler = HandlerFun<Interpreter,Val>;
130 template<
class I,
typename E>
134 using Interpreter = I;
135 using Handler = HandlerFun<I,E>;
155 template<
class I,
typename E>
160 using DiffToken = std::tuple<DiffVerb, E>;
161 using Interpreter = I;
166 DiffVerb& verb() {
return std::get<0>(*this); }
167 E
const& elm() {
return std::get<1>(*this); }
173 operator string()
const 175 return string(unConst(
this)->verb())
176 +
"("+string(unConst(
this)->elm())+
")";
180 applyTo (Interpreter& interpreter)
182 TRACE (diff,
"verb %4s(%s)",
cStr(verb()),
cStr(elm()) );
183 verb().applyTo (interpreter, elm());
188 static const DiffStep
NIL;
200 using Handler =
typename Scheme::Handler;
201 using Val =
typename Scheme::Val;
211 operator() (Val elm)
const 213 return { Verb(handler,
id), elm };
229 return { handlerFun,
id };
242 #define DiffStep_CTOR(_ID_) \ 243 const DiffStepBuilder<Interpreter> _ID_ = diffTokenBuilder (&Interpreter::_ID_, STRINGIFY(_ID_)); 250 template<
class I,
typename E>
277 template<
class TAR,
typename SEL =
void>
303 : target_(targetStructure)
308 consume (DIFF&& diff)
310 target_.initDiffApplication();
311 for ( ; diff; ++diff )
312 diff->applyTo(target_);
313 target_.completeDiffApplication();
< base case is to expect typedef I::Val
Action token implemented by double dispatch to a handler function, as defined in the "receiver" inter...
Building blocks for a simple DSL using double dispatch to a handler function.
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
Any copy and copy construction prohibited.
inline string literal This is a marker type to indicate that
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Implementation namespace for support and library code.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Extension point: define how a specific diff language can be applied to elements in a concrete contain...
Lumiera error handling (C++ interface).
generator to produce specific language tokens
Lumiera public interface.
abstract entry, not yet allocated
static const DiffStep NIL
fixed "invalid" marker token
DiffStepBuilder< typename InterpreterScheme< H >::Interpreter > diffTokenBuilder(H handlerFun, Literal id)
set up a diff language token generator, based on the specific handler function given.
Definition frame for a language to describe differences in data structures.
generic builder to apply a diff description to a given target data structure.