File: node8.html

package info (click to toggle)
kimwitu-doc 10a-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 1,192 kB
  • ctags: 341
  • sloc: makefile: 166; yacc: 125; ansic: 40; lex: 18; sh: 2
file content (149 lines) | stat: -rw-r--r-- 5,013 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.1p1 release (March 2nd, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Attributes of Terms</TITLE>
<META NAME="description" CONTENT="Attributes of Terms">
<META NAME="keywords" CONTENT="tpman">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="tpman.css">
<LINK REL="next" HREF="node9.html">
<LINK REL="previous" HREF="node7.html">
<LINK REL="up" HREF="node6.html">
<LINK REL="next" HREF="node9.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
<A NAME="tex2html223"
 HREF="node9.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
 SRC="/usr/share/latex2html/icons/next.png"></A> 
<A NAME="tex2html219"
 HREF="node6.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
 SRC="/usr/share/latex2html/icons/up.png"></A> 
<A NAME="tex2html213"
 HREF="node7.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
 SRC="/usr/share/latex2html/icons/prev.png"></A> 
<A NAME="tex2html221"
 HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
 SRC="/usr/share/latex2html/icons/contents.png"></A> 
<A NAME="tex2html222"
 HREF="node58.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
 SRC="/usr/share/latex2html/icons/index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html224"
 HREF="node9.html">Storage Options</A>
<B> Up:</B> <A NAME="tex2html220"
 HREF="node6.html">Input</A>
<B> Previous:</B> <A NAME="tex2html214"
 HREF="node7.html">Defining Terms</A>
<BR>
<BR>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION00062000000000000000">&#160;</A>
<A NAME="attr-terms-input">&#160;</A>
<BR>
Attributes of Terms
</H2>

<P>
Phyla can be declared to have
<EM>attributes</EM>
<A NAME="133">&#160;</A>
of a predeclared type.
This type can be any C type, e.g. <I>int</I>, or <I>float</I>.
Of course, it can also be a C type that is generated by <EM>Kimwitu</EM>.
An example phylum with attributes is:
<A NAME="137">&#160;</A>
<PRE><HR><!--lgrindfile: attributed_phylum_example.k 12:13 Jan 17 1997-->
expr:   Plus(expr expr)
|       Minus(expr expr)
|       Neg(expr)
|       Zero()
{       <B>float</B> value = 0;}
;
<HR></PRE>

Here the attribute
<I>value</I>
of type
<I>float</I>
is defined, and initialised with <I>0</I>.
<A NAME="142">&#160;</A>
Multiple attributes can be defined between the curly brackets.
The initialisations are optional.
The type of an attribute can also be a type generated by the term
processor (such as a phylum).

<P>
Attributes serve as a facility to decorate a tree with extra information.
The decoration can be done in arbitrary user code.
The attribute becomes a component of the record that is generated for the phylum.
If <I>x</I> is a value of type <I>expr</I>, then the attribute can be referred to as
<I>x</I>
<!-- MATH: $\rightarrow$ -->
<IMG
 WIDTH="19" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
 SRC="img2.gif"
 ALT="$\rightarrow$"><I>value</I>.

<P>
As the last item of the initialisation  a piece
of arbitrary C, enclosed in curly brackets, is allowed.
In this code the expression <I>$0</I> denotes the term that is being created.
The code is executed after the term has been built completely, and the other
initialisations have been performed.
An alternative way of expressing the above initialisation therefore is:
<PRE><HR><!--lgrindfile: alternative_attribute_initialisation.k 19:44 Oct 21 1992-->
{       <B>float</B> value;
        { $0-&gt;value=0;}}
<HR></PRE>

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html223"
 HREF="node9.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
 SRC="/usr/share/latex2html/icons/next.png"></A> 
<A NAME="tex2html219"
 HREF="node6.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
 SRC="/usr/share/latex2html/icons/up.png"></A> 
<A NAME="tex2html213"
 HREF="node7.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
 SRC="/usr/share/latex2html/icons/prev.png"></A> 
<A NAME="tex2html221"
 HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
 SRC="/usr/share/latex2html/icons/contents.png"></A> 
<A NAME="tex2html222"
 HREF="node58.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
 SRC="/usr/share/latex2html/icons/index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html224"
 HREF="node9.html">Storage Options</A>
<B> Up:</B> <A NAME="tex2html220"
 HREF="node6.html">Input</A>
<B> Previous:</B> <A NAME="tex2html214"
 HREF="node7.html">Defining Terms</A>
<!--End of Navigation Panel-->
<ADDRESS>
<I></I>
<BR><I>2000-04-17</I>
</ADDRESS>
</BODY>
</HTML>