diff options
Diffstat (limited to 'tokenizer.c')
-rw-r--r-- | tokenizer.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tokenizer.c b/tokenizer.c index f69d404..a7b3afb 100644 --- a/tokenizer.c +++ b/tokenizer.c @@ -1,5 +1,9 @@ #include "tokenizer.h" +/* options avaliable */ +#define ASSERT_ON +#define __EXIT_ABBORT +#include "assert.h" /*****************************************************************************/ token* token_create() @@ -14,6 +18,13 @@ token* token_create() /*****************************************************************************/ int token_set( token **tok, int val, char *s, char *e ) { + AS_NULL(s) + AS_NULL(e) + AS_NULL(tok) + AS_NULL(*tok) + AS_EXPR(s>e) + AS_EXPR(val<0) + if ( tok == NULL ) { printf("token is NULL\n"); @@ -64,6 +75,11 @@ error: /*****************************************************************************/ int tl_add_tok( token_list *tl, int t, char *s, char *e ) { + AS_NULL(tl) + AS_NULL(s) + AS_NULL(e) + AS_EXPR(t<1) + token *tok = NULL; tok = token_create(); if (tok == NULL) @@ -80,6 +96,7 @@ int tl_add_tok( token_list *tl, int t, char *s, char *e ) /*****************************************************************************/ char* tl_str( token_list *tl ) { + AS_NULL(tl) int i = 0; for (i=0; i<darr_end(tl->list); i++) @@ -105,18 +122,24 @@ void tl_destroy( token_list *tl ) { darr_clear_destroy( tl->list ); } + + free(tl); } /*****************************************************************************/ int tl_size( token_list *tl ) { + AS_NULL(tl) + return darr_end( tl->list ); } int tok2int( token *tok ) { + AS_NULL(tok) + char str[128]; int sz = tok->e - tok->s; memcpy(str,tok->s,sz); @@ -128,6 +151,6 @@ int tok2int( token *tok ) char *tok2str( token *tok ) { - + return NULL; } |