source: git/Singular/libparse.l @ 029516e

spielwiese
Last change on this file since 029516e was 029516e, checked in by Kai Krüger <krueger@…>, 26 years ago
esthetic change in libparse.l git-svn-id: file:///usr/local/Singular/svn/trunk@1640 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 22.5 KB
Line 
1%{
2/****************************************
3*  Computer Algebra System SINGULAR     *
4****************************************/
5/* $Id: libparse.l,v 1.20 1998-05-07 08:20:32 krueger 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#  include <getopt.h>
13#  define HAVE_LIBPARSER
14#  define YYLPDEBUG 1
15#else
16#  include "mod2.h"
17#  include "subexpr.h"
18#  include "grammar.h"
19#  include "ipshell.h"
20#  include "ipid.h"
21#  include "tok.h"
22#  include "febase.h"
23#  include "mmemory.h"
24#endif
25#include "libparse.h"
26
27#ifdef HAVE_LIBPARSER
28#  define YY_SKIP_YYWRAP
29
30typedef enum { LP_NONE, LP_INFO, LP_VERSION} lib_cmds;
31
32int libread(FILE* f, char* buf, int max_size);
33int current_pos(int i);
34void print_version(lp_modes mode, char *p);
35void copy_string(lp_modes mode);
36void make_version(char *p, int what);
37
38int brace1 = 0;  /* { } */
39int brace2 = 0;  /* ( ) */
40int brace3 = 0;  /* [ ] */
41int quote  = 0;  /* " */
42int offset = 0;
43BOOLEAN p_static = FALSE;
44int old_state = 0;
45lib_cmds last_cmd = LP_NONE;
46
47char libnamebuf[128];
48char *text_buffer;
49long string_start;
50
51char *yylp_buffer_start;
52int yylplineno = 1;
53int lpverbose = 0, check = 0;
54int found_info=0,
55    found_version=0,
56    found_oldhelp = 0,
57    found_proc_in_proc = 0;
58
59char *yylp_errlist[]= {
60   "",
61   "missing close bracket ')' for proc definition in line %d.",  /*  1 */
62   "missing close bracket ')' for procbody in line %d.",         /*  2 */
63   "missing close bracket ']' for procbody in line %d.",         /*  3 */
64   "too many ')' closed brackets in line %d.",                   /*  4 */
65   "too many ']' closed brackets in line %d.",                   /*  5 */
66   "missing close bracket ')' for example in line %d.",          /*  6 */
67   "missing close bracket ']' for example in line %d.",          /*  7 */
68   "cannot assign charater in line %d to any group.",            /*  8 */
69   "there must be a quote missing somewhere before line %d.",    /*  9 */
70   "missing close bracket '}' at end of library in line %d.",    /* 10 */
71   "missing close bracket ')' at end of library in line %d.",    /* 11 */
72   "missing close bracket ']' at end of library in line %d.",    /* 12 */
73   NULL
74};
75int yylp_errno = 0;
76
77#  define YYLP_ERR_NONE    0
78#  define YYLP_DEF_BR2     1
79#  define YYLP_BODY_BR2    2
80#  define YYLP_BODY_BR3    3
81#  define YYLP_BODY_TMBR2  4
82#  define YYLP_BODY_TMBR3  5
83#  define YYLP_EX_BR2      6
84#  define YYLP_EX_BR3      7
85#  define YYLP_BAD_CHAR    8
86#  define YYLP_MISSQUOT    9
87#  define YYLP_MISS_BR1   10
88#  define YYLP_MISS_BR2   11
89#  define YYLP_MISS_BR3   12
90
91#  ifdef __MWERKS__
92#    ifdef __cplusplus
93extern "C" {
94#    endif
95long   ftell(FILE *fp);
96#    ifdef macintosh
97int    fileno(FILE *stream);
98FILE   *fdopen(int filedes, char *type);
99int    isatty(int filedes);
100#else
101int    _fileno(FILE *stream);
102FILE   *_fdopen(int filedes, char *type);
103int    _isatty(int filedes);
104#      define fileno  _fileno
105#      define fdopen  _fdopen
106#      define isatty  _isatty
107#    endif /* macintosh */
108#    ifdef __cplusplus
109}
110#    endif
111#  endif
112
113#  ifdef STANDALONE_PARSER
114procinfov pi;
115printpi(procinfov pi);
116pi_clear(procinfov pi);
117extern "C" {
118  int yylpwrap();
119}
120void main_init(int argc, char *argv[]);
121void main_result(char *libname);
122#  else /* STANDALONE_PARSER */
123idhdl h0;
124#    define pi IDPROC(h0)
125extern "C"
126{
127  int yylpwrap();
128}
129extern libstackv library_stack;
130#  endif /* STANDALONE_PARSER */
131
132#  define SET_DEF_END(mode, pi, p) \
133     if ( mode == LOAD_LIB) pi->data.s.def_end = p;
134#  define SET_HELP_START(mode, pi, p) \
135     if ( mode == LOAD_LIB) pi->data.s.help_start = p; \
136
137#  define SET_BODY_START(mode, pi, l, p) \
138     if ( mode == LOAD_LIB) { \
139       pi->data.s.body_lineno = l; \
140       pi->data.s.body_start = p; \
141     }
142#  define SET_BODY_END(mode, pi, p) \
143     if ( mode == LOAD_LIB) { \
144       pi->data.s.body_end = p-1; \
145       pi->data.s.proc_end = p-1; \
146     }
147
148#  define SET_EXAMPLE_START(mode, pi, l, p) \
149     if ( mode == LOAD_LIB) { \
150       pi->data.s.example_lineno = l; \
151       pi->data.s.example_start = p; \
152     }
153#  define SET_PROC_END(mode, pi, p) \
154     if ( mode == LOAD_LIB) { \
155       pi->data.s.proc_end = p-1; \
156       if(pi->data.s.body_end==0) pi->data.s.body_end = p-1; \
157     }
158
159#  undef YY_DECL
160#  define YY_DECL int yylex(char *newlib, char *libfile, \
161                                 lib_style_types *lib_style, \
162                                 lp_modes mode)
163
164#  undef YY_INPUT
165#  define YY_INPUT(buf,result,max_size) \
166          if ( ((result = libread( (yyin), (char *) buf, max_size )) < 0 ) \
167                  && ferror( yyin ) ) \
168                YY_FATAL_ERROR( "read in flex scanner failed" );
169
170#  define YY_USER_INIT { \
171       BEGIN(header); \
172       yylplineno = 1; \
173       yylp_errno = 0; \
174       *lib_style = OLD_LIBSTYLE; \
175       strcpy(libnamebuf,"(**unknown version**)"); \
176     }
177
178#  if 0
179<pbody>proc[ \t]+{name}  {
180                           printf("MISSING: PROC-cmd found. ERROR!\n"); }
181<pbody>example[ \t]*\n   {
182                           yylplineno++;
183                           printf("MISSING: EXAMPLE-cmd found. ERROR!\n"); }
184#  endif
185%}
186
187digit          [0-9]
188letter         [@a-zA-Z\']
189name           ({letter}({letter}*{digit}*_*)*|_)
190varname        ({letter}({letter}*{digit}*_*\(\))*|_|#)
191letters        ({letter}|{digit}|[_./#%^*:,])
192string         ({letters}*)
193comment        [\/][\/]
194dolar          [$]
195nls            [\n\r]
196symbols        [~!@#$%^&*()_+-=\\\|\[\];:,<.>/\?\' \t\~\`]
197asymbols       ({symbols}|[{}])
198bsymbols       ({symbols}|{escbrack}|[}])
199aletters       ({letter}|{digit}|{asymbols}|{dolar}|{escquote}|{nls})
200bletters       ({letter}|{digit}|{bsymbols}|{dolar}|{quote}|{nls})
201cletters       ({letter}|{digit}|{asymbols}|{dolar}|{quote})
202strings        ({aletters}*)
203escstrings     ({bletters}*)
204fstring        ({cletters}*)
205param          ({name}+{tos}+{varname})
206parameters     ({param}(,{param})*)
207paramlist      ("("{parameters}")")
208quote          [\"]
209escquote       (\\\")
210escbrack       (\\\{)
211tnl            ([ \t\n]*)
212eos            ({quote}+{tnl}+"{")
213tos            ([ \t]*)
214eq             ([ \t]*+=[ \t]*)
215
216/* %start START */
217
218%x header
219%x help
220%x libcmd
221%x pdef
222%x phead
223%x poldhelp
224%x phelp
225%x pbody
226%x pstr
227%x pexample
228%x pestr
229%x string
230%x comment
231
232%%
233(\/\/[^\n]*)|(^#![^\n]*)|([ \t]) { }
234\/\/*      { old_state = YYSTATE; BEGIN(comment); }
235
236info=+"\"" { old_state = YYSTATE; quote++; BEGIN(string);
237             found_info++;
238             string_start = current_pos(yyleng);
239             *lib_style = NEW_LIBSTYLE;
240             last_cmd = LP_INFO;
241           }
242
243(version+{eq}+{quote}+{strings}+{quote}) {
244             found_version++;
245             if ( mode != GET_INFO ) {
246               make_version(yytext,1);
247#ifdef STANDALONE_PARSER
248               printf("Version:%s;\n", libnamebuf);
249#else
250               text_buffer = mstrdup(libnamebuf);
251#endif
252             }
253           }
254
255static     { p_static=TRUE; }
256
257(proc[ \t]+{name})|([ \t]proc[ \t]+{name}) {
258             char proc[256];
259             BEGIN(pdef);
260             found_proc_in_proc = 0;
261             proc[0]='\0';
262             sscanf( yytext, "%*[^p]proc %s", proc);
263             if(strlen(proc)<1) sscanf( yytext, "proc %s", proc);
264#if YYLPDEBUG > 1
265             printf("Newlib:%s\n", newlib);
266#endif
267#ifdef STANDALONE_PARSER
268               if ( pi != NULL ) {
269                 printpi(pi);
270                 pi_clear(pi);
271               }
272               pi = (procinfo *)malloc(sizeof(procinfo));
273               iiInitSingularProcinfo(pi, newlib, proc, yylplineno,
274                                        current_pos(0), p_static);
275#else STANDALONE_PARSER
276             if( mode == LOAD_LIB) {
277               h0 = enterid( mstrdup(proc), myynest, PROC_CMD,
278                                   &idroot, FALSE );
279               if (h0!=NULL) {
280                 iiInitSingularProcinfo(IDPROC(h0), newlib, proc,
281                                yylplineno, current_pos(0),p_static);
282                 if (BVERBOSE(V_LOAD_PROC))
283                   Warn( "     proc '%s' registered", proc );
284               }
285#endif STANDALONE_PARSER
286               SET_DEF_END(mode, pi, current_pos(yyleng+1));
287#if YYLPDEBUG
288               if(lpverbose) {
289                  printf("// PROCEDURE '%s' status: %s, ", proc,
290                      p_static ? "local" : "global");
291                  printf("starting at line %d,%d: (%d).\n",
292                      yylplineno, current_pos(0), brace1);
293               }
294#endif
295               p_static=FALSE;
296#ifndef STANDALONE_PARSER
297             }
298#endif STANDALONE_PARSER
299           }
300example    {
301             BEGIN(pexample);
302             SET_EXAMPLE_START(mode, pi, yylplineno, current_pos(0));
303#if YYLPDEBUG
304             if(lpverbose)
305                printf("//     EXAMPLE at line %d,%d (%d)\n", yylplineno,
306                    current_pos(0), brace1);
307#endif
308           }
309
310LIB[ \t]+"\"" { quote++;
311             BEGIN(libcmd);
312           }
313
314<header>({comment}+{tos}+{dolar}+Id:+{string}+[^\n]*)|({comment}+{tos}+{dolar}+Header:+{string}+[^\n]*) {
315             make_version(yytext, 0);
316#if YYLPDEBUG > 1
317             printf("+(id)HEAD:%s\n", yytext);
318#endif
319           }
320<header>(^{comment}+[^\n]*) {
321#if YYLPDEBUG
322             printf("+(cmt)HEAD:%s\n", yytext);
323#endif
324           }
325<header>(^#![^\n]*) {
326#if YYLPDEBUG > 1
327             printf("-HEAD:%s\n", yytext);
328#endif
329           }
330<header>^proc\  { yyless(0);
331             BEGIN(INITIAL);
332             yymore();
333           }
334<header>(info+{eq}+\")|(version+{eq}+\") {
335             yyless(0);
336             *lib_style = NEW_LIBSTYLE;
337             BEGIN(INITIAL);
338             yymore();
339           }
340
341<header>^LIB[ \t]+"\""   { quote++;
342             BEGIN(libcmd);
343           }
344<header>\n { yylplineno++; }
345<header>.  {
346#if YYLPDEBUG > 1
347             printf(" HEAD:%s\n", yytext);
348#endif
349             yyless(0);
350             BEGIN(help);
351           }
352<help>(^{comment}+[^\n]*)  {
353#if YYLPDEBUG > 1
354             printf(" HELP:%s\n", yytext);
355#endif
356             BEGIN(INITIAL); }
357<help>(^#![^\n]*) {
358#if YYLPDEBUG > 1
359             printf(" HELP:%s\n", yytext);
360#endif
361             BEGIN(INITIAL);
362           }
363<help>(info+{eq}+\")|(version+{eq}+\") {
364             yyless(0);
365             *lib_style = NEW_LIBSTYLE;
366             BEGIN(INITIAL);
367             yymore();
368           }
369<help>^proc\  {
370             yyless(0);
371             //printf("2) proc found.\n");
372             BEGIN(INITIAL);
373             yymore();
374           }
375<help>^LIB[ \t]+"\""     { quote++;
376             BEGIN(libcmd);
377           }
378
379<help>\n { yylplineno++; }
380<help>({tos}|{comment}+{fstring}) {
381#if YYLPDEBUG
382             if(lpverbose>2) printf("--->%s<---\n", yytext);
383#endif
384           }
385<help>.    {
386             found_oldhelp=1;
387#if YYLPDEBUG > 1
388             printf("-HELP:%s\n", yytext);
389#endif
390           }
391
392
393<libcmd>{string}"\""     { quote--;
394             yytext[yyleng-1] = '\0';
395#ifndef STANDALONE_PARSER
396             if ( mode == LOAD_LIB ) {
397             library_stack->push(newlib, yytext);
398           }
399#endif /* STANDALONE_PARSER */
400#if YYLPDEBUG
401             if(lpverbose>1) printf("LIB:'%s'\n", yytext);
402#endif
403             BEGIN(INITIAL);
404           }
405
406<pdef>[ \t] { }
407<pdef>\(   {
408             brace2++;
409#if YYLPDEBUG > 1
410             printf("%s", yytext);
411#endif
412           }
413<pdef>\)   {
414             brace2--;
415#if YYLPDEBUG > 1
416             printf(">%s<\n", yytext);
417             printf("{=%d, (=%d, [=%d\n", brace1, brace2, brace3);
418#endif
419             if(brace2<=0) {
420#if YYLPDEBUG > 1
421               printf("BEGIN(phead){=%d, (=%d, [=%d\n", brace1, brace2, brace3);
422#endif
423               SET_DEF_END(mode, pi, current_pos(yyleng));
424               BEGIN(phead);
425             }
426           }
427<pdef>"{"  {
428             if(brace2>0) {
429#if YYLPDEBUG > 1
430               printf("{=%d, (=%d, [=%d\n", brace1, brace2, brace3);
431#endif
432               yylp_errno = YYLP_DEF_BR2;
433               return(1);
434             } else {
435               brace1++; BEGIN(pbody);
436               if(lpverbose)
437                  printf("//     BODY at line %d,%d (%d)\n", yylplineno,
438                      current_pos(0), brace1);
439               SET_BODY_START(mode, pi, yylplineno, current_pos(0));
440             }
441           }
442<pdef>\n { yylplineno++;
443              if(brace2<=0) {
444#if YYLPDEBUG > 1
445                printf("BEGIN(phead-2){=%d, (=%d, [=%d\n", brace1, brace2, brace3);
446#endif
447                BEGIN(phead);
448              }
449            }
450<pdef>.    {
451             if(brace2<=0) {
452               BEGIN(phead);
453               yyless(0);
454             }
455           }
456
457<phead>({tnl}+{quote}+{strings}+{escquote}+{tnl}+"{") {
458#if YYLPDEBUG
459              if(lpverbose>2)printf("0-Len=%d;\n", yyleng);
460#endif
461              if(check) {
462                printf("Procedure %s (line %d) has OLD-STYLE-HELP!\n",
463                       pi->procname, pi->data.s.proc_lineno);
464              }
465              SET_HELP_START(mode, pi, current_pos(0));
466              BEGIN(poldhelp);
467              yyless(0);
468           }
469<phead>({tnl}+{quote}+{strings}+{eos}) {
470#if YYLPDEBUG
471              if(lpverbose>2)printf("1-Len=%d;\n", yyleng);
472#endif
473              BEGIN(phelp);
474              yyless(0);
475           }
476<phead>{escstrings}+"{" {
477              if(check && yyleng>2) {
478                printf("Procedure %s (line %d) has OLD-STYLE-HELP!\n",
479                       pi->procname, pi->data.s.proc_lineno);
480              }
481#if YYLPDEBUG
482              if(lpverbose>2 && yyleng>2)
483                 printf("2-Len=%d, %s;\n", yyleng, pi->procname);
484#endif
485              SET_HELP_START(mode, pi, current_pos(0));
486              BEGIN(poldhelp);
487              yyless(0);
488           }
489<phead>.   { printf("[%s]", yytext); }
490
491<poldhelp>{escbrack} { }
492<poldhelp>"{" {
493                brace1++; BEGIN(pbody);
494                if(lpverbose)
495                   printf("//     BODY at line %d,%d (%d)\n", yylplineno,
496                       current_pos(0), brace1);
497#if YYLPDEBUG > 1
498                printf("BEGIN(pbody){=%d, (=%d, [=%d\n", brace1, brace2, brace3);
499#endif
500                SET_BODY_START(mode, pi, yylplineno, current_pos(0));
501#if YYLPDEBUG > 1
502                printf("BODY at %d/%d", yylplineno, current_pos(0));
503#endif
504              }
505<poldhelp>\n  { yylplineno++; }
506<poldhelp>.   { }
507
508<phelp>{quote} {
509             old_state = YYSTATE;
510             BEGIN(string);
511             SET_HELP_START(mode, pi, current_pos(1));
512           }
513<phelp>{tos} {}
514<phelp>"{" {
515             brace1++; BEGIN(pbody);
516             if(lpverbose)
517                printf("//     BODY at line %d,%d (%d)\n", yylplineno,
518                    current_pos(0), brace1);
519#if YYLPDEBUG > 1
520             printf("BEGIN(pbody){=%d, (=%d, [=%d\n", brace1, brace2, brace3);
521#endif
522             SET_BODY_START(mode, pi, yylplineno, current_pos(0));
523#if YYLPDEBUG > 1
524             printf("BODY at %d/%d", yylplineno, current_pos(0));
525#endif
526           }
527<phelp>\n  { yylplineno++; }
528
529<pbody>({comment}[^\n]*) { }
530<pbody>{quote} { quote++; old_state = YYSTATE;
531                 BEGIN(string); /* printf("%s", yytext); */
532               }
533
534<pbody>proc+{tos}+{name}+{tnl}+{paramlist}+{tnl}+"{" {
535             if(check) printf("*** found 2 proc whithin procedure '%s'.\n",
536                          pi->procname);
537             yyless(yyleng-1);
538           }
539<pbody>proc+{tos}+{name}+{tnl}+"{" {
540             if(check) printf("*** found 1 proc whithin procedure '%s'.\n",
541                          pi->procname);
542             yyless(yyleng-1);
543           }
544<pbody>"{"     {
545                 brace1++;
546#if YYLPDEBUG > 1
547                 printf("line: %d, (%d)%s\n", yylplineno, brace1, yytext);
548#endif
549                }
550<pbody>"}"               {
551#if YYLPDEBUG > 1
552                           printf("line: %d, (%d)%s\n", yylplineno, brace1, yytext);
553#endif
554                           brace1--;
555                           if(brace2>0) {
556                             yylp_errno = YYLP_BODY_BR2;
557                             return(1);
558                           }
559                           if(brace3>0) {
560                             yylp_errno = YYLP_BODY_BR3;
561                             return(1);
562                           }
563                           if(brace1<=0) {
564                             SET_BODY_END(mode, pi, current_pos(yyleng));
565                             SET_PROC_END(mode, pi, current_pos(yyleng));
566#if YYLPDEBUG > 1
567                             printf("-%d\n", current_pos(0));
568#endif
569                             BEGIN(INITIAL);
570                           }
571                         }
572<pbody>"("               {
573                           brace2++; /* printf("%s", yytext); */
574                         }
575<pbody>")"               {
576                           brace2--; /* printf("%s", yytext); */
577                           if(brace2<0) {
578                             yylp_errno = YYLP_BODY_TMBR2;
579                             return(1);
580                           }
581                         }
582<pbody>"["               {
583                           brace3++; /* printf("%s", yytext); */
584                         }
585<pbody>"]"               {
586                           brace3--; /* printf("%s", yytext); */
587                           if(brace3<0) {
588                             yylp_errno = YYLP_BODY_TMBR3;
589                             return(1);
590                           }
591                         }
592<pbody>\n                { yylplineno++; }
593<pbody>.                 { }
594
595<string>"\""             { quote--;
596                           copy_string(mode);
597                           last_cmd = LP_NONE;
598                           BEGIN(old_state); /* printf("%s", yytext); */
599                         }
600<string>(\\\\)|(\\\")    { }
601<string>\n               { yylplineno++; }
602<string>.                { }
603
604<pexample>(\/\/[^\n]*)  { }
605<pexample>"\""           { quote++; old_state = YYSTATE;
606                           BEGIN(string); /* printf("%s", yytext); */
607                         }
608<pexample>"{"            {
609                           brace1++; /* printf("(%d)%s", brace1, yytext); */
610                         }
611<pexample>"}"            {
612                           brace1--; /* printf("(%d)%s", brace1, yytext); */
613                           if(brace1<=0) {
614                             if(brace2>0) { yylp_errno=YYLP_EX_BR2; return(1); }
615                             if(brace3>0) { yylp_errno=YYLP_EX_BR3; return(1); }
616                             BEGIN(INITIAL);
617                             SET_PROC_END(mode, pi, current_pos(yyleng));
618                           }
619                         }
620<pexample>"("            {
621                           brace2++; /* printf("%s", yytext); */
622                         }
623<pexample>")"            {
624                           brace2--; /* printf("%s", yytext); */
625                         }
626<pexample>"["            {
627                           brace3++; /* printf("%s", yytext); */
628                         }
629<pexample>"]"            {
630                           brace3--; /* printf("%s", yytext); */
631                         }
632<pexample>\n             { yylplineno++; }
633<pexample>.              { }
634
635<pestr>"\""              { quote--;
636                           BEGIN(pexample); /* printf("%s", yytext); */
637                         }
638<pestr>\\\\              { }
639<pestr>\\\"              { }
640<pestr>\n                { yylplineno++; }
641<pestr>.                 { }
642
643<comment>\*\/            { BEGIN(old_state); }
644<comment>\n              { yylplineno++; }
645<comment>.               { }
646
647\n                       { yylplineno++; }
648\r                       { }
649;                        { p_static = FALSE;
650#if YYLPDEBUG > 1
651                            printf("%s", yytext);
652#endif
653                         }
654.                        { p_static = FALSE;
655                           yylp_errno = YYLP_BAD_CHAR;
656                           printf("[%d]", *yytext);
657#if YYLPDEBUG > 1
658                           printf("[%s]", yytext);
659#endif
660                           return(1);
661                         }
662
663%%
664
665int current_pos(int i)
666{
667  return(i+offset+(int)(yytext-yylp_buffer_start));
668}
669
670int libread(FILE* f, char* buf, int max_size)
671{ int rc;
672
673  offset = ftell(f);
674  rc  = myfread( buf, 1, max_size, f );
675#if YYLPDEBUG >2
676  printf("fread: %d of %d\n", rc, max_size);
677#endif
678  yylp_buffer_start = buf;
679  return rc;
680}
681
682extern "C" {
683  int yylpwrap() {
684    //printf("======================= YYWRAP ====================\n");
685    if(brace1>0) { yylp_errno=YYLP_MISS_BR1; }
686    if(brace2>0) { yylp_errno=YYLP_MISS_BR2; }
687    if(brace3>0) { yylp_errno=YYLP_MISS_BR3; }
688    if(quote>0) { yylp_errno=YYLP_MISSQUOT; }
689    /* printf("{=%d, (=%d, [=%d\n", brace1, brace2, brace3);/**/
690    if(feof(yyin)) return 1; else return 0;
691  }
692}
693
694void reinit_yylp()
695{
696   brace1 = 0;
697   brace2 = 0;
698   brace3 = 0;
699   quote  = 0;
700   yy_init=1;
701   yy_delete_buffer(yy_current_buffer);
702}
703
704void make_version(char *p,int what)
705{
706  char ver[10];
707  char date[16];
708  ver[0]='?'; ver[1]='.'; ver[2]='?'; ver[3]='\0';
709  date[0]='?'; date[1]='\0';
710  if(what) sscanf(p,"%*[^=]= %*s %*s %10s %16s",ver,date);
711  else sscanf(p,"// %*s %*s %10s %16s",ver,date);
712  strcpy(libnamebuf,"(");
713  strcat(libnamebuf,ver);
714  strcat(libnamebuf,",");
715  strcat(libnamebuf,date);
716  strcat(libnamebuf,")");
717  if(what && strcmp(libnamebuf, "(?.?,?)")==0) {
718    sscanf(p,"%*[^\"]\"%[^\"]\"",libnamebuf);
719  }
720  //printf("ID=(%d)%s; \n", what, p);
721}
722
723void copy_string(lp_modes mode)
724{
725#  ifndef STANDALONE_PARSER
726  if((last_cmd == LP_INFO)&&(mode == GET_INFO))
727  {
728    long current_location = ftell(yylpin);
729    int len = (int)(current_pos(0) - string_start);
730    fseek(yylpin, string_start, SEEK_SET);
731    text_buffer = (char *)AllocL(len+2);
732    myfread(text_buffer, len, 1, yylpin);
733    fseek(yylpin, current_location, SEEK_SET);
734    text_buffer[len]='\0';
735  }
736#  endif /* STANDALONE_PARSER */
737}
738
739void print_init()
740{
741   printf("Init=%d\n", yy_init);
742}
743
744void print_version(lp_modes mode, char *p)
745{
746#  ifdef STANDALONE_PARSER
747  //printf("loading %s%s", p, libnamebuf);
748#  else
749  if ( mode == LOAD_LIB ) {
750    if (BVERBOSE(V_LOAD_LIB) && p!=NULL ) Print(" %s...", p);
751       //Warn( "loading %s%s", p, libnamebuf);
752  }
753#  endif
754}
755
756#  ifdef STANDALONE_PARSER
757main( int argc, char *argv[] )
758{
759  lib_style_types lib_style;
760  main_init(argc, argv);
761  if(lpverbose)printf("Verbose level=%d\n", lpverbose);
762  if(check)printf("Reporting most possible annomalies.\n");
763  if(lpverbose||check)printf("\n");
764
765  printf( "  %-15s  %20s      %s,%s    %s,%s     %s,%s\n", "Library",
766          "function", "line", "start-eod", "line", "body-eob",
767          "line", "example-eoe");
768  yylplex(argv[0], argv[0], &lib_style);
769  if(yylp_errno) {
770    printf("ERROR occured: [%d] ", yylp_errno);
771    printf(yylp_errlist[yylp_errno], yylplineno);
772    printf("\n");
773  }
774  else if(pi!=NULL) printpi(pi);
775  main_result(argv[0]);
776}
777
778#  endif /* STANDALONE_PARSER */
779#endif /* HAVE_LIBPARSE */
Note: See TracBrowser for help on using the repository browser.