📄 script.h
字号:
#define FPL_INSIDE_NOTFOUND (1<<8) /* This inside function has not been discovered yet. The position the data points to is the search start position. */#define FPL_IGNORE (1<<9) /* Read this and then drop it! *//* Data status */#define FPL_READONLY (1<<10) /* const variable! */#define FPL_EXTERNAL_VARIABLE (1<<11) /* external variable! new from V10 */#define FPL_EXPORT_SYMBOL (1<<12) /* cross program accessible */#define FPL_GLOBAL_SYMBOL (1<<13) /* global accessible in one file */#define FPL_SHORT_VARIABLE (1<<14) /* short (16-bit) variable */#define FPL_CHAR_VARIABLE (1<<15) /* char (8-bit) variable */#define FPL_UNSIGNED_VARIABLE (1<<16) /* unsigned variable */#define FPL_STATIC_VARIABLE (1<<17) /* static variable! */#define FPL_DEALLOC_NAME_ANYWAY (1<<18) /* In normal cases, this name should not get freed, but this is not a normal case... ;-P */#define FPL_STATUS (FPL_READONLY|FPL_HIJACKED_VARIABLE|FPL_EXPORT_SYMBOL\ FPL_GLOBAL_SYMBOL|FPL_SHORT_VARIABLE|FPL_CHAR_VARIABLE\ FPL_UNSIGNED_VARIABLE|FPL_STATIC_VARIABLE|FPL_REFEREMCE)/* * These two lower flags should be combined with the "Data status" flags * when declaring variables! */#define FPLDECL_STRING (1<<31) /* Keyword declaring string */#define FPLDEC_INT (1<<30) /* Keyword declaring int */#define FPL_VARIABLE_LESS32 (FPL_SHORT_VARIABLE|FPL_CHAR_VARIABLE)#define FPL_VARIABLE (FPL_STRING_VARIABLE|FPL_INT_VARIABLE)#define FPL_FUNCTION (FPL_INTERNAL_FUNCTION|FPL_EXTERNAL_FUNCTION |\ FPL_INSIDE_FUNCTION)/***** Identifier.ID defines: ******/struct Position { /* * This struct should be used from now on when storing and using the * interpret position! */ uchar *text; /* Current interpret position */ long prg; /* Current line number */ uchar *virfile; /* virtual file name pointer */ long virprg; /* virtual line number */};#define FPL_INSIDE_FUNCTION_ID -3;struct Condition { uchar *bracetext; /* pointer to the character to the right of the open brace */ long braceprg; /* line number of the above data */ uchar *check; /* pointer to the expression. Used by while() and for() */ long checkl; /* the line number of the expression */ uchar *postexpr; /* USED BY "for" : pointer to statement3 */ long postexprl; /* USED BY "for" : statement3's line number */};struct Expr { /* the numerical expression linked list */ union { long val; /* numerical return */ struct fplStr *str; /* string return */ } val; Operator operator; /* see the operator enums! */ struct Unary *unary; /* unary/primary operators linked list! */ short flags; /* see below */ struct Expr *next; };/**** struct Expr.flags defines: ****/#define FPL_STRING (1<<0) /* Expr structure is a string. */#define FPL_NOFREE (1<<1) /* A returned string should not be freed */#define FPL_OPERAND (1<<2) /* Next part in the expression is a operand */#define FPL_ACTION (1<<3) /* The expression includes any variable change(s) */#define FPL_BREAK (1<<4) /* The val member specifies number of levels left to break from! */#define FPL_RETURN (1<<5) /* There is a return call received, return to the last function caller. */#define FPL_CONTINUE (1<<6) /* Continue is flagged! */#define FPL_DEFUNCTION (1<<7) /* The Expression() just called declared AND defined a function! */#define FPL_BRACE (1<<8) /* This invoke returned due to a closing brace! */struct Local { /* * This structure will create a linked list of all local variables declared * in this level. When leaving this level, *ALL* variables with the names * that the ->ident member points to must be deleted, using DelIdentifier(). */ struct Identifier *ident; /* This pointer points to the Identifier structure, that means this should *NOT* be freed individually but only the entire structure and the Identifier structure (and members) at the same time! */ struct Local *next; /* Next member in this chain */};/* * All fplFunction ID's below zero are reserved for FPL internal use. * We use the funcdata member to set some flags: */#define FPL_HASH_INSIDE 1#define FPL_HASH_INTERNAL 2struct Data { /* * Allocated at fplInit() and freed at fplFree(). */ uchar *text; /* Current interpret position */ long prg; /* Current line number */ uchar *virfile; /* virtual file name pointer */ uchar *filename; /* actual file name pointer */ long virprg; /* virtual line number */ long size; /* file size */ uchar *program; /* file total content! */ uchar strret; /* The Script() now executing should return a string! (TRUE/FALSE) */ long level; /* Nesting level */ long varlevel; /* current variable level */ struct Local *globals; /* Pointer to list holding all global symbols currently declared in this program. They might be removed when this program quits if the user has set that flag or if we miss certain information */ struct Local *locals; /* Linked list of local variables! If any error code is returned, there might be local variables left to free in any precious local level! Use this list to delete 'em all! We add *ALL* levels to one list, separated with a NULL name. Deleting only the latest level, deletes to the nearest NULL name! */ long ret; /* Return value of the FPL block */ uchar *buf; /* Global buffer pointer (Why use more than one buffer at a time? It's only a waste of valuable stack!) */ void *userdata; /* Global Userdata. Free to use. */ unsigned long flags; /* Flags. See defines below! */ long FPLret; /* FPL return code = the result of the "exit(RETURN_CODE);" call! */ long *returnint; /* pointer to the above if an integer actually was returned */ struct Identifier **hash; /* Must be set to NULL before doing anything major... like using fplAddFunction() or calling fplExecute[File]() The NULL-setting is done by fplInit(). */ struct Local *usersym; /* Pointer to list holding all global symbols declared in another FPL program run. These symbols are legal global symbols */ struct Identifier *func; /* pointer to the current interpreted function or NULL */ uchar **string_return; /* whether this program should allow strings to be returned to the host program (set with the FPLTAG_STRING_RETURN tag to 'fplExecuteXXX()'). */ uchar *identifier; /* host program identifier. This should point to a unique string to enable separation between different processes use of FPL library functions! */ long breaks; /* number of levels possible to break! Each nested for, do, while and switch increases, each end of the same decreases as well as break, return and exit */ long conts; /* number of possible continue levels */#define ADDBUFFER_SIZE 32 /* buffered size; before appending string */ uchar addchar_buffer[ADDBUFFER_SIZE]; long addchar_len; uchar switchtype; /* in a switch Script() call, this controls what kind of 'case' -expressions we should allow! */#define SWITCH_NUM 1#define SWITCH_STR 2 long currvariables; /* current amount of variables declared in the function */ long maxvariables; /* maximum number of variables declared at the same time within a single function */ long totalvariables; /* total number of variables declared in a single function */ long *cmdline; /* pointer to array with command line info see cmdline.h */ char newerror; /* set when a new error has been reported. If Script() fails without it being set, we know we have struck one of those old-style error messages! */};/***** Data.flags: *****/#define FPLDATA_ALLFUNCTIONS (1<<0)/* Accept all functions, even if not found! */#define FPLDATA_CACHEFILE (1<<1)/* This file should be cached among the other global data. */#define FPLDATA_CACHEALLFILES (1<<2)/* This makes FPL store all files in memory that it has to remember */#define FPLDATA_CACHEEXPORTS (1<<3)/* This makes FPL store all files in memory that exports symbols */#define FPLDATA_NESTED_COMMENTS (1<<6)/* Allow nested comments */#define FPLDATA_REREAD_CHANGES (1<<7)/* Mark all files by default to get reread into memory when its accessed and the actual file is changed on disk, the symbols for that file will be removed and the file re-read into memory! */#define FPLDATA_FLUSH_NOT_IN_USE (1<<8)/* Mark all files by default to be flushed from memory when not used! */#define FPLDATA_DEBUG_MODE (1<<9) /* currently running in debug mode! */#define FPLDATA_DEBUG_GLOBAL (1<<10) /* always debug mode! */#define FPLDATA_DEBUG (FPLDATA_DEBUG_MODE|FPLDATA_DEBUG_GLOBAL)#define FPLDATA_KIDNAP_CACHED (1<<11) /* kidnap mode default */#define FPLDATA_PREVENT_RUNNING_SAME (1<<12) /* never execute a file that is cached and hasn't been changed since last execution *//********************************************************************** * * * All functions used from external functions. * * * **********************************************************************/ReturnCode REGARGS fplExecuteFile(struct Data *, uchar *);void * REGARGS fplInit(long *);void REGARGS fplFree(struct Data *);/********************************************************************** * All functions used globally in the library. * **********************************************************************/ReturnCode ASM Script(AREG(2) struct Data *, AREG(3) struct Expr *, DREG(2) short);ReturnCode REGARGS Expression(struct Expr *, struct Data *, long, struct Identifier *);ReturnCode REGARGS Eat(struct Data *);ReturnCode REGARGS Getword(struct Data *);uchar * REGARGS GetErrorMsg(struct Data *, long, uchar *);ReturnCode REGARGS ReadFile(void *, uchar *);ReturnCode REGARGS Newline(struct Data *);long REGARGS Strtol(uchar *, long, uchar **);ReturnCode REGARGS NewMember(struct Data *, struct Expr **);ReturnCode REGARGS AddVar(struct Data *, struct Identifier *, struct Local **, uchar);ReturnCode REGARGS ReturnChar(struct Data *, long *, uchar);ReturnCode REGARGS GetEnd(struct Data *, uchar, uchar, uchar);ReturnCode REGARGS AppendStringToString(struct Data *, struct fplStr **, uchar *, long);ReturnCode REGARGS Send(struct Data *, unsigned long *);unsigned long Gethash(uchar *);ReturnCode REGARGS GetIdentifier(struct Data *, uchar *, struct Identifier **);ReturnCode REGARGS DelIdentifier(struct Data *, uchar *, struct Identifier *);void ASM *DefaultAlloc(DREG(0) long, AREG(0) void *);void ASM DefaultDealloc(AREG(1) void *, DREG(0) long, AREG(0) void *);long REGARGS DelLocalVar(struct Data *, struct Local **);ReturnCode REGARGS AddLevel(struct Data *);long REGARGS ArrayNum(long, long, long *, long *);ReturnCode REGARGS ArrayResize(struct Data *, long, long *, struct Identifier *);void REGARGS CleanUp(struct Data *, long, long);long REGARGS BitToggle(long, long, long);ReturnCode REGARGS HashScan(struct Data *);ReturnCode REGARGS StringExpr(struct Expr *, struct Data *);ReturnCode REGARGS AddCharBuffer(struct Data *, struct fplStr **, long);#define ADD_RESET -1 /* reset buffer */#define ADD_FLUSH -2 /* flush buffer */#include "comp.h"#include "error.h" /* compiler error messages */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -