]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
added hooks for building in-memory package description
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 14 Aug 2018 16:34:38 +0000 (12:34 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 14 Aug 2018 16:34:38 +0000 (12:34 -0400)
Makefile
source/parser.c
source/pkg.c [new file with mode: 0644]
source/sclpl.h

index 26c031d821b76d377fcb07a977983d41ef92618f..5875fdd102009b7329ecd7c59627e90b59208959 100644 (file)
--- 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 $@ $<
 
index 99ce7fed6f8ce5d8781579b0c88ea007e744c553..4fe469769b356875e3fddb172e5cecb283f2c6c8 100644 (file)
@@ -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 (file)
index 0000000..482b81a
--- /dev/null
@@ -0,0 +1,14 @@
+#include <sclpl.h>
+
+void pkg_add_require(Package* p, char* req)
+{
+}
+
+void pkg_add_provide(Package* p, char* exp)
+{
+}
+
+void pkg_add_definition(Package* p, AST* ast)
+{
+}
+
index 069e116d3376a9e025a5f941c8add20ce30ff911..aa5482d7ed6055d5bbe578ca2b5bfef302488be9 100644 (file)
@@ -210,6 +210,7 @@ typedef struct {
     FILE* input;
     Tok tok;
     SymTable syms;
+    Package pkg;
 } Parser;
 
 void gettoken(Parser* ctx);