all repos — min @ da4a4c4758f781be62373df64e67bb5928e0363d

A small but practical concatenative programming language.

Now using ( and ) as quotation delimiters.
h3rald h3rald@h3rald.com
Fri, 19 Dec 2014 20:55:07 +0100
commit

da4a4c4758f781be62373df64e67bb5928e0363d

parent

a0894a184e135b97649ee65977582137a9f20008

2 files changed, 38 insertions(+), 41 deletions(-)

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

@@ -36,13 +36,13 @@ eMinEof, ## end of file reached

eMinString, ## a string literal eMinInt, ## an integer literal eMinFloat, ## a float literal - eMinQuotationStart, ## start of an array: the ``[`` token - eMinQuotationEnd ## start of an array: the ``]`` token + eMinQuotationStart, ## start of an array: the ``(`` token + eMinQuotationEnd ## start of an array: the ``)`` token TMinParserError* = enum ## enumeration that lists all errors that can occur errNone, ## no error errInvalidToken, ## invalid token errStringExpected, ## string expected - errBracketRiExpected, ## ``]`` expected + errBracketRiExpected, ## ``)`` expected errQuoteExpected, ## ``"`` or ``'`` expected errEOC_Expected, ## ``*/`` expected errEofExpected, ## EOF expected

@@ -68,7 +68,7 @@ errorMessages: array [TMinParserError, string] = [

"no error", "invalid token", "string expected", - "']' expected", + "')' expected", "'\"' or \"'\" expected", "'*/' expected", "EOF expected",

@@ -80,8 +80,8 @@ "EOF",

"string literal", "int literal", "float literal", - "[", - "]", + "(", + ")", "symbol", "true", "false"

@@ -241,7 +241,7 @@ result = tkSymbol

var pos = my.bufpos var buf = my.buf if not(buf[pos] in Whitespace): - while not(buf[pos] in WhiteSpace) and not(buf[pos] in ['\0', ']', '[']): + while not(buf[pos] in WhiteSpace) and not(buf[pos] in ['\0', ')', '(']): add(my.a, buf[pos]) inc(pos) my.bufpos = pos

@@ -325,10 +325,10 @@ else:

result = tkInt of '"': result = parseString(my) - of '[': + of '(': inc(my.bufpos) result = tkBracketLe - of ']': + of ')': inc(my.bufpos) result = tkBracketRi of '\0':

@@ -440,10 +440,10 @@ return $a.intVal

of minFloat: return $a.floatVal of minQuotation: - var q = "[ " + var q = "( " for i in a.qVal: q = q & $i & " " - q = q & "]" + q = q & ")" return q proc print*(a: TMinValue) =

@@ -476,6 +476,3 @@ else:

return false else: return false - - -
M lib/prelude.minlib/prelude.min

@@ -1,8 +1,8 @@

// Common sigils -[bind] [:] sigil -[getenv] [$] sigil -[system] [!] sigil -[run] [&] sigil +(bind) (:) sigil +(getenv) ($) sigil +(system) (!) sigil +(run) (&) sigil // Aliases 'bind ::

@@ -26,33 +26,33 @@ 'unquote :apply

'filter :select 'clear :empty 'match :~ -["."] :. -[".."] :.. +(".") :. +("..") :.. // Mathematical Operators -[1 +] :succ -[1 -] :pred -[2 mod 0 ==] :even? -[even? not] :odd? +(1 +) :succ +(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 -[[pop] dip] :popd -[[dup] dip] :dupd -[[swap] dip] :swapd -[[dup] dip i] :q -[[zap] dip i] :k -[[cons] dip i] :b -[[swap] dip i] :c -[[dip] cons cons] :take -[[] cons dip] :dig1 -[[] cons cons dip] :dig2 -[[] cons cons cons dip] :dig3 -[[[] cons] dip swap i] :bury1 -[[[] cons cons] dip swap i] :bury2 -[[[] cons cons cons] dip swap i] :bury3 +(swap cons) :swons +((pop) dip) :popd +((dup) dip) :dupd +((swap) dip) :swapd +((dup) dip i) :q +((zap) dip i) :k +((cons) dip i) :b +((swap) dip i) :c +((dip) cons cons) :take +(() cons dip) :dig1 +(() cons cons dip) :dig2 +(() cons cons cons dip) :dig3 +((() cons) dip swap i) :bury1 +((() cons cons) dip swap i) :bury2 +((() cons cons cons) dip swap i) :bury3 // Other -[dup unbind bind] :rebind +(dup unbind bind) :rebind