| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#ifndef PATH_SEPERATORSTR |
| 33 |
#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__) |
| 34 |
#define PATHSEPERATOR_STR "\\" |
| 35 |
#else |
| 36 |
#define PATHSEPERATOR_STR "/" |
| 37 |
#endif |
| 38 |
#endif |
| 39 |
#ifndef PATH_SEPERATORCHAR |
| 40 |
#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__) |
| 41 |
#define PATHSEPERATOR_CHAR '\\' |
| 42 |
#else |
| 43 |
#define PATHSEPERATOR_CHAR '/' |
| 44 |
#endif |
| 45 |
#endif |
| 46 |
|
| 47 |
#if defined(BSPC) && !defined(QDECL) |
| 48 |
#define QDECL |
| 49 |
#endif |
| 50 |
|
| 51 |
|
| 52 |
#define DEFINE_FIXED 0x0001 |
| 53 |
|
| 54 |
#define BUILTIN_LINE 1 |
| 55 |
#define BUILTIN_FILE 2 |
| 56 |
#define BUILTIN_DATE 3 |
| 57 |
#define BUILTIN_TIME 4 |
| 58 |
#define BUILTIN_STDC 5 |
| 59 |
|
| 60 |
#define INDENT_IF 0x0001 |
| 61 |
#define INDENT_ELSE 0x0002 |
| 62 |
#define INDENT_ELIF 0x0004 |
| 63 |
#define INDENT_IFDEF 0x0008 |
| 64 |
#define INDENT_IFNDEF 0x0010 |
| 65 |
|
| 66 |
|
| 67 |
typedef struct define_s |
| 68 |
{ |
| 69 |
char *name; |
| 70 |
int flags; |
| 71 |
int builtin; |
| 72 |
int numparms; |
| 73 |
token_t *parms; |
| 74 |
token_t *tokens; |
| 75 |
struct define_s *next; |
| 76 |
struct define_s *hashnext; |
| 77 |
} define_t; |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
typedef struct indent_s |
| 83 |
{ |
| 84 |
int type; |
| 85 |
int skip; |
| 86 |
script_t *script; |
| 87 |
struct indent_s *next; |
| 88 |
} indent_t; |
| 89 |
|
| 90 |
|
| 91 |
typedef struct source_s |
| 92 |
{ |
| 93 |
char filename[1024]; |
| 94 |
char includepath[1024]; |
| 95 |
punctuation_t *punctuations; |
| 96 |
script_t *scriptstack; |
| 97 |
token_t *tokens; |
| 98 |
define_t *defines; |
| 99 |
define_t **definehash; |
| 100 |
indent_t *indentstack; |
| 101 |
int skip; |
| 102 |
token_t token; |
| 103 |
} source_t; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
int PC_ReadToken(source_t *source, token_t *token); |
| 108 |
|
| 109 |
int PC_ExpectTokenString(source_t *source, char *string); |
| 110 |
|
| 111 |
int PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token); |
| 112 |
|
| 113 |
int PC_ExpectAnyToken(source_t *source, token_t *token); |
| 114 |
|
| 115 |
int PC_CheckTokenString(source_t *source, char *string); |
| 116 |
|
| 117 |
int PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token); |
| 118 |
|
| 119 |
int PC_SkipUntilString(source_t *source, char *string); |
| 120 |
|
| 121 |
void PC_UnreadLastToken(source_t *source); |
| 122 |
|
| 123 |
void PC_UnreadToken(source_t *source, token_t *token); |
| 124 |
|
| 125 |
int PC_ReadLine(source_t *source, token_t *token); |
| 126 |
|
| 127 |
int PC_WhiteSpaceBeforeToken(token_t *token); |
| 128 |
|
| 129 |
int PC_AddDefine(source_t *source, char *string); |
| 130 |
|
| 131 |
int PC_AddGlobalDefine(char *string); |
| 132 |
|
| 133 |
int PC_RemoveGlobalDefine(char *name); |
| 134 |
|
| 135 |
void PC_RemoveAllGlobalDefines(void); |
| 136 |
|
| 137 |
void PC_AddBuiltinDefines(source_t *source); |
| 138 |
|
| 139 |
void PC_SetIncludePath(source_t *source, char *path); |
| 140 |
|
| 141 |
void PC_SetPunctuations(source_t *source, punctuation_t *p); |
| 142 |
|
| 143 |
void PC_SetBaseFolder(char *path); |
| 144 |
|
| 145 |
source_t *LoadSourceFile(const char *filename); |
| 146 |
|
| 147 |
source_t *LoadSourceMemory(char *ptr, int length, char *name); |
| 148 |
|
| 149 |
void FreeSource(source_t *source); |
| 150 |
|
| 151 |
void QDECL SourceError(source_t *source, char *str, ...) Q_PRINTF_FUNC(2, 3); |
| 152 |
|
| 153 |
void QDECL SourceWarning(source_t *source, char *str, ...) Q_PRINTF_FUNC(2, 3); |
| 154 |
|
| 155 |
#ifdef BSPC |
| 156 |
|
| 157 |
|
| 158 |
#ifndef __Q_SHARED_H |
| 159 |
#define MAX_TOKENLENGTH 1024 |
| 160 |
typedef struct pc_token_s |
| 161 |
{ |
| 162 |
int type; |
| 163 |
int subtype; |
| 164 |
int intvalue; |
| 165 |
float floatvalue; |
| 166 |
char string[MAX_TOKENLENGTH]; |
| 167 |
} pc_token_t; |
| 168 |
#endif |
| 169 |
#endif |
| 170 |
|
| 171 |
|
| 172 |
int PC_LoadSourceHandle(const char *filename); |
| 173 |
int PC_FreeSourceHandle(int handle); |
| 174 |
int PC_ReadTokenHandle(int handle, pc_token_t *pc_token); |
| 175 |
int PC_SourceFileAndLine(int handle, char *filename, int *line); |
| 176 |
void PC_CheckOpenSourceHandles(void); |