Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

toyparse.c File Reference

Implementations for generic tokenizer routines. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <malloc.h>
#include <stdarg.h>
#include "toyparse.h"
#include "toyparse_internal.h"

Include dependency graph for toyparse.c:

Include dependency graph

Go to the source code of this file.

Functions

int CheckLineSyntax (TokenType *tarray,...)
 Define PRINT_COMMENTS to print comments at runtime. Used for debugging. A generalized function to check the syntax of an array of token types.

TokenTypeLineToTypes (const char *str, const char **table[])
 Converts a line of text to an array of token-types.

void FreeType (TokenType *types)
 Frees an array of token-types and everything it contains.

TokenTypeTokensToType (const char **tokens, const char **table[])
 Converts a list of string-tokens to an array of types.

int DetermineSubType (int type, const char *str, const char **args[])
 Determines the sub-type from a known type.

int FindInList (const char *str, const char *list[])
 Finds specified string in a table of strings.

int DetermineType (const char *str, const char **table[])
 Determines the root type of a token.

int CompareType (const char *str, const char *typestr)
 Compares a word with a syntax-string to see if it matches the specified syntax.

void * AllocateArray (void *in, int size, int num)
char ** Explode (const char *strIn)
 Converts a string into a list of words - array of pointers to strings ending in NULL.

void FreeStrList (char **strList)
 Frees a list of words.


Detailed Description

Definition in file toyparse.c.


Function Documentation

void * AllocateArray void *  in,
int  size,
int  num
 

Convenience function. Allocate a new array if 'in' is NULL, or resize an existing one.

Definition at line 380 of file toyparse.c.

Referenced by Explode().

int CompareType const char *  str,
const char *  typestr
 

Returns 0 on syntax match, -1 on failure.

Definition at line 234 of file toyparse.c.

Referenced by FindInList().

char** Explode const char *  strIn  ) 
 

Returns a NULL-terminated array of string tokens on success, NULL on failure.

Definition at line 305 of file toyparse.c.

References AllocateArray().

Referenced by LineToTypes().

Here is the call graph for this function:

int FindInList const char *  str,
const char *  list[]
 

Returns the array index on match, -1 on failure.

Definition at line 207 of file toyparse.c.

References CompareType().

Referenced by DetermineSubType(), and DetermineType().

Here is the call graph for this function:

void FreeStrList char **  strList  ) 
 

Returns no values.

Definition at line 391 of file toyparse.c.

TokenType* TokensToType const char **  tokens,
const char **  table[]
 

Returns a tokentype array on success, NULL on failure.

Definition at line 140 of file toyparse.c.

References DetermineSubType(), DetermineType(), TokenType::subtype, TokenType::token, and TokenType::type.

Referenced by LineToTypes().

Here is the call graph for this function:


Generated on Sat Oct 11 13:19:33 2003 for Spritelib by doxygen 1.3.4