Changeset 6a51ef in git


Ignore:
Timestamp:
Mar 6, 1998, 12:50:38 PM (26 years ago)
Author:
Kai Krüger <krueger@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
4746528ffa8e871bd9c3aa620c4ab7f24f71117d
Parents:
33d539f008d9a3378ddd72d9aee94ad96fd8adcd
Message:
use a scanner when loading libraries.


git-svn-id: file:///usr/local/Singular/svn/trunk@1195 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Singular/Makefile.in

    r33d539 r6a51ef  
    9696    mpsr_Put.cc mpsr_PutPoly.cc mpsr_Tok.cc mpsr_GetPoly.cc \
    9797    mpsr_Get.cc mpsr_GetMisc.cc mpsr_Error.cc \
    98     ndbm.cc spSpolyLoop.cc
     98    ndbm.cc spSpolyLoop.cc libparse.cc
    9999
    100100CSOURCES=mmalloc.c mmallocb.c mmallocs.c mmblock.c mmheap.c mmspec.c mmutil.c weight0.c
    101101
    102 SOURCES=${CSOURCES} ${CXXSOURCES} grammar.y scanner.l
     102SOURCES=${CSOURCES} ${CXXSOURCES} grammar.y scanner.l libparse.l
    103103
    104104HEADERS=algmap.h hutil.h lists.h stairc.h attrib.h ideals.h \
     
    142142     algmap.o clapconv.o  clapmem.o clapsing.o claptmpl.o\
    143143     mpsr_Error.o mpsr_Put.o mpsr_PutPoly.o mpsr_GetPoly.o \
    144      mpsr_Get.o mpsr_GetMisc.o ndbm.o spSpolyLoop.o
     144     mpsr_Get.o mpsr_GetMisc.o ndbm.o spSpolyLoop.o libparse.o
    145145
    146146##
     
    165165
    166166Singular: mod2.h Makefile version.h scanner.cc ${OBJS} iparith.o \
    167                                                 mpsr_Tok.o tesths.cc
     167                                        mpsr_Tok.o tesths.cc libparse.cc
    168168        ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${DEFS} -o Singular \
    169169        tesths.cc iparith.o mpsr_Tok.o ${OBJS} ${LDFLAGS} ${LIBS}
     
    174174        tesths.cc iparith.o mpsr_Tok.o \
    175175        ${OBJS} ${STATIC_LDFLAGS} ${LDFLAGS} ${LIBS}
     176
     177libparse: libparse_main.o utils.o
     178        ${CXX} -o libparse libparse_main.o utils.o
     179
     180libparse_main.o: libparse.cc
     181        ${CXX} -c -o libparse_main.o libparse.cc -DSTANDALONE_PARSER
    176182
    177183iparith.o mpsr_Tok.o : iparith.inc mpsr_Tok.inc
     
    198204        fi
    199205
     206libparse.cc: libparse.l
     207        ${LEX} -I -Pyylp -olibparse.cc libparse.l
     208
    200209version.h: ${SOURCES} ${HEADERS} Makefile.in mod2.h.in configure.in
    201210        echo "#define SINGULAR_VERSION_ID " `date '+%y%m%d%H'` >version.h
     
    365374     mpsr_Error.og mpsr_Put.og mpsr_PutPoly.og mpsr_GetPoly.og \
    366375     mpsr_Get.og mpsr_GetMisc.og \
    367      ndbm.og spSpolyLoop.og
     376     ndbm.og spSpolyLoop.og libparse.og
    368377
    369378OBJG2= mmalloc.og mmallocb.og mmallocs.og mmblock.og mmheap.og \
     
    429438     mpsr_Error.op mpsr_Put.op mpsr_PutPoly.op mpsr_GetPoly.op \
    430439     mpsr_Get.op mpsr_GetMisc.op \
    431      ndbm.op spSpolyLoop.op
     440     ndbm.op spSpolyLoop.op libparse.op
    432441
    433442OBJP2= mmalloc.op mmallocb.op mmallocs.op mmblock.op mmheap.op \
  • Singular/iplib.cc

    r33d539 r6a51ef  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: iplib.cc,v 1.10 1998-02-27 14:06:18 Singular Exp $ */
     4/* $Id: iplib.cc,v 1.11 1998-03-06 11:50:37 krueger Exp $ */
    55/*
    66* ABSTRACT: interpreter: LIB and help
     
    2222#include "lists.h"
    2323
    24 procinfo *iiInitSingularProcinfo(procinfo *pi, char *libname,
    25                                  char *procname, int line, long pos);
     24procinfo *iiInitSingularProcinfo(procinfo *pi, char *libname, char *procname,
     25                                 int line, long pos, BOOLEAN pstatic=FALSE);
    2626char *iiConvName(char *p);
     27#ifdef HAVE_LIBPARSER
     28int yylplex(char *libname, char *libfile);
     29void yylprestart (FILE *input_file );
     30int current_pos(int i=0);
     31extern int yylp_errno;
     32extern int yylplineno;
     33extern char *yylp_errlist[];
     34void print_init();
     35void reinit_yylp();
     36libstackv library_stack;
     37#endif
    2738
    2839/*2
     
    136147  if(part==1)
    137148  { // load proc part
    138     fgets(buf, sizeof(buf), fp);
     149    procbuflen = pi->data.s.def_end - pi->data.s.proc_start;
     150    //fgets(buf, sizeof(buf), fp);
     151    fread( buf, procbuflen, 1, fp);
    139152    char ct;
    140153    char *e;
     
    474487  }
    475488
     489#ifdef HAVE_LIBPARSER
     490  extern FILE *yylpin;
     491  libstackv ls_start = library_stack;
     492
     493  yylpin = fp;
     494# if YYLPDEBUG > 1
     495  print_init();
     496#  endif
     497  yylplex(newlib, libnamebuf);
     498  if(yylp_errno) {
     499    Werror("Library %s: ERROR occured: in line %d, %d.", newlib, yylplineno,
     500         current_pos(0));
     501    Werror(yylp_errlist[yylp_errno], yylplineno);
     502    Werror("Cannot load library,... aborting.");
     503    reinit_yylp();
     504    fclose( yylpin );
     505    FreeL((ADDRESS)newlib);
     506    return TRUE;
     507  }
     508  reinit_yylp();
     509  fclose( yylpin );
     510  {
     511    libstackv ls;
     512    for(ls = library_stack; (ls != NULL) && (ls != ls_start); ) {
     513      if(ls->to_be_done) {
     514        //Print("// Processing id %d LIB:%s\n", ls->cnt, ls->get());
     515        ls->to_be_done=FALSE;
     516        iiLibCmd(ls->get());
     517        ls = ls->pop(newlib);
     518        //Print("Done\n");
     519      }
     520    }
     521#if 0
     522    Print("--------------------\n");
     523    for(ls = library_stack; ls != NULL; ls = ls->next) {
     524      Print("%s: LIB-stack:(%d), %s %s\n", newlib, ls->cnt, ls->get(),
     525        ls->to_be_done ? "not loaded" : "loaded");
     526    }
     527    Print("--------------------\n");
     528#endif
     529  }
     530#else /* HAVE_LIBPARSER */
    476531  // processing head section
    477532  if (fgets( buf, sizeof(buf), fp))
     
    499554    }
    500555  }
    501 
    502556
    503557  #define IN_HEADER 1
     
    609663  } while (fgets( buf, sizeof(buf), fp));
    610664  fclose( fp );
     665
    611666  //if (h!=NULL) IDPROC(h) = pi;
    612667  if (BVERBOSE(V_DEBUG_LIB))
     
    619674      Warn("LIB `%s` has no version flag",newlib);
    620675  }
     676#endif /* HAVE_LIBPARSER */
    621677  FreeL((ADDRESS)newlib);
    622678  return FALSE;
    623679}
    624680
    625 procinfo *iiInitSingularProcinfo(procinfov pi, char *libname,
    626                                  char *procname, int line, long pos)
     681procinfo *iiInitSingularProcinfo(procinfov pi, char *libname, char *procname,
     682                                 int line, long pos, BOOLEAN pstatic=FALSE)
    627683{
    628684  pi->libname = mstrdup(libname);
     
    636692  pi->language = LANG_SINGULAR;
    637693  pi->ref = 1;
     694  pi->is_static = pstatic;
    638695  pi->data.s.proc_start = pos;
    639696  pi->data.s.help_start = 0L;
     
    708765  return(buf);
    709766}
     767/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
     768#ifdef HAVE_LIBPARSER
     769void libstack::push(char *p, char *libname)
     770{
     771  idhdl hl = idroot->get("LIB",0);
     772  libstackv lp;
     773  char *f = NULL;
     774  if(hl!=NULL) f = strstr(IDSTRING(hl),libname);
     775  if( (hl==NULL) || (f == NULL)) {
     776    for(lp = this;lp!=NULL;lp=lp->next) {
     777      if(strcmp(lp->get(), libname)==0) break;
     778    }
     779    if(lp==NULL) {
     780      libstackv ls = (libstack *)Alloc0(sizeof(libstack));
     781      ls->next = this;
     782      ls->libname = mstrdup(libname);
     783      ls->to_be_done = TRUE;
     784      if(this != NULL) ls->cnt = this->cnt+1; else ls->cnt = 0;
     785      library_stack = ls;
     786    }
     787  }
     788}
     789
     790libstackv libstack::pop(char *p)
     791{
     792  libstackv ls = this;
     793  //FreeL(ls->libname);
     794  library_stack = ls->next;
     795  Free((ADDRESS)ls, sizeof(libstack));
     796  return(library_stack);
     797}
     798
     799#endif /* HAVE_LIBPARSER */
     800/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
  • Singular/mod2.h.in

    r33d539 r6a51ef  
    117117#define INIT_BUG
    118118
     119/* Define to use new namespaces techniks */
     120#undef HAVE_NAMESPACES
     121
     122/* Define to use scanner when loading libraries */
     123#define HAVE_LIBPARSER
     124
    119125/*#define PROFILING*/
    120126#ifdef PROFILING
     
    188194/* define YYDEBUG 1 for debugging bison texts, 0 otherwise */
    189195#define YYDEBUG 0
     196
     197#ifndef HAVE_LIBPARSER
     198#  undef YYLPDEBUG
     199#else
     200#  define YYLPDEBUG 0
     201#endif
    190202
    191203#ifndef FALSE
  • Singular/structs.h

    r33d539 r6a51ef  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: structs.h,v 1.8 1998-02-27 14:06:26 Singular Exp $ */
     6/* $Id: structs.h,v 1.9 1998-03-06 11:50:38 krueger Exp $ */
    77/*
    88* ABSTRACT
     
    156156#endif
    157157
     158#ifdef HAVE_LIBPARSER
     159#ifdef __cplusplus
     160class libstack;
     161typedef libstack *  libstackv;
     162#endif
     163#endif /* HAVE_LIBPARSER */
     164
    158165#endif
    159166
  • Singular/subexpr.h

    r33d539 r6a51ef  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: subexpr.h,v 1.4 1998-01-16 14:29:58 krueger Exp $ */
     6/* $Id: subexpr.h,v 1.5 1998-03-06 11:50:38 krueger Exp $ */
    77/*
    88* ABSTRACT: handling of leftv
     
    9292public:
    9393  long   proc_start;       // position where proc is starting
     94  long   def_end;          // position where proc header is ending
    9495  long   help_start;       // position where help is starting
    9596  long   body_start;       // position where proc-body is starting
     
    129130  language_defs language;
    130131  short         ref;
     132  char          is_static;        // if set, proc not accessible for user
    131133  procinfodata  data;
    132134};
     
    140142char *piProcinfo(procinfov pi, char *request);
    141143void piShowProcinfo(procinfov pi, char *txt);
     144#ifdef HAVE_LIBPARSER
     145class libstack
     146{
     147 public:
     148  libstackv next;
     149  char      *libname;
     150  BOOLEAN   to_be_done;
     151  int       cnt;
     152  void      push(char *p, char * libname);
     153  libstackv pop(char *p);
     154  inline char *get() { return(libname); }
     155};
     156#endif /* HAVE_LIBPARSER */
    142157#endif
Note: See TracChangeset for help on using the changeset viewer.