ALib C++ Library
Library Version: 2511 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 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 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 /// Implementation of \alib{enumrecords;EnumRecordPrototype::Parse}.
368 void Parse();
369};
370
371
372//==================================================================================================
373/// This enumeration lists the built-in verbal alias names for unary operators.
374///
375/// The associated \ref alib_enums_records "ALib Enum Records" provides the operator verbs
376/// as well as the replacement operator.
377///
378/// Flag \alib{expressions;Compilation::DefaultAlphabeticOperatorAliases} controls if method
379/// \alib{expressions;Compiler::SetupDefaults} adds the aliases to the compiler.
380//==================================================================================================
382{
383 Not , ///< Verbal alias \c "Not" to operator <c>'!'</c>.
384};
385
386//==================================================================================================
387/// This enumeration lists the built-in verbal alias names for binary operators.
388///
389/// The associated \ref alib_enums_records "ALib Enum Records" provides the operator verbs
390/// as well as the replacement operator.
391///
392/// Flag \alib{expressions;Compilation::DefaultAlphabeticOperatorAliases} controls if method
393/// \alib{expressions;Compiler::SetupDefaults} adds the aliases to the compiler.
394//==================================================================================================
396{
397 And , ///< Verbal alias \c "And" to boolean and operator <c>'&&'</c>.
398 Or , ///< Verbal alias \c "Or" to boolean or operator <c>'||'</c>.
399 Sm , ///< Verbal alias \c "Sm" to operator <c>'<'</c>.
400 Smaller , ///< Verbal alias \c "Smaller" to operator <c>'<'</c>.
401 SmEq , ///< Verbal alias \c "Smeq" to operator <c>'<='</c>.
402 SmallerOrEqual , ///< Verbal alias \c "Smaller_or_equal" to operator <c>'<='</c>.
403 Gt , ///< Verbal alias \c "Gt" to operator <c>'>'</c>.
404 Greater , ///< Verbal alias \c "Greater" to operator <c>'>'</c>.
405 GtEq , ///< Verbal alias \c "Gteq" to operator <c>'>='</c>.
406 GreaterOrEqual , ///< Verbal alias \c "Greater_or_equal" to operator <c>'>='</c>.
407 Eq , ///< Verbal alias \c "Eq" to operator <c>'=='</c>.
408 Equals , ///< Verbal alias \c "Equals" to operator <c>'=='</c>.
409 NEq , ///< Verbal alias \c "Neq" to operator <c>'!='</c>.
410 NotEqual , ///< Verbal alias \c "Not_equals" to operator <c>'!='</c>.
411};
412
413//==================================================================================================
414/// \ref alib_enums_records "ALib Enum Record" associated with enumeration
415/// \alib{expressions;DefaultBinaryOperators}.
416//==================================================================================================
418{
419 /// The parsable symbol of an alias operator.
421
422 /// The replacement operator symbol.
424
425 /// Required default constructor leaving the record undefined.
426 /// (Requirement is documented with\alib{enumrecords::EnumRecordPrototype}.)
427 EROperatorAlias() noexcept =default;
428
429 /// Required initializing constructor.
430 /// (Requirement is documented with\alib{enumrecords::EnumRecordPrototype}.)
431 ///
432 /// @param symbol The parsable operator symbol.
433 /// @param replacement The symbol of the aliased operator.
434 EROperatorAlias( const String& symbol, const String& replacement )
435 : Symbol (symbol)
436 , Replacement(replacement) {}
437
438 /// Implementation of \alib{enumrecords;EnumRecordPrototype::Parse}.
440 void Parse();
441};
442
443
444
445//==================================================================================================
446/// \alib{enumops;BitwiseTraits;Bitwise} enum class defining options of expression compilation.
447/// Flags defined with this type are set in field \alib{expressions;Compiler::CfgCompilation}.
448//==================================================================================================
449enum class Compilation
450{
451 /// If this flag is set, all unary operators given in \alib{expressions;DefaultUnaryOperators}
452 /// are defined with method \alib{expressions;Compiler::SetupDefaults}.
453 ///
454 /// Note that the enumeration class is equipped with resourced
455 /// \ref alib_enums_records "ALib Enum Records", which might be changed as an
456 /// alternative to clearing this flag and provide own definitions.
457 ///
458 /// This flag is set by default.
460
461 /// If this flag is set, all binary operators given in \alib{expressions;DefaultBinaryOperators}
462 /// are defined with method \alib{expressions;Compiler::SetupDefaults}.
463 ///
464 /// Note that the enumeration class is equipped with resourced
465 /// \ref alib_enums_records "ALib Enum Records", which might be changed as an
466 /// alternative to clearing this flag and provide own definitions.
467 ///
468 /// This flag is set by default.
470
471 /// If this flag is set, all alphabetic operator aliases given in enumerations
472 /// \alib{expressions;DefaultAlphabeticUnaryOperatorAliases} and
473 /// \alib{expressions;DefaultAlphabeticBinaryOperatorAliases}
474 /// are defined with method \alib{expressions;Compiler::SetupDefaults}.
475 ///
476 /// Note that both enumeration classes are equipped with resourced
477 /// \ref alib_enums_records "ALib Enum Records", which might be changed as an
478 /// alternative to clearing this flag and provide own definitions.
479 ///
480 /// This flag is set by default.
482
483 /// If this flag is set, alphabetic operator aliases defined in
484 /// \alib{expressions;Compiler::AlphabeticUnaryOperatorAliases} and
485 /// \alib{expressions;Compiler::AlphabeticBinaryOperatorAliases} are parsed ignoring letter
486 /// case.
487 ///
488 /// \note
489 /// Even when this flag is cleared, no two verbal operator aliases that are equal
490 /// when case is ignored must be defined (e.g "or" and "OR" ).
491 ///
492 /// This flag is set by default.
494
495 /// If not set, array subscript operator <c>[]</c> is not supported and its use will cause
496 /// parse errors errors.
497 ///
498 /// Note that compiler plug-ins get the array subscript operator presented for compilation
499 /// as a usual binary operator given as \alib{expressions;DefaultBinaryOperators::Subscript}.
500 /// This makes its support with custom types quite simple.
501 ///
502 /// \attention This flag has to be changed to a custom state before performing the first
503 /// compilation of an expression with a dedicated \alib{expressions;Compiler}.
504 /// The rationale behind this is, that the compiler creates the parser system at its
505 /// first use, which in turn does not check the flag after creation.
506 ///
507 /// This flag is set by default.
509
510 /// Used with constructor of compiler plug-ins
511 /// \alib{expressions;plugins::Arithmetics} and
512 /// \alib{expressions;plugins::Strings}.
513 /// (If they are activated in \alib{expressions;Compiler::CfgBuiltInPlugins} or "manually"
514 /// added.)
515 ///
516 /// Denotes if the assignment operator <c>=</c> is an alias for equal operator <c>==</c>.
517 /// If set to \c false, the use of the <c>=</c> operator with several any argument type,
518 /// throws a compilation exception, unless it is compiled by a custom plug-in.
519 ///
520 /// \attention
521 /// In addition to aliasing the <c>==</c> with <c>=</c>, the latter also receives a
522 /// higher precedence of parsing! If this flag is not set, the precedence of
523 /// \e assign <c>=</c>,follows the C++ standards and thus is below the group of
524 /// <c>&</c>, <c>^</c>, <c>|</c>, <c>&&</c>, <c>||</c> and <c>? :</c>. If the alias
525 /// setting is activated, then the precedence is raised to be on the same level as
526 /// boolean equal <c>==</c> and thus higher than the aforementioned operators!
528
529 /// Used with constructor of compiler plug-in \alib{expressions;plugins::Arithmetics}.
530 /// (If it is activated in \alib{expressions;Compiler::CfgBuiltInPlugins} or "manually" added.)
531 ///
532 /// Denotes if the unary bitwise operator <c>~</c> and binary bitwise operators
533 /// <c>&</c>, <c>|</c> and <c>^</c> should be allowed for boolean values.
534 /// If set to \c false, the use of the bitwise operators with boolean arguments, throws
535 /// a compilation exception, unless the bitwise operators are compiled by a custom plug-in.
537
538
539 /// If \c false, compile-time exception
540 /// \alib{expressions;Exceptions::MissingFunctionParentheses} is thrown if a parameterless
541 /// function is stated without (otherwise redundant) parentheses <c>'()'</c>.
542 ///
543 /// If \c true, this is tolerated.
544 ///
545 /// \note
546 /// This flag is not tested, and the exception is not thrown, by the compiler itself, but
547 /// by class \alib{expressions::plugins;Calculus}.<br>
548 /// Even if this flag is \c false, still functions without parentheses may be allowed
549 /// by setting \c nullptr to field
550 /// \doxlinkproblem{structalib_1_1expressions_1_1plugins_1_1Calculus_1_1FunctionEntry;a3f9769a430a930630a75d41bc7e4055c;Calculus::FunctionEntry::Signature}
551 /// when registering a function. In this case the function is considered rather being an
552 /// "identifier" than a function. (Still it is the very same as a function, it is just a
553 /// matter of wording here.)<br>
554 ///
555 /// The other way round, if a function is registered as an identifier, flag
556 /// \b %AllowEmptyParenthesesForIdentifierFunctions, controls if exception
557 /// \alib{expressions;Exceptions::IdentifierWithFunctionParentheses} is to be thrown
558 /// if empty parentheses are given on functions that are registered as
559 /// identifier-style functions.
561
562 /// If \c false, compile-time exception
563 /// \alib{expressions;Exceptions::IdentifierWithFunctionParentheses} is thrown if a
564 /// parameterless function, declared as 'identifier style' is used with parentheses
565 /// <c>'()'</c>.
566 ///
567 /// If \c true, this is tolerated.
568 ///
569 /// \see
570 /// For more information, see the note in documentation of flag
571 /// \b %AllowOmittingParenthesesOfParameterlessFunctions.
573
574 /// If this flag is set (the default), the
575 /// \alib{expressions;Compiler::CfgNestedExpressionOperator;unary nested expression operator}
576 /// is activated, as well as the single-parameter overload of the
577 /// \alib{expressions;Compiler::CfgNestedExpressionFunction;nested expression function}.
578 /// If the field is cleared, then only evaluation-time nested expressions are allowed,
579 /// which is the two- and three-parameter version of the expression function.
580 /// Other uses are then causing compilation exception
581 /// \alib{expressions;Exceptions::UnaryOperatorNotDefined}, respectively
582 /// \alib{expressions;Exceptions::NestedExpressionCallArgumentMismatch}.
584
585 /// If this flag is set (the default), then identifiers that follow the unary nested
586 /// expression operator (defaults to <c>'*'</c>), are internally converted to corresponding
587 /// string literals - just as if they were given as a quoted string.
588 ///
589 /// \see
590 /// Normalization flag
591 /// \alib{expressions::Normalization;QuoteUnaryNestedExpressionOperatorArgument}.
593
594 /// If not set (the default), then names of named expressions are not distinguished by
595 /// letter case.
597
598 /// Controls whether exceptions of type \c std::exception thrown in plug-ins during compilation
599 /// are caught by the compiler and transformed to \alib{expressions;Exceptions::ExceptionInPlugin}
600 ///
601 /// Note that exceptions thrown in callback functions which are evaluated at compile-time
602 /// against constant parameters, are considered plug-in exceptions.
604
605
606 /// This is an "evaluation-time compiler flag". If not set (the default) exceptions of type
607 /// \alib{exceptions;Exception} and \c std::exception thrown in callback functions during expression
608 /// evaluation are caught and transformed to \alib{expressions;Exceptions::ExceptionInCallback}
609 /// letter case.
611
612 /// If this flag is set, no optimizations are performed when assembling the program.
613 ///
614 /// \note
615 /// There is absolutely no reason for setting this flag, other than for running the
616 /// unit tests. Or for playing with the little virtual machine implemented with this
617 /// library and having fun understanding the non-optimized program listings generated.
618 /// The assembly language is easy, it has only four virtual assembly commands - plus a fifth
619 /// for invoking programs of nested expressions.
620 NoOptimization = (1 << 20),
621
622
623 /// Default value. Evaluates to:<br>
624 /// <c> DefaultUnaryOperators + </c><br>
625 /// <c> DefaultBinaryOperators + </c><br>
626 /// <c> DefaultAlphabeticOperatorAliases + </c><br>
627 /// <c> AlphabeticOperatorsIgnoreCase + </c><br>
628 /// <c> AliasEqualsOperatorWithAssignOperator + </c><br>
629 /// <c> AllowBitwiseBooleanOperators + </c><br>
630 /// <c> AllowSubscriptOperator + </c><br>
631 /// <c> AllowOmittingParenthesesOfParameterlessFunctions + </c><br>
632 /// <c> AllowEmptyParenthesesForIdentifierFunctions + </c><br>
633 /// <c> AllowCompileTimeNestedExpressions + </c><br>
634 /// <c> AllowIdentifiersForNestedExpressions + </c><br>
646};
647
648//==================================================================================================
649/// \alib{enumops;BitwiseTraits;Bitwise} enum class defining options for formatting parsed
650/// expressions. The normalized conversion of the expression input string is available
651/// with method \alib{expressions;ExpressionVal::GetNormalizedString}, after an expression was
652/// successfully \alib{expressions;Compiler::Compiler;compiled}.
653///
654/// The normalization flags are stored per compiler instance, consequently using a public compiler
655/// field namely \alib{expressions;Compiler::CfgNormalization}.
656//==================================================================================================
657enum class Normalization : uint64_t
658{
659 /// Replace given shortened and letter case mismatched identifier and function names with
660 /// completed versions.<br>
661 /// This flag is set with \b %DEFAULT.
662 ReplaceFunctionNames = (1LLU << 1),
663
664 /// Replace alias operators with effective operators.<br>
665 /// This flag is not set with \b %DEFAULT.
667
668 /// This is one of four flags that together allow five possible normalization options for
669 /// \ref alib_expressions_operators_verbal "verbal alias operators".
670 /// If more than one flag is set, the one with the highest precedence is used.
671 ///
672 /// The following table lists the flags, their precedence and the type of normalization:
673 ///
674 /// |Precedence | Flag | Description
675 /// |------------|----------------------------------|------------------------------
676 /// | 0 | <none set> | A verbal operator is normalized as given in original expression string.
677 /// | 1 | ReplaceVerbalOperatorsToSymbolic | Replaces verbal operators with the symbolic operator that they represent.
678 /// | 2 | ReplaceVerbalOperatorsToLowerCase | Converts verbal operators to lower case letters.
679 /// | 3 | ReplaceVerbalOperatorsToUpperCase | Converts verbal operators to upper case letters.
680 /// | 4 | ReplaceVerbalOperatorsToDefinedLetterCase | Uses the writing specified with the definition of the verbal operator.
681 ///
682 /// With configuration \alib{expressions::Normalization;DEFAULT}, flag
683 /// \b %ReplaceVerbalOperatorsToUpperCase is set.
685
686 /// See sibling flag \alib{expressions::Normalization;ReplaceVerbalOperatorsToSymbolic}.
688
689 /// See sibling flag \alib{expressions::Normalization;ReplaceVerbalOperatorsToSymbolic}.
691
692 /// See sibling flag \alib{expressions::Normalization;ReplaceVerbalOperatorsToSymbolic}.
694
695 /// Converts nested expression names that have been given unquoted to a quoted string literal.
696 /// If this is not set, the quotation remains as given in original expression string.
697 /// This flag is \e not set with \b %DEFAULT.
698 ///
699 /// \see
700 /// Compilation flag
701 /// \alib{expressions::Compilation;AllowIdentifiersForNestedExpressions}.
703
704 /// Remove redundant provisions unary operators <c>'+'</c> and <c>'-'</c> from number
705 /// literals.<br>
706 /// This flag is \e not set with \b %DEFAULT.
708
709 /// Write a space after an unary operator (if no brackets around arguments and no unary operator
710 /// follows).<br>
711 /// This flag is \e not set with \b %DEFAULT.
712 UnaryOpSpace = (1LLU << 9),
713
714 /// Write a space between two unary operators.<br>
715 /// This flag is \e not set with \b %DEFAULT.
717
718 /// Write a space before opening bracket of bracketed arguments of unary operators.<br>
719 /// This flag is \e not set with \b %DEFAULT.
721
722 /// Write a space after an opening and before a closing bracket of arguments of unary operators.<br>
723 /// This flag is \e not set with \b %DEFAULT.
725
726 /// If this flag is set, normalization inserts redundant brackets to the argument of an
727 /// unary operator, if that argument is an unary operator itself.
728 ///
729 /// This flag is superseded by \b %RedundantUnaryOpBrackets.<br>
730 /// This flag is \e not set with \b %DEFAULT.
732
733 /// If this flag is set, normalization inserts redundant brackets to arguments of unary
734 /// operators.
735 ///
736 /// This flag supersedes by \b %RedundantBracketsBetweenTwoUnaryOps.<br>
737 /// This flag is \e not set with \b %DEFAULT.
739
740
741 /// Write a space before and after binary operator symbol.<br>
742 /// This flag is set with \b %DEFAULT.
743 BinaryOpSpaces = (1LLU << 15),
744
745 /// Write a space after an opening and before a closing bracket of arguments of binary
746 /// operators and around a conditional expression.<br>
747 /// This flag is \e not set with \b %DEFAULT.
748 InnerBracketSpace = (1LLU << 16),
749
750 /// Write a space before opening and after closing bracket of arguments of binary
751 /// operators and around a conditional expression.<br>
752 /// This flag is \e not set with \b %DEFAULT.
753 OuterBracketSpace = (1LLU << 17),
754
755 /// If this flag is set, normalization inserts redundant brackets to the right-hand side
756 /// operand of binary operators if that operand is a binary operator itself and has a higher
757 /// precedence.
758 ///
759 /// The following samples demonstrate why this is useful if normalization targets humans:
760 ///
761 /// Without flag set | With flag set
762 /// ---------------------|----------------------
763 /// 1 - 2 - 3 | <em>no change</em>
764 /// 1 - 2 * 3 | 1 - (2 * 3)
765 /// 1 * 2 - 3 | <em>no change</em>
766 /// 1 - 2 * 3 - 4 - 5 * 6 - 7 | 1 - (2 * 3) - 4 - (5 * 6) - 7
767 /// true == false && true | <em>no change</em>
768 /// true && false == true | true && (false == true)
769 /// true && false == false && true | true && (false == false) && true
770 /// true && false == (false && true) | true && (false == (false && true))
771 /// true && false == true < false | true && (false == (true < false))
772 /// true && false == false == true | true && (false == false == true)
773 /// This flag is superseded by \b %RedundantBinaryOpBrackets.<br>
774 /// This flag is set with \b %DEFAULT.
776
777 /// If this flag is set, normalization inserts redundant brackets to both
778 /// operands of binary operators if both are binary operators themselves.
779 ///
780 /// The following samples demonstrate why this is useful if normalization strings target humans:
781 ///
782 /// Without flag set | With flag set
783 /// ---------------------|----------------------
784 /// 1 - 2 - 3 | <em>no change</em>
785 /// 1 - 2 - 3 - 4 | <em>no change</em>
786 /// 1 - 2 - (3 - 4) | (1 - 2) - (3 - 4)
787 /// 1 - 2 - 3 - (4 - 5) | (1 - 2 - 3) - (4 - 5)
788 /// 1 - 2 - (3 - 4) - 5 | (1 - 2) - (3 - 4) - 5
789 ///
790 /// This flag is superseded by \b %RedundantBinaryOpBrackets.<br>
791 /// This flag is set with \b %DEFAULT.
793
794 /// If this flag is set, normalization inserts redundant brackets around each binary operator
795 /// sub-expression. This flag supersedes flags
796 /// \b %RedundantRhsBracketsIfRhsIsStrongerBinaryOp and
797 /// \b %RedundantBracketsIfLhsAndRhsAreBinaryOps.
798 ///
799 /// It is not recommended to set this flag. It is only useful to debug expressions and
800 /// understand exactly what precedences operators have.
801 ///
802 /// This flag is set with \b %DEFAULT.
804
805
806 /// Write a space before character <c>?</c> of ternary conditional operator.<br>
807 /// This flag is set with \b %DEFAULT.
809
810 /// Write a space after character <c>?</c> of a ternary conditional operator.<br>
811 /// This flag is set with \b %DEFAULT.
813
814 /// Write a space before character <c>:</c> of ternary conditional operator.<br>
815 /// This flag is set with \b %DEFAULT.
817
818 /// Write a space after character <c>:</c> of ternary conditional operator.<br>
819 /// This flag is set with \b %DEFAULT.
821
822 /// If this flag is set, normalization inserts redundant brackets around the conditional
823 /// operator expressions <c>Q ? T : F</c>, if it is not the root node.
824 ///
825 /// This flag is set with \b %DEFAULT.
827
828 /// Write a space before between the function identifier name and the opening bracket of the
829 /// argument list.<br>
830 /// This flag is \e not set with \b %DEFAULT.
832
833 /// Write a space after the opening and before the closing bracket of argument list of a
834 /// function.<br>
835 /// This flag is set with \b %DEFAULT.
837
838 /// Write a space between the opening and the closing bracket of an empty argument list of a
839 /// function.<br>
840 /// This flag is set with \b %DEFAULT.
842
843 /// Write a space before a comma of an argument separator of an function's argument list.<br>
844 /// This flag is \e not set with \b %DEFAULT.
846
847 /// Write a space after a comma of an argument separator of a function's argument list.<br>
848 /// This flag is set with \b %DEFAULT.
850
851 /// Write a space before array subscript operator <c>'[]'</c>.<br>
852 /// This flag is \e not set with \b %DEFAULT.
854
855 /// Write a space after the opening and before the closing bracket of array subscript operator
856 /// <c>'[]'</c>.<br>
857 /// This flag is \e not set with \b %DEFAULT.
859
860
861 /// If this flag is set, floating point literals are normalized in scientific format when
862 /// given in scientific format. If it is not set, then numbers given in scientific format
863 /// might be written as usual floating point values, dependent on their value. E.g.
864 /// a given <c>1.0e1</c> would be converted to <c>10.0</c>.
865 ///
866 /// Note that scientific format can be forced for all floating point number output by setting
867 /// flag \alib{strings;NumberFormatFlags;ForceScientific} in field
868 /// \alib{strings::NumberFormat;Flags} of variable
869 /// \alib{format;Formatter::DefaultNumberFormat}, which in turn is found
870 /// in member \alib{expressions;Compiler::CfgFormatter}. Such setting would supersede
871 /// this flag.
872 ///
873 /// This flag is \e not set with \b %DEFAULT.
874 KeepScientificFormat = (1LLU << 33 ),
875
876 /// If this flag is set, integral literals will be normalized to hexadecimal format.
877 /// If this flag is not set, then integrals will be normalized in the number system that they had
878 /// been provided in.
879 ///
880 /// This flags supersedes flags \b %ForceOctal and \b %ForceBinary.
881 ///
882 /// This flag is \e not set with \b %DEFAULT.
883 ForceHexadecimal = (1LLU << 34 ),
884
885 /// If this flag is set, integral literals will be normalized to octal format.
886 /// If this flag is not set, then integrals will be normalized in the number system that they had
887 /// been provided in.
888 ///
889 /// This flags is superseded by flag \b %ForceHexadecimal and supersedes flag \b %ForceBinary.
890 ///
891 /// This flag is \e not set with \b %DEFAULT.
892 ForceOctal = (1LLU << 35 ),
893
894 /// If this flag is set, integral literals will be normalized to binary format.
895 /// If this flag is not set, then integrals will be normalized in the number system that they had
896 /// been provided in.
897 ///
898 /// This flags is superseded by flags \b %ForceHexadecimal and \b %ForceOctal.
899 ///
900 /// This flag is \e not set with \b %DEFAULT.
901 ForceBinary = (1LLU << 36 ),
902
903 /// All flags are cleared, may be used for testing bits.
904 NONE = 0L,
905
906 /// All flags are cleared, hence no whitespaces and unnecessary brackets are written and
907 /// identifiers as they have been given (potentially abbreviated and ignoring letter case).
909
910 /// Default value. Evaluates to:<br>
911 /// <c>ReplaceFunctionNames + </c><br>
912 /// <c>ReplaceVerbalOperatorsToUpperCase + </c><br>
913 /// <br>
914 /// <c>RemoveRedundantUnaryOpsOnNumberLiterals + </c><br>
915 /// <c>BinaryOpSpaces + </c><br>
916 /// <c>RedundantRhsBracketsIfRhsIsStrongerBinaryOp + </c><br>
917 /// <c>RedundantBracketsIfLhsAndRhsAreBinaryOps + </c><br>
918 /// <br>
919 /// <c>ConditionalOpSpaceBeforeQM + </c><br>
920 /// <c>ConditionalOpSpaceBeforeColon + </c><br>
921 /// <c>ConditionalOpSpaceAfterQM + </c><br>
922 /// <c>ConditionalOpSpaceAfterColon + </c><br>
923 /// <c>RedundantConditionalOpBrackets + </c><br>
924 /// <br>
925 /// <c>FunctionInnerBracketSpace + </c><br>
926 /// <c>FunctionSpaceAfterComma + </c><br>
929
934
940
943};
944
945/// Type definition for passing boxes as sample types.
946///
947/// \see For more information, see
948/// \ref alib_expressions_prereq_sb "3.2 Type definitions With Sample Boxes".
950
951/// Type definition for passing arguments to expression callbacks.
952///
953/// \see For more information, see
954/// \ref alib_expressions_prereq_sb "3.2 Type definitions With Sample Boxes".
955using ArgIterator= StdVectorMA<Box>::iterator;
956
957/// Function pointer implementing native callback functions, for expression functions and
958/// operators. The implementations are defined and selected by the compiler plugins.
959/// They are called (executed) when an expression is evaluated.
960///
961/// @param scope The expression's evaluation scope.
962/// @param[out] argsBegin An iterator that returns \b %Box objects.
963/// The first entry takes also the result.
964/// @param[out] argsEnd The end-iterator.
965///
966using CallbackDecl = Box (*)( Scope& scope, ArgIterator argsBegin, ArgIterator argsEnd );
967
968
969/// This struct constitutes a type declaration for a \ref alib_boxing_functions "box-function".
970/// The function is used to create parsable expression "literals" from constant values of custom
971/// type stored in boxes.
972///
973/// The function is used by the library if all of the following occurs:
974/// - If custom identifiers, functions or operator callback functions return a custom type.
975/// - If such types can be constants and are announced to the compiler as such.
976/// - If method \alib{expressions;ExpressionVal::GetOptimizedString} is called.
977/// - If such string is to be used as input to compiling expressions.
978///
979/// If the last condition is met, compilation of the "normalized optimized expression string " would
980/// fail. If it is not met, then without a proper implementation of this function, the only
981/// "damage" is that such string would show an integral value where a constant custom type was
982/// expected.
983///
984/// The challenge of implementing this box-function for a custom type, is to convert constants of
985/// custom types back into a normalized, human-readable but also compilable expression string.
986/// As the expression syntax only defines the built-in literal types
987/// \alib{expressions::Types;Integer}, \alib{expressions::Types;Float} and
988/// \alib{expressions::Types;String}, the constants have to be created using either appropriate
989/// custom identifiers or "constructor functions" that have to be provided in addition along with
990/// the implementation of this box-function to make it compilable.
991///
992/// A sample for that situation is given in chapter \ref alib_expressions_details_optimizations_norm
993/// of the Programmer's Manual.
994///
995/// The identifiers and constructor functions in turn need to be compile-time evaluatable
996/// to ensure that recompiling the optimized string results to constants so that the same
997/// optimized expression program is generated..
998///
999/// #### Sample: ####
1000/// So far, this probably sounded a little complicated. Let us look step by step at the sample
1001/// given in the aforementioned manual section, that is solved internally by the library using
1002/// this box-function declaration.
1003///
1004/// %Compiler plug-in \alib{expressions::plugins;DateAndTime} introduces \alib class
1005/// \alib{time;TimePointBase::Duration} to expressions. This is, for example, done by defining
1006/// identifiers as follows:
1007///
1008/// \snippet "plugins/dateandtime.cpp" DOX_EXPR_FToLiteral_1
1009///
1010/// The "constructor functions" are declared to be
1011/// \alib{expressions::plugins;Calculus::CTI;compile-time invokable}
1012/// and return a constant value at compile-time in case their input parameter is constant.
1013/// When the program - that may due to optimization not contain the identifiers anymore - becomes
1014/// de-compiled, these constants have to be written to the normalized expression string in a way that
1015/// corresponding constant values of type \b %Duration are expressed.
1016///
1017/// To perform this task, an implementation of the box-function that this struct declares
1018/// has to be registered with boxes containing values of \b TimePointBase::Duration.<br>
1019/// Registrations of box-functions have to be done in the \ref alib_mod_bs "bootstrap"
1020/// code of the library. In this case it is done in static method
1021/// \alib{expressions;plugins::DateAndTime::Bootstrap}.
1022/// The function name that is used for the implementation is \b %FToLiteral_Duration. Here is
1023/// the line of code that registers the function with the boxed type:
1024///
1025/// \snippet "expressions/plugins/dateandtime.cpp" DOX_EXPR_FToLiteral_2
1026///
1027/// The implementation is given in an anonymous namespace of the compilation unit of compiler plug-in
1028/// \b %DateAndTime. The function's signature has to meet the one given with type definition #Signature
1029/// of this struct. Besides the first parameter that passes the box that the function is invoked
1030/// on (the one containing the constant value of custom type), second parameter \p{expressionString}
1031/// provides the \b AString that the function is requested to write the "generation expression" to.<br>
1032/// The implementation code looks as follows:
1033///
1034/// \snippet "expressions/plugins/dateandtime.cpp" DOX_EXPR_FToLiteral_3
1035///
1036/// As it can be understood from the code, the interface implementation tries to find the best
1037/// matching "constructor function" for the time span given, writes its name and the constant parameter
1038/// enclosed by brackets \c "()".
1039///
1040/// Only with such interface implementation in place - one that covers all possible constants - this
1041/// library is able to create <b>parsable, normalized, optimized expression strings</b>.
1042/// To finalize this example, we check what the result for three sample expressions looks like:
1043///
1044/// \snippet "DOX_EXPRESSIONS_TUT_WONO-100.txt" OUTPUT
1045/// \snippet "DOX_EXPRESSIONS_TUT_WONO-101.txt" OUTPUT
1046/// \snippet "DOX_EXPRESSIONS_TUT_WONO-102.txt" OUTPUT
1047///
1048/// \note
1049/// When integrating module \alib_expressions_nl into software, a decision has to be
1050/// taken: "Should optimized expression strings be presented to the end-user?"<br>
1051///
1052/// \note
1053/// While it is obvious, that sample two demonstrates that to be useful, sample three probably
1054/// demonstrates the opposite!<br>
1055/// It is important to understand, that the decision depends on the custom use case, where for
1056/// example the technical understanding of a typical end-user may be taken into account.
1057///
1058/// \note
1059/// If the decision is taken, \b not to present optimized expression strings to the end-user, this
1060/// has absolutely no influence on the evaluation performance: The compilation of all three
1061/// expression strings, namely
1062/// - the original input,
1063/// - the normalized output and
1064/// - the optimized, normalized output,
1065/// \note
1066/// are leading to the very same (optimized) internal program when compiled!
1067///
1068/// \note
1069/// Of course, if no optimization strings are presented to the end-user and hence are not
1070/// recompiled (or copy/pasted by such users), then the implementation of this box-function is
1071/// not needed for your custom type, as it is only invoked with method
1072/// \alib{expressions;ExpressionVal::GetOptimizedString}!
1074{
1075 /// Signature of the invokable function.
1076 ///
1077 /// @param constantValue The constant program value that is about to be written into
1078 /// \p{expressionString}.
1079 /// @param expressionString The expression string that is currently generated.
1080 using Signature = void (*) ( const Box& constantValue, AString& expressionString );
1081};
1082
1083
1084//==================================================================================================
1085/// The module class for module \alib_expressions_nl.
1086///
1087/// This is a strict singleton class. The only instance found with namespace variable
1088/// \ref alib::EXPRESSIONS.
1089//==================================================================================================
1091{
1092 public:
1093 /// Constructor.<br>
1094 /// While this is public, it must not be invoked as this is a strict singleton type.
1095 /// (See notes in \ref alib_camp_camp).
1097
1098 protected:
1099 /// Initializes this camp.
1100 virtual void Bootstrap() override;
1101
1102 /// Terminates this camp. (Nothing to do.)
1103 /// @param phase The shutdown phase to perform.
1104 virtual void Shutdown( ShutdownPhases phase ) override { (void) phase; }
1105
1106}; // class ExpressionsCamp
1107
1108} // namespace alib[::expressions]
1109
1110/// The singleton instance of \alibcamp class \alib{expressions;ExpressionsCamp}.
1111extern ALIB_DLL expressions::ExpressionsCamp EXPRESSIONS;
1112
1113} // namespace [alib]
1114
1116
1120
1128
virtual void Shutdown(ShutdownPhases phase) override
virtual void Bootstrap() override
Initializes this camp.
#define ALIB_DLL
Definition alib.inl:503
#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:497
#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
@ 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.
StdVectorMA< Box >::iterator ArgIterator
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:1149
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2189
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