printExp, printStr
This commit is contained in:
@@ -323,6 +323,7 @@ class Helpers {
|
|||||||
interp.variables.set("readExpArray", Reader.readExpArray.bind(_, _, k));
|
interp.variables.set("readExpArray", Reader.readExpArray.bind(_, _, k));
|
||||||
interp.variables.set("ReaderExp", ReaderExpDef);
|
interp.variables.set("ReaderExp", ReaderExpDef);
|
||||||
interp.variables.set("nextToken", Reader.nextToken.bind(_, "a token"));
|
interp.variables.set("nextToken", Reader.nextToken.bind(_, "a token"));
|
||||||
|
interp.variables.set("printExp", printExp);
|
||||||
interp.variables.set("kiss", {
|
interp.variables.set("kiss", {
|
||||||
ReaderExp: {
|
ReaderExp: {
|
||||||
ReaderExpDef: ReaderExpDef
|
ReaderExpDef: ReaderExpDef
|
||||||
@@ -385,6 +386,17 @@ class Helpers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function printExp(e:Dynamic, label = "") {
|
||||||
|
var toPrint = label;
|
||||||
|
if (label.length > 0) {
|
||||||
|
toPrint += ": ";
|
||||||
|
}
|
||||||
|
var expDef = if (e.def != null) e.def else e;
|
||||||
|
toPrint += Reader.toString(expDef);
|
||||||
|
Prelude.printStr(toPrint);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
static function evalUnquoteLists(l:Array<ReaderExp>, k:KissState, ?args:Map<String, Dynamic>):Array<ReaderExp> {
|
static function evalUnquoteLists(l:Array<ReaderExp>, k:KissState, ?args:Map<String, Dynamic>):Array<ReaderExp> {
|
||||||
var idx = 0;
|
var idx = 0;
|
||||||
while (idx < l.length) {
|
while (idx < l.length) {
|
||||||
|
@@ -322,12 +322,21 @@ class Prelude {
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static dynamic function print<T>(v:T):T {
|
public static dynamic function printStr(s:String) {
|
||||||
#if (sys || hxnodejs)
|
#if (sys || hxnodejs)
|
||||||
Sys.println(v);
|
Sys.println(s);
|
||||||
#else
|
#else
|
||||||
trace(v);
|
trace(s);
|
||||||
#end
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function print<T>(v:T, label = ""):T {
|
||||||
|
var toPrint = label;
|
||||||
|
if (label.length > 0) {
|
||||||
|
toPrint += ": ";
|
||||||
|
}
|
||||||
|
toPrint += Std.string(v);
|
||||||
|
printStr(toPrint);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
,@(_randomLengthMacroList _randomUncertainExp))}
|
,@(_randomLengthMacroList _randomUncertainExp))}
|
||||||
])))
|
])))
|
||||||
(defMacro randomFalsyExp []
|
(defMacro randomFalsyExp []
|
||||||
~(_randomFalsyExp))
|
(printExp (_randomFalsyExp) "Falsy"))
|
||||||
|
|
||||||
(defMacroFunction _randomTruthyExp []
|
(defMacroFunction _randomTruthyExp []
|
||||||
((chooseRandom
|
((chooseRandom
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
->{(_randomLetterString)}
|
->{(_randomLetterString)}
|
||||||
])))
|
])))
|
||||||
(defMacro randomTruthyExp []
|
(defMacro randomTruthyExp []
|
||||||
~(_randomTruthyExp))
|
(printExp (_randomTruthyExp) "Truthy"))
|
||||||
|
|
||||||
(defMacroFunction _randomUncertainExp []
|
(defMacroFunction _randomUncertainExp []
|
||||||
((chooseRandom
|
((chooseRandom
|
||||||
|
@@ -209,10 +209,7 @@
|
|||||||
(registerCommand description (lambda :Void [&opt _] (executeCommand command))))
|
(registerCommand description (lambda :Void [&opt _] (executeCommand command))))
|
||||||
|
|
||||||
(function :Void registerBuiltins []
|
(function :Void registerBuiltins []
|
||||||
(set Prelude.print
|
(set Prelude.printStr Vscode.window.showInformationMessage)
|
||||||
->[v] {
|
|
||||||
(infoMessage (Std.string v))
|
|
||||||
v})
|
|
||||||
(registerCommand "Run a [k]iss command" runCommand)
|
(registerCommand "Run a [k]iss command" runCommand)
|
||||||
(registerCommand "Rerun last command" runLastCommand)
|
(registerCommand "Rerun last command" runLastCommand)
|
||||||
(registerCommand "Run a keyboard shortcut command" runKeyboardShortcut)
|
(registerCommand "Run a keyboard shortcut command" runKeyboardShortcut)
|
||||||
|
Reference in New Issue
Block a user