Skip to content

Commit

Permalink
Fit code blocks on the same page
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Jul 10, 2023
1 parent c67ab7f commit 993c978
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
Binary file modified docs/TinyExpr++ReferenceManual.pdf
Binary file not shown.
10 changes: 10 additions & 0 deletions docs/manual/22-Examples.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ int main(int argc, char *argv[])
}
```
\newpage
## Example 2: Binding Custom Variables
```cpp
Expand Down Expand Up @@ -66,6 +68,8 @@ int main(int argc, char* argv[])
}
```

\newpage

## Example 3: Calling a Free Function

```cpp
Expand Down Expand Up @@ -106,6 +110,8 @@ int main(int argc, char *argv[])
}
```
\newpage
## Example 4: Non-US Formatted Formulas
```cpp
Expand Down Expand Up @@ -152,6 +158,8 @@ int main(int argc, char *argv[])
}
```

\newpage

## Example 5: Binding to Custom Classes

A class derived from `te_expr` can be bound to custom functions. This enables you to
Expand Down Expand Up @@ -192,6 +200,7 @@ double cell_max(const te_expr* context)
Finally, create an instance of the class and connect the custom functions to it,
while also adding them to the parser:

::: {.minipage data-latex="{\textwidth}"}
```cpp
te_expr_array teArray{ TE_DEFAULT };

Expand All @@ -211,3 +220,4 @@ auto result = tep.evaluate("SUM(CELL 0, CELL 1, CELL 2, CELL 3, CELL 4)");
// (will be 8).
res = tep.evaluate("CellMax()");
```
:::
22 changes: 7 additions & 15 deletions docs/manual/24-NonUSFormulas.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,21 @@ int main(int argc, char *argv[])
/* After setting your locale to German, functions like strtod() will fail
with values like "3.14" because it expects "3,14" instead.
To fix this, we will tell the parser to use "," as the decimal separator
and ";" as list argument separator.*/

const char *expression = "pow(2,2; 2)"; // instead of "pow(2.2, 2)"
and ";" as the list argument separator.*/
const char* expression = "pow(2,2; 2)"; // instead of "pow(2.2, 2)"
std::cout << "Evaluating:\n\t" << expression << "\n";

te_parser tep;
tep.set_decimal_separator(',');
tep.set_list_separator(';');

/* This will compile the expression and check for errors. */
auto r = tep.evaluate(expression);
const auto result = tep.evaluate(expression);

if (tep.success())
{ std::cout << "Result:\n\t" << result << "\n"; }
else /* Show the user where the error is at. */
{
const double r = tep.evaluate(expression);
std::cout << "Result:\n\t" << r << "\n";
}
else
{
/* Show the user where the error is at. */
std::cout << "\t " << std::setfill(' ') <<
std::setw(tep.get_last_error_position()) << '^' <<
"\tError near here\n";
std::setw(tep.get_last_error_position()) << "^\tError here\n";
}

return EXIT_SUCCESS;
Expand All @@ -54,4 +46,4 @@ This produces the output:
$ Evaluating:
pow(2,2; 2)
Result:
4,840000
4,840000

0 comments on commit 993c978

Please sign in to comment.