diff options
author | s-over-4 | 2023-06-15 19:01:32 -0400 |
---|---|---|
committer | s-over-4 | 2023-06-15 19:01:32 -0400 |
commit | c7d0b43b200ee2103653468c76050c1113299fea (patch) | |
tree | c28d081e2ba7f64fbd93154ebec555bb22a8e9d1 | |
parent | 4c41e9f95d23f9ba322b2516164cd4bab0b439fa (diff) |
fixed everything and changed Makefile a bit
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | examples/hello.halk | 2 | ||||
-rw-r--r-- | src/lexer.c | 7 | ||||
-rw-r--r-- | src/util.c | 15 |
4 files changed, 8 insertions, 22 deletions
@@ -1,6 +1,7 @@ name := halk cc := cc -flags := -g +flags := -s +devflags := -g sources := $(wildcard src/*.c) sources := $(filter-out src/parser.c, $(sources)) # exclude the incomplete parser for now. objects := $(sources:.c=.o) @@ -8,6 +9,9 @@ objects := $(sources:.c=.o) $(name): $(objects) $(cc) $(objects) $(flags) -o ./$(name).out +dev: $(objects) + $(cc) $(objects) $(devflags) -o ./$(name).out + %.o: %.c include/%.h $(cc) -c $(flags) $< -o $@ diff --git a/examples/hello.halk b/examples/hello.halk index b0999cc..62b8360 100644 --- a/examples/hello.halk +++ b/examples/hello.halk @@ -1,5 +1,3 @@ -** - :str:hello = 'hello, '; :void:greeting. :str:to = { ` functions declared the same way as variables, but with a . after the name, followed by arguments ` diff --git a/src/lexer.c b/src/lexer.c index 1f647f5..60fa1a5 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -126,12 +126,11 @@ token_t* lexer_collect(lexer_t* lexer, int (*end_char)(char), int fskip, int lsk char* current = lexer_get_c_as_string(lexer); token = realloc( token, - (len + strlen(current) * sizeof(char)) + (len + sizeof(char) * strlen(current)) ); - memcpy(token + len, current, strlen(current) * sizeof(char)); - len += strlen(current) * sizeof(char); - free(current); + memcpy(token + len, current, sizeof(char) * strlen(current)); + len += sizeof(char) * strlen(current); lexer_next(lexer); } @@ -8,14 +8,6 @@ void die(const char* fmt, ...) { va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); - - if (fmt[0] && fmt[strlen(fmt) - 1] == ':') { - fputc(' ', stderr); - perror(NULL); - } else { - fputc('\n', stderr); - } - fprintf(stderr, "\n"); exit(1); @@ -49,12 +41,5 @@ void log_war(const char* fmt, ...) { vfprintf(stderr, fmt, ap); va_end(ap); - if (fmt[0] && fmt[strlen(fmt) - 1] == ':') { - fputc(' ', stderr); - perror(NULL); - } else { - fputc('\n', stderr); - } - fprintf(stderr, "\n"); } |