Changeset f2c53c0 in git
- Timestamp:
- Jan 29, 2010, 2:17:17 PM (14 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
- Children:
- 319f7948b5d13ad1012fdfd9c4113b6aced44bd4
- Parents:
- 20d4b60dbf3e6336262bc0f3909917d6f602bbe6
- Location:
- Singular
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/Makefile.in
r20d4b6 rf2c53c0 388 388 ${CXX} ${CPPFLAGS} -c -o libparse_main.o libparse.cc -DSTANDALONE_PARSER 389 389 390 utils.o: utils.cc 391 ${CXX} ${CPPFLAGS} -c -o utils.o utils.cc -DSTANDALONE_PARSER 392 390 393 libparse.cc: libparse.l 391 394 @if test "x${LEX}" = x; then \ -
Singular/libparse.cc
r20d4b6 rf2c53c0 1062 1062 #define HAVE_LIBPARSER 1063 1063 #define YYLPDEBUG 1 1064 #include "../kernel/febase.cc"1065 1064 #else 1066 1065 #include "subexpr.h" -
Singular/libparse.h
r20d4b6 rf2c53c0 8 8 * ABSTRACT: lib parsing 9 9 */ 10 # include "structs.h" 11 # include "subexpr.h" 10 typedef enum { OLD_LIBSTYLE, NEW_LIBSTYLE } lib_style_types; 12 11 typedef enum { LOAD_LIB, GET_INFO } lp_modes; 13 typedef enum { OLD_LIBSTYLE, NEW_LIBSTYLE } lib_style_types;14 12 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 21 typedef 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 27 class proc_singular 28 { 29 public: 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 45 struct proc_object 46 { 47 //public: 48 BOOLEAN (*function)(leftv res, leftv v); 49 }; 50 union uprocinfodata 51 { 52 public: 53 proc_singular s; // data of Singular-procedure 54 struct proc_object o; // pointer to binary-function 55 }; 56 57 typedef union uprocinfodata procinfodata; 58 59 class procinfo; 60 typedef procinfo * procinfov; 61 62 class procinfo 63 { 64 public: 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 78 procinfo *iiInitSingularProcinfo(procinfo* pi, const char *libname, 16 79 const char *procname, int line, long pos, BOOLEAN pstatic=FALSE); 17 80 -
Singular/libparse.l
r20d4b6 rf2c53c0 13 13 #define HAVE_LIBPARSER 14 14 #define YYLPDEBUG 1 15 #include "../kernel/febase.cc"16 15 #else 17 16 #include "subexpr.h" -
Singular/utils.cc
r20d4b6 rf2c53c0 3 3 #include <stdlib.h> 4 4 #include <ctype.h> 5 #include "mod2.h"6 5 #include "fegetopt.h" 6 #include "utils.h" 7 7 #include "libparse.h" 8 #include "utils.h"9 8 10 9 extern FILE *yylpin; … … 38 37 char c; 39 38 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 { 42 43 case 'd': 43 44 lpverbose = 1; … … 69 70 if (texinfo_out || category_out) lpverbose = 0; 70 71 71 if(lib_file!=NULL) { 72 if(lib_file!=NULL) 73 { 72 74 yylpin = fopen( lib_file, "rb" ); 73 75 if (! (texinfo_out || category_out)) … … 75 77 else if (! category_out) 76 78 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 { 79 84 yylpin = fopen( argv[fe_optind], "rb" ); 80 85 if(yylpin!=NULL) … … 89 94 } 90 95 } 91 if(yylpin == NULL) { 96 if(yylpin == NULL) 97 { 92 98 printf("No library found to parse.\n"); 93 99 usage(argv[0]); … … 108 114 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ 109 115 110 procinfo *iiInitSingularProcinfo(procinfo vpi, const char *libname,116 procinfo *iiInitSingularProcinfo(procinfo* pi, const char *libname, 111 117 const char *procname, int line, long pos, 112 118 BOOLEAN pstatic /*= FALSE*/) … … 206 212 printf("\nEOT\n"); 207 213 } 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); 209 215 } 210 216 } … … 233 239 if (fp != NULL) fclose(fp); 234 240 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.