diff --git a/src/Samples/Kaleidoscope/.editorconfig b/src/Samples/Kaleidoscope/.editorconfig index fba5099f7..b06558a7e 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 2741479bd..17538a745 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 7f12c5079..d882ec728 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)