Commit | Line | Data |
---|---|---|
459ebbd7 C |
1 | /* lex.l - lex ASN.1 analyzer */ |
2 | /* %WARNING% */ | |
3 | ||
4 | %{ | |
5 | #ifndef lint | |
6 | static char *RCSid = "$Header: /f/osi/pepsy/RCS/lex.l.gnrc,v 7.5 91/02/22 09:49:01 mrose Interim $"; | |
7 | #endif | |
8 | ||
9 | /* | |
10 | * $Header: /f/osi/pepsy/RCS/lex.l.gnrc,v 7.5 91/02/22 09:49:01 mrose Interim $ | |
11 | * | |
12 | * | |
13 | * $Log: lex.l.gnrc,v $ | |
14 | * Revision 7.5 91/02/22 09:49:01 mrose | |
15 | * Interim 6.8 | |
16 | * | |
17 | * Revision 7.4 91/01/08 12:49:40 mrose | |
18 | * update | |
19 | * | |
20 | * Revision 7.3 90/12/11 10:33:40 mrose | |
21 | * sync | |
22 | * | |
23 | * Revision 7.2 90/11/11 10:53:55 mrose | |
24 | * update | |
25 | * | |
26 | * Revision 7.1 90/11/04 19:17:10 mrose | |
27 | * update | |
28 | * | |
29 | * Revision 7.0 90/11/03 21:18:11 mrose | |
30 | * *** empty log message *** | |
31 | * | |
32 | */ | |
33 | ||
34 | /* | |
35 | * NOTICE | |
36 | * | |
37 | * Acquisition, use, and distribution of this module and related | |
38 | * materials are subject to the restrictions of a license agreement. | |
39 | * Consult the Preface in the User's Manual for the full terms of | |
40 | * this agreement. | |
41 | * | |
42 | * | |
43 | */ | |
44 | ||
45 | ||
46 | struct table { | |
47 | char *t_keyword; | |
48 | int t_value; | |
49 | int t_porting; | |
50 | }; | |
51 | ||
52 | static struct table reserved[] = { | |
53 | "ABSENT", ABSENT, 0, | |
54 | "ANY", ANY, 0, | |
55 | "APPLICATION", APPLICATION, 0, | |
56 | "BEGIN", BGIN, 0, | |
57 | "BIT", BIT, 0, | |
58 | "BITSTRING", BITSTRING, 0, | |
59 | "BOOLEAN", BOOLEAN, 0, | |
60 | "BY", BY, 0, | |
61 | "CHOICE", CHOICE, 0, | |
62 | "COMPONENT", COMPONENT, 0, | |
63 | "COMPONENTS", COMPONENTS, 0, | |
64 | "COMPONENTSOF", COMPONENTSOF, 0, | |
65 | "DECODER", DECODER, 0, | |
66 | "DEFAULT", DEFAULT, 0, | |
67 | "DEFINED", DEFINED, 0, | |
68 | "DEFINITIONS", DEFINITIONS, 0, | |
69 | "ENCODER", ENCODER, 0, | |
70 | "ENCRYPTED", ENCRYPTED, 0, | |
71 | "END", END, 0, | |
72 | "ENUMERATED", ENUMERATED, 0, | |
73 | "EXPLICIT", EXPLICIT, 0, | |
74 | "EXPORTS", EXPORTS, 0, | |
75 | "FALSE", FALSE, 0, | |
76 | "FROM", FROM, 0, | |
77 | "IDENTIFIER", IDENTIFIER, 0, | |
78 | "IMPLICIT", IMPLICIT, 0, | |
79 | "IMPORTS", IMPORTS, 0, | |
80 | "INCLUDE", INCLUDES, 0, | |
81 | "INTEGER", INTEGER, 0, | |
82 | "MIN", MIN, 0, | |
83 | "MAX", MAX, 0, | |
84 | "NULL", NIL, 0, | |
85 | "OBJECT", OBJECT, 0, | |
86 | "OCTET", OCTET, 0, | |
87 | "OCTETSTRING", OCTETSTRING, 0, | |
88 | "OF", OF, 0, | |
89 | "OPTIONAL", OPTIONAL, 0, | |
90 | "PREFIXES", PREFIXES, 0, | |
91 | "PRESENT", PRESENT, 0, | |
92 | "PRINTER", PRINTER, 0, | |
93 | "PRIVATE", PRIVATE, 0, | |
94 | "REAL", REAL, 0, | |
95 | "SECTIONS", SECTIONS, 0, | |
96 | "SEQUENCE", SEQUENCE, 0, | |
97 | "SEQUENCEOF", SEQUENCEOF, 0, | |
98 | "SET", SET, 0, | |
99 | "SETOF", SETOF, 0, | |
100 | "SIZE", SIZE, 0, | |
101 | "STRING", STRING, 0, | |
102 | "TAGS", TAGS, 0, | |
103 | "TRUE", TRUE, 0, | |
104 | "UNIVERSAL", UNIVERSAL, 0, | |
105 | "WITH", WITH, 0, | |
106 | "PLUS-INFINITY", PLUSINFINITY, 0, | |
107 | "MINUS-INFINITY", MINUSINFINITY, 0, | |
108 | %BEGIN(ROSY)% | |
109 | "OPERATION", OPERATION, 1, | |
110 | "ARGUMENT", ARGUMENT, 0, | |
111 | "RESULT", RESULT, 0, | |
112 | "ERRORS", ERRORS, 0, | |
113 | "LINKED", LINKED, 0, | |
114 | "ERROR", ERROR, 1, | |
115 | "PARAMETER", PARAMETER, 0, | |
116 | /* start new stuff */ | |
117 | "ABSTRACT-OPERATION", OPERATION, 0, | |
118 | "ABSTRACT-ERROR", ERROR, 0, | |
119 | "ABSTRACT", ABSTRACT, 0, | |
120 | "OPERATIONS", OPERATIONS, 0, | |
121 | "CONSUMER", CONSUMER, 0, | |
122 | "SUPPLIER", SUPPLIER, 0, | |
123 | "INVOKES", INVOKES, 0, | |
124 | "PORT", PORT, 0, | |
125 | "PORTS", PORTS, 0, | |
126 | /* refine is beyond me! (JPO) | |
127 | "REFINE", REFINE, 0, | |
128 | "AS", AS, 0, | |
129 | "RECURRING", RECURRING, 0, | |
130 | "VISIBLE", VISIBLE, 0, | |
131 | "PAIRED", PAIRED, 0, | |
132 | */ | |
133 | /* end new stuff */ | |
134 | %END(ROSY)% | |
135 | %BEGIN(MOSY)% | |
136 | "OBJECT-TYPE", OBJECTYPE, 1, | |
137 | "SYNTAX", SYNTAX, 0, | |
138 | "ACCESS", ACCESS, 0, | |
139 | "STATUS", STATUS, 0, | |
140 | %END(MOSY)% | |
141 | NULL, 0 | |
142 | }; | |
143 | ||
144 | %} | |
145 | ||
146 | %% | |
147 | ||
148 | "--" { register int c, d; | |
149 | ||
150 | for (d = 0; c = input (); d = c == '-') | |
151 | if (c == '\n' || (d && c == '-')) | |
152 | break; | |
153 | } | |
154 | [ \t]* { | |
155 | if (yydebug) | |
156 | fprintf (stderr, "WT\n"); | |
157 | } | |
158 | \n { | |
159 | if (yydebug) | |
160 | fprintf (stderr, "NL\n"); | |
161 | } | |
162 | "::=" { | |
163 | if (yydebug) | |
164 | fprintf (stderr, "SY: CCE\n"); | |
165 | return CCE; | |
166 | } | |
167 | "..." { | |
168 | if (yydebug) | |
169 | fprintf (stderr, "SY: DOTDOTDOT\n"); | |
170 | return DOTDOTDOT; | |
171 | } | |
172 | ".." { | |
173 | if (yydebug) | |
174 | fprintf (stderr, "SY: DOTDOT\n"); | |
175 | return DOTDOT; | |
176 | } | |
177 | "." { | |
178 | if (yydebug) | |
179 | fprintf (stderr, "SY: DOT\n"); | |
180 | return DOT; | |
181 | } | |
182 | ";" { | |
183 | if (yydebug) | |
184 | fprintf (stderr, "SY: SEMICOLON"); | |
185 | return SEMICOLON; | |
186 | } | |
187 | "," { | |
188 | if (yydebug) | |
189 | fprintf (stderr, "SY: COMMA\n"); | |
190 | return COMMA; | |
191 | } | |
192 | "{" { | |
193 | if (yydebug) | |
194 | fprintf (stderr, "SY: LBRACE\n"); | |
195 | return LBRACE; | |
196 | } | |
197 | "}" { | |
198 | if (yydebug) | |
199 | fprintf (stderr, "SY: RBRACE\n"); | |
200 | return RBRACE; | |
201 | } | |
202 | "|" { | |
203 | if (yydebug) | |
204 | fprintf (stderr, "SY: BAR\n"); | |
205 | return BAR; | |
206 | } | |
207 | "-" { | |
208 | if (yydebug) | |
209 | fprintf (stderr, "SY: MINUS\n"); | |
210 | return MINUS; | |
211 | } | |
212 | "+" { | |
213 | if (yydebug) | |
214 | fprintf (stderr, "SY: PLUS\n"); | |
215 | return PLUS; | |
216 | } | |
217 | %BEGIN(ROSY)% | |
218 | "[S]" { | |
219 | if (yydebug) | |
220 | fprintf (stderr, "SY: OBJECTSUPPLIER\n"); | |
221 | return OBJECTSUPPLIER; | |
222 | } | |
223 | "[C]" { | |
224 | if (yydebug) | |
225 | fprintf (stderr, "SY: OBJECTCONSUMER\n"); | |
226 | return OBJECTCONSUMER; | |
227 | } | |
228 | %END(ROSY)% | |
229 | "[["|"$"|"<<" { register int tok, c, d, len; | |
230 | register char *cp, *ep, *pp; | |
231 | ||
232 | if (*yytext == '$') | |
233 | tok = VLENGTH; | |
234 | else | |
235 | if (*yytext == '<') | |
236 | tok = CONTROL; | |
237 | else { | |
238 | while((c = input()) == ' ' || c =='\t') | |
239 | continue; | |
240 | switch (c) { | |
241 | case 'a': tok = VALA; | |
242 | break; | |
243 | case 'b': tok = VALB; | |
244 | break; | |
245 | case 'i': tok = VALI; | |
246 | break; | |
247 | case 's': tok = VALS; | |
248 | break; | |
249 | case 'o': tok = VALO; | |
250 | break; | |
251 | case 'x': tok = VALX; | |
252 | break; | |
253 | case 'p': tok = VALP; | |
254 | break; | |
255 | case 'q': tok = VALQ; | |
256 | break; | |
257 | case 'r': tok = VALR; | |
258 | break; | |
259 | case 't': tok = VALT; | |
260 | break; | |
261 | case 'O': tok = VALOID; | |
262 | break; | |
263 | case 'P': tok = PARAMETERTYPE; | |
264 | break; | |
265 | case 'T': tok = VALTYPE; | |
266 | break; | |
267 | case 'E': tok = ENC_FN; | |
268 | break; | |
269 | case 'D': tok = DEC_FN; | |
270 | break; | |
271 | case 'F': tok = FRE_FN; | |
272 | break; | |
273 | default : myyerror ("unknown token: \"%s\"", yytext); | |
274 | break; | |
275 | } | |
276 | if ((c = input()) != ' ' && c != '\t' | |
277 | && c != '\n') | |
278 | yyerror ("syntax error in [[ ... ]]"); | |
279 | } | |
280 | ||
281 | if ((pp = malloc ((unsigned) (len = BUFSIZ))) | |
282 | == NULL) | |
283 | yyerror ("out of memory"); | |
284 | ||
285 | for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { | |
286 | if ((c = input ()) == NULL) | |
287 | yyerror ("end-of-file while reading value"); | |
288 | if ((d == ']' && c == ']' && tok !=CONTROL) || | |
289 | (c == '$' && (tok ==VALX || tok ==VALO)) || | |
290 | (d == '>' && c == '>' && tok ==CONTROL)) { | |
291 | if ((tok == VALX || tok == VALO) && | |
292 | (c != '$')) | |
293 | yyerror("Missing '$' in [[ - ]]"); | |
294 | if (c == '$') {unput(c); *cp = NULL;} | |
295 | else *--cp = NULL; | |
296 | yylval.yy_string = pp; | |
297 | if (yydebug) | |
298 | fprintf (stderr, "VAL: \"%s\"\n", | |
299 | yylval.yy_string); | |
300 | return tok; | |
301 | } | |
302 | if (cp >= ep) { | |
303 | register int curlen = cp - pp; | |
304 | register char *dp; | |
305 | ||
306 | if ((dp = realloc (pp, | |
307 | (unsigned) (len += BUFSIZ))) | |
308 | == NULL) | |
309 | yyerror ("out of memory"); | |
310 | cp = dp + curlen; | |
311 | ep = (pp = dp) + len - 1; | |
312 | } | |
313 | *cp++ = c; | |
314 | } | |
315 | } | |
316 | "[" { | |
317 | if (yydebug) | |
318 | fprintf (stderr, "SY: LBRACKET\n"); | |
319 | return LBRACKET; | |
320 | } | |
321 | "]" { | |
322 | if (yydebug) | |
323 | fprintf (stderr, "SY: RBRACKET\n"); | |
324 | return RBRACKET; | |
325 | } | |
326 | "<" { | |
327 | if (yydebug) | |
328 | fprintf (stderr, "SY: LANGLE\n"); | |
329 | return LANGLE; | |
330 | } | |
331 | "(" { | |
332 | if (yydebug) | |
333 | fprintf (stderr, "SY: LPAREN\n"); | |
334 | return LPAREN; | |
335 | } | |
336 | ")" { | |
337 | if (yydebug) | |
338 | fprintf (stderr, "SY: RPAREN\n"); | |
339 | return RPAREN; | |
340 | } | |
341 | "\*" { | |
342 | if (yydebug) | |
343 | fprintf (stderr, "SY: STAR\n"); | |
344 | return STAR; | |
345 | } | |
346 | [0-9]+ { | |
347 | (void) sscanf (yytext, "%d", &yylval.yy_number); | |
348 | if (yydebug) | |
349 | fprintf (stderr, "LIT: 0x%x\n", yylval.yy_number); | |
350 | return LITNUMBER; | |
351 | } | |
352 | -[0-9]+ { | |
353 | (void) sscanf (yytext, "%d", &yylval.yy_number); | |
354 | if (yydebug) | |
355 | fprintf (stderr, "LIT: 0x%x\n", yylval.yy_number); | |
356 | return LITNUMBER; | |
357 | } | |
358 | '[^'$]*'[BbHh] { register char *cp; register int i; | |
359 | ||
360 | switch (*(cp = yytext + strlen (yytext) - 1)) { | |
361 | case 'H': | |
362 | case 'h': | |
363 | *--cp = NULL; | |
364 | for (cp = yytext + 1; *cp; cp++) | |
365 | if (!isxdigit(*cp)) | |
366 | yyerror ("bad hex string"); | |
367 | yylval.yy_string = new_string(yytext + 1); | |
368 | if (yydebug) | |
369 | fprintf (stderr, | |
370 | "HSTRING: %s\n", yylval.yy_string); | |
371 | return HSTRING; | |
372 | ||
373 | case 'B': | |
374 | case 'b': | |
375 | *--cp = NULL; | |
376 | for (cp = yytext + 1; *cp; cp++) | |
377 | if (*cp != '0' && *cp != '1') | |
378 | yyerror ("bad bit string"); | |
379 | yylval.yy_string = new_string(yytext + 1); | |
380 | if (yydebug) | |
381 | fprintf (stderr, | |
382 | "BSTRING: %s\n", yylval.yy_string); | |
383 | return BSTRING; | |
384 | } | |
385 | yyerror ("illegal string"); | |
386 | } | |
387 | \"[^\"$]*\" { | |
388 | yytext[strlen (yytext) - 1] = NULL; | |
389 | yylval.yy_string = new_string (yytext + 1); | |
390 | if (yydebug) | |
391 | fprintf (stderr, "LIT: \"%s\"\n", yylval.yy_string); | |
392 | return LITSTRING; | |
393 | } | |
394 | [A-Z][A-Za-z0-9-]* { register struct table *t; | |
395 | ||
396 | for (t = reserved; t -> t_keyword; t++) | |
397 | if (strcmp (t -> t_keyword, yytext) == 0) { | |
398 | if (yyporting && t -> t_porting) | |
399 | break; | |
400 | if (yydebug) | |
401 | fprintf (stderr, | |
402 | "KE: \"%s\"\n", yytext); | |
403 | yylval.yy_number = yylineno; | |
404 | return t -> t_value; | |
405 | } | |
406 | yylval.yy_string = new_string (yytext); | |
407 | if (yydebug) | |
408 | fprintf (stderr, "ID: \"%s\"\n", yylval.yy_string); | |
409 | return ID; | |
410 | } | |
411 | [a-z][A-Za-z0-9-]* { yylval.yy_string = new_string (yytext); | |
412 | if (yydebug) | |
413 | fprintf (stderr, "NAME: \"%s\"\n", yylval.yy_string); | |
414 | return NAME; | |
415 | } | |
416 | "%[" { register int c, d, len; | |
417 | register char *cp, *ep, *pp; | |
418 | ||
419 | if ((pp = malloc ((unsigned) (len = BUFSIZ))) | |
420 | == NULL) | |
421 | yyerror ("out of memory"); | |
422 | ||
423 | for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { | |
424 | if ((c = input ()) == NULL) | |
425 | yyerror ("end-of-file while reading value"); | |
426 | if (d == '%' && c == ']' ) { | |
427 | *--cp = NULL; | |
428 | yylval.yy_string = pp; | |
429 | if (yydebug) | |
430 | fprintf (stderr, "VAL: \"%s\"\n", | |
431 | yylval.yy_string); | |
432 | return SCTRL; | |
433 | } | |
434 | if (d == '\n') | |
435 | yyerror ("newline in %[ %] construct"); | |
436 | if (cp >= ep) { | |
437 | register int curlen = cp - pp; | |
438 | register char *dp; | |
439 | ||
440 | if ((dp = realloc (pp, | |
441 | (unsigned) (len += BUFSIZ))) | |
442 | == NULL) | |
443 | yyerror ("out of memory"); | |
444 | cp = dp + curlen; | |
445 | ep = (pp = dp) + len - 1; | |
446 | } | |
447 | *cp++ = c; | |
448 | } | |
449 | } | |
450 | "%{" { register int c, d, len; | |
451 | int mylineno; | |
452 | register char *cp, *ep, *pp; | |
453 | ||
454 | mylineno = yylineno; | |
455 | if ((pp = malloc ((unsigned) (len = BUFSIZ))) | |
456 | == NULL) | |
457 | yyerror ("out of memory"); | |
458 | ||
459 | for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { | |
460 | if ((c = input ()) == NULL) | |
461 | yyerror ("end-of-file while reading action"); | |
462 | if (d == '%' && c == '}') { | |
463 | *--cp = NULL; | |
464 | yylval.yy_action = new_action (pp, mylineno);; | |
465 | if (yydebug) | |
466 | fprintf (stderr, "ACTION: \"%s\", %d\n", | |
467 | yylval.yy_action -> ya_text, | |
468 | yylval.yy_action -> ya_lineno); | |
469 | return ACTION; | |
470 | } | |
471 | if (cp >= ep) { | |
472 | register int curlen = cp - pp; | |
473 | register char *dp; | |
474 | ||
475 | if ((dp = realloc (pp, | |
476 | (unsigned) (len += BUFSIZ))) | |
477 | == NULL) | |
478 | yyerror ("out of memory"); | |
479 | cp = dp + curlen; | |
480 | ep = (pp = dp) + len - 1; | |
481 | } | |
482 | *cp++ = c; | |
483 | } | |
484 | } | |
485 | %BEGIN(PEPSY)% | |
486 | \<[DEP]< { register int c, d, len; | |
487 | int mylineno; | |
488 | register char *cp, *ep, *pp; | |
489 | int c_typ = (yytext[1] == 'D' ? DCHOICE : | |
490 | (yytext[1] == 'E' ? ECHOICE : PCHOICE)); | |
491 | ||
492 | mylineno = yylineno; | |
493 | if ((pp = malloc ((unsigned) (len = BUFSIZ))) | |
494 | == NULL) | |
495 | yyerror ("out of memory"); | |
496 | ||
497 | for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { | |
498 | if ((c = input ()) == NULL) | |
499 | yyerror ("end-of-file while reading action"); | |
500 | if (d == '>' && c == '>') { | |
501 | *--cp = NULL; | |
502 | yylval.yy_action = new_action (pp, mylineno);; | |
503 | if (yydebug) | |
504 | fprintf (stderr,"%cCHOICE: \"%s\", %d\n", | |
505 | yytext[1], | |
506 | yylval.yy_action -> ya_text, | |
507 | yylval.yy_action -> ya_lineno); | |
508 | return c_typ; | |
509 | } | |
510 | if (cp >= ep) { | |
511 | register int curlen = cp - pp; | |
512 | register char *dp; | |
513 | ||
514 | if ((dp = realloc (pp, | |
515 | (unsigned) (len += BUFSIZ))) | |
516 | == NULL) | |
517 | yyerror ("out of memory"); | |
518 | cp = dp + curlen; | |
519 | ep = (pp = dp) + len - 1; | |
520 | } | |
521 | *cp++ = c; | |
522 | } | |
523 | } | |
524 | ||
525 | "%E{" { register int c, d, len; | |
526 | int mylineno; | |
527 | register char *cp, *ep, *pp; | |
528 | ||
529 | mylineno = yylineno; | |
530 | if ((pp = malloc ((unsigned) (len = BUFSIZ))) | |
531 | == NULL) | |
532 | yyerror ("out of memory"); | |
533 | ||
534 | for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { | |
535 | if ((c = input ()) == NULL) | |
536 | yyerror ("end-of-file while reading action"); | |
537 | if (d == '%' && c == '}') { | |
538 | *--cp = NULL; | |
539 | yylval.yy_action = new_action (pp, mylineno);; | |
540 | if (yydebug) | |
541 | fprintf (stderr,"EACTION: \"%s\", %d\n", | |
542 | yylval.yy_action -> ya_text, | |
543 | yylval.yy_action -> ya_lineno); | |
544 | return EACTION; | |
545 | } | |
546 | if (cp >= ep) { | |
547 | register int curlen = cp - pp; | |
548 | register char *dp; | |
549 | ||
550 | if ((dp = realloc (pp, | |
551 | (unsigned) (len += BUFSIZ))) | |
552 | == NULL) | |
553 | yyerror ("out of memory"); | |
554 | cp = dp + curlen; | |
555 | ep = (pp = dp) + len - 1; | |
556 | } | |
557 | *cp++ = c; | |
558 | } | |
559 | } | |
560 | "%D{" { register int c, d, len; | |
561 | int mylineno; | |
562 | register char *cp, *ep, *pp; | |
563 | ||
564 | mylineno = yylineno; | |
565 | if ((pp = malloc ((unsigned) (len = BUFSIZ))) | |
566 | == NULL) | |
567 | yyerror ("out of memory"); | |
568 | ||
569 | for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { | |
570 | if ((c = input ()) == NULL) | |
571 | yyerror ("end-of-file while reading action"); | |
572 | if (d == '%' && c == '}') { | |
573 | *--cp = NULL; | |
574 | yylval.yy_action = new_action (pp, mylineno);; | |
575 | if (yydebug) | |
576 | fprintf (stderr,"DACTION: \"%s\", %d\n", | |
577 | yylval.yy_action -> ya_text, | |
578 | yylval.yy_action -> ya_lineno); | |
579 | return DACTION; | |
580 | } | |
581 | if (cp >= ep) { | |
582 | register int curlen = cp - pp; | |
583 | register char *dp; | |
584 | ||
585 | if ((dp = realloc (pp, | |
586 | (unsigned) (len += BUFSIZ))) | |
587 | == NULL) | |
588 | yyerror ("out of memory"); | |
589 | cp = dp + curlen; | |
590 | ep = (pp = dp) + len - 1; | |
591 | } | |
592 | *cp++ = c; | |
593 | } | |
594 | } | |
595 | "%P{" { register int c, d, len; | |
596 | int mylineno; | |
597 | register char *cp, *ep, *pp; | |
598 | ||
599 | mylineno = yylineno; | |
600 | if ((pp = malloc ((unsigned) (len = BUFSIZ))) | |
601 | == NULL) | |
602 | yyerror ("out of memory"); | |
603 | ||
604 | for (ep = (cp = pp) + len - 1, d = NULL;; d = c) { | |
605 | if ((c = input ()) == NULL) | |
606 | yyerror ("end-of-file while reading action"); | |
607 | if (d == '%' && c == '}') { | |
608 | *--cp = NULL; | |
609 | yylval.yy_action = new_action (pp, mylineno);; | |
610 | if (yydebug) | |
611 | fprintf (stderr,"PACTION: \"%s\", %d\n", | |
612 | yylval.yy_action -> ya_text, | |
613 | yylval.yy_action -> ya_lineno); | |
614 | return PACTION; | |
615 | } | |
616 | if (cp >= ep) { | |
617 | register int curlen = cp - pp; | |
618 | register char *dp; | |
619 | ||
620 | if ((dp = realloc (pp, | |
621 | (unsigned) (len += BUFSIZ))) | |
622 | == NULL) | |
623 | yyerror ("out of memory"); | |
624 | cp = dp + curlen; | |
625 | ep = (pp = dp) + len - 1; | |
626 | } | |
627 | *cp++ = c; | |
628 | } | |
629 | } | |
630 | %END(PEPSY)% | |
631 | . { | |
632 | myyerror ("unknown token: \"%s\"", yytext); | |
633 | } | |
634 | ||
635 | %% |