source: git/Singular/libparse.l @ 799ce1

spielwiese
Last change on this file since 799ce1 was 799ce1, checked in by Kai Krüger <krueger@…>, 26 years ago
Modified Files: iplib.cc libparse.l mod2.h.in libparse.cc Changed output of 'loading libraries' enabled option(debugLib) git-svn-id: file:///usr/local/Singular/svn/trunk@1607 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 22.4 KB
Line 
1%{
2/****************************************
3*  Computer Algebra System SINGULAR     *
4****************************************/
5/* $Id: libparse.l,v 1.19 1998-05-05 13:46:38 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("// %s PROC '%s' at line %d,%d: (%d).\n",
290                      p_static ? "local" : "global", proc,
291                      yylplineno, current_pos(0), brace1);
292#endif
293               p_static=FALSE;
294#ifndef STANDALONE_PARSER
295             }
296#endif STANDALONE_PARSER
297           }
298example    {
299             BEGIN(pexample);
300             SET_EXAMPLE_START(mode, pi, yylplineno, current_pos(0));
301#if YYLPDEBUG
302             if(lpverbose)
303                printf("//     EXAMPLE at line %d,%d (%d)\n", yylplineno,
304                    current_pos(0), brace1);
305#endif
306           }
307
308LIB[ \t]+"\"" { quote++;
309             BEGIN(libcmd);
310           }
311
312<header>({comment}+{tos}+{dolar}+Id:+{string}+[^\n]*)|({comment}+{tos}+{dolar}+Header:+{string}+[^\n]*) {
313             make_version(yytext, 0);
314#if YYLPDEBUG > 1
315             printf("+(id)HEAD:%s\n", yytext);
316#endif
317           }
318<header>(^{comment}+[^\n]*) {
319#if YYLPDEBUG
320             printf("+(cmt)HEAD:%s\n", yytext);
321#endif
322           }
323<header>(^#![^\n]*) {
324#if YYLPDEBUG > 1
325             printf("-HEAD:%s\n", yytext);
326#endif
327           }
328<header>^proc\  { yyless(0);
329             BEGIN(INITIAL);
330             yymore();
331           }
332<header>(info+{eq}+\")|(version+{eq}+\") {
333             yyless(0);
334             *lib_style = NEW_LIBSTYLE;
335             BEGIN(INITIAL);
336             yymore();
337           }
338
339<header>^LIB[ \t]+"\""   { quote++;
340             BEGIN(libcmd);
341           }
342<header>\n { yylplineno++; }
343<header>.  {
344#if YYLPDEBUG > 1
345             printf(" HEAD:%s\n", yytext);
346#endif
347             yyless(0);
348             BEGIN(help);
349           }
350<help>(^{comment}+[^\n]*)  {
351#if YYLPDEBUG > 1
352             printf(" HELP:%s\n", yytext);
353#endif
354             BEGIN(INITIAL); }
355<help>(^#![^\n]*) {
356#if YYLPDEBUG > 1
357             printf(" HELP:%s\n", yytext);
358#endif
359             BEGIN(INITIAL);
360           }
361<help>(info+{eq}+\")|(version+{eq}+\") {
362             yyless(0);
363             *lib_style = NEW_LIBSTYLE;
364             BEGIN(INITIAL);
365             yymore();
366           }
367<help>^proc\  {
368             yyless(0);
369             //printf("2) proc found.\n");
370             BEGIN(INITIAL);
371             yymore();
372           }
373<help>^LIB[ \t]+"\""     { quote++;
374             BEGIN(libcmd);
375           }
376
377<help>\n { yylplineno++; }
378<help>({tos}|{comment}+{fstring}) {
379#if YYLPDEBUG
380             if(lpverbose>2) printf("--->%s<---\n", yytext);
381#endif
382           }
383<help>.    {
384             found_oldhelp=1;
385#if YYLPDEBUG > 1
386             printf("-HELP:%s\n", yytext);
387#endif
388           }
389
390
391<libcmd>{string}"\""     { quote--;
392             yytext[yyleng-1] = '\0';
393#ifndef STANDALONE_PARSER
394             if ( mode == LOAD_LIB ) {
395             library_stack->push(newlib, yytext);
396           }
397#endif /* STANDALONE_PARSER */
398#if YYLPDEBUG
399             if(lpverbose>1) printf("LIB:'%s'\n", yytext);
400#endif
401             BEGIN(INITIAL);
402           }
403
404<pdef>[ \t] { }
405<pdef>\(   {
406             brace2++;
407#if YYLPDEBUG > 1
408             printf("%s", yytext);
409#endif
410           }
411<pdef>\)   {
412             brace2--;
413#if YYLPDEBUG > 1
414             printf(">%s<\n", yytext);
415             printf("{=%d, (=%d, [=%d\n", brace1, brace2, brace3);
416#endif
417             if(brace2<=0) {
418#if YYLPDEBUG > 1
419               printf("BEGIN(phead){=%d, (=%d, [=%d\n", brace1, brace2, brace3);
420#endif
421               SET_DEF_END(mode, pi, current_pos(yyleng));
422               BEGIN(phead);
423             }
424           }
425<pdef>"{"  {
426             if(brace2>0) {
427#if YYLPDEBUG > 1
428               printf("{=%d, (=%d, [=%d\n", brace1, brace2, brace3);
429#endif
430               yylp_errno = YYLP_DEF_BR2;
431               return(1);
432             } else {
433               brace1++; BEGIN(pbody);
434               if(lpverbose)
435                  printf("//     BODY at line %d,%d (%d)\n", yylplineno,
436                      current_pos(0), brace1);
437               SET_BODY_START(mode, pi, yylplineno, current_pos(0));
438             }
439           }
440<pdef>\n { yylplineno++;
441              if(brace2<=0) {
442#if YYLPDEBUG > 1
443                printf("BEGIN(phead-2){=%d, (=%d, [=%d\n", brace1, brace2, brace3);
444#endif
445                BEGIN(phead);
446              }
447            }
448<pdef>.    {
449             if(brace2<=0) {
450               BEGIN(phead);
451               yyless(0);
452             }
453           }
454
455<phead>({tnl}+{quote}+{strings}+{escquote}+{tnl}+"{") {
456#if YYLPDEBUG
457              if(lpverbose>2)printf("0-Len=%d;\n", yyleng);
458#endif
459              if(check) {
460                printf("Procedure %s (line %d) has OLD-STYLE-HELP!\n",
461                       pi->procname, pi->data.s.proc_lineno);
462              }
463              SET_HELP_START(mode, pi, current_pos(0));
464              BEGIN(poldhelp);
465              yyless(0);
466           }
467<phead>({tnl}+{quote}+{strings}+{eos}) {
468#if YYLPDEBUG
469              if(lpverbose>2)printf("1-Len=%d;\n", yyleng);
470#endif
471              BEGIN(phelp);
472              yyless(0);
473           }
474<phead>{escstrings}+"{" {
475              if(check && yyleng>2) {
476                printf("Procedure %s (line %d) has OLD-STYLE-HELP!\n",
477                       pi->procname, pi->data.s.proc_lineno);
478              }
479#if YYLPDEBUG
480              if(lpverbose>2 && yyleng>2)
481                 printf("2-Len=%d, %s;\n", yyleng, pi->procname);
482#endif
483              SET_HELP_START(mode, pi, current_pos(0));
484              BEGIN(poldhelp);
485              yyless(0);
486           }
487<phead>.   { printf("[%s]", yytext); }
488
489<poldhelp>{escbrack} { }
490<poldhelp>"{" {
491                brace1++; BEGIN(pbody);
492                if(lpverbose)
493                   printf("//     BODY at line %d,%d (%d)\n", yylplineno,
494                       current_pos(0), brace1);
495#if YYLPDEBUG > 1
496                printf("BEGIN(pbody){=%d, (=%d, [=%d\n", brace1, brace2, brace3);
497#endif
498                SET_BODY_START(mode, pi, yylplineno, current_pos(0));
499#if YYLPDEBUG > 1
500                printf("BODY at %d/%d", yylplineno, current_pos(0));
501#endif
502              }
503<poldhelp>\n  { yylplineno++; }
504<poldhelp>.   { }
505
506<phelp>{quote} {
507             old_state = YYSTATE;
508             BEGIN(string);
509             SET_HELP_START(mode, pi, current_pos(1));
510           }
511<phelp>{tos} {}
512<phelp>"{" {
513             brace1++; BEGIN(pbody);
514             if(lpverbose)
515                printf("//     BODY at line %d,%d (%d)\n", yylplineno,
516                    current_pos(0), brace1);
517#if YYLPDEBUG > 1
518             printf("BEGIN(pbody){=%d, (=%d, [=%d\n", brace1, brace2, brace3);
519#endif
520             SET_BODY_START(mode, pi, yylplineno, current_pos(0));
521#if YYLPDEBUG > 1
522             printf("BODY at %d/%d", yylplineno, current_pos(0));
523#endif
524           }
525<phelp>\n  { yylplineno++; }
526
527<pbody>({comment}[^\n]*) { }
528<pbody>{quote} { quote++; old_state = YYSTATE;
529                 BEGIN(string); /* printf("%s", yytext); */
530               }
531
532<pbody>proc+{tos}+{name}+{tnl}+{paramlist}+{tnl}+"{" {
533             if(check) printf("*** found 2 proc whithin procedure '%s'.\n",
534                          pi->procname);
535             yyless(yyleng-1);
536           }
537<pbody>proc+{tos}+{name}+{tnl}+"{" {
538             if(check) printf("*** found 1 proc whithin procedure '%s'.\n",
539                          pi->procname);
540             yyless(yyleng-1);
541           }
542<pbody>"{"     {
543                 brace1++;
544#if YYLPDEBUG > 1
545                 printf("line: %d, (%d)%s\n", yylplineno, brace1, yytext);
546#endif
547                }
548<pbody>"}"               {
549#if YYLPDEBUG > 1
550                           printf("line: %d, (%d)%s\n", yylplineno, brace1, yytext);
551#endif
552                           brace1--;
553                           if(brace2>0) {
554                             yylp_errno = YYLP_BODY_BR2;
555                             return(1);
556                           }
557                           if(brace3>0) {
558                             yylp_errno = YYLP_BODY_BR3;
559                             return(1);
560                           }
561                           if(brace1<=0) {
562                             SET_BODY_END(mode, pi, current_pos(yyleng));
563                             SET_PROC_END(mode, pi, current_pos(yyleng));
564#if YYLPDEBUG > 1
565                             printf("-%d\n", current_pos(0));
566#endif
567                             BEGIN(INITIAL);
568                           }
569                         }
570<pbody>"("               {
571                           brace2++; /* printf("%s", yytext); */
572                         }
573<pbody>")"               {
574                           brace2--; /* printf("%s", yytext); */
575                           if(brace2<0) {
576                             yylp_errno = YYLP_BODY_TMBR2;
577                             return(1);
578                           }
579                         }
580<pbody>"["               {
581                           brace3++; /* printf("%s", yytext); */
582                         }
583<pbody>"]"               {
584                           brace3--; /* printf("%s", yytext); */
585                           if(brace3<0) {
586                             yylp_errno = YYLP_BODY_TMBR3;
587                             return(1);
588                           }
589                         }
590<pbody>\n                { yylplineno++; }
591<pbody>.                 { }
592
593<string>"\""             { quote--;
594                           copy_string(mode);
595                           last_cmd = LP_NONE;
596                           BEGIN(old_state); /* printf("%s", yytext); */
597                         }
598<string>(\\\\)|(\\\")    { }
599<string>\n               { yylplineno++; }
600<string>.                { }
601
602<pexample>(\/\/[^\n]*)  { }
603<pexample>"\""           { quote++; old_state = YYSTATE;
604                           BEGIN(string); /* printf("%s", yytext); */
605                         }
606<pexample>"{"            {
607                           brace1++; /* printf("(%d)%s", brace1, yytext); */
608                         }
609<pexample>"}"            {
610                           brace1--; /* printf("(%d)%s", brace1, yytext); */
611                           if(brace1<=0) {
612                             if(brace2>0) { yylp_errno=YYLP_EX_BR2; return(1); }
613                             if(brace3>0) { yylp_errno=YYLP_EX_BR3; return(1); }
614                             BEGIN(INITIAL);
615                             SET_PROC_END(mode, pi, current_pos(yyleng));
616                           }
617                         }
618<pexample>"("            {
619                           brace2++; /* printf("%s", yytext); */
620                         }
621<pexample>")"            {
622                           brace2--; /* printf("%s", yytext); */
623                         }
624<pexample>"["            {
625                           brace3++; /* printf("%s", yytext); */
626                         }
627<pexample>"]"            {
628                           brace3--; /* printf("%s", yytext); */
629                         }
630<pexample>\n             { yylplineno++; }
631<pexample>.              { }
632
633<pestr>"\""              { quote--;
634                           BEGIN(pexample); /* printf("%s", yytext); */
635                         }
636<pestr>\\\\              { }
637<pestr>\\\"              { }
638<pestr>\n                { yylplineno++; }
639<pestr>.                 { }
640
641<comment>\*\/            { BEGIN(old_state); }
642<comment>\n              { yylplineno++; }
643<comment>.               { }
644
645\n                       { yylplineno++; }
646\r                       { }
647;                        { p_static = FALSE;
648#if YYLPDEBUG > 1
649                            printf("%s", yytext);
650#endif
651                         }
652.                        { p_static = FALSE;
653                           yylp_errno = YYLP_BAD_CHAR;
654                           printf("[%d]", *yytext);
655#if YYLPDEBUG > 1
656                           printf("[%s]", yytext);
657#endif
658                           return(1);
659                         }
660
661%%
662
663int current_pos(int i)
664{
665  return(i+offset+(int)(yytext-yylp_buffer_start));
666}
667
668int libread(FILE* f, char* buf, int max_size)
669{ int rc;
670
671  offset = ftell(f);
672  rc  = myfread( buf, 1, max_size, f );
673#if YYLPDEBUG >2
674  printf("fread: %d of %d\n", rc, max_size);
675#endif
676  yylp_buffer_start = buf;
677  return rc;
678}
679
680extern "C" {
681  int yylpwrap() {
682    //printf("======================= YYWRAP ====================\n");
683    if(brace1>0) { yylp_errno=YYLP_MISS_BR1; }
684    if(brace2>0) { yylp_errno=YYLP_MISS_BR2; }
685    if(brace3>0) { yylp_errno=YYLP_MISS_BR3; }
686    if(quote>0) { yylp_errno=YYLP_MISSQUOT; }
687    /* printf("{=%d, (=%d, [=%d\n", brace1, brace2, brace3);/**/
688    if(feof(yyin)) return 1; else return 0;
689  }
690}
691
692void reinit_yylp()
693{
694   brace1 = 0;
695   brace2 = 0;
696   brace3 = 0;
697   quote  = 0;
698   yy_init=1;
699   yy_delete_buffer(yy_current_buffer);
700}
701
702void make_version(char *p,int what)
703{
704  char ver[10];
705  char date[16];
706  ver[0]='?'; ver[1]='.'; ver[2]='?'; ver[3]='\0';
707  date[0]='?'; date[1]='\0';
708  if(what) sscanf(p,"%*[^=]= %*s %*s %10s %16s",ver,date);
709  else sscanf(p,"// %*s %*s %10s %16s",ver,date);
710  strcpy(libnamebuf,"(");
711  strcat(libnamebuf,ver);
712  strcat(libnamebuf,",");
713  strcat(libnamebuf,date);
714  strcat(libnamebuf,")");
715  if(what && strcmp(libnamebuf, "(?.?,?)")==0) {
716    sscanf(p,"%*[^\"]\"%[^\"]\"",libnamebuf);
717  }
718  //printf("ID=(%d)%s; \n", what, p);
719}
720
721void copy_string(lp_modes mode)
722{
723#  ifndef STANDALONE_PARSER
724  if((last_cmd == LP_INFO)&&(mode == GET_INFO))
725  {
726    long current_location = ftell(yylpin);
727    int len = (int)(current_pos(0) - string_start);
728    fseek(yylpin, string_start, SEEK_SET);
729    text_buffer = (char *)AllocL(len+2);
730    myfread(text_buffer, len, 1, yylpin);
731    fseek(yylpin, current_location, SEEK_SET);
732    text_buffer[len]='\0';
733  }
734#  endif /* STANDALONE_PARSER */
735}
736
737void print_init()
738{
739   printf("Init=%d\n", yy_init);
740}
741
742void print_version(lp_modes mode, char *p)
743{
744#  ifdef STANDALONE_PARSER
745  //printf("loading %s%s", p, libnamebuf);
746#  else
747  if ( mode == LOAD_LIB ) {
748    if (BVERBOSE(V_LOAD_LIB) && p!=NULL ) Print(" %s...", p);
749       //Warn( "loading %s%s", p, libnamebuf);
750  }
751#  endif
752}
753
754#  ifdef STANDALONE_PARSER
755main( int argc, char *argv[] )
756{
757  lib_style_types lib_style;
758  main_init(argc, argv);
759  if(lpverbose)printf("Verbose level=%d\n", lpverbose);
760  if(check)printf("Reporting most possible annomalies.\n");
761  if(lpverbose||check)printf("\n");
762
763  printf( "  %-15s  %20s      %s,%s    %s,%s     %s,%s\n", "Library",
764          "function", "line", "start-eod", "line", "body-eob",
765          "line", "example-eoe");
766  yylplex(argv[0], argv[0], &lib_style);
767  if(yylp_errno) {
768    printf("ERROR occured: [%d] ", yylp_errno);
769    printf(yylp_errlist[yylp_errno], yylplineno);
770    printf("\n");
771  }
772  else if(pi!=NULL) printpi(pi);
773  main_result(argv[0]);
774}
775
776#  endif /* STANDALONE_PARSER */
777#endif /* HAVE_LIBPARSE */
Note: See TracBrowser for help on using the repository browser.