all repos — min @ 5dbdd446cdc7c19062aaacc80f999f45f1c4849f

A small but practical concatenative programming language.

Restricted characters for symbol identifiers.
h3rald h3rald@h3rald.com
Sat, 08 Oct 2016 22:25:04 +0200
commit

5dbdd446cdc7c19062aaacc80f999f45f1c4849f

parent

60694312e4b2788caf070ab22cca6310f45389f2

2 files changed, 36 insertions(+), 12 deletions(-)

jump to
M lib/min_lang.nimlib/min_lang.nim

@@ -163,6 +163,8 @@ var symbol: string

if not q1.isQuotation: q1 = @[q1].newVal symbol = sym.getString + if not symbol.match "^[a-zA-Z0-9+._-][a-zA-Z0-9/!?+*._-]*$": + raiseInvalid("Symbol identifier '$1' contains invalid characters." % symbol) i.debug "[define] " & symbol & " = " & $q1 #let p = proc(i: In) = # i.push q1.qVal

@@ -745,5 +747,38 @@ i.push("load-symbol".newSym)

.sigil("*") do (i: In): i.push("seal".newSym) + + .symbol(":") do (i: In): + i.push("define".newSym) + + .symbol("@") do (i: In): + i.push("bind".newSym) + + .symbol("!") do (i: In): + i.push("system".newSym) + + .symbol("&") do (i: In): + i.push("run".newSym) + + .symbol("$") do (i: In): + i.push("getenv".newSym) + + .symbol("^") do (i: In): + i.push("call".newSym) + + .symbol("%") do (i: In): + i.push("interpolate".newSym) + + .symbol("'") do (i: In): + i.push("quote".newSym) + + .symbol("->") do (i: In): + i.push("unquote".newSym) + + .symbol("=>") do (i: In): + i.push("scope".newSym) + + .symbol("=~") do (i: In): + i.push("regex".newSym) .finalize()
M prelude.minprelude.min

@@ -9,8 +9,6 @@ 'fs import

'crypto import ; Aliases -'define :: -'bind :@ 'exit :quit '== :eq '!= :noteq

@@ -19,24 +17,15 @@ '< :lt

'>= :gte '<= :lte 'puts :echo -'system :! -'run :& -'getenv :$ -'call :^ -'interpolate :% 'pop :zap 'quote :unit -'quote :' 'unquote :i 'unquote :apply -'unquote :-> -'scope :=> 'filter :select 'cons :prepend 'size :length -'regex :=~ -(': '@ 'quit 'eq 'noteq 'gt 'lt 'gte 'lte 'echo '! '& '$ '^ '% 'zap 'unit '' 'i 'apply '-> '=> 'select 'prepend 'length '=~) 'seal foreach +('quit 'eq 'noteq 'gt 'lt 'gte 'lte 'echo 'zap 'unit 'i 'apply 'select 'prepend 'length) 'seal foreach ; Mathematical Operators (1 +) :succ