Added accessors for the filename
This commit is contained in:
parent
ccb781960c
commit
fcab87e048
|
@ -33,6 +33,9 @@ void token_delete(Token * token);
|
|||
|
||||
|
||||
/* accessors */
|
||||
char const * token_get_filename(Token * token);
|
||||
int token_set_filename(Token * token, char const * filename);
|
||||
|
||||
unsigned int token_get_col(Token * token);
|
||||
void token_set_col(Token * token, unsigned int col);
|
||||
|
||||
|
|
17
src/token.c
17
src/token.c
|
@ -91,6 +91,13 @@ unsigned int token_get_col(Token * token)
|
|||
}
|
||||
|
||||
|
||||
/* token_get_filename */
|
||||
char const * token_get_filename(Token * token)
|
||||
{
|
||||
return token->filename;
|
||||
}
|
||||
|
||||
|
||||
/* token_get_line */
|
||||
unsigned int token_get_line(Token * token)
|
||||
{
|
||||
|
@ -119,6 +126,16 @@ void token_set_col(Token * token, unsigned int col)
|
|||
}
|
||||
|
||||
|
||||
/* token_set_filename */
|
||||
int token_set_filename(Token * token, char const * filename)
|
||||
{
|
||||
free(token->filename);
|
||||
if((token->filename = strdup(filename)) == NULL)
|
||||
return error_set_code(1, "%s", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* token_set_line */
|
||||
void token_set_line(Token * token, unsigned int line)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user