<<<<<<<<<<<<<<<<<

alias_gener(prog_tools) Programming Tools alias_gener(prog_tools)

NAME

alias_generator - generate and manage aliases for the LYMB parser

DESCRIPTION

The alias_generator class manages a table of aliases that allows the same LYMB script to be read in repeatedly, each time generating a different set of objects. This is useful in situations where macro creation and expansion is desired. The macro can simply be a LYMB script that is read in whenever needed. By generating aliases using the alias_generator class and enabling alias expansion in the parser, a LYMB script can be read in repeatedly, generating different objects each time.

SUPERCLASS

object

INSTANCE VARIABLES

none.

MESSAGES

names= (name1,name2,...) Sets the list of names for which aliases will be generated to the list of arguments.

names+ (name1,name2,...) Adds the arguments to the list of names for which aliases will be generated.

names- (name1,name2,...) Removes the arguments from the list of names for which aliases will be generated.

names? Returns all names stored in the top stack frame.

generate_aliases! generates aliases for all active names.

aliases? returns all aliases for the names in the top stack frame.

push! opens a new level of alias expansion.

pop! closes the current level of alias expansion, releasing all name/alias pairs for the current level.

EXAMPLE

The following example demonstrates how a LYMB script might be structured so it could be loaded repeatedly (effectively treated as a macro).

/* define aliases for the various objects we will be creating */ alias_generator push! names=(`form', `up', `down', `label', `up_actions', `down_actions') generate_aliases! ; parser expand_aliases_on!;

alias_generator print:aliases;

/* create the objects, aliasing along the way */ motif_form_dialog new: `form' parent=`motif' create! ;

motif_arrow_button new: `up' parent=`form' @ `arrowDirection' : XmARROW_UP @ `topAttachment' : XmATTACH_FORM @ `leftAttachment' : XmATTACH_FORM @ `rightAttachment' : XmATTACH_FORM create! ;

motif_label new: `label' parent=`form' @ `topAttachment' : XmATTACH_WIDGET @ `topWidget' : [up id?] @ `leftAttachment' : XmATTACH_FORM @ `rightAttachment' : XmATTACH_FORM create! ;

motif_arrow_button new: `down' parent=`form' @ `arrowDirection' : XmARROW_DOWN @ `topAttachment' : XmATTACH_WIDGET @ `topWidget' : [label id?] @ `leftAttachment' : XmATTACH_FORM @ `rightAttachment' : XmATTACH_FORM create! ;

actions new: `up_actions' tick_actions=` up print!; ' ;

actions new: `down_actions' tick_actions=` down print!; '

;

/* action compilation is required to expand object names

within tick actions */ up_actions compile!; down_actions compile!;

/* disable alias expansion and get rid of the current

crop of aliases */ parser expand_aliases_off!; alias_generator pop!;

SEE ALSO

parser, actions


Please send comments and suggestions to
consult@rpi.edu