As a convenience to the user, LYMB statements can be gathered into logical groups using the message tick_actions+ to specify each group. When actions is invoked using the tick! message, each group is sent to the parser separately. By using the break! message, the processing of actions can be stopped between groups of LYMB statements.
assume_static_objects_off! Turns off the "assume_static_objects" mode.
compile_on! Turn on compile mode. When compile mode is on, the parser is used only to compile the tick actions and send "tokens" back to the actions object which maintains the compiled actions internally. Actions are compiled only when a "tick!" or "do!" message is sent, and only if the tick_actions have been modified since the last time a compilation was done.
compile_off! Turn off compile mode. At each "tick!" message, the parser is used to parse and execute the actions. If a syntax error occurs during compilation, this message is automatically issued to ensure that the actions object does not attempt to execute a partially generated token sequence.
tick! invoke the LYMB statements contained in the instance variable tick_actions. Each group of LYMB statements is processed separately.
do! same as the "tick!" action.
tick_actions= LYMB statements set the tick actions. Any previously set actions are discarded.
tick_actions+ LYMB statements add to the list of tick actions. The group of LYMB statements provided to this message will be parsed separately from any other LYMB statements.
tick_actions? Print the tick actions.
break! stop parsing the actions block after completion of the current group of LYMB staments.
/* * Create an actions instance that prints itself */ actions new: action_1 tick_actions=( "! print myself", "action_1 print!;" ) ;
/* Now we can use tick! or do! to run the action. */
action_1 do!;
The second example shows how to use actions in conjunction with the logic object to stop processing the actions. Very useful for error processing.
/* * Create an actions to check string for correct value. If not * correct, action aborts. Runs inconjuntion with logic and string * instances. */ logic new: if;
string new: null="";
actions new: print_string tick_actions= `if equal: (null,astring) true: `print_string break!;'; ' tick_actions+ ( `! This is the string', `astring print:value;' ) ;
string new: astring=""; print_string tick!; -- shouldn't print
astring = `Hello world'; -- should print print_string tick!;