aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/filehandler.cc3
-rw-r--r--src/lexer.cc6
-rw-r--r--src/list.cc5
-rw-r--r--src/main.cc11
-rw-r--r--src/token.cc3
5 files changed, 19 insertions, 9 deletions
diff --git a/src/filehandler.cc b/src/filehandler.cc
index a901fc5..4856702 100644
--- a/src/filehandler.cc
+++ b/src/filehandler.cc
@@ -2,7 +2,8 @@
#include <stdio.h>
#include <stdlib.h>
-Filehandler::Filehandler(char *path)
+void
+Filehandler::init(char *path)
{
f = NULL;
buffer = NULL;
diff --git a/src/lexer.cc b/src/lexer.cc
index 086200e..baacdbb 100644
--- a/src/lexer.cc
+++ b/src/lexer.cc
@@ -1,8 +1,12 @@
#include <lexer.h>
#include <stdio.h>
-Lexer::Lexer(char *script) : script(script) {}
+void
+Lexer::init(char *script)
+{
+ this->script = script;
+}
void
Lexer::scan_tokens(void)
{
diff --git a/src/list.cc b/src/list.cc
index cd0dc7c..4518d89 100644
--- a/src/list.cc
+++ b/src/list.cc
@@ -5,12 +5,13 @@
#include <stdlib.h>
#include <string.h>
-List::List(size_t element_size)
+void
+List::init(size_t element_size)
{
this->element_size = element_size;
current = 0;
max = START_SIZE;
- elements = (uint8_t *) malloc(element_size * max);
+ elements = (uint8_t *) calloc(max, element_size);
}
void
diff --git a/src/main.cc b/src/main.cc
index 294e7d8..2ebf2a6 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -13,7 +13,8 @@ main(int argc, char **argv)
return 1;
}
- Filehandler f(argv[1]);
+ Filehandler f;
+ f.init(argv[1]);
bool opened = f.open();
if (!opened) {
@@ -27,10 +28,12 @@ main(int argc, char **argv)
return 1;
}
- Lexer s(buffer);
- s.scan_tokens();
+ Lexer l;
+ l.init(buffer);
+ l.scan_tokens();
- Token t(EOFF, "EOF", 221);
+ Token t;
+ t.init(EOFF, "EOF", 221);
printf("%s\n", t.to_string());
t.clean();
diff --git a/src/token.cc b/src/token.cc
index a776d01..ad9dd92 100644
--- a/src/token.cc
+++ b/src/token.cc
@@ -3,7 +3,8 @@
#include <string.h>
#include <token.h>
-Token::Token(TokenType type, char *lexeme, unsigned int line)
+void
+Token::init(TokenType type, char *lexeme, unsigned int line)
{
this->type = type;
this->lexeme = lexeme;