Proteus Macros

Global Macros

The proteus.h header file defines global macros for easy access to each of the Lookup Tables this library uses.

 

 

To make use of any of these globals, an author’s source module must #include the proteus.h header module.

 

 

The globals currently defined in proteus.h are:

 

·          gProteusLU                       a list of the global lookup table instances

·          gSymbols                            the global symbols lookup table

·          gInterfaces                    the global interfaces lookup table

·          gSnapshots                       the global snapshots lookup table

·          gServices                          the global services lookup table

·          gObservables                  the global observables lookup table

·          gObservers                       the global observers lookup table

 

Templates

The templates currently defined in proteus.h are used by ProxyService in order to facilitate the shorthand vocabulary, description, location attributes to the class.

Action Macros

Proteus provides macros for defining derivations of the special action classes defined in diagnostic.t. These macros are allow for the addition of mix-ins in the definition:

 

 

These macros can take mix-ins because in many cases it is convenient to provide a common class for defining the execSystemAction() invoked by the SystemAction class.

 

Verb Macros

Proteus provides macros for defining Verb Rules. The macro DefineVerbRule() is similar to the library’s VerbRule() macro, but takes an optional seq parameter.

 

       DefineVerbRule(tag, seq…)

 

To define a verb using this macro you start by defining the Action, just as you normally would:

 

       DefineTAction(Foo)

                ;

 

Next, you define the grammar alternates list, which must be named tag +  seq + AltList. For example, if our Action is FooAction, and we only need one alternates list for this verb, then our tag is Foo, and we define FooAltList:

 

       #define FooAltList 'foo' dobjList

 

If we wanted to define multiple alternates lists for our FooAction, then we take advantage of the optional seq parameter:

 

                #define Foo1AltList 'foo' 'bar' dobjList

 

Next we define our Verb Rule. Using the DefineVerbRule() macro:

 

DefineVerbRule(Foo)

    verbPhrase = 'foo/fooing (what)'

;

 

DefineVerbRule(Foo, 1)

    verbPhrase = 'foo/fooing (what)'

;

 

 

Notice that the DefineVerbRule() macro will generate the alternates list and superclass list automatically. It is only necessary to assign a verbPhrase to the definition.

 

Complex alternates lists can be spread over multiple lines by using the ‘\’ macro continuation. Suppose we want to define a BazAction, like this:

 

DefineTAction(Baz)

;

 

#define BazAltList \

    'foo' \

    ('bar'|'bars') \

    'baz' dobjList

 

DefineVerbRule(Baz)

    verbPhrase = 'baz/bazing (what)'

;

 

 

This file is part of the TADS 3 Proteus Library Extension

Copyright © 2001-2004 Kevin Forchione. All rights reserved.