all repos — min @ 6578177e05a03e274f52e025f3dd724e149dc1a2

A small but practical concatenative programming language.

Working on autocompletion.
h3rald h3rald@h3rald.com
Sat, 01 Jun 2024 14:24:39 +0200
commit

6578177e05a03e274f52e025f3dd724e149dc1a2

parent

5e23c241e3051ae7a7a206e4ba0fcc5cff4fb188

2 files changed, 15 insertions(+), 26 deletions(-)

jump to
M minpkg/core/shell.nimminpkg/core/shell.nim

@@ -42,23 +42,14 @@ if words.len == 0:

word = ed.lineText else: word = words[words.len-1] - if word.startsWith("'"): - return symbols.mapIt("'" & $it) - if word.startsWith("~"): - return symbols.mapIt("~" & $it) - if word.startsWith("?"): - return symbols.mapIt("?" & $it) - if word.startsWith("@"): - return symbols.mapIt("@" & $it) - if word.startsWith("#"): - return symbols.mapIt("#" & $it) - if word.startsWith(">"): - return symbols.mapIt(">" & $it) if word.contains("."): - let dicts = word.split(".") var op: MinOperator var dict: MinValue var path = "" + if ['?', '@', '\'', '~', '#'].contains(word[0]): + word = word[1..^1] + path &= word[0] + let dicts = word.split(".") for d in dicts: if dict.isNil: if i.scope.symbols.hasKey(d):

@@ -76,10 +67,16 @@ elif op.kind == minValOp and op.val.kind == minDictionary:

dict = op.val path &= d & "." return dict.dVal.keys.toSeq.mapIt(path & it) - if word.startsWith("("): - return symbols.mapIt("(" & $it) - if word.startsWith("<"): - return toSeq(MINSYMBOLS.readFile.parseJson.pairs).mapIt("<" & $it[0]) + if word.startsWith("'"): + return symbols.mapIt("'" & $it) + if word.startsWith("~"): + return symbols.mapIt("~" & $it) + if word.startsWith("?"): + return symbols.mapIt("?" & $it) + if word.startsWith("@"): + return symbols.mapIt("@" & $it) + if word.startsWith("#"): + return symbols.mapIt("#" & $it) if word.startsWith("$"): return toSeq(envPairs()).mapIt("$" & $it[0]) if word.startsWith("\""):

@@ -106,14 +103,6 @@ dir = getCurrentDir()

return toSeq(walkDir(dir, true)).filterIt( it.path.toLowerAscii.startsWith(f.toLowerAscii)).mapIt("\"$1\"" % [ it.path.replace("\\", "/")]) - if word.startsWith("*"): - let filterProc = proc (it: string): bool = - let op = i.scope.symbols[it] - if op.kind == minProcOp and not op.mdl.isNil: - return true - else: - return op.kind == minValOp and op.val.kind == minDictionary - return symbols.filter(filterProc).mapIt("*" & $it) return symbols proc p(s: string, color = fgWhite) =
M minpkg/lib/min_global.nimminpkg/lib/min_global.nim

@@ -1133,7 +1133,7 @@ else:

raiseInvalid("Cannot convert a quotation to float.") def.symbol("prompt") do (i: In): - i.eval(""""[$1]\n$$ " (.) => %""") + i.eval(""""[$1]\n$$ " (pwd) => %""") def.symbol("quotesym") do (i: In): let vals = i.expect("str")