From 22c5a86f83288b94975bb84cbd1ebfa62d2ed2af Mon Sep 17 00:00:00 2001 From: s-over-4 Date: Thu, 22 Jun 2023 23:46:09 -0400 Subject: Makefile changes --- Makefile | 60 ++++++++++++++++++++++++++++++++---------------- resources/HALK_FINAL.svg | 2 +- src/include/parser.h | 3 ++- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 057890d..fa953ca 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,49 @@ -.PHONY: install uninstall dev clean test me a sandwich -name := halk -cc := gcc -flags := -devflags := -ggdb -fsanitize=leak,address,undefined -fno-omit-frame-pointer -sources := $(wildcard src/*.c) -sources := $(filter-out src/parser.c, $(sources)) # exclude the incomplete parser for now. -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 $@ +PREFIX := /usr/local +BINDIR := $(PREFIX)/bin +BIN := halk +TMPBIN := halk.out +CC := gcc +FLAGS := +DEVFLAGS := -ggdb -fsanitize=leak,address,undefined -fno-omit-frame-pointer +SRCS := $(wildcard src/*.c) +SRCS := $(filter-out src/parser.c, $(SRCS)) # exclude the incomplete parser for now. +OBJS := $(SRCS:.c=.o) + +all: options HALK + +options: + @echo "HALK build options " + @echo "================== " + @echo "cc: $(CC) " + @echo "flags: $(FLAGS) " + @echo " " + +devoptions: + @echo "HALK build options (development) " + @echo "================================ " + @echo "cc: $(CC) " + @echo "flags: $(DEVFLAGS) " + @echo " " + +HALK: $(OBJS) + $(CC) $(OBJS) $(FLAGS) -o $(TMPBIN) + +dev: $(OBJS) + @make devoptions + $(CC) $(OBJS) $(DEVFLAGS) -o $(TMPBIN) install: make - cp ./$(name).out /usr/bin/$(name) + cp ./$(BIN).out $(BINDIR)/$(BIN) uninstall: - rm -f /usr/bin/$(name) + rm -f $(BINDIR)/$(BIN) clean: - rm -f ./$(name).out ./src/*.o + rm -f $(TMPBIN) src/*.o + +%.o: %.c include/%.h + $(CC) -c $(FLAGS) $< -o $@ # fun me: @@ -33,3 +52,4 @@ me: a sandwich: @exit +.PHONY: all options devoptions dev install uninstall clean diff --git a/resources/HALK_FINAL.svg b/resources/HALK_FINAL.svg index e22d772..01f1c1b 100644 --- a/resources/HALK_FINAL.svg +++ b/resources/HALK_FINAL.svg @@ -56,4 +56,4 @@ HALK HALK - \ No newline at end of file + diff --git a/src/include/parser.h b/src/include/parser.h index dcacabe..2811469 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -13,9 +13,10 @@ typedef struct PARSER_STRUC { // initialize a parser parser_t* parser_init(lexer_t* lexer); +void parser_destroy(parser_t* parser); // check for expected token, or throw syntax error -void parser_token_expect(parser_t* parser, int token_type); +void parser_token_expect(parser_t* parser, int (*expected_token)(token_t*)); // do the parse tree_t* parser_parse(parser_t* parser); -- cgit v1.2.3