Skip to content

Commit

Permalink
Document data types
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Nov 18, 2023
1 parent 492d818 commit 60aca58
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/manual/custom-extensions.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const auto r = tep.evaluate("mysum(5, 6)");
:::

::: {.minipage data-latex="{\textwidth}"}
## Binding to Custom Classes {#custom-classes .unnumbered}
## Binding to Custom Classes {-#custom-classes}

A class derived from `te_expr` can be bound to custom functions\index{classes!binding to custom}. This enables you to
have full access to an object (via these functions) when parsing an expression.
Expand Down
23 changes: 21 additions & 2 deletions docs/manual/usage.qmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Usage

## Functions & Data Types {-}
## Data Types {-}

The following data types and constants are used throughout *TinyExpr++*:

`te_parser`: The main class for defining an evaluation engine and solving expressions.

`te_type`: The data type for variables, function parameters, and results.
By default this is `double`, but can be `float` when [`TE_FLOAT`](#te-float) is defined.

`te_variable`: A user-defined variable or function that can be embedded into a `te_parser`.
(Refer to [custom variables](#custom-variables).)

`te_expr`: The base class for a compiled expression.
Classes that derive from this can be bound to custom functions. In turn, this allows for
connecting more complex, class-based objects to the parser.
(Refer to [custom classes](#custom-classes).)

`te_parser::te_nan`: An invalid numeric value.
This should be returned from user-defined functions to signal a failed calculation.

Expand All @@ -15,7 +25,14 @@ This should be returned from user-defined functions to signal a failed calculati
`te_usr_noop`: A no-op function. When passed to `te_parser::set_unknown_symbol_resolver()`, will disable unknown symbol resolution.
(Refer to [ch. -@sec-usr].)

*TinyExpr++*'s `te_parser` class defines these functions:
{{< pagebreak >}}

## Functions {-}

The primary interface to *TinyExpr++* is the class `te_parser`. A `te_parser` is a self-contained parser,
which stores its own user-defined variables &amp; functions, separators, and state information.

`te_parser` provides these functions:

```{.cpp}
te_type evaluate(const std::string_view expression); // <1>
Expand Down Expand Up @@ -123,6 +140,8 @@ Along with positional and message information, the return value\index{results!ev
When an evaluation fails, the parser will return NaN (i.e., `std::numeric_limits<te_type>::quiet_NaN()`) as the result.
NaN values can be verified using the standard function `std::isnan()`.

{{< pagebreak >}}

## Example {-}

The following is a short example demonstrating how to use *TinyExpr++*.
Expand Down

0 comments on commit 60aca58

Please sign in to comment.