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 : monttyle@heavyspace.ca 00023 ***************************************************************************/ 00024 00025 #ifndef __TOYPARSE_H__ 00026 #define __TOYPARSE_H__ 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif/*__cplusplus*/ 00031 00049 00056 #define BAIL_IF(value,func,errval) if(value) { func; return(errval); } 00057 00058 00063 typedef struct TokenType 00064 { 00066 int type; 00068 int subtype; 00070 char *token; 00071 } TokenType; 00072 00074 void FreeType(TokenType *types); 00076 TokenType *LineToTypes(const char *str, const char **table[]); 00077 00079 int DetermineType(const char *str, const char **table[]); 00080 00082 int DetermineSubType(int type,const char *str, const char **args[]); 00083 00084 int CheckLineSyntax(TokenType *tarray, ...); 00085 00087 #define TYPE_ENDOPEN 0xffff 00088 00089 #define TYPE_ENDCLOSE 0xfffe 00090 00093 #ifdef __cplusplus 00094 } 00095 #endif/*__cplusplus*/ 00096 00097 #endif/*__TOYPARSE_H__*/
1.3-rc3