2 |
7u83 |
1 |
<!-- Crown Copyright (c) 1998 -->
|
|
|
2 |
<HTML>
|
|
|
3 |
<HEAD>
|
|
|
4 |
<TITLE>
|
|
|
5 |
C++ Producer Guide: TDF generation
|
|
|
6 |
</TITLE>
|
|
|
7 |
</HEAD>
|
|
|
8 |
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#400080" ALINK="#FF0000">
|
|
|
9 |
|
|
|
10 |
<H1>C++ Producer Guide</H1>
|
|
|
11 |
<H3>March 1998</H3>
|
|
|
12 |
<A HREF="pragma1.html"><IMG SRC="../images/next.gif" ALT="next section"></A>
|
|
|
13 |
<A HREF="parse.html"><IMG SRC="../images/prev.gif" ALT="previous section"></A>
|
|
|
14 |
<A HREF="index.html"><IMG SRC="../images/top.gif" ALT="current document"></A>
|
|
|
15 |
<A HREF="../index.html"><IMG SRC="../images/home.gif" ALT="TenDRA home page">
|
|
|
16 |
</A>
|
|
|
17 |
<IMG SRC="../images/no_index.gif" ALT="document index"><P>
|
|
|
18 |
<HR>
|
|
|
19 |
|
|
|
20 |
<H2>3.5. TDF generation</H2>
|
|
|
21 |
<P>
|
|
|
22 |
The TDF encoding as a bitstream is expressed as a series of macros
|
|
|
23 |
generated by the <CODE>make_tdf</CODE> tool from the TDF specification
|
|
|
24 |
database. Note that the version of the TDF database used contains
|
|
|
25 |
a couple of corrections from the standard version:
|
|
|
26 |
<OL>
|
|
|
27 |
<LI>A construct <CODE>make_token_def</CODE> has been added to represent
|
|
|
28 |
a token definition.
|
|
|
29 |
<LI>The sort <CODE>diag_tag</CODE> has been added to the edge constructors.
|
|
|
30 |
</OL>
|
|
|
31 |
The macros generated only handle the encoding of the construct - the
|
|
|
32 |
construct parameters need to be encoded by hand (the C producer does
|
|
|
33 |
something similar, but including the construct parameters). For example,
|
|
|
34 |
<CODE>make_tdf</CODE> generates a macro:
|
|
|
35 |
<PRE>
|
|
|
36 |
void ENC_plus ( BITSTREAM * ) ;
|
|
|
37 |
</PRE>
|
|
|
38 |
which encodes the <CODE>plus</CODE> construct (91 as 7 bits in extended
|
|
|
39 |
format). A typical use of this macro, for adding the expressions
|
|
|
40 |
<CODE>a</CODE> and <CODE>b</CODE> would be:
|
|
|
41 |
<PRE>
|
|
|
42 |
ENC_plus ( bs ) ;
|
|
|
43 |
ENC_impossible ( bs ) ;
|
|
|
44 |
bs = enc_exp ( bs, a ) ;
|
|
|
45 |
bs = enc_exp ( bs, b ) ;
|
|
|
46 |
</PRE>
|
|
|
47 |
</P>
|
|
|
48 |
<P>
|
|
|
49 |
Each function or variable is compiled to TDF as its definition is
|
|
|
50 |
encountered. For some definitions, such as inline functions, the
|
|
|
51 |
compilation may be deferred until it is clear whether or not the identifier
|
|
|
52 |
has been used. There is a final pass over all identifiers during
|
|
|
53 |
the variable analysis routines which incorporates this check. Because
|
|
|
54 |
of the organisation of a TDF capsule it is necessary to store all
|
|
|
55 |
of the compiled TDF in memory until the end of the program, when the
|
|
|
56 |
complete capsule, including external tag and token names and linkage
|
|
|
57 |
information, is written to the output file.
|
|
|
58 |
</P>
|
|
|
59 |
|
|
|
60 |
<HR>
|
|
|
61 |
<P><I>Part of the <A HREF="../index.html">TenDRA Web</A>.<BR>Crown
|
|
|
62 |
Copyright © 1998.</I></P>
|
|
|
63 |
</BODY>
|
|
|
64 |
</HTML>
|