]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
Checkpoint commit
authorMike D. Lowis <mike.lowis@gentex.com>
Fri, 9 Oct 2015 20:28:29 +0000 (16:28 -0400)
committerMike D. Lowis <mike.lowis@gentex.com>
Fri, 9 Oct 2015 20:28:29 +0000 (16:28 -0400)
14 files changed:
build.rb
input.txt [new file with mode: 0644]
source/sclpl/codegen.c
source/sclpl/codegen.h [deleted file]
source/sclpl/log.c
source/sclpl/log.h [deleted file]
source/sclpl/main.c
source/sclpl/ops.c
source/sclpl/ops.h
source/sclpl/pprint.c
source/sclpl/pprint.h [deleted file]
source/sclpl/sclpl.h [new file with mode: 0644]
source/sclpl/sys.c
source/sclpl/sys.h [deleted file]

index 88cedf5730c0e585ff7e16a37a42d61cd900c432..e441e512fc8192d75f867e024aefdbb3222b788d 100755 (executable)
--- a/build.rb
+++ b/build.rb
@@ -50,6 +50,7 @@ base_env = BuildEnv.new do |env|
   env["CPPPATH"] += Dir['modules/libcds/source/**/'] + [
     'modules/libopts/source',
     'source/libparse/',
+    'source/sclpl/',
   ]
 end
 
diff --git a/input.txt b/input.txt
new file mode 100644 (file)
index 0000000..190a180
--- /dev/null
+++ b/input.txt
@@ -0,0 +1 @@
+123
index 6968d20b98d997d3ad54f82efcdb2d53e475c391..0190d5dc80a8e4c091ac9cb3ed155c336c4b13bb 100644 (file)
@@ -1,6 +1,4 @@
-#include <libparse.h>
-#include "codegen.h"
-#include "pprint.h"
+#include <sclpl.h>
 
 #if 0
 static void lift_funcs(vec_t* fnlst, AST* tree) {
diff --git a/source/sclpl/codegen.h b/source/sclpl/codegen.h
deleted file mode 100644 (file)
index c854d43..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
-  @file codegen.h
-  @brief TODO: Describe this file
-  $Revision$
-  $HeadURL$
-  */
-#ifndef CODEGEN_H
-#define CODEGEN_H
-
-#include <stdio.h>
-#include "vec.h"
-
-void codegen_csource(FILE* file, vec_t* program);
-
-#endif /* CODEGEN_H */
index ae0e3842c1b19ba9370062918c11b047ddce6bea..ee9c9b7d70bfe58bd2f0364d812732754b118c80 100644 (file)
@@ -4,8 +4,7 @@
   $Revision$
   $HeadURL$
   */
-#include "log.h"
-#include <stdio.h>
+#include <sclpl.h>
 
 void log_error(const char msg[], ...) {
     va_list args;
diff --git a/source/sclpl/log.h b/source/sclpl/log.h
deleted file mode 100644 (file)
index 90c4637..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
-  @file log.h
-  @brief TODO: Describe this file
-  $Revision$
-  $HeadURL$
-  */
-#ifndef LOG_H
-#define LOG_H
-
-#include <stdarg.h>
-
-void log_error(const char msg[], ...);
-
-#endif /* LOG_H */
index 51d3815599e6a506ca83db3771552ac01ddb65a4..10b32e5508c269430f2fc0402b8f222b2c1d757f 100644 (file)
@@ -1,16 +1,4 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include "opts.h"
-#include "str.h"
-#include "list.h"
-#include "pprint.h"
-#include "codegen.h"
-#include "sys.h"
-#include "log.h"
-#include "ops.h"
-#include <libparse.h>
-
+#include <sclpl.h>
 
 /* Command Line Options
  *****************************************************************************/
@@ -36,54 +24,16 @@ void print_usage(void) {
     exit(1);
 }
 
-/* Options Helpers
- *****************************************************************************/
-bool file_exists(const char* name) {
-    bool  ret  = false;
-    FILE* file = fopen(name,"r");
-    if (NULL != file) {
-        fclose(file);
-        ret = true;
-    }
-    return ret;
-}
-
-list_t* input_files(void) {
-    list_t* infiles = list_new();
-    const char** fvec  = opts_arguments();
-    const char** files = fvec;
-    while (NULL != files[0]) {
-        if (!file_exists(files[0])) {
-            mem_release(infiles);
-            log_error("no such file or directory: %s", files[0]);
-            exit(1);
-        }
-        list_push_front(infiles, str_new(files[0]));
-        files++;
-    }
-    free(fvec);
-    return infiles;
-}
-
 /* Driver Modes
  *****************************************************************************/
 static int emit_tokens(void) {
-    list_t* files  = input_files();
-    size_t  nfiles = list_size(files);
-    if (0 == nfiles) {
-        (void)ops_token_file(NULL);
-    } else if (1 == nfiles) {
-        str_t* fname = list_front(files)->contents;
-        mem_release( ops_token_file(fname) );
-    } else {
-        log_error("too many files provided for target mode 'tokens'");
-    }
-    mem_release(files);
+    (void)ops_token_file(NULL);
     return 0;
 }
 
 static int emit_tree(void) {
     int ret = 0;
+#if 0
     list_t* files  = input_files();
     size_t  nfiles = list_size(files);
     if (0 == nfiles) {
@@ -95,12 +45,13 @@ static int emit_tree(void) {
         log_error("too many files provided for target mode 'ast'");
     }
     mem_release(files);
-
+#endif
     return ret;
 }
 
 static int emit_csource(void) {
     int ret = 0;
+#if 0
     list_t* files  = input_files();
     size_t  nfiles = list_size(files);
     if (0 == nfiles) {
@@ -112,10 +63,12 @@ static int emit_csource(void) {
         log_error("too many files provided for target mode 'csource'");
     }
     mem_release(files);
+#endif
     return ret;
 }
 
 static int exec_repl(void) {
+#if 0
     Parser* p_parser = parser_new(":> ", stdin);
     while(!parser_eof(p_parser)) {
         AST* p_tree = toplevel(p_parser);
@@ -130,10 +83,12 @@ static int exec_repl(void) {
         }
     }
     mem_release(p_parser);
+#endif
     return 0;
 }
 
 static int emit_object(void) {
+#if 0
     list_t* files  = input_files();
     size_t  nfiles = list_size(files);
     if (0 == nfiles) {
@@ -148,6 +103,7 @@ static int emit_object(void) {
         log_error("too many files provided for target mode 'object'");
     }
     mem_release(files);
+#endif
     return 0;
 }
 
index 4cc4700f918d1e7093d48eaec56fb1dabfa4458b..0c7114f1bab6eb16d81b1925bf5105cbdf2d7a57 100644 (file)
@@ -4,13 +4,9 @@
   $Revision$
   $HeadURL$
   */
-#include "opts.h"
-#include "str.h"
-#include "sys.h"
-#include "pprint.h"
-#include "codegen.h"
-#include <libparse.h>
+#include <sclpl.h>
 
+#if 0
 vec_t* ops_parse_file(str_t* in) {
     //bool failed = false;
     //FILE* input = (NULL == in) ? stdin : fopen(str_cstr(in), "r");
@@ -38,9 +34,9 @@ vec_t* ops_deps_file(vec_t* program) {
     (void)program;
     return deps;
 }
+#endif
 
-str_t* ops_token_file(str_t* in) {
-    str_t* ofname = NULL;
+char* ops_token_file(str_t* in) {
     FILE* input = (NULL == in) ? stdin : fopen(str_cstr(in), "r");
     FILE* output;
     if (NULL == in) {
@@ -58,9 +54,10 @@ str_t* ops_token_file(str_t* in) {
     }
     mem_release(ctx);
 
-    return ofname;
+    return NULL;
 }
 
+#if 0
 str_t* ops_syntax_file(str_t* in) {
     str_t* ofname = NULL;
     FILE* output;
@@ -118,4 +115,4 @@ str_t* ops_compile_file(str_t* in) {
     mem_release(command);
     return ofname;
 }
-
+#endif
index fd52b17f89ef3ed32e60bb0eba99bb513caf3498..b66d98376aa9344934714a56b92b7dbe839d6269 100644 (file)
@@ -7,14 +7,5 @@
 #ifndef OPS_H
 #define OPS_H
 
-#include "str.h"
-#include "vec.h"
-
-vec_t* ops_parse_file(str_t* in);
-vec_t* ops_deps_file(vec_t* program);
-str_t* ops_token_file(str_t* in);
-str_t* ops_syntax_file(str_t* in);
-str_t* ops_translate_file(str_t* in);
-str_t* ops_compile_file(str_t* in);
 
 #endif /* OPS_H */
index 236d685b67b096f75981343012344d686e29a349..32718ecede9f9536a2f928bdd4f3214e8781f0cd 100644 (file)
@@ -4,12 +4,14 @@
   $Revision$
   $HeadURL$
   */
-#include "pprint.h"
+#include <sclpl.h>
 
+#if 0
 static void print_indent(FILE* file, int depth) {
     for(int i = 0; i < (2 * depth); i++)
         fprintf(file, "%c", ' ');
 }
+#endif
 
 static const char* token_type_to_string(TokType type) {
     switch(type) {
diff --git a/source/sclpl/pprint.h b/source/sclpl/pprint.h
deleted file mode 100644 (file)
index a60030d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
-  @file pprint.h
-  @brief TODO: Describe this file
-  $Revision$
-  $HeadURL$
-  */
-#ifndef PPRINT_H
-#define PPRINT_H
-
-#include <libparse.h>
-
-void pprint_token_type(FILE* file, Tok* token);
-
-void pprint_token_value(FILE* file, Tok* token);
-
-void pprint_token(FILE* file, Tok* token, bool print_loc);
-
-void pprint_tree(FILE* file, AST* tree, int depth);
-
-#endif /* PPRINT_H */
diff --git a/source/sclpl/sclpl.h b/source/sclpl/sclpl.h
new file mode 100644 (file)
index 0000000..bbf6445
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+  @file sclpl.h
+*/
+#ifndef SCLPL_H
+#define SCLPL_H
+
+#include <opts.h>
+#include <libparse.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include "str.h"
+//#include "vec.h"
+#include "list.h"
+
+typedef enum {
+    TOKFILE,
+    ASTFILE,
+    CSOURCE,
+    OBJECT,
+    PROGRAM,
+    STATICLIB,
+    SHAREDLIB
+} file_type_t;
+
+/* Filesystem Routines */
+str_t* sys_bin_dir(void);
+str_t* sys_inc_dir(void);
+str_t* sys_extension(file_type_t ftype);
+str_t* sys_filename(file_type_t ftype, str_t* infile);
+
+/* Pretty Printing Data Structures */
+void pprint_token_type(FILE* file, Tok* token);
+void pprint_token_value(FILE* file, Tok* token);
+void pprint_token(FILE* file, Tok* token, bool print_loc);
+//void pprint_tree(FILE* file, AST* tree, int depth);
+
+/* Compiler Driver Operations */
+//vec_t* ops_parse_file(str_t* in);
+//vec_t* ops_deps_file(vec_t* program);
+str_t* ops_token_file(str_t* in);
+//str_t* ops_syntax_file(str_t* in);
+//str_t* ops_translate_file(str_t* in);
+//str_t* ops_compile_file(str_t* in);
+
+/* Error Logging */
+void log_error(const char msg[], ...);
+
+/* Code Generation */
+void codegen_csource(FILE* file, vec_t* program);
+
+#endif /* SCLPL_H */
index 06301e18c00537723e769aa196c843819d2f3c8d..7f6fb142305750be379719ba7bab9b6628b155e1 100644 (file)
@@ -4,10 +4,7 @@
   $Revision$
   $HeadURL$
   */
-#include <stdlib.h>
-#include "sys.h"
-#include "opts.h"
-#include "log.h"
+#include <sclpl.h>
 
 str_t* sys_bin_dir(void) {
     str_t* bindir = NULL;
diff --git a/source/sclpl/sys.h b/source/sclpl/sys.h
deleted file mode 100644 (file)
index f386bec..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
-  @file sys.h
-  @brief TODO: Describe this file
-  $Revision$
-  $HeadURL$
-  */
-#ifndef SYS_H
-#define SYS_H
-
-#include "str.h"
-
-str_t* sys_bin_dir(void);
-str_t* sys_inc_dir(void);
-
-typedef enum {
-    TOKFILE,
-    ASTFILE,
-    CSOURCE,
-    OBJECT,
-    PROGRAM,
-    STATICLIB,
-    SHAREDLIB
-} file_type_t;
-
-str_t* sys_extension(file_type_t ftype);
-str_t* sys_filename(file_type_t ftype, str_t* infile);
-
-#endif /* SYS_H */