ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
expressionscamp.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_expressions of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace expressions {
9struct Scope;
10
11//==================================================================================================
12/// Exceptions thrown by module \alib_expressions_nl.
13///
14/// \note
15/// This enum type is associated with \ref alib_enums_records "ALib Enum Records" according to
16/// the specification documented with class \alib{exceptions;Exception}.
17//==================================================================================================
18enum class Exceptions
19{
20 /// General error thrown by the parser.
22
23 /// Detail entry (negative element value) used with various exceptions. Shows the expression
24 /// in a first line and a marker of the syntax error position in a second.
26
27 /// This is added to exceptions when when a \c std::exception is wrapped.
28 /// The 'what()' string is included as entry parameter.
29 /// (This is a detail entry with negative element value).
31
32 /// Thrown when an empty string is tried to be compiled.
34
35 /// Syntax error with concrete information about what the parser expected at given position.
37
38 /// Unknown unary operator symbol found when parsing expression string.
40
41 /// Unknown binary operator symbol found when parsing expression string.
43
44 /// Compile-time exception thrown when an expression uses an unknown identifier name.
46
47 /// Compile-time exception thrown when an expression uses an unknown function name.
49
50 /// Optional info entry (negative element value) on a function with matching name but
51 /// non-matching arguments found.
53
54 /// Compile-time exception thrown when an unary operator is not applicable to the given
55 /// argument type.
57
58 /// Compile-time exception thrown when a binary operator is not applicable to the combination of
59 /// left-hand and right-and argument type.
61
62 /// Compile-time exception thrown when function parentheses are missing with parameterless
63 /// functions, while flag
64 /// \alib{expressions::Compilation;AllowOmittingParenthesesOfParameterlessFunctions} is not set
65 /// in \alib{expressions;Compiler::CfgCompilation}.
67
68 /// Compile-time exception thrown when empty function parentheses are given with identifiers
69 /// (parameterless functions), while flag
70 /// \alib{expressions::Compilation;AllowEmptyParenthesesForIdentifierFunctions} is not set
71 /// in \alib{expressions;Compiler::CfgCompilation}.
73
74 /// Compile-time exception thrown when incompatible types are given with conditional
75 /// term <c>Q ? T : F</c>. Note that before throwing this exception, the compiler tries to
76 /// insert auto-cast callback functions, and if found, performs one second try to compile
77 /// the operator for the new pair of operatnd types.
79
80
81 /// This is a "wrapper" exception thrown when a plug-in or a compile-time invoked callback
82 /// function throws an exception of type \c std::exception or of type
83 /// \alib{exceptions;Exception} with a code that is not of this enumeration type.<br>
84 /// Used only if compilation \alib{expressions;Compilation::PluginExceptionFallThrough}
85 /// is not set.
87
88 /// This is a "wrapper" exception thrown when callback functions throws an exception of type
89 /// \c std::exception or of type \alib{exceptions;Exception}.
90 /// Used only if compilation \alib{expressions;Compilation::CallbackExceptionFallThrough}
91 /// is not set.
93
94 // ############################ Nested expressions ##################################
95
96 /// Compile-time exception thrown when unary expression operator is used with a non-constant
97 /// nested expression name.
99
100 /// Compile-time exception thrown when an expression refers to an unknown named nested expression.
102
103 /// Compile-time exception thrown when a named nested expression which is searched an inserted
104 /// at compile-time could not be found.<br>
105 /// Overwrites exception \b %NamedExpressionNotFound.
106 ///
107 /// \see Manual chapter \ref alib_expressions_nested "10. Nested Expressions".
109
110 /// Compile-time exception thrown when when wrong arguments were passed to function
111 /// \alib{expressions;Compiler::CfgNestedExpressionFunction}.
112 ///
113 /// \see Manual chapter \ref alib_expressions_nested "10. Nested Expressions".
115
116 /// Evaluation-time exception thrown when a named nested expression which is searched only at
117 /// evaluation-time could not be found.<br>
118 /// Overwrites exception \b %NamedExpressionNotFound.
119 /// \see Manual chapter \ref alib_expressions_nested "10. Nested Expressions".
121
122 /// Informational exception entry (negative element value) providing the name of the expression
123 /// that caused any other exception than \c NamedExpressionNotFound during evaluation of a
124 /// nested expression.
125 ///
126 /// Note that entries of this type might be repeated when expressions are recursively nested.
127 /// The number of entries in the exception corresponds to the depth of nesting.
129
130 /// Evaluation-time exception thrown when a named nested expression which was searched and found
131 /// only at evaluation-time, returned a different result type than specified.<br>
132 ///
133 /// \see Manual chapter \ref alib_expressions_nested "10. Nested Expressions".
135
136 /// Evaluation-time exception thrown when a circular relationship of nested expressions
137 /// is detected, which comprises an infinite loop.
139
140 /// A list of informational entries of this type is given with exception
141 /// \b %CircularNestedExpressions. Each entry provides the name of the expression that
142 /// was evaluated and the name of the nested expression that it called. Hence, the list of
143 /// entries of this type comprise the "call stack" that leaded to the circular call that
144 /// caused the exception.
146
147
148 /// This is an extension entry added to exceptions that occur with compilation or evaluation
149 /// of expressions by class \alib{expressions;util::ExpressionFormatter}.
151};
152
153//==================================================================================================
154/// \alib{enumops;ArithmeticalTraits;Arithmetical enumeration} of slots used to prioritize
155/// \alib{expressions;CompilerPlugin} instances attached to instances of class
156/// \alib{expressions;Compiler} at run-time.
157//==================================================================================================
159{
160 /// Used to denote that no variable or plug-in was found.
161 NONE = 0,
162
163 /// Built-in operator <c>?:</c> (like conditional, but no 'true'-expression).
164 /// \see \alib{expressions;plugins::ElvisOperator}
166
167 /// Auto-cast plug-in.
168 AutoCast = 200,
169
170 /// Built-in String comparison and manipulation.
171 Strings = 300,
172
173
174 /// Collection of built-in unary and binary operators for boolean, integer and floating point values.
176
177 /// Collection of built-in unary and binary operators for boolean, integer and floating point values.
178 Math = 500,
179
180 /// Collection of date and time functions based on \ref alib::time.
182
183 /// This is where custom plug-ins usually should be placed. It gives them a higher priority
184 /// than all built-in plug-ins have.<br>
185 /// If more than one plug-in should be installed, add 1, 2, ... to the enum element.
186 Custom = 1000,
187
188};
189
190//==================================================================================================
191/// This struct holds static \ref alib_expressions_prereq_sb "sample values" for
192/// the built-in supported types of module \alib_expressions_nl.
193///
194/// These boxes are mainly used by built-in compiler plug-ins to denote the corresponding type.
195/// Customized plug-ins are proposed to use these boxes to denote internal types as well and
196/// besides that to define static sample boxes for each custom type that they introduce in a
197/// similar fashion.
198///
199/// \note
200/// Of course, just sample any value might be passed where a type is expected, but using these
201/// pre-defined objects is more efficient in respect to code size. In respect to execution
202/// performance, the sample values are rather irrelevant, as those are used almost exclusively
203/// at expression compile-time.
204//==================================================================================================
205struct Types
206{
207 /// Sample <em>type-box</em> for C++ type <c>void</c>.
209
210 /// Sample <em>type-box</em> for C++ type <c>bool</c>.
212
213 /// Sample <em>type-box</em> for integer types. (Precisely for type \alib{integer}.)
215
216 /// Sample <em>type-box</em> for C++ type <c>double</c>.
218
219 /// Sample <em>type-box</em> for string types. While internally, \alib class
220 /// \alib{strings;TString;String} is used, due to the magic of module \alib_boxing, almost
221 /// any custom string type is compatible, including of course \c std::string.
223
224 /// Sample <em>type-box</em> for date and time values of type \alib{time;DateTime}).
226
227 /// Sample <em>type-box</em> for values of type \alib{time;TimePointBase::Duration;DateTime::Duration}).
229};
230
231//==================================================================================================
232/// This struct holds static arrays of pointers to \ref alib_expressions_prereq_sb "sample values".
233/// The arrays are used with helper-class \alib{expressions::plugins;Calculus} to denote accepted
234/// "function signatures" when* initializing column
235/// \doxlinkproblem{structalib_1_1expressions_1_1plugins_1_1Calculus_1_1FunctionEntry.html;a3f9769a430a930630a75d41bc7e4055c;FunctionEntry::Signature}
236/// of table \alib{expressions::plugins;Calculus::Functions}.
237///
238/// Each static field of this class represents a permutation of function arguments. Note, that only
239/// those permutations which are needed and used by the built-in compiler plugins (
240/// \alib{expressions::plugins;Arithmetics},
241/// \alib{expressions::plugins;Math},
242/// \alib{expressions::plugins;Strings} and
243/// \alib{expressions::plugins;DateAndTime} ) are contained here.
244///
245/// Custom compiler plug-ins may use the argument signatures given here, if a fitting signature
246/// is already included. Otherwise a custom signature array has to be defined, initialized and
247/// provided to the function definition table.
248//==================================================================================================
250{
251 static ALIB_DLL Box* Var [1]; ///< Function accepts variadic arguments.
252 static ALIB_DLL Box* B [1]; ///< Function accepts one boolean argument.
253 static ALIB_DLL Box* BB [2]; ///< Function accepts two boolean arguments.
254 static ALIB_DLL Box* I [1]; ///< Function accepts one integral argument.
255 static ALIB_DLL Box* II [2]; ///< Function accepts two integral arguments.
256 static ALIB_DLL Box* IVar[2]; ///< Function accepts one integral argument, followed by variadic arguments.
257 static ALIB_DLL Box* F [1]; ///< Function accepts one floating point argument.
258 static ALIB_DLL Box* FF [2]; ///< Function accepts two floating point arguments.
259 static ALIB_DLL Box* S [1]; ///< Function accepts one string argument.
260 static ALIB_DLL Box* SVar[2]; ///< Function accepts one string argument, followed by variadic arguments.
261 static ALIB_DLL Box* SS [2]; ///< Function accepts two string arguments.
262 static ALIB_DLL Box* SI [2]; ///< Function accepts one string argument, followed by an integral argument.
263 static ALIB_DLL Box* SSB [3]; ///< Function accepts two string arguments, followed by a boolean argument.
264 static ALIB_DLL Box* SSI [3]; ///< Function accepts two string arguments, followed by an integral argument.
265 static ALIB_DLL Box* SII [3]; ///< Function accepts one string argument, followed by two integral arguments.
266 static ALIB_DLL Box* SSS [3]; ///< Function accepts three string arguments.
267#if ALIB_CAMP
268 static ALIB_DLL Box* D [1]; ///< Function accepts a \alib{time;DateTime} argument.
269 static ALIB_DLL Box* Dur [1]; ///< Function accepts a \alib{time;TimePointBase::Duration;Duration} argument.
270 static ALIB_DLL Box* DDur[2]; ///< Function accepts a \alib{time;DateTime} argument; followed by a \alib{time;TimePointBase::Duration;Duration}.
271#endif
272};
273
274
275//==================================================================================================
276/// This enumeration lists the built-in unary operators.
277/// The associated \ref alib_enums_records "ALib Enum Records" provides the operator symbols.
278//==================================================================================================
280{
281 NONE , ///< Not an operator.
282
283 Positive , ///< <c>'+'</c> operator (usually returns identity value).
284 Negative , ///< <c>'-'</c> operator, negates a value.
285
286 BoolNot , ///< Boolean not (<c>'!'</c>).
287 BitNot , ///< Bitwise not (<c>'~'</c>).
288
289 Indirection , ///< Unary <c>'*'</c> operator. Similar to the C++ indirection operator, this
290 ///< is the default operator uses with nested expressions, which is defined
291 ///< with \alib{expressions;Compiler::CfgNestedExpressionOperator}.
292};
293
294//==================================================================================================
295/// This enumeration lists the built-in binary operators.
296/// The associated \ref alib_enums_records "ALib Enum RecordS" of type
297/// \alib{expressions;ERBinaryOperator} provides an operator's symbol an its precedence.
298//==================================================================================================
300{
301 NONE , ///< Not an operator.
302 Subscript , ///< Array subscripting (<c>'[]'</c>). Precedence hardcoded with parser.
303
304 Multiply , ///< Arithmetic multiplication (<c>'*'</c>). Precedence \c 900.
305 Divide , ///< Arithmetic division (<c>'/'</c>). Precedence \c 900.
306 Modulo , ///< Arithmetic modulo (<c>'%%'</c>). Precedence \c 900.
307
308 Add , ///< Arithmetic addition (<c>'+'</c>). Precedence \c 800.
309 Subtract , ///< Arithmetic subtraction (<c>'-'</c>). Precedence \c 800.
310
311 ShiftLeft , ///< Bitwise shifting of integral values (<c>'<<'</c>). Precedence \c 700.
312 ShiftRight , ///< Bitwise shifting of integral values (<c>'>>'</c>). Precedence \c 700.
313
314 Smaller , ///< Smaller operator (<c>'<'</c>). Precedence \c 600.
315 SmallerOrEqual , ///< Smaller or equal operator (<c>'<='</c>). Precedence \c 600.
316 Greater , ///< Greater operator (<c>'>'</c>). Precedence \c 600.
317 GreaterOrEqual , ///< Greater or equal operator (<c>'>='</c>). Precedence \c 600.
318
319 Equal , ///< Equal operator (<c>'=='</c>). Precedence \c 500.
320 NotEqual , ///< Not equal operator (<c>'!='</c>). Precedence \c 500.
321
322 BitAnd , ///< Binary and (<c>'&'</c>). "and"s all bits of two integral values. Precedence \c 470.
323 BitXOr , ///< Binary xor (<c>'^'</c>). "xor"s all bits of two integral values. Precedence \c 460.
324 BitOr , ///< Binary or (<c>'|'</c>). "or"s all bits of two integral values. Precedence \c 450.
325 BoolAnd , ///< Boolean and (<c>'&&'</c>). Result is boolean. Precedence \c 440.
326 BoolOr , ///< Boolean or (<c>'||'</c>). Result is boolean. Precedence \c 430.
327
328 Assign , ///< Assignment. By default, this is used as alias operator for
329 ///< operator \b Equal by the built-in compiler plug-ins.
330 ///< See \alib{expressions::Compilation;AliasEqualsOperatorWithAssignOperator}
331 ///< for more information.<br>
332 ///< Precedence \c 300.
333
334
335 Elvis , ///< Binary version of ternary operator <c>Q ? T : F</c> with
336 ///< second operand (\c T) not given.
337 ///< Whitespaces are allowed between '?' and ':'.<br>
338 ///< Precedence \c 200.
339};
340
341//==================================================================================================
342/// \ref alib_enums_records "ALib Enum Record" associated with enumeration
343/// \alib{expressions;DefaultBinaryOperators}.
344//==================================================================================================
346{
347 /// The parable symbol of an operator.
349
350 /// The precedence of an operator in respect to other binary operators.
352
353 /// Required default constructor leaving the record undefined.
354 /// (Requirement is documented with\alib{enumrecords::EnumRecordPrototype}.)
355 ERBinaryOperator() noexcept = default;
356
357 /// Required initializing constructor.
358 /// (Requirement is documented with\alib{enumrecords::EnumRecordPrototype}.)
359 ///
360 /// @param symbol The parsable operator symbol.
361 /// @param precedence The operator's precedence.
362 ERBinaryOperator( const String& symbol, int precedence )
363 : Symbol (symbol)
364 , Precedence(precedence)
365 {}
366
367 /// Implementation of \alib{enumrecords;EnumRecordPrototype::Parse}.
369 void Parse();
370};
371
372
373//==================================================================================================
374/// This enumeration lists the built-in verbal alias names for unary operators.
375///
376/// The associated \ref alib_enums_records "ALib Enum Records" provides the operator verbs
377/// as well as the replacement operator.
378///
379/// Flag \alib{expressions;Compilation::DefaultAlphabeticOperatorAliases} controls if method
380/// \alib{expressions;Compiler::SetupDefaults} adds the aliases to the compiler.
381//==================================================================================================
383{
384 Not , ///< Verbal alias \c "Not" to operator <c>'!'</c>.
385};
386
387//==================================================================================================
388/// This enumeration lists the built-in verbal alias names for binary operators.
389///
390/// The associated \ref alib_enums_records "ALib Enum Records" provides the operator verbs
391/// as well as the replacement operator.
392///
393/// Flag \alib{expressions;Compilation::DefaultAlphabeticOperatorAliases} controls if method
394/// \alib{expressions;Compiler::SetupDefaults} adds the aliases to the compiler.
395//==================================================================================================
397{
398 And , ///< Verbal alias \c "And" to boolean and operator <c>'&&'</c>.
399 Or , ///< Verbal alias \c "Or" to boolean or operator <c>'||'</c>.
400 Sm , ///< Verbal alias \c "Sm" to operator <c>'<'</c>.
401 Smaller , ///< Verbal alias \c "Smaller" to operator <c>'<'</c>.
402 SmEq , ///< Verbal alias \c "Smeq" to operator <c>'<='</c>.
403 SmallerOrEqual , ///< Verbal alias \c "Smaller_or_equal" to operator <c>'<='</c>.
404 Gt , ///< Verbal alias \c "Gt" to operator <c>'>'</c>.
405 Greater , ///< Verbal alias \c "Greater" to operator <c>'>'</c>.
406 GtEq , ///< Verbal alias \c "Gteq" to operator <c>'>='</c>.
407 GreaterOrEqual , ///< Verbal alias \c "Greater_or_equal" to operator <c>'>='</c>.
408 Eq , ///< Verbal alias \c "Eq" to operator <c>'=='</c>.
409 Equals , ///< Verbal alias \c "Equals" to operator <c>'=='</c>.
410 NEq , ///< Verbal alias \c "Neq" to operator <c>'!='</c>.
411 NotEqual , ///< Verbal alias \c "Not_equals" to operator <c>'!='</c>.
412};
413
414//==================================================================================================
415/// \ref alib_enums_records "ALib Enum Record" associated with enumeration
416/// \alib{expressions;DefaultBinaryOperators}.
417//==================================================================================================
419{
420 /// The parsable symbol of an alias operator.
422
423 /// The replacement operator symbol.
425
426 /// Required default constructor leaving the record undefined.
427 /// (Requirement is documented with\alib{enumrecords::EnumRecordPrototype}.)
428 EROperatorAlias() noexcept = default;
429
430 /// Required initializing constructor.
431 /// (Requirement is documented with\alib{enumrecords::EnumRecordPrototype}.)
432 ///
433 /// @param symbol The parsable operator symbol.
434 /// @param replacement The symbol of the aliased operator.
435 EROperatorAlias( const String& symbol, const String& replacement )
436 : Symbol (symbol)
437 , Replacement(replacement)
438 {}
439
440 /// Implementation of \alib{enumrecords;EnumRecordPrototype::Parse}.
442 void Parse();
443};
444
445
446
447//==================================================================================================
448/// \alib{enumops;BitwiseTraits;Bitwise} enum class defining options of expression compilation.
449/// Flags defined with this type are set in field \alib{expressions;Compiler::CfgCompilation}.
450//==================================================================================================
451enum class Compilation
452{
453 /// If this flag is set, all unary operators given in \alib{expressions;DefaultUnaryOperators}
454 /// are defined with method \alib{expressions;Compiler::SetupDefaults}.
455 ///
456 /// Note that the enumeration class is equipped with resourced
457 /// \ref alib_enums_records "ALib Enum Records", which might be changed as an
458 /// alternative to clearing this flag and provide own definitions.
459 ///
460 /// This flag is set by default.
462
463 /// If this flag is set, all binary operators given in \alib{expressions;DefaultBinaryOperators}
464 /// are defined with method \alib{expressions;Compiler::SetupDefaults}.
465 ///
466 /// Note that the enumeration class is equipped with resourced
467 /// \ref alib_enums_records "ALib Enum Records", which might be changed as an
468 /// alternative to clearing this flag and provide own definitions.
469 ///
470 /// This flag is set by default.
472
473 /// If this flag is set, all alphabetic operator aliases given in enumerations
474 /// \alib{expressions;DefaultAlphabeticUnaryOperatorAliases} and
475 /// \alib{expressions;DefaultAlphabeticBinaryOperatorAliases}
476 /// are defined with method \alib{expressions;Compiler::SetupDefaults}.
477 ///
478 /// Note that both enumeration classes are equipped with resourced
479 /// \ref alib_enums_records "ALib Enum Records", which might be changed as an
480 /// alternative to clearing this flag and provide own definitions.
481 ///
482 /// This flag is set by default.
484
485 /// If this flag is set, alphabetic operator aliases defined in
486 /// \alib{expressions;Compiler::AlphabeticUnaryOperatorAliases} and
487 /// \alib{expressions;Compiler::AlphabeticBinaryOperatorAliases} are parsed ignoring letter
488 /// case.
489 ///
490 /// \note
491 /// Even when this flag is cleared, no two verbal operator aliases that are equal
492 /// when case is ignored must be defined (e.g "or" and "OR" ).
493 ///
494 /// This flag is set by default.
496
497 /// If not set, array subscript operator <c>[]</c> is not supported and its use will cause
498 /// parse errors errors.
499 ///
500 /// Note that compiler plug-ins get the array subscript operator presented for compilation
501 /// as a usual binary operator given as \alib{expressions;DefaultBinaryOperators::Subscript}.
502 /// This makes its support with custom types quite simple.
503 ///
504 /// \attention This flag has to be changed to a custom state before performing the first
505 /// compilation of an expression with a dedicated \alib{expressions;Compiler}.
506 /// The rationale behind this is, that the compiler creates the parser system at its
507 /// first use, which in turn does not check the flag after creation.
508 ///
509 /// This flag is set by default.
511
512 /// Used with constructor of compiler plug-ins
513 /// \alib{expressions;plugins::Arithmetics} and
514 /// \alib{expressions;plugins::Strings}.
515 /// (If they are activated in \alib{expressions;Compiler::CfgBuiltInPlugins} or "manually"
516 /// added.)
517 ///
518 /// Denotes if the assignment operator <c>=</c> is an alias for equal operator <c>==</c>.
519 /// If set to \c false, the use of the <c>=</c> operator with several any argument type,
520 /// throws a compilation exception, unless it is compiled by a custom plug-in.
521 ///
522 /// \attention
523 /// In addition to aliasing the <c>==</c> with <c>=</c>, the latter also receives a
524 /// higher precedence of parsing! If this flag is not set, the precedence of
525 /// \e assign <c>=</c>,follows the C++ standards and thus is below the group of
526 /// <c>&</c>, <c>^</c>, <c>|</c>, <c>&&</c>, <c>||</c> and <c>? :</c>. If the alias
527 /// setting is activated, then the precedence is raised to be on the same level as
528 /// boolean equal <c>==</c> and thus higher than the aforementioned operators!
530
531 /// Used with constructor of compiler plug-in \alib{expressions;plugins::Arithmetics}.
532 /// (If it is activated in \alib{expressions;Compiler::CfgBuiltInPlugins} or "manually" added.)
533 ///
534 /// Denotes if the unary bitwise operator <c>~</c> and binary bitwise operators
535 /// <c>&</c>, <c>|</c> and <c>^</c> should be allowed for boolean values.
536 /// If set to \c false, the use of the bitwise operators with boolean arguments, throws
537 /// a compilation exception, unless the bitwise operators are compiled by a custom plug-in.
539
540
541 /// If \c false, compile-time exception
542 /// \alib{expressions;Exceptions::MissingFunctionParentheses} is thrown if a parameterless
543 /// function is stated without (otherwise redundant) parentheses <c>'()'</c>.
544 ///
545 /// If \c true, this is tolerated.
546 ///
547 /// \note
548 /// This flag is not tested, and the exception is not thrown, by the compiler itself, but
549 /// by class \alib{expressions::plugins;Calculus}.<br>
550 /// Even if this flag is \c false, still functions without parentheses may be allowed
551 /// by setting \c nullptr to field
552 /// \doxlinkproblem{structalib_1_1expressions_1_1plugins_1_1Calculus_1_1FunctionEntry;a3f9769a430a930630a75d41bc7e4055c;Calculus::FunctionEntry::Signature}
553 /// when registering a function. In this case the function is considered rather being an
554 /// "identifier" than a function. (Still it is the very same as a function, it is just a
555 /// matter of wording here.)<br>
556 ///
557 /// The other way round, if a function is registered as an identifier, flag
558 /// \b %AllowEmptyParenthesesForIdentifierFunctions, controls if exception
559 /// \alib{expressions;Exceptions::IdentifierWithFunctionParentheses} is to be thrown
560 /// if empty parentheses are given on functions that are registered as
561 /// identifier-style functions.
563
564 /// If \c false, compile-time exception
565 /// \alib{expressions;Exceptions::IdentifierWithFunctionParentheses} is thrown if a
566 /// parameterless function, declared as 'identifier style' is used with parentheses
567 /// <c>'()'</c>.
568 ///
569 /// If \c true, this is tolerated.
570 ///
571 /// \see
572 /// For more information, see the note in documentation of flag
573 /// \b %AllowOmittingParenthesesOfParameterlessFunctions.
575
576 /// If this flag is set (the default), the
577 /// \alib{expressions;Compiler::CfgNestedExpressionOperator;unary nested expression operator}
578 /// is activated, as well as the single-parameter overload of the
579 /// \alib{expressions;Compiler::CfgNestedExpressionFunction;nested expression function}.
580 /// If the field is cleared, then only evaluation-time nested expressions are allowed,
581 /// which is the two- and three-parameter version of the expression function.
582 /// Other uses are then causing compilation exception
583 /// \alib{expressions;Exceptions::UnaryOperatorNotDefined}, respectively
584 /// \alib{expressions;Exceptions::NestedExpressionCallArgumentMismatch}.
586
587 /// If this flag is set (the default), then identifiers that follow the unary nested
588 /// expression operator (defaults to <c>'*'</c>), are internally converted to corresponding
589 /// string literals - just as if they were given as a quoted string.
590 ///
591 /// \see
592 /// Normalization flag
593 /// \alib{expressions::Normalization;QuoteUnaryNestedExpressionOperatorArgument}.
595
596 /// If not set (the default), then names of named expressions are not distinguished by
597 /// letter case.
599
600 /// Controls whether exceptions of type \c std::exception thrown in plug-ins during compilation
601 /// are caught by the compiler and transformed to \alib{expressions;Exceptions::ExceptionInPlugin}
602 ///
603 /// Note that exceptions thrown in callback functions which are evaluated at compile-time
604 /// against constant parameters, are considered plug-in exceptions.
606
607
608 /// This is an "evaluation-time compiler flag". If not set (the default) exceptions of type
609 /// \alib{exceptions;Exception} and \c std::exception thrown in callback functions during expression
610 /// evaluation are caught and transformed to \alib{expressions;Exceptions::ExceptionInCallback}
611 /// letter case.
613
614 /// If this flag is set, no optimizations are performed when assembling the program.
615 ///
616 /// \note
617 /// There is absolutely no reason for setting this flag, other than for running the
618 /// unit tests. Or for playing with the little virtual machine implemented with this
619 /// library and having fun understanding the non-optimized program listings generated.
620 /// The assembly language is easy, it has only four virtual assembly commands - plus a fifth
621 /// for invoking programs of nested expressions.
622 NoOptimization = (1 << 20),
623
624
625 /// Default value. Evaluates to:<br>
626 /// <c> DefaultUnaryOperators + </c><br>
627 /// <c> DefaultBinaryOperators + </c><br>
628 /// <c> DefaultAlphabeticOperatorAliases + </c><br>
629 /// <c> AlphabeticOperatorsIgnoreCase + </c><br>
630 /// <c> AliasEqualsOperatorWithAssignOperator + </c><br>
631 /// <c> AllowBitwiseBooleanOperators + </c><br>
632 /// <c> AllowSubscriptOperator + </c><br>
633 /// <c> AllowOmittingParenthesesOfParameterlessFunctions + </c><br>
634 /// <c> AllowEmptyParenthesesForIdentifierFunctions + </c><br>
635 /// <c> AllowCompileTimeNestedExpressions + </c><br>
636 /// <c> AllowIdentifiersForNestedExpressions + </c><br>
648};
649
650//==================================================================================================
651/// \alib{enumops;BitwiseTraits;Bitwise} enum class defining options for formatting parsed
652/// expressions. The normalized conversion of the expression input string is available
653/// with method \alib{expressions;ExpressionVal::GetNormalizedString}, after an expression was
654/// successfully \alib{expressions;Compiler::Compiler;compiled}.
655///
656/// The normalization flags are stored per compiler instance, consequently using a public compiler
657/// field namely \alib{expressions;Compiler::CfgNormalization}.
658//==================================================================================================
659enum class Normalization : uint64_t
660{
661 /// Replace given shortened and letter case mismatched identifier and function names with
662 /// completed versions.<br>
663 /// This flag is set with \b %DEFAULT.
664 ReplaceFunctionNames = (1LLU << 1),
665
666 /// Replace alias operators with effective operators.<br>
667 /// This flag is not set with \b %DEFAULT.
669
670 /// This is one of four flags that together allow five possible normalization options for
671 /// \ref alib_expressions_operators_verbal "verbal alias operators".
672 /// If more than one flag is set, the one with the highest precedence is used.
673 ///
674 /// The following table lists the flags, their precedence and the type of normalization:
675 ///
676 /// |Precedence | Flag | Description
677 /// |------------|----------------------------------|------------------------------
678 /// | 0 | <none set> | A verbal operator is normalized as given in original expression string.
679 /// | 1 | ReplaceVerbalOperatorsToSymbolic | Replaces verbal operators with the symbolic operator that they represent.
680 /// | 2 | ReplaceVerbalOperatorsToLowerCase | Converts verbal operators to lower case letters.
681 /// | 3 | ReplaceVerbalOperatorsToUpperCase | Converts verbal operators to upper case letters.
682 /// | 4 | ReplaceVerbalOperatorsToDefinedLetterCase | Uses the writing specified with the definition of the verbal operator.
683 ///
684 /// With configuration \alib{expressions::Normalization;DEFAULT}, flag
685 /// \b %ReplaceVerbalOperatorsToUpperCase is set.
687
688 /// See sibling flag \alib{expressions::Normalization;ReplaceVerbalOperatorsToSymbolic}.
690
691 /// See sibling flag \alib{expressions::Normalization;ReplaceVerbalOperatorsToSymbolic}.
693
694 /// See sibling flag \alib{expressions::Normalization;ReplaceVerbalOperatorsToSymbolic}.
696
697 /// Converts nested expression names that have been given unquoted to a quoted string literal.
698 /// If this is not set, the quotation remains as given in original expression string.
699 /// This flag is \e not set with \b %DEFAULT.
700 ///
701 /// \see
702 /// Compilation flag
703 /// \alib{expressions::Compilation;AllowIdentifiersForNestedExpressions}.
705
706 /// Remove redundant provisions unary operators <c>'+'</c> and <c>'-'</c> from number
707 /// literals.<br>
708 /// This flag is \e not set with \b %DEFAULT.
710
711 /// Write a space after an unary operator (if no brackets around arguments and no unary operator
712 /// follows).<br>
713 /// This flag is \e not set with \b %DEFAULT.
714 UnaryOpSpace = (1LLU << 9),
715
716 /// Write a space between two unary operators.<br>
717 /// This flag is \e not set with \b %DEFAULT.
719
720 /// Write a space before opening bracket of bracketed arguments of unary operators.<br>
721 /// This flag is \e not set with \b %DEFAULT.
723
724 /// Write a space after an opening and before a closing bracket of arguments of unary operators.<br>
725 /// This flag is \e not set with \b %DEFAULT.
727
728 /// If this flag is set, normalization inserts redundant brackets to the argument of an
729 /// unary operator, if that argument is an unary operator itself.
730 ///
731 /// This flag is superseded by \b %RedundantUnaryOpBrackets.<br>
732 /// This flag is \e not set with \b %DEFAULT.
734
735 /// If this flag is set, normalization inserts redundant brackets to arguments of unary
736 /// operators.
737 ///
738 /// This flag supersedes by \b %RedundantBracketsBetweenTwoUnaryOps.<br>
739 /// This flag is \e not set with \b %DEFAULT.
741
742
743 /// Write a space before and after binary operator symbol.<br>
744 /// This flag is set with \b %DEFAULT.
745 BinaryOpSpaces = (1LLU << 15),
746
747 /// Write a space after an opening and before a closing bracket of arguments of binary
748 /// operators and around a conditional expression.<br>
749 /// This flag is \e not set with \b %DEFAULT.
750 InnerBracketSpace = (1LLU << 16),
751
752 /// Write a space before opening and after closing bracket of arguments of binary
753 /// operators and around a conditional expression.<br>
754 /// This flag is \e not set with \b %DEFAULT.
755 OuterBracketSpace = (1LLU << 17),
756
757 /// If this flag is set, normalization inserts redundant brackets to the right-hand side
758 /// operand of binary operators if that operand is a binary operator itself and has a higher
759 /// precedence.
760 ///
761 /// The following samples demonstrate why this is useful if normalization targets humans:
762 ///
763 /// Without flag set | With flag set
764 /// ---------------------|----------------------
765 /// 1 - 2 - 3 | <em>no change</em>
766 /// 1 - 2 * 3 | 1 - (2 * 3)
767 /// 1 * 2 - 3 | <em>no change</em>
768 /// 1 - 2 * 3 - 4 - 5 * 6 - 7 | 1 - (2 * 3) - 4 - (5 * 6) - 7
769 /// true == false && true | <em>no change</em>
770 /// true && false == true | true && (false == true)
771 /// true && false == false && true | true && (false == false) && true
772 /// true && false == (false && true) | true && (false == (false && true))
773 /// true && false == true < false | true && (false == (true < false))
774 /// true && false == false == true | true && (false == false == true)
775 /// This flag is superseded by \b %RedundantBinaryOpBrackets.<br>
776 /// This flag is set with \b %DEFAULT.
778
779 /// If this flag is set, normalization inserts redundant brackets to both
780 /// operands of binary operators if both are binary operators themselves.
781 ///
782 /// The following samples demonstrate why this is useful if normalization strings target humans:
783 ///
784 /// Without flag set | With flag set
785 /// ---------------------|----------------------
786 /// 1 - 2 - 3 | <em>no change</em>
787 /// 1 - 2 - 3 - 4 | <em>no change</em>
788 /// 1 - 2 - (3 - 4) | (1 - 2) - (3 - 4)
789 /// 1 - 2 - 3 - (4 - 5) | (1 - 2 - 3) - (4 - 5)
790 /// 1 - 2 - (3 - 4) - 5 | (1 - 2) - (3 - 4) - 5
791 ///
792 /// This flag is superseded by \b %RedundantBinaryOpBrackets.<br>
793 /// This flag is set with \b %DEFAULT.
795
796 /// If this flag is set, normalization inserts redundant brackets around each binary operator
797 /// sub-expression. This flag supersedes flags
798 /// \b %RedundantRhsBracketsIfRhsIsStrongerBinaryOp and
799 /// \b %RedundantBracketsIfLhsAndRhsAreBinaryOps.
800 ///
801 /// It is not recommended to set this flag. It is only useful to debug expressions and
802 /// understand exactly what precedences operators have.
803 ///
804 /// This flag is set with \b %DEFAULT.
806
807
808 /// Write a space before character <c>?</c> of ternary conditional operator.<br>
809 /// This flag is set with \b %DEFAULT.
811
812 /// Write a space after character <c>?</c> of a ternary conditional operator.<br>
813 /// This flag is set with \b %DEFAULT.
815
816 /// Write a space before character <c>:</c> of ternary conditional operator.<br>
817 /// This flag is set with \b %DEFAULT.
819
820 /// Write a space after character <c>:</c> of ternary conditional operator.<br>
821 /// This flag is set with \b %DEFAULT.
823
824 /// If this flag is set, normalization inserts redundant brackets around the conditional
825 /// operator expressions <c>Q ? T : F</c>, if it is not the root node.
826 ///
827 /// This flag is set with \b %DEFAULT.
829
830 /// Write a space before between the function identifier name and the opening bracket of the
831 /// argument list.<br>
832 /// This flag is \e not set with \b %DEFAULT.
834
835 /// Write a space after the opening and before the closing bracket of argument list of a
836 /// function.<br>
837 /// This flag is set with \b %DEFAULT.
839
840 /// Write a space between the opening and the closing bracket of an empty argument list of a
841 /// function.<br>
842 /// This flag is set with \b %DEFAULT.
844
845 /// Write a space before a comma of an argument separator of an function's argument list.<br>
846 /// This flag is \e not set with \b %DEFAULT.
848
849 /// Write a space after a comma of an argument separator of a function's argument list.<br>
850 /// This flag is set with \b %DEFAULT.
852
853 /// Write a space before array subscript operator <c>'[]'</c>.<br>
854 /// This flag is \e not set with \b %DEFAULT.
856
857 /// Write a space after the opening and before the closing bracket of array subscript operator
858 /// <c>'[]'</c>.<br>
859 /// This flag is \e not set with \b %DEFAULT.
861
862
863 /// If this flag is set, floating point literals are normalized in scientific format when
864 /// given in scientific format. If it is not set, then numbers given in scientific format
865 /// might be written as usual floating point values, dependent on their value. E.g.
866 /// a given <c>1.0e1</c> would be converted to <c>10.0</c>.
867 ///
868 /// Note that scientific format can be forced for all floating point number output by setting
869 /// flag \alib{strings;NumberFormatFlags;ForceScientific} in field
870 /// \alib{strings::NumberFormat;Flags} of variable
871 /// \alib{format;Formatter::DefaultNumberFormat}, which in turn is found
872 /// in member \alib{expressions;Compiler::CfgFormatter}. Such setting would supersede
873 /// this flag.
874 ///
875 /// This flag is \e not set with \b %DEFAULT.
876 KeepScientificFormat = (1LLU << 33 ),
877
878 /// If this flag is set, integral literals will be normalized to hexadecimal format.
879 /// If this flag is not set, then integrals will be normalized in the number system that they had
880 /// been provided in.
881 ///
882 /// This flags supersedes flags \b %ForceOctal and \b %ForceBinary.
883 ///
884 /// This flag is \e not set with \b %DEFAULT.
885 ForceHexadecimal = (1LLU << 34 ),
886
887 /// If this flag is set, integral literals will be normalized to octal format.
888 /// If this flag is not set, then integrals will be normalized in the number system that they had
889 /// been provided in.
890 ///
891 /// This flags is superseded by flag \b %ForceHexadecimal and supersedes flag \b %ForceBinary.
892 ///
893 /// This flag is \e not set with \b %DEFAULT.
894 ForceOctal = (1LLU << 35 ),
895
896 /// If this flag is set, integral literals will be normalized to binary format.
897 /// If this flag is not set, then integrals will be normalized in the number system that they had
898 /// been provided in.
899 ///
900 /// This flags is superseded by flags \b %ForceHexadecimal and \b %ForceOctal.
901 ///
902 /// This flag is \e not set with \b %DEFAULT.
903 ForceBinary = (1LLU << 36 ),
904
905 /// All flags are cleared, may be used for testing bits.
906 NONE = 0L,
907
908 /// All flags are cleared, hence no whitespaces and unnecessary brackets are written and
909 /// identifiers as they have been given (potentially abbreviated and ignoring letter case).
911
912 /// Default value. Evaluates to:<br>
913 /// <c>ReplaceFunctionNames + </c><br>
914 /// <c>ReplaceVerbalOperatorsToUpperCase + </c><br>
915 /// <br>
916 /// <c>RemoveRedundantUnaryOpsOnNumberLiterals + </c><br>
917 /// <c>BinaryOpSpaces + </c><br>
918 /// <c>RedundantRhsBracketsIfRhsIsStrongerBinaryOp + </c><br>
919 /// <c>RedundantBracketsIfLhsAndRhsAreBinaryOps + </c><br>
920 /// <br>
921 /// <c>ConditionalOpSpaceBeforeQM + </c><br>
922 /// <c>ConditionalOpSpaceBeforeColon + </c><br>
923 /// <c>ConditionalOpSpaceAfterQM + </c><br>
924 /// <c>ConditionalOpSpaceAfterColon + </c><br>
925 /// <c>RedundantConditionalOpBrackets + </c><br>
926 /// <br>
927 /// <c>FunctionInnerBracketSpace + </c><br>
928 /// <c>FunctionSpaceAfterComma + </c><br>
931
936
942
945};
946
947/// Type definition for passing boxes as sample types.
948///
949/// \see For more information, see
950/// \ref alib_expressions_prereq_sb "3.2 Type definitions With Sample Boxes".
952
953/// Type definition for passing arguments to expression callbacks.
954///
955/// \see For more information, see
956/// \ref alib_expressions_prereq_sb "3.2 Type definitions With Sample Boxes".
957using ArgIterator= StdVectorMono<Box>::iterator;
958
959/// Function pointer implementing native callback functions, for expression functions and
960/// operators. The implementations are defined and selected by the compiler plugins.
961/// They are called (executed) when an expression is evaluated.
962///
963/// @param scope The expression's evaluation scope.
964/// @param[out] argsBegin An iterator that returns \b %Box objects.
965/// The first entry takes also the result.
966/// @param[out] argsEnd The end-iterator.
967///
968using CallbackDecl = Box (*)( Scope& scope, ArgIterator argsBegin, ArgIterator argsEnd );
969
970
971/// This struct constitutes a type declaration for a \ref alib_boxing_functions "box-function".
972/// The function is used to create parsable expression "literals" from constant values of custom
973/// type stored in boxes.
974///
975/// The function is used by the library if all of the following occurs:
976/// - If custom identifiers, functions or operator callback functions return a custom type.
977/// - If such types can be constants and are announced to the compiler as such.
978/// - If method \alib{expressions;ExpressionVal::GetOptimizedString} is called.
979/// - If such string is to be used as input to compiling expressions.
980///
981/// If the last condition is met, compilation of the "normalized optimized expression string " would
982/// fail. If it is not met, then without a proper implementation of this function, the only
983/// "damage" is that such string would show an integral value where a constant custom type was
984/// expected.
985///
986/// The challenge of implementing this box-function for a custom type, is to convert constants of
987/// custom types back into a normalized, human-readable but also compilable expression string.
988/// As the expression syntax only defines the built-in literal types
989/// \alib{expressions::Types;Integer}, \alib{expressions::Types;Float} and
990/// \alib{expressions::Types;String}, the constants have to be created using either appropriate
991/// custom identifiers or "constructor functions" that have to be provided in addition along with
992/// the implementation of this box-function to make it compilable.
993///
994/// A sample for that situation is given in chapter \ref alib_expressions_details_optimizations_norm
995/// of the Programmer's Manual.
996///
997/// The identifiers and constructor functions in turn need to be compile-time evaluatable
998/// to ensure that recompiling the optimized string results to constants so that the same
999/// optimized expression program is generated..
1000///
1001/// #### Sample: ####
1002/// So far, this probably sounded a little complicated. Let us look step by step at the sample
1003/// given in the aforementioned manual section, that is solved internally by the library using
1004/// this box-function declaration.
1005///
1006/// %Compiler plug-in \alib{expressions::plugins;DateAndTime} introduces \alib class
1007/// \alib{time;TimePointBase::Duration} to expressions. This is for example done by defining
1008/// identifiers as follows:
1009///
1010/// \snippet "plugins/dateandtime.cpp" DOX_EXPR_FToLiteral_1
1011///
1012/// The "constructor functions" are declared to be
1013/// \alib{expressions::plugins;Calculus::CTI;compile-time invokable}
1014/// and return a constant value at compile-time in case their input parameter is constant.
1015/// When the program - that may due to optimization not contain the identifiers anymore - becomes
1016/// de-compiled, these constants have to be written to the normalized expression string in a way that
1017/// corresponding constant values of type \b %Duration are expressed.
1018///
1019/// To perform this task, an implementation of the box-function that this struct declares
1020/// has to be registered with boxes containing values of \b TimePointBase::Duration.<br>
1021/// Registrations of box-functions have to be done in the \ref alib_mod_bs "bootstrap"
1022/// code of the library. In this case it is done in static method
1023/// \alib{expressions;plugins::DateAndTime::Bootstrap}.
1024/// The function name that is used for the implementation is \b %FToLiteral_Duration. Here is
1025/// the line of code that registers the function with the boxed type:
1026///
1027/// \snippet "expressions/plugins/dateandtime.cpp" DOX_EXPR_FToLiteral_2
1028///
1029/// The implementation is given in an anonymous namespace of the compilation unit of compiler plug-in
1030/// \b %DateAndTime. The function's signature has to meet the one given with type definition #Signature
1031/// of this struct. Besides the first parameter that passes the box that the function is invoked
1032/// on (the one containing the constant value of custom type), second parameter \p{expressionString}
1033/// provides the \b AString that the function is requested to write the "generation expression" to.<br>
1034/// The implementation code looks as follows:
1035///
1036/// \snippet "expressions/plugins/dateandtime.cpp" DOX_EXPR_FToLiteral_3
1037///
1038/// As it can be understood from the code, the interface implementation tries to find the best
1039/// matching "constructor function" for the time span given, writes its name and the constant parameter
1040/// enclosed by brackets \c "()".
1041///
1042/// Only with such interface implementation in place - one that covers all possible constants - this
1043/// library is able to create <b>parsable, normalized, optimized expression strings</b>.
1044/// To finalize this example, we check what the result for three sample expressions looks like:
1045///
1046/// \snippet "DOX_EXPRESSIONS_TUT_WONO-100.txt" OUTPUT
1047/// \snippet "DOX_EXPRESSIONS_TUT_WONO-101.txt" OUTPUT
1048/// \snippet "DOX_EXPRESSIONS_TUT_WONO-102.txt" OUTPUT
1049///
1050/// \note
1051/// When integrating module \alib_expressions_nl into software, a decision has to be
1052/// taken: "Should optimized expression strings be presented to the end-user?"<br>
1053///
1054/// \note
1055/// While it is obvious, that sample two demonstrates that to be useful, sample three probably
1056/// demonstrates the opposite!<br>
1057/// It is important to understand, that the decision depends on the custom use case, where for
1058/// example the technical understanding of a typical end-user may be taken into account.
1059///
1060/// \note
1061/// If the decision is taken, \b not to present optimized expression strings to the end-user, this
1062/// has absolutely no influence on the evaluation performance: The compilation of all three
1063/// expression strings, namely
1064/// - the original input,
1065/// - the normalized output and
1066/// - the optimized, normalized output,
1067/// \note
1068/// are leading to the very same (optimized) internal program when compiled!
1069///
1070/// \note
1071/// Of course, if no optimization strings are presented to the end-user and hence are not
1072/// recompiled (or copy/pasted by such users), then the implementation of this box-function is
1073/// not needed for your custom type, as it is only invoked with method
1074/// \alib{expressions;ExpressionVal::GetOptimizedString}!
1076{
1077 /// Signature of the invokable function.
1078 ///
1079 /// @param constantValue The constant program value that is about to be written into
1080 /// \p{expressionString}.
1081 /// @param expressionString The expression string that is currently generated.
1082 using Signature = void (*) ( const Box& constantValue, AString& expressionString );
1083};
1084
1085
1086//==================================================================================================
1087/// The module class for module \alib_expressions_nl.
1088///
1089/// This is a strict singleton class. The only instance found with namespace variable
1090/// \ref alib::EXPRESSIONS.
1091//==================================================================================================
1093{
1094 public:
1095 //==========================================================================================
1096 /// Constructor.<br>
1097 /// While this is public, it must not be invoked as this is a strict singleton type.
1098 /// (See notes in \ref alib_camp_camp).
1099 //==========================================================================================
1101
1102 protected:
1103 //==========================================================================================
1104 /// Initializes this camp.
1105 //==========================================================================================
1106 virtual void Bootstrap() override;
1107
1108 //==========================================================================================
1109 /// Terminates this camp. (Nothing to do.)
1110 /// @param phase The shutdown phase to perform.
1111 //==========================================================================================
1112 virtual void Shutdown( ShutdownPhases phase ) override { (void) phase; }
1113
1114}; // class ExpressionsCamp
1115
1116} // namespace alib[::expressions]
1117
1118/// The singleton instance of \alibcamp class \alib{expressions;ExpressionsCamp}.
1119extern ALIB_DLL expressions::ExpressionsCamp EXPRESSIONS;
1120
1121} // namespace [alib]
1122
1124
1128
1136
1139
1140
virtual void Shutdown(ShutdownPhases phase) override
virtual void Bootstrap() override
Initializes this camp.
#define ALIB_DLL
Definition alib.inl:496
#define ALIB_ENUMS_MAKE_BITWISE(TEnum)
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
#define ALIB_ENUMS_MAKE_ARITHMETICAL(TEnum)
#define ALIB_EXPORT
Definition alib.inl:488
#define ALIB_RESOURCED_IN_MODULE(T, Camp, ResName)
@ DateAndTime
Collection of date and time functions based on alib::time.
@ Arithmetics
Collection of built-in unary and binary operators for boolean, integer and floating point values.
@ Strings
Built-in String comparison and manipulation.
@ Math
Collection of built-in unary and binary operators for boolean, integer and floating point values.
@ NONE
Used to denote that no variable or plug-in was found.
@ Or
Verbal alias "Or" to boolean or operator '||'.
@ And
Verbal alias "And" to boolean and operator '&&'.
Box(*)(Scope &scope, ArgIterator argsBegin, ArgIterator argsEnd) CallbackDecl
StdVectorMono< Box >::iterator ArgIterator
@ BitOr
Binary or ('|'). "or"s all bits of two integral values. Precedence 450.
@ SmallerOrEqual
Smaller or equal operator ('<='). Precedence 600.
@ Divide
Arithmetic division ('/'). Precedence 900.
@ NotEqual
Not equal operator ('!='). Precedence 500.
@ Subtract
Arithmetic subtraction ('-'). Precedence 800.
@ BoolAnd
Boolean and ('&&'). Result is boolean. Precedence 440.
@ Modulo
Arithmetic modulo ('%'). Precedence 900.
@ BoolOr
Boolean or ('||'). Result is boolean. Precedence 430.
@ GreaterOrEqual
Greater or equal operator ('>='). Precedence 600.
@ BitXOr
Binary xor ('^'). "xor"s all bits of two integral values. Precedence 460.
@ Greater
Greater operator ('>'). Precedence 600.
@ Subscript
Array subscripting ('[]'). Precedence hardcoded with parser.
@ Smaller
Smaller operator ('<'). Precedence 600.
@ ShiftLeft
Bitwise shifting of integral values ('<<'). Precedence 700.
@ Multiply
Arithmetic multiplication ('*'). Precedence 900.
@ BitAnd
Binary and ('&'). "and"s all bits of two integral values. Precedence 470.
@ Add
Arithmetic addition ('+'). Precedence 800.
@ ShiftRight
Bitwise shifting of integral values ('>>'). Precedence 700.
@ Equal
Equal operator ('=='). Precedence 500.
const alib::boxing::Box & Type
@ ReplaceVerbalOperatorsToLowerCase
See sibling flag ReplaceVerbalOperatorsToSymbolic.
@ ReplaceVerbalOperatorsToDefinedLetterCase
See sibling flag ReplaceVerbalOperatorsToSymbolic.
@ ReplaceVerbalOperatorsToUpperCase
See sibling flag ReplaceVerbalOperatorsToSymbolic.
@ UnknownIdentifier
Compile-time exception thrown when an expression uses an unknown identifier name.
@ UnknownFunction
Compile-time exception thrown when an expression uses an unknown function name.
@ NamedExpressionNotFound
Compile-time exception thrown when an expression refers to an unknown named nested expression.
@ UnknownBinaryOperatorSymbol
Unknown binary operator symbol found when parsing expression string.
@ UnknownUnaryOperatorSymbol
Unknown unary operator symbol found when parsing expression string.
@ EmptyExpressionString
Thrown when an empty string is tried to be compiled.
@ SyntaxErrorExpectation
Syntax error with concrete information about what the parser expected at given position.
@ SyntaxError
General error thrown by the parser.
@ Positive
'+' operator (usually returns identity value).
@ Negative
'-' operator, negates a value.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
ShutdownPhases
Termination levels usable with Bootstrapping ALib Camps.
Definition camp.inl:42
boxing::Box Box
Type alias in namespace alib.
Definition box.inl:1216
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2381
expressions::ExpressionsCamp EXPRESSIONS
The singleton instance of ALib Camp class ExpressionsCamp.
ALIB_DLL void Parse()
Implementation of EnumRecordPrototype::Parse.
String Symbol
The parable symbol of an operator.
int Precedence
The precedence of an operator in respect to other binary operators.
ALIB_DLL void Parse()
Implementation of EnumRecordPrototype::Parse.
EROperatorAlias() noexcept=default
String Replacement
The replacement operator symbol.
String Symbol
The parsable symbol of an alias operator.
void(*)(const Box &constantValue, AString &expressionString) Signature
static ALIB_DLL Box * SI[2]
Function accepts one string argument, followed by an integral argument.
static ALIB_DLL Box * FF[2]
Function accepts two floating point arguments.
static ALIB_DLL Box * B[1]
Function accepts one boolean argument.
static ALIB_DLL Box * IVar[2]
Function accepts one integral argument, followed by variadic arguments.
static ALIB_DLL Box * BB[2]
Function accepts two boolean arguments.
static ALIB_DLL Box * II[2]
Function accepts two integral arguments.
static ALIB_DLL Box * Dur[1]
Function accepts a Duration argument.
static ALIB_DLL Box * SII[3]
Function accepts one string argument, followed by two integral arguments.
static ALIB_DLL Box * SSB[3]
Function accepts two string arguments, followed by a boolean argument.
static ALIB_DLL Box * F[1]
Function accepts one floating point argument.
static ALIB_DLL Box * SVar[2]
Function accepts one string argument, followed by variadic arguments.
static ALIB_DLL Box * SS[2]
Function accepts two string arguments.
static ALIB_DLL Box * Var[1]
Function accepts variadic arguments.
static ALIB_DLL Box * DDur[2]
Function accepts a DateTime argument; followed by a Duration.
static ALIB_DLL Box * SSI[3]
Function accepts two string arguments, followed by an integral argument.
static ALIB_DLL Box * D[1]
Function accepts a DateTime argument.
static ALIB_DLL Box * SSS[3]
Function accepts three string arguments.
static ALIB_DLL Box * S[1]
Function accepts one string argument.
static ALIB_DLL Box * I[1]
Function accepts one integral argument.
static ALIB_DLL Box Duration
Sample type-box for values of type DateTime::Duration).
static ALIB_DLL Box Integer
Sample type-box for integer types. (Precisely for type integer.)
static ALIB_DLL Box Boolean
Sample type-box for C++ type bool.
static ALIB_DLL Box Void
Sample type-box for C++ type void.
static ALIB_DLL Box Float
Sample type-box for C++ type double.
static ALIB_DLL Box DateTime
Sample type-box for date and time values of type DateTime).
static ALIB_DLL Box String