all repos — min @ b4eebd2ecdd98d7056b1388f4f28bf7a2af00b25

A small but practical concatenative programming language.

Reverting changes about DEV mode; re-adding sigils to all scopes.
h3rald h3rald@h3rald.com
Sun, 15 Jul 2018 20:08:34 +0200
commit

b4eebd2ecdd98d7056b1388f4f28bf7a2af00b25

parent

1f6a02ad9e3595ac541b628a605921fc551d6ed4

M core/parser.nimcore/parser.nim

@@ -10,8 +10,6 @@ critbits,

math, logging -var DEV* = false - type MinTokenKind* = enum tkError,

@@ -91,11 +89,8 @@ minLangScope

MinScope* = object {.acyclic, shallow, final.} parent*: ref MinScope symbols*: CritBitTree[MinOperator] - case kind: MinScopeKind - of minNativeScope: - sigils*: CritBitTree[MinOperator] - of minLangScope: - discard + sigils*: CritBitTree[MinOperator] + kind*: MinScopeKind MinOperatorProc* = proc (i: In) {.closure.} MinOperatorKind* = enum minProcOp
M core/scope.nimcore/scope.nim

@@ -1,6 +1,5 @@

import strutils, - sequtils, ## critbits import parser
M core/utils.nimcore/utils.nim

@@ -218,11 +218,6 @@ return true

return false proc expect*(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] {.extern:"min_exported_symbol_$1".}= - if not DEV: - result = newSeq[MinValue](0) - for e in elements: - result.add i.pop - return let stack = elements.reverse.join(" ") let sym = i.currSym.getString var valid = newSeq[string](0)

@@ -252,8 +247,6 @@ valid.add element

proc reqQuotationOfQuotations*(i: var MinInterpreter, a: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop - if not DEV: - return if not a.isQuotation: raiseInvalid("A quotation is required on the stack") for s in a.qVal:

@@ -262,8 +255,6 @@ raiseInvalid("A quotation of quotations is required on the stack")

proc reqQuotationOfNumbers*(i: var MinInterpreter, a: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop - if not DEV: - return if not a.isQuotation: raiseInvalid("A quotation is required on the stack") for s in a.qVal:

@@ -272,8 +263,6 @@ raiseInvalid("A quotation of numbers is required on the stack")

proc reqQuotationOfSymbols*(i: var MinInterpreter, a: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop - if not DEV: - return if not a.isQuotation: raiseInvalid("A quotation is required on the stack") for s in a.qVal:

@@ -283,22 +272,16 @@

proc reqTwoNumbersOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop b = i.pop - if not DEV: - return if not (a.isString and b.isString or a.isNumber and b.isNumber): raiseInvalid("Two numbers or two strings are required on the stack") proc reqStringOrQuotation*(i: var MinInterpreter, a: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop - if not DEV: - return if not a.isQuotation and not a.isString: raiseInvalid("A quotation or a string is required on the stack") proc reqTwoQuotationsOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop b = i.pop - if not DEV: - return if not (a.isQuotation and b.isQuotation or a.isString and b.isString): raiseInvalid("Two quotations or two strings are required on the stack")
M min.nimmin.nim

@@ -244,7 +244,6 @@ i.stdLib()

i.dynLib() var s = newStringStream("") i.open(s, "<repl>") - DEV = true var line: string var ed = initEditor(historyFile = MINHISTORY) while true:

@@ -290,8 +289,6 @@ -—install:<lib> Install dynamic library file <lib>

—-uninstall:<lib> Uninstall dynamic library file <lib> -l, --log Set log level (debug|info|notice|warn|error|fatal) Default: notice - -d, --dev Run in development mode - Default: false -e, --evaluate Evaluate a $1 program inline -h, —-help Print this help -v, —-version Print the program version

@@ -309,8 +306,6 @@ if file == "":

file = key of cmdLongOption, cmdShortOption: case key: - of "dev", "d": - DEV = true of "log", "l": if file == "": var val = val
M site/contents/download.mdsite/contents/download.md

@@ -81,12 +81,6 @@ > %min-terminal%

> > [$](class:prompt) cat myfile.min | min -## Development Mode - -By default, when you execute a min program it is run in _production mode_ meaning that some of the runtime checks and validation on the stack items expected by quotations are _not_ performed, essentially to speed up execution a little bit. By contrast, when executing min code from the min shell, it will be executed in _development mode_, with all runtime checks and validations enabled. - -To enable development mode when executing a program, run min specifying the **-d** or **--dev** flag. - ## Syntax Highlighting * If you are using [Vim](https://www.vim.org), a [min.vim](https://github.com/h3rald/min/blob/master/min.vim) syntax definition file is available in the min repo.
M site/contents/reference-seq.mdsite/contents/reference-seq.md

@@ -4,12 +4,6 @@ title: "seq Module"

----- {@ _defs_.md || 0 @} -{#sig||/||dget#} - -{#sig||?||dhas?#} - -{#sig||%||dset#} - {#op||all?||{{q1}} {{q2}}||{{b}}|| Applies predicate {{q2}} to each element of {{q1}} and returns {{t}} if all elements of {{q1}} satisfy predicate {{q2}}, {{f}} otherwise. #}

@@ -25,55 +19,8 @@

{#op||concat||{{q1}} {{q2}}||{{q3}}|| Concatenates {{q1}} with {{q2}}. #} -{#op||ddel||{{d1}} {{sl}}||{{d2}}|| -Returns a copy of {{d1}} without the element with key {{sl}}. #} - -{#op||dget||{{d}} {{sl}}||{{any}}|| -Returns the value of key {{sl}} from dictionary {{d}}. #} - -{#op||dhas?||{{d}} {{sl}}||{{b}}|| -> Returns {{t}} if dictionary {{d}} contains the key {{sl}}, {{f}} otherwise. -> -> > %sidebar% -> > Example -> > -> > The following program returns {{t}}: -> > -> > (("a1" true) ("a2" "aaa") ("a3" false)) 'a2 dhas? - #} - -{#op||dkeys||{{d}}||({{s}}{{0p}})|| -Returns a quotation containing all the keys of dictionary {{d}}. #} - -{#op||dpick||{{d1}} {{q}}||{{d2}}|| -> Returns a new dictionary {{d2}} containing the elements of {{d1}} whose keys are included in {{q}}. -> -> > %sidebar% -> > Example -> > -> > The following program returns `(("a" 4) ("d" 7))`: -> > -> > (("q" 5) ("a" 4) ("c" 6) ("d" 7)) ("a" "d") dpick - #} - {#op||drop||{{q1}} {{i}}||{{q2}}|| Returns a quotation {{q2}} containing the remaining elements after the first _n_ values of the input quotation {{q1}}, or an empty quotation if {{i}} is greater than the length of {{q1}}. #} - -{#op||dset||{{d1}} {{any}} {{sl}}||{{d2}}|| -Sets the value of the {{sl}} of {{d1}} to {{any}}, and returns the modified copy of the dictionary {{d2}}. #} - -{#op||dsort||{{d1}}||{{d2}}|| -> Returns a new dictionary {{d2}} containing all elements of {{d1}} sorted by key in ascending order. -> -> > %sidebar% -> > Example -> > -> > The following program leaves `(("a" 342) ("b" true) ("c" -4) ("d" 22))` on the stack: -> > -> > (("b" true) ("d" 22) ("c" -4) ("a" 342)) dsort#} - -{#op||dvalues||{{d}}||({{a0p}})|| -Returns a quotation containing all the values of dictionary {{d}}. #} {#op||filter||{{q1}} {{q2}}||{{q3}}|| > Returns a new quotation {{q3}} containing all elements of {{q1}} that satisfy predicate {{q2}}.
M site/settings.jsonsite/settings.json

@@ -5,6 +5,6 @@ "templates": "templates",

"temp": "temp", "output": "output", "title": "min language", - "version": "0.18.0", + "version": "0.19.0", "rules": "rules.min" }