aboutsummaryrefslogtreecommitdiff
path: root/src/token.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/token.cc')
-rw-r--r--src/token.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/token.cc b/src/token.cc
index ad9dd92..6045f30 100644
--- a/src/token.cc
+++ b/src/token.cc
@@ -6,22 +6,22 @@
void
Token::init(TokenType type, char *lexeme, unsigned int line)
{
- this->type = type;
- this->lexeme = lexeme;
- this->line = line;
- this->string = NULL;
+ m_type = type;
+ m_lexeme = lexeme;
+ m_line = line;
+ m_string = NULL;
}
char *
Token::to_string(void)
{
- unsigned int line_length = snprintf(NULL, 0, "%ul", line) - 1;
+ unsigned int line_length = snprintf(NULL, 0, "%ul", m_line) - 1;
/* 2: ": ", 1: "\0" */
- unsigned int final_size = strlen(lexeme) + line_length + 2 + 1;
+ unsigned int final_size = strlen(m_lexeme) + line_length + 2 + 1;
char *result = (char *) calloc(1, final_size);
- snprintf(result, final_size, "%d: %s", line, lexeme);
- string = result;
+ snprintf(result, final_size, "%d: %s", m_line, m_lexeme);
+ m_string = result;
return result;
}
@@ -29,6 +29,6 @@ Token::to_string(void)
void
Token::clean(void)
{
- if (string != NULL)
- free(string);
+ if (m_string != NULL)
+ free(m_string);
}