language: prelude and internal functions, and varargs support

This commit is contained in:
2023-09-10 19:27:59 -04:00
parent 1cfb197a7f
commit e8c984f2dc
24 changed files with 166 additions and 104 deletions

View File

@ -117,6 +117,12 @@ types:
type: Symbol
- name: arguments
type: List<Expression>
ArgumentSpec:
values:
- name: symbol
type: Symbol
- name: multiple
type: Boolean
FunctionDefinition:
parent: Definition
values:
@ -125,7 +131,7 @@ types:
- name: symbol
type: Symbol
- name: arguments
type: List<Symbol>
type: List<ArgumentSpec>
- name: block
type: Block?
- name: native

View File

@ -14,6 +14,7 @@ digraph A {
type_InfixOperation [shape=box,label="InfixOperation"]
type_BooleanLiteral [shape=box,label="BooleanLiteral"]
type_FunctionCall [shape=box,label="FunctionCall"]
type_ArgumentSpec [shape=box,label="ArgumentSpec"]
type_FunctionDefinition [shape=box,label="FunctionDefinition"]
type_If [shape=box,label="If"]
type_ImportDeclaration [shape=box,label="ImportDeclaration"]
@ -70,8 +71,10 @@ digraph A {
type_InfixOperation -> type_InfixOperator [style=dotted]
type_FunctionCall -> type_Symbol [style=dotted]
type_FunctionCall -> type_Expression [style=dotted]
type_ArgumentSpec -> type_Symbol [style=dotted]
type_FunctionDefinition -> type_DefinitionModifiers [style=dotted]
type_FunctionDefinition -> type_Symbol [style=dotted]
type_FunctionDefinition -> type_ArgumentSpec [style=dotted]
type_FunctionDefinition -> type_Block [style=dotted]
type_FunctionDefinition -> type_Native [style=dotted]
type_If -> type_Expression [style=dotted]

View File

@ -0,0 +1,9 @@
// GENERATED CODE FROM PORK AST CODEGEN
package gay.pizza.pork.ast
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("argumentSpec")
class ArgumentSpec(var symbol: Symbol, var multiple: Boolean)

View File

@ -6,11 +6,11 @@ import kotlinx.serialization.Serializable
@Serializable
@SerialName("functionDefinition")
class FunctionDefinition(override val modifiers: DefinitionModifiers, override val symbol: Symbol, val arguments: List<Symbol>, val block: Block?, val native: Native?) : Definition() {
class FunctionDefinition(override val modifiers: DefinitionModifiers, override val symbol: Symbol, val arguments: List<ArgumentSpec>, val block: Block?, val native: Native?) : Definition() {
override val type: NodeType = NodeType.FunctionDefinition
override fun <T> visitChildren(visitor: NodeVisitor<T>): List<T> =
visitor.visitAll(listOf(symbol), arguments, listOf(block), listOf(native))
visitor.visitAll(listOf(symbol), listOf(block), listOf(native))
override fun <T> visit(visitor: NodeVisitor<T>): T =
visitor.visitFunctionDefinition(this)