Added token_get_data() and token_set_data()

This commit is contained in:
Pierre Pronchery 2008-04-24 17:15:41 +00:00
parent 705057b22f
commit c8135f070c
2 changed files with 19 additions and 0 deletions

View File

@ -48,6 +48,9 @@ void token_set_code(Token * token, int code);
char const * token_get_string(Token * token);
int token_set_string(Token * token, char const * string);
void * token_get_data(Token * token);
void token_set_data(Token * token, void * data);
/* useful */
int token_in_set(Token * token, TokenSet set);

View File

@ -36,6 +36,7 @@ struct _Token
char * filename;
unsigned int line;
unsigned int col;
void * data;
};
@ -57,6 +58,7 @@ Token * token_new(char const * filename, unsigned int line, unsigned int col)
token->filename = strdup(filename);
token->line = line;
token->col = col;
token->data = NULL;
if(token->filename == NULL)
{
error_set_code(1, "%s", strerror(errno));
@ -91,6 +93,13 @@ unsigned int token_get_col(Token * token)
}
/* token_get_data */
void * token_get_data(Token * token)
{
return token->data;
}
/* token_get_filename */
char const * token_get_filename(Token * token)
{
@ -126,6 +135,13 @@ void token_set_col(Token * token, unsigned int col)
}
/* token_set_data */
void token_set_data(Token * token, void * data)
{
token->data = data;
}
/* token_set_filename */
int token_set_filename(Token * token, char const * filename)
{