00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef MAX_PATH
00033 #define MAX_PATH MAX_QPATH
00034 #endif
00035
00036 #ifndef PATH_SEPERATORSTR
00037 #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
00038 #define PATHSEPERATOR_STR "\\"
00039 #else
00040 #define PATHSEPERATOR_STR "/"
00041 #endif
00042 #endif
00043 #ifndef PATH_SEPERATORCHAR
00044 #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
00045 #define PATHSEPERATOR_CHAR '\\'
00046 #else
00047 #define PATHSEPERATOR_CHAR '/'
00048 #endif
00049 #endif
00050
00051 #if defined(BSPC) && !defined(QDECL)
00052 #define QDECL
00053 #endif
00054
00055
00056 #define DEFINE_FIXED 0x0001
00057
00058 #define BUILTIN_LINE 1
00059 #define BUILTIN_FILE 2
00060 #define BUILTIN_DATE 3
00061 #define BUILTIN_TIME 4
00062 #define BUILTIN_STDC 5
00063
00064 #define INDENT_IF 0x0001
00065 #define INDENT_ELSE 0x0002
00066 #define INDENT_ELIF 0x0004
00067 #define INDENT_IFDEF 0x0008
00068 #define INDENT_IFNDEF 0x0010
00069
00070
00071 typedef struct define_s
00072 {
00073 char *name;
00074 int flags;
00075 int builtin;
00076 int numparms;
00077 token_t *parms;
00078 token_t *tokens;
00079 struct define_s *next;
00080 struct define_s *hashnext;
00081 } define_t;
00082
00083
00084
00085
00086 typedef struct indent_s
00087 {
00088 int type;
00089 int skip;
00090 script_t *script;
00091 struct indent_s *next;
00092 } indent_t;
00093
00094
00095 typedef struct source_s
00096 {
00097 char filename[1024];
00098 char includepath[1024];
00099 punctuation_t *punctuations;
00100 script_t *scriptstack;
00101 token_t *tokens;
00102 define_t *defines;
00103 define_t **definehash;
00104 indent_t *indentstack;
00105 int skip;
00106 token_t token;
00107 } source_t;
00108
00109
00110
00111 int PC_ReadToken(source_t *source, token_t *token);
00112
00113 int PC_ExpectTokenString(source_t *source, char *string);
00114
00115 int PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token);
00116
00117 int PC_ExpectAnyToken(source_t *source, token_t *token);
00118
00119 int PC_CheckTokenString(source_t *source, char *string);
00120
00121 int PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token);
00122
00123 int PC_SkipUntilString(source_t *source, char *string);
00124
00125 void PC_UnreadLastToken(source_t *source);
00126
00127 void PC_UnreadToken(source_t *source, token_t *token);
00128
00129 int PC_ReadLine(source_t *source, token_t *token);
00130
00131 int PC_WhiteSpaceBeforeToken(token_t *token);
00132
00133 int PC_AddDefine(source_t *source, char *string);
00134
00135 int PC_AddGlobalDefine(char *string);
00136
00137 int PC_RemoveGlobalDefine(char *name);
00138
00139 void PC_RemoveAllGlobalDefines(void);
00140
00141 void PC_AddBuiltinDefines(source_t *source);
00142
00143 void PC_SetIncludePath(source_t *source, char *path);
00144
00145 void PC_SetPunctuations(source_t *source, punctuation_t *p);
00146
00147 void PC_SetBaseFolder(char *path);
00148
00149 source_t *LoadSourceFile(const char *filename);
00150
00151 source_t *LoadSourceMemory(char *ptr, int length, char *name);
00152
00153 void FreeSource(source_t *source);
00154
00155 void QDECL SourceError(source_t *source, char *str, ...);
00156
00157 void QDECL SourceWarning(source_t *source, char *str, ...);
00158
00159 #ifdef BSPC
00160
00161
00162 #ifndef __Q_SHARED_H
00163 #define MAX_TOKENLENGTH 1024
00164 typedef struct pc_token_s
00165 {
00166 int type;
00167 int subtype;
00168 int intvalue;
00169 float floatvalue;
00170 char string[MAX_TOKENLENGTH];
00171 } pc_token_t;
00172 #endif
00173 #endif //BSPC
00174
00175
00176 int PC_LoadSourceHandle(const char *filename);
00177 int PC_FreeSourceHandle(int handle);
00178 int PC_ReadTokenHandle(int handle, pc_token_t *pc_token);
00179 int PC_SourceFileAndLine(int handle, char *filename, int *line);
00180 void PC_CheckOpenSourceHandles(void);