Make aliases more flexible
This commit is contained in:
@@ -163,12 +163,12 @@ class Helpers {
|
||||
}
|
||||
|
||||
// alias replacements are processed by the reader
|
||||
public static function defAlias(k:KissState, whenItsThis:String, makeItThisInstead:String) {
|
||||
public static function defAlias(k:KissState, whenItsThis:String, makeItThisInstead:ReaderExpDef) {
|
||||
// The alias has to be followed by a terminator to count!
|
||||
for (terminator in Reader.terminators) {
|
||||
k.readTable[whenItsThis + terminator] = (s:Stream) -> {
|
||||
s.putBackString(terminator);
|
||||
Symbol(makeItThisInstead);
|
||||
makeItThisInstead;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -48,10 +48,10 @@ class Kiss {
|
||||
k.convert = readerExpToHaxeExpr.bind(_, k);
|
||||
|
||||
// Helpful aliases
|
||||
k.defAlias("print", "Prelude.print");
|
||||
k.defAlias("map", "Lambda.map");
|
||||
k.defAlias("filter", "Lambda.filter");
|
||||
k.defAlias("has", "Lambda.has");
|
||||
k.defAlias("print", Symbol("Prelude.print"));
|
||||
k.defAlias("map", Symbol("Lambda.map"));
|
||||
k.defAlias("filter", Symbol("Lambda.filter"));
|
||||
k.defAlias("has", Symbol("Lambda.has"));
|
||||
|
||||
while (true) {
|
||||
stream.dropWhitespace();
|
||||
|
@@ -205,13 +205,7 @@ class Macros {
|
||||
whenItsThis;
|
||||
default:
|
||||
throw CompileError.fromExp(exps[0], 'first argument to defalias should be a symbol for the alias');
|
||||
}, switch (exps[1].def) {
|
||||
case Symbol(makeItThis):
|
||||
makeItThis;
|
||||
default:
|
||||
throw CompileError.fromExp(exps[1], 'second argument to defalias should be a symbol for what the alias becomes');
|
||||
});
|
||||
|
||||
}, exps[1].def);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user