PROC(3)

Table of Contents

Name

proc specifies a product template procedure

Synopsis

%proc procname ( [ param [ , param ] ... ] ) [ param declaration ] ...
[ %declare local C declarations ]
%begin template-stuff %end-proc

Description

The proc section of a product description file specifies a template procedure that is used in the generation of a product. There may be any number of proc sections in a product description file. Template procedures are required only for recursive product generation, but they can be useful in generating non-recursive products as well. Template procedures are called from the template section, or from proc sections, by using the call template construct (see CALL(4) ). A proc section may call itself recursively.

ivy*meta SDTB converts each proc section into a C routine which generates the portion of the product described by the section. The name of the generated C routine is procname, and it is generated in the GEN_x.c file. The params, param declarations and local C declarations are all written in C code, and are copied directly into the generated routine. The template-stuff in the body of the section is written in the template language (see INTRO(4) ).

Each time the template procedure is called, the templatestuff making up its body is generated to the product.

Example

If the source description file includes the following grammar fragment for expressions:
expr: ( id:<[a-z]+>
| const:<[0-9]+>
| op1:expr oper:<[+-]> op2:expr ) then the following proc section would generate stack-based assembly language code for each expression passed to it as an argument:
%proc genexpr(e)
EXPR e;
%begin
%case tag(e)
%when Id
PUSH %(tok(id(e)))
%when Const
PUSHC %(tok(const(e)))
%when Op1
%call genexpr(op1(e)) %call genexpr(op2(2) )
%case tok(oper(e))[0]
%when `+'
ADD
%when `-'
SUB
%end-case
%end-case
%end-proc %* genexpr *%
For example, the input expression:
a + 4
would be converted to:
PUSH A
PUSHC 4
ADD

See Also

TEMPLATE(3)
INTRO(4)
CALL(4)


© 1990 Lucent Technologies, Inc
© 1998 Harmony Software, Inc