Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<!-- Crown Copyright (c) 1998 -->
<HTML>
<HEAD>
<TITLE>
C++ Producer Guide: TDF generation
</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#400080" ALINK="#FF0000">
<H1>C++ Producer Guide</H1>
<H3>March 1998</H3>
<A HREF="pragma1.html"><IMG SRC="../images/next.gif" ALT="next section"></A>
<A HREF="parse.html"><IMG SRC="../images/prev.gif" ALT="previous section"></A>
<A HREF="index.html"><IMG SRC="../images/top.gif" ALT="current document"></A>
<A HREF="../index.html"><IMG SRC="../images/home.gif" ALT="TenDRA home page">
</A>
<IMG SRC="../images/no_index.gif" ALT="document index"><P>
<HR>
<H2>3.5. TDF generation</H2>
<P>
The TDF encoding as a bitstream is expressed as a series of macros
generated by the <CODE>make_tdf</CODE> tool from the TDF specification
database. Note that the version of the TDF database used contains
a couple of corrections from the standard version:
<OL>
<LI>A construct <CODE>make_token_def</CODE> has been added to represent
a token definition.
<LI>The sort <CODE>diag_tag</CODE> has been added to the edge constructors.
</OL>
The macros generated only handle the encoding of the construct - the
construct parameters need to be encoded by hand (the C producer does
something similar, but including the construct parameters). For example,
<CODE>make_tdf</CODE> generates a macro:
<PRE>
void ENC_plus ( BITSTREAM * ) ;
</PRE>
which encodes the <CODE>plus</CODE> construct (91 as 7 bits in extended
format). A typical use of this macro, for adding the expressions
<CODE>a</CODE> and <CODE>b</CODE> would be:
<PRE>
ENC_plus ( bs ) ;
ENC_impossible ( bs ) ;
bs = enc_exp ( bs, a ) ;
bs = enc_exp ( bs, b ) ;
</PRE>
</P>
<P>
Each function or variable is compiled to TDF as its definition is
encountered. For some definitions, such as inline functions, the
compilation may be deferred until it is clear whether or not the identifier
has been used. There is a final pass over all identifiers during
the variable analysis routines which incorporates this check. Because
of the organisation of a TDF capsule it is necessary to store all
of the compiled TDF in memory until the end of the program, when the
complete capsule, including external tag and token names and linkage
information, is written to the output file.
</P>
<HR>
<P><I>Part of the <A HREF="../index.html">TenDRA Web</A>.<BR>Crown
Copyright © 1998.</I></P>
</BODY>
</HTML>