all repos — min @ e8683f56b3be94e952dcb394f6812b5681d0edff

A small but practical concatenative programming language.

Retructured and made the dynlib loading a bit production-ready
Peter Munch-Ellingsen peterme@peterme.net
Wed, 25 Oct 2017 23:03:39 +0200
commit

e8683f56b3be94e952dcb394f6812b5681d0edff

parent

d099c8886599eb8e816a5bf215856c9170a1a55f

17 files changed, 268 insertions(+), 907 deletions(-)

jump to
A dynamic/dynamicadd.nim

@@ -0,0 +1,25 @@

+## This is all you need to create a min module in Nim +## Compile with `nim c --app:lib --noMain -d:release dynamicadd.nim` +{.pragma: rtl, exportc, dynlib, cdecl.} +import mindyn + +proc setup*(): DynInfo {.rtl.} = + result = DynInfo(moduleName: "the_lib", dynlibVersion: 1) + +proc the_lib*(i: In) {.rtl.} = + let def = i.define() + def.symbol("myp") do (i: In): + let vals = i.expect("num", "num") + let a = vals[0] + let b = vals[1] + if a.isInt: + if b.isInt: + i.push newVal(a.intVal + b.intVal) + else: + i.push newVal(a.intVal.float + b.floatVal) + else: + if b.isFloat: + i.push newVal(a.floatVal + b.floatVal) + else: + i.push newVal(a.floatVal + b.intVal.float) + def.finalize("dyn")
A dynamic/mindyn.nim

@@ -0,0 +1,215 @@

+type + DynInfo* = object + moduleName*: string # The name of the symbol to load and run + dynlibVersion*: int # The version of the interface the dynlib is built for. This should increase if the interface changes + +# Everything below here is to interface with the main program +# Import for the missing types (Look into importing just type definitions) +import + lexbase, + streams, + critbits, + json, + os + +type + MinTokenKind* = enum + tkError, + tkEof, + tkString, + tkInt, + tkFloat, + tkBracketLe, + tkBracketRi, + tkSymbol, + tkTrue, + tkFalse + MinKind* = enum + minInt, + minFloat, + minQuotation, + minString, + minSymbol, + minBool + MinEventKind* = enum ## enumeration of all events that may occur when parsing + eMinError, ## an error ocurred during parsing + 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 + MinParserError* = enum ## enumeration that lists all errors that can occur + errNone, ## no error + errInvalidToken, ## invalid token + errStringExpected, ## string expected + errBracketRiExpected, ## ``)`` expected + errQuoteExpected, ## ``"`` or ``'`` expected + errEOC_Expected, ## ``*/`` expected + errEofExpected, ## EOF expected + errExprExpected + MinParserState* = enum + stateEof, + stateStart, + stateQuotation, + stateExpectValue + MinParser* = object of BaseLexer + a*: string + token*: MinTokenKind + state*: seq[MinParserState] + kind*: MinEventKind + err*: MinParserError + filename*: string + MinValue* = ref MinValueObject + MinValueObject* = object + line*: int + column*: int + filename*: string + case kind*: MinKind + of minInt: intVal*: BiggestInt + of minFloat: floatVal*: BiggestFloat + of minQuotation: + qVal*: seq[MinValue] + scope*: ref MinScope + of minString: strVal*: string + of minSymbol: symVal*: string + of minBool: boolVal*: bool + MinScope* = object + symbols*: CritBitTree[MinOperator] + sigils*: CritBitTree[MinOperator] + parent*: ref MinScope + name*: string + stack*: MinStack + MinOperatorProc* = proc (i: In) {.closure.} + MinOperatorKind* = enum + minProcOp + minValOp + MinOperator* = object + sealed*: bool + case kind*: MinOperatorKind + of minProcOp: + prc*: MinOperatorProc + of minValOp: + val*: MinValue + MinStack* = seq[MinValue] + In* = var MinInterpreter + MinInterpreter* = object + stack*: MinStack + trace*: MinStack + stackcopy*: MinStack + pwd*: string + scope*: ref MinScope + parser*: MinParser + currSym*: MinValue + filename*: string + evaluating*: bool + MinParsingError* = ref object of ValueError + MinUndefinedError* = ref object of ValueError + MinEmptyStackError* = ref object of ValueError + MinInvalidError* = ref object of ValueError + MinOutOfBoundsError* = ref object of ValueError +proc raiseInvalid(msg: string) {.importc, extern:"raiseInvalid_Emp5jFVyMCrh15i1fpFZiQ".} +proc raiseUndefined(msg: string) {.importc, extern:"raiseUndefined_Emp5jFVyMCrh15i1fpFZiQ_2".} +proc raiseOutOfBounds(msg: string) {.importc, extern:"raiseOutOfBounds_Emp5jFVyMCrh15i1fpFZiQ_3".} +proc raiseEmptyStack() {.importc, extern:"raiseEmptyStack_TxAgT9bR9codeB2uLmVKwt3w".} +proc newScope(parent: ref MinScope): MinScope {.importc, extern:"newScope_rH9cNZXpQjLoAhnola5cX4Q".} +proc newScopeRef(parent: ref MinScope): ref MinScope {.importc, extern:"newScopeRef_s7aB4NQYrY7Hev87iAW4jw".} +proc open(my: var MinParser, input: Stream, filename: string) {.importc, extern:"open_9brvHSJ7qjV9aGAqIpwcMV3A".} +proc close(my: var MinParser) {.importc, extern:"close_vmj9agDNIDvOwQZe8A2kGIAparser".} +proc getInt(my: MinParser): int {.importc, extern:"getInt_bXIqXGzvO9aGBMkrzA6B15gparser".} +proc getFloat(my: MinParser): float {.importc, extern:"getFloat_VXTaXBiGVD6XkIZK3YSq5Aparser".} +proc kind(my: MinParser): MinEventKind {.importc, extern:"kind_tgDyDbkEOSH9aIKWnOecz4Aparser".} +proc getColumn(my: MinParser): int {.importc, extern:"getColumn_bXIqXGzvO9aGBMkrzA6B15g_2parser".} +proc getLine(my: MinParser): int {.importc, extern:"getLine_bXIqXGzvO9aGBMkrzA6B15g_3parser".} +proc getFilename(my: MinParser): string {.importc, extern:"getFilename_s9a5R24VyFqQ3N3m7ZkDqmAparser".} +proc errorMsg(my: MinParser, msg: string): string {.importc, extern:"errorMsg_cVsoiM0SE9cH0KWBNfKqZcA".} +proc errorMsg(my: MinParser): string {.importc, extern:"errorMsg_r87VYrPzvmEsJhjriyvyQw".} +proc errorMsgExpected(my: MinParser, e: string): string {.importc, extern:"errorMsgExpected_Wqyr2ROfsYVJGDFwgiczQw".} +proc raiseParsing(p: MinParser, msg: string) {.importc, extern:"raiseParsing_Tz7DX0jKGOjDMX8SFWqb1A".} +proc raiseUndefined(p:MinParser, msg: string) {.importc, extern:"raiseUndefined_Tz7DX0jKGOjDMX8SFWqb1A_2".} +proc parseNumber(my: var MinParser) {.importc, extern:"parseNumber_q1Bg9ctZWMedsyrbTHRwU9aQ".} +proc handleHexChar(c: char, x: var int): bool {.importc, extern:"handleHexChar_5qj5zQ9aD5ka0UVtIDvSjNg".} +proc parseString(my: var MinParser): MinTokenKind {.importc, extern:"parseString_e3KFIguKCxnkZTqCF3o3jg".} +proc parseSymbol(my: var MinParser): MinTokenKind {.importc, extern:"parseSymbol_4hcHuz8N3YVsotvxzfL3Kw".} +proc skip(my: var MinParser) {.importc, extern:"skip_iFcpIZyA9cJx6updYRSgzjw".} +proc getToken(my: var MinParser): MinTokenKind {.importc, extern:"getToken_e3KFIguKCxnkZTqCF3o3jg_2".} +proc next(my: var MinParser) {.importc, extern:"next_iFcpIZyA9cJx6updYRSgzjw_2".} +proc eat(p: var MinParser, token: MinTokenKind) {.importc, extern:"eat_WE9bi5nLbQn9cAjnzHQ9bV6Kw".} +proc parseMinValue(p: var MinParser, i: In): MinValue {.importc, extern:"parseMinValue_Y6xeteQ253Mvf1JjLWhFig".} +proc `$`(a: MinValue): string {.importc, extern:"dollar__byT09beg0JPSCPWB3NVBb9bQ".} +proc `$$`(a: MinValue): string {.importc, extern:"dollardollar__byT09beg0JPSCPWB3NVBb9bQ_2".} +proc print(a: MinValue) {.importc, extern:"print_az8I9cfVT9b9bR2oSHjBwYE9bQ".} +proc `==`(a: MinValue, b: MinValue): bool {.importc, extern:"eqeq__zMKrLdJOCGuSouwNLkqPvQ".} +proc typeName*(v: MinValue): string {.importc, extern:"typeName_81jMzzfB0Qc0O4DsVU5arg".} +proc isSymbol*(s: MinValue): bool {.importc, extern:"isSymbol_BKcj9aQlJC73fcAZURf0pHw".} +proc isQuotation*(s: MinValue): bool {.importc, extern:"isQuotation_BKcj9aQlJC73fcAZURf0pHw_2".} +proc isString*(s: MinValue): bool {.importc, extern:"isString_BKcj9aQlJC73fcAZURf0pHw_3".} +proc isFloat*(s: MinValue): bool {.importc, extern:"isFloat_BKcj9aQlJC73fcAZURf0pHw_4".} +proc isInt*(s: MinValue): bool {.importc, extern:"isInt_BKcj9aQlJC73fcAZURf0pHw_5".} +proc isNumber*(s: MinValue): bool {.importc, extern:"isNumber_BKcj9aQlJC73fcAZURf0pHw_6".} +proc isBool*(s: MinValue): bool {.importc, extern:"isBool_BKcj9aQlJC73fcAZURf0pHw_7".} +proc isStringLike*(s: MinValue): bool {.importc, extern:"isStringLike_BKcj9aQlJC73fcAZURf0pHw_8".} +proc isDictionary*(q: MinValue): bool {.importc, extern:"isDictionary_7f9afQ8e7zZDtSeY6FzGNrw".} +proc newVal*(s: string): MinValue {.importc, extern:"newVal_JF8l73VBhy9cJEUaMht6wZA".} +proc newVal*(s: cstring): MinValue {.importc, extern:"newVal_MSseSJELDL5qivFR59byJ8Q".} +proc newVal*(q: seq[MinValue], parentScope: ref MinScope): MinValue {.importc, extern:"newVal_1PJ4YdZbCuyyD9bQkH2eu6A".} +proc newVal*(s: BiggestInt): MinValue {.importc, extern:"newVal_xDcIKp9bEb37NZkc9bhRat9cQ".} +proc newVal*(s: BiggestFloat): MinValue {.importc, extern:"newVal_ipbzO9cNeJyt42iGojkGmgg".} +proc newVal*(s: bool): MinValue {.importc, extern:"newVal_3PdI7sQ7HL5wBrAMsSG5sQ".} +proc newSym*(s: string): MinValue {.importc, extern:"newSym_JF8l73VBhy9cJEUaMht6wZA_2".} +proc getString*(v: MinValue): string {.importc, extern:"getString_81jMzzfB0Qc0O4DsVU5arg_2".} +proc define*(i: In): ref MinScope {.importc, extern:"define_HtvBzo0skz2GBYAKuFddKA".} +proc symbol*(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"symbol_D4i19cVxxCgOFsbGlV20kyQ".} +proc symbol*(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"symbol_XrX9bLAdrrQ3LgR9a9aYCQDXA".} +proc sigil*(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"sigil_D4i19cVxxCgOFsbGlV20kyQ_2".} +proc sigil*(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"sigil_XrX9bLAdrrQ3LgR9a9aYCQDXA_2".} +proc finalize*(scope: ref MinScope, name: string) {.importc, extern:"finalize_Igz9a7Xvo9cCa28si6nE0p5A".} +proc dget*(q: MinValue, s: MinValue): MinValue {.importc, extern:"dget_mfiqh3xcyXvnw9ajEytZuIA".} +proc dhas*(q: MinValue, s: MinValue): bool {.importc, extern:"dhas_MEAApOlp4yH17chuSa0k9bA".} +proc ddel*(i: In, p: MinValue, s: MinValue): MinValue {.importc, extern:"ddel_Riw3bw1BbxVPbq6m4TtOjw".} +proc dset*(i: In, p: MinValue, s: MinValue, m: MinValue): MinValue {.importc, extern:"dset_17HpKix9agOFpoPvvopNcCA".} +proc keys*(i: In, q: MinValue): MinValue {.importc, extern:"keys_oXC9bS9cwNWVkX1wVKP9aFEGA".} +proc values*(i: In, q: MinValue): MinValue {.importc, extern:"values_oXC9bS9cwNWVkX1wVKP9aFEGA_2".} +proc `%`*(a: MinValue): JsonNode {.importc, extern:"percent__QWqVWTWlpTitafp2NrtHgw".} +proc fromJson*(i: In, json: JsonNode): MinValue {.importc, extern:"fromJson_xPRwXdsUk4l7MGnYd2GbVA".} +proc reverse[T](xs: openarray[T]): seq[T] {.importc, extern:"reverse_drwb9cipBBt6vULs9c1MUijg".} +proc expect*(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] {.importc, extern:"expect_EYb0Rd1E6Tl9bqxEJWylifg".} +proc reqQuotationOfQuotations*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfQuotations_Xy0o2sh9cpmSUTDb9cbQNwQg".} +proc reqQuotationOfNumbers*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfNumbers_Xy0o2sh9cpmSUTDb9cbQNwQg_2".} +proc reqQuotationOfSymbols*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfSymbols_Xy0o2sh9cpmSUTDb9cbQNwQg_3".} +proc reqTwoNumbersOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoNumbersOrStrings_iouGpQgslNcuoSL0Wzu7kQ".} +proc reqStringOrQuotation*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqStringOrQuotation_Xy0o2sh9cpmSUTDb9cbQNwQg_4".} +proc reqTwoQuotationsOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoQuotationsOrStrings_iouGpQgslNcuoSL0Wzu7kQ_2".} +proc reqTwoSimilarTypesNonSymbol*(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoSimilarTypesNonSymbol_iouGpQgslNcuoSL0Wzu7kQ_3".} +proc copy*(s: ref MinScope): ref MinScope {.importc, extern:"copy_KGlnVwWC9c0GiqXFwLDTiww".} +proc getSymbol*(scope: ref MinScope, key: string): MinOperator {.importc, extern:"getSymbol_fLEzdqSpt81S0Of5t4H9afg".} +proc hasSymbol*(scope: ref MinScope, key: string): bool {.importc, extern:"hasSymbol_58ut1Z9aCNCsBFnk7k9a9cVKA".} +proc delSymbol*(scope: ref MinScope, key: string): bool {.importc, extern:"delSymbol_58ut1Z9aCNCsBFnk7k9a9cVKA_2".} +proc setSymbol*(scope: ref MinScope, key: string, value: MinOperator, override = false): bool {.importc, extern:"setSymbol_i9bO9b9aWD4K9c3RcQs0RqQvPw".} +proc getSigil*(scope: ref MinScope, key: string): MinOperator {.importc, extern:"getSigil_fLEzdqSpt81S0Of5t4H9afg_2".} +proc hasSigil*(scope: ref MinScope, key: string): bool {.importc, extern:"hasSigil_58ut1Z9aCNCsBFnk7k9a9cVKA_3".} +proc previous*(scope: ref MinScope): ref MinScope {.importc, extern:"previous_wp9cZN2pi3N79at4ESdxFNVQ".} +proc raiseRuntime*(msg: string, qVal: var seq[MinValue]) {.importc, extern:"raiseRuntime_t8oUDThVodY80ZU1ov5Z9cQ".} +proc dump*(i: MinInterpreter): string {.importc, extern:"dump_QNAGfSm5dAMbe9cao1yAs9bg".} +proc debug*(i: In, value: MinValue) {.importc, extern:"debug_e4IWAT3CueUziUEgqNhCEA".} +proc debug*(i: In, value: string) {.importc, extern:"debug_lPtsJwNzbYFsAR31JL52GA".} +proc newMinInterpreter*(filename: string): MinInterpreter {.importc, extern:"newMinInterpreter_XvlvXMt0JDVisNg0vLdKLQ".} +proc copy*(i: MinInterpreter, filename: string): MinInterpreter {.importc, extern:"copy_gOoDr5ILrrcZmPeoNmvPmg".} +proc formatError(sym: MinValue, message: string): string {.importc, extern:"formatError_c89a9aMhg9av88jUAkonIhspw".} +proc formatTrace(sym: MinValue): string {.importc, extern:"formatTrace_TfxbUETR0myClep3aQiOxA".} +proc stackTrace(i: In) {.importc, extern:"stackTrace_jfgtXM0Fziq5qAA4WP56DA".} +proc error(i: In, message: string) {.importc, extern:"error_KPzdvl74rfHwj1Zjzl9clSQ".} +proc open*(i: In, stream:Stream, filename: string) {.importc, extern:"open_0S1akx2yO9cGND7o1a5E4Pg".} +proc close*(i: In) {.importc, extern:"close_jfgtXM0Fziq5qAA4WP56DA_2".} +proc apply*(i: In, op: MinOperator) {.importc, extern:"apply_rdLuMUFDgimLSTje2hi9a9cw".} +proc push*(i: In, val: MinValue) {.importc, extern:"push_5Bl42rKgV9afPr4fSWYKCQQ".} +proc dequote*(i: In, q: var MinValue) {.importc, extern:"dequote_iIi9a4U4PSOa3lI3GtpF9a2g".} +proc apply*(i: In, q: var MinValue) {.importc, extern:"apply_iIi9a4U4PSOa3lI3GtpF9a2g_2".} +proc pop*(i: In): MinValue {.importc, extern:"pop_kQ2ndJ8jYAFjieSQojhyOA".} +proc peek*(i: MinInterpreter): MinValue {.importc, extern:"peek_iWvRjZI9bPYXgbwT9bMlY33g".} +proc interpret*(i: In): MinValue {.importc, extern:"interpret_XWC8a7Zv9bICBdwhFZC4oFw".} +proc eval*(i: In, s: string, name: string) {.importc, extern:"eval_IB9cHX0kT7i7VJ1JVxalc0g".} +proc load*(i: In, s: string) {.importc, extern:"load_0LYMivTZTdTPkcMxl9cGHiw".} +proc filetype*(p: PathComponent): string {.importc, extern:"filetype_FZiFjJo8tLR4Z31M0hOccg".} +proc unixPermissions*(s: set[FilePermission]): int {.importc, extern:"unixPermissions_yRhMgkace1wP9a9cKdvJCJhw".} +proc toFilePermissions*(p: BiggestInt): set[FilePermission] {.importc, extern:"toFilePermissions_iFbq0Qn5CDseGqlJex9cAkw".}
D dynlibprocs/fileutilsProcs

@@ -1,3 +0,0 @@

-proc filetype(p: PathComponent): string {.importc, extern:"filetype_FZiFjJo8tLR4Z31M0hOccg".} -proc unixPermissions(s: set[FilePermission]): int {.importc, extern:"unixPermissions_yRhMgkace1wP9a9cKdvJCJhw".} -proc toFilePermissions(p: BiggestInt): set[FilePermission] {.importc, extern:"toFilePermissions_iFbq0Qn5CDseGqlJex9cAkw".}
D dynlibprocs/interpreterProcs

@@ -1,20 +0,0 @@

-proc raiseRuntime(msg: string, qVal: var seq[MinValue]) {.importc, extern:"raiseRuntime_t8oUDThVodY80ZU1ov5Z9cQ".} -proc dump(i: MinInterpreter): string {.importc, extern:"dump_QNAGfSm5dAMbe9cao1yAs9bg".} -proc debug(i: In, value: MinValue) {.importc, extern:"debug_e4IWAT3CueUziUEgqNhCEA".} -proc debug(i: In, value: string) {.importc, extern:"debug_lPtsJwNzbYFsAR31JL52GA".} -proc newMinInterpreter(filename: string): MinInterpreter {.importc, extern:"newMinInterpreter_XvlvXMt0JDVisNg0vLdKLQ".} -proc copy(i: MinInterpreter, filename: string): MinInterpreter {.importc, extern:"copy_gOoDr5ILrrcZmPeoNmvPmg".} -proc formatError(sym: MinValue, message: string): string {.importc, extern:"formatError_c89a9aMhg9av88jUAkonIhspw".} -proc formatTrace(sym: MinValue): string {.importc, extern:"formatTrace_TfxbUETR0myClep3aQiOxA".} -proc stackTrace(i: In) {.importc, extern:"stackTrace_jfgtXM0Fziq5qAA4WP56DA".} -proc error(i: In, message: string) {.importc, extern:"error_KPzdvl74rfHwj1Zjzl9clSQ".} -proc open(i: In, stream:Stream, filename: string) {.importc, extern:"open_0S1akx2yO9cGND7o1a5E4Pg".} -proc close(i: In) {.importc, extern:"close_jfgtXM0Fziq5qAA4WP56DA_2".} -proc apply(i: In, op: MinOperator) {.importc, extern:"apply_rdLuMUFDgimLSTje2hi9a9cw".} -proc dequote(i: In, q: var MinValue) {.importc, extern:"dequote_iIi9a4U4PSOa3lI3GtpF9a2g".} -proc apply(i: In, q: var MinValue) {.importc, extern:"apply_iIi9a4U4PSOa3lI3GtpF9a2g_2".} -proc pop(i: In): MinValue {.importc, extern:"pop_kQ2ndJ8jYAFjieSQojhyOA".} -proc peek(i: MinInterpreter): MinValue {.importc, extern:"peek_iWvRjZI9bPYXgbwT9bMlY33g".} -proc interpret(i: In): MinValue {.importc, extern:"interpret_XWC8a7Zv9bICBdwhFZC4oFw".} -proc eval(i: In, s: string, name: string) {.importc, extern:"eval_IB9cHX0kT7i7VJ1JVxalc0g".} -proc load(i: In, s: string) {.importc, extern:"load_0LYMivTZTdTPkcMxl9cGHiw".}
D dynlibprocs/mindyn.nim

@@ -1,208 +0,0 @@

-# Import for the missing types (Look into importing just type definitions) -import - lexbase, - streams, - critbits, - json, - os - -type - MinTokenKind* = enum - tkError, - tkEof, - tkString, - tkInt, - tkFloat, - tkBracketLe, - tkBracketRi, - tkSymbol, - tkTrue, - tkFalse - MinKind* = enum - minInt, - minFloat, - minQuotation, - minString, - minSymbol, - minBool - MinEventKind* = enum ## enumeration of all events that may occur when parsing - eMinError, ## an error ocurred during parsing - 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 - MinParserError* = enum ## enumeration that lists all errors that can occur - errNone, ## no error - errInvalidToken, ## invalid token - errStringExpected, ## string expected - errBracketRiExpected, ## ``)`` expected - errQuoteExpected, ## ``"`` or ``'`` expected - errEOC_Expected, ## ``*/`` expected - errEofExpected, ## EOF expected - errExprExpected - MinParserState* = enum - stateEof, - stateStart, - stateQuotation, - stateExpectValue - MinParser* = object of BaseLexer - a*: string - token*: MinTokenKind - state*: seq[MinParserState] - kind*: MinEventKind - err*: MinParserError - filename*: string - MinValue* = ref MinValueObject - MinValueObject* = object - line*: int - column*: int - filename*: string - case kind*: MinKind - of minInt: intVal*: BiggestInt - of minFloat: floatVal*: BiggestFloat - of minQuotation: - qVal*: seq[MinValue] - scope*: ref MinScope - of minString: strVal*: string - of minSymbol: symVal*: string - of minBool: boolVal*: bool - MinScope* = object - symbols*: CritBitTree[MinOperator] - sigils*: CritBitTree[MinOperator] - parent*: ref MinScope - name*: string - stack*: MinStack - MinOperatorProc* = proc (i: In) {.closure.} - MinOperatorKind* = enum - minProcOp - minValOp - MinOperator* = object - sealed*: bool - case kind*: MinOperatorKind - of minProcOp: - prc*: MinOperatorProc - of minValOp: - val*: MinValue - MinStack* = seq[MinValue] - In* = var MinInterpreter - MinInterpreter* = object - stack*: MinStack - trace*: MinStack - stackcopy*: MinStack - pwd*: string - scope*: ref MinScope - parser*: MinParser - currSym*: MinValue - filename*: string - evaluating*: bool - MinParsingError* = ref object of ValueError - MinUndefinedError* = ref object of ValueError - MinEmptyStackError* = ref object of ValueError - MinInvalidError* = ref object of ValueError - MinOutOfBoundsError* = ref object of ValueError -proc raiseInvalid(msg: string) {.importc, extern:"raiseInvalid_Emp5jFVyMCrh15i1fpFZiQ".} -proc raiseUndefined(msg: string) {.importc, extern:"raiseUndefined_Emp5jFVyMCrh15i1fpFZiQ_2".} -proc raiseOutOfBounds(msg: string) {.importc, extern:"raiseOutOfBounds_Emp5jFVyMCrh15i1fpFZiQ_3".} -proc raiseEmptyStack() {.importc, extern:"raiseEmptyStack_TxAgT9bR9codeB2uLmVKwt3w".} -proc newScope(parent: ref MinScope): MinScope {.importc, extern:"newScope_rH9cNZXpQjLoAhnola5cX4Q".} -proc newScopeRef(parent: ref MinScope): ref MinScope {.importc, extern:"newScopeRef_s7aB4NQYrY7Hev87iAW4jw".} -proc open(my: var MinParser, input: Stream, filename: string) {.importc, extern:"open_9brvHSJ7qjV9aGAqIpwcMV3A".} -proc close(my: var MinParser) {.importc, extern:"close_vmj9agDNIDvOwQZe8A2kGIAparser".} -proc getInt(my: MinParser): int {.importc, extern:"getInt_bXIqXGzvO9aGBMkrzA6B15gparser".} -proc getFloat(my: MinParser): float {.importc, extern:"getFloat_VXTaXBiGVD6XkIZK3YSq5Aparser".} -proc kind(my: MinParser): MinEventKind {.importc, extern:"kind_tgDyDbkEOSH9aIKWnOecz4Aparser".} -proc getColumn(my: MinParser): int {.importc, extern:"getColumn_bXIqXGzvO9aGBMkrzA6B15g_2parser".} -proc getLine(my: MinParser): int {.importc, extern:"getLine_bXIqXGzvO9aGBMkrzA6B15g_3parser".} -proc getFilename(my: MinParser): string {.importc, extern:"getFilename_s9a5R24VyFqQ3N3m7ZkDqmAparser".} -proc errorMsg(my: MinParser, msg: string): string {.importc, extern:"errorMsg_cVsoiM0SE9cH0KWBNfKqZcA".} -proc errorMsg(my: MinParser): string {.importc, extern:"errorMsg_r87VYrPzvmEsJhjriyvyQw".} -proc errorMsgExpected(my: MinParser, e: string): string {.importc, extern:"errorMsgExpected_Wqyr2ROfsYVJGDFwgiczQw".} -proc raiseParsing(p: MinParser, msg: string) {.importc, extern:"raiseParsing_Tz7DX0jKGOjDMX8SFWqb1A".} -proc raiseUndefined(p:MinParser, msg: string) {.importc, extern:"raiseUndefined_Tz7DX0jKGOjDMX8SFWqb1A_2".} -proc parseNumber(my: var MinParser) {.importc, extern:"parseNumber_q1Bg9ctZWMedsyrbTHRwU9aQ".} -proc handleHexChar(c: char, x: var int): bool {.importc, extern:"handleHexChar_5qj5zQ9aD5ka0UVtIDvSjNg".} -proc parseString(my: var MinParser): MinTokenKind {.importc, extern:"parseString_e3KFIguKCxnkZTqCF3o3jg".} -proc parseSymbol(my: var MinParser): MinTokenKind {.importc, extern:"parseSymbol_4hcHuz8N3YVsotvxzfL3Kw".} -proc skip(my: var MinParser) {.importc, extern:"skip_iFcpIZyA9cJx6updYRSgzjw".} -proc getToken(my: var MinParser): MinTokenKind {.importc, extern:"getToken_e3KFIguKCxnkZTqCF3o3jg_2".} -proc next(my: var MinParser) {.importc, extern:"next_iFcpIZyA9cJx6updYRSgzjw_2".} -proc eat(p: var MinParser, token: MinTokenKind) {.importc, extern:"eat_WE9bi5nLbQn9cAjnzHQ9bV6Kw".} -proc parseMinValue(p: var MinParser, i: In): MinValue {.importc, extern:"parseMinValue_Y6xeteQ253Mvf1JjLWhFig".} -proc `$`(a: MinValue): string {.importc, extern:"dollar__byT09beg0JPSCPWB3NVBb9bQ".} -proc `$$`(a: MinValue): string {.importc, extern:"dollardollar__byT09beg0JPSCPWB3NVBb9bQ_2".} -proc print(a: MinValue) {.importc, extern:"print_az8I9cfVT9b9bR2oSHjBwYE9bQ".} -proc `==`(a: MinValue, b: MinValue): bool {.importc, extern:"eqeq__zMKrLdJOCGuSouwNLkqPvQ".} -proc copy(s: ref MinScope): ref MinScope {.importc, extern:"copy_KGlnVwWC9c0GiqXFwLDTiww".} -proc getSymbol(scope: ref MinScope, key: string): MinOperator {.importc, extern:"getSymbol_fLEzdqSpt81S0Of5t4H9afg".} -proc hasSymbol(scope: ref MinScope, key: string): bool {.importc, extern:"hasSymbol_58ut1Z9aCNCsBFnk7k9a9cVKA".} -proc delSymbol(scope: ref MinScope, key: string): bool {.importc, extern:"delSymbol_58ut1Z9aCNCsBFnk7k9a9cVKA_2".} -proc setSymbol(scope: ref MinScope, key: string, value: MinOperator, override = false): bool {.importc, extern:"setSymbol_i9bO9b9aWD4K9c3RcQs0RqQvPw".} -proc getSigil(scope: ref MinScope, key: string): MinOperator {.importc, extern:"getSigil_fLEzdqSpt81S0Of5t4H9afg_2".} -proc hasSigil(scope: ref MinScope, key: string): bool {.importc, extern:"hasSigil_58ut1Z9aCNCsBFnk7k9a9cVKA_3".} -proc previous(scope: ref MinScope): ref MinScope {.importc, extern:"previous_wp9cZN2pi3N79at4ESdxFNVQ".} -proc define(i: In): ref MinScope {.importc, extern:"define_HtvBzo0skz2GBYAKuFddKA".} -proc symbol(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"symbol_D4i19cVxxCgOFsbGlV20kyQ".} -proc symbol(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"p".} -proc sigil(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"sym".} -proc sigil(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"scope".} -proc finalize(scope: ref MinScope, name: string) {.importc, extern:"sigil_XrX9bLAdrrQ3LgR9a9aYCQDXA_2".} -proc dget(q: MinValue, s: MinValue): MinValue {.importc, extern:"dget_mfiqh3xcyXvnw9ajEytZuIA".} -proc dhas(q: MinValue, s: MinValue): bool {.importc, extern:"dhas_MEAApOlp4yH17chuSa0k9bA".} -proc ddel(i: In, p: MinValue, s: MinValue): MinValue {.importc, extern:"ddel_Riw3bw1BbxVPbq6m4TtOjw".} -proc dset(i: In, p: MinValue, s: MinValue, m: MinValue): MinValue {.importc, extern:"dset_17HpKix9agOFpoPvvopNcCA".} -proc keys(i: In, q: MinValue): MinValue {.importc, extern:"keys_oXC9bS9cwNWVkX1wVKP9aFEGA".} -proc values(i: In, q: MinValue): MinValue {.importc, extern:"values_oXC9bS9cwNWVkX1wVKP9aFEGA_2".} -proc `%`(a: MinValue): JsonNode {.importc, extern:"percent__QWqVWTWlpTitafp2NrtHgw".} -proc fromJson(i: In, json: JsonNode): MinValue {.importc, extern:"fromJson_xPRwXdsUk4l7MGnYd2GbVA".} -proc expect(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] {.importc, extern:"expect_EYb0Rd1E6Tl9bqxEJWylifg".} -proc reqQuotationOfQuotations(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfQuotations_Xy0o2sh9cpmSUTDb9cbQNwQg".} -proc reqQuotationOfNumbers(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfNumbers_Xy0o2sh9cpmSUTDb9cbQNwQg_2".} -proc reqQuotationOfSymbols(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfSymbols_Xy0o2sh9cpmSUTDb9cbQNwQg_3".} -proc reqTwoNumbersOrStrings(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoNumbersOrStrings_iouGpQgslNcuoSL0Wzu7kQ".} -proc reqStringOrQuotation(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqStringOrQuotation_Xy0o2sh9cpmSUTDb9cbQNwQg_4".} -proc reqTwoQuotationsOrStrings(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoQuotationsOrStrings_iouGpQgslNcuoSL0Wzu7kQ_2".} -proc reqTwoSimilarTypesNonSymbol(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoSimilarTypesNonSymbol_iouGpQgslNcuoSL0Wzu7kQ_3".} -proc typeName(v: MinValue): string {.importc, extern:"typeName_81jMzzfB0Qc0O4DsVU5arg".} -proc isSymbol(s: MinValue): bool {.importc, extern:"isSymbol_BKcj9aQlJC73fcAZURf0pHw".} -proc isQuotation(s: MinValue): bool {.importc, extern:"isQuotation_BKcj9aQlJC73fcAZURf0pHw_2".} -proc isString(s: MinValue): bool {.importc, extern:"isString_BKcj9aQlJC73fcAZURf0pHw_3".} -proc isFloat(s: MinValue): bool {.importc, extern:"isFloat_BKcj9aQlJC73fcAZURf0pHw_4".} -proc isInt(s: MinValue): bool {.importc, extern:"isInt_BKcj9aQlJC73fcAZURf0pHw_5".} -proc isNumber(s: MinValue): bool {.importc, extern:"isNumber_BKcj9aQlJC73fcAZURf0pHw_6".} -proc isBool(s: MinValue): bool {.importc, extern:"isBool_BKcj9aQlJC73fcAZURf0pHw_7".} -proc isStringLike(s: MinValue): bool {.importc, extern:"isStringLike_BKcj9aQlJC73fcAZURf0pHw_8".} -proc isDictionary(q: MinValue): bool {.importc, extern:"isDictionary_7f9afQ8e7zZDtSeY6FzGNrw".} -proc newVal(s: string): MinValue {.importc, extern:"newVal_JF8l73VBhy9cJEUaMht6wZA".} -proc newVal(s: cstring): MinValue {.importc, extern:"newVal_MSseSJELDL5qivFR59byJ8Q".} -proc newVal(q: seq[MinValue], parentScope: ref MinScope): MinValue {.importc, extern:"newVal_1PJ4YdZbCuyyD9bQkH2eu6A".} -proc newVal(s: BiggestInt): MinValue {.importc, extern:"newVal_xDcIKp9bEb37NZkc9bhRat9cQ".} -proc newVal(s: BiggestFloat): MinValue {.importc, extern:"newVal_ipbzO9cNeJyt42iGojkGmgg".} -proc newVal(s: bool): MinValue {.importc, extern:"newVal_3PdI7sQ7HL5wBrAMsSG5sQ".} -proc newSym(s: string): MinValue {.importc, extern:"newSym_JF8l73VBhy9cJEUaMht6wZA_2".} -proc getString(v: MinValue): string {.importc, extern:"getString_81jMzzfB0Qc0O4DsVU5arg_2".} -proc raiseRuntime(msg: string, qVal: var seq[MinValue]) {.importc, extern:"raiseRuntime_t8oUDThVodY80ZU1ov5Z9cQ".} -proc dump(i: MinInterpreter): string {.importc, extern:"dump_QNAGfSm5dAMbe9cao1yAs9bg".} -proc debug(i: In, value: MinValue) {.importc, extern:"debug_e4IWAT3CueUziUEgqNhCEA".} -proc debug(i: In, value: string) {.importc, extern:"debug_lPtsJwNzbYFsAR31JL52GA".} -proc newMinInterpreter(filename: string): MinInterpreter {.importc, extern:"newMinInterpreter_XvlvXMt0JDVisNg0vLdKLQ".} -proc copy(i: MinInterpreter, filename: string): MinInterpreter {.importc, extern:"copy_gOoDr5ILrrcZmPeoNmvPmg".} -proc formatError(sym: MinValue, message: string): string {.importc, extern:"formatError_c89a9aMhg9av88jUAkonIhspw".} -proc formatTrace(sym: MinValue): string {.importc, extern:"formatTrace_TfxbUETR0myClep3aQiOxA".} -proc stackTrace(i: In) {.importc, extern:"stackTrace_jfgtXM0Fziq5qAA4WP56DA".} -proc error(i: In, message: string) {.importc, extern:"error_KPzdvl74rfHwj1Zjzl9clSQ".} -proc open(i: In, stream:Stream, filename: string) {.importc, extern:"open_0S1akx2yO9cGND7o1a5E4Pg".} -proc close(i: In) {.importc, extern:"close_jfgtXM0Fziq5qAA4WP56DA_2".} -proc apply(i: In, op: MinOperator) {.importc, extern:"apply_rdLuMUFDgimLSTje2hi9a9cw".} -proc dequote(i: In, q: var MinValue) {.importc, extern:"dequote_iIi9a4U4PSOa3lI3GtpF9a2g".} -proc apply(i: In, q: var MinValue) {.importc, extern:"apply_iIi9a4U4PSOa3lI3GtpF9a2g_2".} -proc pop(i: In): MinValue {.importc, extern:"pop_kQ2ndJ8jYAFjieSQojhyOA".} -proc peek(i: MinInterpreter): MinValue {.importc, extern:"peek_iWvRjZI9bPYXgbwT9bMlY33g".} -proc interpret(i: In): MinValue {.importc, extern:"interpret_XWC8a7Zv9bICBdwhFZC4oFw".} -proc eval(i: In, s: string, name: string) {.importc, extern:"eval_IB9cHX0kT7i7VJ1JVxalc0g".} -proc load(i: In, s: string) {.importc, extern:"load_0LYMivTZTdTPkcMxl9cGHiw".} -proc filetype(p: PathComponent): string {.importc, extern:"filetype_FZiFjJo8tLR4Z31M0hOccg".} -proc unixPermissions(s: set[FilePermission]): int {.importc, extern:"unixPermissions_yRhMgkace1wP9a9cKdvJCJhw".} -proc toFilePermissions(p: BiggestInt): set[FilePermission] {.importc, extern:"toFilePermissions_iFbq0Qn5CDseGqlJex9cAkw".} -proc push(i: In, val: MinValue) {.importc, extern: "push_5Bl42rKgV9afPr4fSWYKCQQ".}
D dynlibprocs/parserProcs

@@ -1,32 +0,0 @@

-proc raiseInvalid(msg: string) {.importc, extern:"raiseInvalid_Emp5jFVyMCrh15i1fpFZiQ".} -proc raiseUndefined(msg: string) {.importc, extern:"raiseUndefined_Emp5jFVyMCrh15i1fpFZiQ_2".} -proc raiseOutOfBounds(msg: string) {.importc, extern:"raiseOutOfBounds_Emp5jFVyMCrh15i1fpFZiQ_3".} -proc raiseEmptyStack() {.importc, extern:"raiseEmptyStack_TxAgT9bR9codeB2uLmVKwt3w".} -proc newScope(parent: ref MinScope): MinScope {.importc, extern:"newScope_rH9cNZXpQjLoAhnola5cX4Q".} -proc newScopeRef(parent: ref MinScope): ref MinScope {.importc, extern:"newScopeRef_s7aB4NQYrY7Hev87iAW4jw".} -proc open(my: var MinParser, input: Stream, filename: string) {.importc, extern:"open_9brvHSJ7qjV9aGAqIpwcMV3A".} -proc close(my: var MinParser) {.importc, extern:"close_vmj9agDNIDvOwQZe8A2kGIAparser".} -proc getInt(my: MinParser): int {.importc, extern:"getInt_bXIqXGzvO9aGBMkrzA6B15gparser".} -proc getFloat(my: MinParser): float {.importc, extern:"getFloat_VXTaXBiGVD6XkIZK3YSq5Aparser".} -proc kind(my: MinParser): MinEventKind {.importc, extern:"kind_tgDyDbkEOSH9aIKWnOecz4Aparser".} -proc getColumn(my: MinParser): int {.importc, extern:"getColumn_bXIqXGzvO9aGBMkrzA6B15g_2parser".} -proc getLine(my: MinParser): int {.importc, extern:"getLine_bXIqXGzvO9aGBMkrzA6B15g_3parser".} -proc getFilename(my: MinParser): string {.importc, extern:"getFilename_s9a5R24VyFqQ3N3m7ZkDqmAparser".} -proc errorMsg(my: MinParser, msg: string): string {.importc, extern:"errorMsg_cVsoiM0SE9cH0KWBNfKqZcA".} -proc errorMsg(my: MinParser): string {.importc, extern:"errorMsg_r87VYrPzvmEsJhjriyvyQw".} -proc errorMsgExpected(my: MinParser, e: string): string {.importc, extern:"errorMsgExpected_Wqyr2ROfsYVJGDFwgiczQw".} -proc raiseParsing(p: MinParser, msg: string) {.importc, extern:"raiseParsing_Tz7DX0jKGOjDMX8SFWqb1A".} -proc raiseUndefined(p:MinParser, msg: string) {.importc, extern:"raiseUndefined_Tz7DX0jKGOjDMX8SFWqb1A_2".} -proc parseNumber(my: var MinParser) {.importc, extern:"parseNumber_q1Bg9ctZWMedsyrbTHRwU9aQ".} -proc handleHexChar(c: char, x: var int): bool {.importc, extern:"handleHexChar_5qj5zQ9aD5ka0UVtIDvSjNg".} -proc parseString(my: var MinParser): MinTokenKind {.importc, extern:"parseString_e3KFIguKCxnkZTqCF3o3jg".} -proc parseSymbol(my: var MinParser): MinTokenKind {.importc, extern:"parseSymbol_4hcHuz8N3YVsotvxzfL3Kw".} -proc skip(my: var MinParser) {.importc, extern:"skip_iFcpIZyA9cJx6updYRSgzjw".} -proc getToken(my: var MinParser): MinTokenKind {.importc, extern:"getToken_e3KFIguKCxnkZTqCF3o3jg_2".} -proc next(my: var MinParser) {.importc, extern:"next_iFcpIZyA9cJx6updYRSgzjw_2".} -proc eat(p: var MinParser, token: MinTokenKind) {.importc, extern:"eat_WE9bi5nLbQn9cAjnzHQ9bV6Kw".} -proc parseMinValue(p: var MinParser, i: In): MinValue {.importc, extern:"parseMinValue_Y6xeteQ253Mvf1JjLWhFig".} -proc `$`(a: MinValue): string {.importc, extern:"dollar__byT09beg0JPSCPWB3NVBb9bQ".} -proc `$$`(a: MinValue): string {.importc, extern:"dollardollar__byT09beg0JPSCPWB3NVBb9bQ_2".} -proc print(a: MinValue) {.importc, extern:"print_az8I9cfVT9b9bR2oSHjBwYE9bQ".} -proc `==`(a: MinValue, b: MinValue): bool {.importc, extern:"eqeq__zMKrLdJOCGuSouwNLkqPvQ".}
D dynlibprocs/scopeProcs

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

-proc copy(s: ref MinScope): ref MinScope {.importc, extern:"copy_KGlnVwWC9c0GiqXFwLDTiww".} -proc getSymbol(scope: ref MinScope, key: string): MinOperator {.importc, extern:"getSymbol_fLEzdqSpt81S0Of5t4H9afg".} -proc hasSymbol(scope: ref MinScope, key: string): bool {.importc, extern:"hasSymbol_58ut1Z9aCNCsBFnk7k9a9cVKA".} -proc delSymbol(scope: ref MinScope, key: string): bool {.importc, extern:"delSymbol_58ut1Z9aCNCsBFnk7k9a9cVKA_2".} -proc setSymbol(scope: ref MinScope, key: string, value: MinOperator, override = false): bool {.importc, extern:"setSymbol_i9bO9b9aWD4K9c3RcQs0RqQvPw".} -proc getSigil(scope: ref MinScope, key: string): MinOperator {.importc, extern:"getSigil_fLEzdqSpt81S0Of5t4H9afg_2".} -proc hasSigil(scope: ref MinScope, key: string): bool {.importc, extern:"hasSigil_58ut1Z9aCNCsBFnk7k9a9cVKA_3".} -proc previous(scope: ref MinScope): ref MinScope {.importc, extern:"previous_wp9cZN2pi3N79at4ESdxFNVQ".}
D dynlibprocs/types.nim

@@ -1,104 +0,0 @@

-# Import for the missing types (Look into importing just type definitions) -import - lexbase, - streams, - critbits, - json, - os - -type - MinTokenKind* = enum - tkError, - tkEof, - tkString, - tkInt, - tkFloat, - tkBracketLe, - tkBracketRi, - tkSymbol, - tkTrue, - tkFalse - MinKind* = enum - minInt, - minFloat, - minQuotation, - minString, - minSymbol, - minBool - MinEventKind* = enum ## enumeration of all events that may occur when parsing - eMinError, ## an error ocurred during parsing - 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 - MinParserError* = enum ## enumeration that lists all errors that can occur - errNone, ## no error - errInvalidToken, ## invalid token - errStringExpected, ## string expected - errBracketRiExpected, ## ``)`` expected - errQuoteExpected, ## ``"`` or ``'`` expected - errEOC_Expected, ## ``*/`` expected - errEofExpected, ## EOF expected - errExprExpected - MinParserState* = enum - stateEof, - stateStart, - stateQuotation, - stateExpectValue - MinParser* = object of BaseLexer - a*: string - token*: MinTokenKind - state*: seq[MinParserState] - kind*: MinEventKind - err*: MinParserError - filename*: string - MinValue* = ref MinValueObject - MinValueObject* = object - line*: int - column*: int - filename*: string - case kind*: MinKind - of minInt: intVal*: BiggestInt - of minFloat: floatVal*: BiggestFloat - of minQuotation: - qVal*: seq[MinValue] - scope*: ref MinScope - of minString: strVal*: string - of minSymbol: symVal*: string - of minBool: boolVal*: bool - MinScope* = object - symbols*: CritBitTree[MinOperator] - sigils*: CritBitTree[MinOperator] - parent*: ref MinScope - name*: string - stack*: MinStack - MinOperatorProc* = proc (i: In) {.closure.} - MinOperatorKind* = enum - minProcOp - minValOp - MinOperator* = object - sealed*: bool - case kind*: MinOperatorKind - of minProcOp: - prc*: MinOperatorProc - of minValOp: - val*: MinValue - MinStack* = seq[MinValue] - In* = var MinInterpreter - MinInterpreter* = object - stack*: MinStack - trace*: MinStack - stackcopy*: MinStack - pwd*: string - scope*: ref MinScope - parser*: MinParser - currSym*: MinValue - filename*: string - evaluating*: bool - MinParsingError* = ref object of ValueError - MinUndefinedError* = ref object of ValueError - MinEmptyStackError* = ref object of ValueError - MinInvalidError* = ref object of ValueError - MinOutOfBoundsError* = ref object of ValueError
D dynlibprocs/utilsProcs

@@ -1,22 +0,0 @@

-proc define(i: In): ref MinScope {.importc, extern:"define_HtvBzo0skz2GBYAKuFddKA".} -proc symbol(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"symbol_D4i19cVxxCgOFsbGlV20kyQ".} -proc symbol(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"p".} -proc sigil(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"sym".} -proc sigil(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"scope".} -proc finalize(scope: ref MinScope, name: string: string) {.importc, extern:"sigil_XrX9bLAdrrQ3LgR9a9aYCQDXA_2".} -proc dget(q: MinValue, s: MinValue): MinValue {.importc, extern:"dget_mfiqh3xcyXvnw9ajEytZuIA".} -proc dhas(q: MinValue, s: MinValue): bool {.importc, extern:"dhas_MEAApOlp4yH17chuSa0k9bA".} -proc ddel(i: In, p: MinValue, s: MinValue): MinValue {.importc, extern:"ddel_Riw3bw1BbxVPbq6m4TtOjw".} -proc dset(i: In, p: MinValue, s: MinValue, m: MinValue): MinValue {.importc, extern:"dset_17HpKix9agOFpoPvvopNcCA".} -proc keys(i: In, q: MinValue): MinValue {.importc, extern:"keys_oXC9bS9cwNWVkX1wVKP9aFEGA".} -proc values(i: In, q: MinValue): MinValue {.importc, extern:"values_oXC9bS9cwNWVkX1wVKP9aFEGA_2".} -proc `%`(a: MinValue): JsonNode {.importc, extern:"percent__QWqVWTWlpTitafp2NrtHgw".} -proc fromJson(i: In, json: JsonNode): MinValue {.importc, extern:"fromJson_xPRwXdsUk4l7MGnYd2GbVA".} -proc expect(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] {.importc, extern:"expect_EYb0Rd1E6Tl9bqxEJWylifg".} -proc reqQuotationOfQuotations(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfQuotations_Xy0o2sh9cpmSUTDb9cbQNwQg".} -proc reqQuotationOfNumbers(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfNumbers_Xy0o2sh9cpmSUTDb9cbQNwQg_2".} -proc reqQuotationOfSymbols(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfSymbols_Xy0o2sh9cpmSUTDb9cbQNwQg_3".} -proc reqTwoNumbersOrStrings(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoNumbersOrStrings_iouGpQgslNcuoSL0Wzu7kQ".} -proc reqStringOrQuotation(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqStringOrQuotation_Xy0o2sh9cpmSUTDb9cbQNwQg_4".} -proc reqTwoQuotationsOrStrings(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoQuotationsOrStrings_iouGpQgslNcuoSL0Wzu7kQ_2".} -proc reqTwoSimilarTypesNonSymbol(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoSimilarTypesNonSymbol_iouGpQgslNcuoSL0Wzu7kQ_3".}
D dynlibprocs/valueProcs

@@ -1,27 +0,0 @@

-CC: min_dynparser -CC: stdlib_system -CC: stdlib_strutils -CC: stdlib_parseutils -CC: stdlib_math -CC: stdlib_algorithm -CC: stdlib_tables -CC: stdlib_hashes -CC: stdlib_unicode -proc typeName(v: MinValue): string {.importc, extern:"typeName_81jMzzfB0Qc0O4DsVU5arg".} -proc isSymbol(s: MinValue): bool {.importc, extern:"isSymbol_BKcj9aQlJC73fcAZURf0pHw".} -proc isQuotation(s: MinValue): bool {.importc, extern:"isQuotation_BKcj9aQlJC73fcAZURf0pHw_2".} -proc isString(s: MinValue): bool {.importc, extern:"isString_BKcj9aQlJC73fcAZURf0pHw_3".} -proc isFloat(s: MinValue): bool {.importc, extern:"isFloat_BKcj9aQlJC73fcAZURf0pHw_4".} -proc isInt(s: MinValue): bool {.importc, extern:"isInt_BKcj9aQlJC73fcAZURf0pHw_5".} -proc isNumber(s: MinValue): bool {.importc, extern:"isNumber_BKcj9aQlJC73fcAZURf0pHw_6".} -proc isBool(s: MinValue): bool {.importc, extern:"isBool_BKcj9aQlJC73fcAZURf0pHw_7".} -proc isStringLike(s: MinValue): bool {.importc, extern:"isStringLike_BKcj9aQlJC73fcAZURf0pHw_8".} -proc isDictionary(q: MinValue): bool {.importc, extern:"isDictionary_7f9afQ8e7zZDtSeY6FzGNrw".} -proc newVal(s: string): MinValue {.importc, extern:"newVal_JF8l73VBhy9cJEUaMht6wZA".} -proc newVal(s: cstring): MinValue {.importc, extern:"newVal_MSseSJELDL5qivFR59byJ8Q".} -proc newVal(q: seq[MinValue], parentScope: ref MinScope): MinValue {.importc, extern:"newVal_1PJ4YdZbCuyyD9bQkH2eu6A".} -proc newVal(s: BiggestInt): MinValue {.importc, extern:"newVal_xDcIKp9bEb37NZkc9bhRat9cQ".} -proc newVal(s: BiggestFloat): MinValue {.importc, extern:"newVal_ipbzO9cNeJyt42iGojkGmgg".} -proc newVal(s: bool): MinValue {.importc, extern:"newVal_3PdI7sQ7HL5wBrAMsSG5sQ".} -proc newSym(s: string): MinValue {.importc, extern:"newSym_JF8l73VBhy9cJEUaMht6wZA_2".} -proc getString(v: MinValue): string {.importc, extern:"getString_81jMzzfB0Qc0O4DsVU5arg_2".}
D dynparser.nim

@@ -1,23 +0,0 @@

-import strutils -import nre - -var - currentLine = 1 - oldLine = 0 - sourceFile = open("core/value.nim") - -for line in lines "core/nimcache/value.ndi": - let - fields = line.split('\t') - (origName, mangledName, path, row, column) = (fields[0], fields[1], fields[2], fields[3].parseInt, fields[4]) - if path == "/home/peter/min/core/value.nim": - while currentLine < row: - currentLine += 1 - discard sourceFile.readLine() - if currentLine != oldLine: - let definition = sourceFile.readLine() - if definition.startsWith("proc"): - #echo origName & " -> " & mangledName - echo definition.replace(re""" *= *\".*\"""", ": string").replace(re"""{\..*\.}""","").replace(re""" *= *$""", "").replace("*(","(") & " {.importc, extern:\"" & mangledName & "\".}" - currentLine += 1 - oldLine = currentLine
D dyntest.min

@@ -1,5 +0,0 @@

-'dyn import -1 1 + -1 1 myplus -== -puts!
M min.nimmin.nim

@@ -134,46 +134,42 @@ i.eval MINRC.readFile()

i.eval "\"prompt\" unseal" type - setupProc = proc( - defineProc: proc(i: In): ref MinScope, - finalizeProc: proc(scope: ref MinScope, name: string), - symbolProc: proc(scope: ref MinScope, sym: string, p: MinOperatorProc), - expectProc: proc(i: var MinInterpreter, elements: varargs[string]): seq[MinValue], - pushProc: proc(i: In, val: MinValue) - ): string {.nimcall.} + DynInfo = object + moduleName: string # The name of the symbol to load and run + dynlibVersion: int # The version of the interface the dynlib is built for. This should increase if the interface changes + setupProc = proc(): DynInfo {.nimcall.} libProc = proc( i: In ) {.nimcall.} -{.emit: """ - #include <dlfcn.h> -"""} proc dynLib*(i: In) = var dll: LibHandle setup: setupProc - dll = loadLib("./dynlibs/libmindyn.so") - if dll != nil: - let setupAddr = dll.symAddr("setup") - if setupAddr != nil: - setup = cast[setupProc](setupAddr) - else: - echo "Unable to load lib" - {.emit:""" - printf("%s\n", dlerror()); - """} - - if setup != nil: - let - libName = setup(define, finalize, symbol, expect, push) - libAddr = dll.symAddr(libName) - if libAddr != nil: - var lib = cast[libProc](libAddr) - i.lib - echo "Loaded dynlib" + echo "Trying to load libraries from " & $(getAppDir() / "dynlibs") + for library in walkFiles(getAppDir() / "dynlibs/*"): + dll = loadLib(library) + if dll != nil: + let setupAddr = dll.symAddr("setup") + if setupAddr != nil: + setup = cast[setupProc](setupAddr) + if setup != nil: + let + expectedVersion = 1 + libInfo = setup() + libAddr = dll.symAddr(libInfo.moduleName) + if libInfo.dynlibVersion == expectedVersion: + if libAddr != nil: + var lib = cast[libProc](libAddr) + i.lib + echo "Loaded dynlib " & libInfo.moduleName & "[" & library & "]" + else: + echo "Wasn't able to load " & libInfo.moduleName & "(i: In) from " & library + else: + echo "Dynlib in " & library & " has wrong version, got " & $libInfo.dynlibVersion & " but expected " & $expectedVersion + else: + echo "Wasn't able to load setup() from " & library else: - echo "Wasn't able to load " & libName & "(i: In) from DLL." - else: - echo "Wasn't able to load setup() from DLL." + echo "Unable to load lib from " & library proc interpret*(i: In, s: Stream) = i.stdLib()
D mindyn.nim

@@ -1,198 +0,0 @@

-{.pragma: rtl, exportc, dynlib, cdecl.} - -import - lexbase, - streams, - critbits - -type - MinTokenKind* = enum - tkError, - tkEof, - tkString, - tkInt, - tkFloat, - tkBracketLe, - tkBracketRi, - tkSymbol, - tkTrue, - tkFalse - MinKind* = enum - minInt, - minFloat, - minQuotation, - minString, - minSymbol, - minBool - MinEventKind* = enum ## enumeration of all events that may occur when parsing - eMinError, ## an error ocurred during parsing - 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 - MinParserError* = enum ## enumeration that lists all errors that can occur - errNone, ## no error - errInvalidToken, ## invalid token - errStringExpected, ## string expected - errBracketRiExpected, ## ``)`` expected - errQuoteExpected, ## ``"`` or ``'`` expected - errEOC_Expected, ## ``*/`` expected - errEofExpected, ## EOF expected - errExprExpected - MinParserState* = enum - stateEof, - stateStart, - stateQuotation, - stateExpectValue - MinParser* = object of BaseLexer - a*: string - token*: MinTokenKind - state*: seq[MinParserState] - kind*: MinEventKind - err*: MinParserError - filename*: string - MinValue* = ref MinValueObject - MinValueObject* = object - line*: int - column*: int - filename*: string - case kind*: MinKind - of minInt: intVal*: BiggestInt - of minFloat: floatVal*: BiggestFloat - of minQuotation: - qVal*: seq[MinValue] - scope*: ref MinScope - of minString: strVal*: string - of minSymbol: symVal*: string - of minBool: boolVal*: bool - MinScope* = object - symbols*: CritBitTree[MinOperator] - sigils*: CritBitTree[MinOperator] - parent*: ref MinScope - name*: string - stack*: MinStack - MinOperatorProc* = proc (i: In) {.closure.} - MinOperatorKind* = enum - minProcOp - minValOp - MinOperator* = object - sealed*: bool - case kind*: MinOperatorKind - of minProcOp: - prc*: MinOperatorProc - of minValOp: - val*: MinValue - MinStack* = seq[MinValue] - In* = var MinInterpreter - MinInterpreter* = object - stack*: MinStack - trace*: MinStack - stackcopy*: MinStack - pwd*: string - scope*: ref MinScope - parser*: MinParser - currSym*: MinValue - filename*: string - evaluating*: bool - MinParsingError* = ref object of ValueError - MinUndefinedError* = ref object of ValueError - MinEmptyStackError* = ref object of ValueError - MinInvalidError* = ref object of ValueError - MinOutOfBoundsError* = ref object of ValueError - -proc isSymbol*(s: MinValue): bool = - return s.kind == minSymbol - -proc isQuotation*(s: MinValue): bool = - return s.kind == minQuotation - -proc isString*(s: MinValue): bool = - return s.kind == minString - -proc isFloat*(s: MinValue): bool = - return s.kind == minFloat - -proc isInt*(s: MinValue): bool = - return s.kind == minInt - -proc isNumber*(s: MinValue): bool = - return s.kind == minInt or s.kind == minFloat - -proc isBool*(s: MinValue): bool = - return s.kind == minBool - -proc isStringLike*(s: MinValue): bool = - return s.isSymbol or s.isString or (s.isQuotation and s.qVal.len == 1 and s.qVal[0].isSymbol) - -proc isDictionary*(q: MinValue): bool = - if not q.isQuotation: - return false - if q.qVal.len == 0: - return true - for val in q.qVal: - if not val.isQuotation or val.qVal.len != 2 or not val.qVal[0].isString: - return false - return true - -proc newVal*(s: string): MinValue = - return MinValue(kind: minString, strVal: s) - -proc newVal*(s: cstring): MinValue = - return MinValue(kind: minString, strVal: $s) - -#proc newVal*(q: seq[MinValue], parentScope: ref MinScope): MinValue = -# return MinValue(kind: minQuotation, qVal: q, scope: newScopeRef(parentScope)) - -proc newVal*(s: BiggestInt): MinValue = - return MinValue(kind: minInt, intVal: s) - -proc newVal*(s: BiggestFloat): MinValue = - return MinValue(kind: minFloat, floatVal: s) - -proc newVal*(s: bool): MinValue = - return MinValue(kind: minBool, boolVal: s) - -proc newSym*(s: string): MinValue = - return MinValue(kind: minSymbol, symVal: s) - -var - define: proc(i: In): ref MinScope - finalize: proc(scope: ref MinScope, name: string) - symbol: proc(scope: ref MinScope, sym: string, p: MinOperatorProc) - expect: proc(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] - push: proc(i: In, val: MinValue) - -proc setup*( - defineProc: proc(i: In): ref MinScope, - finalizeProc: proc(scope: ref MinScope, name: string), - symbolProc: proc(scope: ref MinScope, sym: string, p: MinOperatorProc), - expectProc: proc(i: var MinInterpreter, elements: varargs[string]): seq[MinValue], - pushProc: proc(i: In, val: MinValue) - ): string {.rtl.} = - echo "Hello from lib" - define = defineProc - finalize = finalizeProc - symbol = symbolProc - expect = expectProc - push = pushProc - result = "the_lib" - -proc the_lib*(i: In) {.rtl.} = - let def = i.define() - def.symbol("myplus") do (i: In): - let vals = i.expect("num", "num") - let a = vals[0] - let b = vals[1] - if a.isInt: - if b.isInt: - i.push newVal(a.intVal + b.intVal) - else: - i.push newVal(a.intVal.float + b.floatVal) - else: - if b.isFloat: - i.push newVal(a.floatVal + b.floatVal) - else: - i.push newVal(a.floatVal + b.intVal.float) - def.finalize("dyn")
D mindyn2.nim

@@ -1,196 +0,0 @@

-{.pragma: rtl, exportc, dynlib, cdecl.} - -#import -# core/parser, -# core/value, -# core/interpreter, -# core/utils -import - lexbase, - streams, - critbits - -type - MinTokenKind* = enum - tkError, - tkEof, - tkString, - tkInt, - tkFloat, - tkBracketLe, - tkBracketRi, - tkSymbol, - tkTrue, - tkFalse - MinKind* = enum - minInt, - minFloat, - minQuotation, - minString, - minSymbol, - minBool - MinEventKind* = enum ## enumeration of all events that may occur when parsing - eMinError, ## an error ocurred during parsing - 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 - MinParserError* = enum ## enumeration that lists all errors that can occur - errNone, ## no error - errInvalidToken, ## invalid token - errStringExpected, ## string expected - errBracketRiExpected, ## ``)`` expected - errQuoteExpected, ## ``"`` or ``'`` expected - errEOC_Expected, ## ``*/`` expected - errEofExpected, ## EOF expected - errExprExpected - MinParserState* = enum - stateEof, - stateStart, - stateQuotation, - stateExpectValue - MinParser* = object of BaseLexer - a*: string - token*: MinTokenKind - state*: seq[MinParserState] - kind*: MinEventKind - err*: MinParserError - filename*: string - MinValue* = ref MinValueObject - MinValueObject* = object - line*: int - column*: int - filename*: string - case kind*: MinKind - of minInt: intVal*: BiggestInt - of minFloat: floatVal*: BiggestFloat - of minQuotation: - qVal*: seq[MinValue] - scope*: ref MinScope - of minString: strVal*: string - of minSymbol: symVal*: string - of minBool: boolVal*: bool - MinScope* = object - symbols*: CritBitTree[MinOperator] - sigils*: CritBitTree[MinOperator] - parent*: ref MinScope - name*: string - stack*: MinStack - MinOperatorProc* = proc (i: In) {.closure.} - MinOperatorKind* = enum - minProcOp - minValOp - MinOperator* = object - sealed*: bool - case kind*: MinOperatorKind - of minProcOp: - prc*: MinOperatorProc - of minValOp: - val*: MinValue - MinStack* = seq[MinValue] - In* = var MinInterpreter - MinInterpreter* = object - stack*: MinStack - trace*: MinStack - stackcopy*: MinStack - pwd*: string - scope*: ref MinScope - parser*: MinParser - currSym*: MinValue - filename*: string - evaluating*: bool - MinParsingError* = ref object of ValueError - MinUndefinedError* = ref object of ValueError - MinEmptyStackError* = ref object of ValueError - MinInvalidError* = ref object of ValueError - MinOutOfBoundsError* = ref object of ValueError - -proc isSymbol*(s: MinValue): bool = - return s.kind == minSymbol - -proc isQuotation*(s: MinValue): bool = - return s.kind == minQuotation - -proc isString*(s: MinValue): bool = - return s.kind == minString - -proc isFloat*(s: MinValue): bool = - return s.kind == minFloat - -proc isInt*(s: MinValue): bool = - return s.kind == minInt - -proc isNumber*(s: MinValue): bool = - return s.kind == minInt or s.kind == minFloat - -proc isBool*(s: MinValue): bool = - return s.kind == minBool - -proc isStringLike*(s: MinValue): bool = - return s.isSymbol or s.isString or (s.isQuotation and s.qVal.len == 1 and s.qVal[0].isSymbol) - -proc isDictionary*(q: MinValue): bool = - if not q.isQuotation: - return false - if q.qVal.len == 0: - return true - for val in q.qVal: - if not val.isQuotation or val.qVal.len != 2 or not val.qVal[0].isString: - return false - return true - -proc newVal*(s: string): MinValue = - return MinValue(kind: minString, strVal: s) - -proc newVal*(s: cstring): MinValue = - return MinValue(kind: minString, strVal: $s) - -#proc newVal*(q: seq[MinValue], parentScope: ref MinScope): MinValue = -# return MinValue(kind: minQuotation, qVal: q, scope: newScopeRef(parentScope)) - -proc newVal*(s: BiggestInt): MinValue = - return MinValue(kind: minInt, intVal: s) - -proc newVal*(s: BiggestFloat): MinValue = - return MinValue(kind: minFloat, floatVal: s) - -proc newVal*(s: bool): MinValue = - return MinValue(kind: minBool, boolVal: s) - -proc newSym*(s: string): MinValue = - return MinValue(kind: minSymbol, symVal: s) - -proc define(i: In): ref MinScope {.importc, extern: "define_HtvBzo0skz2GBYAKuFddKA".} -proc finalize(scope: ref MinScope, name: string) {.importc, extern: "finalize_Igz9a7Xvo9cCa28si6nE0p5A".} -proc symbol(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern: "symbol_D4i19cVxxCgOFsbGlV20kyQ".} -proc expect(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] {.importc, extern: "expect_EYb0Rd1E6Tl9bqxEJWylifg".} -proc push(i: In, val: MinValue) {.importc, extern: "push_5Bl42rKgV9afPr4fSWYKCQQ".} - -proc setup*( - defineProc: proc(i: In): ref MinScope, - finalizeProc: proc(scope: ref MinScope, name: string), - symbolProc: proc(scope: ref MinScope, sym: string, p: MinOperatorProc), - expectProc: proc(i: var MinInterpreter, elements: varargs[string]): seq[MinValue], - pushProc: proc(i: In, val: MinValue) - ): string {.rtl.} = - result = "the_lib" - -proc the_lib*(i: In) {.rtl.} = - let def = i.define() - def.symbol("myp") do (i: In): - let vals = i.expect("num", "num") - let a = vals[0] - let b = vals[1] - if a.isInt: - if b.isInt: - i.push newVal(a.intVal + b.intVal) - else: - i.push newVal(a.intVal.float + b.floatVal) - else: - if b.isFloat: - i.push newVal(a.floatVal + b.floatVal) - else: - i.push newVal(a.floatVal + b.intVal.float) - def.finalize("dyn2")
D mindyn3.nim

@@ -1,29 +0,0 @@

-{.pragma: rtl, exportc, dynlib, cdecl.} -include "dynlibprocs/mindyn.nim" - -proc setup*( - defineProc: proc(i: In): ref MinScope, - finalizeProc: proc(scope: ref MinScope, name: string), - symbolProc: proc(scope: ref MinScope, sym: string, p: MinOperatorProc), - expectProc: proc(i: var MinInterpreter, elements: varargs[string]): seq[MinValue], - pushProc: proc(i: In, val: MinValue) - ): string {.rtl.} = - result = "the_lib" - -proc the_lib*(i: In) {.rtl.} = - let def = i.define() - def.symbol("myp") do (i: In): - let vals = i.expect("num", "num") - let a = vals[0] - let b = vals[1] - if a.isInt: - if b.isInt: - i.push newVal(a.intVal + b.intVal) - else: - i.push newVal(a.intVal.float + b.floatVal) - else: - if b.isFloat: - i.push newVal(a.floatVal + b.floatVal) - else: - i.push newVal(a.floatVal + b.intVal.float) - def.finalize("dyn2")