Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

open-axiom repository from github

24005 views
1
/*
2
Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd.
3
All rights reserved.
4
Copyright (C) 2007-2010, Gabriel Dos Reis.
5
All rights reserved.
6
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions are
9
met:
10
11
- Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
14
- Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the following disclaimer in
16
the documentation and/or other materials provided with the
17
distribution.
18
19
- Neither the name of The Numerical Algorithms Group Ltd. nor the
20
names of its contributors may be used to endorse or promote products
21
derived from this software without specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
/******************************************************************************
37
*
38
* parse-types.h: HyperDoc parsing routines for node types.
39
*
40
* Copyright The Numerical Algorithms Group Limited 1991, 1992, 1993.
41
*
42
****************************************************************************/
43
44
#include "openaxiom-c-macros.h"
45
#include "debug.h"
46
#include "halloc.h"
47
#include "sockio.h"
48
#include "parse.h"
49
#include "parse-types.h"
50
#include "hyper.h"
51
#include "lex.h"
52
#include "extent.h"
53
#include "cfuns.h"
54
55
using namespace OpenAxiom;
56
57
static void parse_condnode();
58
static void parse_hasreturnto();
59
60
bool gInButton = false;
61
bool gInIf = false;
62
bool gInItems = false;
63
bool gInOptional = false;
64
65
66
static const char* errmess[] = {
67
"place holder",
68
"parsing condition node",
69
"unrecognized keyword"
70
};
71
72
73
/*
74
* htperror(): arguments: msg - like perror it accepts an error
75
* message to be printed erno - the erno which occurred. This is so an
76
* appropriate error message can be printed.
77
*
78
* The prints out the page name, and then the filename in which the error
79
* occurred. If possible it also tries to print out the next ten tokens.
80
*/
81
82
static void
83
htperror(const char* msg, int erno)
84
{
85
char obuff[256];
86
87
/* The first thing I do is create the error message */
88
89
if (erno <= Numerrors) {
90
sprintf(obuff, "%s:%s\n", msg, errmess[erno]);
91
}
92
else {
93
sprintf(obuff, "%s:\n", msg);
94
fprintf(stderr, "Unknown error type %d\n", erno);
95
}
96
fprintf(stderr, "%s", obuff);
97
98
print_page_and_filename();
99
100
print_next_ten_tokens();
101
}
102
103
void
104
parse_ifcond()
105
{
106
TextNode *ifnode = curr_node;
107
TextNode *endif;
108
TextNode *condnode;
109
110
/*
111
* parse a conditional. At first I am just going to parse if
112
* <hypertext> fi
113
*/
114
if (gInIf) {
115
curr_node->type = openaxiom_Noop_token;
116
fprintf(stderr, "\\if found within \\if \n");
117
longjmp(jmpbuf, 1);
118
fprintf(stderr, "Longjump failed, Exiting\n");
119
exit(-1);
120
}
121
gInIf = true;
122
curr_node->type = openaxiom_Ifcond_token;
123
curr_node->space = token.id[-1];
124
curr_node->data.ifnode = alloc_ifnode();
125
/* Now get the cond node I hope */
126
127
condnode = curr_node->data.ifnode->cond = alloc_node();
128
curr_node = condnode;
129
parse_condnode();
130
131
endif = alloc_node();
132
endif->type = openaxiom_Endif_token;
133
ifnode->data.ifnode->thennode = alloc_node();
134
curr_node = ifnode->data.ifnode->thennode;
135
parse_HyperDoc();
136
if (token.type == openaxiom_Fi_token) {
137
curr_node->type = openaxiom_Fi_token;
138
curr_node->next = endif;
139
ifnode->data.ifnode->elsenode = endif;
140
}
141
else if (token.type == openaxiom_Else_token) {
142
/* first finish up the then part */
143
curr_node->type = openaxiom_Fi_token;
144
curr_node->next = endif;
145
/* the go and parse the else part */
146
ifnode->data.ifnode->elsenode = alloc_node();
147
curr_node = ifnode->data.ifnode->elsenode;
148
parse_HyperDoc();
149
if (token.type != openaxiom_Fi_token) {
150
token_name(token.type);
151
curr_node->type = openaxiom_Noop_token;
152
fprintf(stderr, "Expected a \\fi not a %s", ebuffer);
153
longjmp(jmpbuf, 1);
154
fprintf(stderr, "Longjump failed, Exiting\n");
155
exit(-1);
156
}
157
curr_node->type = openaxiom_Fi_token;
158
curr_node->next = endif;
159
}
160
else {
161
curr_node->type = openaxiom_Noop_token;
162
token_name(token.type);
163
fprintf(stderr, "Expected a \\fi not a %s", ebuffer);
164
longjmp(jmpbuf, 1);
165
fprintf(stderr, "Longjump failed, Exiting\n");
166
exit(-1);
167
}
168
ifnode->next = ifnode->data.ifnode->thennode;
169
ifnode->width = -1; /* A flag for compute if extents */
170
curr_node = endif;
171
gInIf = false;
172
}
173
174
static void
175
parse_condnode()
176
{
177
get_token();
178
179
switch (token.type) {
180
case openaxiom_Cond_token:
181
curr_node->type = openaxiom_Cond_token;
182
curr_node->data.text = alloc_string(token.id);
183
break;
184
case openaxiom_Haslisp_token:
185
case openaxiom_Hasreturn_token:
186
case openaxiom_Lastwindow_token:
187
case openaxiom_Hasup_token:
188
curr_node->type = token.type;
189
break;
190
case openaxiom_Boxcond_token:
191
curr_node->type = openaxiom_Boxcond_token;
192
curr_node->data.text = alloc_string(token.id);
193
break;
194
case openaxiom_Hasreturnto_token:
195
parse_hasreturnto();
196
break;
197
default:
198
{
199
char eb[128];
200
token_name(token.type);
201
sprintf(eb, "Unexpected Token %s\n", eb);
202
htperror(eb, HTCONDNODE);
203
}
204
break;
205
}
206
}
207
208
static void
209
parse_hasreturnto()
210
{
211
TextNode *hrt = curr_node, *arg_node = alloc_node();
212
213
curr_node->type = openaxiom_Hasreturnto_token;
214
curr_node = arg_node;
215
get_expected_token(openaxiom_Lbrace_token);
216
parse_HyperDoc();
217
curr_node->type = openaxiom_Endarg_token;
218
hrt->data.node = arg_node;
219
curr_node = hrt;
220
}
221
222
void
223
parse_newcond()
224
{
225
char label[256];
226
227
get_expected_token(openaxiom_Lbrace_token);
228
get_expected_token(openaxiom_Unkeyword_token);
229
strcpy(label, token.id);
230
get_expected_token(openaxiom_Rbrace_token);
231
insert_cond(label, "0");
232
curr_node->type = openaxiom_Noop_token;
233
}
234
235
void
236
parse_setcond()
237
{
238
char label[256], cond[256];
239
240
get_expected_token(openaxiom_Lbrace_token);
241
get_expected_token(openaxiom_Cond_token);
242
strcpy(label, token.id);
243
get_expected_token(openaxiom_Rbrace_token);
244
get_expected_token(openaxiom_Lbrace_token);
245
get_expected_token(openaxiom_Word_token);
246
strcpy(cond, token.id);
247
get_expected_token(openaxiom_Rbrace_token);
248
change_cond(label, cond);
249
curr_node->type = openaxiom_Noop_token;
250
}
251
252
void
253
parse_begin_items()
254
{
255
TextNode *bi = curr_node;
256
257
/*
258
* This procedure parses a begin item. It sets the current
259
* node and sees if there is an optional argument for the itemspace
260
*/
261
262
bi->type = token.type;
263
get_token();
264
if (token.type == openaxiom_Lsquarebrace_token) {
265
bi->data.node = alloc_node();
266
curr_node = bi->data.node;
267
gInOptional = true;
268
parse_HyperDoc();
269
gInOptional = false;
270
curr_node->type = openaxiom_Enddescription_token;
271
if (token.type != openaxiom_Rsquarebrace_token) {
272
fprintf(stderr, "(HyperDoc) Optional arguments must end with ].\n");
273
print_next_ten_tokens();
274
print_page_and_filename();
275
jump();
276
}
277
curr_node = bi;
278
}
279
else
280
unget_token();
281
gInItems = true;
282
}
283
284
void
285
parse_item()
286
{
287
if (!gInItems) {
288
fprintf(stderr, "\\item found outside an items environment\n");
289
print_page_and_filename();
290
print_next_ten_tokens();
291
jump();
292
}
293
curr_node->type = openaxiom_Item_token;
294
get_token();
295
if (token.type == openaxiom_Lsquarebrace_token) {
296
/* I should parse the optional argument */
297
curr_node->next = alloc_node();
298
curr_node = curr_node->next;
299
curr_node->type = openaxiom_Description_token;
300
curr_node->next = alloc_node();
301
curr_node = curr_node->next;
302
gInOptional = true;
303
parse_HyperDoc();
304
gInOptional = false;
305
curr_node->type = openaxiom_Enddescription_token;
306
if (token.type != openaxiom_Rsquarebrace_token) {
307
fprintf(stderr, "(HyperDoc) Optional arguments must end with ].\n");
308
print_next_ten_tokens();
309
print_page_and_filename();
310
jump();
311
}
312
}
313
else {
314
unget_token();
315
}
316
}
317
318
void
319
parse_mitem()
320
{
321
if (!gInItems) {
322
fprintf(stderr, "\\mitem found outside an items environment\n");
323
print_page_and_filename();
324
print_next_ten_tokens();
325
jump();
326
}
327
curr_node->type = openaxiom_Mitem_token;
328
}
329
330
char *vbuf = NULL;
331
int vbuf_size = 0;
332
333
#define VbufSlop 10
334
#define resizeVbuf()\
335
if (size == vbuf_size) { \
336
vbuf = resizeBuffer(size + VbufSlop, vbuf, &vbuf_size); \
337
vb = vbuf + size; \
338
}
339
340
#define new_verb_node() \
341
resizeVbuf(); \
342
*vb = '\0'; \
343
curr_node->data.text = alloc_string(vbuf); \
344
curr_node->next = alloc_node(); \
345
curr_node = curr_node->next; \
346
curr_node->type = openaxiom_Newline_token; \
347
curr_node->next = alloc_node(); \
348
curr_node = curr_node->next; \
349
curr_node->type = type; \
350
if (*end_string == '\n') es = end_string+1; \
351
else es = end_string; \
352
size = 0; \
353
vb = vbuf;
354
355
void
356
parse_verbatim(int type)
357
{
358
int size = 0, c;
359
char *vb = vbuf;
360
const char *end_string;
361
const char* es;
362
363
curr_node->type = type;
364
if (token.id[-1])
365
curr_node->space = 1;
366
if (type == openaxiom_Spadsrctxt_token) {
367
es = end_string = "\n\\end{spadsrc}";
368
}
369
else if (type == openaxiom_Math_token)
370
es = end_string = "$";
371
else
372
es = end_string = "\\end{verbatim}";
373
while ((c = get_char()) != EOF) {
374
resizeVbuf();
375
size++;
376
if (c == '\n') {
377
new_verb_node();
378
continue;
379
}
380
*vb++ = c;
381
if (*es++ != c)
382
es = end_string;
383
if (!*es)
384
break;
385
}
386
if (c == EOF) {
387
fprintf(stderr, "parse_verbatim: Unexpected EOF found\n");
388
longjmp(jmpbuf, 1);
389
}
390
resizeVbuf();
391
if (*end_string == '\n')
392
es = end_string + 1;
393
else
394
es = end_string;
395
vbuf[size - strlen(es)] = '\0';
396
if (*vbuf) {
397
curr_node->data.text = alloc_string(vbuf);
398
curr_node->next = alloc_node();
399
curr_node = curr_node->next;
400
}
401
if (type == openaxiom_Spadsrctxt_token)
402
curr_node->type = openaxiom_Endspadsrc_token;
403
else if (type == openaxiom_Math_token)
404
curr_node->type = openaxiom_Endmath_token;
405
else
406
curr_node->type = openaxiom_Endverbatim_token;
407
}
408
409
void
410
parse_input_pix()
411
{
412
TextNode *pixnode;
413
char *filename;
414
415
pixnode = curr_node;
416
pixnode->type = token.type;
417
pixnode->space = token.id[-1];
418
pixnode->width = -1;
419
get_expected_token(openaxiom_Lbrace_token);
420
filename = get_input_string();
421
pixnode->data.text = alloc_string(filename);
422
curr_node = pixnode;
423
if (pixnode->type == openaxiom_Inputimage_token) {
424
char f[256];
425
char *p;
426
427
if ((gXDisplay && DisplayPlanes(gXDisplay, gXScreenNumber) == 1) || gSwitch_to_mono ==1) {
428
pixnode->type = openaxiom_Inputbitmap_token;
429
strcpy(f, pixnode->data.text);
430
strcat(f, ".bm");
431
p=pixnode->data.text;
432
pixnode->data.text = alloc_string(f);
433
free(p);
434
}
435
else {
436
pixnode->type = openaxiom_Inputpixmap_token;
437
strcpy(f, pixnode->data.text);
438
#ifdef OLD
439
strcat(f, ".pm");
440
#endif
441
strcat(f, ".xpm.Z");
442
p=pixnode->data.text;
443
pixnode->data.text = alloc_string(f);
444
free(p);
445
}
446
}
447
}
448
449
void
450
parse_centerline()
451
{
452
curr_node->type = token.type;
453
curr_node->space = token.id[-1];
454
curr_node->width = -1;
455
curr_node->next = alloc_node();
456
curr_node = curr_node->next;
457
get_expected_token(openaxiom_Lbrace_token);
458
parse_HyperDoc();
459
if (token.type != openaxiom_Rbrace_token) {
460
curr_node->type = openaxiom_Noop_token;
461
fprintf(stderr, "(HyperdDoc) \\centerline was expecting a }\n");
462
print_page_and_filename();
463
print_next_ten_tokens();
464
longjmp(jmpbuf, 1);
465
}
466
curr_node->type = openaxiom_Endcenter_token;
467
}
468
469
void
470
parse_command()
471
{
472
TextNode *link_node, *save_node, *arg_node;
473
474
gInButton = true;
475
if (gParserMode == SimpleMode) {
476
curr_node->type = openaxiom_Noop_token;
477
fprintf(stderr, "Parser Error token %s unexpected\n",
478
token_table[token.type]);
479
longjmp(jmpbuf, 1);
480
}
481
gStringValueOk = 1;
482
483
/* set the values for the current node */
484
curr_node->type = token.type;
485
curr_node->space = token.id[-1];
486
487
/* now parse for the label */
488
link_node = curr_node;
489
curr_node->next = alloc_node();
490
curr_node = curr_node->next;
491
get_expected_token(openaxiom_Lbrace_token);
492
parse_HyperDoc();
493
curr_node->type = openaxiom_Endbutton_token;
494
save_node = curr_node;
495
arg_node = alloc_node();
496
curr_node = arg_node;
497
get_expected_token(openaxiom_Lbrace_token);
498
parse_HyperDoc();
499
curr_node->type = openaxiom_Endarg_token;
500
link_node->link = make_link_window(arg_node, link_node->type, 0);
501
gStringValueOk = 0;
502
curr_node = save_node;
503
gInButton = false;
504
}
505
506
void
507
parse_button()
508
{
509
TextNode *link_node, *save_node;
510
511
gInButton = true;
512
if (gParserMode == SimpleMode) {
513
curr_node->type = openaxiom_Noop_token;
514
fprintf(stderr, "Parser Error token %s unexpected\n",
515
token_table[token.type]);
516
longjmp(jmpbuf, 1);
517
}
518
/* fill the node */
519
curr_node->type = token.type;
520
curr_node->space = token.id[-1];
521
522
/* the save the current node for creating the link and stuff */
523
link_node = curr_node;
524
525
/* then parse the label */
526
curr_node->next = alloc_node();
527
curr_node = curr_node->next;
528
get_expected_token(openaxiom_Lbrace_token);
529
parse_HyperDoc();
530
curr_node->type = openaxiom_Endbutton_token;
531
532
/* now try to get the argument node */
533
save_node = curr_node;
534
get_expected_token(openaxiom_Lbrace_token);
535
save_node->data.node = alloc_node();
536
curr_node = save_node->data.node;
537
parse_HyperDoc();
538
curr_node->type = openaxiom_Endarg_token;
539
540
/*
541
* buffer[0] = '\0'; print_to_string(arg_node, buffer + 1);
542
*/
543
link_node->link =
544
make_link_window(save_node->data.node, link_node->type, 0);
545
curr_node = save_node;
546
gInButton = false;
547
}
548
549
extern int example_number;
550
551
void
552
parse_spadcommand(TextNode *spad_node)
553
{
554
/*TextNode *node = NULL;*/
555
556
example_number++;
557
gInButton = true;
558
spad_node->type = token.type;
559
spad_node->space = token.id[-1];
560
get_expected_token(openaxiom_Lbrace_token);
561
cur_spadcom = curr_node;
562
563
spad_node->next = alloc_node();
564
curr_node = spad_node->next;
565
parse_HyperDoc();
566
curr_node->type = openaxiom_Endspadcommand_token;
567
cur_spadcom = NULL;
568
spad_node->link = make_link_window(spad_node->next, spad_node->type, 1);
569
gInButton = false;
570
}
571
572
void
573
parse_spadsrc(TextNode *spad_node)
574
{
575
char buf[512], *c = buf;
576
int ch, start_opts = 0;
577
/*TextNode *node = NULL;*/
578
579
example_number++;
580
gInButton = true;
581
gInSpadsrc = true;
582
spad_node->type = openaxiom_Spadsrc_token;
583
spad_node->space = token.id[-1];
584
585
cur_spadcom = curr_node;
586
spad_node->next = alloc_node();
587
curr_node = spad_node->next;
588
589
do {
590
ch = get_char();
591
if (ch == ']')
592
start_opts = 0;
593
if (start_opts)
594
*c++ = ch;
595
if (ch == '[')
596
start_opts = 1;
597
} while (ch != '\n');
598
*c = '\0';
599
parse_verbatim(openaxiom_Spadsrctxt_token);
600
parse_from_string(buf);
601
602
curr_node->type = openaxiom_Endspadsrc_token;
603
cur_spadcom = NULL;
604
spad_node->link = make_link_window(spad_node->next,
605
openaxiom_Spadsrc_token, 1);
606
gInButton = false;
607
gInSpadsrc = false;
608
}
609
610
void
611
parse_env(TextNode *node)
612
{
613
char *env;
614
char buff[256];
615
char *buff_pntr = &buff[1];
616
int noEnv = 0;
617
618
get_expected_token(openaxiom_Lbrace_token);
619
get_expected_token(openaxiom_Word_token);
620
env = oa_getenv(token.id);
621
622
if (env == NULL) {
623
/** The environment variable was not found **/
624
625
fprintf(stderr, "(HyperDoc) Warning: environment variable \'%s\' was not found.\n",
626
token.id);
627
628
env = halloc(1, "string");
629
env[0] = '\0';
630
noEnv = 1;
631
}
632
633
buff[0] = token.id[-1];
634
strcpy(buff_pntr, env);
635
636
if (noEnv)
637
free(env);
638
639
node->data.text = alloc_string(buff_pntr);
640
node->type = openaxiom_Word_token;
641
642
get_expected_token(openaxiom_Rbrace_token);
643
}
644
645
/*
646
* This parse_value routine accepts an empty {} but makes it a zero instead
647
* of a one. Thus \indent{} is equivelant to \indent{0}
648
*/
649
650
void
651
parse_value1()
652
{
653
TextNode *value_node, *ocn = curr_node;
654
char *s;
655
656
curr_node->type = token.type;
657
curr_node->space = token.id[-1];
658
659
value_node = alloc_node();
660
value_node->type = openaxiom_Word_token;
661
curr_node->data.node = value_node;
662
get_expected_token(openaxiom_Lbrace_token);
663
s = get_input_string();
664
if (!is_number(s)) {
665
fprintf(stderr,
666
"Parser Error: parse for value was expecting a numeric value\n");
667
strcpy(value_node->data.text, "0");
668
}
669
else {
670
value_node->data.text = alloc_string(s);
671
}
672
curr_node = ocn;
673
}
674
675
/*
676
* This command accepts an empty argument command. Thus \space{} is
677
* equivelant \space{1}
678
*/
679
680
void
681
parse_value2()
682
{
683
TextNode *value_node, *ocn = curr_node;
684
char *s;
685
686
curr_node->type = token.type;
687
curr_node->space = token.id[-1];
688
689
value_node = alloc_node();
690
value_node->type = openaxiom_Word_token;
691
curr_node->data.node = value_node;
692
get_expected_token(openaxiom_Lbrace_token);
693
s = get_input_string();
694
if (!is_number(s)) {
695
fprintf(stderr,
696
"Parser Error: parse for value was expecting a numeric value\n");
697
strcpy(value_node->data.text, "1");
698
}
699
else {
700
value_node->data.text = alloc_string(s);
701
}
702
curr_node = ocn;
703
}
704
705
706
/* parse a \table sommand */
707
708
void
709
parse_table()
710
{
711
TextNode *tn = curr_node;
712
713
if (gParserMode != AllMode) {
714
curr_node->type = openaxiom_Noop_token;
715
fprintf(stderr, "Parser Error token %s unexpected\n",
716
token_table[token.type]);
717
longjmp(jmpbuf, 1);
718
}
719
curr_node->type = openaxiom_Table_token;
720
get_expected_token(openaxiom_Lbrace_token);
721
curr_node->next = alloc_node();
722
curr_node = curr_node->next;
723
724
get_token();
725
if (token.type == openaxiom_Lbrace_token) {
726
while (token.type != openaxiom_Rbrace_token) {
727
curr_node->type = openaxiom_Tableitem_token;
728
curr_node->next = alloc_node();
729
curr_node = curr_node->next;
730
parse_HyperDoc();
731
curr_node->type = openaxiom_Endtableitem_token;
732
curr_node->next = alloc_node();
733
curr_node = curr_node->next;
734
get_token();
735
}
736
curr_node->type = openaxiom_Endtable_token;
737
}
738
else { /* a patch for SG for empty tables */
739
if (token.type != openaxiom_Rbrace_token) {
740
token_name(token.type);
741
fprintf(stderr,
742
"Unexpected Token %s found while parsing a table\n",
743
ebuffer);
744
print_page_and_filename();
745
jump();
746
}
747
tn->type = openaxiom_Noop_token;
748
tn->next = NULL;
749
free(curr_node);
750
curr_node = tn;
751
}
752
}
753
754
void
755
parse_box()
756
{
757
curr_node->type = token.type;
758
curr_node->space = token.id[-1];
759
curr_node->width = -1;
760
curr_node->next = alloc_node();
761
curr_node = curr_node->next;
762
get_expected_token(openaxiom_Lbrace_token);
763
parse_HyperDoc();
764
curr_node->type = openaxiom_Endbox_token;
765
}
766
767
void
768
parse_mbox()
769
{
770
curr_node->type = token.type;
771
curr_node->space = token.id[-1];
772
curr_node->width = -1;
773
curr_node->next = alloc_node();
774
curr_node = curr_node->next;
775
get_expected_token(openaxiom_Lbrace_token);
776
parse_HyperDoc();
777
curr_node->type = openaxiom_Endbox_token;
778
}
779
780
void
781
parse_free()
782
{
783
TextNode *free_node = curr_node;
784
785
curr_node->type = token.type;
786
curr_node->space = token.id[-1];
787
curr_node->width = -1;
788
curr_node->data.node = alloc_node();
789
curr_node = curr_node->data.node;
790
get_expected_token(openaxiom_Lbrace_token);
791
parse_HyperDoc();
792
curr_node->type = openaxiom_Endarg_token;
793
curr_node = free_node;
794
}
795
796
void
797
parse_help()
798
{
799
curr_node->type = openaxiom_Noop_token;
800
get_token();
801
if (token.type != openaxiom_Lbrace_token) {
802
token_name(token.type);
803
fprintf(stderr, "\\helppage was expecting a { and not a %s\n", ebuffer);
804
print_page_and_filename();
805
jump();
806
}
807
808
/* before we clobber this pointer we better free the contents (cf. alloc_page) */
809
free(gPageBeingParsed->helppage);
810
gPageBeingParsed->helppage = alloc_string(get_input_string());
811
812
if (token.type != openaxiom_Rbrace_token) {
813
token_name(token.type);
814
fprintf(stderr, "\\helppage was expecting a } and not a %s\n",
815
ebuffer);
816
print_page_and_filename();
817
jump();
818
}
819
}
820
821