Port sc3 to C++.
This commit is contained in:
		
							parent
							
								
									234b4907ed
								
							
						
					
					
						commit
						4608050bd2
					
				| @ -84,7 +84,7 @@ binary.sources += [ | |||||||
|   'pawncc.cpp', |   'pawncc.cpp', | ||||||
|   'sc1.c', |   'sc1.c', | ||||||
|   'sc2.c', |   'sc2.c', | ||||||
|   'sc3.c', |   'sc3.cpp', | ||||||
|   'sc4.cpp', |   'sc4.cpp', | ||||||
|   'sc5.cpp', |   'sc5.cpp', | ||||||
|   'sc6.cpp', |   'sc6.cpp', | ||||||
|  | |||||||
| @ -547,8 +547,8 @@ typedef enum s_optmark { | |||||||
|  */ |  */ | ||||||
| int pc_compile(int argc, char **argv); | int pc_compile(int argc, char **argv); | ||||||
| int pc_addconstant(char *name,cell value,int tag); | int pc_addconstant(char *name,cell value,int tag); | ||||||
| int pc_addtag(char *name); | int pc_addtag(const char *name); | ||||||
| int pc_addtag_flags(char *name, int flags); | int pc_addtag_flags(const char *name, int flags); | ||||||
| int pc_findtag(const char *name); | int pc_findtag(const char *name); | ||||||
| constvalue *pc_tagptr(const char *name); | constvalue *pc_tagptr(const char *name); | ||||||
| int pc_enablewarning(int number,int enable); | int pc_enablewarning(int number,int enable); | ||||||
|  | |||||||
| @ -681,17 +681,19 @@ int pc_findtag(const char *name) | |||||||
| #if defined __cplusplus | #if defined __cplusplus | ||||||
|   extern "C" |   extern "C" | ||||||
| #endif | #endif | ||||||
| int pc_addtag(char *name) | int pc_addtag(const char *name) | ||||||
| { | { | ||||||
|   int val; |   int val; | ||||||
|   int flags = 0; |   int flags = 0; | ||||||
| 
 | 
 | ||||||
|   if (name==NULL) { |   if (name==NULL) { | ||||||
|     /* no tagname was given, check for one */ |     /* no tagname was given, check for one */ | ||||||
|     if (lex(&val,&name)!=tLABEL) { |     char *nameptr; | ||||||
|  |     if (lex(&val,&nameptr)!=tLABEL) { | ||||||
|       lexpush(); |       lexpush(); | ||||||
|       return 0;         /* untagged */ |       return 0;         /* untagged */ | ||||||
|     } /* if */ |     } /* if */ | ||||||
|  |     name = nameptr; | ||||||
|   } /* if */ |   } /* if */ | ||||||
| 
 | 
 | ||||||
|   if (isupper(*name)) |   if (isupper(*name)) | ||||||
| @ -700,7 +702,7 @@ int pc_addtag(char *name) | |||||||
|   return pc_addtag_flags(name, flags); |   return pc_addtag_flags(name, flags); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int pc_addtag_flags(char *name, int flags) | int pc_addtag_flags(const char *name, int flags) | ||||||
| { | { | ||||||
|   constvalue *ptr; |   constvalue *ptr; | ||||||
|   int last,tag; |   int last,tag; | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ static int skim(int *opstr,void (*testfunc)(int),int dropval,int endval, | |||||||
|                 int (*hier)(value*),value *lval); |                 int (*hier)(value*),value *lval); | ||||||
| static void dropout(int lvalue,void (*testfunc)(int val),int exit1,value *lval); | static void dropout(int lvalue,void (*testfunc)(int val),int exit1,value *lval); | ||||||
| static int plnge(int *opstr,int opoff,int (*hier)(value *lval),value *lval, | static int plnge(int *opstr,int opoff,int (*hier)(value *lval),value *lval, | ||||||
|                  char *forcetag,int chkbitwise); |                  const char *forcetag,int chkbitwise); | ||||||
| static int plnge1(int (*hier)(value *lval),value *lval); | static int plnge1(int (*hier)(value *lval),value *lval); | ||||||
| static void plnge2(void (*oper)(void), | static void plnge2(void (*oper)(void), | ||||||
|                    int (*hier)(value *lval), |                    int (*hier)(value *lval), | ||||||
| @ -116,13 +116,17 @@ static int nextop(int *opidx,int *list) | |||||||
| SC_FUNC int check_userop(void (*oper)(void),int tag1,int tag2,int numparam, | SC_FUNC int check_userop(void (*oper)(void),int tag1,int tag2,int numparam, | ||||||
|                          value *lval,int *resulttag) |                          value *lval,int *resulttag) | ||||||
| { | { | ||||||
| static char *binoperstr[] = { "*", "/", "%", "+", "-", "", "", "", |   static const char *binoperstr[] = { | ||||||
|                               "", "", "", "<=", ">=", "<", ">", "==", "!=" }; |     "*", "/", "%", "+", "-", "", "", "", | ||||||
| static int binoper_savepri[] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, |     "", "", "", "<=", ">=", "<", ">", "==", "!=" | ||||||
|                                  FALSE, FALSE, FALSE, FALSE, FALSE, |   }; | ||||||
|                                  TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }; |   static int binoper_savepri[] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, | ||||||
| static char *unoperstr[] = { "!", "-", "++", "--" }; |                                    FALSE, FALSE, FALSE, FALSE, FALSE, | ||||||
| static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec }; |                                    TRUE, TRUE, TRUE, TRUE, FALSE, FALSE | ||||||
|  |   }; | ||||||
|  |   static const char *unoperstr[] = { "!", "-", "++", "--" }; | ||||||
|  |   static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec }; | ||||||
|  | 
 | ||||||
|   char opername[4] = "", symbolname[sNAMEMAX+1]; |   char opername[4] = "", symbolname[sNAMEMAX+1]; | ||||||
|   int i,swapparams,savepri,savealt; |   int i,swapparams,savepri,savealt; | ||||||
|   int paramspassed; |   int paramspassed; | ||||||
| @ -719,7 +723,7 @@ static void checkfunction(value *lval) | |||||||
|  *  Plunge to a lower level |  *  Plunge to a lower level | ||||||
|  */ |  */ | ||||||
| static int plnge(int *opstr,int opoff,int (*hier)(value *lval),value *lval, | static int plnge(int *opstr,int opoff,int (*hier)(value *lval),value *lval, | ||||||
|                  char *forcetag,int chkbitwise) |                  const char *forcetag,int chkbitwise) | ||||||
| { | { | ||||||
|   int lvalue,opidx; |   int lvalue,opidx; | ||||||
|   int count; |   int count; | ||||||
| @ -862,10 +866,10 @@ static void plnge2(void (*oper)(void), | |||||||
|     checkfunction(lval1); |     checkfunction(lval1); | ||||||
|     checkfunction(lval2); |     checkfunction(lval2); | ||||||
|     if (lval1->ident==iARRAY || lval1->ident==iREFARRAY) { |     if (lval1->ident==iARRAY || lval1->ident==iREFARRAY) { | ||||||
|       char *ptr=(lval1->sym!=NULL) ? lval1->sym->name : "-unknown-"; |       const char *ptr=(lval1->sym!=NULL) ? lval1->sym->name : "-unknown-"; | ||||||
|       error(33,ptr);                    /* array must be indexed */ |       error(33,ptr);                    /* array must be indexed */ | ||||||
|     } else if (lval2->ident==iARRAY || lval2->ident==iREFARRAY) { |     } else if (lval2->ident==iARRAY || lval2->ident==iREFARRAY) { | ||||||
|       char *ptr=(lval2->sym!=NULL) ? lval2->sym->name : "-unknown-"; |       const char *ptr=(lval2->sym!=NULL) ? lval2->sym->name : "-unknown-"; | ||||||
|       error(33,ptr);                    /* array must be indexed */ |       error(33,ptr);                    /* array must be indexed */ | ||||||
|     } /* if */ |     } /* if */ | ||||||
|     /* ??? ^^^ should do same kind of error checking with functions */ |     /* ??? ^^^ should do same kind of error checking with functions */ | ||||||
| @ -1033,7 +1037,7 @@ SC_FUNC int sc_getstateid(constvalue **automaton,constvalue **state) | |||||||
|   assert(*automaton!=NULL); |   assert(*automaton!=NULL); | ||||||
|   *state=state_find(name,fsa); |   *state=state_find(name,fsa); | ||||||
|   if (*state==NULL) { |   if (*state==NULL) { | ||||||
|     char *fsaname=(*automaton)->name; |     const char *fsaname=(*automaton)->name; | ||||||
|     if (*fsaname=='\0') |     if (*fsaname=='\0') | ||||||
|       fsaname="<main>"; |       fsaname="<main>"; | ||||||
|     error(87,name,fsaname);   /* unknown state for automaton */ |     error(87,name,fsaname);   /* unknown state for automaton */ | ||||||
| @ -2526,7 +2530,7 @@ static int nesting=0; | |||||||
|   sc_allowproccall=FALSE;       /* parameters may not use procedure call syntax */ |   sc_allowproccall=FALSE;       /* parameters may not use procedure call syntax */ | ||||||
| 
 | 
 | ||||||
|   if ((sym->flags & flgDEPRECATED)!=0) { |   if ((sym->flags & flgDEPRECATED)!=0) { | ||||||
|     char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; |     const char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; | ||||||
|     error(234,sym->name,ptr);   /* deprecated (probably a native function) */ |     error(234,sym->name,ptr);   /* deprecated (probably a native function) */ | ||||||
|   } /* if */ |   } /* if */ | ||||||
| 
 | 
 | ||||||
| @ -2557,10 +2561,9 @@ static int nesting=0; | |||||||
|     do { |     do { | ||||||
|       if (!pending_this && matchtoken('.')) { |       if (!pending_this && matchtoken('.')) { | ||||||
|         namedparams=TRUE; |         namedparams=TRUE; | ||||||
|         if (needtoken(tSYMBOL)) |         if (!needtoken(tSYMBOL)) | ||||||
|           tokeninfo(&lexval,&lexstr); |           break; | ||||||
|         else |         tokeninfo(&lexval,&lexstr); | ||||||
|           lexstr=""; |  | ||||||
|         argpos=findnamedarg(arg,lexstr); |         argpos=findnamedarg(arg,lexstr); | ||||||
|         if (argpos<0) { |         if (argpos<0) { | ||||||
|           error(17,lexstr);       /* undefined symbol */ |           error(17,lexstr);       /* undefined symbol */ | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user