Skip to content

Commit

Permalink
add missing headers, fix gitignore, rm c-only test framework
Browse files Browse the repository at this point in the history
  • Loading branch information
jethrodaniel committed Jan 22, 2022
1 parent 24a44fb commit 93be8bc
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 259 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
holyc
**/*.o
*.o
*.a
test/bin/
16 changes: 16 additions & 0 deletions include/holyc/_parse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef HOLYC__PARSE
#define HOLYC__PARSE

#include <holyc/ast.h>
#include <holyc/lex.h>

typedef struct Parser {
NodeNameTable node_name_table;
Lexer lexer;
} Parser;

Parser *parse_new(Parser *parser, char *input, int size);
AstNode *parse_parse(Parser *parser);
void parse_print_node(Parser *parser, AstNode *node);

#endif // HOLYC__PARSE
36 changes: 36 additions & 0 deletions include/holyc/ast.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef HOLYC_AST
#define HOLYC_AST

typedef enum {
NODE_UNINITIALIZED,
NODE_INT,
NODE_BINOP_PLUS,
NODE_BINOP_MIN,
NODE_BINOP_MUL,
NODE_BINOP_DIV,
NODE_EXPR,
} AstType;

#define NUM_NODES 7

typedef char *NodeNameTable[NUM_NODES];

typedef struct AstNode {
AstType type;
int value;

struct AstNode *left;
struct AstNode *right;

struct AstNode *expr_value;
} AstNode;

// typedef struct BinOpNode {
// AstNode left;
// AstNode right;
// BinOpType type;
// } BinOpNode;

AstNode *ast_new(AstNode *node, AstType type, int value);

#endif // HOLYC_AST
10 changes: 10 additions & 0 deletions include/holyc/buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef HOLYC_BUFFER
#define HOLYC_BUFFER

typedef struct Buffer {
char *start;
char *curr;
int size;
} Buffer;

#endif // HOLYC_BUFFER
7 changes: 0 additions & 7 deletions lib/testing/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions lib/testing/include/testing.h

This file was deleted.

52 changes: 0 additions & 52 deletions lib/testing/makefile

This file was deleted.

52 changes: 0 additions & 52 deletions lib/testing/src/testing.c

This file was deleted.

17 changes: 2 additions & 15 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,22 @@ CFLAGS += -I . -I lib/c/include -I include

#--

default: clean $(PROG) test ctest
default: test

SRCS := $(wildcard src/*.c)
OBJS := $(SRCS:.c=.o)
LIBC := lib/c/libc.a
LIBC_FLAGS := -Llib/c -lc

LIBTESTING := lib/testing/libtesting.a
LIBTESTING_FLAGS := -I lib/testing/include -Llib/testing -ltesting
TEST_EXE := ctest.out

$(LIBC):
$(MAKE) -C lib/c
$(LIBTESTING):
$(MAKE) -C lib/testing

$(PROG): $(OBJS) | $(LIBC)
$(CC) -e _start $(CFLAGS) $(LIBC_FLAGS) $^ $(LIBC) -o $(PROG)

clean:
rm -f $(OBJS) $(PROG) *.out test/*.o $(TEST_MAIN)
$(MAKE) -C lib/c clean
$(MAKE) -C lib/testing clean

#--
test/bin:
Expand All @@ -105,13 +98,7 @@ test/bin/asm: test/asm.o $(filter-out src/main.o, $(OBJS)) $(LIBC) | test/bin
$(CC) -e _start $(CFLAGS) $(LIBC_FLAGS) $^ -o $@
./$@

$(TEST_EXE): test/main.c $(LIBC) $(LIBTESTING) $(filter-out src/main.o, $(OBJS))
$(CC) -e _start $(CFLAGS) $(LIBC_FLAGS) $(LIBTESTING_FLAGS) $^ -o $@

ctest: $(TEST_EXE)
./$<

test: test/bin/lex test/bin/parse FORCE
test: test/bin/lex test/bin/parse $(PROG) FORCE
sh test/main.sh
FORCE:

Expand Down
78 changes: 0 additions & 78 deletions test/asm.c

This file was deleted.

13 changes: 0 additions & 13 deletions test/main.c

This file was deleted.

0 comments on commit 93be8bc

Please sign in to comment.