all repos — min @ acc4d3725fea53776474dae876ebc67472009f50

A small but practical concatenative programming language.

Trying to auto-generate the procedure mappings, still not quite working
Peter Munch-Ellingsen peterme@peterme.net
Wed, 25 Oct 2017 15:29:44 +0200
commit

acc4d3725fea53776474dae876ebc67472009f50

parent

217b4d6e32c8488ed8c0557065ffd2d59b50133d

A dynlibprocs/fileutilsProcs

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

+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".}
A dynlibprocs/interpreterProcs

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

+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".}
A dynlibprocs/mindyn.nim

@@ -0,0 +1,210 @@

+# 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 + +# Define all procedures and map them to their external symbol (as they will appear when loaded) +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:"result".} +proc raiseUndefined(p:MinParser, msg: string) {.importc, extern:"msg".} +proc parseNumber(my: var MinParser) {.importc, extern:"msg".} +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:"result".} +proc newVal(s: BiggestFloat): MinValue {.importc, extern:"result".} +proc newVal(s: bool): MinValue {.importc, extern:"result".} +proc newSym(s: string): MinValue {.importc, extern:"result".} +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".}
A dynlibprocs/parserProcs

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

+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:"result".} +proc raiseUndefined(p:MinParser, msg: string) {.importc, extern:"msg".} +proc parseNumber(my: var MinParser) {.importc, extern:"msg".} +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".}
A dynlibprocs/scopeProcs

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

+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".}
A dynlibprocs/types.nim

@@ -0,0 +1,102 @@

+# Import for the missing types (Look into importing just type definitions) +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
A dynlibprocs/utilsProcs

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

+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".}
A dynlibprocs/valueProcs

@@ -0,0 +1,18 @@

+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:"result".} +proc newVal(s: BiggestFloat): MinValue {.importc, extern:"result".} +proc newVal(s: bool): MinValue {.importc, extern:"result".} +proc newSym(s: string): MinValue {.importc, extern:"result".} +proc getString(v: MinValue): string {.importc, extern:"getString_81jMzzfB0Qc0O4DsVU5arg_2".}
A dynparser.nim

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

+import strutils +import nre + +var + currentLine = 1 + oldLine = 0 + sourceFile = open("parser2.nim") + +for line in lines "parser.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/parser.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 & "\".}" + oldLine = currentLine + currentLine += 1
A mindyn3.nim

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

+{.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")