all repos — min @ fb2b3b790a882ac21370f63ef6f83e909d1aad41

A small but practical concatenative programming language.

fix(modules) Fixed errors in module implementation.
h3rald h3rald@h3rald.com
Sun, 22 May 2016 18:59:09 +0200
commit

fb2b3b790a882ac21370f63ef6f83e909d1aad41

parent

41ef6b03007f894516fa6f06624da7fb848e210e

4 files changed, 64 insertions(+), 36 deletions(-)

jump to
M core/parser.nimcore/parser.nim

@@ -190,6 +190,23 @@ var pos = my.bufpos

var buf = my.buf while true: case buf[pos] + of ';': + # skip line comment: + inc(pos, 2) + while true: + case buf[pos] + of '\0': + break + of '\c': + pos = lexbase.handleCR(my, pos) + buf = my.buf + break + of '\L': + pos = lexbase.handleLF(my, pos) + buf = my.buf + break + else: + inc(pos) of '/': if buf[pos+1] == '/': # skip line comment:
M lib/lang.nimlib/lang.nim

@@ -70,14 +70,6 @@ i.evaluating = true

i.push q1.qVal i.evaluating = false - .symbol("unset") do (i: In): - var q1 = i.pop - if q1.qVal.len == 1 and q1.qVal[0].kind == minSymbol: - var symbol = q1.qVal[0].symVal - i.scope.parent.symbols.excl symbol - else: - i.error errIncorrect, "The top quotation must contain only one symbol value" - .symbol("module") do (i: In): let name = i.pop var code = i.pop
M lib/prelude.minlib/prelude.min

@@ -1,6 +1,6 @@

(import) (#) sigil -// Imports +; Imports #str #io #logic

@@ -9,7 +9,7 @@ #stack

#sys #time -// Common sigils +; Common sigils (bind) (:) sigil (let) (.) sigil (getenv) ($) sigil

@@ -18,7 +18,7 @@ (run) (&) sigil

(module) (=) sigil (load) (@) sigil -// Aliases +; Aliases 'bind :: 'let :. 'module :=

@@ -47,7 +47,7 @@ 'clear :empty

'cons :prepend 'match :~ -// Mathematical Operators +; Mathematical Operators (1 +) :succ (1 -) :pred (2 mod 0 ==) :even?

@@ -55,7 +55,7 @@ (even? not) :odd?

((dup 0 ==) (1 +) (dup 1 -) ( * ) linrec) :factorial -// Stack Operators +; Stack Operators (swap cons) :swons ((pop) dip) :popd ((dup) dip) :dupd

@@ -72,6 +72,7 @@ ((() cons) dip swap i) :bury1

((() cons cons) dip swap i) :bury2 ((() cons cons cons) dip swap i) :bury3 -// Other -//(dup unset set) :reset +; Other +(print pop) :print! +(puts pop) :puts!
M tests/test.mintests/test.min

@@ -1,29 +1,47 @@

( - (("OK")) .ok + ("OK") ' .ok + (" " print!) .padding + + ;; describe + ( + .name + "Testing: " print! name puts! + padding + () + ) :describe + ;; assert ( - quote .check // save the check quotation to validate - quote .results // save the result symbol to update - check dup first swap rest + ' .check ; save the check quotation to validate + ' .results ; save the result symbol to update + (check -> true ==) ( - pop - ok results -> append quote results bind - "." print pop + ok results append quote :results + "." print! ) ( - pop - check results -> append quote results bind - "x" print pop + check results append quote :results + "x" print! ) ifte + results ) :assert + ;; report ( + ' .results ; save the results collected so far + 0 .total + 0 .failed + results ( + total succ :total + (ok !=) (failed succ :failed) () ifte + ) map + padding total print! " tests executed - " print! failed print! " failed." puts! ( - quote .result + ' .result result (ok !=) - ("FAILED: " print pop result puts) + (padding "FAILED: " print! result puts!) () ifte )

@@ -34,12 +52,12 @@ ) =test

#test -// Sample unit test program -(()) :maths -'maths (2 3 ==) assert -'maths (2 1 >) assert -'maths (2 1 <) assert -'maths (4 4 ==) assert -'maths (7 7 ==) assert -newline -maths report +; Sample unit test program +"maths" describe + (2 3 ==) assert + (2 1 >) assert + (2 1 <) assert + (4 4 ==) assert + (7 7 ==) assert + newline + report