]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
rearrange comments so real code is at the top. also fix the build for OSX because...
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 6 May 2014 01:30:54 +0000 (21:30 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 6 May 2014 01:30:54 +0000 (21:30 -0400)
SConstruct
source/slvm/main.c
source/slvm/parser.c

index 7db068d0956f36879cf33285f2329bfec48695f1..59fbac4b2a1302cd2db39bc3514dde873fec5657 100644 (file)
@@ -75,17 +75,17 @@ scheme = base.Clone(CCFLAGS  = [ '-I', 'inc'],
 #------------------------------------------------------------------------------
 
 # SOF Shared Library
-c_cpp.SharedLibrary('build/sof', find_files('source/libsof/','*.c'))
+#c_cpp.SharedLibrary('build/sof', find_files('source/libsof/','*.c'))
 
 # SBC Shared Library
-c_cpp.SharedLibrary('build/sbc', find_files('source/libsbc/','*.c'))
+#c_cpp.SharedLibrary('build/sbc', find_files('source/libsbc/','*.c'))
 
 # readsof Command Line Utility
-readsof = c_cpp.Clone(CPPPATH = [ 'source/libsof/' ],
-                      LIBS    = [ 'sof' ],
-                      LIBPATH = [ 'build' ])
-readsof.Program('build/readsof', find_files('source/readsof/','*.c'))
-readsof.Depends('readsof', 'sof')
+#readsof = c_cpp.Clone(CPPPATH = [ 'source/libsof/' ],
+#                      LIBS    = [ 'sof' ],
+#                      LIBPATH = [ 'build' ])
+#readsof.Program('build/readsof', find_files('source/readsof/','*.c'))
+#readsof.Depends('readsof', 'sof')
 
 # SCLPL Compiler
 SchemeBuildAndTest( 'build/slc',
index f552c584a171951a501d09ef03a41e272b5c55fd..e647b88e641647c1c2acaec944f43e580153e9c9 100644 (file)
@@ -5,8 +5,6 @@
 /*
     Wish List:
 
-    * Rework Interpreter With Custom Syntax
-    * Add Dictionary Typedef
     * Dynamic Loading and Unloading of Dictionaries (File, Object, or Dynamic Lib)
     * Rework w* words to allow gettign and setting attributes of a word
     * Add optional debugging words
@@ -33,7 +31,7 @@ void docolon(val_t* code) {
     val_t* prev_code = CodePtr;
     /* Set the next instruction to execute */
     CodePtr = code;
-    /* And loop through until we "ret" sets the code pointer to null */
+    /* Loop through until "ret" sets the code pointer to null */
     while(CodePtr)
     {
         word = (word_t*)*CodePtr;
@@ -84,56 +82,6 @@ defcode("here", here, 0, &wcode){
     *(ArgStack) = (val_t)((((word_t*)latest_val)->flags.attr.codesize) - 1);
 }
 
-/* Input/Output Words
- *****************************************************************************/
-#if 0
-defvar("stdin",  _stdin,  0, &here,    0);
-defvar("stdout", _stdout, 0, &_stdin,  0);
-defvar("stderr", _stderr, 0, &_stdout, 0);
-
-defconst("F_R",  f_r,  0, &_stderr, (val_t)"r");
-defconst("F_W",  f_w,  0, &f_r,     (val_t)"w");
-defconst("F_A",  f_a,  0, &f_w,     (val_t)"a");
-defconst("F_R+", f_ru, 0, &f_a,     (val_t)"r+");
-defconst("F_W+", f_wu, 0, &f_ru,    (val_t)"w+");
-defconst("F_A+", f_au, 0, &f_wu,    (val_t)"a+");
-
-defcode("fopen",  _fopen,  0, &f_au){
-    *(ArgStack-1) = (val_t)fopen( (const char*)*(ArgStack-1), (const char*)*(ArgStack) );
-    ArgStack--;
-}
-
-defcode("fclose", _fclose, 0, &_fopen){
-    fclose((FILE*)*(ArgStack));
-    ArgStack--;
-}
-
-defcode("fflush", _fflush, 0, &_fclose){
-    fflush((FILE*)*(ArgStack));
-    ArgStack--;
-}
-
-defcode("fgetc",  _fgetc,  0, &_fflush){
-    *(ArgStack) = fgetc((FILE*)*(ArgStack));
-}
-
-defcode("fputc",  _fputc,  0, &_fgetc){
-    fputc((char)*(ArgStack-1), (FILE*)*(ArgStack));
-    ArgStack -= 2;
-}
-
-defcode("fputs",  _fputs,  0, &_fputc){
-    fputs((char*)*(ArgStack-1), (FILE*)*(ArgStack));
-    ArgStack -= 2;
-}
-
-defcode("fpeekc", _fpeekc, 0, &_fputs){
-    FILE* p_file = (FILE*)*(ArgStack);
-    *(ArgStack) = fgetc(p_file);
-    ungetc((char)*(ArgStack), p_file);
-}
-#endif
-
 /* Interpreter Words
  *****************************************************************************/
 defcode("exec", exec, 0, &here){
@@ -506,6 +454,77 @@ defcode("b@b!", bytecopy, 0, &bytefetch){
 defcode("bmove", bytemove, 0, &bytecopy){
 }
 
+/* Main
+ *****************************************************************************/
+int main(int argc, char** argv)
+{
+    /* Default Kernel dictionary */
+    //static dict_t kernel_dict = { NULL, (word_t*)&bytemove };
+    /* Compile-time Assertions */
+    CT_ASSERT(sizeof(val_t) == sizeof(val_t*));
+    CT_ASSERT(sizeof(val_t) == sizeof(flags_t));
+
+    /* Platform specific initialization */
+    //_stdin_val  = (val_t)stdin;
+    //_stdout_val = (val_t)stdout;
+    //_stderr_val = (val_t)stderr;
+    latest_val = (val_t)&bytemove;
+
+    /* Start the interpreter */
+    EXEC(quit);
+    return 0;
+}
+
+/* Input/Output Words
+ *****************************************************************************/
+#if 0
+defvar("stdin",  _stdin,  0, &here,    0);
+defvar("stdout", _stdout, 0, &_stdin,  0);
+defvar("stderr", _stderr, 0, &_stdout, 0);
+
+defconst("F_R",  f_r,  0, &_stderr, (val_t)"r");
+defconst("F_W",  f_w,  0, &f_r,     (val_t)"w");
+defconst("F_A",  f_a,  0, &f_w,     (val_t)"a");
+defconst("F_R+", f_ru, 0, &f_a,     (val_t)"r+");
+defconst("F_W+", f_wu, 0, &f_ru,    (val_t)"w+");
+defconst("F_A+", f_au, 0, &f_wu,    (val_t)"a+");
+
+defcode("fopen",  _fopen,  0, &f_au){
+    *(ArgStack-1) = (val_t)fopen( (const char*)*(ArgStack-1), (const char*)*(ArgStack) );
+    ArgStack--;
+}
+
+defcode("fclose", _fclose, 0, &_fopen){
+    fclose((FILE*)*(ArgStack));
+    ArgStack--;
+}
+
+defcode("fflush", _fflush, 0, &_fclose){
+    fflush((FILE*)*(ArgStack));
+    ArgStack--;
+}
+
+defcode("fgetc",  _fgetc,  0, &_fflush){
+    *(ArgStack) = fgetc((FILE*)*(ArgStack));
+}
+
+defcode("fputc",  _fputc,  0, &_fgetc){
+    fputc((char)*(ArgStack-1), (FILE*)*(ArgStack));
+    ArgStack -= 2;
+}
+
+defcode("fputs",  _fputs,  0, &_fputc){
+    fputs((char*)*(ArgStack-1), (FILE*)*(ArgStack));
+    ArgStack -= 2;
+}
+
+defcode("fpeekc", _fpeekc, 0, &_fputs){
+    FILE* p_file = (FILE*)*(ArgStack);
+    *(ArgStack) = fgetc(p_file);
+    ungetc((char)*(ArgStack), p_file);
+}
+#endif
+
 /* Control Flow Words
  *****************************************************************************/
 #if 0
@@ -661,24 +680,4 @@ defcode("printdefw", printdefw, 0, &printallw){
 }
 #endif
 
-/* Main
- *****************************************************************************/
-int main(int argc, char** argv)
-{
-    /* Default Kernel dictionary */
-    //static dict_t kernel_dict = { NULL, (word_t*)&bytemove };
-    /* Compile-time Assertions */
-    CT_ASSERT(sizeof(val_t) == sizeof(val_t*));
-    CT_ASSERT(sizeof(val_t) == sizeof(flags_t));
-
-    /* Platform specific initialization */
-    //_stdin_val  = (val_t)stdin;
-    //_stdout_val = (val_t)stdout;
-    //_stderr_val = (val_t)stderr;
-    latest_val = (val_t)&bytemove;
-
-    /* Start the interpreter */
-    EXEC(quit);
-    return 0;
-}
 
index ab16e6cacd8e66c46ce20120eef1cd011eae2827..8da82fd82cbdd0b74612ca8f7ba1da28fedbace9 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 
-/* Track Lines Read
- *****************************************************************************/
-static bool Line_Read = true;
-
-bool line_read(void)
-{
-    bool res = Line_Read;
-    Line_Read = false;
-    return res;
-}
-
 /* Fetching Tokens
  *****************************************************************************/
 static void skip_whitespace(void);
@@ -129,10 +118,7 @@ static void skip_comment(void)
 static bool is_whitespace(void)
 {
     char ch = pal_peek_char();
-    bool res = ((ch == ' ')  || (ch == '\t') || (ch == '\r') || (ch == '\n'));
-    if (ch == '\n')
-        Line_Read = true;
-    return res;
+    return ((ch == ' ')  || (ch == '\t') || (ch == '\r') || (ch == '\n'));
 }
 
 /* Parsing Tokens