KCL: Comparison operators (#4025)

Add `==, !=, >, >=, <, <=` to the language parser, executor and tests.

Closes https://github.com/KittyCAD/modeling-app/issues/4020

Currently these comparison operators are associative, allowing users to chain them, e.g. (x <= y <= z). This should not be allowed, will do in a follow-up. See https://github.com/KittyCAD/modeling-app/issues/4155
This commit is contained in:
Adam Chalmers
2024-10-14 10:46:39 -07:00
committed by GitHub
parent 3382b66075
commit 1d3ade114f
10 changed files with 573 additions and 2 deletions

View File

@ -83520,6 +83520,48 @@
"enum": [
"^"
]
},
{
"description": "Are two numbers equal?",
"type": "string",
"enum": [
"=="
]
},
{
"description": "Are two numbers not equal?",
"type": "string",
"enum": [
"!="
]
},
{
"description": "Is left greater than right",
"type": "string",
"enum": [
">"
]
},
{
"description": "Is left greater than or equal to right",
"type": "string",
"enum": [
">="
]
},
{
"description": "Is left less than right",
"type": "string",
"enum": [
"<"
]
},
{
"description": "Is left less than or equal to right",
"type": "string",
"enum": [
"<="
]
}
]
},
@ -87076,6 +87118,48 @@
"enum": [
"^"
]
},
{
"description": "Are two numbers equal?",
"type": "string",
"enum": [
"=="
]
},
{
"description": "Are two numbers not equal?",
"type": "string",
"enum": [
"!="
]
},
{
"description": "Is left greater than right",
"type": "string",
"enum": [
">"
]
},
{
"description": "Is left greater than or equal to right",
"type": "string",
"enum": [
">="
]
},
{
"description": "Is left less than right",
"type": "string",
"enum": [
"<"
]
},
{
"description": "Is left less than or equal to right",
"type": "string",
"enum": [
"<="
]
}
]
},
@ -90636,6 +90720,48 @@
"enum": [
"^"
]
},
{
"description": "Are two numbers equal?",
"type": "string",
"enum": [
"=="
]
},
{
"description": "Are two numbers not equal?",
"type": "string",
"enum": [
"!="
]
},
{
"description": "Is left greater than right",
"type": "string",
"enum": [
">"
]
},
{
"description": "Is left greater than or equal to right",
"type": "string",
"enum": [
">="
]
},
{
"description": "Is left less than right",
"type": "string",
"enum": [
"<"
]
},
{
"description": "Is left less than or equal to right",
"type": "string",
"enum": [
"<="
]
}
]
},
@ -115048,6 +115174,48 @@
"enum": [
"^"
]
},
{
"description": "Are two numbers equal?",
"type": "string",
"enum": [
"=="
]
},
{
"description": "Are two numbers not equal?",
"type": "string",
"enum": [
"!="
]
},
{
"description": "Is left greater than right",
"type": "string",
"enum": [
">"
]
},
{
"description": "Is left greater than or equal to right",
"type": "string",
"enum": [
">="
]
},
{
"description": "Is left less than right",
"type": "string",
"enum": [
"<"
]
},
{
"description": "Is left less than or equal to right",
"type": "string",
"enum": [
"<="
]
}
]
},
@ -118997,6 +119165,48 @@
"enum": [
"^"
]
},
{
"description": "Are two numbers equal?",
"type": "string",
"enum": [
"=="
]
},
{
"description": "Are two numbers not equal?",
"type": "string",
"enum": [
"!="
]
},
{
"description": "Is left greater than right",
"type": "string",
"enum": [
">"
]
},
{
"description": "Is left greater than or equal to right",
"type": "string",
"enum": [
">="
]
},
{
"description": "Is left less than right",
"type": "string",
"enum": [
"<"
]
},
{
"description": "Is left less than or equal to right",
"type": "string",
"enum": [
"<="
]
}
]
},
@ -122553,6 +122763,48 @@
"enum": [
"^"
]
},
{
"description": "Are two numbers equal?",
"type": "string",
"enum": [
"=="
]
},
{
"description": "Are two numbers not equal?",
"type": "string",
"enum": [
"!="
]
},
{
"description": "Is left greater than right",
"type": "string",
"enum": [
">"
]
},
{
"description": "Is left greater than or equal to right",
"type": "string",
"enum": [
">="
]
},
{
"description": "Is left less than right",
"type": "string",
"enum": [
"<"
]
},
{
"description": "Is left less than or equal to right",
"type": "string",
"enum": [
"<="
]
}
]
},
@ -126107,6 +126359,48 @@
"enum": [
"^"
]
},
{
"description": "Are two numbers equal?",
"type": "string",
"enum": [
"=="
]
},
{
"description": "Are two numbers not equal?",
"type": "string",
"enum": [
"!="
]
},
{
"description": "Is left greater than right",
"type": "string",
"enum": [
">"
]
},
{
"description": "Is left greater than or equal to right",
"type": "string",
"enum": [
">="
]
},
{
"description": "Is left less than right",
"type": "string",
"enum": [
"<"
]
},
{
"description": "Is left less than or equal to right",
"type": "string",
"enum": [
"<="
]
}
]
},

View File

@ -82,6 +82,78 @@ Raise a number to a power.
----
Are two numbers equal?
**enum:** `==`
----
Are two numbers not equal?
**enum:** `!=`
----
Is left greater than right
**enum:** `>`
----
Is left greater than or equal to right
**enum:** `>=`
----
Is left less than right
**enum:** `<`
----
Is left less than or equal to right
**enum:** `<=`
----