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