value_expr/
lib.rs

1//! Value Expr
2//!
3//! ## DSL
4//!
5//! ```dsl
6//! Value:
7//!     i32
8//!     | Unary
9//!     | Binary
10//!     | Assign
11//!     | Paren
12//!     | FuncLike
13//!     | Ident
14//! Unary:
15//!     - Value
16//!     | ! Value
17//! Binary:
18//!     Value + Value
19//!     | Value - Value
20//!     | Value * Value
21//!     | Value / Value
22//!     | Value % Value
23//!     | Value ^ Value
24//!     | Value & Value
25//!     | Value | Value
26//!     | Value << Value
27//!     | Value >> Value
28//!     | Value == Value
29//!     | Value != Value
30//!     | Value > Value
31//!     | Value < Value
32//!     | Value >= Value
33//!     | Value <= Value
34//!     | Value && Value
35//!     | Value || Value
36//! Assign:
37//!     Ident = Value
38//!     | Ident += Value
39//!     | Ident -= Value
40//!     | Ident *= Value
41//!     | Ident /= Value
42//!     | Ident %= Value
43//!     | Ident ^= Value
44//!     | Ident &= Value
45//!     | Ident |= Value
46//!     | Ident <<= Value
47//!     | Ident >>= Value
48//! Paren:
49//!     ( Values )
50//! FuncLike:
51//!     Ident ( Values )
52//! Values:
53//!     <nothing>
54//!     | ValuesNext
55//! ValuesNext:
56//!     Value
57//!     | Value , ValuesNext
58//! Ident:
59//!     <the rust lang ident>
60//! ```
61//!
62//! ## Binary
63//!
64//! Here is the precedence of binary operators, going from strong to weak.
65//! Operators at the same precedence level are all left-associative.
66//!
67//! If you're unsure about operator precedence, use parentheses to explicitly enforce the desired evaluation order.
68//!
69//! When mixing numerical and logical operations, any numeric value not 0 is considered true, otherwise false.
70//! The logical value true corresponds to 1 numerically, while false corresponds to 0.
71//!
72//! | Operator | Remark |
73//! | -------- | ------- |
74//! | `*` `/` `%` | arithmetic |
75//! | `+` `-` | arithmetic |
76//! | `<<` `>>` | bit shift |
77//! | `&` | bit and|
78//! | `^` | bit xor |
79//! | `\|` | bit or |
80//! | `==` `!=` `>` `<` `>=` `<=` | compare |
81//! | `&&` | logical and |
82//! | `\|\|` | logical or |
83//!
84//! ## Assign
85//!
86//! Assign Operators all right-associative.
87//!
88//! ## FuncLike
89//!
90//! FuncLike, a function-like object, is similar to a function in that it takes multiple parameters.
91//!
92//! The difference is that it allows lazy evaluation, enabling you to freely control the order of evaluation.
93//!
94
95mod context;
96mod data;
97mod parser;
98mod valuer;
99
100pub use context::ContextHelper;
101pub use data::{AssignOp, BinOp, UnOp, Value};
102pub use valuer::{Context, Valued};