utils.nim
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import tables, strutils import parser, interpreter proc print*(a: TMinValue) = case a.kind: of minSymbol: stdout.write a.symVal of minString: stdout.write "\""&a.strVal&"\"" of minInt: stdout.write a.intVal of minFloat: stdout.write a.floatVal of minQuotation: stdout.write "[ " for i in a.qVal: i.print stdout.write " " stdout.write "]" template minsym*(name: string, body: stmt): stmt {.immediate.} = SYMBOLS[name] = proc (i: var TMinInterpreter) = body proc minalias*(newname: string, oldname: string) = SYMBOLS[newname] = SYMBOLS[oldname] proc isSymbol(s: TMinValue): bool = return s.kind == minSymbol |