|
Perl 6
SMOP sm0p Language: Revision 1
sm0pThe default implementation of the interpreter in SMOP now is pretty lame. The sm0p language is a macro language that will translate from a higher-level meaningfull language to a set of repetitive C calls that noone wants to write by hand. The exemple seems to be the better way to illustrate that.
// c code before here
continuation = q:sm0p {
$current;
___STACK___;
$obj.DESTROYALL();
SMOP__STACK__Operators.move_capturize(
|SMOP__STACK__OPCAPTURE_Move_Capturize.new(2,(3),(),3));
SMOP__STACK__Operators.forget();
SMOP__STACK__Operators.free(|$obj);
___STACK___.goto()
};
// c code after here
This embedded code, that means:
continuation = Stack.new(
Node.new(
result => $current,
continuation => Node.new(
result => ___STACK___,
continuation => Node.new(
responder => ___RI___($obj),
identifier => DESTROYALL,
capture => \( $obj: ),
continuation => Node.new(
responder => ___RI___(SMOP__STACK__Operators),
identifier => move_capturize,
capture => SMOP__STACK__OPCAPTURE_Move_Capturize.new(2,(3),(),3),
continuation => Node.new(
responder => ___RI___(SMOP__STACK__Operators),
identifier => forget,
continuation => Node.new(
responder => ___RI___(SMOP__STACK__Operators),
identifier => free,
capture => $obj,
continuation => Node.new(
responder => ___RI___(___STACK___),
identifier => goto
)
)
)
)
)
)
)
);
Would be translated by a pre-processor to:
continuation =
SMOP_DISPATCH(NULL, SMOP__STACK__Stack, SMOP__ID__new,
smop__stack__stack_new_capture(SMOP__STACK__Stack,
SMOP_DISPATCH(NULL, SMOP__STACK__Node, SMOP__ID__new,
smop__stack__node_new_capture(
NULL, NULL, NULL, NULL, NULL, NULL, NULL, (
SMOP_DISPATCH(NULL, SMOP__STACK__Node, SMOP__ID__new,
smop__stack__node_new_capture(
NULL, NULL, NULL, NULL, NULL, NULL, NULL, (
SMOP_DISPATCH(NULL, SMOP__STACK__Node, SMOP__ID__new,
smop__stack__node_new_capture(
SMOP_RI(obj), DESTROYALL, smop__capture_new_capture(obj, NULL, NULL), NULL, NULL, NULL, NULL, (
SMOP_DISPATCH(NULL, SMOP__STACK__Node, SMOP__ID__new,
smop__stack__node_new_capture(
SMOP_RI(SMOP__STACK__Operators), MOP__ID__move_capturize,
smop__stack__opcapture_move_capturize_new(2, (int[]){3,0}, NULL, 3), NULL, NULL, NULL, NULL, (
SMOP_DISPATCH(NULL, SMOP__STACK__Node, SMOP__ID__new,
smop__stack__node_new_capture(
SMOP_RI(SMOP__STACK__Operators), SMOP__ID__forget, NULL, NULL, NULL, NULL, NULL, (
SMOP_DISPATCH(NULL, SMOP__STACK__Node, SMOP__ID__new,
smop__stack__node_new_capture(
SMOP_RI(SMOP__STACK__Operators), SMOP__ID__free, obj, NULL, NULL, NULL, NULL, (
SMOP_DISPATCH(NULL, SMOP__STACK__Node, SMOP__ID__new,
smop__stack__node_new_capture(
SMOP__RI(___STACK___), goto, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
)
)
), NULL, NULL
)
)
), NULL, NULL
)
)
), NULL, NULL
)
)
), NULL, NULL
)
)
), NULL, ___STACK___
)
)
), NULL, current
)
)
)
);
|