This is the reference documentation of sub-namespace expressions
of the ALib C++ Library, which holds types of library module ALib Expressions.
Extensive documentation for this module is provided with ALib Module Expressions - Programmer's Manual.
Nested Namespaces: | |
namespace | detail |
namespace | plugins |
namespace | util |
Utility types of camp ALib Expressions. | |
Type Index: | |
class | Compiler |
struct | CompilerPlugin |
struct | ERBinaryOperator |
struct | EROperatorAlias |
struct | Expression |
class | ExpressionRepository |
class | ExpressionsCamp |
class | ExpressionVal |
struct | FToLiteral |
struct | Scope |
struct | ScopeResource |
struct | Signatures |
class | StandardRepository |
struct | Types |
Type Definition Index: | |
using | ArgIterator = StdVectorMono<Box>::iterator |
using | CallbackDecl = Box (*)( Scope& scope, ArgIterator argsBegin, ArgIterator argsEnd ) |
using | Type = const alib::boxing::Box& |
using ArgIterator = StdVectorMono<Box>::iterator |
Type definition for passing arguments to expression callbacks.
Definition at line 971 of file expressionscamp.hpp.
using CallbackDecl = Box (*)( Scope& scope, ArgIterator argsBegin, ArgIterator argsEnd ) |
Function pointer implementing native callback functions, for expression functions and operators. The implementations are defined and selected by the compiler plugins. They are called (executed) when an expression is evaluated.
scope | The expression's evaluation scope. | |
[out] | argsBegin | An iterator that returns Box objects. The first entry takes also the result. |
[out] | argsEnd | The end-iterator. |
Definition at line 982 of file expressionscamp.hpp.
using Type = const alib::boxing::Box& |
Type definition for passing boxes as sample types.
Definition at line 965 of file expressionscamp.hpp.
|
strong |
Bitwise enum class defining options of expression compilation. Flags defined with this type are set in field Compiler::CfgCompilation.
Enumerator | |
---|---|
DefaultUnaryOperators | If this flag is set, all unary operators given in DefaultUnaryOperators are defined with method Compiler::SetupDefaults. Note that the enumeration class is equipped with resourced ALib Enum Records, which might be changed as an alternative to clearing this flag and provide own definitions. This flag is set by default. |
DefaultBinaryOperators | If this flag is set, all binary operators given in DefaultBinaryOperators are defined with method Compiler::SetupDefaults. Note that the enumeration class is equipped with resourced ALib Enum Records, which might be changed as an alternative to clearing this flag and provide own definitions. This flag is set by default. |
DefaultAlphabeticOperatorAliases | If this flag is set, all alphabetic operator aliases given in enumerations DefaultAlphabeticUnaryOperatorAliases and DefaultAlphabeticBinaryOperatorAliases are defined with method Compiler::SetupDefaults. Note that both enumeration classes are equipped with resourced ALib Enum Records, which might be changed as an alternative to clearing this flag and provide own definitions. This flag is set by default. |
AlphabeticOperatorsIgnoreCase | If this flag is set, alphabetic operator aliases defined in Compiler::AlphabeticUnaryOperatorAliases and Compiler::AlphabeticBinaryOperatorAliases are parsed ignoring letter case.
This flag is set by default. |
AllowSubscriptOperator | If not set, array subscript operator Note that compiler plug-ins get the array subscript operator presented for compilation as a usual binary operator given as DefaultBinaryOperators::Subscript. This makes its support with custom types quite simple.
This flag is set by default. |
AliasEqualsOperatorWithAssignOperator | Used with constructor of compiler plug-ins plugins::Arithmetics and plugins::Strings. (If they are activated in Compiler::CfgBuiltInPlugins or "manually" added.) Denotes if the assignment operator
|
AllowBitwiseBooleanOperators | Used with constructor of compiler plug-in plugins::Arithmetics. (If it is activated in Compiler::CfgBuiltInPlugins or "manually" added.) Denotes if the unary bitwise operator |
AllowOmittingParenthesesOfParameterlessFunctions | If If
The other way round, if a function is registered as an identifier, flag AllowEmptyParenthesesForIdentifierFunctions, controls if exception Exceptions::IdentifierWithFunctionParentheses is to be thrown if empty parentheses are given on functions that are registered as identifier-style functions. |
AllowEmptyParenthesesForIdentifierFunctions | If If
|
AllowCompileTimeNestedExpressions | If this flag is set (the default), the unary nested expression operator is activated, as well as the single-parameter overload of the nested expression function. If the field is cleared, then only evaluation-time nested expressions are allowed, which is the two- and three-parameter version of the expression function. Other uses are then causing compilation exception Exceptions::UnaryOperatorNotDefined, respectively Exceptions::NestedExpressionCallArgumentMismatch. |
AllowIdentifiersForNestedExpressions | If this flag is set (the default), then identifiers that follow the unary nested expression operator (defaults to
|
CaseSensitiveNamedExpressions | If not set (the default), then names of named expressions are not distinguished by letter case. |
PluginExceptionFallThrough | Controls whether exceptions of type Note that exceptions thrown in callback functions which are evaluated at compile-time against constant parameters, are considered plug-in exceptions. |
CallbackExceptionFallThrough | This is an "evaluation-time compiler flag". If not set (the default) exceptions of type Exception and |
NoOptimization | If this flag is set, no optimizations are performed when assembling the program.
|
DEFAULT | Default value. Evaluates to: |
Definition at line 465 of file expressionscamp.hpp.
|
strong |
Arithmetical enumeration of slots used to prioritize CompilerPlugin instances attached to instances of class Compiler at run-time.
Enumerator | |
---|---|
NONE | Used to denote that no variable or plug-in was found. |
ElvisOperator | Built-in operator
|
AutoCast | Auto-cast plug-in. |
Strings | Built-in String comparison and manipulation. |
Arithmetics | Collection of built-in unary and binary operators for boolean, integer and floating point values. |
Math | Collection of built-in unary and binary operators for boolean, integer and floating point values. |
DateAndTime | Collection of date and time functions based on alib::time. |
Custom | This is where custom plug-ins usually should be placed. It gives them a higher priority than all built-in plug-ins have. |
Definition at line 172 of file expressionscamp.hpp.
|
strong |
This enumeration lists the built-in verbal alias names for binary operators.
The associated ALib Enum Records provides the operator verbs as well as the replacement operator.
Flag Compilation::DefaultAlphabeticOperatorAliases controls if method Compiler::SetupDefaults adds the aliases to the compiler.
Definition at line 410 of file expressionscamp.hpp.
|
strong |
This enumeration lists the built-in verbal alias names for unary operators.
The associated ALib Enum Records provides the operator verbs as well as the replacement operator.
Flag Compilation::DefaultAlphabeticOperatorAliases controls if method Compiler::SetupDefaults adds the aliases to the compiler.
Enumerator | |
---|---|
Not | Verbal alias |
Definition at line 396 of file expressionscamp.hpp.
|
strong |
This enumeration lists the built-in binary operators. The associated ALib Enum RecordS of type ERBinaryOperator provides an operator's symbol an its precedence.
Enumerator | |
---|---|
NONE | Not an operator. |
Subscript | Array subscripting ( |
Multiply | Arithmetic multiplication ( |
Divide | Arithmetic division ( |
Modulo | Arithmetic modulo ( |
Add | Arithmetic addition ( |
Subtract | Arithmetic subtraction ( |
ShiftLeft | Bitwise shifting of integral values ( |
ShiftRight | Bitwise shifting of integral values ( |
Smaller | Smaller operator ( |
SmallerOrEqual | Smaller or equal operator ( |
Greater | Greater operator ( |
GreaterOrEqual | Greater or equal operator ( |
Equal | Equal operator ( |
NotEqual | Not equal operator ( |
BitAnd | Binary and ( |
BitXOr | Binary xor ( |
BitOr | Binary or ( |
BoolAnd | Boolean and ( |
BoolOr | Boolean or ( |
Assign | Assignment. By default, this is used as alias operator for operator Equal by the built-in compiler plug-ins. See AliasEqualsOperatorWithAssignOperator for more information. |
Elvis | Binary version of ternary operator |
Definition at line 313 of file expressionscamp.hpp.
|
strong |
This enumeration lists the built-in unary operators. The associated ALib Enum Records provides the operator symbols.
Enumerator | |
---|---|
NONE | Not an operator. |
Positive |
|
Negative |
|
BoolNot | Boolean not ( |
BitNot | Bitwise not ( |
Indirection | Unary |
Definition at line 293 of file expressionscamp.hpp.
|
strong |
Exceptions thrown by module ALib Expressions.
Enumerator | |
---|---|
SyntaxError | General error thrown by the parser. |
ExpressionInfo | Detail entry (negative element value) used with various exceptions. Shows the expression in a first line and a marker of the syntax error position in a second. |
StdExceptionInfo | This is added to exceptions when when a |
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. |
UnknownUnaryOperatorSymbol | Unknown unary operator symbol found when parsing expression string. |
UnknownBinaryOperatorSymbol | Unknown binary operator symbol found when parsing expression string. |
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. |
FunctionHint | Optional info entry (negative element value) on a function with matching name but non-matching arguments found. |
UnaryOperatorNotDefined | Compile-time exception thrown when an unary operator is not applicable to the given argument type. |
BinaryOperatorNotDefined | Compile-time exception thrown when a binary operator is not applicable to the combination of left-hand and right-and argument type. |
MissingFunctionParentheses | Compile-time exception thrown when function parentheses are missing with parameterless functions, while flag AllowOmittingParenthesesOfParameterlessFunctions is not set in Compiler::CfgCompilation. |
IdentifierWithFunctionParentheses | Compile-time exception thrown when empty function parentheses are given with identifiers (parameterless functions), while flag AllowEmptyParenthesesForIdentifierFunctions is not set in Compiler::CfgCompilation. |
IncompatibleTypesInConditional | Compile-time exception thrown when incompatible types are given with conditional term |
ExceptionInPlugin | This is a "wrapper" exception thrown when a plug-in or a compile-time invoked callback function throws an exception of type |
ExceptionInCallback | This is a "wrapper" exception thrown when callback functions throws an exception of type |
NamedExpressionNotConstant | Compile-time exception thrown when unary expression operator is used with a non-constant nested expression name. |
NamedExpressionNotFound | Compile-time exception thrown when an expression refers to an unknown named nested expression. |
NestedExpressionNotFoundCT | Compile-time exception thrown when a named nested expression which is searched an inserted at compile-time could not be found.
|
NestedExpressionCallArgumentMismatch | Compile-time exception thrown when when wrong arguments were passed to function Compiler::CfgNestedExpressionFunction.
|
NestedExpressionNotFoundET | Evaluation-time exception thrown when a named nested expression which is searched only at evaluation-time could not be found.
|
WhenEvaluatingNestedExpression | Informational exception entry (negative element value) providing the name of the expression that caused any other exception than Note that entries of this type might be repeated when expressions are recursively nested. The number of entries in the exception corresponds to the depth of nesting. |
NestedExpressionResultTypeError | Evaluation-time exception thrown when a named nested expression which was searched and found only at evaluation-time, returned a different result type than specified.
|
CircularNestedExpressions | Evaluation-time exception thrown when a circular relationship of nested expressions is detected, which comprises an infinite loop. |
CircularNestedExpressionsInfo | A list of informational entries of this type is given with exception CircularNestedExpressions. Each entry provides the name of the expression that was evaluated and the name of the nested expression that it called. Hence, the list of entries of this type comprise the "call stack" that leaded to the circular call that caused the exception. |
InExpressionFormatter | This is an extension entry added to exceptions that occur with compilation or evaluation of expressions by class util::ExpressionFormatter. |
Definition at line 32 of file expressionscamp.hpp.
|
strong |
Bitwise enum class defining options for formatting parsed expressions. The normalized conversion of the expression input string is available with method ExpressionVal::GetNormalizedString, after an expression was successfully compiled.
The normalization flags are stored per compiler instance, consequently using a public compiler field namely Compiler::CfgNormalization.
Enumerator | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ReplaceFunctionNames | Replace given shortened and letter case mismatched identifier and function names with completed versions. | ||||||||||||||||||||||
ReplaceAliasOperators | Replace alias operators with effective operators. | ||||||||||||||||||||||
ReplaceVerbalOperatorsToSymbolic | This is one of four flags that together allow five possible normalization options for verbal alias operators. If more than one flag is set, the one with the highest precedence is used. The following table lists the flags, their precedence and the type of normalization:
With configuration DEFAULT, flag ReplaceVerbalOperatorsToUpperCase is set. | ||||||||||||||||||||||
ReplaceVerbalOperatorsToLowerCase | See sibling flag ReplaceVerbalOperatorsToSymbolic. | ||||||||||||||||||||||
ReplaceVerbalOperatorsToUpperCase | See sibling flag ReplaceVerbalOperatorsToSymbolic. | ||||||||||||||||||||||
ReplaceVerbalOperatorsToDefinedLetterCase | See sibling flag ReplaceVerbalOperatorsToSymbolic. | ||||||||||||||||||||||
QuoteUnaryNestedExpressionOperatorArgument | Converts nested expression names that have been given unquoted to a quoted string literal. If this is not set, the quotation remains as given in original expression string. This flag is not set with DEFAULT.
| ||||||||||||||||||||||
RemoveRedundantUnaryOpsOnNumberLiterals | Remove redundant provisions unary operators | ||||||||||||||||||||||
UnaryOpSpace | Write a space after an unary operator (if no brackets around arguments and no unary operator follows). | ||||||||||||||||||||||
UnaryOpSpaceIfUnaryFollows | Write a space between two unary operators. | ||||||||||||||||||||||
UnaryOpSpaceIfBracketFollows | Write a space before opening bracket of bracketed arguments of unary operators. | ||||||||||||||||||||||
UnaryOpInnerBracketSpace | Write a space after an opening and before a closing bracket of arguments of unary operators. | ||||||||||||||||||||||
RedundantBracketsBetweenTwoUnaryOps | If this flag is set, normalization inserts redundant brackets to the argument of an unary operator, if that argument is an unary operator itself. This flag is superseded by RedundantUnaryOpBrackets. | ||||||||||||||||||||||
RedundantUnaryOpBrackets | If this flag is set, normalization inserts redundant brackets to arguments of unary operators. This flag supersedes by RedundantBracketsBetweenTwoUnaryOps. | ||||||||||||||||||||||
BinaryOpSpaces | Write a space before and after binary operator symbol. | ||||||||||||||||||||||
InnerBracketSpace | Write a space after an opening and before a closing bracket of arguments of binary operators and around a conditional expression. | ||||||||||||||||||||||
OuterBracketSpace | Write a space before opening and after closing bracket of arguments of binary operators and around a conditional expression. | ||||||||||||||||||||||
RedundantRhsBracketsIfRhsIsStrongerBinaryOp | If this flag is set, normalization inserts redundant brackets to the right-hand side operand of binary operators if that operand is a binary operator itself and has a higher precedence. The following samples demonstrate why this is useful if normalization targets humans:
This flag is superseded by RedundantBinaryOpBrackets. | ||||||||||||||||||||||
RedundantBracketsIfLhsAndRhsAreBinaryOps | If this flag is set, normalization inserts redundant brackets to both operands of binary operators if both are binary operators themselves. The following samples demonstrate why this is useful if normalization strings target humans:
This flag is superseded by RedundantBinaryOpBrackets. | ||||||||||||||||||||||
RedundantBinaryOpBrackets | If this flag is set, normalization inserts redundant brackets around each binary operator sub-expression. This flag supersedes flags RedundantRhsBracketsIfRhsIsStrongerBinaryOp and RedundantBracketsIfLhsAndRhsAreBinaryOps. It is not recommended to set this flag. It is only useful to debug expressions and understand exactly what precedences operators have. This flag is set with DEFAULT. | ||||||||||||||||||||||
ConditionalOpSpaceBeforeQM | Write a space before character | ||||||||||||||||||||||
ConditionalOpSpaceAfterQM | Write a space after character | ||||||||||||||||||||||
ConditionalOpSpaceBeforeColon | Write a space before character | ||||||||||||||||||||||
ConditionalOpSpaceAfterColon | Write a space after character | ||||||||||||||||||||||
RedundantConditionalOpBrackets | If this flag is set, normalization inserts redundant brackets around the conditional operator expressions This flag is set with DEFAULT. | ||||||||||||||||||||||
FunctionSpaceBeforeOpeningBracket | Write a space before between the function identifier name and the opening bracket of the argument list. | ||||||||||||||||||||||
FunctionInnerBracketSpace | Write a space after the opening and before the closing bracket of argument list of a function. | ||||||||||||||||||||||
FunctionInnerBracketSpaceIfNoArguments | Write a space between the opening and the closing bracket of an empty argument list of a function. | ||||||||||||||||||||||
FunctionSpaceBeforeComma | Write a space before a comma of an argument separator of an function's argument list. | ||||||||||||||||||||||
FunctionSpaceAfterComma | Write a space after a comma of an argument separator of a function's argument list. | ||||||||||||||||||||||
SubscriptSpaceBeforeBrackets | Write a space before array subscript operator | ||||||||||||||||||||||
SubscriptInnerBracketSpace | Write a space after the opening and before the closing bracket of array subscript operator | ||||||||||||||||||||||
KeepScientificFormat | If this flag is set, floating point literals are normalized in scientific format when given in scientific format. If it is not set, then numbers given in scientific format might be written as usual floating point values, dependent on their value. E.g. a given Note that scientific format can be forced for all floating point number output by setting flag ForceScientific in field Flags of variable Formatter::DefaultNumberFormat, which in turn is found in member Compiler::CfgFormatter. Such setting would supersede this flag. This flag is not set with DEFAULT. | ||||||||||||||||||||||
ForceHexadecimal | If this flag is set, integral literals will be normalized to hexadecimal format. If this flag is not set, then integrals will be normalized in the number system that they had been provided in. This flags supersedes flags ForceOctal and ForceBinary. This flag is not set with DEFAULT. | ||||||||||||||||||||||
ForceOctal | If this flag is set, integral literals will be normalized to octal format. If this flag is not set, then integrals will be normalized in the number system that they had been provided in. This flags is superseded by flag ForceHexadecimal and supersedes flag ForceBinary. This flag is not set with DEFAULT. | ||||||||||||||||||||||
ForceBinary | If this flag is set, integral literals will be normalized to binary format. If this flag is not set, then integrals will be normalized in the number system that they had been provided in. This flags is superseded by flags ForceHexadecimal and ForceOctal. This flag is not set with DEFAULT. | ||||||||||||||||||||||
NONE | All flags are cleared, may be used for testing bits. | ||||||||||||||||||||||
COMPACT | All flags are cleared, hence no whitespaces and unnecessary brackets are written and identifiers as they have been given (potentially abbreviated and ignoring letter case). | ||||||||||||||||||||||
DEFAULT | Default value. Evaluates to: |
Definition at line 673 of file expressionscamp.hpp.