corrected me forcing c99 because i use strtok_r that isn't c99 compliant
This commit is contained in:
parent
378cae31a1
commit
fd2ba66124
8
Makefile
8
Makefile
@ -1,12 +1,12 @@
|
||||
NAME := Sterling
|
||||
NAME := SterlingCompiler
|
||||
|
||||
SRC := $(wildcard source/*.c)
|
||||
|
||||
OBJ := $(SRC:source/%.c=obj/%.o)
|
||||
|
||||
CC := gcc
|
||||
CFLAG := -ggdb -Wall -Wextra -Werror -Wpedantic -I include -O0 -std=c99 -fsignaling-nans
|
||||
LFLAG :=
|
||||
CFLAG := -ggdb -Wall -Wextra -Werror -Wpedantic -I include -Og -fsignaling-nans -fsanitize=address -fsanitize=undefined
|
||||
LDFLAG := -lasan -lubsan -lpthread
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
@ -14,7 +14,7 @@ obj/%.o : source/%.c | makedir
|
||||
$(CC) $(CFLAG) -c $< -o $@
|
||||
|
||||
$(NAME): $(OBJ)
|
||||
$(CC) $(OBJ) $(LFLAG) -o build/$(NAME)
|
||||
$(CC) $(OBJ) $(LDFLAG) -o build/$(NAME)
|
||||
|
||||
makedir:
|
||||
mkdir -p obj
|
||||
|
||||
BIN
build/SterlingCompiler
Normal file
BIN
build/SterlingCompiler
Normal file
Binary file not shown.
BIN
obj/main.o
BIN
obj/main.o
Binary file not shown.
@ -1,66 +0,0 @@
|
||||
#ifndef ARRAY_H
|
||||
# define ARRAY_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
typedef struct Header_s{
|
||||
int size;
|
||||
int capacity;
|
||||
int type;
|
||||
} Header;
|
||||
|
||||
#ifndef memset
|
||||
|
||||
void *memset(void *src, char c, size_t size) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
*(char *)(src + i) = c;
|
||||
}
|
||||
return (src);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
typedef void *Array;
|
||||
|
||||
#define ARRAY_BASE_CAPACITY 64
|
||||
|
||||
#define ArraySize(arr) ((Header*)(arr) - 1)->size
|
||||
|
||||
#define ArrayFree(arr) free(((Header*)(arr) - 1))
|
||||
|
||||
#define ArrayPush(arr, x)\
|
||||
do {\
|
||||
Header *head = NULL;\
|
||||
if (!arr) { \
|
||||
head = malloc(sizeof(x) * ARRAY_BASE_CAPACITY + sizeof(Header));\
|
||||
head->size = 0;\
|
||||
head->type = sizeof(x);\
|
||||
head->capacity = ARRAY_BASE_CAPACITY;\
|
||||
arr = (void *)(head + 1);\
|
||||
}\
|
||||
head = (Header*)(arr)-1;\
|
||||
assert(sizeof(x) == head->type);\
|
||||
if (head->size >= head->capacity) {\
|
||||
head->capacity *= 2;\
|
||||
head = realloc(head, head->type *head->capacity + sizeof(Header));\
|
||||
arr = (void *)(head + 1);\
|
||||
}\
|
||||
(arr)[head->size++] = x;\
|
||||
} while(0)
|
||||
|
||||
#define ArrayClear(arr)\
|
||||
do {\
|
||||
assert(arr);\
|
||||
Header * head = (Header*)(arr)-1;\
|
||||
memset(arr, 0, head->size * head->type);\
|
||||
} while(0)\
|
||||
|
||||
|
||||
# ifdef ARRAY_IMPL
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
@ -124,8 +124,11 @@ void ListFree(list_t *lst, void (*free_func)(void*)) {
|
||||
free(current);
|
||||
current = next;
|
||||
}
|
||||
//seems like i got a leak here, but may not be that bad since it is only called when closing
|
||||
lst->size = 0;
|
||||
lst->first = lst->last = NULL;
|
||||
free(lst);
|
||||
lst = NULL;
|
||||
}
|
||||
|
||||
void *ListPeekK(const list_iter_t *it, size_t k) {
|
||||
|
||||
@ -571,6 +571,14 @@ int main(int ac, char **av) {
|
||||
//Parser_t p = ParserInit(tkn_lst);
|
||||
//Parse(&p);
|
||||
|
||||
//Ast
|
||||
//print all error and check correction available
|
||||
//symbletable
|
||||
//type check
|
||||
//metaanalyze to know what how to put it into IR (as asm allow for metaprog)
|
||||
|
||||
//create ir by resolving ast on multiple thread
|
||||
|
||||
ListFree(tkn_lst, ClearTokens);
|
||||
free(data);
|
||||
return(0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user