work on manual
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 6 May 2025 15:25:57 +0000 (08:25 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 6 May 2025 15:25:57 +0000 (08:25 -0700)
rust/doc/src/SUMMARY.md
rust/doc/src/language/expressions/arithmetic.md [new file with mode: 0644]
rust/doc/src/language/expressions/boolean-values.md [new file with mode: 0644]
rust/doc/src/language/expressions/grouping.md [new file with mode: 0644]
rust/doc/src/language/expressions/index.md [new file with mode: 0644]
rust/doc/src/language/expressions/missing-values.md [new file with mode: 0644]

index d2b7594fc9c3d41cb87691a00a6fb5ab939b94da..a4071ce82d0763ced786f83ccd45533cc213c684 100644 (file)
 - [Files Used by PSPP](language/files/index.md)
   - [File Handles](language/files/file-handles.md)
 - [Syntax Diagrams](language/syntax-diagrams.md)
+- [Expressions](language/expressions/index.md)
+  - [Boolean Values](language/expressions/boolean-values.md)
+  - [Missing Values in Expressions](language/expressions/missing-values.md)
+  - [Grouping Operators](language/expressions/grouping.md)
+  - [Arithmetic Operators](language/expressions/arithmetic.md)
 
 # Developer Documentation
 
diff --git a/rust/doc/src/language/expressions/arithmetic.md b/rust/doc/src/language/expressions/arithmetic.md
new file mode 100644 (file)
index 0000000..1f4db7d
--- /dev/null
@@ -0,0 +1,27 @@
+# Arithmetic Operators
+
+The arithmetic operators take numeric operands and produce numeric
+results.
+
+* `A + B`  
+  The sum of `A` and `B`.
+
+* `A - B`  
+  The difference when `B` is subtracted from `A`.
+
+* `A * B`  
+  The product of `A` and `B`.  If either `A` or `B` is 0, then the result is
+  0, even if the other operand is missing.
+
+* `A / B`  
+  The quotient of `A` divided by `B`.  If `A` is 0, then the result is 0,
+  even if `B` is missing.  If `B` is zero, the result is system-missing.
+
+* `A ** B`  
+  Yields the result of raising `A` to the power `B`.  If `A` is
+  negative and `B` is not an integer, the result is system-missing.
+  `0**0` is also system-missing.
+
+* `- A`  
+  Reverses the sign of `A`.
+
diff --git a/rust/doc/src/language/expressions/boolean-values.md b/rust/doc/src/language/expressions/boolean-values.md
new file mode 100644 (file)
index 0000000..11cf592
--- /dev/null
@@ -0,0 +1,14 @@
+# Boolean Values
+
+Some PSPP operators and expressions work with Boolean values, which
+represent true/false conditions.  Booleans have only three possible
+values: 0 (false), 1 (true), and system-missing (unknown).
+System-missing is neither true nor false and indicates that the true
+value is unknown.
+
+   Boolean-typed operands or function arguments must take on one of
+these three values.  Other values are considered false, but provoke a
+warning when the expression is evaluated.
+
+   Strings and Booleans are not compatible, and neither may be used in
+place of the other.
diff --git a/rust/doc/src/language/expressions/grouping.md b/rust/doc/src/language/expressions/grouping.md
new file mode 100644 (file)
index 0000000..c777321
--- /dev/null
@@ -0,0 +1,8 @@
+# Grouping Operators
+
+Parentheses (`()`) are the grouping operators.  Surround an expression
+with parentheses to force early evaluation.
+
+   Parentheses also surround the arguments to functions, but in that
+situation they act as punctuators, not as operators.
+
diff --git a/rust/doc/src/language/expressions/index.md b/rust/doc/src/language/expressions/index.md
new file mode 100644 (file)
index 0000000..e764aca
--- /dev/null
@@ -0,0 +1,12 @@
+# Mathematical Expressions
+
+Expressions share a common syntax each place they appear in PSPP
+commands.  Expressions are made up of "operands", which can be numbers,
+strings, or variable names, separated by "operators".  There are five
+types of operators: grouping, arithmetic, logical, relational, and
+functions.
+
+   Every operator takes one or more operands as input and yields exactly
+one result as output.  Depending on the operator, operands accept
+strings or numbers as operands.  With few exceptions, operands may be
+full-fledged expressions in themselves.
diff --git a/rust/doc/src/language/expressions/missing-values.md b/rust/doc/src/language/expressions/missing-values.md
new file mode 100644 (file)
index 0000000..6830e40
--- /dev/null
@@ -0,0 +1,17 @@
+# Missing Values in Expressions
+
+Most numeric operators yield system-missing when given any
+system-missing operand.  A string operator given any system-missing
+operand typically results in the empty string.  Exceptions are listed
+under particular operator descriptions.
+
+   String user-missing values are not treated specially in expressions.
+
+   User-missing values for numeric variables are always transformed into
+the system-missing value, except inside the arguments to the `VALUE` and
+`SYSMIS` functions.
+
+   The missing-value functions can be used to precisely control how
+missing values are treated in expressions.  *Note Missing Value
+Functions::, for more details.
+