]> git.mdlowis.com Git - archive/dlang.git/commitdiff
Updated project to remove architecture dependence.
authorMike D. Lowis <mike@mdlowis.com>
Mon, 23 Apr 2012 19:11:25 +0000 (15:11 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Mon, 23 Apr 2012 19:11:25 +0000 (15:11 -0400)
Makefile
example.dl
source/visitors/scheme/scheme.cpp

index be2219ba0cc50bd027c37c45e3012de9ee7c9468..357a86fac6e46160f546540dde8b41bc2ca95bf4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -27,12 +27,10 @@ TEST_RUNNER = test_runner
 #----------------------------
 # Root Directories
 SRC_ROOT   = source/
-RES_ROOT   = res/
 TESTS_ROOT = tests/
 
 # File Extensions
 SRC_EXT    = cpp
-RES_EXT    = scm
 TEST_EXT   = cpp
 
 # Libraries to Link Against
@@ -42,12 +40,10 @@ TEST_LIBS = $(LIBS) \
 
 # Source File Lists
 SRC_FILES  = $(call flist, $(SRC_ROOT), $(SRC_EXT))
-RES_FILES  = $(call flist, $(RES_ROOT), $(RES_EXT))
 TEST_FILES = $(call flist, $(TESTS_ROOT), $(TEST_EXT))
 
 # Object File Lists
 SRC_OBJS  = $(SRC_FILES:%.$(SRC_EXT)=%.o)
-RES_OBJS  = $(RES_FILES:%.$(RES_EXT)=%.o)
 TEST_OBJS = $(TEST_FILES:%.$(TEST_EXT)=%.o)
 
 # Include Directories
@@ -69,11 +65,11 @@ test: $(TEST_RUNNER)
        $(TEST_RUNNER)
 
 # Binaries
-$(PROJ_NAME): parseutils $(SRC_OBJS) res/environment.o
-       $(CXX) $(CXX_FLAGS) -o $@ $(SRC_OBJS) $(RES_OBJS) $(LIBS)
+$(PROJ_NAME): parseutils $(SRC_OBJS)
+       $(CXX) $(CXX_FLAGS) -o $@ $(SRC_OBJS) $(LIBS)
 
-$(TEST_RUNNER): parseutils unit_test_pp $(SRC_OBJS) $(RES_OBJS) $(TEST_OBJS)
-       $(CXX) $(CXX_FLAGS) -o $@ $(filter-out source/main.o,$(SRC_OBJS)) $(RES_OBJS) $(TEST_OBJS) $(TEST_LIBS)
+$(TEST_RUNNER): parseutils unit_test_pp $(SRC_OBJS) $(TEST_OBJS)
+       $(CXX) $(CXX_FLAGS) -o $@ $(filter-out source/main.o,$(SRC_OBJS)) $(TEST_OBJS) $(TEST_LIBS)
 
 # Libraries
 parseutils:
@@ -87,15 +83,11 @@ $(SRC_OBJS): %.o : %.$(SRC_EXT)
 
 $(TEST_OBJS): %.o : %.$(TEST_EXT)
 
-$(RES_OBJS): %.o : %.$(RES_EXT)
-       objcopy -I binary -O elf32-i386 -B i386 $< $@
-
 # Cleanup
 clean:
        $(MAKE) -C deps/parse-utils clean
        $(MAKE) -C tools/UnitTest++ clean
        $(RM) $(SRC_OBJS)
-       $(RM) $(RES_OBJS)
        $(RM) $(TEST_OBJS)
        $(RM) $(TEST_RUNNER)*
        $(RM) $(PROJ_NAME)*
index 5a2d3c08c7d15163fb113d28140f0dbe23a04d42..fcacd8aafa0643f629253d3485dbcf62089eaec8 100644 (file)
-##------------------------------------------------------------------------------
-## Literal Definition and Usage
-##------------------------------------------------------------------------------
-#
-## Nums
-#assert( 1 == 1,           "Positive integer parses correctly")
-#assert( -1 == -1,         "Negative integer parses correctly")
-#assert( 1.0 == 1.0,       "Parse postive floating point value without exponent")
-#assert( -1.0 == -1.0,     "Parse negative floating point value without exponent")
-#assert( 10.0e-1 == 1.0,   "Parse positive floating point value with exponent")
-#assert( -10.0e-1 == -1.0, "Parse negative floating point value with exponent")
-#
-## Char
-#assert('a',  "Parse a character")
-#assert('\a', "Parse escape sequence for alarm")
-#assert('\b', "Parse escape sequence for backspace")
-#assert('\n', "Parse escape sequence for newline")
-#assert('\r', "Parse escape sequence for return")
-#assert('\t', "Parse escape sequence for tab")
-#assert('\v', "Parse escape sequence for vertical tab")
-#
-## String
-#foo := "some string"
-#foo = "foo \a \b \f \n \r \t \v \' \" \\ \xFF bar"
-#foo = "12345"[2]
-#
-## Symbol
-#foo = $some_symbol
-#
-## Map
-#foo = @{}
-#foo.stuff = "bar"
-#foo = @{
-#    $foo : 1 + 1,
-#    "stuff" : 2 + 2,
-#    $stuff : 2 + 2,
-#    $bar : 3 + 3,
-#}
-#
-## Setting map elements
-#foo["stuff"] = 3
-#foo.stuff = 5
-#
-## Vector
-#foo = []
-#foo = [1]
-#foo = [1,2,3]
-#foo = foo[1]
-#foo = [1,2,3,4,5][2]
-#
-## Setting Vector Elements
-#foo[2] = 6
-#
-## List
-#foo = ()
-#foo = (1,)
-#foo = (1,2,3)
-#foo = foo[1]
-#foo = (1,2,3,4,5)[2]
-#
-## Setting List Elements
-#foo[2] = 6
-#
-## Block
-#foo = { 1 + 1 }
-#foo = {|a| a + 1}
-#foo = {|a,b| a + b }
-#foo = foo(1,2)
-#foo = ({|a,b| a + b })(1,2)
-#
-##------------------------------------------------------------------------------
-## Operators and Precedence Tests
-##------------------------------------------------------------------------------
-#
-#
-##------------------------------------------------------------------------------
-## Macro Definition and Usage
-##------------------------------------------------------------------------------
-#
-## Define a macro that represents a traditional if statement
+#------------------------------------------------------------------------------
+# Literal Definition and Usage
+#------------------------------------------------------------------------------
+
+# Nums
+foo := 1
+foo = -1
+foo = 1.0
+foo = -1.0
+foo = 10.0e1
+foo = 10.0e-1
+foo = -10.0e1
+foo = -10.0e-1
+
+# Char
+foo = 'a'
+foo = '\a'
+foo = '\b'
+foo = '\n'
+foo = '\r'
+foo = '\t'
+foo = '\v'
+
+# String
+foo = "some string"
+foo = "foo \a \b \f \n \r \t \v \' \" \\ \xFF bar"
+foo = "12345"[2]
+
+# Symbol
+foo = $some_symbol
+
+# Map
+foo = @{}
+foo.stuff = "bar"
+foo = @{
+    $foo : 1 + 1,
+    "stuff" : 2 + 2,
+    $stuff : 2 + 2,
+    $bar : 3 + 3,
+}
+
+# Setting map elements
+foo["stuff"] = 3
+foo.stuff = 5
+
+# Vector
+foo = []
+foo = [1]
+foo = [1,2,3]
+foo = foo[1]
+foo = [1,2,3,4,5][2]
+
+# Setting Vector Elements
+foo[2] = 6
+
+# List
+foo = ()
+foo = (1,)
+foo = (1,2,3)
+foo = foo[1]
+foo = (1,2,3,4,5)[2]
+
+# Setting List Elements
+foo[2] = 6
+
+# Block
+foo = { 1 + 1 }
+foo = {|a| a + 1}
+foo = {|a,b| a + b }
+foo = foo(1,2)
+foo = ({|a,b| a + b })(1,2)
+
+#------------------------------------------------------------------------------
+# Operators and Precedence Tests
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# Macro Definition and Usage
+#------------------------------------------------------------------------------
+assert := {|cond,msg|
+    exec_if(cond,{},{ print(msg) })
+}
+
+# Define a macro that represents a traditional if statement
 % if [
     (E B B) : exec_if($1, $2, $3),
     (E B)   : exec_if($1, $2),
 ]
-#
-#test_result = false
-#if (1 < 2)
-#{
-#    test_result = true
-#}{
-#    test_result = false
-#}
-#assert( test_result, "First branch should be taken when test condition is true" )
-#
-#test_result = false
-#if (1 > 2)
-#{
-#    test_result = false
-#}{
-#    test_result = true
-#}
-#assert( test_result, "Second branch should be taken when test condition is false" )
-#
-#test_result = false
-#if (1 < 2)
-#{
-#    test_result = true
-#}
-#assert( test_result, "Branch should be taken when test condition is true" )
-#
-#test_result = true
-#if (1 > 2)
-#{
-#    test_result = false
-#}
-#assert( test_result, "Branch should not be taken when test condition is false" )
+
+test_result = false
+if (1 < 2)
+{
+    test_result = true
+}{
+    test_result = false
+}
+assert( test_result, "First branch should be taken when test condition is true" )
+
+test_result = false
+if (1 > 2)
+{
+    test_result = false
+}{
+    test_result = true
+}
+assert( test_result, "Second branch should be taken when test condition is false" )
+
+test_result = false
+if (1 < 2)
+{
+    test_result = true
+}
+assert( test_result, "Branch should be taken when test condition is true" )
+
+test_result = true
+if (1 > 2)
+{
+    test_result = false
+}
+assert( test_result, "Branch should not be taken when test condition is false" )
 
 #------------------------------------------------------------------------------
 # Delayed Evaluation
 #------------------------------------------------------------------------------
 
+###############################################################################
+# WARNING: This Section is a work in progress. Please ignore it for now.      #
+###############################################################################
+
 # Define a function that makes a promise
-make_promise := {|expr|
-    result := expr
-    {
-        print( "expr: ", expr )
-        print( "result: ", result )
-        result
-        #if result_ready == true {
-        #    print("Returning cached results")
-        #    result
-        #}{
-        #    print("Caching results")
-        #    result
-        #}
-    }
-}
+#make_promise := {|expr|
+#    result := expr
+#    {
+#        print( "expr: ", expr )
+#        print( "result: ", result )
+#        result
+#        #if result_ready == true {
+#        #    print("Returning cached results")
+#        #    result
+#        #}{
+#        #    print("Caching results")
+#        #    result
+#        #}
+#    }
+#}
 
 # Define a macro that will delay the evaluation of the following expression
-% delay [
-    (E) : make_promise({ $1 })
-]
+#% delay [
+#    (E) : make_promise({ $1 })
+#]
 
 # Define a macro that will force the evaluation of the following delayed statement
-% force [
-    (E) : $1()
-]
-
-foo = delay 1 + 1
-print("foo: ", foo)
-foo = force foo
-print("foo: ", foo)
-print( force foo )
+#% force [
+#    (E) : $1()
+#]
+#
+#foo = delay 1 + 1
+#print("foo: ", foo)
+#foo = force foo
+#print("foo: ", foo)
+#print( force foo )
 #print( force foo )
 #print( force foo )
 
@@ -158,29 +167,29 @@ print( force foo )
 # Classes
 #------------------------------------------------------------------------------
 
-## Define a macro for creating new classes
-#% class [
-#    (B)   : {
-#        this := @{}
-#        $1()
-#        this
-#    },
-#]
-#
-## Simple class definition (No inheritance supported)
-#Animal := class {
-#    # The sound of the mating call is kept private
-#    priv_call := "Moo!"
-#
-#    # Define a method to print the mating call sound
-#    this.mating_call = {
-#        print( priv_call )
-#    }
-#}
-#
-## Animal is a constructor so call it to create a new cow
-#Cow := Animal()
-#
-## And call the method to print the sound (This syntax needs to be cleaned up a bit)
-#(Cow.mating_call)()
+# Define a macro for creating new classes
+% class [
+    (B)   : {
+        this := @{}
+        $1()
+        this
+    },
+]
+
+# Simple class definition (No inheritance supported)
+Animal := class {
+    # The sound of the mating call is kept private
+    priv_call := "Moo!"
+
+    # Define a method to print the mating call sound
+    this.mating_call = {
+        print( priv_call )
+    }
+}
+
+# Animal is a constructor so call it to create a new cow
+Cow := Animal()
+
+# And call the method to print the sound (This syntax needs to be cleaned up a bit)
+(Cow.mating_call)()
 
index 7ba2eaeb0b5d587c54b8b0dc9c13e8897b230433..8bd10a9de081a6383a623a7b4966ad10b9bcf607 100644 (file)
@@ -4,11 +4,17 @@
 
 using namespace std;
 
-extern char binary_res_environment_scm_start;
+//extern char binary_res_environment_scm_start;
 
 Scheme::Scheme(std::ostream& out) : IVisitor(), stream(out) {
+    ifstream env_file("res/environment.scm");
+    while( !env_file.eof() )
+    {
+        stream << (char)env_file.get();
+    }
+    env_file.close();
     // Print scheme environment to output stream
-    stream << &binary_res_environment_scm_start << endl;
+    //stream << &binary_res_environment_scm_start << endl;
 }
 
 string Scheme::typeToString(ASTNodeType type)