synthphonia/expr/ops/macros.rs
1
2use super::*;
3
4#[macro_export]
5/// Defines a macro that generates a sequence of unary operations for expressions in the synthesis framework.
6///
7/// This macro, when invoked, expands into a list of operation identifiers that correspond to various unary operations applicable within the framework.
8/// These include conversion operations (such as `ToInt`, `ToStr`, and `StrToFloat`), string manipulations (like `Uppercase` and `Lowercase`), and mathematical operations (for example, `Neg`, `IsPos`, and `FAbs`).
9/// Additional operations handle parsing and formatting tasks (`ParseDate`, `FormatMonth`, `ParseFloat`) and manage numeric transformations relevant to float and integer types.
10/// This macro serves as a central registry for unary operations, ensuring they are consistently defined and utilized throughout the synthesis module.
11///
12macro_rules! for_all_op1 {
13 () => {
14 _do!(Len ToInt ToStr Neg IsPos IsZero IsNatural RetainLl RetainLc RetainN RetainL RetainLN Uppercase Lowercase ParseDate AsMonth AsDay AsYear AsWeekDay ParseTime FormatFloat
15 ParseInt
16 FormatInt
17 ParseMonth
18 ParseWeekday
19 FormatTime
20 FormatMonth
21 FormatWeekday
22 FormatFloat
23 ParseFloat
24 FNeg
25 FAbs
26 FIsPos
27 FExp10
28 IntToFloat
29 FloatToInt
30 StrToFloat
31 FNotNeg
32 FIsZero
33 FLen
34 Map
35 Filter
36 BvNot BvNeg);
37 };
38}
39#[macro_export]
40/// Expands to include a sequence of binary (two-operand) operations as part of the `Expr Ops` sub-module.
41///
42/// These operations encompass a wide range of functionalities for string handling, mathematical computations, and date-time manipulations within the synthesis framework.
43/// The macro generates repetitive code structures for each operation defined within its body, listed in a `_do!` macro call.
44/// This list includes operations like `Concat` for concatenating strings, `Eq` for equality checks, `Add` and `Sub` for arithmetic, and `TimeAdd` for time adjustments, among others.
45/// Such a macro centralizes the operation definitions, simplifying maintenance and reducing redundancy in coding related to binary operations.
46///
47macro_rules! for_all_op2 {
48 () => {
49 _do!(Concat Eq At PrefixOf SuffixOf Contains Split Join Count Add Sub Head Tail TimeFloor TimeAdd Floor Round Ceil FAdd FSub FFloor FRound FCeil FCount FShl10
50 TimeMul StrAt
51 BvAdd BvSub BvMul BvUDiv BvURem BvSDiv BvSRem BvOr BvAnd BvXor BvShl BvAShr BvLShr)
52 };
53}
54#[macro_export]
55/// Defines a macro that expands to include a set of three-element operations used within the expression handling of string synthesis tasks.
56///
57/// This macro uses the `_do!` macro utility to list the operations `Replace`, `Ite`, `SubStr`, and `IndexOf`, which are likely shorthand references to more complex operations involving three arguments or parameters.
58/// The purpose is to simplify the repetitive task of writing out these operations each time they need to be applied, enabling more concise and modular code within areas of the project that handle ternary operations.
59///
60macro_rules! for_all_op3 {
61 () => {
62 _do!(Replace Ite SubStr IndexOf)
63 };
64}