Skip to content

Commit

Permalink
feat: get ready for rewrite to support unicode ([BUG]: Files w/ Unico…
Browse files Browse the repository at this point in the history
…de Characters cause errors #2)
  • Loading branch information
skifli authored Dec 11, 2023
1 parent 5254afd commit 83d7d3d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
CompileFlags:
Add: [-std=c17, -Weverything, -Wno-missing-prototypes, -Wno-empty-translation-unit, -Wno-cast-qual]
Diagnostics:
Suppress: [unused-includes, padded, unsafe-buffer-usage]
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"Visual Studio 17 2022",
],
"cSpell.words": [
"Exeme"
"Exeme",
"LEXERTOKENS",
"Unlexes",
],
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
Expand Down
2 changes: 1 addition & 1 deletion programs/test.exl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
func a(a: a, b: b)
func a(á: a, b: b)
2 changes: 2 additions & 0 deletions src/includes.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
// other OSes.

#include <ctype.h>
#include <locale.h>
#include <malloc.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>

#include "./globals.c"
6 changes: 2 additions & 4 deletions src/lexer/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ void lexer_free(struct Lexer **self) {
* @param ERROR_MSG The error message.
* @param token The erroneous token.
*/
void lexer_error(struct Lexer *self, const enum ErrorIdentifiers ERROR_MSG_NUMBER, const char *ERROR_MSG,
const struct LexerToken *token) {
__attribute__((noreturn)) void lexer_error(struct Lexer *self, const enum ErrorIdentifiers ERROR_MSG_NUMBER,
const char *ERROR_MSG, const struct LexerToken *token) {
const char *lineNumberString;
FILE *filePointer = fopen(self->FILE_PATH, "r");
struct String *line = string_new("\0", true);
Expand Down Expand Up @@ -441,8 +441,6 @@ char lexer_escapeChr(struct Lexer *self, const size_t startChrIndex) {

lexer_error(self, L0004, "invalid escape sequence",
lexerToken_new(LEXERTOKENS_NONE, string_new("\0", true), startChrIndex, self->chrIndex, self->lineIndex));

return '\0';
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
#pragma pack(1)

int main(int argc, char **argv) {
struct Args *args = args_new(argc, argv);
struct Args *args = NULL;
struct Compiler *compiler = NULL;

struct Compiler *compiler = compiler_new("../../programs/test.exl");
setlocale(LC_ALL, "");

args = args_new(argc, argv);

compiler = compiler_new("../../programs/test.exl");

while (compiler_compile(compiler)) {
}
Expand Down

0 comments on commit 83d7d3d

Please sign in to comment.