mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 21:21:33 +00:00
parser: use ast user data to store attribution
This commit is contained in:
@ -8,5 +8,6 @@ import kotlinx.serialization.Serializable
|
||||
@SerialName("definition")
|
||||
sealed class Definition : Node() {
|
||||
abstract val symbol: Symbol
|
||||
|
||||
abstract val modifiers: DefinitionModifiers
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// GENERATED CODE FROM PORK AST CODEGEN
|
||||
package gay.pizza.pork.ast
|
||||
|
||||
import kotlinx.serialization.Transient
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@ -9,6 +10,9 @@ import kotlinx.serialization.Serializable
|
||||
sealed class Node {
|
||||
abstract val type: NodeType
|
||||
|
||||
@Transient
|
||||
var data: Any? = null
|
||||
|
||||
open fun <T> visitChildren(visitor: NodeVisitor<T>): List<T> =
|
||||
emptyList()
|
||||
|
||||
|
6
ast/src/main/kotlin/gay/pizza/pork/ast/NodeExtensions.kt
Normal file
6
ast/src/main/kotlin/gay/pizza/pork/ast/NodeExtensions.kt
Normal file
@ -0,0 +1,6 @@
|
||||
// GENERATED CODE FROM PORK AST CODEGEN
|
||||
package gay.pizza.pork.ast
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <P> Node.data(): P? =
|
||||
data as? P?
|
Reference in New Issue
Block a user