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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
/* l2xusrlb.c user-defined support functions for l2x actions */
/* Written by Peter Wilson (Catholic University and NIST) */
/* Development of this software was funded by the United States Government,
* and is not subject to copyright.
*/
#include <stdio.h>
#ifndef STRTYPES_H
#include "strtypes.h"
#endif
#ifndef L2XCOM_H
#include "l2xcom.h"
#endif
#include "l2xytab.h" /* parser communication */
#include "l2xlib.h" /* l2x system library functions */
#include "l2xacts.h" /* l2x standard actions */
/* lexer/parser communication */
extern int opt_param;
/* In general, actions are specified via case statements
* in the special_ functions at the end of this file. The
* special actions must be provided by the extender.
*/
/* The system special_ functions */
void special_start_with_req();
void special_action_p_p1();
void special_action_last_p();
void special_start_with_opt();
void special_action_opt_first();
void special_action_p_opt();
void special_action_last_opt();
void special_action_no_param();
/* extender-provided functions */
void prwboiler1();
void prwboiler2();
void prwboiler3();
void codespecial_start();
void codespecial_p1();
void codespecial_end();
/* FUNCTIONS, ETC. TO BE PROVIDED BY THE EXTENDER */
/* demonstration string definition */
STRING boiler_string_3 = "\nin the middle of it.\n\n";
/* demonstration functions */
char codebuf[80]; /* a string buffer */
/* PRWBOILER1 print some demonstration boilerplate */
void prwboiler1()
{
myprint("\nSome boilerplate text with ");
} /* end PRWBOILER1 */
/* PRWBOILER2 print some demonstration boilerplate */
void prwboiler2()
{
myprint("\nin the middle. Now there is\n");
myprint("some more boilerplate with ");
} /* end PRWBOILER2 */
/* PRWBOILER3 yet more demonstration boilerplate */
void prwboiler3()
{
myprint(boiler_string_3);
} /* end PRWBOILER1 */
/* CODESPECIAL_START actions for start of CODEspecial command */
void codespecial_start(pos)
PSENTRY pos; /* symbol entry */
{
start_section(pos); /* do start of sectioning */
tag_print(get_t(pos)); /* print start tag */
} /* end CODESPECIAL_START */
/* CODESPECIAL_P1 actions at stast of CODEspecial param 1 */
void codespecial_p1(pos)
PSENTRY pos; /* symbol entry */
{
tag_print(get_tag_t(pos,1)); /* print 1st param start tag */
initialise_sysbuf(); /* clear system string buffer */
set_print(p_print_to_sysbuf); /* put param text into system buffer */
} /* end CODESPECIAL_P1 */
/* CODESPECIAL_END actions at end of CODEspecial command */
void codespecial_end(pos)
PSENTRY pos; /* symbol entry */
{
initialise_string(codebuf); /* clear this string buffer */
copy_sysbuf(codebuf); /* copy system buffer into this buffer */
reset_print(); /* normal printing */
prwboiler1(); /* print some boilerplate */
print_sysbuf(); /* print system buffer */
prwboiler2(); /* print more boilerplate */
myprint(codebuf); /* print this buffer */
prwboiler3(); /* print yet more boilerplate */
start_list(pos); /* start a list environment */
} /* end CODESPECIAL_END */
/*==================================================================*/
/* SYSTEM SPECIAL_ FUNCTIONS FOR INCORPORATING EXTENDER */
/* SPECIFIED CASE STATEMENTS FOR USER-DEFINED SPECIAL COMMANDS */
/* SPECIAL_START_WITH_REQ special action at start of command with req param */
void special_start_with_req(pos)
PSENTRY pos; /* symbol entry */
{
int special_kind; /* user-specified special token */
special_kind = get_special_token(pos);
switch(special_kind) {
/* additional cases for specials added here */
/* end of cases for specials */
default: /* should not be here! */
warning("(special_start_with_req) Unrecognized SPECIAL");
tdebug_str_int("SPECIAL_TOKEN =",special_kind);
break;
} /* end of switch on user_kind */
} /* end SPECIAL_START_WITH_REQ */
/* SPECIAL_ACTION_P_P1 special action between p'th and (p+1)'th req params */
void special_action_p_p1(pos,p)
PSENTRY pos; /* symbol entry */
int p; /* number of p'th req param */
{
int special_kind; /* user-specified special token */
special_kind = get_special_token(pos);
switch(special_kind) {
/* additional cases for specials added here */
/* end of cases for specials */
default: /* should not be here! */
warning("(special_action_p_p1) Unrecognized SPECIAL");
tdebug_str_int("SPECIAL_TOKEN =",special_kind);
break;
} /* end of switch on user_kind */
} /* end SPECIAL_ACTION_P_P1 */
/* SPECIAL_ACTION_LAST_P special action after last req param */
void special_action_last_p(pos,p)
PSENTRY pos; /* symbol entry */
int p; /* number of last req param */
{
int special_kind; /* user-specified special token */
special_kind = get_special_token(pos);
switch(special_kind) {
/* additional cases for specials added here */
case 59999: /* example coded special */
if (p == 1) { /* has only 1 req param */
codespecial_end(pos);
}
break;
/* end of cases for specials */
default: /* should not be here! */
warning("(special_action_last_p) Unrecognized SPECIAL");
tdebug_str_int("SPECIAL_TOKEN =",special_kind);
break;
} /* end of switch on user_kind */
} /* end SPECIAL_ACTION_LAST_P */
/* SPECIAL_START_WITH_OPT special start for command with opt param */
void special_start_with_opt(pos)
PSENTRY pos; /* symbol entry */
{
int special_kind; /* user-specified special token */
special_kind = get_special_token(pos);
switch(special_kind) {
/* additional cases for specials added here */
case 59999: /* example coded special */
codespecial_start(pos);
default_start_with_opt(pos);
break;
/* end of cases for specials */
default: /* should not be here! */
warning("(special_start_with_opt) Unrecognized SPECIAL");
tdebug_str_int("SPECIAL_TOKEN =",special_kind);
break;
} /* end of switch on user_kind */
} /* end SPECIAL_START_WITH_OPT */
/* SPECIAL_ACTION_OPT_FIRST special action between opt and 1st param */
void special_action_opt_first(pos)
PSENTRY pos; /* symbol entry */
{
int special_kind; /* user-specified special token */
special_kind = get_special_token(pos);
switch(special_kind) {
/* additional cases for specials added here */
case 59999: /* example coded special */
default_end_start_opt(pos);
codespecial_p1(pos);
break;
/* end of cases for specials */
default: /* should not be here! */
warning("(special_action_opt_first) Unrecognized SPECIAL");
tdebug_str_int("SPECIAL_TOKEN =",special_kind);
break;
} /* end of switch on user_kind */
} /* end SPECIAL_ACTION_OPT_FIRST */
/* SPECIAL_ACTION_P_OPT special action between param p and opt */
void special_action_p_opt(pos,p)
PSENTRY pos; /* symbol entry */
int p; /* number of p'th req param */
{
int special_kind; /* user-specified special token */
special_kind = get_special_token(pos);
switch(special_kind) {
/* additional cases for specials added here */
/* end of cases for specials */
default: /* should not be here! */
warning("(special_action_p_opt) Unrecognized SPECIAL");
tdebug_str_int("SPECIAL_TOKEN =",special_kind);
break;
} /* end of switch on user_kind */
} /* end SPECIAL_ACTION_P_OPT */
/* SPECIAL_ACTION_LAST_OPT special action after last opt param */
void special_action_last_opt(pos)
PSENTRY pos; /* symbol entry */
{
int special_kind; /* user-specified special token */
special_kind = get_special_token(pos);
switch(special_kind) {
/* additional cases for specials added here */
/* end of cases for specials */
default: /* should not be here! */
warning("(special_action_last_opt) Unrecognized SPECIAL");
tdebug_str_int("SPECIAL_TOKEN =",special_kind);
break;
} /* end of switch on user_kind */
} /* end SPECIAL_ACTION_LAST_OPT */
/* SPECIAL_ACTION_NO_PARAM special action for command with no params */
void special_action_no_param(pos)
PSENTRY pos; /* symbol entry */
{
int special_kind; /* user-specified special token */
special_kind = get_special_token(pos);
switch(special_kind) {
/* additional cases for specials added here */
/* end of cases for specials */
default: /* should not be here! */
warning("(special_action_no_param) Unrecognized SPECIAL");
tdebug_str_int("SPECIAL_TOKEN =",special_kind);
break;
} /* end of switch on user_kind */
} /* end SPECIAL_ACTION_NO_PARAM */
|