From 2eae050a66bbc53fe5717f6a381229583cdbb2e7 Mon Sep 17 00:00:00 2001 From: Steven Maillet Date: Thu, 13 Nov 2025 14:51:38 -0800 Subject: [PATCH] Minor misc. updates * clarified doc comments. * corrected typos in comments * update test sample `mandel.kls` to include comments added to the sample assembly --- src/Samples/Kaleidoscope/.editorconfig | 2 +- .../KaleidoscopeUserOperatorListener.cs | 5 +++-- src/Samples/Kaleidoscope/mandel.kls | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Samples/Kaleidoscope/.editorconfig b/src/Samples/Kaleidoscope/.editorconfig index fba5099f79..b06558a7ea 100644 --- a/src/Samples/Kaleidoscope/.editorconfig +++ b/src/Samples/Kaleidoscope/.editorconfig @@ -4,7 +4,7 @@ vsspell_section_id = 1566b770c5af48b08aa5b43b10ffef28 vsspell_ignored_words_1566b770c5af48b08aa5b43b10ffef28 = File:IgnoredWords.dic|def [*.kls] -# VSSPELL: DIsable everything for the sample languages +# VSSPELL: Disable everything for the sample languages vsspell_section_id = 257c51e4a39d462090397bebd5922176 vsspell_spell_check_as_you_type = false vsspell_include_in_project_spell_check = false diff --git a/src/Samples/Kaleidoscope/Kaleidoscope.Grammar/KaleidoscopeUserOperatorListener.cs b/src/Samples/Kaleidoscope/Kaleidoscope.Grammar/KaleidoscopeUserOperatorListener.cs index 2741479bd0..17538a745e 100644 --- a/src/Samples/Kaleidoscope/Kaleidoscope.Grammar/KaleidoscopeUserOperatorListener.cs +++ b/src/Samples/Kaleidoscope/Kaleidoscope.Grammar/KaleidoscopeUserOperatorListener.cs @@ -19,8 +19,9 @@ public KaleidoscopeUserOperatorListener( DynamicRuntimeState state ) /// Handles successfully parsed function definitions /// Context parse node for the parsed function /// - /// Upon successful parse of a function definition this check if it is a user defined operator - /// and updates the RuntimeState accordingly, if it is. + /// Upon successful parse of a function definition this checks if it is a user defined operator + /// and updates the RuntimeState accordingly, if it is. This is used for support of user defined + /// operators providing user defined precedence. /// public override void ExitFunctionDefinition( KaleidoscopeParser.FunctionDefinitionContext context ) { diff --git a/src/Samples/Kaleidoscope/mandel.kls b/src/Samples/Kaleidoscope/mandel.kls index 7f12c50799..d882ec7286 100644 --- a/src/Samples/Kaleidoscope/mandel.kls +++ b/src/Samples/Kaleidoscope/mandel.kls @@ -1,15 +1,19 @@ +# unary operator to perform a logical NOT def unary!(v) if v then 0 else 1; +# unary operator to perform a mathematical negation def unary-(v) 0-v; +# Comparison operator def binary> 10 (LHS RHS) RHS < LHS; +# Logical OR operator def binary| 5 (LHS RHS) if LHS then 1 @@ -18,17 +22,21 @@ def binary| 5 (LHS RHS) else 0; +# Logical AND operator def binary& 6 (LHS RHS) if !LHS then 0 else !!RHS; +# arithmatic equality test def binary== 9 (LHS RHS) !(LHS < RHS | LHS > RHS); +# selector operator def binary : 1 (x y) y; +# declare access to built-in function extern putchard(char); def printdensity(d)