all repos — min @ 98fe3a636db61da489ae3adbc145265e51c13937

A small but practical concatenative programming language.

Implemented common file operations.
h3rald h3rald@h3rald.com
Sun, 30 Nov 2014 18:45:43 +0100
commit

98fe3a636db61da489ae3adbc145265e51c13937

parent

881c2a9597eddb47de38f9a1fbe9db2a987ef23e

2 files changed, 29 insertions(+), 1 deletions(-)

jump to
M prelude.minprelude.min

@@ -21,7 +21,7 @@ [1 -] [pred] :

[2 mod 0 ==] [even?] : [even? not] [odd?] : -[[ dup 0 == ] [ 1 + ] [ dup 1 - ] [ * ] linrec] [factorial] : +[[dup 0 ==] [1 +] [dup 1 -] [ * ] linrec] [factorial] : // Stack Operators [swap cons] [swons] :
M primitives.nimprimitives.nim

@@ -23,6 +23,10 @@ minsym "debug":

i.debugging = not i.debugging echo "Debugging: $1" % [$i.debugging] +minsym "clear": + while i.stack.len > 0: + discard i.pop + # Common stack operations minsym "id":

@@ -571,6 +575,28 @@ warn getCurrentExceptionMsg()

else: i.error errIncorrect, "A string is required on the stack" +minsym "cp": + let b = i.pop + let a = i.pop + if a.isString and b.isString: + try: + copyFile a.strVal, b.strVal + except: + warn getCurrentExceptionMsg() + else: + i.error errIncorrect, "Two strings are required on the stack" + +minsym "mv": + let b = i.pop + let a = i.pop + if a.isString and b.isString: + try: + moveFile a.strVal, b.strVal + except: + warn getCurrentExceptionMsg() + else: + i.error errIncorrect, "Two strings are required on the stack" + minsym "rmdir": let f = i.pop if f.isString:

@@ -610,8 +636,10 @@ minalias "sh", "system"

minalias "!", "system" minalias "!&", "run" minalias "$", "getenv" +minalias "$=", "putenv" minalias "zap", "pop" minalias "unit", "quote" minalias "i", "unquote" minalias "i", "apply" minalias "select", "filter" +minalias "empty", "clear"