Add precedences to operators in docs
This commit is contained in:
parent
1e5b0bda22
commit
a51680da08
51
README.md
51
README.md
@ -11,23 +11,44 @@ Evalexpr is a powerful arithmetic and boolean expression evaluator.
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
### Operators
|
||||||
|
|
||||||
Supported binary operators:
|
Supported binary operators:
|
||||||
|
|
||||||
| Operator | Description |
|
| Operator | Precedence | Description | | Operator | Precedence | Description |
|
||||||
|----------|-------------|
|
|----------|------------|-------------|---|----------|------------|-------------|
|
||||||
| + | Sum |
|
| + | 95 | Sum | | < | 80 | Lower than |
|
||||||
| - | Difference |
|
| - | 95 | Difference | | \> | 80 | Greater than |
|
||||||
| * | Product |
|
| * | 100 | Product | | <= | 80 | Lower than or equal |
|
||||||
| / | Division |
|
| / | 100 | Division | | \>= | 80 | Greater than or equal |
|
||||||
| % | Modulo |
|
| % | 100 | Modulo | | == | 80 | Equal |
|
||||||
| < | Lower than |
|
| && | 75 | Logical and | | != | 80 | Not equal |
|
||||||
| \> | Greater than |
|
| || | 70 | Logical or | | | |
|
||||||
| <= | Lower than or equal |
|
|
||||||
| \>= | Greater than or equal |
|
Supported unary operators:
|
||||||
| == | Equal |
|
|
||||||
| != | Not equal |
|
| Operator | Precedence | Description |
|
||||||
| && | Logical and |
|
|----------|------------|-------------|
|
||||||
| || | Logical or |
|
| - | 110 | Negation |
|
||||||
|
| ! | 110 | Logical not |
|
||||||
|
|
||||||
|
### Values
|
||||||
|
|
||||||
|
Operators take values as arguments and produce values as results.
|
||||||
|
Values can be boolean, integer or floating point numbers.
|
||||||
|
Strings are supported as well, but there are no operations defined for them yet.
|
||||||
|
|
||||||
|
Integers are internally represented as `i64`, and floating point numbers are represented as `f64`.
|
||||||
|
Operators that take numbers as arguments can either take integers or floating point numbers.
|
||||||
|
If one of the arguments is a floating point number, all others are converted to floating point numbers as well, and the resulting value is a floating point number as well.
|
||||||
|
Otherwise, the result is an integer.
|
||||||
|
|
||||||
|
### Variables
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Supported binary operators: `!` `!=` `""` `''` `()` `[]` `,` `>` `<` `>=` `<=` `==`
|
Supported binary operators: `!` `!=` `""` `''` `()` `[]` `,` `>` `<` `>=` `<=` `==`
|
||||||
`+` unary/binary `-` `*` `/` `%` `&&` `||` `n..m`.
|
`+` unary/binary `-` `*` `/` `%` `&&` `||` `n..m`.
|
||||||
|
51
src/lib.rs
51
src/lib.rs
@ -1,23 +1,44 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Features
|
//! ## Features
|
||||||
//!
|
//!
|
||||||
|
//! ### Operators
|
||||||
|
//!
|
||||||
//! Supported binary operators:
|
//! Supported binary operators:
|
||||||
//!
|
//!
|
||||||
//! | Operator | Description |
|
//! | Operator | Precedence | Description | | Operator | Precedence | Description |
|
||||||
//! |----------|-------------|
|
//! |----------|------------|-------------|---|----------|------------|-------------|
|
||||||
//! | + | Sum |
|
//! | + | 95 | Sum | | < | 80 | Lower than |
|
||||||
//! | - | Difference |
|
//! | - | 95 | Difference | | \> | 80 | Greater than |
|
||||||
//! | * | Product |
|
//! | * | 100 | Product | | <= | 80 | Lower than or equal |
|
||||||
//! | / | Division |
|
//! | / | 100 | Division | | \>= | 80 | Greater than or equal |
|
||||||
//! | % | Modulo |
|
//! | % | 100 | Modulo | | == | 80 | Equal |
|
||||||
//! | < | Lower than |
|
//! | && | 75 | Logical and | | != | 80 | Not equal |
|
||||||
//! | > | Greater than |
|
//! | || | 70 | Logical or | | | |
|
||||||
//! | <= | Lower than or equal |
|
//!
|
||||||
//! | >= | Greater than or equal |
|
//! Supported unary operators:
|
||||||
//! | == | Equal |
|
//!
|
||||||
//! | != | Not equal |
|
//! | Operator | Precedence | Description |
|
||||||
//! | && | Logical and |
|
//! |----------|------------|-------------|
|
||||||
//! | || | Logical or |
|
//! | - | 110 | Negation |
|
||||||
|
//! | ! | 110 | Logical not |
|
||||||
|
//!
|
||||||
|
//! ### Values
|
||||||
|
//!
|
||||||
|
//! Operators take values as arguments and produce values as results.
|
||||||
|
//! Values can be boolean, integer or floating point numbers.
|
||||||
|
//! Strings are supported as well, but there are no operations defined for them yet.
|
||||||
|
//!
|
||||||
|
//! Integers are internally represented as `i64`, and floating point numbers are represented as `f64`.
|
||||||
|
//! Operators that take numbers as arguments can either take integers or floating point numbers.
|
||||||
|
//! If one of the arguments is a floating point number, all others are converted to floating point numbers as well, and the resulting value is a floating point number as well.
|
||||||
|
//! Otherwise, the result is an integer.
|
||||||
|
//!
|
||||||
|
//! ### Variables
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
//!
|
||||||
//!
|
//!
|
||||||
//!Supported binary operators: `!` `!=` `""` `''` `()` `[]` `,` `>` `<` `>=` `<=` `==`
|
//!Supported binary operators: `!` `!=` `""` `''` `()` `[]` `,` `>` `<` `>=` `<=` `==`
|
||||||
//!`+` unary/binary `-` `*` `/` `%` `&&` `||` `n..m`.
|
//!`+` unary/binary `-` `*` `/` `%` `&&` `||` `n..m`.
|
||||||
|
Loading…
Reference in New Issue
Block a user