script.h

来自「类PASCAL语言的编译器,LINUX环境的,我没试过是否正确.」· C头文件 代码 · 共 1,385 行 · 第 1/4 页

H
1,385
字号
#define SCR_GLOBAL (1<<7)#define SCR_SWITCH (1<<8)#define SCR_FILE   (1<<9)  /* this is the file level, on this level the program                              can end with a '\0' char! */#define SCR_DEBUG  (1<<10) /* this level runs in debug mode! *//*********************************************************************** * * Expression() control bits: * **********************************************************************/#define CON_NORMAL     0      /* normal statement */#define CON_DECLINT    (1<<0) /* int declaration statement */#define CON_DECLSTR    (1<<1) /* string declaration statement */#define CON_GROUNDLVL  (1<<2) /* this statement starts at the ground level */#define CON_SEMICOLON  (1<<3) /* forces Statement() to return positive on ";"				 statement. Designed to support "for(;;)". */#define CON_PAREN      (1<<4) /* support for the last expression of the for(;;)				 ones */#define CON_ACTION     (1<<5) /* This flag forces Statement() to report errror				 if no "action" was made in the statement just				 parsed. */#define CON_END        (1<<6) /* Tell statement() there can be no				 "UNEXPECTED_END".*/#define CON_NUM        (1<<7) /* Only accept numerical statements! */#define CON_STRING     (1<<8) /* Hint about this being a string statement! */#define CON_DECLVOID   (1<<9) /* Declaration of a `void' function! */#define CON_DECLEXP    (1<<10) /* Declaration of an `export' symbol */#define CON_DECLGLOB   (1<<11) /* Declaration of a global symbol! */#define CON_IDENT      (1<<12) /* The local parameter points to an already				  parsed "struct Identifier" */#define CON_DECL8      (1<<13) /* Declaration of an eight bit variable */#define CON_DECL16     (1<<14) /* Declaration of an sixteen bit variable */#define CON_DECLUNSIGN (1<<15) /* Unsigned declaration */#define CON_DECLCONST  (1<<16) /* Constant declaration (read only) */#define CON_DECLSTATIC (1<<17) /* Static declaration */#define CON_LEVELOK    (1<<18) /* Disables same "proper level" controls */#define CON_NORETURN   (1<<19) /* Don't calculate return code, nobody wants                                  to know! */#define CON_LESSTHAN32 (CON_DECL8|CON_DECL16)#define CON_DECLARE (CON_DECLINT|CON_DECLSTR|CON_DECLVOID) /* declaration *//*********************************************************************** * * A bunch of useful macros: * **********************************************************************/#define isalpha(c)  ((type+1)[c] & (_U|_L))#define isupper(c)  ((type+1)[c] & _U)#define islower(c)  ((type+1)[c] & _L)#define isdigit(c)  ((type+1)[c] & _N)#define isxdigit(c) ((type+1)[c] & _X)#define isalnum(c)  ((type+1)[c] & (_U|_L|_N))#define isspace(c)  ((type+1)[c] & _S)#define ispunct(c)  ((type+1)[c] & _P)#define isprint(c)  ((type+1)[c] & (_U|_L|_N|_P))#define iscntrl(c)  ((type+1)[c] & _C)#define isascii(c)  (!((c) & ~127))#define isgraph(c)  ((type+1)[c] & (_U|_L|_N|_P))#define toascii(c)  ((c) & 127)#define toupper(c)  ((type+1)[c] & _L? c-CASE_BIT: c)#define tolower(c)  ((type+1)[c] & _U? c+CASE_BIT: c)#define isodigit(c) ((c) >= CHAR_ZERO && (c) <= CHAR_SEVEN)#define isident(c)  ((type+1)[c] & (_U|_L|_W))#define isidentnum(c)  ((type+1)[c] & (_U|_L|_W|_N))  /* CALL - macro performing the instruction inside parentheses and receiving     the return code in `ret'. If `ret' happens to become non-zero, a     "return(ret);" will be performed! */#define CALL(func) if(ret=(func)) return(ret)  /* GETMEM - macro allocating memory and returning FPLERR_OUT_OF_MEMORY if it     fails! */#define GETMEM(var,size) if(!(var=(void *)MALLOC(size))) \  return(FPLERR_OUT_OF_MEMORY);  /* GETMEMA - macro allocating static memory and returning FPLERR_OUT_OF_MEMORY     if it fails! */#define GETMEMA(var,size) if(!(var=(void *)MALLOCA(size))) \  return(FPLERR_OUT_OF_MEMORY);  /* STRDUP - macro instead of the common strdup() ! */#define STRDUP(var, pointer) \  GETMEM(var, strlen((uchar *)(pointer))+1);\  strcpy(var, (pointer));  /* STRDUPA - macro instead of the common strdup() for STATIC allocs ! */#define STRDUPA(var, pointer) \  GETMEMA(var, strlen((uchar *)(pointer))+1);\  strcpy(var, (uchar *)(pointer));  /* UPPER - returns uppercase version any a-z character */#define UPPER(x) ((x)&~CASE_BIT)  /* ABS - returns the absolute value of the argument */#define ABS(x) ((x)>0?x:-x)  /* MIN - returns the minimum value of the two input arguments */#define MIN(x,y) ((x)<(y)?(x):(y))  /* MIN3 - returns the minimum value of the three input arguments */#define MIN3(x,y,z) MIN( MIN((x),(y)) ,(z))  /* Here follows the define for strdup() of a string stored in a     (struct fplStr *) */#define STRFPLDUP(dest,source)\   do {\     GETMEM(dest, sizeof(struct fplStr)+source->len); /* get string space */\     memcpy(dest->string, source->string, source->len); /* copy string */\     dest->len=dest->alloc=source->len; /* set alloc and length */\     dest->string[dest->len]='\0'; /* zero terminate! */\   } while(0)#define ASSIGN_OPERATOR ( \			 (scr->text[0]==CHAR_ASSIGN &&		\			  scr->text[1]!=CHAR_ASSIGN) ||		\			 ((scr->text[0]==CHAR_PLUS ||		\			  scr->text[0]==CHAR_MINUS ||		\			  scr->text[0]==CHAR_MULTIPLY ||	\			  scr->text[0]==CHAR_DIVIDE ||		\			  scr->text[0]==CHAR_AND ||		\			  scr->text[0]==CHAR_OR ||		\			  scr->text[0]==CHAR_REMAIN ||		\			  scr->text[0]==CHAR_XOR) &&		\			 scr->text[1]==CHAR_ASSIGN) ||		\			 !strncmp("<<=", scr->text, 3) ||	\			 !strncmp(">>=", scr->text, 3)		\			) /* Get-file-date macros */#ifdef AMIGA#define GETFILEDATE(x) (x.fib_Date.ds_Days * 86400 +\                        x.fib_Date.ds_Minute * 60 +\                        x.fib_Date.ds_Tick / TICKS_PER_SECOND)#define timeoffile(date,file)                                  \      do {                                                     \        struct MyLibrary *lib = (struct MyLibrary *)getreg(REG_A6); \        struct Library *DOSBase = lib->ml_DosBase;             \        register BPTR lock;                                    \        struct FileInfoBlock fi;                               \        date =0;                                               \        if (lock=(BPTR)Lock((UBYTE *)(file), ACCESS_READ)) {   \          if (Examine((BPTR)lock, &fi))                        \            date = GETFILEDATE(fi);                            \          UnLock((BPTR)lock);                                  \        }                                                      \      } while(0)#else#define timeoffile(date,file)                                  \      do {                                                     \        struct stat statstr;                                   \	date = !stat(file, &statstr)?statstr.st_mtime:0; \      } while(0)#endif/*********************************************************************** * * Defines: * **********************************************************************/#define MALLOC_DYNAMIC 0#define MALLOC_STATIC  1#define FREE_KIND(x) FreeKind(scr, (void *)(x))#ifdef DEBUG#define MALLOC(x) MallocCycle(scr, x, __FILE__, __LINE__)#define MALLOCA(x) Malloc(scr, (x), MALLOC_STATIC, __FILE__, __LINE__)#else#define MALLOC(x) MallocCycle(scr, x)#define MALLOCA(x) Malloc(scr, (x), MALLOC_STATIC)#endif#define FREE(x) FreeCycle(scr, (void *)(x))#define FREEA(x) Free(scr, (void *)(x), MALLOC_STATIC)#define FREEALL() FreeAll(scr, MALLOC_DYNAMIC)#define FREEALLA() FreeAll(scr, MALLOC_STATIC)/* old version:   #define GETSTRLEN(str) ((long)*(long *)(str))   */#define GETSTRLEN(str) (((struct fplStr *)(((uchar *)str)-offsetof(struct fplStr, string)))->len)#if defined(AMIGA)  /*   * We have to make all external referenced functions to receive the   * parameters in certain registers and restore the A4 register.   */#define PREFIX __asm __saveds   /* special SAS/C ideas! Forces arguments				   to be puched in specified registers and				   forces the A6 register to be loaded at the				   beginning of the funtion. */#define AREG(x) register __a ## x#define DREG(x) register __d ## x#define REGARGS __regargs#define ASM __asm /***************************************  *  * funclib specific defines:  *  **************************************/#define FPLLIB_SOURCE "FPLLIBS:"#define FPLLIB_OPENCMD "open "#define FPLLIB_CLOSECMD "close "#define FPLLIB_MAXSPACE 60 /* length of the command string */#else#ifdef WIN32  /* Win32 foolishness. This MUST PRECEED 'uchar *' and similar if the function has     that type!! */#define PREFIX __declspec( dllexport )#else  /*   * No need for any of those!   */#define PREFIX#endif#define REGARGS#define AREG(x)#define DREG(x)#define ASM#endif#if defined(AMIGA) /* the amiga library defines... */#define INLINE __inline#else#define INLINE#endif/********************************************************************** * * Create some structures and define their flags: * *********************************************************************/struct Unary {  Operator unary;  struct Unary *next;};struct InsideFunction {  /*   * Used for `inside' functions.   */  uchar ret;  uchar *format;     long col; /* column number of the inside function position. */  long prg; /* line number of the function */  uchar *file; /* name of file where this function resides */  long virprg; /* virtual line number */  uchar *virfile; /* virtual file name */};struct ExternalFunction {  /*   * Used for all other functions and keywords.   */  uchar ret; /* 'I' - returns an integer	       'S' - returns a string	       */  uchar *format; /* Parameter format. Zero terminated. Unlimited length.		   'I' - integer		   'S' - string		   'C' - string variable structure		   'N' - integer variable structure		   '>' - variable number of the previous type.		   NULL pointer - no argument at all.		   lower case - optional (must only be to the right of		   the required)		     		   Ex: "ISsc"		   means that the function requires two parameters:		   one integer and one string. It has two optional		   parameters: one string and one string variable. */  long ID; /* Identifier ID. This information is sent in the	      fplArgument structure.	      <0 is reserved for FPL internals. */  void *data; /* function specific data! */  long (*func)(void *); /* optional function! */};struct fplStr {  /*   * FPL 'string' structure!   */  long alloc;     /* Allocated length of following string. That goes for the		     string *only*! The structure's size have to be added if		     the entire alloc is wanted! Notice that the first (or		     last) byte in the string belongs to the structure and		     not the 'string'!!! */  long len;	  /* length of following string */  uchar string[1]; /* memory included in the string! */};struct fplVariable {  struct Identifier *ref; /* Used when passing variable references. */                          /* pointer to the "actual" identifier */  long *dims;  /* An array holding the size of each dimension. */  long num;    /* Number of dimensions */  long size;   /* Number of variables in this array, that it is all		  dims' members multiplied with each other! */  long ID; /* set when using EXTERNAL_VARIABLEs from v10 */  /*   * Variable values to read. This is an array of values if the variable   * was declared as an array!   */  union {    struct fplStr **str; /* FPL string  */    long *val32;	/* FPL integer */    short *val16;	/* FPL short   */    uchar *val8;	/* FPL char    */    void *val;		/* general FPL data pointer */  } var;};struct Identifier {  /* This structure is used to store all identifiers in when they are "hashed     in". Notice that *ALL* data in this structure is pointing and referring     to the very same data as was sent to it, which means that you must keep     that data intact while using FPL. */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?