allow hollywoo readermacros to handle optional arguments
This commit is contained in:
@@ -344,6 +344,8 @@ class Helpers {
|
||||
FieldExp(field, removeTypeAnnotations(innerExp));
|
||||
case KeyValueExp(keyExp, valueExp):
|
||||
KeyValueExp(removeTypeAnnotations(keyExp), removeTypeAnnotations(valueExp));
|
||||
case None:
|
||||
None;
|
||||
default:
|
||||
throw CompileError.fromExp(exp, 'cannot remove type annotations');
|
||||
};
|
||||
@@ -404,6 +406,7 @@ class Helpers {
|
||||
});
|
||||
interp.variables.set("k", k.forMacroEval());
|
||||
interp.variables.set("Macros", Macros);
|
||||
interp.variables.set("Stream", Stream);
|
||||
for (name => value in k.macroVars) {
|
||||
interp.variables.set(name, value);
|
||||
}
|
||||
|
@@ -50,6 +50,8 @@
|
||||
readerMacroStart "$(.toUpperCase methodName) "]
|
||||
`{
|
||||
(defReaderMacro ,readerMacroStart [stream &builder b]
|
||||
(let [nextLineStream
|
||||
(Stream.fromString (stream.expect "hollywoo macro line" ->(stream.takeLine)))]
|
||||
(b.callSymbol
|
||||
,methodName
|
||||
,(for arg args
|
||||
@@ -57,7 +59,11 @@
|
||||
((exprTyped Continuation cc)
|
||||
(b.callSymbol "b.symbol" [(b.str "cc")]))
|
||||
(_
|
||||
(b.callSymbol "read" [(b.symbol "stream")]))))))
|
||||
(b.callSymbol "try" [
|
||||
(b.callSymbol "read" [(b.symbol "nextLineStream")])
|
||||
// optional arguments may not be present:
|
||||
(b.callSymbol "catch" [(b.list [(b.symbol "e")]) (b.callSymbol "b.symbol" [(b.str "null")])])
|
||||
])))))))
|
||||
(#unless subclass (method ,nameAndType ,argList ,@body))
|
||||
}))
|
||||
|
||||
|
Reference in New Issue
Block a user