#----------------------------
# 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
# 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
$(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:
$(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)*
-##------------------------------------------------------------------------------
-## 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 )
# 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)()