all repos — min @ 7bb38b205fbbf82cc69b6fa83f09adfb32e273e1

A small but practical concatenative programming language.

feat(raise) Added raise operator.
h3rald h3rald@h3rald.com
Fri, 03 Jun 2016 23:07:41 +0200
commit

7bb38b205fbbf82cc69b6fa83f09adfb32e273e1

parent

bae02ddf6ecc00f6ee991ab732c861260048f903

6 files changed, 16 insertions(+), 9 deletions(-)

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

@@ -128,6 +128,8 @@ let symbolProc = i.scope.getSymbol(symbol)

if not symbolProc.isNil: try: symbolProc(i) + except MinRuntimeError: + stderr.writeLine("$1 [$2,$3]: $4" % [i.currSym.filename, $i.currSym.line, $i.currSym.column, getCurrentExceptionMsg()]) except: i.error(errSystem, getCurrentExceptionMsg()) else:
M core/parser.nimcore/parser.nim

@@ -69,10 +69,10 @@ proc errorMsgExpected*(my: MinParser, e: string): string =

result = errorMsg(my, e & " expected") proc raiseParseError*(p: MinParser, msg: string) {.noinline, noreturn.} = - raise EMinParsingError(msg: errorMsgExpected(p, msg)) + raise MinParsingError(msg: errorMsgExpected(p, msg)) proc raiseUndefinedError*(p:MinParser, msg: string) {.noinline, noreturn.} = - raise EMinUndefinedError(msg: errorMsg(p, msg)) + raise MinUndefinedError(msg: errorMsg(p, msg)) #proc error(p: MinParser, msg: string) = # writeln(stderr, p.errorMsg(msg))
M core/types.nimcore/types.nim

@@ -68,8 +68,9 @@ kind*: MinEventKind

err*: MinParserError filename*: string MinStack* = seq[MinValue] - EMinParsingError* = ref object of ValueError - EMinUndefinedError* = ref object of ValueError + MinParsingError* = ref object of ValueError + MinUndefinedError* = ref object of ValueError + MinRuntimeError* = ref object of SystemError MinInterpreter* = object stack*: MinStack pwd*: string
M lib/lang.nimlib/lang.nim

@@ -150,7 +150,6 @@ i.load i.pwd.joinPath(file)

else: i.error(errIncorrect, "A string is required on the stack") - .symbol("call") do (i: In): let symbols = i.pop var target = i.pop

@@ -181,7 +180,6 @@ return

i.scope = q.scope i.scope = origScope - .symbol("inspect") do (i: In): let scope = i.pop if not scope.isQuotation:

@@ -190,6 +188,12 @@ var symbols = newSeq[MinValue](0)

for s in scope.scope.symbols.keys: symbols.add s.newVal i.push symbols.newVal + + .symbol("raise") do (i: In): + let err = i.pop + if not err.isQuotation: + i.error errNoQuotation + raise MinRuntimeError(msg: "($1) $2" % [err.qVal[0].getString, err.qVal[1].getString]) # Operations on the whole stack
M minim.nimminim.nim

@@ -22,9 +22,9 @@ const

USE_LINENOISE = true -let usage* = " MiNiM v" & version & " - a tiny concatenative system programming language" & """ +let usage* = " MiNiM v" & version & " - a tiny concatenative programming language" & """ - (c) 2014 Fabio Cevasco + (c) 2014-2016 Fabio Cevasco Usage: minim [options] [filename]
M tests/lang.mintests/lang.min

@@ -3,7 +3,7 @@ #test

"lang" describe - (symbols size 160 ==) assert + (symbols size 161 ==) assert (sigils size 10 ==) assert