diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-05-29 10:36:42 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-05-29 10:36:42 +0100 |
| commit | 9e6149639b0020687e80fa6b1ac53205e6d6bc75 (patch) | |
| tree | f3449fc94242f80895b7b7ce488816fe5db6a4dc | |
| parent | 4760a565652e49e4e929396ee08bd3296c482e3e (diff) | |
Add hobgoblin definitions for untyped nodes
| -rw-r--r-- | hobgoblin/hobgoblin.json5 | 24 | ||||
| -rw-r--r-- | hobgoblin/src/hobgoblin/untyped.hob | 67 | ||||
| -rw-r--r-- | makefile | 5 |
3 files changed, 96 insertions, 0 deletions
diff --git a/hobgoblin/hobgoblin.json5 b/hobgoblin/hobgoblin.json5 new file mode 100644 index 0000000..139c070 --- /dev/null +++ b/hobgoblin/hobgoblin.json5 @@ -0,0 +1,24 @@ +{ + outputs: [ + { + generator: "java-types", + path: "../src/main/java", + packageName: "org.zwobble.hobgoblin.compiler.ast.untyped", + nativeTypes: [ + { + // TODO: should be hobgoblin/untyped.Source ? + hobgoblin: "hobgoblin.untyped.Source", + java: "org.zwobble.hobgoblin.compiler.sources.Source", + }, + { + hobgoblin: "hobgoblin.untyped.NamespaceName", + java: "org.zwobble.hobgoblin.compiler.types.NamespaceName", + }, + { + hobgoblin: "hobgoblin.untyped.DocComment", + java: "org.zwobble.hobgoblin.compiler.ast.DocComment", + } + ], + }, + ], +} diff --git a/hobgoblin/src/hobgoblin/untyped.hob b/hobgoblin/src/hobgoblin/untyped.hob new file mode 100644 index 0000000..31ba4f2 --- /dev/null +++ b/hobgoblin/src/hobgoblin/untyped.hob @@ -0,0 +1,67 @@ +native Source { +} + +native NamespaceName { +} + +native DocComment { +} + +struct UntypedNamespaceNode { + field namespaceName: NamespaceName; + field body: List[UntypedNamespaceStatementNode]; + field source: Source; +} + +sum UntypedNamespaceStatementNode { + variant UntypedNativeTypeDefinitionNode; + variant UntypedStructDefinitionNode; + variant UntypedSumDefinitionNode; +} + +struct UntypedNativeTypeDefinitionNode { + field name: String; + field docComment: DocComment; + field source: Source; +} + +struct UntypedStructDefinitionNode { + field name: String; + field fields: List[UntypedStructFieldDefinitionNode]; + field docComment: DocComment; + field source: Source; +} + +struct UntypedStructFieldDefinitionNode { + field name: String; + field type: UntypedTypeLevelExpressionNode; + field source: Source; +} + +struct UntypedSumDefinitionNode { + field name: String; + field variants: List[UntypedSumVariantDefinitionNode]; + field docComment: DocComment; + field source: Source; +} + +struct UntypedSumVariantDefinitionNode { + field type: UntypedTypeLevelExpressionNode; + field source: Source; +} + +sum UntypedTypeLevelExpressionNode { + variant UntypedConstructedTypeNode; + variant UntypedTypeLevelReferenceNode; +} + +struct UntypedConstructedTypeNode { + field receiver: UntypedTypeLevelExpressionNode; + field args: List[UntypedTypeLevelExpressionNode]; + field source: Source; +} + +struct UntypedTypeLevelReferenceNode { + field name: String; + field source: Source; +} @@ -2,3 +2,8 @@ package: mvn package -Dmaven.test.skip=true + +.PHONY: codegen + +codegen: package + java -jar target/hobgoblin-0.1.0.jar compile hobgoblin |
