Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

l_script.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  punctuation_s
struct  script_s
struct  token_s

Defines

#define BINARYNUMBERS
#define DOLLAR
#define MAX_TOKEN   1024
#define NUMBERVALUE
#define P_ADD   29
#define P_ADD_ASSIGN   14
#define P_ASSIGN   31
#define P_BACKSLASH   50
#define P_BIN_AND   32
#define P_BIN_AND_ASSIGN   18
#define P_BIN_NOT   35
#define P_BIN_OR   33
#define P_BIN_OR_ASSIGN   19
#define P_BIN_XOR   34
#define P_BIN_XOR_ASSIGN   20
#define P_BRACECLOSE   47
#define P_BRACEOPEN   46
#define P_COLON   42
#define P_COMMA   40
#define P_CPP1   24
#define P_CPP2   25
#define P_DEC   17
#define P_DIV   27
#define P_DIV_ASSIGN   12
#define P_DOLLAR   52
#define P_INC   16
#define P_LOGIC_AND   5
#define P_LOGIC_EQ   9
#define P_LOGIC_GEQ   7
#define P_LOGIC_GREATER   37
#define P_LOGIC_LEQ   8
#define P_LOGIC_LESS   38
#define P_LOGIC_NOT   36
#define P_LOGIC_OR   6
#define P_LOGIC_UNEQ   10
#define P_LSHIFT   22
#define P_LSHIFT_ASSIGN   2
#define P_MOD   28
#define P_MOD_ASSIGN   13
#define P_MUL   26
#define P_MUL_ASSIGN   11
#define P_PARENTHESESCLOSE   45
#define P_PARENTHESESOPEN   44
#define P_PARMS   3
#define P_POINTERREF   23
#define P_PRECOMP   51
#define P_PRECOMPMERGE   4
#define P_QUESTIONMARK   43
#define P_REF   39
#define P_RSHIFT   21
#define P_RSHIFT_ASSIGN   1
#define P_SEMICOLON   41
#define P_SQBRACKETCLOSE   49
#define P_SQBRACKETOPEN   48
#define P_SUB   30
#define P_SUB_ASSIGN   15
#define SCFL_NOBINARYNUMBERS   0x0020
#define SCFL_NOERRORS   0x0001
#define SCFL_NONUMBERVALUES   0x0040
#define SCFL_NOSTRINGESCAPECHARS   0x0008
#define SCFL_NOSTRINGWHITESPACES   0x0004
#define SCFL_NOWARNINGS   0x0002
#define SCFL_PRIMITIVE   0x0010
#define TT_BINARY   0x0400
#define TT_DECIMAL   0x0008
#define TT_FLOAT   0x0800
#define TT_HEX   0x0100
#define TT_INTEGER   0x1000
#define TT_LITERAL   2
#define TT_LONG   0x2000
#define TT_NAME   4
#define TT_NUMBER   3
#define TT_OCTAL   0x0200
#define TT_PUNCTUATION   5
#define TT_STRING   1
#define TT_UNSIGNED   0x4000

Typedefs

typedef punctuation_s punctuation_t
typedef script_s script_t
typedef token_s token_t

Functions

int EndOfScript (script_t *script)
void FreeScript (script_t *script)
int GetScriptFlags (script_t *script)
script_tLoadScriptFile (const char *filename)
script_tLoadScriptMemory (char *ptr, int length, char *name)
int PS_CheckTokenString (script_t *script, char *string)
int PS_CheckTokenType (script_t *script, int type, int subtype, token_t *token)
int PS_ExpectAnyToken (script_t *script, token_t *token)
int PS_ExpectTokenString (script_t *script, char *string)
int PS_ExpectTokenType (script_t *script, int type, int subtype, token_t *token)
char PS_NextWhiteSpaceChar (script_t *script)
int PS_ReadToken (script_t *script, token_t *token)
void PS_SetBaseFolder (char *path)
int PS_SkipUntilString (script_t *script, char *string)
void PS_UnreadLastToken (script_t *script)
void PS_UnreadToken (script_t *script, token_t *token)
char * PunctuationFromNum (script_t *script, int num)
long double ReadSignedFloat (script_t *script)
signed long int ReadSignedInt (script_t *script)
void ResetScript (script_t *script)
void QDECL ScriptError (script_t *script, char *str,...)
void QDECL ScriptWarning (script_t *script, char *str,...)
void SetScriptFlags (script_t *script, int flags)
void SetScriptPunctuations (script_t *script, punctuation_t *p)
void StripDoubleQuotes (char *string)
void StripSingleQuotes (char *string)


Define Documentation

#define BINARYNUMBERS
 

Definition at line 33 of file l_script.h.

#define DOLLAR
 

Definition at line 37 of file l_script.h.

#define MAX_TOKEN   1024
 

Definition at line 40 of file l_script.h.

Referenced by PC_ReadToken(), PC_StringizeTokens(), PS_ReadName(), PS_ReadNumber(), PS_ReadPrimitive(), PS_ReadPunctuation(), and PS_ReadString().

#define NUMBERVALUE
 

Definition at line 35 of file l_script.h.

#define P_ADD   29
 

Definition at line 115 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_ADD_ASSIGN   14
 

Definition at line 98 of file l_script.h.

#define P_ASSIGN   31
 

Definition at line 117 of file l_script.h.

#define P_BACKSLASH   50
 

Definition at line 140 of file l_script.h.

#define P_BIN_AND   32
 

Definition at line 119 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_BIN_AND_ASSIGN   18
 

Definition at line 103 of file l_script.h.

#define P_BIN_NOT   35
 

Definition at line 122 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_BIN_OR   33
 

Definition at line 120 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_BIN_OR_ASSIGN   19
 

Definition at line 104 of file l_script.h.

#define P_BIN_XOR   34
 

Definition at line 121 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_BIN_XOR_ASSIGN   20
 

Definition at line 105 of file l_script.h.

#define P_BRACECLOSE   47
 

Definition at line 137 of file l_script.h.

#define P_BRACEOPEN   46
 

Definition at line 136 of file l_script.h.

#define P_COLON   42
 

Definition at line 131 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_COMMA   40
 

Definition at line 129 of file l_script.h.

#define P_CPP1   24
 

Definition at line 110 of file l_script.h.

#define P_CPP2   25
 

Definition at line 111 of file l_script.h.

#define P_DEC   17
 

Definition at line 101 of file l_script.h.

Referenced by PC_EvaluateTokens().

#define P_DIV   27
 

Definition at line 113 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_DIV_ASSIGN   12
 

Definition at line 96 of file l_script.h.

#define P_DOLLAR   52
 

Definition at line 143 of file l_script.h.

#define P_INC   16
 

Definition at line 100 of file l_script.h.

Referenced by PC_EvaluateTokens().

#define P_LOGIC_AND   5
 

Definition at line 88 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LOGIC_EQ   9
 

Definition at line 92 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LOGIC_GEQ   7
 

Definition at line 90 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LOGIC_GREATER   37
 

Definition at line 125 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LOGIC_LEQ   8
 

Definition at line 91 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LOGIC_LESS   38
 

Definition at line 126 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LOGIC_NOT   36
 

Definition at line 124 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LOGIC_OR   6
 

Definition at line 89 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LOGIC_UNEQ   10
 

Definition at line 93 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LSHIFT   22
 

Definition at line 107 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_LSHIFT_ASSIGN   2
 

Definition at line 84 of file l_script.h.

#define P_MOD   28
 

Definition at line 114 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_MOD_ASSIGN   13
 

Definition at line 97 of file l_script.h.

#define P_MUL   26
 

Definition at line 112 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_MUL_ASSIGN   11
 

Definition at line 95 of file l_script.h.

#define P_PARENTHESESCLOSE   45
 

Definition at line 135 of file l_script.h.

#define P_PARENTHESESOPEN   44
 

Definition at line 134 of file l_script.h.

#define P_PARMS   3
 

Definition at line 85 of file l_script.h.

#define P_POINTERREF   23
 

Definition at line 109 of file l_script.h.

#define P_PRECOMP   51
 

Definition at line 142 of file l_script.h.

#define P_PRECOMPMERGE   4
 

Definition at line 86 of file l_script.h.

#define P_QUESTIONMARK   43
 

Definition at line 132 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_REF   39
 

Definition at line 128 of file l_script.h.

#define P_RSHIFT   21
 

Definition at line 106 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_RSHIFT_ASSIGN   1
 

Definition at line 83 of file l_script.h.

#define P_SEMICOLON   41
 

Definition at line 130 of file l_script.h.

#define P_SQBRACKETCLOSE   49
 

Definition at line 139 of file l_script.h.

#define P_SQBRACKETOPEN   48
 

Definition at line 138 of file l_script.h.

#define P_SUB   30
 

Definition at line 116 of file l_script.h.

Referenced by PC_EvaluateTokens(), and PC_OperatorPriority().

#define P_SUB_ASSIGN   15
 

Definition at line 99 of file l_script.h.

#define SCFL_NOBINARYNUMBERS   0x0020
 

Definition at line 53 of file l_script.h.

#define SCFL_NOERRORS   0x0001
 

Definition at line 48 of file l_script.h.

#define SCFL_NONUMBERVALUES   0x0040
 

Definition at line 54 of file l_script.h.

#define SCFL_NOSTRINGESCAPECHARS   0x0008
 

Definition at line 51 of file l_script.h.

Referenced by AAS_ParseBSPEntities(), HL_ParseEntities(), Q1_ParseEntities(), Q2_LoadMapFile(), Q2_ParseEntities(), Q3_ParseEntities(), and Sin_ParseEntities().

#define SCFL_NOSTRINGWHITESPACES   0x0004
 

Definition at line 50 of file l_script.h.

Referenced by AAS_ParseBSPEntities(), HL_ParseEntities(), Q1_ParseEntities(), Q2_LoadMapFile(), Q2_ParseEntities(), Q3_ParseEntities(), and Sin_ParseEntities().

#define SCFL_NOWARNINGS   0x0002
 

Definition at line 49 of file l_script.h.

#define SCFL_PRIMITIVE   0x0010
 

Definition at line 52 of file l_script.h.

Referenced by Q2_LoadMapFile().

#define TT_BINARY   0x0400
 

Definition at line 75 of file l_script.h.

#define TT_DECIMAL   0x0008
 

Definition at line 71 of file l_script.h.

Referenced by PC_ExpandBuiltinDefine().

#define TT_FLOAT   0x0800
 

Definition at line 77 of file l_script.h.

Referenced by PC_Directive_evalfloat(), and PC_DollarDirective_evalfloat().

#define TT_HEX   0x0100
 

Definition at line 72 of file l_script.h.

#define TT_INTEGER   0x1000
 

Definition at line 78 of file l_script.h.

Referenced by BotLoadMatchTemplates(), PC_Directive_eval(), PC_DollarDirective_evalint(), ReadFuzzySeperators_r(), and ReadSignedInt().

#define TT_LITERAL   2
 

Definition at line 58 of file l_script.h.

#define TT_LONG   0x2000
 

Definition at line 79 of file l_script.h.

Referenced by PC_Directive_eval(), PC_Directive_evalfloat(), PC_DollarDirective_evalfloat(), and PC_DollarDirective_evalint().

#define TT_NAME   4
 

Definition at line 60 of file l_script.h.

Referenced by PC_Directive_define(), PC_EvaluateTokens(), and PC_MergeTokens().

#define TT_NUMBER   3
 

Definition at line 59 of file l_script.h.

Referenced by BotLoadCharacterFromFile(), BotLoadChatMessage(), BotLoadMatchPieces(), BotLoadMatchTemplates(), BotLoadReplyChat(), BotLoadSynonyms(), PC_DollarEvaluate(), PC_Evaluate(), PC_EvaluateTokens(), Q2_ParseBrush(), ReadFuzzySeperators_r(), ReadSignedFloat(), ReadSignedInt(), and ReadValue().

#define TT_OCTAL   0x0200
 

Definition at line 73 of file l_script.h.

#define TT_PUNCTUATION   5
 

Definition at line 61 of file l_script.h.

Referenced by PC_Directive_include(), PC_EvaluateTokens(), and PC_ReadToken().

#define TT_STRING   1
 

Definition at line 57 of file l_script.h.

Referenced by AAS_ParseBSPEntities(), BotLoadInitialChat(), BotLoadMatchPieces(), BotLoadReplyChat(), BotLoadSynonyms(), LoadItemConfig(), PC_MergeTokens(), ReadString(), and ReadWeightConfig().

#define TT_UNSIGNED   0x4000
 

Definition at line 80 of file l_script.h.

Referenced by PS_ReadNumber().


Typedef Documentation

typedef struct punctuation_s punctuation_t
 

Referenced by PC_SetPunctuations(), PS_CreatePunctuationTable(), PS_ReadPunctuation(), and SetScriptPunctuations().

typedef struct script_s script_t
 

Referenced by LoadScriptFile(), and LoadScriptMemory().

typedef struct token_s token_t
 

Referenced by AAS_ParseBSPEntities(), BotLoadCharacterFromFile(), BotLoadChatMessage(), BotLoadInitialChat(), BotLoadMatchPieces(), BotLoadMatchTemplates(), BotLoadRandomStrings(), BotLoadReplyChat(), BotLoadSynonyms(), FreeSource(), LoadCfgFile(), LoadItemConfig(), LoadWeaponConfig(), ParseEntity(), ParseEpair(), PC_CheckTokenString(), PC_CheckTokenType(), PC_ClearTokenWhiteSpace(), PC_CopyDefine(), PC_CopyToken(), PC_DefineFromString(), PC_Directive_define(), PC_Directive_error(), PC_Directive_eval(), PC_Directive_evalfloat(), PC_Directive_if_def(), PC_Directive_include(), PC_Directive_pragma(), PC_Directive_undef(), PC_DollarDirective_evalfloat(), PC_DollarDirective_evalint(), PC_DollarEvaluate(), PC_Evaluate(), PC_EvaluateTokens(), PC_ExpandBuiltinDefine(), PC_ExpandDefine(), PC_ExpandDefineIntoSource(), PC_ExpectAnyToken(), PC_ExpectTokenString(), PC_ExpectTokenType(), PC_FindDefineParm(), PC_FreeDefine(), PC_FreeToken(), PC_MergeTokens(), PC_ReadDefineParms(), PC_ReadDirective(), PC_ReadDollarDirective(), PC_ReadLine(), PC_ReadSourceToken(), PC_ReadToken(), PC_ReadTokenHandle(), PC_SkipUntilString(), PC_StringizeTokens(), PC_UnreadSourceToken(), PC_UnreadToken(), PC_WhiteSpaceBeforeToken(), PS_CheckTokenString(), PS_CheckTokenType(), PS_ExpectAnyToken(), PS_ExpectTokenString(), PS_ExpectTokenType(), PS_ReadLiteral(), PS_ReadName(), PS_ReadNumber(), PS_ReadPrimitive(), PS_ReadPunctuation(), PS_ReadString(), PS_ReadToken(), PS_SkipUntilString(), PS_UnreadToken(), Q2_ParseBrush(), Q2_ParseMapEntity(), ReadChar(), ReadFuzzySeperators_r(), ReadNumber(), ReadSignedFloat(), ReadSignedInt(), ReadString(), ReadStructure(), ReadValue(), ReadWeightConfig(), ResetScript(), and UnreadSignToken().


Function Documentation

int EndOfScript script_t script  ) 
 

Definition at line 1242 of file l_script.c.

References script_t::end_p, script, and script_t::script_p.

01243 {
01244     return script->script_p >= script->end_p;
01245 } //end of the function EndOfScript

void FreeScript script_t script  ) 
 

Definition at line 1413 of file l_script.c.

References FreeMemory(), and script.

Referenced by AAS_ParseBSPEntities(), FreeSource(), HL_ParseEntities(), PC_DefineFromString(), PC_ReadSourceToken(), Q1_ParseEntities(), Q2_LoadMapFile(), Q2_ParseEntities(), Q3_ParseEntities(), and Sin_ParseEntities().

01414 {
01415 #ifdef PUNCTABLE
01416     if (script->punctuationtable) FreeMemory(script->punctuationtable);
01417 #endif //PUNCTABLE
01418     FreeMemory(script);
01419 } //end of the function FreeScript

Here is the call graph for this function:

int GetScriptFlags script_t script  ) 
 

Definition at line 1207 of file l_script.c.

References script.

01208 {
01209     return script->flags;
01210 } //end of the function GetScriptFlags

script_t* LoadScriptFile const char *  filename  ) 
 

Definition at line 1308 of file l_script.c.

01309 {
01310 #ifdef BOTLIB
01311     fileHandle_t fp;
01312     char pathname[MAX_QPATH];
01313 #else
01314     FILE *fp;
01315 #endif
01316     int length;
01317     void *buffer;
01318     script_t *script;
01319 
01320 #ifdef BOTLIB
01321     if (strlen(basefolder))
01322         Com_sprintf(pathname, sizeof(pathname), "%s/%s", basefolder, filename);
01323     else
01324         Com_sprintf(pathname, sizeof(pathname), "%s", filename);
01325     length = botimport.FS_FOpenFile( pathname, &fp, FS_READ );
01326     if (!fp) return NULL;
01327 #else
01328     fp = fopen(filename, "rb");
01329     if (!fp) return NULL;
01330 
01331     length = FileLength(fp);
01332 #endif
01333 
01334     buffer = GetClearedMemory(sizeof(script_t) + length + 1);
01335     script = (script_t *) buffer;
01336     Com_Memset(script, 0, sizeof(script_t));
01337     strcpy(script->filename, filename);
01338     script->buffer = (char *) buffer + sizeof(script_t);
01339     script->buffer[length] = 0;
01340     script->length = length;
01341     //pointer in script buffer
01342     script->script_p = script->buffer;
01343     //pointer in script buffer before reading token
01344     script->lastscript_p = script->buffer;
01345     //pointer to end of script buffer
01346     script->end_p = &script->buffer[length];
01347     //set if there's a token available in script->token
01348     script->tokenavailable = 0;
01349     //
01350     script->line = 1;
01351     script->lastline = 1;
01352     //
01353     SetScriptPunctuations(script, NULL);
01354     //
01355 #ifdef BOTLIB
01356     botimport.FS_Read(script->buffer, length, fp);
01357     botimport.FS_FCloseFile(fp);
01358 #else
01359     if (fread(script->buffer, length, 1, fp) != 1)
01360     {
01361         FreeMemory(buffer);
01362         script = NULL;
01363     } //end if
01364     fclose(fp);
01365 #endif
01366     //
01367     script->length = COM_Compress(script->buffer);
01368 
01369     return script;
01370 } //end of the function LoadScriptFile

script_t* LoadScriptMemory char *  ptr,
int  length,
char *  name
 

Definition at line 1377 of file l_script.c.

References script_t::buffer, buffer, Com_Memcpy(), Com_Memset(), script_t::end_p, script_t::filename, GetClearedMemory(), length(), script_t::line, name, NULL, ptr(), script, script_t::script_p, script_t, SetScriptPunctuations(), and strcpy().

Referenced by AAS_ParseBSPEntities(), HL_ParseEntities(), LoadSourceMemory(), PC_DefineFromString(), Q1_ParseEntities(), Q2_ParseEntities(), Q3_ParseEntities(), and Sin_ParseEntities().

01378 {
01379     void *buffer;
01380     script_t *script;
01381 
01382     buffer = GetClearedMemory(sizeof(script_t) + length + 1);
01383     script = (script_t *) buffer;
01384     Com_Memset(script, 0, sizeof(script_t));
01385     strcpy(script->filename, name);
01386     script->buffer = (char *) buffer + sizeof(script_t);
01387     script->buffer[length] = 0;
01388     script->length = length;
01389     //pointer in script buffer
01390     script->script_p = script->buffer;
01391     //pointer in script buffer before reading token
01392     script->lastscript_p = script->buffer;
01393     //pointer to end of script buffer
01394     script->end_p = &script->buffer[length];
01395     //set if there's a token available in script->token
01396     script->tokenavailable = 0;
01397     //
01398     script->line = 1;
01399     script->lastline = 1;
01400     //
01401     SetScriptPunctuations(script, NULL);
01402     //
01403     Com_Memcpy(script->buffer, ptr, length);
01404     //
01405     return script;
01406 } //end of the function LoadScriptMemory

Here is the call graph for this function:

int PS_CheckTokenString script_t script,
char *  string
 

Definition at line 1023 of file l_script.c.

References PS_ReadToken(), script, script_t::script_p, strcmp(), string(), token_s::string, and token_t.

01024 {
01025     token_t tok;
01026 
01027     if (!PS_ReadToken(script, &tok)) return 0;
01028     //if the token is available
01029     if (!strcmp(tok.string, string)) return 1;
01030     //token not available
01031     script->script_p = script->lastscript_p;
01032     return 0;
01033 } //end of the function PS_CheckTokenString

Here is the call graph for this function:

int PS_CheckTokenType script_t script,
int  type,
int  subtype,
token_t token
 

Definition at line 1040 of file l_script.c.

References Com_Memcpy(), PS_ReadToken(), script, script_t::script_p, token_s::subtype, token, token_t, type, and token_s::type.

Referenced by Q2_ParseBrush().

01041 {
01042     token_t tok;
01043 
01044     if (!PS_ReadToken(script, &tok)) return 0;
01045     //if the type matches
01046     if (tok.type == type &&
01047             (tok.subtype & subtype) == subtype)
01048     {
01049         Com_Memcpy(token, &tok, sizeof(token_t));
01050         return 1;
01051     } //end if
01052     //token is not available
01053     script->script_p = script->lastscript_p;
01054