00001 /*************************************************************************** 00002 toyparse.h 00003 Functions used in the Toy Memory Manager String Parser. 00004 00005 How the parser works: 00006 At the root of it all, is the command table. It contains 00007 a list of pointers; each pointer points to a list of strings. 00008 Both the table and each list in it are NULL-terminated. 00009 The strings denote valid commands or valid command forms. 00010 For instance, say you have the root category of 'value'. Being 00011 the first thing in the command table, it would be at index 0, 00012 and point to a list of strings, like { "#%d","\"%s",NULL }; 00013 %d means accept any sequence of numbers in that spot, %s means 00014 accept any integer values in that spot. So both "#100" and "\"Hello" 00015 would be accepted as valid commands. "#100" would be subcommand 00016 0, while "\"Hello" would be subcommand 1. 00017 ------------------- 00018 begin : Sat Jan 25 2003 00019 copyright : (C) 2003 by Tyler Montbriand 00020 student # : 200200370 00021 class : CS330 00022 email : tsm@accesscomm.ca 00023 ***************************************************************************/ 00024 00025 #ifndef __TOYPARSE_H__ 00026 #define __TOYPARSE_H__ 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif/*__cplusplus*/ 00031 00032 #include <SDL/begin_code.h> 00033 00051 00060 typedef struct TokenType 00061 { 00063 int type; 00065 int subtype; 00067 char *token; 00068 } TokenType; 00069 00071 DECLSPEC void SDLCALL FreeType(TokenType *types); 00073 DECLSPEC TokenType *SDLCALL LineToTypes(const char *str, const char **table[]); 00074 00076 DECLSPEC int SDLCALL DetermineType(const char *str, const char **table[]); 00077 00079 DECLSPEC int SDLCALL DetermineSubType(int type,const char *str, const char **args[]); 00080 00081 DECLSPEC int SDLCALL CheckLineSyntax(TokenType *tarray, ...); 00082 00084 #define TYPE_ENDOPEN 0xffff 00085 00086 #define TYPE_ENDCLOSE 0xfffe 00087 00090 #include <SDL/close_code.h> 00091 00092 #ifdef __cplusplus 00093 } 00094 #endif/*__cplusplus*/ 00095 00096 #endif/*__TOYPARSE_H__*/