AGPUTS(5)

Table of Contents

Name

agputs
outputs directly to a product file
agprintf
outputs a formatted string to a product file
SET_LINE
outputs a #line directive for included code
RESET_LINE
outputs a #line directive at end of included code
INCLUDE
outputs a text segment with #line directives
LINCLUDE
outputs a text segment with #line directives
set_column
spaces to specified column in a product file itabwidth width of the input tab character otabwidth width of the output tab character
cur_column
current column in a product file
cur_line
current line in a product file

Synopsis

VOID agputs(str)
STRING str;
VOID agprintf(str [ , arg ]... )
STRING str;
VOID SET_LINE(tree)
ANY tree;
VOID RESET_LINE()
VOID INCLUDE(tree)
ANY tree;
VOID LINCLUDE(tree)
ANY tree;
VOID set_column(col)
int col;
INT itabwidth, otabwidth, cur_column, cur_line;

Description

These components of the run-time library are used for the generation of product files; they can only be used in product description files or in C code that is called from product description files. The one exception to this rule is the itabwidth variable, which specifies the number of spaces represented by a tab in the specification input. Its default value is eight; the value can be reset in the startcode section.

The agputs and agprintf functions are identical to the C library routines puts and printf with two exceptions: the output goes to the product file (instead of standard output), and the two variables, cur_column and cur_line, are updated. These two variables always specify the column and line numbers of the next character to be output to the current product file. The variable otabwidth specifies the width of the output tab character.

The SET_LINE and RESET_LINE macros are used to place accurate source tracing information about included files into product files. Each macro outputs a #line directive to the current product file. Other tools, such as the C compiler, use these directives to generate error messages that refer back to the original source files, rather than the current product file. The SET_LINE macro requires a tree argument which is used to determine the beginning line number and file name of source to be included in the product file (see BEGLINE(5) ). The RESET_LINE macro is used at the end of included code to change the line number and file name back to that of the current product file. The INCLUDE macro provides a short cut for placing included source text into the current product file, while also surrounding the included text with the correct #line directives. The INCLUDE macro outputs the frontier of its argument node, preceded by a call to SET_LINE and followed by a RESET_LINE (see example). The macro LINCLUDE is similar to INCLUDE; LINCLUDE outputs the frontier of a list of nodes rather than the frontier of a single node.

The set_column function outputs characters to the product file until cur_column equals the value of the argument C expression. A newline is output if the C expression is initially greater than cur_column. Then tabs and blanks are output until the correct column is reached. The %col(Cexpr) format construct (see FORMAT(4) ) uses set_column.

Example

The following balanced lex-token (see GRAMMAR(2) ) may be used to define escapes to the C language that may be included in specification files.
ccode: balance «{» <[^{}]*> «}"
Given this rule, the following may be placed in a product template section to copy the escape to the product file, while also surrounding the escape with the proper #line directives (in this example, x is of type CCODE): %{SET_LINE(x);} %(whitespace(x))%(tok(x)) %{RESET_LINE();}
This is equivalent to:
%{INCLUDE(x);}
For instance, if the source of an escape began on line 15 of the specification file abc_file, and the body of the escape were ``{a = 5;}'', then the product file (say named main.c) would contain something like:
#line 15 «abc_file"
{a = 5;}
#line 23 «main.c"

See Also

GRAMMAR(2)
STARTCODE(2)
BEGLINE(4)
FORMAT(4)
FRONTIER(5)
REPORTINFO(5)


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