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