From 3b07cef209494be2a7eeb139525c0d5019adf85d Mon Sep 17 00:00:00 2001 From: Jesse Brault Date: Wed, 3 Sep 2025 17:05:15 -0500 Subject: [PATCH] Basic function types. --- src/parser/ast.yaml | 44 ++++++++++++++++++++++++++++++++++++++---- src/parser/deimos.pest | 16 +++------------ 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/parser/ast.yaml b/src/parser/ast.yaml index 5d34c8e..938d738 100644 --- a/src/parser/ast.yaml +++ b/src/parser/ast.yaml @@ -150,15 +150,51 @@ Function: build: type: boolean on: rule_present - - modifier: - rule: Modifier - build: FunctionModifier - fn_kw: rule: Fn skip: true - generics: rule: GenericParameters + optional: true + - identifier + - parameters + - return_type: + optional: true + - function_body +OperatorFunction: + children: + - is_public: + rule: Pub + build: + type: boolean + on: rule_present + - op_kw: + rule: Op + skip: true + - generics: + rule: GenericParameters + optional: true + - operator + - parameters + - return_type: + optional: true + - function_body +PlatformFunction: + children: + - is_public: + rule: Pub + build: + type: boolean + on: rule_present + - platform_kw: + rule: Platform + skip: true + - fn_kw: + rule: Fn + skip: true + - generics: + rule: GenericParameters + optional: true - identifier - parameters - return_type - - function_body diff --git a/src/parser/deimos.pest b/src/parser/deimos.pest index c8ead30..6b2012e 100644 --- a/src/parser/deimos.pest +++ b/src/parser/deimos.pest @@ -427,9 +427,8 @@ Class = { // Function constructs -FunctionDefinition = { +Function = { Pub? - ~ FunctionModifier? ~ Fn ~ GenericParameters? ~ Identifier @@ -438,9 +437,8 @@ FunctionDefinition = { ~ FunctionBody } -OperatorFunctionDefinition = { +OperatorFunction = { Pub? - ~ FunctionModifier? ~ Op ~ GenericParameters? ~ Operator @@ -451,14 +449,12 @@ OperatorFunctionDefinition = { PlatformFunction = { Pub? - ~ FunctionModifier? ~ Platform ~ Fn ~ GenericParameters? ~ Identifier ~ Parameters ~ ReturnType - ~ ";" } InterfaceFunction = { @@ -501,13 +497,7 @@ InterfaceDefaultOperatorFunction = { ~ FunctionBody } -FunctionModifier = { - Static - | Cons - | Mut ~ Ref - | Mut - | Ref -} +// Function Components FunctionBody = { FunctionAliasBody