Pest and ast syntax changes.
This commit is contained in:
parent
e79c22db72
commit
4dcb5ee783
5
sketching/september_2025/adder/adder.dm
Normal file
5
sketching/september_2025/adder/adder.dm
Normal file
@ -0,0 +1,5 @@
|
||||
use math::add
|
||||
|
||||
fn main()
|
||||
println add(1, 2) // 3
|
||||
end
|
3
sketching/september_2025/adder/math/add.dm
Normal file
3
sketching/september_2025/adder/math/add.dm
Normal file
@ -0,0 +1,3 @@
|
||||
mod math
|
||||
|
||||
pub fn add(a: Int, b: Int) = a + b
|
@ -78,12 +78,14 @@ $defs:
|
||||
properties:
|
||||
rule:
|
||||
type: string
|
||||
description: The type to build, in Pascal case.
|
||||
optional:
|
||||
type: boolean
|
||||
description: If true, this child will be stored as an Option.
|
||||
build:
|
||||
oneOf:
|
||||
- type: string
|
||||
- $ref: "#/$defs/SingleChildBuildDefinition"
|
||||
required:
|
||||
- rule
|
||||
SingleChildBuildDefinition:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
|
@ -1,19 +1,21 @@
|
||||
# $schema: ./ast.schema.yaml
|
||||
# Top-level constructs
|
||||
CompilationUnit:
|
||||
children:
|
||||
- namespace
|
||||
- parent_mod
|
||||
- use_statements:
|
||||
rule: UseStatement
|
||||
vec: true
|
||||
- module_level_declarations:
|
||||
rule: ModuleLevelDeclaration
|
||||
Namespace:
|
||||
vec: true
|
||||
ParentMod:
|
||||
children:
|
||||
- ns_kw:
|
||||
rule: Ns
|
||||
- mod_kw:
|
||||
rule: Mod
|
||||
skip: true
|
||||
- fqn:
|
||||
rule: Fqn
|
||||
rule: FullyQualifiedName
|
||||
UseStatement:
|
||||
children:
|
||||
- use_kw:
|
||||
@ -24,17 +26,49 @@ UseStatement:
|
||||
vec: true
|
||||
- suffix:
|
||||
rule: UseStatementSuffix
|
||||
UseStatementPrefix:
|
||||
children:
|
||||
- identifier
|
||||
UseStatementSuffix:
|
||||
rules:
|
||||
- Identifier
|
||||
- rule: Star
|
||||
build: UseStatementStarSuffix
|
||||
- UseList
|
||||
UseList:
|
||||
children:
|
||||
- identifiers:
|
||||
rule: Identifier
|
||||
vec: true
|
||||
|
||||
# Level declarations
|
||||
ModuleLevelDeclaration:
|
||||
rules:
|
||||
- rule: Module
|
||||
build: ModuleDeclaration
|
||||
- rule: Interface
|
||||
build: InterfaceDeclaration
|
||||
- rule: Class
|
||||
build: ClassDeclaration
|
||||
- FunctionDefinition
|
||||
- Module
|
||||
- Interface
|
||||
- Class
|
||||
- Function
|
||||
- PlatformFunction
|
||||
ModuleDeclaration:
|
||||
InterfaceLevelDeclaration:
|
||||
rules:
|
||||
- CompanionModule
|
||||
- Interface
|
||||
- Class
|
||||
- InterfaceFunction
|
||||
- InterfaceDefaultFunction
|
||||
- InterfaceOperatorFunction
|
||||
- InterfaceDefaultOperatorFunction
|
||||
ClassLevelDeclaration:
|
||||
children:
|
||||
- CompanionModule
|
||||
- Interface
|
||||
- Class
|
||||
- Function
|
||||
- OperatorFunction
|
||||
- PlatformFunction
|
||||
|
||||
# Main organizational constructs
|
||||
Module:
|
||||
children:
|
||||
- is_public:
|
||||
rule: Pub
|
||||
@ -49,7 +83,45 @@ ModuleDeclaration:
|
||||
- declarations:
|
||||
rule: ModuleLevelDeclaration
|
||||
vec: true
|
||||
ClassDeclaration:
|
||||
- end_kw:
|
||||
rule: End
|
||||
skip: true
|
||||
CompanionModule:
|
||||
children:
|
||||
- companion_kw:
|
||||
rule: Companion
|
||||
skip: true
|
||||
- mod_kw:
|
||||
rule: Mod
|
||||
skip: true
|
||||
- declarations:
|
||||
rule: ModuleLevelDeclaration
|
||||
vec: true
|
||||
- end_kw:
|
||||
rule: End
|
||||
skip: true
|
||||
Interface:
|
||||
children:
|
||||
- is_public:
|
||||
rule: Pub
|
||||
build:
|
||||
type: boolean
|
||||
on: rule_present
|
||||
- int_kw:
|
||||
rule: IntKw
|
||||
skip: true
|
||||
- identifier
|
||||
- generic_parameters:
|
||||
optional: true
|
||||
- implements_list:
|
||||
optional: true
|
||||
- declarations:
|
||||
rule: InterfaceLevelDeclaration
|
||||
vec: true
|
||||
- end_kw:
|
||||
rule: End
|
||||
skip: true
|
||||
Class:
|
||||
children:
|
||||
- is_public:
|
||||
rule: Pub
|
||||
@ -60,13 +132,18 @@ ClassDeclaration:
|
||||
rule: ClassKw
|
||||
skip: true
|
||||
- identifier
|
||||
- generic_parameters
|
||||
- class_constructor
|
||||
- implements_list
|
||||
- generic_parameters:
|
||||
optional: true
|
||||
- class_constructor:
|
||||
optional: true
|
||||
- implements_list:
|
||||
optional: true
|
||||
- class_level_declarations:
|
||||
rule: ClassLevelDeclaration
|
||||
vec: true
|
||||
FunctionDeclaration:
|
||||
|
||||
# Function constructs
|
||||
Function:
|
||||
children:
|
||||
- is_public:
|
||||
rule: Pub
|
||||
|
@ -30,6 +30,8 @@ Alias = { "alias" }
|
||||
True = { "true" }
|
||||
False = { "false" }
|
||||
Use = { "use" }
|
||||
End = { "end" }
|
||||
Companion = { "comp" }
|
||||
|
||||
// Keywords: primitive types
|
||||
Byte = { "Byte" }
|
||||
@ -322,22 +324,31 @@ RefList = {
|
||||
|
||||
CompilationUnit = {
|
||||
SOI
|
||||
~ ( Namespace ~ Semicolon )?
|
||||
~ ( UseStatement ~ Semicolon )*
|
||||
~ ModuleLevelDeclaration*
|
||||
~ ParentMod?
|
||||
~ ( UseStatement | ModuleLevelDeclaration )*
|
||||
~ EOI
|
||||
}
|
||||
|
||||
Namespace = {
|
||||
Ns
|
||||
ParentMod = {
|
||||
Mod
|
||||
~ FullyQualifiedName
|
||||
}
|
||||
|
||||
UseStatement = {
|
||||
Use
|
||||
~ Identifier
|
||||
~ ( "::" ~ Identifier )*
|
||||
~ ( "::" ~ ( Star | UseList ) )?
|
||||
~ UseStatementPrefix*
|
||||
~ UseStatementSuffix
|
||||
}
|
||||
|
||||
UseStatementPrefix = {
|
||||
Identifier
|
||||
~ "::"
|
||||
}
|
||||
|
||||
UseStatementSuffix = {
|
||||
Identifier
|
||||
| Star
|
||||
| UseList
|
||||
}
|
||||
|
||||
UseList = {
|
||||
@ -353,12 +364,12 @@ ModuleLevelDeclaration = {
|
||||
Module
|
||||
| Interface
|
||||
| Class
|
||||
| FunctionDefinition
|
||||
| Function
|
||||
| PlatformFunction
|
||||
}
|
||||
|
||||
InterfaceLevelDeclaration = {
|
||||
Module
|
||||
CompanionModule
|
||||
| Interface
|
||||
| Class
|
||||
| InterfaceFunction
|
||||
@ -368,14 +379,12 @@ InterfaceLevelDeclaration = {
|
||||
}
|
||||
|
||||
ClassLevelDeclaration = {
|
||||
Module
|
||||
CompanionModule
|
||||
| Interface
|
||||
| Class
|
||||
| FunctionDefinition
|
||||
| OperatorFunctionDefinition
|
||||
| Function
|
||||
| OperatorFunction
|
||||
| PlatformFunction
|
||||
| Property
|
||||
| Field
|
||||
}
|
||||
|
||||
// Main organizational constructs
|
||||
@ -384,7 +393,15 @@ Module = {
|
||||
Pub?
|
||||
~ Mod
|
||||
~ Identifier
|
||||
~ "{" ~ ModuleLevelDeclaration* ~ "}"
|
||||
~ ModuleLevelDeclaration*
|
||||
~ End
|
||||
}
|
||||
|
||||
CompanionModule = {
|
||||
Companion
|
||||
~ Mod
|
||||
~ ModuleLevelDeclaration*
|
||||
~ End
|
||||
}
|
||||
|
||||
Interface = {
|
||||
@ -393,7 +410,8 @@ Interface = {
|
||||
~ Identifier
|
||||
~ GenericParameters?
|
||||
~ ImplementsList?
|
||||
~ ( "{" ~ InterfaceLevelDeclaration* ~ "}" )?
|
||||
~ InterfaceLevelDeclaration*
|
||||
~ End
|
||||
}
|
||||
|
||||
Class = {
|
||||
@ -403,7 +421,8 @@ Class = {
|
||||
~ GenericParameters?
|
||||
~ ClassConstructor?
|
||||
~ ImplementsList?
|
||||
~ ( "{" ~ ClassLevelDeclaration* ~ "}" )?
|
||||
~ ClassLevelDeclaration*
|
||||
~ End
|
||||
}
|
||||
|
||||
// Function constructs
|
||||
|
Loading…
Reference in New Issue
Block a user