ffi: new native function format

This commit is contained in:
2023-09-22 00:26:24 -07:00
parent f60715dfb3
commit 83c24843a3
14 changed files with 75 additions and 57 deletions

View File

@ -308,8 +308,11 @@ class Parser(source: TokenSource, attribution: NodeAttribution) :
override fun parseNative(): Native = guarded(NodeType.Native) {
expect(TokenType.Native)
val form = parseSymbol()
val definition = parseStringLiteral()
Native(form, definition)
val definitions = mutableListOf<StringLiteral>()
while (peek(TokenType.StringLiteral)) {
definitions.add(parseStringLiteral())
}
Native(form, definitions)
}
override fun parseNoneLiteral(): NoneLiteral = guarded(NodeType.NoneLiteral) {

View File

@ -82,7 +82,12 @@ class Printer(buffer: StringBuilder) : NodeVisitor<Unit> {
append("native ")
visit(node.form)
append(" ")
visit(node.definition)
for ((index, argument) in node.definitions.withIndex()) {
visit(argument)
if (index + 1 != node.definitions.size) {
append(" ")
}
}
}
override fun visitNoneLiteral(node: NoneLiteral) {