1 | %{ |
---|
2 | /**************************************** |
---|
3 | * Computer Algebra System SINGULAR * |
---|
4 | ****************************************/ |
---|
5 | /* $Id: libparse.l,v 1.49 2001-10-23 14:04:23 Singular Exp $ */ |
---|
6 | #include <stdio.h> |
---|
7 | #include <string.h> |
---|
8 | #include <stdlib.h> |
---|
9 | #include <ctype.h> |
---|
10 | #ifdef STANDALONE_PARSER |
---|
11 | #include "utils.h" |
---|
12 | #define HAVE_LIBPARSER |
---|
13 | #define YYLPDEBUG 1 |
---|
14 | #else |
---|
15 | #include "mod2.h" |
---|
16 | #include "subexpr.h" |
---|
17 | #include "grammar.h" |
---|
18 | #include "ipshell.h" |
---|
19 | #include "ipid.h" |
---|
20 | #include "tok.h" |
---|
21 | #include "febase.h" |
---|
22 | #include "omalloc.h" |
---|
23 | #endif |
---|
24 | #include "libparse.h" |
---|
25 | |
---|
26 | #ifdef HAVE_LIBPARSER |
---|
27 | #define YY_SKIP_YYWRAP |
---|
28 | |
---|
29 | typedef enum { LP_NONE, LP_INFO, LP_CATEGORY, LP_VERSION} lib_cmds; |
---|
30 | |
---|
31 | int libread(FILE* f, char* buf, int max_size); |
---|
32 | int current_pos(int i); |
---|
33 | void print_version(lp_modes mode, char *p); |
---|
34 | #ifdef HAVE_NAMESPACES |
---|
35 | void copy_string(lp_modes mode, idhdl pl); |
---|
36 | #else /* HAVE_NAMESPACES */ |
---|
37 | void copy_string(lp_modes mode); |
---|
38 | #endif /* HAVE_NAMESPACES */ |
---|
39 | extern void piCleanUp(procinfov pi); |
---|
40 | void make_version(char *p, int what); |
---|
41 | |
---|
42 | int brace1 = 0; /* { } */ |
---|
43 | int brace2 = 0; /* ( ) */ |
---|
44 | int brace3 = 0; /* [ ] */ |
---|
45 | int quote = 0; /* " */ |
---|
46 | int offset = 0; |
---|
47 | BOOLEAN p_static = FALSE; |
---|
48 | int old_state = 0; |
---|
49 | lib_cmds last_cmd = LP_NONE; |
---|
50 | |
---|
51 | char libnamebuf[128]; |
---|
52 | char *text_buffer=NULL; |
---|
53 | long string_start; |
---|
54 | |
---|
55 | char *yylp_buffer_start; |
---|
56 | int yylplineno = 1; |
---|
57 | int lpverbose = 0, check = 0; |
---|
58 | int texinfo_out = 0; |
---|
59 | int found_info=0, |
---|
60 | found_cat=0, |
---|
61 | found_version=0, |
---|
62 | found_oldhelp = 0, |
---|
63 | found_proc_in_proc = 0; |
---|
64 | |
---|
65 | char *yylp_errlist[]= { |
---|
66 | "", |
---|
67 | "missing close bracket ')' for proc definition in line %d.", /* 1 */ |
---|
68 | "missing close bracket ')' for procbody in line %d.", /* 2 */ |
---|
69 | "missing close bracket ']' for procbody in line %d.", /* 3 */ |
---|
70 | "too many ')' closed brackets in line %d.", /* 4 */ |
---|
71 | "too many ']' closed brackets in line %d.", /* 5 */ |
---|
72 | "missing close bracket ')' for example in line %d.", /* 6 */ |
---|
73 | "missing close bracket ']' for example in line %d.", /* 7 */ |
---|
74 | "cannot assign character '%c' in line %d to any group.", /* 8 */ |
---|
75 | "there must be a quote missing somewhere before line %d.", /* 9 */ |
---|
76 | "missing close bracket '}' at end of library in line %d.", /* 10 */ |
---|
77 | "missing close bracket ')' at end of library in line %d.", /* 11 */ |
---|
78 | "missing close bracket ']' at end of library in line %d.", /* 12 */ |
---|
79 | NULL |
---|
80 | }; |
---|
81 | int yylp_errno = 0; |
---|
82 | |
---|
83 | #ifdef __MWERKS__ |
---|
84 | #ifdef __cplusplus |
---|
85 | extern "C" { |
---|
86 | #endif |
---|
87 | long ftell(FILE *fp); |
---|
88 | #ifdef macintosh |
---|
89 | int fileno(FILE *stream); |
---|
90 | FILE *fdopen(int filedes, char *type); |
---|
91 | int isatty(int filedes); |
---|
92 | #else |
---|
93 | int _fileno(FILE *stream); |
---|
94 | FILE *_fdopen(int filedes, char *type); |
---|
95 | int _isatty(int filedes); |
---|
96 | #define fileno _fileno |
---|
97 | #define fdopen _fdopen |
---|
98 | #define isatty _isatty |
---|
99 | #endif /* macintosh */ |
---|
100 | #ifdef __cplusplus |
---|
101 | } |
---|
102 | #endif |
---|
103 | #endif |
---|
104 | |
---|
105 | #ifdef STANDALONE_PARSER |
---|
106 | procinfov pi; |
---|
107 | int category_out = 0; |
---|
108 | void printpi(procinfov pi); |
---|
109 | void pi_clear(procinfov pi); |
---|
110 | extern "C" { |
---|
111 | int yylpwrap(); |
---|
112 | } |
---|
113 | void main_init(int argc, char *argv[]); |
---|
114 | void main_result(char *libname); |
---|
115 | #else /* STANDALONE_PARSER */ |
---|
116 | idhdl h0; |
---|
117 | #ifdef HAVE_NAMESPACES |
---|
118 | idhdl h_top; |
---|
119 | extern namehdl namespaceroot; |
---|
120 | #endif /* HAVE_NAMESPACES */ |
---|
121 | #ifdef HAVE_NS |
---|
122 | idhdl h_top; |
---|
123 | #endif |
---|
124 | #define pi IDPROC(h0) |
---|
125 | extern "C" |
---|
126 | { |
---|
127 | int yylpwrap(); |
---|
128 | } |
---|
129 | extern libstackv library_stack; |
---|
130 | #endif /* STANDALONE_PARSER */ |
---|
131 | |
---|
132 | static unsigned long help_chksum; |
---|
133 | |
---|
134 | #define SET_DEF_END(mode, pi, p) \ |
---|
135 | if ( mode == LOAD_LIB) pi->data.s.def_end = p; |
---|
136 | #define SET_HELP_START(mode, pi, p) \ |
---|
137 | if ( mode == LOAD_LIB) {pi->data.s.help_start = p; help_chksum = 0;} |
---|
138 | #define SET_HELP_END(mode, pi, p) \ |
---|
139 | if ( mode == LOAD_LIB) {pi->data.s.help_end = p; \ |
---|
140 | pi->data.s.help_chksum = help_chksum;} |
---|
141 | |
---|
142 | #define SET_BODY_START(mode, pi, l, p) \ |
---|
143 | if ( mode == LOAD_LIB) \ |
---|
144 | { \ |
---|
145 | pi->data.s.body_lineno = l; \ |
---|
146 | pi->data.s.body_start = p; \ |
---|
147 | } |
---|
148 | #define SET_BODY_END(mode, pi, p) \ |
---|
149 | if ( mode == LOAD_LIB) \ |
---|
150 | { \ |
---|
151 | pi->data.s.body_end = p-1; \ |
---|
152 | pi->data.s.proc_end = p-1; \ |
---|
153 | } |
---|
154 | |
---|
155 | #define SET_EXAMPLE_START(mode, pi, l, p) \ |
---|
156 | if ( mode == LOAD_LIB) \ |
---|
157 | { \ |
---|
158 | pi->data.s.example_lineno = l; \ |
---|
159 | pi->data.s.example_start = p; \ |
---|
160 | } |
---|
161 | #define SET_PROC_END(mode, pi, p) \ |
---|
162 | if ( mode == LOAD_LIB) \ |
---|
163 | { \ |
---|
164 | pi->data.s.proc_end = p-1; \ |
---|
165 | if(pi->data.s.body_end==0) \ |
---|
166 | pi->data.s.body_end = p-1; \ |
---|
167 | } |
---|
168 | |
---|
169 | #define ROTATE_RIGHT(c) if ((c) & 01) (c) = ((c) >>1) + 0x8000; else (c) >>= 1; |
---|
170 | #define IncrCheckSum(c) \ |
---|
171 | do \ |
---|
172 | { \ |
---|
173 | ROTATE_RIGHT(help_chksum); \ |
---|
174 | help_chksum += c; \ |
---|
175 | help_chksum &= 0xffff; \ |
---|
176 | } \ |
---|
177 | while(0) |
---|
178 | |
---|
179 | #undef YY_DECL |
---|
180 | #ifdef HAVE_NAMESPACES |
---|
181 | #define YY_DECL int yylex(char *newlib, char *libfile, \ |
---|
182 | lib_style_types *lib_style, \ |
---|
183 | idhdl pl, BOOLEAN autoexport, lp_modes mode) |
---|
184 | #else /* HAVE_NAMESPACES */ |
---|
185 | #ifdef HAVE_NS |
---|
186 | #define YY_DECL int yylex(char *newlib, char *libfile, \ |
---|
187 | lib_style_types *lib_style, \ |
---|
188 | idhdl pl, BOOLEAN autoexport, lp_modes mode) |
---|
189 | #else |
---|
190 | #define YY_DECL int yylex(char *newlib, char *libfile, \ |
---|
191 | lib_style_types *lib_style, \ |
---|
192 | lp_modes mode) |
---|
193 | #endif /* HAVE_NS */ |
---|
194 | #endif /* HAVE_NAMESPACES */ |
---|
195 | |
---|
196 | #undef YY_INPUT |
---|
197 | #define YY_INPUT(buf,result,max_size) \ |
---|
198 | if ( ((result = libread( (yyin), (char *) buf, max_size )) < 0 ) \ |
---|
199 | && ferror( yyin ) ) \ |
---|
200 | YY_FATAL_ERROR( "read in flex scanner failed" ); |
---|
201 | |
---|
202 | #define YY_USER_INIT { \ |
---|
203 | BEGIN(header); \ |
---|
204 | yylplineno = 1; \ |
---|
205 | yylp_errno = 0; \ |
---|
206 | *lib_style = OLD_LIBSTYLE; \ |
---|
207 | strcpy(libnamebuf,"(**unknown version**)"); \ |
---|
208 | } |
---|
209 | |
---|
210 | #if 0 |
---|
211 | <pbody>proc[ \t]+{name} { |
---|
212 | printf("MISSING: PROC-cmd found. ERROR!\n"); } |
---|
213 | <pbody>example[ \t]*\n { |
---|
214 | yylplineno++; |
---|
215 | printf("MISSING: EXAMPLE-cmd found. ERROR!\n"); } |
---|
216 | info=+"\"" { |
---|
217 | #endif |
---|
218 | |
---|
219 | %} |
---|
220 | |
---|
221 | digit [0-9] |
---|
222 | letter [@a-zA-Z\'] |
---|
223 | name ({letter}({letter}*{digit}*_*)*|_) |
---|
224 | varname ({letter}({letter}*{digit}*_*\(\))*|_|#) |
---|
225 | letters ({letter}|{digit}|[_./#%^*:,]) |
---|
226 | string ({letters}*) |
---|
227 | comment [\/][\/] |
---|
228 | dolar [$] |
---|
229 | nls [\n\r] |
---|
230 | symbols [~!@#$%^&*()_+-=\\\|\[\];:,<.>/\?\' \t\~\`] |
---|
231 | asymbols ({symbols}|[{}]) |
---|
232 | bsymbols ({symbols}|{escbrack}|[}]) |
---|
233 | aletters ({letter}|{digit}|{asymbols}|{dolar}|{escquote}|{nls}) |
---|
234 | bletters ({letter}|{digit}|{bsymbols}|{dolar}|{quote}|{nls}) |
---|
235 | cletters ({letter}|{digit}|{asymbols}|{dolar}|{quote}) |
---|
236 | strings ({aletters}*) |
---|
237 | escstrings ({bletters}*) |
---|
238 | fstring ({cletters}*) |
---|
239 | param ({name}+{tos}+{varname}) |
---|
240 | parameters ({param}(,{param})*) |
---|
241 | paramlist ("("{parameters}")") |
---|
242 | quote [\"] |
---|
243 | escquote (\\\") |
---|
244 | escbrack (\\\{) |
---|
245 | tnl ([ \t\n]*) |
---|
246 | eos ({quote}+{tnl}+"{") |
---|
247 | tos ([ \t]*) |
---|
248 | eq ([ \t]*+=[ \t]*) |
---|
249 | eqnl ([ \t\n]*+=[ \t\n]*) |
---|
250 | |
---|
251 | /* %start START */ |
---|
252 | |
---|
253 | %x header |
---|
254 | %x help |
---|
255 | %x libcmd |
---|
256 | %x libcmd2 |
---|
257 | %x pdef |
---|
258 | %x phead |
---|
259 | %x poldhelp |
---|
260 | %x phelp |
---|
261 | %x pbody |
---|
262 | %x pstr |
---|
263 | %x pexample |
---|
264 | %x pestr |
---|
265 | %x string |
---|
266 | %x comment |
---|
267 | %x info |
---|
268 | %x category |
---|
269 | %x version |
---|
270 | |
---|
271 | %% |
---|
272 | (\/\/[^\n]*)|(^#![^\n]*)|([ \t]) { } |
---|
273 | \/\/* { old_state = YYSTATE; BEGIN(comment); } |
---|
274 | |
---|
275 | (info+{eqnl}+{quote}+{strings}+{quote}) { |
---|
276 | yyless(4); old_state = YYSTATE; BEGIN(info); |
---|
277 | } |
---|
278 | (category+{eqnl}+{quote}+{strings}+{quote}) { |
---|
279 | yyless(8); old_state = YYSTATE; BEGIN(category); |
---|
280 | } |
---|
281 | (version+{eqnl}+{quote}+{strings}+{quote}) { |
---|
282 | found_version++; |
---|
283 | if ( mode != GET_INFO ) |
---|
284 | { |
---|
285 | make_version(yytext,1); |
---|
286 | #ifdef STANDALONE_PARSER |
---|
287 | if (texinfo_out) |
---|
288 | { |
---|
289 | char *c = libnamebuf; |
---|
290 | printf("$version = \""); |
---|
291 | while (*c != '\0') |
---|
292 | { |
---|
293 | if (*c == '$' || *c == '@') putchar('\\'); |
---|
294 | if (*c != '\r') putchar(*c); |
---|
295 | if (*c == '\\') |
---|
296 | { |
---|
297 | c++; |
---|
298 | if (*c != '"') putchar('\\'); |
---|
299 | } |
---|
300 | else |
---|
301 | c++; |
---|
302 | } |
---|
303 | printf("\";\n"); |
---|
304 | } |
---|
305 | else if (!category_out) |
---|
306 | printf("Version:%s;\n", libnamebuf); |
---|
307 | #else |
---|
308 | //#ifdef HAVE_NAMESPACES |
---|
309 | //h0 = enterid( "version", myynest, STRING_CMD, |
---|
310 | // &IDPACKAGE(pl)->idroot, FALSE ); |
---|
311 | //if (h0!=NULL) |
---|
312 | //{ |
---|
313 | // IDSTRING(h0) = omStrDup(libnamebuf); |
---|
314 | //} |
---|
315 | //#else /* HAVE_NAMESPACES */ |
---|
316 | if (text_buffer!=NULL) omFree((ADDRESS)text_buffer); |
---|
317 | text_buffer = omStrDup(libnamebuf); |
---|
318 | omMarkAsStaticAddr(text_buffer); |
---|
319 | //#endif /* HAVE_NAMESPACES */ |
---|
320 | #endif |
---|
321 | } |
---|
322 | } |
---|
323 | |
---|
324 | static { p_static=TRUE; } |
---|
325 | |
---|
326 | (proc[ \t]+{name})|([ \t]proc[ \t]+{name}) { |
---|
327 | char proc[256]; |
---|
328 | BEGIN(pdef); |
---|
329 | found_proc_in_proc = 0; |
---|
330 | proc[0]='\0'; |
---|
331 | sscanf( yytext, "%*[^p]proc %s", proc); |
---|
332 | if(strlen(proc)<1) sscanf( yytext, "proc %s", proc); |
---|
333 | #if YYLPDEBUG > 1 |
---|
334 | printf("Newlib:%s\n", newlib); |
---|
335 | #endif |
---|
336 | #ifdef STANDALONE_PARSER |
---|
337 | if ( pi != NULL ) |
---|
338 | { |
---|
339 | printpi(pi); |
---|
340 | pi_clear(pi); |
---|
341 | } |
---|
342 | #ifdef STANDALONE_PARSER |
---|
343 | pi = (procinfo *)malloc(sizeof(procinfo)); |
---|
344 | #else |
---|
345 | pi = (procinfo *)omAlloc(sizeof(procinfo)); |
---|
346 | #endif |
---|
347 | iiInitSingularProcinfo(pi, newlib, proc, yylplineno, |
---|
348 | current_pos(0), p_static); |
---|
349 | #else STANDALONE_PARSER |
---|
350 | if( mode == LOAD_LIB) |
---|
351 | { |
---|
352 | #ifdef HAVE_NAMESPACES |
---|
353 | h0 = enterid( proc, 0 /*myynest*/, PROC_CMD, |
---|
354 | &IDPACKAGE(pl)->idroot, TRUE); |
---|
355 | if(!p_static && autoexport) |
---|
356 | { |
---|
357 | namespaceroot->push( NSPACK(namespaceroot->root) ,""); |
---|
358 | h_top = enterid( proc, myynest, PROC_CMD, |
---|
359 | &NSROOT(namespaceroot->root), FALSE ); |
---|
360 | namespaceroot->pop(); |
---|
361 | } |
---|
362 | #else /* HAVE_NAMESPACES */ |
---|
363 | #ifdef HAVE_NS |
---|
364 | h0 = enterid( proc, 0 /*myynest*/, PROC_CMD, |
---|
365 | &(IDPACKAGE(pl)->idroot), TRUE); |
---|
366 | if(!p_static && autoexport) |
---|
367 | { |
---|
368 | h_top = enterid( proc, 0 /*myynest*/, PROC_CMD, |
---|
369 | &(basePack->idroot), FALSE ); |
---|
370 | } |
---|
371 | #else |
---|
372 | h0 = enterid( proc, 0 /*myynest*/, PROC_CMD, |
---|
373 | &IDROOT, TRUE ); |
---|
374 | #endif /* HAVE_NS */ |
---|
375 | #endif /* HAVE_NAMESPACES */ |
---|
376 | /* omCheckAddr(IDID(h0)); */ |
---|
377 | if (h0!=NULL) |
---|
378 | { |
---|
379 | iiInitSingularProcinfo(IDPROC(h0), newlib, proc, |
---|
380 | yylplineno, current_pos(0),p_static); |
---|
381 | #ifdef HAVE_NAMESPACES |
---|
382 | if (!p_static && h_top != NULL && autoexport) |
---|
383 | { |
---|
384 | if(IDPROC(h_top)!=NULL) piCleanUp((procinfo *)IDPROC(h_top)); |
---|
385 | IDPROC(h_top)=IDPROC(h0); |
---|
386 | IDPROC(h_top)->ref++; |
---|
387 | } |
---|
388 | #endif /* HAVE_NAMESPACES */ |
---|
389 | #ifdef HAVE_NS |
---|
390 | if (!p_static && h_top != NULL && autoexport) |
---|
391 | { |
---|
392 | if(IDPROC(h_top)!=NULL) piCleanUp((procinfo *)IDPROC(h_top)); |
---|
393 | IDPROC(h_top)=IDPROC(h0); |
---|
394 | IDPROC(h_top)->ref++; |
---|
395 | } |
---|
396 | IDPROC(h0)->pack=IDPACKAGE(pl); |
---|
397 | #endif /* HAVE_NS */ |
---|
398 | if (BVERBOSE(V_LOAD_PROC)) |
---|
399 | Warn( " proc '%s' registered", proc ); |
---|
400 | } |
---|
401 | #endif STANDALONE_PARSER |
---|
402 | SET_DEF_END(mode, pi, current_pos(yyleng+1)); |
---|
403 | #if YYLPDEBUG |
---|
404 | if(lpverbose) |
---|
405 | { |
---|
406 | printf("// PROCEDURE '%s' status: %s, ", proc, |
---|
407 | p_static ? "local" : "global"); |
---|
408 | printf("starting at line %d,%d: definition end: %d (%d).\n", |
---|
409 | yylplineno, current_pos(0), (int)pi->data.s.def_end, brace1); |
---|
410 | } |
---|
411 | #endif |
---|
412 | p_static=FALSE; |
---|
413 | #ifndef STANDALONE_PARSER |
---|
414 | } |
---|
415 | #endif STANDALONE_PARSER |
---|
416 | } |
---|
417 | example { |
---|
418 | BEGIN(pexample); |
---|
419 | SET_EXAMPLE_START(mode, pi, yylplineno, current_pos(0)); |
---|
420 | #if YYLPDEBUG |
---|
421 | if(lpverbose) |
---|
422 | { |
---|
423 | printf("// EXAMPLE at line %d,%d (%d)\n", yylplineno, |
---|
424 | current_pos(0), brace1); |
---|
425 | } |
---|
426 | #endif |
---|
427 | } |
---|
428 | |
---|
429 | LIB[ \t]+"\"" { quote++; |
---|
430 | BEGIN(libcmd); |
---|
431 | } |
---|
432 | |
---|
433 | LIB[ \t]*"(\"" { quote++; brace2++; |
---|
434 | BEGIN(libcmd2); |
---|
435 | } |
---|
436 | |
---|
437 | <header>({comment}+{tos}+{dolar}+Id:+{string}+[^\n]*)|({comment}+{tos}+{dolar}+Header:+{string}+[^\n]*) { |
---|
438 | make_version(yytext, 0); |
---|
439 | #if YYLPDEBUG > 1 |
---|
440 | printf("+(id)HEAD:%s\n", yytext); |
---|
441 | #endif |
---|
442 | } |
---|
443 | <header>(^{comment}+[^\n]*) { |
---|
444 | #if YYLPDEBUG |
---|
445 | printf("+(cmt)HEAD:%s\n", yytext); |
---|
446 | #endif |
---|
447 | } |
---|
448 | <header>(^#![^\n]*) { |
---|
449 | #if YYLPDEBUG > 1 |
---|
450 | printf("-HEAD:%s\n", yytext); |
---|
451 | #endif |
---|
452 | } |
---|
453 | <header>^proc\ { yyless(0); |
---|
454 | BEGIN(INITIAL); |
---|
455 | yymore(); |
---|
456 | } |
---|
457 | <header>(info+{eqnl}+{quote})|(version+{eqnl}+{quote})|(category+{eqnl}+{quote}) { |
---|
458 | yyless(0); |
---|
459 | *lib_style = NEW_LIBSTYLE; |
---|
460 | BEGIN(INITIAL); |
---|
461 | yymore(); |
---|
462 | } |
---|
463 | |
---|
464 | <header>^LIB[ \t]+"\"" { quote++; |
---|
465 | BEGIN(libcmd); |
---|
466 | } |
---|
467 | <header>^LIB[ \t]+"(\"" { quote++; brace2++; |
---|
468 | BEGIN(libcmd2); |
---|
469 | } |
---|
470 | <header>\n { yylplineno++; } |
---|
471 | <header>. { |
---|
472 | #if YYLPDEBUG > 1 |
---|
473 | printf(" HEAD:%s\n", yytext); |
---|
474 | #endif |
---|
475 | yyless(0); |
---|
476 | BEGIN(help); |
---|
477 | } |
---|
478 | <help>(^{comment}+[^\n]*) { |
---|
479 | #if YYLPDEBUG > 1 |
---|
480 | printf(" HELP:%s\n", yytext); |
---|
481 | #endif |
---|
482 | BEGIN(INITIAL); } |
---|
483 | <help>(^#![^\n]*) { |
---|
484 | #if YYLPDEBUG > 1 |
---|
485 | printf(" HELP:%s\n", yytext); |
---|
486 | #endif |
---|
487 | BEGIN(INITIAL); |
---|
488 | } |
---|
489 | <help>(info+{eqnl}+{quote})|(version+{eqnl}+{quote})|(category+{eqnl}+{quote}) { |
---|
490 | yyless(0); |
---|
491 | *lib_style = NEW_LIBSTYLE; |
---|
492 | BEGIN(INITIAL); |
---|
493 | yymore(); |
---|
494 | } |
---|
495 | <help>^proc\ { |
---|
496 | yyless(0); |
---|
497 | //printf("2) proc found.\n"); |
---|
498 | BEGIN(INITIAL); |
---|
499 | yymore(); |
---|
500 | } |
---|
501 | <help>^LIB[ \t]+"\"" { quote++; |
---|
502 | BEGIN(libcmd); |
---|
503 | } |
---|
504 | <help>^LIB[ \t]+"(\"" { quote++; brace2++; |
---|
505 | BEGIN(libcmd2); |
---|
506 | } |
---|
507 | |
---|
508 | <help>\n { yylplineno++; } |
---|
509 | <help>({tos}|{comment}+{fstring}) { |
---|
510 | #if YYLPDEBUG |
---|
511 | if(lpverbose>2) printf("--->%s<---\n", yytext); |
---|
512 | #endif |
---|
513 | } |
---|
514 | <help>. { |
---|
515 | found_oldhelp=1; |
---|
516 | #if YYLPDEBUG > 1 |
---|
517 | printf("-HELP:%s\n", yytext); |
---|
518 | #endif |
---|
519 | } |
---|
520 | |
---|
521 | |
---|
522 | <libcmd>{string}"\"" { quote--; |
---|
523 | yytext[yyleng-1] = '\0'; |
---|
524 | #ifndef STANDALONE_PARSER |
---|
525 | if ( mode == LOAD_LIB ) |
---|
526 | { |
---|
527 | library_stack->push(newlib, yytext); |
---|
528 | } |
---|
529 | #endif /* STANDALONE_PARSER */ |
---|
530 | #if YYLPDEBUG |
---|
531 | if(lpverbose>1) printf("LIB:'%s'\n", yytext); |
---|
532 | #endif |
---|
533 | BEGIN(INITIAL); |
---|
534 | } |
---|
535 | <libcmd2>{string}"\")" { quote--; brace2--; |
---|
536 | yytext[yyleng-1] = '\0'; |
---|
537 | #ifndef STANDALONE_PARSER |
---|
538 | if ( mode == LOAD_LIB ) |
---|
539 | { |
---|
540 | library_stack->push(newlib, yytext); |
---|
541 | } |
---|
542 | #endif /* STANDALONE_PARSER */ |
---|
543 | #if YYLPDEBUG |
---|
544 | if(lpverbose>1) printf("LIB:'%s'\n", yytext); |
---|
545 | #endif |
---|
546 | BEGIN(INITIAL); |
---|
547 | } |
---|
548 | |
---|
549 | <pdef>[ \t] { } |
---|
550 | <pdef>\( { |
---|
551 | brace2++; |
---|
552 | #if YYLPDEBUG > 1 |
---|
553 | printf("%s", yytext); |
---|
554 | #endif |
---|
555 | } |
---|
556 | <pdef>\) { |
---|
557 | brace2--; |
---|
558 | #if YYLPDEBUG > 1 |
---|
559 | printf(">%s<\n", yytext); |
---|
560 | printf("{=%d, (=%d, [=%d\n", brace1, brace2, brace3); |
---|
561 | #endif |
---|
562 | if(brace2<=0) |
---|
563 | { |
---|
564 | #if YYLPDEBUG > 1 |
---|
565 | printf("BEGIN(phead){=%d, (=%d, [=%d\n", brace1, brace2, brace3); |
---|
566 | #endif |
---|
567 | SET_DEF_END(mode, pi, current_pos(yyleng)); |
---|
568 | BEGIN(phead); |
---|
569 | } |
---|
570 | } |
---|
571 | <pdef>"{" { |
---|
572 | if(brace2>0) |
---|
573 | { |
---|
574 | #if YYLPDEBUG > 1 |
---|
575 | printf("{=%d, (=%d, [=%d\n", brace1, brace2, brace3); |
---|
576 | #endif |
---|
577 | yylp_errno = YYLP_DEF_BR2; |
---|
578 | return(1); |
---|
579 | } |
---|
580 | else |
---|
581 | { |
---|
582 | brace1++; BEGIN(pbody); |
---|
583 | if(lpverbose) |
---|
584 | printf("// BODY at line %d,%d (%d)\n", yylplineno, |
---|
585 | current_pos(0), brace1); |
---|
586 | SET_BODY_START(mode, pi, yylplineno, current_pos(0)); |
---|
587 | } |
---|
588 | } |
---|
589 | <pdef>\n { yylplineno++; |
---|
590 | if(brace2<=0) |
---|
591 | { |
---|
592 | #if YYLPDEBUG > 1 |
---|
593 | printf("BEGIN(phead-2){=%d, (=%d, [=%d\n", brace1, brace2, brace3); |
---|
594 | #endif |
---|
595 | BEGIN(phead); |
---|
596 | } |
---|
597 | } |
---|
598 | <pdef>({comment}[^\n]*) { } |
---|
599 | <pdef>\/\/* { old_state = YYSTATE; BEGIN(comment); } |
---|
600 | <pdef>. { |
---|
601 | if(brace2<=0) |
---|
602 | { |
---|
603 | BEGIN(phead); |
---|
604 | yyless(0); |
---|
605 | } |
---|
606 | } |
---|
607 | |
---|
608 | <phead>({tnl}+{quote}+{strings}+{escquote}+{tnl}+"{") { |
---|
609 | #if YYLPDEBUG |
---|
610 | if(lpverbose>2)printf("0-Len=%d;\n", yyleng); |
---|
611 | #endif |
---|
612 | if(check) |
---|
613 | { |
---|
614 | printf("Procedure %s (line %d) has OLD-STYLE-HELP!\n", |
---|
615 | pi->procname, pi->data.s.proc_lineno); |
---|
616 | } |
---|
617 | SET_HELP_START(mode, pi, current_pos(0)); |
---|
618 | BEGIN(poldhelp); |
---|
619 | yyless(0); |
---|
620 | } |
---|
621 | <phead>({tnl}+{quote}+{strings}+{eos}) { |
---|
622 | #if YYLPDEBUG |
---|
623 | if(lpverbose>2)printf("1-Len=%d;\n", yyleng); |
---|
624 | #endif |
---|
625 | BEGIN(phelp); |
---|
626 | yyless(0); |
---|
627 | } |
---|
628 | <phead>{escstrings}+"{" { |
---|
629 | if(check && yyleng>2) |
---|
630 | { |
---|
631 | printf("Procedure %s (line %d) has OLD-STYLE-HELP!\n", |
---|
632 | pi->procname, pi->data.s.proc_lineno); |
---|
633 | } |
---|
634 | #if YYLPDEBUG |
---|
635 | if(lpverbose>2 && yyleng>2) |
---|
636 | printf("2-Len=%d, %s;\n", yyleng, pi->procname); |
---|
637 | #endif |
---|
638 | SET_HELP_START(mode, pi, current_pos(0)); |
---|
639 | BEGIN(poldhelp); |
---|
640 | yyless(0); |
---|
641 | } |
---|
642 | <phead>. { printf("[%s]", yytext); } |
---|
643 | |
---|
644 | <poldhelp>{escbrack} { } |
---|
645 | <poldhelp>"{" { |
---|
646 | SET_HELP_END(mode, pi, current_pos(0)); |
---|
647 | brace1++; BEGIN(pbody); |
---|
648 | if(lpverbose) |
---|
649 | { |
---|
650 | printf("// HELP from %d to %d\n", |
---|
651 | (int)pi->data.s.help_start, (int)pi->data.s.help_end); |
---|
652 | printf("// BODY at line %d,%d (%d)\n", yylplineno, |
---|
653 | current_pos(0), brace1); |
---|
654 | } |
---|
655 | #if YYLPDEBUG > 1 |
---|
656 | printf("BEGIN(pbody){=%d, (=%d, [=%d\n", brace1, brace2, brace3); |
---|
657 | #endif |
---|
658 | SET_BODY_START(mode, pi, yylplineno, current_pos(0)); |
---|
659 | #if YYLPDEBUG > 1 |
---|
660 | printf("BODY at %d/%d", yylplineno, current_pos(0)); |
---|
661 | #endif |
---|
662 | } |
---|
663 | <poldhelp>\n { yylplineno++; } |
---|
664 | <poldhelp>. { } |
---|
665 | |
---|
666 | <phelp>{quote} { |
---|
667 | old_state = YYSTATE; |
---|
668 | BEGIN(string); |
---|
669 | SET_HELP_START(mode, pi, current_pos(1)); |
---|
670 | } |
---|
671 | <phelp>{tos} {} |
---|
672 | <phelp>"{" { |
---|
673 | brace1++; BEGIN(pbody); |
---|
674 | if(lpverbose) |
---|
675 | { |
---|
676 | printf("// HELP from %d to %d\n", |
---|
677 | (int)pi->data.s.help_start, (int)pi->data.s.help_end); |
---|
678 | printf("// BODY at line %d,%d (%d)\n", yylplineno, |
---|
679 | current_pos(0), brace1); |
---|
680 | } |
---|
681 | #if YYLPDEBUG > 1 |
---|
682 | printf("BEGIN(pbody){=%d, (=%d, [=%d\n", brace1, brace2, brace3); |
---|
683 | #endif |
---|
684 | SET_BODY_START(mode, pi, yylplineno, current_pos(0)); |
---|
685 | #if YYLPDEBUG > 1 |
---|
686 | printf("BODY at %d/%d", yylplineno, current_pos(0)); |
---|
687 | #endif |
---|
688 | } |
---|
689 | <phelp>\n { yylplineno++;} |
---|
690 | |
---|
691 | <pbody>({comment}[^\n]*) { } |
---|
692 | <pbody>{quote} { quote++; old_state = YYSTATE; |
---|
693 | BEGIN(string); /* printf("%s", yytext); */ |
---|
694 | } |
---|
695 | |
---|
696 | <pbody>proc+{tos}+{name}+{tnl}+{paramlist}+{tnl}+"{" { |
---|
697 | if(check) printf("*** found 2 proc whithin procedure '%s'.\n", |
---|
698 | pi->procname); |
---|
699 | yyless(yyleng-1); |
---|
700 | } |
---|
701 | <pbody>proc+{tos}+{name}+{tnl}+"{" { |
---|
702 | if(check) printf("*** found 1 proc whithin procedure '%s'.\n", |
---|
703 | pi->procname); |
---|
704 | yyless(yyleng-1); |
---|
705 | } |
---|
706 | <pbody>"{" { |
---|
707 | brace1++; |
---|
708 | #if YYLPDEBUG > 1 |
---|
709 | printf("line: %d, (%d)%s\n", yylplineno, brace1, yytext); |
---|
710 | #endif |
---|
711 | } |
---|
712 | <pbody>"}" { |
---|
713 | #if YYLPDEBUG > 1 |
---|
714 | printf("line: %d, (%d)%s\n", |
---|
715 | yylplineno, brace1, yytext); |
---|
716 | #endif |
---|
717 | brace1--; |
---|
718 | if(brace2>0) |
---|
719 | { |
---|
720 | yylp_errno = YYLP_BODY_BR2; |
---|
721 | return(1); |
---|
722 | } |
---|
723 | if(brace3>0) |
---|
724 | { |
---|
725 | yylp_errno = YYLP_BODY_BR3; |
---|
726 | return(1); |
---|
727 | } |
---|
728 | if(brace1<=0) |
---|
729 | { |
---|
730 | SET_BODY_END(mode, pi, current_pos(yyleng)); |
---|
731 | SET_PROC_END(mode, pi, current_pos(yyleng)); |
---|
732 | #if YYLPDEBUG > 1 |
---|
733 | printf("-%d\n", current_pos(0)); |
---|
734 | #endif |
---|
735 | BEGIN(INITIAL); |
---|
736 | } |
---|
737 | } |
---|
738 | <pbody>"(" { |
---|
739 | brace2++; /* printf("%s", yytext); */ |
---|
740 | } |
---|
741 | <pbody>")" { |
---|
742 | brace2--; /* printf("%s", yytext); */ |
---|
743 | if(brace2<0) { |
---|
744 | yylp_errno = YYLP_BODY_TMBR2; |
---|
745 | return(1); |
---|
746 | } |
---|
747 | } |
---|
748 | <pbody>"[" { |
---|
749 | brace3++; /* printf("%s", yytext); */ |
---|
750 | } |
---|
751 | <pbody>"]" { |
---|
752 | brace3--; /* printf("%s", yytext); */ |
---|
753 | if(brace3<0) { |
---|
754 | yylp_errno = YYLP_BODY_TMBR3; |
---|
755 | return(1); |
---|
756 | } |
---|
757 | } |
---|
758 | <pbody>\n { yylplineno++; } |
---|
759 | <pbody>. { } |
---|
760 | |
---|
761 | <info>{quote} { |
---|
762 | quote++; BEGIN(string); |
---|
763 | found_info++; |
---|
764 | string_start = current_pos(yyleng); |
---|
765 | *lib_style = NEW_LIBSTYLE; |
---|
766 | last_cmd = LP_INFO; |
---|
767 | } |
---|
768 | <info>\n { yylplineno++; } |
---|
769 | <info>. { } |
---|
770 | |
---|
771 | <category>{quote} { |
---|
772 | quote++; BEGIN(string); |
---|
773 | found_cat++; |
---|
774 | string_start = current_pos(yyleng); |
---|
775 | *lib_style = NEW_LIBSTYLE; |
---|
776 | last_cmd = LP_CATEGORY; |
---|
777 | } |
---|
778 | <category>\n { yylplineno++; } |
---|
779 | <category>. { } |
---|
780 | |
---|
781 | <string>"\"" { quote--; |
---|
782 | #ifdef HAVE_NAMESPACES |
---|
783 | copy_string(mode, pl); |
---|
784 | #else /* HAVE_NAMESPACES */ |
---|
785 | copy_string(mode); |
---|
786 | #endif /* HAVE_NAMESPACES */ |
---|
787 | last_cmd = LP_NONE; |
---|
788 | if(old_state==phelp) |
---|
789 | { |
---|
790 | SET_HELP_END(mode, pi, current_pos(0)); |
---|
791 | } |
---|
792 | BEGIN(old_state); /* printf("%s", yytext); */ |
---|
793 | } |
---|
794 | <string>(\\\\)|(\\\") { if (old_state == phelp) IncrCheckSum(*yytext);} |
---|
795 | <string>\n { yylplineno++; if (old_state == phelp) IncrCheckSum('\n');} |
---|
796 | <string>. { if (old_state == phelp) IncrCheckSum(*yytext);} |
---|
797 | |
---|
798 | <pexample>(\/\/[^\n]*) { } |
---|
799 | <pexample>"\"" { quote++; old_state = YYSTATE; |
---|
800 | BEGIN(string); /* printf("%s", yytext); */ |
---|
801 | } |
---|
802 | <pexample>"{" { |
---|
803 | brace1++; /* printf("(%d)%s", brace1, yytext); */ |
---|
804 | } |
---|
805 | <pexample>"}" { |
---|
806 | brace1--; /* printf("(%d)%s", brace1, yytext); */ |
---|
807 | if(brace1<=0) { |
---|
808 | if(brace2>0) { yylp_errno=YYLP_EX_BR2; return(1); } |
---|
809 | if(brace3>0) { yylp_errno=YYLP_EX_BR3; return(1); } |
---|
810 | BEGIN(INITIAL); |
---|
811 | SET_PROC_END(mode, pi, current_pos(yyleng)); |
---|
812 | } |
---|
813 | } |
---|
814 | <pexample>"(" { |
---|
815 | brace2++; /* printf("%s", yytext); */ |
---|
816 | } |
---|
817 | <pexample>")" { |
---|
818 | brace2--; /* printf("%s", yytext); */ |
---|
819 | } |
---|
820 | <pexample>"[" { |
---|
821 | brace3++; /* printf("%s", yytext); */ |
---|
822 | } |
---|
823 | <pexample>"]" { |
---|
824 | brace3--; /* printf("%s", yytext); */ |
---|
825 | } |
---|
826 | <pexample>\n { yylplineno++; } |
---|
827 | <pexample>. { } |
---|
828 | |
---|
829 | <pestr>"\"" { quote--; |
---|
830 | BEGIN(pexample); /* printf("%s", yytext); */ |
---|
831 | } |
---|
832 | <pestr>\\\\ { } |
---|
833 | <pestr>\\\" { } |
---|
834 | <pestr>\n { yylplineno++; } |
---|
835 | <pestr>. { } |
---|
836 | |
---|
837 | <comment>\*\/ { BEGIN(old_state); } |
---|
838 | <comment>\n { yylplineno++; } |
---|
839 | <comment>. { } |
---|
840 | |
---|
841 | \n { yylplineno++; } |
---|
842 | \r { } |
---|
843 | ; { p_static = FALSE; |
---|
844 | #if YYLPDEBUG > 1 |
---|
845 | printf("%s", yytext); |
---|
846 | #endif |
---|
847 | } |
---|
848 | . { p_static = FALSE; |
---|
849 | yylp_errno = YYLP_BAD_CHAR; |
---|
850 | #ifdef STANDALONE_PARSER |
---|
851 | printf("[%d]", *yytext); |
---|
852 | #else |
---|
853 | if (text_buffer!=NULL) omFree((ADDRESS)text_buffer); |
---|
854 | text_buffer = omStrDup(yytext); |
---|
855 | omMarkAsStaticAddr(text_buffer); |
---|
856 | #endif |
---|
857 | #if YYLPDEBUG > 1 |
---|
858 | printf("[%s]", yytext); |
---|
859 | #endif |
---|
860 | return(1); |
---|
861 | } |
---|
862 | |
---|
863 | %% |
---|
864 | |
---|
865 | int current_pos(int i) |
---|
866 | { |
---|
867 | return(i+offset+(int)(yytext-yylp_buffer_start)); |
---|
868 | } |
---|
869 | |
---|
870 | int libread(FILE* f, char* buf, int max_size) |
---|
871 | { int rc; |
---|
872 | |
---|
873 | offset = ftell(f); |
---|
874 | rc = myfread( buf, 1, max_size, f ); |
---|
875 | #if YYLPDEBUG >2 |
---|
876 | printf("fread: %d of %d\n", rc, max_size); |
---|
877 | #endif |
---|
878 | yylp_buffer_start = buf; |
---|
879 | return rc; |
---|
880 | } |
---|
881 | |
---|
882 | extern "C" { |
---|
883 | int yylpwrap() |
---|
884 | { |
---|
885 | //printf("======================= YYWRAP ====================\n"); |
---|
886 | if(brace1>0) { yylp_errno=YYLP_MISS_BR1; } |
---|
887 | if(brace2>0) { yylp_errno=YYLP_MISS_BR2; } |
---|
888 | if(brace3>0) { yylp_errno=YYLP_MISS_BR3; } |
---|
889 | if(quote>0) { yylp_errno=YYLP_MISSQUOT; } |
---|
890 | /* printf("{=%d, (=%d, [=%d\n", brace1, brace2, brace3);/**/ |
---|
891 | if(feof(yyin)) return 1; else return 0; |
---|
892 | } |
---|
893 | } |
---|
894 | |
---|
895 | void reinit_yylp() |
---|
896 | { |
---|
897 | brace1 = 0; |
---|
898 | brace2 = 0; |
---|
899 | brace3 = 0; |
---|
900 | quote = 0; |
---|
901 | yy_init=1; |
---|
902 | yy_delete_buffer(yy_current_buffer); |
---|
903 | } |
---|
904 | |
---|
905 | void make_version(char *p,int what) |
---|
906 | { |
---|
907 | char ver[10]; |
---|
908 | char date[16]; |
---|
909 | ver[0]='?'; ver[1]='.'; ver[2]='?'; ver[3]='\0'; |
---|
910 | date[0]='?'; date[1]='\0'; |
---|
911 | if(what) sscanf(p,"%*[^=]= %*s %*s %10s %16s",ver,date); |
---|
912 | else sscanf(p,"// %*s %*s %10s %16s",ver,date); |
---|
913 | strcpy(libnamebuf,"("); |
---|
914 | strcat(libnamebuf,ver); |
---|
915 | strcat(libnamebuf,","); |
---|
916 | strcat(libnamebuf,date); |
---|
917 | strcat(libnamebuf,")"); |
---|
918 | if(what && strcmp(libnamebuf, "(?.?,?)")==0) |
---|
919 | { |
---|
920 | sscanf(p,"%*[^\"]\"%[^\"]\"",libnamebuf); |
---|
921 | } |
---|
922 | //printf("ID=(%d)%s; \n", what, p); |
---|
923 | } |
---|
924 | |
---|
925 | #ifdef HAVE_NAMESPACES |
---|
926 | void copy_string(lp_modes mode, idhdl pl) |
---|
927 | #else /* HAVE_NAMESPACES */ |
---|
928 | void copy_string(lp_modes mode) |
---|
929 | #endif /* HAVE_NAMESPACES */ |
---|
930 | { |
---|
931 | #ifdef STANDALONE_PARSER |
---|
932 | if ((texinfo_out && (last_cmd == LP_INFO || last_cmd == LP_CATEGORY)) || |
---|
933 | (category_out && last_cmd == LP_CATEGORY)) |
---|
934 | { |
---|
935 | long current_location = ftell(yylpin), i = string_start, quote = 0; |
---|
936 | char c; |
---|
937 | if (texinfo_out) |
---|
938 | { |
---|
939 | if (last_cmd == LP_INFO) |
---|
940 | { |
---|
941 | printf("$info = <<EOT;\n"); |
---|
942 | } |
---|
943 | else |
---|
944 | { |
---|
945 | printf("$category = <<EOT;\n"); |
---|
946 | } |
---|
947 | } |
---|
948 | fseek (yylpin, i, SEEK_SET); |
---|
949 | while (i< current_location) |
---|
950 | { |
---|
951 | c = fgetc(yylpin); |
---|
952 | if (c == '\\') |
---|
953 | { |
---|
954 | quote = (! quote); |
---|
955 | } |
---|
956 | else if (c == '"') |
---|
957 | { |
---|
958 | if (! quote) break; |
---|
959 | } |
---|
960 | else |
---|
961 | quote = 0; |
---|
962 | if (c == '@' || c == '$') putchar('\\'); |
---|
963 | if (c != '\r') putchar(c); |
---|
964 | i++; |
---|
965 | } |
---|
966 | if (category_out) exit(0); |
---|
967 | fseek (yylpin, current_location, SEEK_SET); |
---|
968 | printf("\nEOT\n"); |
---|
969 | } |
---|
970 | #else |
---|
971 | if((last_cmd == LP_INFO)&&(mode == GET_INFO)) |
---|
972 | { |
---|
973 | int i, offset=0; |
---|
974 | long current_location = ftell(yylpin); |
---|
975 | int len = (int)(current_pos(0) - string_start); |
---|
976 | fseek(yylpin, string_start, SEEK_SET); |
---|
977 | if (text_buffer!=NULL) omFree((ADDRESS)text_buffer); |
---|
978 | text_buffer = (char *)omAlloc(len+2); |
---|
979 | omMarkAsStaticAddr(text_buffer); |
---|
980 | myfread(text_buffer, len, 1, yylpin); |
---|
981 | fseek(yylpin, current_location, SEEK_SET); |
---|
982 | text_buffer[len]='\0'; |
---|
983 | offset=0; |
---|
984 | for(i=0;i<=len; i++) |
---|
985 | { |
---|
986 | if(text_buffer[i]=='\\' && |
---|
987 | (text_buffer[i+1]=='\"' || text_buffer[i+1]=='{' || |
---|
988 | text_buffer[i+1]=='}' || text_buffer[i+1]=='\\')) |
---|
989 | { |
---|
990 | i++; |
---|
991 | offset++; |
---|
992 | } |
---|
993 | if(offset>0) text_buffer[i-offset] = text_buffer[i]; |
---|
994 | } |
---|
995 | #ifdef HAVE_NAMESPACES |
---|
996 | if( mode != GET_INFO ) { |
---|
997 | h0 = enterid( "info", myynest, STRING_CMD, |
---|
998 | &IDPACKAGE(pl)->idroot, FALSE ); |
---|
999 | if (h0!=NULL) |
---|
1000 | { |
---|
1001 | IDSTRING(h0) = omStrDup(text_buffer); |
---|
1002 | } |
---|
1003 | } |
---|
1004 | #endif /* HAVE_NAMESPACES */ |
---|
1005 | } |
---|
1006 | #endif /* STANDALONE_PARSER */ |
---|
1007 | } |
---|
1008 | |
---|
1009 | void print_init() |
---|
1010 | { |
---|
1011 | printf("Init=%d\n", yy_init); |
---|
1012 | } |
---|
1013 | |
---|
1014 | void print_version(lp_modes mode, char *p) |
---|
1015 | { |
---|
1016 | #ifdef STANDALONE_PARSER |
---|
1017 | //printf("loading %s%s", p, libnamebuf); |
---|
1018 | #else |
---|
1019 | if ( mode == LOAD_LIB ) |
---|
1020 | { |
---|
1021 | if (BVERBOSE(V_LOAD_LIB) && p!=NULL ) Print(" %s...", p); |
---|
1022 | //Warn( "loading %s%s", p, libnamebuf); |
---|
1023 | } |
---|
1024 | #endif |
---|
1025 | } |
---|
1026 | |
---|
1027 | #ifdef STANDALONE_PARSER |
---|
1028 | main( int argc, char *argv[] ) |
---|
1029 | { |
---|
1030 | lib_style_types lib_style; |
---|
1031 | main_init(argc, argv); |
---|
1032 | if(yyin == NULL) { |
---|
1033 | fprintf(stderr, "No library found to parse.\n"); |
---|
1034 | exit(1); |
---|
1035 | } |
---|
1036 | if (! (texinfo_out || category_out)) |
---|
1037 | { |
---|
1038 | if(lpverbose)printf("Verbose level=%d\n", lpverbose); |
---|
1039 | if(check)printf("Reporting most possible annomalies.\n"); |
---|
1040 | if(lpverbose||check)printf("\n"); |
---|
1041 | |
---|
1042 | printf( " %-15s %20s %s,%s %s,%s %s,%s\n", "Library", |
---|
1043 | "function", "line", "start-eod", "line", "body-eob", |
---|
1044 | "line", "example-eoe"); |
---|
1045 | } |
---|
1046 | yylplex(argv[0], argv[0], &lib_style); |
---|
1047 | if(yylp_errno) { |
---|
1048 | printf("ERROR occured: [%d] ", yylp_errno); |
---|
1049 | printf(yylp_errlist[yylp_errno], yylplineno); |
---|
1050 | printf("\n"); |
---|
1051 | } |
---|
1052 | else if(pi!=NULL) printpi(pi); |
---|
1053 | if (texinfo_out) |
---|
1054 | printf("1;"); |
---|
1055 | exit(0); |
---|
1056 | } |
---|
1057 | |
---|
1058 | #endif /* STANDALONE_PARSER */ |
---|
1059 | #endif /* HAVE_LIBPARSE */ |
---|