-
Notifications
You must be signed in to change notification settings - Fork 0
/
shilka-3.html
215 lines (197 loc) · 7.71 KB
/
shilka-3.html
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.66">
<TITLE>SHILKA (keywords description translator): Generated code</TITLE>
<LINK HREF="shilka-4.html" REL=next>
<LINK HREF="shilka-2.html" REL=previous>
<LINK HREF="shilka.html#toc3" REL=contents>
</HEAD>
<BODY>
<A HREF="shilka-4.html">Next</A>
<A HREF="shilka-2.html">Previous</A>
<A HREF="shilka.html#toc3">Contents</A>
<HR>
<H2><A NAME="s3">3.</A> <A HREF="shilka.html#toc3">Generated code</A></H2>
<P>A specification as described in the previous section is translated by
SHILKA (keywords description translator) into interface and
implementation files having the same names as one of specification
file and correspondingly suffixes `.h' and `.c' (C code) or `.cpp'
(C++ code). By default the interface file is not generated.</P>
<H2><A NAME="ss3.1">3.1</A> <A HREF="shilka.html#toc3.1">C++ code</A>
</H2>
<P>The interface and implementation files consist of the following
definitions of generated macros, types, and functions:
<DL>
<DT><B>Class `KR_recognizer'.</B><DD>
<P>Object of the class describes a keyword recognizer. If the
interface file is generated, the interface file contains the
class. The implementation file contains the class functions
themself. The class has the following public members:
<OL>
<LI>Function
<BLOCKQUOTE><CODE>
<PRE>
`<type> KR_find_keyword (const char *KR_keyword,
int KR_length)'
</PRE>
</CODE></BLOCKQUOTE>
The function has two parameters: keyword being recognized
and length in characters of the keyword. By default the
function returns code of recognized keyword (integer type
or enumeration -- see flag `-enum'). The function will
return value of type given in construction `%type' of the
description file. Usually the value contains some
additional information about recognized keyword.
<P>By default the keyword is suggested to be stored according
to C representation (with zero byte as end marker). If
this is not true, you can use option `-length' during
generation of the keyword recognizer by SHILKA. In this
case the function `strncmp' instead of `strcmp' is used for
keywords comparison.</P>
<P>If option `-inline' has been used, the function is defined
as inline. This can significantly speed up keywords
recognition.</P>
</LI>
<LI>Function
<BLOCKQUOTE><CODE>
<PRE>
`void KR_output_statistics (void)'
</PRE>
</CODE></BLOCKQUOTE>
The function outputs number of occurrences for each keywords
since the keyword recognizer start. The function also
outputs relative frequencies of occurrences (this value is
always nonzero). The frequencies output after work
recognizer on a large typical program can be used for
setting up keyword frequencies in the description file for
generation of faster keyword recognizer.
<P>The function do nothing if SHILKA flag `-strip' has been
used during the keyword recognizer or flag `-statistics' has
been not used. Flag `-statistics' simply generates macro
definition `__KR__DEBUG__' which includes code for picking
up and outputting statistics about keyword occurrences.</P>
</LI>
<LI>Function
<BLOCKQUOTE><CODE>
<PRE>
`void KR_reset (void)'
</PRE>
</CODE></BLOCKQUOTE>
The function initiates keyword recognizer.
</LI>
<LI>Constructor
<BLOCKQUOTE><CODE>
<PRE>
`void KR_recognizer (void)'
</PRE>
</CODE></BLOCKQUOTE>
The constructor simply calls function `KR_reset'.
</LI>
<LI>Destructor
<BLOCKQUOTE><CODE>
<PRE>
`~KR_recognizer (void)'
</PRE>
</CODE></BLOCKQUOTE>
This destructor is for accurate finish work with the keyword
recognizer.</LI>
</OL>
</P>
<DT><B>Macros or enumeration (see option `-enum')</B><DD>
<P>which declare keyword codes. Macros or enumeration constants
have the same name as one in the description file and prefix
`KR_' (see also option `-p'). SHILKA generates additional code
`KR__not_found'. By default such code means that any keyword
is not found. Macros or enumeration are generated in interface
file only if option `-export' is present on SHILKA command
line. By default, the macros or the enumeration are generated
in the implementation file. Usually, the last case means that
only the keyword recognizer implementation file is used, and
the file is included into another C/C++ file.</P>
</DL>
</P>
<H2><A NAME="ss3.2">3.2</A> <A HREF="shilka.html#toc3.2">C code</A>
</H2>
<P>The interface and implementation files consist of the following
definitions of generated macros, types, and functions:
<OL>
<LI>Macros or enumeration (see option `-enum') which declare
keyword codes. Macros or enumeration constants have the same
name as one in the description file and prefix `KR_' (see also
option `-p'). SHILKA generates additional code
`KR__not_found'. By default such code means that any keyword
is not found. Macros or enumeration are generated in interface
file only if option `-export' is present on SHILKA command
line. By default, the macros or the enumeration are generated
in the implementation file. Usually, the last case means that
only the keyword recognizer implementation file is generated,
and the file is included into another C/C++ file.
</LI>
<LI>Function
<BLOCKQUOTE><CODE>
<PRE>
`<type> KR_find_keyword (const char *KR_keyword,
int KR_length)'
</PRE>
</CODE></BLOCKQUOTE>
The function has two parameters: keyword being recognized and
length in characters of the keyword. By default the function
returns code of recognized keyword (integer type or enumeration
-- see flag `-enum'). The function can also return value of
type given in construction `%type' of the description file.
Usually the value contains some additional information about
recognized keyword.
<P>By default the keyword is suggested to be stored according to C
representation (with zero byte as end marker). If this is not
true, you can use option `-length' during generation of the
keyword recognizer by SHILKA. In this case the function
`strncmp' instead of `strcmp' is used for keywords comparison.</P>
<P>If option `-inline' has been used, the function is defined as
inline. This can significantly speed up keywords recognition.</P>
<P>If the interface file is generated, the interface file contains
external definition of the function. The implementation file
contains the function itself.</P>
</LI>
<LI>Function
<BLOCKQUOTE><CODE>
<PRE>
`void KR_reset (void)'
</PRE>
</CODE></BLOCKQUOTE>
The function initiates keyword recognizer. Therefore the
function must be called by the first. If the interface file is
generated, the interface file contains external definition of
the function. The implementation file contains the function
itself.
</LI>
<LI>Function
<BLOCKQUOTE><CODE>
<PRE>
`void KR_output_statistics (void)'
</PRE>
</CODE></BLOCKQUOTE>
The function outputs number of occurrences for each keywords
since the keyword recognizer start. The function also outputs
relative frequencies of occurrences (this value is always
nonzero). The frequencies output after work recognizer on a
large typical program can be used for setting up keyword
frequencies in the description file for generation of faster
keyword recognizer.
<P>The function do nothing if SHILKA flag `-strip' has been used
during the keyword recognizer or flag `-statistics' has been
not used. Flag `-statistics' simply generates macro definition
`__KR__DEBUG__' which includes code for picking up and
outputting statistics about keyword occurrences.</P>
<P>If the interface file is generated, the interface file contains
external definition of the function. The implementation file
contains the function itself.</P>
</LI>
</OL>
</P>
<HR>
<A HREF="shilka-4.html">Next</A>
<A HREF="shilka-2.html">Previous</A>
<A HREF="shilka.html#toc3">Contents</A>
</BODY>
</HTML>