Namespace: Binding
Template parameters:
- Binding - Type used to name the binding struct. Binding struct instances get passed as arguments to functions etc.
+ _BINDING_ - Type used to name the binding struct. Binding struct instances get passed as arguments to functions etc.
-This files declares a binding struct named [Binding]. It also provides
+This files declares a binding struct named [_BINDING_]. It also provides
the macro `call` that uses the binding.
Note this file does not make an instance of the binding, and does not intialize
// once per Binding value
-#ifdef Binding
-#if BOOLEAN(NOT_IN(Binding·SET ,Binding))
+#ifdef _BINDING_
+#if BOOLEAN(NOT_IN(Binding·SET ,_BINDING_))
#ifdef Binding·DEBUG
- #pragma message( "adding binding for:" STR_VAL(Binding) )
+ #pragma message( "adding binding for:" STR_VAL(_BINDING_) )
#endif
- struct Ξ(Binding ,FG);
- typedef struct Ξ(Binding ,FG) Ξ(Binding ,FG);
+ struct ·(_BINDING_ ,FG);
+ typedef struct ·(_BINDING_ ,FG) ·(_BINDING_ ,FG);
- struct Ξ(Binding ,Tableau);
- typedef struct Ξ(Binding ,Tableau) Ξ(Binding ,Tableau);
+ struct ·(_BINDING_ ,Tableau);
+ typedef struct ·(_BINDING_ ,Tableau) ·(_BINDING_ ,Tableau);
- typedef struct Binding{
- Ξ(Binding ,Tableau) *tableau;
- Ξ(Binding ,FG) *fg;
- } Binding;
+ typedef struct _BINDING_{
+ ·(_BINDING_ ,Tableau) *tableau;
+ ·(_BINDING_ ,FG) *fg;
+ } _BINDING_;
- static void Binding·wellformed_binding(Ξ(Binding) b){
+ static void Binding·wellformed_binding(_BINDING_ b){
#ifdef Binding·DEBUG
Core·Guard·init_count(chk);
Core·Guard·fg.check(&chk, 1, b.fg, "NULL fg table");
/*--------------------------------------------------------------------------------
undef the template parameters
-------------------------------------------------------------------------------*/
-#undef Binding
+#undef _BINDING_
typedef struct {
Map·Completion (*copy_byte_to_byte)(
- Ξ(TM·Array ,AU) *read_tm
- ,Ξ(TM·Array ,AU) *write_tm
+ ·(TM·Array ,AU) *read_tm
+ ,·(TM·Array ,AU) *write_tm
);
Map·Completion (*copy_hex_to_byte)(
- Ξ(TM·Array ,uint16_t) *read_tm
- ,Ξ(TM·Array ,AU) *write_tm
+ ·(TM·Array ,uint16_t) *read_tm
+ ,·(TM·Array ,AU) *write_tm
);
Map·Completion (*copy_byte_to_hex)(
- Ξ(TM·Array ,AU) *read_tm
- ,Ξ(TM·Array ,uint16_t) *write_tm
+ ·(TM·Array ,AU) *read_tm
+ ,·(TM·Array ,uint16_t) *write_tm
);
// Terminate string function
Map·Completion (*terminate_string)(
- Ξ(TM·Array ,AU) *write_tm
+ ·(TM·Array ,AU) *write_tm
);
} Map·FG;
#if defined(CVT_read) && defined(CVT_write)
// Function passed to map type signature must be this:
- typedef Core·Status (*Ξ(Map·fn ,CVT_read ,CVT_write))(
+ typedef Core·Status (*·(Map·fn ,CVT_read ,CVT_write))(
CVT_read *read_value
,CVT_write *write_value
);
typedef struct {
// Map a function over all elements from read_tm to write_tm
Map·Completion (*map)(
- Ξ(TM·Array ,CVT_read) *read_tm
- ,Ξ(TM·Array ,CVT_write) *write_tm
- ,Ξ(Map·fn ,CVT_read ,CVT_write) map_fn
+ ·(TM·Array ,CVT_read) *read_tm
+ ,·(TM·Array ,CVT_write) *write_tm
+ ,·(Map·fn ,CVT_read ,CVT_write) map_fn
);
// Map a function over elements from read_tm to write_tm until a condition is met
Map·Completion (*map_while)(
- Ξ(TM·Array ,CVT_read) *read_tm
- ,Ξ(TM·Array ,CVT_write) *write_tm
- ,Ξ(Map·fn ,CVT_read ,CVT_write) map_fn
- ,bool (*condition)(Ξ(TM·Array ,CVT_read) *read_tm)
+ ·(TM·Array ,CVT_read) *read_tm
+ ,·(TM·Array ,CVT_write) *write_tm
+ ,·(Map·fn ,CVT_read ,CVT_write) map_fn
+ ,bool (*condition)(·(TM·Array ,CVT_read) *read_tm)
);
// Map a function over n elements from read_tm to write_tm
Map·Completion (*map_extent)(
- Ξ(TM·Array ,CVT_read) *read_tm
- ,Ξ(TM·Array ,CVT_write) *write_tm
- ,Ξ(Map·fn ,CVT_read ,CVT_write) map_fn
- ,Ξ(extent_t ,CVT_read) extent
+ ·(TM·Array ,CVT_read) *read_tm
+ ,·(TM·Array ,CVT_write) *write_tm
+ ,·(Map·fn ,CVT_read ,CVT_write) map_fn
+ ,·(extent_t ,CVT_read) extent
);
- } Ξ(Map·FG ,CVT_read ,CVT_write);
+ } ·(Map·FG ,CVT_read ,CVT_write);
// Default function given table
- Ξ(Map·FG ,CVT_read ,CVT_write) Ξ(Map·fg ,CVT_read ,CVT_write);
+ ·(Map·FG ,CVT_read ,CVT_write) ·(Map·fg ,CVT_read ,CVT_write);
#endif
#if !defined(CVT_read) || !defined(CVT_write)
typedef struct {
Map·Completion (*copy_byte_to_byte)(
- Ξ(TM·Array ,AU) *read_tm
- ,Ξ(TM·Array ,AU) *write_tm
+ ·(TM·Array ,AU) *read_tm
+ ,·(TM·Array ,AU) *write_tm
);
Map·Completion (*copy_hex_to_byte)(
- Ξ(TM·Array ,uint16_t) *read_tm
- ,Ξ(TM·Array ,AU) *write_tm
+ ·(TM·Array ,uint16_t) *read_tm
+ ,·(TM·Array ,AU) *write_tm
);
Map·Completion (*copy_byte_to_hex)(
- Ξ(TM·Array ,AU) *read_tm
- ,Ξ(TM·Array ,uint16_t) *write_tm
+ ·(TM·Array ,AU) *read_tm
+ ,·(TM·Array ,uint16_t) *write_tm
);
// Terminate string function
Map·Completion (*terminate_string)(
- Ξ(TM·Array ,AU) *write_tm
+ ·(TM·Array ,AU) *write_tm
);
}
#endif
#if defined(CVT_read) && defined(CVT_write)
// Function passed to map type signature must be this:
- typedef Core·Status (*Ξ(Map·fn ,CVT_read ,CVT_write))(
+ typedef Core·Status (*·(Map·fn ,CVT_read ,CVT_write))(
CVT_read *read_value
,CVT_write *write_value
);
typedef struct {
// Map a function over all elements from read_tm to write_tm
Map·Completion (*map)(
- Ξ(TM·Array ,CVT_read) *read_tm
- ,Ξ(TM·Array ,CVT_write) *write_tm
- ,Ξ(Map·fn ,CVT_read ,CVT_write) map_fn
+ ·(TM·Array ,CVT_read) *read_tm
+ ,·(TM·Array ,CVT_write) *write_tm
+ ,·(Map·fn ,CVT_read ,CVT_write) map_fn
);
// Map a function over elements from read_tm to write_tm until a condition is met
Map·Completion (*map_while)(
- Ξ(TM·Array ,CVT_read) *read_tm
- ,Ξ(TM·Array ,CVT_write) *write_tm
- ,Ξ(Map·fn ,CVT_read ,CVT_write) map_fn
- ,bool (*condition)(Ξ(TM·Array ,CVT_read) *read_tm)
+ ·(TM·Array ,CVT_read) *read_tm
+ ,·(TM·Array ,CVT_write) *write_tm
+ ,·(Map·fn ,CVT_read ,CVT_write) map_fn
+ ,bool (*condition)(·(TM·Array ,CVT_read) *read_tm)
);
// Map a function over n elements from read_tm to write_tm
Map·Completion (*map_extent)(
- Ξ(TM·Array ,CVT_read) *read_tm
- ,Ξ(TM·Array ,CVT_write) *write_tm
- ,Ξ(Map·fn ,CVT_read ,CVT_write) map_fn
- ,Ξ(extent_t ,CVT_read) extent
+ ·(TM·Array ,CVT_read) *read_tm
+ ,·(TM·Array ,CVT_write) *write_tm
+ ,·(Map·fn ,CVT_read ,CVT_write) map_fn
+ ,·(extent_t ,CVT_read) extent
);
- } Ξ(Map·FG ,CVT_read ,CVT_write);
+ } ·(Map·FG ,CVT_read ,CVT_write);
// Default function given table
- Ξ(Map·FG ,CVT_read ,CVT_write) Ξ(Map·fg ,CVT_read ,CVT_write);
+ ·(Map·FG ,CVT_read ,CVT_write) ·(Map·fg ,CVT_read ,CVT_write);
#endif // !defined(CVT_read) && !defined(CVT_write)
#endif // #ifndef Map·FACE
// Map implementation with specific types
// Map a function over all elements from read_tm to write_tm
- Local Core·Status Ξ(Map ,CVT_read ,CVT_write)·map(
- Ξ(TM·Array ,CVT_read) *read_tm
- ,Ξ(TM·Array ,CVT_write) *write_tm
- ,Ξ(Map·fn ,CVT_read ,CVT_write) map_fn
+ Local Core·Status ·(Map ,CVT_read ,CVT_write)·map(
+ ·(TM·Array ,CVT_read) *read_tm
+ ,·(TM·Array ,CVT_write) *write_tm
+ ,·(Map·fn ,CVT_read ,CVT_write) map_fn
){
#ifdef Map·DEBUG
Core·Guard·init_count(chk);
#endif
// Rewind both tape machines to ensure we start at the beginning
- Ξ(TM·Array ,CVT_read)·fg.rewind(read_tm);
- Ξ(TM·Array ,CVT_write)·fg.rewind(write_tm);
+ ·(TM·Array ,CVT_read)·fg.rewind(read_tm);
+ ·(TM·Array ,CVT_write)·fg.rewind(write_tm);
// Initial check if can_read (not part of the loop)
- if(!Ξ(TM·Array ,CVT_read)·fg.can_read(read_tm)) return Core·Status·on_track;
+ if(!·(TM·Array ,CVT_read)·fg.can_read(read_tm)) return Core·Status·on_track;
// Track completion status
uint completion = 0;
while(1){
// Read value from source
CVT_read read_value;
- Ξ(TM·Array ,CVT_read)·fg.read(read_tm ,&read_value);
+ ·(TM·Array ,CVT_read)·fg.read(read_tm ,&read_value);
// Apply mapping function to get write value
CVT_write write_value;
}
// Write result to destination
- Ξ(TM·Array ,CVT_write)·fg.write(write_tm ,&write_value);
+ ·(TM·Array ,CVT_write)·fg.write(write_tm ,&write_value);
// Check if we're at the rightmost position for read
- bool read_rightmost = Ξ(TM·Array ,CVT_read)·fg.on_rightmost(read_tm);
+ bool read_rightmost = ·(TM·Array ,CVT_read)·fg.on_rightmost(read_tm);
if(read_rightmost) {
completion |= Core·Map·Completion·rightmost_read;
}
// Check if we're at the rightmost position for write
- bool write_rightmost = Ξ(TM·Array ,CVT_write)·fg.on_rightmost(write_tm);
+ bool write_rightmost = ·(TM·Array ,CVT_write)·fg.on_rightmost(write_tm);
if(write_rightmost) {
completion |= Core·Map·Completion·rightmost_write;
}
if(read_rightmost || write_rightmost) break;
// Step both machines
- Ξ(TM·Array ,CVT_read)·fg.step(read_tm);
- Ξ(TM·Array ,CVT_write)·fg.step(write_tm);
+ ·(TM·Array ,CVT_read)·fg.step(read_tm);
+ ·(TM·Array ,CVT_write)·fg.step(write_tm);
}
return Core·Status·on_track;
}
// Map a function over elements from read_tm to write_tm until a condition is met
- Local Core·Status Ξ(Map ,CVT_read ,CVT_write)·map_while(
- Ξ(TM·Array ,CVT_read) *read_tm
- ,Ξ(TM·Array ,CVT_write) *write_tm
- ,Ξ(Map·fn ,CVT_read ,CVT_write) map_fn
+ Local Core·Status ·(Map ,CVT_read ,CVT_write)·map_while(
+ ·(TM·Array ,CVT_read) *read_tm
+ ,·(TM·Array ,CVT_write) *write_tm
+ ,·(Map·fn ,CVT_read ,CVT_write) map_fn
,bool (*condition)(CVT_read *value)
){
#ifdef Map·DEBUG
#endif
// Rewind both tape machines to ensure we start at the beginning
- Ξ(TM·Array ,CVT_read)·fg.rewind(read_tm);
- Ξ(TM·Array ,CVT_write)·fg.rewind(write_tm);
+ ·(TM·Array ,CVT_read)·fg.rewind(read_tm);
+ ·(TM·Array ,CVT_write)·fg.rewind(write_tm);
// Initial check if can_read (not part of the loop)
- if(!Ξ(TM·Array ,CVT_read)·fg.can_read(read_tm)) return Core·Status·on_track;
+ if(!·(TM·Array ,CVT_read)·fg.can_read(read_tm)) return Core·Status·on_track;
// Track completion status
uint completion = 0;
while(1){
// Read value from source
CVT_read read_value;
- Ξ(TM·Array ,CVT_read)·fg.read(read_tm ,&read_value);
+ ·(TM·Array ,CVT_read)·fg.read(read_tm ,&read_value);
// Check condition
if(!condition(&read_value)) break;
}
// Write result to destination
- Ξ(TM·Array ,CVT_write)·fg.write(write_tm ,&write_value);
+ ·(TM·Array ,CVT_write)·fg.write(write_tm ,&write_value);
// Check if we're at the rightmost position for read
- bool read_rightmost = Ξ(TM·Array ,CVT_read)·fg.on_rightmost(read_tm);
+ bool read_rightmost = ·(TM·Array ,CVT_read)·fg.on_rightmost(read_tm);
if(read_rightmost) {
completion |= Core·Map·Completion·rightmost_read;
}
// Check if we're at the rightmost position for write
- bool write_rightmost = Ξ(TM·Array ,CVT_write)·fg.on_rightmost(write_tm);
+ bool write_rightmost = ·(TM·Array ,CVT_write)·fg.on_rightmost(write_tm);
if(write_rightmost) {
completion |= Core·Map·Completion·rightmost_write;
}
if(read_rightmost || write_rightmost) break;
// Step both machines
- Ξ(TM·Array ,CVT_read)·fg.step(read_tm);
- Ξ(TM·Array ,CVT_write)·fg.step(write_tm);
+ ·(TM·Array ,CVT_read)·fg.step(read_tm);
+ ·(TM·Array ,CVT_write)·fg.step(write_tm);
}
return Core·Status·on_track;
}
// Map a function over n elements from read_tm to write_tm
- Local Core·Status Ξ(Map ,CVT_read ,CVT_write)·map_n(
- Ξ(TM·Array ,CVT_read) *read_tm
- ,Ξ(TM·Array ,CVT_write) *write_tm
- ,Ξ(Map·fn ,CVT_read ,CVT_write) map_fn
+ Local Core·Status ·(Map ,CVT_read ,CVT_write)·map_n(
+ ·(TM·Array ,CVT_read) *read_tm
+ ,·(TM·Array ,CVT_write) *write_tm
+ ,·(Map·fn ,CVT_read ,CVT_write) map_fn
,size_t n
){
#ifdef Map·DEBUG
#endif
// Rewind both tape machines to ensure we start at the beginning
- Ξ(TM·Array ,CVT_read)·fg.rewind(read_tm);
- Ξ(TM·Array ,CVT_write)·fg.rewind(write_tm);
+ ·(TM·Array ,CVT_read)·fg.rewind(read_tm);
+ ·(TM·Array ,CVT_write)·fg.rewind(write_tm);
// Initial check if can_read (not part of the loop)
- if(!Ξ(TM·Array ,CVT_read)·fg.can_read(read_tm)) return Core·Status·on_track;
+ if(!·(TM·Array ,CVT_read)·fg.can_read(read_tm)) return Core·Status·on_track;
// Track completion status
uint completion = 0;
while(count < n){
// Read value from source
CVT_read read_value;
- Ξ(TM·Array ,CVT_read)·fg.read(read_tm ,&read_value);
+ ·(TM·Array ,CVT_read)·fg.read(read_tm ,&read_value);
// Apply mapping function to get write value
CVT_write write_value;
}
// Write result to destination
- Ξ(TM·Array ,CVT_write)·fg.write(write_tm ,&write_value);
+ ·(TM·Array ,CVT_write)·fg.write(write_tm ,&write_value);
// Increment count
count++;
// Check if we're at the rightmost position for read
- bool read_rightmost = Ξ(TM·Array ,CVT_read)·fg.on_rightmost(read_tm);
+ bool read_rightmost = ·(TM·Array ,CVT_read)·fg.on_rightmost(read_tm);
if(read_rightmost) {
completion |= Core·Map·Completion·rightmost_read;
}
// Check if we're at the rightmost position for write
- bool write_rightmost = Ξ(TM·Array ,CVT_write)·fg.on_rightmost(write_tm);
+ bool write_rightmost = ·(TM·Array ,CVT_write)·fg.on_rightmost(write_tm);
if(write_rightmost) {
completion |= Core·Map·Completion·rightmost_write;
}
if(read_rightmost || write_rightmost) break;
// Step both machines
- Ξ(TM·Array ,CVT_read)·fg.step(read_tm);
- Ξ(TM·Array ,CVT_write)·fg.step(write_tm);
+ ·(TM·Array ,CVT_read)·fg.step(read_tm);
+ ·(TM·Array ,CVT_write)·fg.step(write_tm);
}
return Core·Status·on_track;
}
// Initialize the function given table
- Ξ(Map·FG ,CVT_read ,CVT_write) Ξ(Map·fg ,CVT_read ,CVT_write) = {
- .map = Ξ(Map ,CVT_read ,CVT_write)·map
- ,.map_while = Ξ(Map ,CVT_read ,CVT_write)·map_while
- ,.map_n = Ξ(Map ,CVT_read ,CVT_write)·map_n
+ ·(Map·FG ,CVT_read ,CVT_write) ·(Map·fg ,CVT_read ,CVT_write) = {
+ .map = ·(Map ,CVT_read ,CVT_write)·map
+ ,.map_while = ·(Map ,CVT_read ,CVT_write)·map_while
+ ,.map_n = ·(Map ,CVT_read ,CVT_write)·map_n
};
#endif // defined(CVT_read) && defined(CVT_write)
// Byte to byte copy
Local Core·Status Map·copy_byte_to_byte(
- Ξ(TM·Array ,AU) *read_tm
- ,Ξ(TM·Array ,AU) *write_tm
+ ·(TM·Array ,AU) *read_tm
+ ,·(TM·Array ,AU) *write_tm
){
#ifdef Map·DEBUG
Core·Guard·init_count(chk);
Core·Guard·if_return(chk);
#endif
- return Ξ(Map ,AU ,AU)·fg.map(read_tm, write_tm, Map·byte_to_byte_fn);
+ return ·(Map ,AU ,AU)·fg.map(read_tm, write_tm, Map·byte_to_byte_fn);
}
// Hex to byte copy
Local Core·Status Map·copy_hex_to_byte(
- Ξ(TM·Array ,uint16_t) *read_tm
- ,Ξ(TM·Array ,AU) *write_tm
+ ·(TM·Array ,uint16_t) *read_tm
+ ,·(TM·Array ,AU) *write_tm
){
#ifdef Map·DEBUG
Core·Guard·init_count(chk);
Namespace: TM
Template parameters:
- `TM·CVT` Cell Value Type`.
+ `_TM·CVT_` Cell Value Type`.
TM - Tape Machine Model
#endif //#ifndef TM·FACE
-// once per TM·CVT value
+// once per _TM·CVT_ value
// Caller must #define SET__Binding__TM·<CVT>, after inclusion, to prevent re-inclusion
-#ifdef TM·CVT
-#if BOOLEAN( NOT_IN(Binding ,Ξ(TM,TM·CVT)) )
+#ifdef _TM·CVT_
+#if BOOLEAN( NOT_IN(Binding ,·(TM,_TM·CVT_)) )
#ifdef TM·DEBUG
- #pragma message( "Creating TM type with a CVT of:" STR_VAL(TM·CVT) )
+ #pragma message( "Creating TM type with a CVT of:" STR_VAL(_TM·CVT_) )
#endif
- #define Binding Ξ(TM,TM·CVT)
+ #define _BINDING_ ·(TM,_TM·CVT_)
#include "Binding.lib.c"
- typedef size_t Ξ(extent_t,TM·CVT);
+ // debug: TM·AU tm_binding;
- typedef struct Ξ(TM,TM·CVT,FG){
+ typedef size_t ·(extent_t,_TM·CVT_);
- TM·Tape·Topo (*Tape·topo) ( Ξ(TM,TM·CVT) tm );
- bool (*Tape·bounded) ( Ξ(TM,TM·CVT) tm );
- Ξ(extent_t,TM·CVT) (*Tape·extent) ( Ξ(TM,TM·CVT) tm );
+ typedef struct ·(TM,_TM·CVT_,FG){
- TM·Head·Status (*Head·status) ( Ξ(TM,TM·CVT) tm );
- bool (*Head·dismounted) ( Ξ(TM,TM·CVT) tm );
- bool (*Head·on_tape) ( Ξ(TM,TM·CVT) tm );
- bool (*Head·on_leftmost)( Ξ(TM,TM·CVT) tm );
- bool (*Head·on_rightmost)( Ξ(TM,TM·CVT) tm );
+ TM·Tape·Topo (*Tape·topo) ( ·(TM,_TM·CVT_) tm );
+ bool (*Tape·bounded) ( ·(TM,_TM·CVT_) tm );
+ ·(extent_t,_TM·CVT_) (*Tape·extent) ( ·(TM,_TM·CVT_) tm );
+
+ TM·Head·Status (*Head·status) ( ·(TM,_TM·CVT_) tm );
+ bool (*Head·dismounted) ( ·(TM,_TM·CVT_) tm );
+ bool (*Head·on_tape) ( ·(TM,_TM·CVT_) tm );
+ bool (*Head·on_leftmost)( ·(TM,_TM·CVT_) tm );
+ bool (*Head·on_rightmost)( ·(TM,_TM·CVT_) tm );
// tape machine functions
- void (*mount) ( Ξ(TM,TM·CVT) tm );
- void (*dismount) ( Ξ(TM,TM·CVT) tm );
+ void (*mount) ( ·(TM,_TM·CVT_) tm );
+ void (*dismount) ( ·(TM,_TM·CVT_) tm );
- void (*step) ( Ξ(TM,TM·CVT) tm );
- void (*step_right) ( Ξ(TM,TM·CVT) tm );
- void (*step_left) ( Ξ(TM,TM·CVT) tm );
- void (*rewind) ( Ξ(TM,TM·CVT) tm );
+ void (*step) ( ·(TM,_TM·CVT_) tm );
+ void (*step_right) ( ·(TM,_TM·CVT_) tm );
+ void (*step_left) ( ·(TM,_TM·CVT_) tm );
+ void (*rewind) ( ·(TM,_TM·CVT_) tm );
- TM·CVT (*read) ( Ξ(TM,TM·CVT) tm );
- void (*write) ( Ξ(TM,TM·CVT) tm ,TM·CVT *remote_pt );
+ _TM·CVT_ (*read) ( ·(TM,_TM·CVT_) tm );
+ void (*write) ( ·(TM,_TM·CVT_) tm ,_TM·CVT_ *remote_pt );
- } Ξ(TM,TM·CVT,FG);
+ } ·(TM,_TM·CVT_,FG);
//----------------------------------------
// Array interface
- #undef TM·ARRAY
- #define TM·ARRAY Ξ(TM,TM·CVT,ARRAY)
-
- struct Ξ(TM,TM·CVT,ARRAY,Tableau);
- typedef struct Ξ(TM,TM·CVT,ARRAY,Tableau) Ξ(TM,TM·CVT,ARRAY,Tableau);
+ // Not exposing the implementation would be better, but the user needs to allocate these before calling init.
+ typedef struct{
+ _TM·CVT_ *hd;
+ _TM·CVT_ *position;
+ ·(extent_t,_TM·CVT_) extent;
+ } ·(TM,_TM·CVT_,Array,Tableau);
/*
- We assume that the binding produced by init is valid. Thus it does not have null pointers to the tableau or the fg table; it points to an initialized tableau; it points to a valid array fg table; and, that the fg table and tableau go together.
+ We assume that the binding produced by init is valid. Thus: it does not have null pointers to the tableau or the fg table; it points to an initialized tableau; it points to a valid array fg table; and, that the fg table and tableau go together.
Calling init is the only time the user/programmer will need to know the implementation name.
The resulting binding object returned is what the user will call an instance of the
type.
*/
- TM Ξ(TM,TM·CVT,ARRAY,init_pe)(
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t
- ,TM·CVT position[]
- ,Ξ(extent_t,TM·CVT) extent
+ ·(TM,_TM·CVT_) ·(TM,_TM·CVT_,Array,init_pe)(
+ ·(TM,_TM·CVT_,Array,Tableau) *t
+ ,_TM·CVT_ position[]
+ ,·(extent_t,_TM·CVT_) extent
);
- TM Ξ(TM,TM·CVT,ARRAY,init_pp)(
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t
- ,TM·CVT *position_left
- ,TM·CVT *position_right
+ ·(TM,_TM·CVT_) ·(TM,_TM·CVT_,Array,init_pp)(
+ ·(TM,_TM·CVT_,Array,Tableau) *t
+ ,_TM·CVT_ *position_left
+ ,_TM·CVT_ *position_right
);
#endif // #if BOOLEAN( NOT_IN(Binding ,TM) )
-#endif // #ifdef TM·CVT
+#endif // #ifdef _TM·CVT_
/*--------------------------------------------------------------------------------
Local
#ifndef TM·LOCAL
#define TM·LOCAL
+ #include "Core.lib.c"
+ #include "Binding.lib.c"
+
const char *TM·Msg·tm = "given NULL tm";
const char *TM·Msg·flag = "given NULL flag pointer";
const char *TM·Msg·result = "given NULL result pointer";
#endif
- // once per TM·CVT value
+ // once per _TM·CVT_ value
// Caller must #define SET__TM·LOCAL__TM·<CVT>, after inclusion, to prevent re-inclusion
- #ifdef TM·CVT
- #if BOOLEAN(NOT_IN(TM·LOCAL ,Ξ(TM,TM·CVT)))
+ #ifdef _TM·CVT_
+ #if BOOLEAN(NOT_IN(TM·LOCAL ,·(TM,_TM·CVT_)))
#ifdef TM·DEBUG
- #pragma message( "Including LOCAL code for:" STR_VAL(TM·CVT) )
+ #pragma message( "Including LOCAL code for:" STR_VAL(_TM·CVT_) )
#endif
Array implementation with a segment tape
*/
- typedef struct Ξ(TM,TM·CVT,ARRAY,Tableau){
- TM·CVT *hd;
- TM·CVT position[];
- Ξ(extent_t,TM·CVT) extent;
- } Ξ(TM,TM·CVT,ARRAY,Tableau);
-
- Local TM·Tape·Topo Ξ(TM,TM·CVT,ARRAY,Tape·topo)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
+ Local TM·Tape·Topo ·(TM,_TM·CVT_,Array,Tape·topo)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
if( t->extent == 0 ) return TM·Tape·Topo·singleton;
return TM·Tape·Topo·segment;
}
- Local bool Ξ(TM,TM·CVT,ARRAY,Tape·bounded)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
- return Ξ(TM,TM·CVT,ARRAY,Tape·topo)( tm ) & TM·Tape·Topo·bounded;
+ Local bool ·(TM,_TM·CVT_,Array,Tape·bounded)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
+ return ·(TM,_TM·CVT_,Array,Tape·topo)( tm ) & TM·Tape·Topo·bounded;
}
- Local Ξ(extent_t,TM·CVT) Ξ(TM,TM·CVT,ARRAY,Tape·extent)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
+ Local ·(extent_t,_TM·CVT_) ·(TM,_TM·CVT_,Array,Tape·extent)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
return t->extent;
}
- Local TM·Head·Status Ξ(TM,TM·CVT,ARRAY,Head·status)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
+ Local TM·Head·Status ·(TM,_TM·CVT_,Array,Head·status)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
if( !t->hd ) return TM·Head·Status·dismounted;
- if( t->hd == tm->position ) return TM·Head·Status·leftmost;
+ if( t->hd == t->position ) return TM·Head·Status·leftmost;
- TM·CVT *rightmost_pt = t->position + t->extent;
+ _TM·CVT_ *rightmost_pt = t->position + t->extent;
if( t->hd == rightmost_pt ) return TM·Head·Status·rightmost;
- if( t->hd < tm->position || t->hd > rightmost_pt )
+ if( t->hd < t->position || t->hd > rightmost_pt )
return TM·Head·Status·out_of_area;
return TM·Head·Status·interim;
}
- Local bool Ξ(TM,TM·CVT,ARRAY,Head·dismounted)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
- return Ξ(TM,TM·CVT,ARRAY,Head·status)( tm ) & TM·Head·Status·dismounted;
+ Local bool ·(TM,_TM·CVT_,Array,Head·dismounted)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
+ return ·(TM,_TM·CVT_,Array,Head·status)( tm ) & TM·Head·Status·dismounted;
}
- Local bool Ξ(TM,TM·CVT,ARRAY,Head·on_tape)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
- return Ξ(TM,TM·CVT,ARRAY,Head·status)( tm ) & TM·Head·Status·on_tape;
+ Local bool ·(TM,_TM·CVT_,Array,Head·on_tape)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
+ return ·(TM,_TM·CVT_,Array,Head·status)( tm ) & TM·Head·Status·on_tape;
}
- Local bool Ξ(TM,TM·CVT,ARRAY,Head·on_leftmost)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
- return Ξ(TM,TM·CVT,ARRAY,Head·status)( tm ) & TM·Head·Status·leftmost;
+ Local bool ·(TM,_TM·CVT_,Array,Head·on_leftmost)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
+ return ·(TM,_TM·CVT_,Array,Head·status)( tm ) & TM·Head·Status·leftmost;
}
- Local bool Ξ(TM,TM·CVT,ARRAY,Head·on_rightmost)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
- return Ξ(TM,TM·CVT,ARRAY,Head·status)( tm ) & TM·Head·Status·rightmost;
+ Local bool ·(TM,_TM·CVT_,Array,Head·on_rightmost)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
+ return ·(TM,_TM·CVT_,Array,Head·status)( tm ) & TM·Head·Status·rightmost;
}
// does nothing if the hd is already mounted
- Local void Ξ(TM,TM·CVT,ARRAY,mount)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
+ Local void ·(TM,_TM·CVT_,Array,mount)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
if( !t->hd ) t->hd = t->position;
}
- Local void Ξ(TM,TM·CVT,ARRAY,dismount)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
+ Local void ·(TM,_TM·CVT_,Array,dismount)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
t->hd = NULL;
}
// does nothing if the hd is not mounted
- Local void Ξ(TM,TM·CVT,ARRAY,step)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
+ Local void ·(TM,_TM·CVT_,Array,step)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
t->hd++;
}
- Local void Ξ(TM,TM·CVT,ARRAY,step_left)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
+ Local void ·(TM,_TM·CVT_,Array,step_left)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
t->hd--;
}
- Local void Ξ(TM,TM·CVT,ARRAY,rewind)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
- if( Ξ(TM,TM·CVT,ARRAY,Head·dismounted)( tm ) ) return;
+ Local void ·(TM,_TM·CVT_,Array,rewind)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
+ if( ·(TM,_TM·CVT_,Array,Head·dismounted)( tm ) ) return;
t->hd = t->position;
}
- Local TM·CVT Ξ(TM,TM·CVT,ARRAY,read)( Ξ(TM,TM·CVT) tm ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
+ Local _TM·CVT_ ·(TM,_TM·CVT_,Array,read)( ·(TM,_TM·CVT_) tm ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
return *t->hd;
}
- Local void Ξ(TM,TM·CVT,ARRAY,write)( Ξ(TM,TM·CVT) tm ,TM·CVT *remote_pt ){
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t = (Ξ(TM,TM·CVT,ARRAY,Tableau) *) tm.tableau;
+ Local void ·(TM,_TM·CVT_,Array,write)( ·(TM,_TM·CVT_) tm ,_TM·CVT_ *remote_pt ){
+ ·(TM,_TM·CVT_,Array,Tableau) *t = (·(TM,_TM·CVT_,Array,Tableau) *) tm.tableau;
*remote_pt = *t->hd;
}
- Local TM·Binding Ξ(TM,TM·CVT,FG) Ξ(TM,TM·CVT,ARRAY,fg) = {
+ Local ·(TM,_TM·CVT_,FG) ·(TM,_TM·CVT_,Array,fg) = {
- .Tape·topo = Ξ(TM,TM·CVT,ARRAY,Tape·topo)
- ,.Tape·bounded = Ξ(TM,TM·CVT,ARRAY,Tape·bounded)
- ,.Tape·extent = Ξ(TM,TM·CVT,ARRAY,Tape·extent)
+ .Tape·topo = ·(TM,_TM·CVT_,Array,Tape·topo)
+ ,.Tape·bounded = ·(TM,_TM·CVT_,Array,Tape·bounded)
+ ,.Tape·extent = ·(TM,_TM·CVT_,Array,Tape·extent)
- ,.Head·status = Ξ(TM,TM·CVT,ARRAY,Head·status)
- ,.Head·dismounted = Ξ(TM,TM·CVT,ARRAY,Head·dismounted)
- ,.Head·on_tape = Ξ(TM,TM·CVT,ARRAY,Head·on_tape)
- ,.Head·on_leftmost = Ξ(TM,TM·CVT,ARRAY,Head·on_leftmost)
- ,.Head·on_rightmost= Ξ(TM,TM·CVT,ARRAY,Head·on_rightmost)
+ ,.Head·status = ·(TM,_TM·CVT_,Array,Head·status)
+ ,.Head·dismounted = ·(TM,_TM·CVT_,Array,Head·dismounted)
+ ,.Head·on_tape = ·(TM,_TM·CVT_,Array,Head·on_tape)
+ ,.Head·on_leftmost = ·(TM,_TM·CVT_,Array,Head·on_leftmost)
+ ,.Head·on_rightmost= ·(TM,_TM·CVT_,Array,Head·on_rightmost)
- ,.mount = Ξ(TM,TM·CVT,ARRAY,mount)
- ,.dismount = Ξ(TM,TM·CVT,ARRAY,dismount)
+ ,.mount = ·(TM,_TM·CVT_,Array,mount)
+ ,.dismount = ·(TM,_TM·CVT_,Array,dismount)
- ,.step = Ξ(TM,TM·CVT,ARRAY,step)
- ,.step_right = Ξ(TM,TM·CVT,ARRAY,step)
- ,.step_left = Ξ(TM,TM·CVT,ARRAY,step_left)
- ,.rewind = Ξ(TM,TM·CVT,ARRAY,rewind)
+ ,.step = ·(TM,_TM·CVT_,Array,step)
+ ,.step_right = ·(TM,_TM·CVT_,Array,step)
+ ,.step_left = ·(TM,_TM·CVT_,Array,step_left)
+ ,.rewind = ·(TM,_TM·CVT_,Array,rewind)
- ,.read = Ξ(TM,TM·CVT,ARRAY,read)
- ,.write = Ξ(TM,TM·CVT,ARRAY,write)
+ ,.read = ·(TM,_TM·CVT_,Array,read)
+ ,.write = ·(TM,_TM·CVT_,Array,write)
};
/*
tm is up casted from being array specific, to being generic. Later it is downcasted within the array code before being used. This can be seen at the top of each of the array specific function. This is the only loss of static type safety, and it is embedded in the library code.
*/
- Ξ(TM,TM·CVT) Ξ(TM,TM·CVT,ARRAY,init_pe)(
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t
- ,TM·CVT *position
- ,Ξ(extent_t,TM·CVT) extent
+ ·(TM,_TM·CVT_) ·(TM,_TM·CVT_,Array,init_pe)(
+ ·(TM,_TM·CVT_,Array,Tableau) *t
+ ,_TM·CVT_ *position
+ ,·(extent_t,_TM·CVT_) extent
){
t->hd = position;
t->position = position;
t->extent = extent;
- Ξ(TM,TM·CVT) tm = (Ξ(TM,TM·CVT)) {
- .tableau = t
- ,.fg = &Ξ(TM,TM·CVT,ARRAY,fg)
+ ·(TM,_TM·CVT_) tm = {
+ .tableau = (·(TM,_TM·CVT_,Tableau) *)t
+ ,.fg = &·(TM,_TM·CVT_,Array,fg)
};
return tm;
}
- Ξ(TM,TM·CVT) Ξ(TM,TM·CVT,ARRAY,init_pp)(
- Ξ(TM,TM·CVT,ARRAY,Tableau) *t
- ,TM·CVT *position_left
- ,TM·CVT *position_right
+ ·(TM,_TM·CVT_) ·(TM,_TM·CVT_,Array,init_pp)(
+ ·(TM,_TM·CVT_,Array,Tableau) *t
+ ,_TM·CVT_ *position_left
+ ,_TM·CVT_ *position_right
){
- t->hd = position_left;
- t->position = position_left;
- t->extent = position_right - position_left;
+ return ·(TM,_TM·CVT_,Array,init_pe)(
+ t ,position_left ,position_right - position_left
+ );
}
-
#endif // #if BOOLEAN(NOT_IN(TM·LOCAL ,TM))
- #endif // #ifdef TM·CVT
+ #endif // #ifdef _TM·CVT_
#endif // LOCAL
//--------------------------------------------------------------------------------
// undef the template parameters
//--------------------------------------------------------------------------------
-#undef TM·CVT
+#undef _TM·CVT_
// some aliases to make things a little easier to read
#undef TM
- #define TM Ξ(TM ,TM·CVT)
+ #define TM ·(TM ,TM·CVT)
#undef EXTENT_T
- #define EXTENT_T Ξ(extent_t ,TM·CVT)
+ #define EXTENT_T ·(extent_t ,TM·CVT)
//----------------------------------------
// TM Array implementation, not TM·CVT differentiated
// some aliases to make things a little easier to read
#undef TM
- #define TM Ξ(TM ,TM·CVT)
+ #define TM ·(TM ,TM·CVT)
#undef EXTENT_T
- #define EXTENT_T Ξ(extent_t ,TM·CVT)
+ #define EXTENT_T ·(extent_t ,TM·CVT)
#undef TM·ARRAY
- #define TM·ARRAY Ξ(TM ,ARRAY)
+ #define TM·ARRAY ·(TM ,ARRAY)
- typedef struct Ξ(TM·ARRAY ,Tableau){
+ typedef struct ·(TM·ARRAY ,Tableau){
TM·CVT *hd;
TM·CVT position[];
EXTENT_T extent;
- } Ξ(TM·ARRAY ,Tableau);
+ } ·(TM·ARRAY ,Tableau);
- Local TM·Tape·Topo Ξ(TM·ARRAY ,Tape·topo)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
+ Local TM·Tape·Topo ·(TM·ARRAY ,Tape·topo)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
if(t->extent == 0) return TM·Tape·Topo·singleton;
return TM·Tape·Topo·segment;
}
- Local bool Ξ(TM·ARRAY ,Tape·bounded)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
- return Ξ(TM·ARRAY ,Tape·topo)(tm) & TM·Tape·Topo·bounded;
+ Local bool ·(TM·ARRAY ,Tape·bounded)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
+ return ·(TM·ARRAY ,Tape·topo)(tm) & TM·Tape·Topo·bounded;
}
- Local EXTENT_T Ξ(TM·ARRAY ,Tape·extent)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
+ Local EXTENT_T ·(TM·ARRAY ,Tape·extent)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
return t->extent;
}
- Local TM·Head·Status Ξ(TM·ARRAY ,Head·status)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
+ Local TM·Head·Status ·(TM·ARRAY ,Head·status)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
if(!t->hd) return TM·Head·Status·dismounted;
if(t->hd == tm->position) return TM·Head·Status·leftmost;
return TM·Head·Status·interim;
}
- Local bool Ξ(TM·ARRAY ,Head·dismounted)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
- return Ξ(TM·ARRAY ,Head·status)(tm) & TM·Head·Status·dismounted;
+ Local bool ·(TM·ARRAY ,Head·dismounted)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
+ return ·(TM·ARRAY ,Head·status)(tm) & TM·Head·Status·dismounted;
}
- Local bool Ξ(TM·ARRAY ,Head·on_tape)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
- return Ξ(TM·ARRAY ,Head·status)(tm) & TM·Head·Status·on_tape;
+ Local bool ·(TM·ARRAY ,Head·on_tape)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
+ return ·(TM·ARRAY ,Head·status)(tm) & TM·Head·Status·on_tape;
}
- Local bool Ξ(TM·ARRAY ,Head·on_leftmost)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
- return Ξ(TM·ARRAY ,Head·status)(tm) & TM·Head·Status·leftmost;
+ Local bool ·(TM·ARRAY ,Head·on_leftmost)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
+ return ·(TM·ARRAY ,Head·status)(tm) & TM·Head·Status·leftmost;
}
- Local bool Ξ(TM·ARRAY ,Head·on_rightmost)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
- return Ξ(TM·ARRAY ,Head·status)(tm) & TM·Head·Status·rightmost;
+ Local bool ·(TM·ARRAY ,Head·on_rightmost)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
+ return ·(TM·ARRAY ,Head·status)(tm) & TM·Head·Status·rightmost;
}
// does nothing if the hd is already mounted
- Local void Ξ(TM·ARRAY ,mount)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
+ Local void ·(TM·ARRAY ,mount)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
if( !t->hd ) t->hd = t->position;
}
- Local void dismount Ξ(TM·ARRAY ,dismount)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
+ Local void dismount ·(TM·ARRAY ,dismount)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
t->hd = NULL;
}
// does nothing if the hd is not mounted
- Local void Ξ(TM·ARRAY ,step)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
+ Local void ·(TM·ARRAY ,step)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
t->hd++;
}
- Local void Ξ(TM·ARRAY ,step_left)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
+ Local void ·(TM·ARRAY ,step_left)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
t->hd--;
}
- Local void Ξ(TM·ARRAY ,rewind)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
- Ξ(TM·ARRAY ,Head·dismounted)(tm) return;
+ Local void ·(TM·ARRAY ,rewind)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
+ ·(TM·ARRAY ,Head·dismounted)(tm) return;
t->hd = t->position;
}
- Local TM·CVT Ξ(TM·ARRAY ,read)(TM tm){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
+ Local TM·CVT ·(TM·ARRAY ,read)(TM tm){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
return *t->hd;
}
- Local void Ξ(TM·ARRAY ,write)(TM tm ,TM·CVT *remote_pt){
- Ξ(TM·ARRAY ,Tableau) *t = (Ξ(TM·ARRAY ,Tableau) *) tm.tableau;
+ Local void ·(TM·ARRAY ,write)(TM tm ,TM·CVT *remote_pt){
+ ·(TM·ARRAY ,Tableau) *t = (·(TM·ARRAY ,Tableau) *) tm.tableau;
*remote_pt = *t->hd;
}
Local TM·Binding TM·fg = {
- .Tape·topo = Ξ(TM·ARRAY ,Tape·topo)
- ,.Tape·bounded = Ξ(TM·ARRAY ,Tape·bounded)
- ,.Tape·extent = Ξ(TM·ARRAY ,Tape·extent)
+ .Tape·topo = ·(TM·ARRAY ,Tape·topo)
+ ,.Tape·bounded = ·(TM·ARRAY ,Tape·bounded)
+ ,.Tape·extent = ·(TM·ARRAY ,Tape·extent)
- ,.Head·status = Ξ(TM·ARRAY ,Head·status)
- ,.Head·dismounted = Ξ(TM·ARRAY ,Head·dismounted)
- ,.Head·on_tape = Ξ(TM·ARRAY ,Head·on_tape)
- ,.Head·on_leftmost = Ξ(TM·ARRAY ,Head·on_leftmost)
- ,.Head·on_rightmost = Ξ(TM·ARRAY ,Head·on_rightmost)
+ ,.Head·status = ·(TM·ARRAY ,Head·status)
+ ,.Head·dismounted = ·(TM·ARRAY ,Head·dismounted)
+ ,.Head·on_tape = ·(TM·ARRAY ,Head·on_tape)
+ ,.Head·on_leftmost = ·(TM·ARRAY ,Head·on_leftmost)
+ ,.Head·on_rightmost = ·(TM·ARRAY ,Head·on_rightmost)
- ,.mount = Ξ(TM·ARRAY ,mount)
- ,.dismount = Ξ(TM·ARRAY ,dismount)
+ ,.mount = ·(TM·ARRAY ,mount)
+ ,.dismount = ·(TM·ARRAY ,dismount)
- ,.step = Ξ(TM·ARRAY ,step)
- ,.step_right = Ξ(TM·ARRAY ,step)
- ,.step_left = Ξ(TM·ARRAY ,step_left)
- ,.rewind = Ξ(TM·ARRAY ,rewind)
+ ,.step = ·(TM·ARRAY ,step)
+ ,.step_right = ·(TM·ARRAY ,step)
+ ,.step_left = ·(TM·ARRAY ,step_left)
+ ,.rewind = ·(TM·ARRAY ,rewind)
- ,.read = Ξ(TM·ARRAY ,read)
- ,.write = Ξ(TM·ARRAY ,write)
+ ,.read = ·(TM·ARRAY ,read)
+ ,.write = ·(TM·ARRAY ,write)
};
#ifdef TM·CVT
- Local Ξ(extent_t ,TM·CVT) Ξ(TM ,TM·CVT)·extent(TM *tm){
+ Local ·(extent_t ,TM·CVT) ·(TM ,TM·CVT)·extent(TM *tm){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
Core·Guard·fg.check(&chk ,1 ,TM·Tape·bounded(tm) ,"Tape is not bounded.");
return tm->fg.write(tm ,write_pt);
}
- Local Ξ(TM ,TM·CVT)·Binding Ξ(TM ,TM·CVT)·fg = {
+ Local ·(TM ,TM·CVT)·Binding ·(TM ,TM·CVT)·fg = {
.parent = TM·fg
- ,.extent = Ξ(TM ,TM·CVT)·extent
- ,.read = Ξ(TM ,TM·CVT)·read
- ,.write = Ξ(TM ,TM·CVT)·write
+ ,.extent = ·(TM ,TM·CVT)·extent
+ ,.read = ·(TM ,TM·CVT)·read
+ ,.write = ·(TM ,TM·CVT)·write
};
#endif // ifdef TM·CVT
// check the Tape·topo to make sure tape has extent before calling this
// `extent·TM·CVT` returns the index to the rightmost cell in the array.
- Local Ξ(extent_t ,TM·CVT) Ξ(TM·Array ,TM·CVT)·extent(Ξ(TM·Array ,TM·CVT) *tm){
+ Local ·(extent_t ,TM·CVT) ·(TM·Array ,TM·CVT)·extent(·(TM·Array ,TM·CVT) *tm){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
Core·Tape·Topo Tape·topo = Core·Tape·Topo·mu;
- Core·Status status = Ξ(TM·Array ,TM·CVT)·Tape·topo(tm ,&Tape·topo);
+ Core·Status status = ·(TM·Array ,TM·CVT)·Tape·topo(tm ,&Tape·topo);
bool good_Tape·topo =
(status == Core·Status·on_track) && (Tape·topo & Core·Tape·Topo·finite_nz)
;
//-----------------------------------
// TM·Array.area implementation
- Local Core·Status Ξ(TM·Array ,TM·CVT)·mount_pe(
- Ξ(TM·Array ,TM·CVT) *tm ,TM·CVT *position ,Ξ(extent_t ,TM·CVT) extent
+ Local Core·Status ·(TM·Array ,TM·CVT)·mount_pe(
+ ·(TM·Array ,TM·CVT) *tm ,TM·CVT *position ,·(extent_t ,TM·CVT) extent
){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
}
// If size of TM·CVT is not a power of two this can perform a divide
- Local Core·Status Ξ(TM·Array ,TM·CVT)·mount_pp(
- Ξ(TM·Array ,TM·CVT) *tm ,TM·CVT *pos_leftmost ,TM·CVT *pos_rightmost
+ Local Core·Status ·(TM·Array ,TM·CVT)·mount_pp(
+ ·(TM·Array ,TM·CVT) *tm ,TM·CVT *pos_leftmost ,TM·CVT *pos_rightmost
){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
Core·Guard·if_return(chk);
#endif
- Ξ(extent_t ,TM·CVT) extent = pos_rightmost - pos_leftmost);
- return Ξ(TM·Array ,TM·CVT)·mount_pe(tm ,pos_leftmost ,extent);
+ ·(extent_t ,TM·CVT) extent = pos_rightmost - pos_leftmost);
+ return ·(TM·Array ,TM·CVT)·mount_pe(tm ,pos_leftmost ,extent);
}
//-----------------------------------
// base Tape Machine operations
- Local Core·Status Ξ(TM·Array ,TM·CVT)·mount(Ξ(TM·Array ,TM·CVT) *tm){
+ Local Core·Status ·(TM·Array ,TM·CVT)·mount(·(TM·Array ,TM·CVT) *tm){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
Core·Guard·fg.check(&chk ,1 ,tm ,TM·Array·Msg·tm);
return Core·Status·on_track;
}
- Local Core·Status Ξ(TM·Array ,TM·CVT)·dismount(Ξ(TM·Array ,TM·CVT) *tm){
+ Local Core·Status ·(TM·Array ,TM·CVT)·dismount(·(TM·Array ,TM·CVT) *tm){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
Core·Guard·fg.check(&chk ,1 ,tm ,TM·Array·Msg·tm);
return Core·Status·on_track;
}
- Local TM·Head·Status Ξ(TM·Array ,TM·CVT)·head_status(TM *tm){
+ Local TM·Head·Status ·(TM·Array ,TM·CVT)·head_status(TM *tm){
if(!tm || !tm->position) return TM·Head·Status·mu;
if(!tm->hd) return TM·Head·Status·dismounted;
if(tm->hd == tm->position) return TM·Head·Status·leftmost;
return TM·Head·Status·interim;
}
- bool Ξ(TM·Array ,TM·CVT)·can_read(Ξ(TM·Array ,TM·CVT) *tm){
+ bool ·(TM·Array ,TM·CVT)·can_read(·(TM·Array ,TM·CVT) *tm){
return tm && tm->position && tm->hd;
}
// can_read was true
- bool Ξ(TM·Array ,TM·CVT)·on_origin(Ξ(TM·Array ,TM·CVT) *tm){
+ bool ·(TM·Array ,TM·CVT)·on_origin(·(TM·Array ,TM·CVT) *tm){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
bool flag = true ,s;
- s = Ξ(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
+ s = ·(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
Core·Guard·fg.check(&chk ,1 ,s && flag ,"head off format");
Core·Guard·assert(chk);
#endif
}
// can_read was true
- bool Ξ(TM·Array ,TM·CVT)·on_rightmost(Ξ(TM·Array ,TM·CVT) *tm){
+ bool ·(TM·Array ,TM·CVT)·on_rightmost(·(TM·Array ,TM·CVT) *tm){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
bool flag = true ,s;
- s = Ξ(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
+ s = ·(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
Core·Guard·fg.check(&chk ,1 ,s && flag ,"head off format");
Core·Guard·assert(chk);
#endif
return tm->hd == tm->position;
}
- void Ξ(TM·Array ,TM·CVT)·step(Ξ(TM·Array ,TM·CVT) *tm){
+ void ·(TM·Array ,TM·CVT)·step(·(TM·Array ,TM·CVT) *tm){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
bool flag = true ,s;
- s = Ξ(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
+ s = ·(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
Core·Guard·fg.check(&chk ,1 ,s && flag ,"head off format");
Core·Guard·assert(chk);
#endif
tm->hd++;
}
- void Ξ(TM·Array ,TM·CVT)·step_left(Ξ(TM·Array ,TM·CVT) *tm){
+ void ·(TM·Array ,TM·CVT)·step_left(·(TM·Array ,TM·CVT) *tm){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
bool flag = true ,s;
- s = Ξ(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
+ s = ·(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
Core·Guard·fg.check(&chk ,1 ,s && flag ,"head off format");
Core·Guard·assert(chk);
#endif
tm->hd--;
}
- void Ξ(TM·Array ,TM·CVT)·rewind(Ξ(TM·Array ,TM·CVT) *tm){
+ void ·(TM·Array ,TM·CVT)·rewind(·(TM·Array ,TM·CVT) *tm){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
bool flag = true ,s;
- s = Ξ(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
+ s = ·(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
Core·Guard·fg.check(&chk ,1 ,s && flag ,"head off format");
Core·Guard·assert(chk);
#endif
}
// tm_can_read must be true for both machines.
- void Ξ(TM·Array ,TM·CVT)·copy_datum(Ξ(TM·Array ,TM·CVT) *tm_read ,Ξ(TM·Array ,TM·CVT) *tm_write){
+ void ·(TM·Array ,TM·CVT)·copy_datum(·(TM·Array ,TM·CVT) *tm_read ,·(TM·Array ,TM·CVT) *tm_write){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
bool flag = true ,s;
- s = Ξ(TM·Array ,TM·CVT)·head_on_format(tm_read ,flag) == Control·Status·on_track;
+ s = ·(TM·Array ,TM·CVT)·head_on_format(tm_read ,flag) == Control·Status·on_track;
Core·Guard·fg.check(&chk ,1 ,s && flag ,"tm_read head off track");
- s = Ξ(TM·Array ,TM·CVT)·head_on_format(tm_write ,flag) == Control·Status·on_track;
+ s = ·(TM·Array ,TM·CVT)·head_on_format(tm_write ,flag) == Control·Status·on_track;
Core·Guard·fg.check(&chk ,1 ,s && flag ,"tm_write head off track");
Core·Guard·assert(chk);
#endif
return Core·Status·on_track;
}
- void Ξ(TM·Array ,TM·CVT)·read(Ξ(TM·Array ,TM·CVT) *tm ,TM·CVT *read_pt){
+ void ·(TM·Array ,TM·CVT)·read(·(TM·Array ,TM·CVT) *tm ,TM·CVT *read_pt){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
bool flag = true ,s;
- s = Ξ(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
+ s = ·(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
Core·Guard·fg.check(&chk ,1 ,s && flag ,"head off format");
Core·Guard·assert(chk);
#endif
//----------------------------------------
- // Initialization for Ξ(TM·Array ,TM·CVT)·fg
+ // Initialization for ·(TM·Array ,TM·CVT)·fg
- Local Ξ(TM·Array ,TM·CVT)·Binding Ξ(TM·Array ,TM·CVT)·fg = {
+ Local ·(TM·Array ,TM·CVT)·Binding ·(TM·Array ,TM·CVT)·fg = {
.tape = {
- .Tape·topo = Ξ(TM·Array ,TM·CVT)·Tape·topo
- .extent = Ξ(TM·Array ,TM·CVT)·extent
+ .Tape·topo = ·(TM·Array ,TM·CVT)·Tape·topo
+ .extent = ·(TM·Array ,TM·CVT)·extent
}
,.area = {
- .mount_pe = Ξ(TM·Array ,TM·CVT)·mount_pe
- ,.mount_pp = Ξ(TM·Array ,TM·CVT)·mount_pp
+ .mount_pe = ·(TM·Array ,TM·CVT)·mount_pe
+ ,.mount_pp = ·(TM·Array ,TM·CVT)·mount_pp
}
- ,.mount = Ξ(TM·Array ,TM·CVT)·mount
- ,.dismount = Ξ(TM·Array ,TM·CVT)·dismount
+ ,.mount = ·(TM·Array ,TM·CVT)·mount
+ ,.dismount = ·(TM·Array ,TM·CVT)·dismount
- ,.status = Ξ(TM·Array ,TM·CVT)·status
- ,.head_on_format = Ξ(TM·Array ,TM·CVT)·head_on_format
+ ,.status = ·(TM·Array ,TM·CVT)·status
+ ,.head_on_format = ·(TM·Array ,TM·CVT)·head_on_format
- ,.can_read = Ξ(TM·Array ,TM·CVT)·can_read
- ,.on_origin = Ξ(TM·Array ,TM·CVT)·on_origin
- ,.on_rightmost = Ξ(TM·Array ,TM·CVT)·on_rightmost
+ ,.can_read = ·(TM·Array ,TM·CVT)·can_read
+ ,.on_origin = ·(TM·Array ,TM·CVT)·on_origin
+ ,.on_rightmost = ·(TM·Array ,TM·CVT)·on_rightmost
- ,.step = Ξ(TM·Array ,TM·CVT)·step
- ,.step_left = Ξ(TM·Array ,TM·CVT)·step_left
- ,.step_right = Ξ(TM·Array ,TM·CVT)·step_right // Synonym for step
- ,.rewind = Ξ(TM·Array ,TM·CVT)·rewind
+ ,.step = ·(TM·Array ,TM·CVT)·step
+ ,.step_left = ·(TM·Array ,TM·CVT)·step_left
+ ,.step_right = ·(TM·Array ,TM·CVT)·step_right // Synonym for step
+ ,.rewind = ·(TM·Array ,TM·CVT)·rewind
- ,.copy_datum = Ξ(TM·Array ,TM·CVT)·copy_datum
- ,.read = Ξ(TM·Array ,TM·CVT)·read
- ,.write = Ξ(TM·Array ,TM·CVT)·write
+ ,.copy_datum = ·(TM·Array ,TM·CVT)·copy_datum
+ ,.read = ·(TM·Array ,TM·CVT)·read
+ ,.write = ·(TM·Array ,TM·CVT)·write
};
// scrat
-void Ξ(TM·Array ,TM·CVT)·write(Ξ(TM·Array ,TM·CVT) *tm ,TM·CVT *write_pt){
+void ·(TM·Array ,TM·CVT)·write(·(TM·Array ,TM·CVT) *tm ,TM·CVT *write_pt){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
bool flag = true ,s;
- s = Ξ(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
+ s = ·(TM·Array ,TM·CVT)·head_on_format(tm ,flag) == Core·Status·on_track;
Core·Guard·fg.check(&chk ,1 ,s && flag ,"head off format");
Core·Guard·assert(chk);
#endif
// TM struct initializers
Local Core·Status TM·mount_pe(
- TM *tm ,TM·CVT *position ,Ξ(extent_t ,TM·CVT) extent
+ TM *tm ,TM·CVT *position ,·(extent_t ,TM·CVT) extent
){
#ifdef TM·DEBUG
Core·Guard·init_count(chk);
Core·Guard·if_return(chk);
#endif
- Ξ(extent_t ,TM·CVT) extent = pos_rightmost - pos_leftmost);
+ ·(extent_t ,TM·CVT) extent = pos_rightmost - pos_leftmost);
return TM·mount_pe(tm ,pos_leftmost ,extent);
}
+++ /dev/null
-/*
- This will print at compile time as:
-
- example/custom_type.cli.c:6:9: note: ‘#pragma message: C -> 7’
- 6 | #pragma message( STR_VAL(C) )
- | ^~~~~~~
-
- Note the C->7 on the right side of the first line. That printed
- the name of the macro, and its value. This is a 'note' not an 'error'.
-*/
-
-#include "cpp_ext.c"
-#include "Core.lib.c"
-#include "Binding.lib.c"
-
-/*
- This defines the Bespoke type.
-
- Here by 'type' we mean a Tableau to FG table binding.
-*/
-
- #define Binding Bespoke
- #include "Binding.lib.c"
- #define SET__Binding__Bespoke
-
- // This defines the FG table type for Bespoke (aka vtable). Each instance is a different implementation of the type sharing the same interface.
- typedef struct Bespoke·FG{
- void (*version)(Bespoke tm);
- void (*report)(Bespoke tm ,char *mess);
- }Bespoke·FG;
-
- // This defines the Tableau, the data that is given as a first argument of each FG table entry.
- typedef struct Bespoke·Tableau{
-
- }Bespoke·Tableau;
-
- // This creates a FG table to Tableau binding type. We will use this to represent the type.
- // The EQ pattern is required for `FIND_ITEM` to recognize the type:
-
- // these functions will be used for making an instance of the abstract Bespoke type
-
- void Bespoke·version(Bespoke tm){ printf("version 1.0\n"); };
- void Bespoke·report(Bespoke tm ,char *mess){ printf("The report: %s\n" ,mess);};
-
-
-int main(){
-
- printf("running example binding.cli.c on %s at %s\n", __DATE__, __TIME__);
-
- SHOW(Ξ(Binding·TYPE ,FG));
-
- #define A 5
- SHOW(A);
-
- #define B Ξ(X,Y)
- SHOW(B);
-
- // one FG table will be shared by many instances of Bespoke, maybe all of them
- Bespoke·FG fg = {
- .version = Bespoke·version
- ,.report = Bespoke·report
- };
-
- // The Bespoke·Tableau carries the instance data', often is one to one to a binding.
- Bespoke·Tableau t;
-
- // allocate a binding
- Bespoke spoke;
-
- // Initialize the binding, this the job of a type specific init function.
- // in C we don't know where the user is allocating the data, otherwise we would
- // have a factory instead of an initializer.
- spoke.fg = &fg;
- spoke.tableau = &t;
-
- // direct use of the fg table, the user/programmer should not do this
- fg.version(spoke);
- fg.report(spoke ,"fg.report");
-
- // does the binding have null pointers?
- printf("fg: %p, tableau: %p\n", (void*)spoke.fg, (void*)spoke.tableau);
-
- // calling though the binding
- spoke.fg->version(spoke);
- spoke.fg->report(spoke ,"spoke.fg->report");
-
- printf("and version again\n");
- spoke.fg->version(spoke);
- printf("before Binding·call to version\n");
- Binding·call(spoke ,version);
- printf("after Binding·call to version.\n");
-
- printf("before Binding·call to report\n");
- Binding·call(spoke ,report ,"Binding·call to report");
- printf("after Binding·call to report\n");
-
- return 0;
-}
-
-#define LOCAL
-#include "Core.lib.c"
-
-
--- /dev/null
+/*
+ This will print at compile time as:
+
+ example/custom_type.cli.c:6:9: note: ‘#pragma message: C -> 7’
+ 6 | #pragma message( STR_VAL(C) )
+ | ^~~~~~~
+
+ Note the C->7 on the right side of the first line. That printed
+ the name of the macro, and its value. This is a 'note' not an 'error'.
+*/
+
+#include "cpp_ext.c"
+#include "Core.lib.c"
+#include "Binding.lib.c"
+
+/*
+ This defines the Bespoke type.
+
+ Here by 'type' we mean a Tableau to FG table binding.
+*/
+
+ #define _BINDING_ Bespoke
+ #include "Binding.lib.c"
+ #define SET__Binding__Bespoke
+
+ // This defines the FG table type for Bespoke (aka vtable). Each instance is a different implementation of the type sharing the same interface.
+ typedef struct Bespoke·FG{
+ void (*version)(Bespoke tm);
+ void (*report)(Bespoke tm ,char *mess);
+ }Bespoke·FG;
+
+ // This defines the Tableau, the data that is given as a first argument of each FG table entry.
+ typedef struct Bespoke·Tableau{
+
+ }Bespoke·Tableau;
+
+ // This creates a FG table to Tableau binding type. We will use this to represent the type.
+ // The EQ pattern is required for `FIND_ITEM` to recognize the type:
+
+ // these functions will be used for making an instance of the abstract Bespoke type
+
+ void Bespoke·version(Bespoke tm){ printf("version 1.0\n"); };
+ void Bespoke·report(Bespoke tm ,char *mess){ printf("The report: %s\n" ,mess);};
+
+
+int main(){
+
+ printf("running example binding.cli.c on %s at %s\n", __DATE__, __TIME__);
+
+ SHOW(·(Binding·TYPE ,FG));
+
+ #define A 5
+ SHOW(A);
+
+ #define B ·(X,Y)
+ SHOW(B);
+
+ // one FG table will be shared by many instances of Bespoke, maybe all of them
+ Bespoke·FG fg = {
+ .version = Bespoke·version
+ ,.report = Bespoke·report
+ };
+
+ // The Bespoke·Tableau carries the instance data', often is one to one to a binding.
+ Bespoke·Tableau t;
+
+ // allocate a binding
+ Bespoke spoke;
+
+ // Initialize the binding, this the job of a type specific init function.
+ // in C we don't know where the user is allocating the data, otherwise we would
+ // have a factory instead of an initializer.
+ spoke.fg = &fg;
+ spoke.tableau = &t;
+
+ // direct use of the fg table, the user/programmer should not do this
+ fg.version(spoke);
+ fg.report(spoke ,"fg.report");
+
+ // does the binding have null pointers?
+ printf("fg: %p, tableau: %p\n", (void*)spoke.fg, (void*)spoke.tableau);
+
+ // calling though the binding
+ spoke.fg->version(spoke);
+ spoke.fg->report(spoke ,"spoke.fg->report");
+
+ printf("and version again\n");
+ spoke.fg->version(spoke);
+ printf("before Binding·call to version\n");
+ Binding·call(spoke ,version);
+ printf("after Binding·call to version.\n");
+
+ printf("before Binding·call to report\n");
+ Binding·call(spoke ,report ,"Binding·call to report");
+ printf("after Binding·call to report\n");
+
+ return 0;
+}
+
+#define LOCAL
+#include "Core.lib.c"
+
+
*/
#include "cpp_ext.c"
-#include "Core.lib.c"
-#include "Binding.lib.c"
#include "TM.lib.c"
-#define TM·CVT AU
+#define _TM·CVT_ AU
#include "TM.lib.c"
#define SET__Binding__TM·AU
int main(){
printf("running try_TM.cli.c on %s at %s\n", __DATE__, __TIME__);
- SHOW(Ξ(TM·CVT ,FG)); // TM·AU·FG
- SHOW(Ξ(TM·CVT ,Tableau)); // TM·AU·Tableau
-
// Create a tape with 5 AU values
AU tape[] = {1 ,2 ,3 ,4 ,5};
extent_t·AU extent = sizeof(tape) - 1;
// Init the tableau
-#if 0
+ TM·AU·Array·Tableau t;
+ TM·AU tm = TM·AU·Array·init_pe(&t ,tape ,extent);
- Ξ(TM ,AU)·Tableau t;
- Ξ(TM ,AU)·init_pe(&t ,tape ,extent);
+#if 0
+ if( Binding·call(tm ,Head·on_tape) ){
+ do{
+ printf( "%x" ,Binding·call(tm ,read) );
+ if( Binding·call(tm ,)
- // Allocate a binding
- TM·AU tm;
- tm.fg = &Ξ(TM ,AU)·fg;
- tm.tableau = &t;
- // Call version of the TM status
- printf("Before any operations:\n");
- Binding·call(tm ,rewind);
+ }
+
AU datum = Binding·call(tm ,read);
printf("Initial datum: %u\n", datum);
// Rewind and read again
Binding·call(tm ,rewind);
datum = Binding·call(tm ,read);
+
+
+
printf("After rewind, datum: %u\n", datum);
#endif
}
#define LOCAL
-#include "Core.lib.c"
-#include "Binding.lib.c"
+#define _TM·CVT_ AU
#include "TM.lib.c"
+#define SET__TM·LOCAL__TM·AU