From 8d85c8442ff15100eeb7262bf7ea37472fd78095 Mon Sep 17 00:00:00 2001 From: s-over-4 Date: Wed, 21 Jun 2023 17:36:09 -0400 Subject: RETURN OGHF TEH BORKED SHIAT D: D: D: --- README.md | 10 +++++----- src/lexer.c | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9879378..6a06767 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # HALK - + *HALK* seeks to be a language. @@ -27,18 +27,18 @@ You are mistaken. Usage of *HALK* is not yet a feature of *HALK*. One can only hope this feature will be added in the future. - # Syntax -*HALK* is a **dubiously-typed**, **procedural**, **interpreted** programming language. +*HALK* is a **dubiously-typed**, **vaguely-functional**, **interpreted** programming language, with syntax designed to be as +**minimal** and **consistent** as possible. Note that all syntax described is liable to sudden and violent change. -Examples can be found [here](examples/). +Example programs can be found [here](examples/). ***HALK*** **progress:** 20% - [x] Lexer -- [~] Abstract Syntax Tree +- [ ] Abstract Syntax Tree - [ ] Parser - [ ] Doer - [ ] ?? profit ?? diff --git a/src/lexer.c b/src/lexer.c index 731210e..6d9d5a8 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -121,9 +121,8 @@ token_t* lexer_collect(lexer_t* lexer, int (*end_char)(char), int fskip, int lsk size_t len; // length of collected token so far char* token; // collected token so far - len = 1; + len = 0; token = calloc(len, sizeof(char)); - token[0] = '\0'; if (fskip) { lexer_next(lexer); } @@ -133,11 +132,11 @@ token_t* lexer_collect(lexer_t* lexer, int (*end_char)(char), int fskip, int lsk current = lexer_get_c_as_string(lexer); token = realloc( token, - (len + sizeof(char) * strlen(current)) + (len + sizeof(current)) ); memcpy(token + len, current, sizeof(char) * strlen(current)); - len += sizeof(char) * strlen(current); + len += strlen(current) * sizeof(char); lexer_next(lexer); free(current); -- cgit v1.2.3