From: Michael D. Lowis Date: Tue, 14 Aug 2018 16:34:38 +0000 (-0400) Subject: added hooks for building in-memory package description X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=f8b4aab22359cfb1ab0c889d7ff8b356f99191f7;p=proto%2Fsclpl.git added hooks for building in-memory package description --- diff --git a/Makefile b/Makefile index 26c031d..5875fdd 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ ARFLAGS = rcs #------------------------------------------------------------------------------ BIN = sclpl OBJS = source/main.o \ + source/pkg.o \ source/vec.o \ source/pprint.o \ source/parser.o \ @@ -28,8 +29,8 @@ OBJS = source/main.o \ source/syms.o \ source/codegen.o -.PHONY: all tests specs -all: sclpl tests specs +.PHONY: all specs tests +all: sclpl specs tests lib${BIN}.a: ${OBJS} ${AR} ${ARFLAGS} $@ $^ @@ -40,6 +41,10 @@ ${BIN}: lib${BIN}.a specs: $(BIN) rspec --pattern 'spec/**{,/*/**}/*_spec.rb' --format documentation +tests: $(BIN) + @echo "Parsing example file..." + ./sclpl -Aast < example.src + .l.c: ${LEX} -o $@ $< diff --git a/source/parser.c b/source/parser.c index 99ce7fe..4fe4697 100644 --- a/source/parser.c +++ b/source/parser.c @@ -86,6 +86,7 @@ static void require_list(Parser* p) { expect(p, '('); while (!matches(p, ')')) { expect(p, T_STRING); + pkg_add_require(&(p->pkg), "required/module"); } expect(p, ')'); } @@ -95,6 +96,7 @@ static void provide_list(Parser* p) { expect(p, '('); while (!matches(p, ')')) { expect(p, T_ID); + pkg_add_provide(&(p->pkg), "provided/symbol"); } expect(p, ')'); } @@ -110,6 +112,7 @@ static AST* definition_list(Parser* p) { } else { error(p, "only definitions are allowed at the top level"); } + pkg_add_definition(&(p->pkg), NULL); } return NULL; } @@ -161,10 +164,6 @@ static AST* expression(Parser* p) { expression_block(p); } else if (matches(p, T_IF)) { if_expression(p); -// } else if (matches(p, T_ID)) { -// identifier(p); -// if (matches(p, '(')) -// func_expr_list(p); } else if (matches(p, T_ID)) { identifier(p); } else { diff --git a/source/pkg.c b/source/pkg.c new file mode 100644 index 0000000..482b81a --- /dev/null +++ b/source/pkg.c @@ -0,0 +1,14 @@ +#include + +void pkg_add_require(Package* p, char* req) +{ +} + +void pkg_add_provide(Package* p, char* exp) +{ +} + +void pkg_add_definition(Package* p, AST* ast) +{ +} + diff --git a/source/sclpl.h b/source/sclpl.h index 069e116..aa5482d 100644 --- a/source/sclpl.h +++ b/source/sclpl.h @@ -210,6 +210,7 @@ typedef struct { FILE* input; Tok tok; SymTable syms; + Package pkg; } Parser; void gettoken(Parser* ctx);