Changeset f2c53c0 in git


Ignore:
Timestamp:
Jan 29, 2010, 2:17:17 PM (14 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
Children:
319f7948b5d13ad1012fdfd9c4113b6aced44bd4
Parents:
20d4b60dbf3e6336262bc0f3909917d6f602bbe6
Message:
libparse fixed

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

Legend:

Unmodified
Added
Removed
  • Singular/Makefile.in

    r20d4b6 rf2c53c0  
    388388        ${CXX} ${CPPFLAGS} -c -o libparse_main.o libparse.cc  -DSTANDALONE_PARSER
    389389
     390utils.o: utils.cc
     391        ${CXX} ${CPPFLAGS} -c -o utils.o utils.cc  -DSTANDALONE_PARSER
     392
    390393libparse.cc: libparse.l
    391394        @if test "x${LEX}" = x; then \
  • Singular/libparse.cc

    r20d4b6 rf2c53c0  
    10621062  #define HAVE_LIBPARSER
    10631063  #define YYLPDEBUG 1
    1064   #include "../kernel/febase.cc"
    10651064#else
    10661065  #include "subexpr.h"
  • Singular/libparse.h

    r20d4b6 rf2c53c0  
    88* ABSTRACT: lib parsing
    99*/
    10 #  include "structs.h"
    11 #  include "subexpr.h"
     10typedef enum { OLD_LIBSTYLE, NEW_LIBSTYLE } lib_style_types;
    1211typedef enum { LOAD_LIB, GET_INFO } lp_modes;
    13 typedef enum { OLD_LIBSTYLE, NEW_LIBSTYLE } lib_style_types;
    1412
    15 procinfo *iiInitSingularProcinfo(procinfov pi, const char *libname,
     13#ifdef STANDALONE_PARSER
     14
     15
     16#define idhdl void*
     17#define leftv void*
     18#define package void*
     19#define BOOLEAN int
     20
     21typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs;
     22// LANG_TOP     : Toplevel package only
     23// LANG_SINGULAR:
     24// LANG_C       :
     25//
     26
     27class proc_singular
     28{
     29public:
     30  long   proc_start;       // position where proc is starting
     31  long   def_end;          // position where proc header is ending
     32  long   help_start;       // position where help is starting
     33  long   help_end;         // position where help is starting
     34  long   body_start;       // position where proc-body is starting
     35  long   body_end;         // position where proc-body is ending
     36  long   example_start;    // position where example is starting
     37  long   proc_end;         // position where proc is ending
     38  int    proc_lineno;
     39  int    body_lineno;
     40  int    example_lineno;
     41  char   *body;
     42  long help_chksum;
     43};
     44
     45struct proc_object
     46{
     47//public:
     48  BOOLEAN (*function)(leftv res, leftv v);
     49};
     50union uprocinfodata
     51{
     52public:
     53  proc_singular  s;        // data of Singular-procedure
     54  struct proc_object    o; // pointer to binary-function
     55};
     56
     57typedef union uprocinfodata procinfodata;
     58
     59class procinfo;
     60typedef procinfo *         procinfov;
     61
     62class procinfo
     63{
     64public:
     65  char          *libname;
     66  char          *procname;
     67  package       pack;
     68  language_defs language;
     69  short         ref;
     70  char          is_static;        // if set, proc not accessible for user
     71  char          trace_flag;
     72  procinfodata  data;
     73};
     74#else
     75#include "febase.h"
     76#endif
     77
     78procinfo *iiInitSingularProcinfo(procinfo* pi, const char *libname,
    1679              const char *procname, int line, long pos, BOOLEAN pstatic=FALSE);
    1780
  • Singular/libparse.l

    r20d4b6 rf2c53c0  
    1313  #define HAVE_LIBPARSER
    1414  #define YYLPDEBUG 1
    15   #include "../kernel/febase.cc"
    1615#else
    1716  #include "subexpr.h"
  • Singular/utils.cc

    r20d4b6 rf2c53c0  
    33#include <stdlib.h>
    44#include <ctype.h>
    5 #include "mod2.h"
    65#include "fegetopt.h"
     6#include "utils.h"
    77#include "libparse.h"
    8 #include "utils.h"
    98
    109extern FILE *yylpin;
     
    3837  char c;
    3938
    40   while((c=fe_getopt(argc, argv, "ihdc:sf:"))>=0) {
    41     switch(c) {
     39  while((c=fe_getopt(argc, argv, "ihdc:sf:"))>=0)
     40  {
     41    switch(c)
     42    {
    4243        case 'd':
    4344          lpverbose = 1;
     
    6970  if (texinfo_out || category_out) lpverbose = 0;
    7071
    71   if(lib_file!=NULL) {
     72  if(lib_file!=NULL)
     73  {
    7274    yylpin = fopen( lib_file, "rb" );
    7375    if (! (texinfo_out || category_out))
     
    7577    else if (! category_out)
    7678      printf("$library = \"%s\";\n", lib_file);
    77   } else {
    78     while(argc>fe_optind && yylpin==NULL) {
     79  }
     80  else
     81  {
     82    while(argc>fe_optind && yylpin==NULL)
     83    {
    7984      yylpin = fopen( argv[fe_optind], "rb" );
    8085      if(yylpin!=NULL)
     
    8994    }
    9095  }
    91   if(yylpin == NULL) {
     96  if(yylpin == NULL)
     97  {
    9298    printf("No library found to parse.\n");
    9399    usage(argv[0]);
     
    108114/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
    109115
    110 procinfo *iiInitSingularProcinfo(procinfov pi, const char *libname,
     116procinfo *iiInitSingularProcinfo(procinfo* pi, const char *libname,
    111117                                 const char *procname, int line, long pos,
    112118                                 BOOLEAN pstatic /*= FALSE*/)
     
    206212        printf("\nEOT\n");
    207213      }
    208       printf("$chksum{\"%s\"} = %d;\n", pi->procname, pi->data.s.help_chksum);
     214      printf("$chksum{\"%s\"} = %ld;\n", pi->procname, pi->data.s.help_chksum);
    209215    }
    210216  }
     
    233239  if (fp != NULL) fclose(fp);
    234240
    235 #if 0
    236   if( fp != NULL) { // loading body
    237     len1 = pi->data.s.def_end - pi->data.s.proc_start;
    238     if(pi->data.s.body_end==0)
    239       len2 = pi->data.s.proc_end - pi->data.s.body_start;
    240     else len2 = pi->data.s.body_end - pi->data.s.body_start;
    241     buf = (char *)malloc(len1 + len2 + 1);
    242     fseek(fp, pi->data.s.proc_start, SEEK_SET);
    243     fread( buf, len1, 1, fp);
    244     *(buf+len1) = '\n';
    245     fseek(fp, pi->data.s.body_start, SEEK_SET);
    246     fread( buf+len1+1, len2, 1, fp);
    247     *(buf+len1+len2+1)='\0';
    248     printf("##BODY:'%s'##\n", buf);
    249     free(buf);
    250 
    251     // loading help
    252     len1 = pi->data.s.body_start - pi->data.s.proc_start;
    253     printf("len1=%d;\n", len1);
    254     buf = (char *)malloc(len1+1);
    255     fseek(fp, pi->data.s.proc_start, SEEK_SET);
    256     fread( buf, len1, 1, fp);
    257     *(buf+len1)='\0';
    258     printf("##HELP:'%s'##\n", buf);
    259     free(buf);
    260 
    261     if(pi->data.s.example_start>0) { // loading example
    262       fseek(fp, pi->data.s.example_start, SEEK_SET);
    263       len2 = pi->data.s.proc_end - pi->data.s.example_start;
    264       buf = (char *)malloc(len2+1);
    265       fread( buf, len2, 1, fp);
    266       *(buf+len2)='\0';
    267       printf("##EXAMPLE:'%s'##\n", buf);
    268       free(buf);
    269     }
    270 
    271     //getchar();
    272   }
    273 #endif
    274 }
    275 
    276 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
     241}
     242
     243/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
Note: See TracChangeset for help on using the changeset viewer.