76 #ifndef LIB_DIFF_DIFF_LANGUAGE_H 77 #define LIB_DIFF_DIFF_LANGUAGE_H 100 template<
class I,
typename E>
101 using HandlerFun = void (I::*) (E
const&);
108 using Interpreter = I;
109 using Val =
typename I::Val;
110 using Handler = HandlerFun<I,Val>;
113 template<
template<
typename>
class IP,
typename E>
117 using Interpreter = IP<E>;
118 using Handler = HandlerFun<Interpreter,Val>;
121 template<
class I,
typename E>
125 using Interpreter = I;
126 using Handler = HandlerFun<I,E>;
146 template<
class I,
typename E>
151 using DiffToken = std::tuple<DiffVerb, E>;
152 using Interpreter = I;
157 DiffVerb& verb() {
return std::get<0>(*this); }
158 E
const& elm() {
return std::get<1>(*this); }
164 operator string()
const 166 return string(unConst(
this)->verb())
167 +
"("+string(unConst(
this)->elm())+
")";
171 applyTo (Interpreter& interpreter)
173 TRACE (diff,
"verb %4s(%s)",
cStr(verb()),
cStr(elm()) );
174 verb().applyTo (interpreter, elm());
179 static const DiffStep
NIL;
191 using Handler =
typename Scheme::Handler;
192 using Val =
typename Scheme::Val;
202 operator() (Val elm)
const 204 return { Verb(handler,
id), elm };
220 return { handlerFun,
id };
233 #define DiffStep_CTOR(_ID_) \ 234 const DiffStepBuilder<Interpreter> _ID_ = diffTokenBuilder (&Interpreter::_ID_, STRINGIFY(_ID_)); 241 template<
class I,
typename E>
268 template<
class TAR,
typename SEL =
void>
294 : target_(targetStructure)
299 consume (DIFF&& diff)
301 target_.initDiffApplication();
302 for ( ; diff; ++diff )
303 diff->applyTo(target_);
304 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.