ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
compiler.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//==================================================================================================
8
9ALIB_EXPORT namespace alib { namespace expressions {
10
11// forwards
12namespace detail { struct Parser; }
13struct CompilerPlugin;
14
15//==================================================================================================
16/// An implementation of this abstract interface class may be attached to field
17/// \alib{expressions;Compiler::Repository} to enable an \e automated definition and retrieval
18/// of expression strings of nested expressions.
19///
20/// A default implementation, which uses typical \alib mechanics to define expression
21/// strings, is given with class \alib{expressions;StandardRepository}.
22///
23/// More information about automated nested expressions and the use of this interface class is
24/// provided with manual chapter \ref alib_expressions_nested_config.
25//==================================================================================================
27{
28 public:
29 /// Virtual destructor.
31
32 //==============================================================================================
33 /// This method is called during compilation of expressions in the case a named expression
34 /// is not found by method \alib{expressions;Compiler::GetNamed}.
35 ///
36 /// @param identifier The name of the required expression.
37 /// @param[out] target The target to write the requested expression string to.
38 /// @return \c true, if the expression string could be retrieved, \c false otherwise.
39 /// If \c true is returned and \p{target} is still empty, then the string is defined
40 /// to be empty, which throws an exception on compilation.
41 //==============================================================================================
42 virtual bool Get( const String& identifier, AString& target ) = 0;
43};
44
45//==================================================================================================
46/// This is a central class of library module \alib_expressions_nl used to compile
47/// expression strings.
48///
49/// For information about general use and features of this class consult the
50/// \ref alib::expressions "ALib Expressions User Manual".
51///
52/// ## Friends ##
53/// class \alib{expressions;ExpressionVal}
54//==================================================================================================
55class Compiler : public lang::PluginContainer<CompilerPlugin, CompilePriorities>
56{
57 #if !DOXYGEN
58 friend class ExpressionVal;
59 friend struct detail::Parser;
60 friend class detail::ProgramBase;
61 #endif
62
63 public:
64 /// Alias shortcut to the type of the plug-in vector inherited from \b %PluginContainer.
65 using Plugins= std::vector<lang::PluginContainer<CompilerPlugin, CompilePriorities>::Slot>;
66
67 // #############################################################################################
68 // internal fields
69 // #############################################################################################
70 protected:
71 /// Memory for used for permanent allocations during the set-up phase.
72 /// Later it is also used for temporary allocations during compilation and reset to its
73 /// state after setup.
75
76 /// The expression parser.
78
79 /// The map of Type names and bit flag values.
84
85 /// The map of 'named' expressions.
88 std::hash <String>,
89 std::equal_to<String> > namedExpressions;
90
91
92 // #############################################################################################
93 // Public fields
94 // #############################################################################################
95 public:
96
97 /// The list of unary operators.
98 /// To define a new unary operator, method #AddUnaryOperator should be used.
99 /// In debug-builds, the methods asserts that no double insertions are performed.
100 ///
101 /// Custom insertions may be performed before or after invoking #SetupDefaults,
102 /// but before a first expression is compiled.
103 ///
104 ///
105 /// Flag \alib{expressions;Compilation::DefaultUnaryOperators} controls if method
106 /// \b %SetupDefaults adds operators resourced with enumeration
107 /// \alib{expressions;DefaultUnaryOperators}.
109
110 /// This public map allows defining alias names for unary operators. Such names
111 /// must consist only of alphabetic characters.
112 ///
113 /// Flag \alib{expressions;Compilation::DefaultAlphabeticOperatorAliases} controls if method
114 /// #SetupDefaults adds the aliases defined with resourced data records of enumeration
115 /// \alib{expressions;DefaultAlphabeticUnaryOperatorAliases} to this map.
117 String, String,
118 alib::hash_string_ignore_case<character>,
119 alib::equal_to_string_ignore_case<character> > AlphabeticUnaryOperatorAliases;
120
121 /// This public map allows defining alias names for binary operators. Such names
122 /// must consist only of alphabetic characters.
123 ///
124 /// Flag \alib{expressions;Compilation::DefaultAlphabeticOperatorAliases} controls if method
125 /// #SetupDefaults adds the aliases defined with resourced data records of enumeration
126 /// \alib{expressions;DefaultAlphabeticBinaryOperatorAliases} to this map.
128 alib::hash_string_ignore_case<character>,
129 alib::equal_to_string_ignore_case<character> > AlphabeticBinaryOperatorAliases;
130
131 /// Adds an unary operator to this expression compiler.
132 /// This method should be invoked before invoking #SetupDefaults.
133 ///
134 /// Operator symbols must be added only once.
135 ///
136 /// @param symbol The operator symbol.
137 void AddUnaryOperator( const String& symbol )
138 {
139 #if ALIB_DEBUG
140 for( auto& op : UnaryOperators )
141 if( op.Equals<NC>( symbol ) )
142 ALIB_ASSERT_ERROR( false, "EXPR", "Unary operator '{}' already defined.",
143 symbol )
144 #endif
145 UnaryOperators.emplace_back(symbol);
146 }
147
148
149 /// The list of binary operators. The map stores the precedences.
150 ///
151 /// To define a new binary operator, entry may be added before invoking #SetupDefaults
152 /// using method #AddBinaryOperator.
153 ///
154 /// Flag \alib{expressions;Compilation::DefaultUnaryOperators} controls if method
155 /// \b %SetupDefaults adds operators resourced with enumeration
156 /// \alib{expressions;DefaultBinaryOperators}.
158
159 /// Adds a binary operator to this expression compiler.
160 /// This method should be invoked before invoking #SetupDefaults.
161 ///
162 /// Operator symbols must be added only once.
163 ///
164 /// @param symbol The operator symbol.
165 /// @param precedence The precedence of the operator.
166 void AddBinaryOperator( const String& symbol, int precedence )
167 {
168 ALIB_DBG( auto result= )
169 BinaryOperators.EmplaceOrAssign(symbol, precedence);
170 ALIB_ASSERT_ERROR( result.second == true, "EXPR", // was inserted
171 "Binary operator '{}' already defined.", symbol )
172 }
173
174 /// Returns the precedence of given operator \b symbol.
175 ///
176 /// @param symbol The operator symbol.
177 /// @return The precedence of the operator as defined with #AddBinaryOperator.
179 {
180 // search in operator table first
181 auto it= BinaryOperators.Find( symbol );
182 if( it != BinaryOperators.end() )
183 return it.Mapped();
184
185 // have an alias?
186 auto aliasOp= AlphabeticBinaryOperatorAliases.Find( symbol );
187 ALIB_ASSERT_ERROR( aliasOp != AlphabeticBinaryOperatorAliases.end(), "EXPR",
188 "Unknown binary operator '{}'.", symbol )
189
190 it= BinaryOperators.Find( aliasOp.Mapped() );
191 ALIB_ASSERT_ERROR( it != BinaryOperators.end(), "EXPR",
192 "Unknown binary operator '{}' which was aliased by '{}'.",
193 aliasOp->second, symbol )
194 return it.Mapped();
195 }
196
197
198 /// \alib{enumops;BitwiseTraits;Bitwise enum class} that lists the plug-ins built-into
199 /// \alib expression library. This bitfield is used with method #SetupDefaults, which
200 /// reads the flags set in #CfgBuiltInPlugins and installs the plug-ins accordingly.
201 enum class BuiltInPlugins
202 {
203 NONE = 0, ///< Installs no plug-in.
204 ALL = -1, ///< Installs all plug-ins.
205 ElvisOperator = (1 << 1), ///< Installs \alib{expressions;plugins::ElvisOperator}.
206 AutoCast = (1 << 2), ///< Installs \alib{expressions;plugins::AutoCast}.
207 Arithmetics = (1 << 3), ///< Installs \alib{expressions;plugins::Arithmetics}.
208 Math = (1 << 4), ///< Installs \alib{expressions;plugins::Math}.
209 Strings = (1 << 5), ///< Installs \alib{expressions;plugins::Strings}.
211 DateAndTime = (1 << 6), ) ///< Installs \alib{expressions;plugins::DateAndTime}. )
212 };
213
214
215 /// Bitfield that defines the built-in compiler plug-ins that are created and inserted
216 /// by method #SetupDefaults.
217 ///
218 /// Defaults to \alib{expressions::Compiler;BuiltInPlugins::ALL}
219 ///
220 /// \note
221 /// The built-in plug-ins are allowed to be shared by different compiler instances.
222 /// To reach that, they must not be disabled here (or method #SetupDefaults must be
223 /// omitted) and instead created once and registered with the compiler using
224 /// inherited method \alib{lang::PluginContainer::InsertPlugin}. In that case, parameter
225 /// \p{responsibility} of that method has to be provided as
226 /// \c Responsibility::KeepWithSender.
228
229 /// The operator defined in this public field is used to address nested expressions.
230 /// The operator used can be customized to any defined (!) unary operator.
231 ///
232 /// To disable nested expression parsing, change to empty or \e nulled string.
233 ///
234 /// \note
235 /// If changed, the change hast to be made \b before invoking #SetupDefaults. Otherwise,
236 /// the default configuration for
237 /// \ref alib_expressions_operators_verbal "verbal operator aliases" would be set in
238 /// effect to a wrong (or disabled) target operator.
239 ///
240 /// Defaults to \c "*".
241 ///
242 /// \see Manual chapter \ref alib_expressions_nested "10. Nested Expressions".
243 ///
245
246 /// Name descriptor for nested expression function.
247 /// Defaults to "Expression" with a minimum abbreviation of \c 4 characters, ignoring letter
248 /// case.<br>
249 /// Resourced with the key \c "EF"
250 ///
251 /// \see Manual chapter \ref alib_expressions_nested "10. Nested Expressions".
253
254 /// Keyword used with optional third parameter of expression function.
255 /// Defaults to \c "throw". Resourced with key \c "EF"
256 ///
257 /// \see Manual chapter \ref alib_expressions_nested "10. Nested Expressions".
259
260 /// Compilation flags.
262
263 /// Flags that allow to tweak the result of the normalization of the originally parsed
264 /// expression string.
266
267 /// This list is used with the normalization of the expression string. It contains
268 /// strings, which are not allowed to appear in normalized expression strings.
269 ///
270 /// In the current library version, such strings might occur only if flags
271 /// \alib{expressions;Normalization::UnaryOpSpace},
272 /// \alib{expressions;Normalization::UnaryOpSpaceIfUnaryFollows} or
273 /// \alib{expressions;Normalization::BinaryOpSpaces} are not set.
274 /// As a sample see expression:
275 ///
276 /// 1 - -2
277 ///
278 /// If no space is written after binary operators, this expression would be normalized
279 /// to:
280 /// 1--2
281 ///
282 /// While this just looks irritating to a homo sapiens, it would be even illegal if
283 /// well known C++ operator <c>--</c> was supported. Therefore, string <c>"--"</c> is added
284 /// to this map in method #SetupDefaults, which forces the normalization logic to insert
285 /// a space, even if spaces are otherwise configured to be omitted.
287
288 /// Formatter used throughout all phases of the life-cycle of an expression:
289 /// - Used for parsing expression strings (Using the encapsulated
290 /// \alib{strings;TNumberFormat;NumberFormat} object. This is also the reason, why the type
291 /// of formatter is \b %Formatter and not its more abstract base \b %Formatter.)
292 /// - Used for the generation of the normalized expression strings.
293 /// - Used for the generation of constant string objects during compilation.
294 /// - Used for the generation of string objects during evaluation.
295 ///
296 /// For the latter two, a copy of the pointer is provided through field
297 /// \doxlinkproblem{structalib_1_1expressions_1_1Scope.html;aebf2cd4ff8a2611de06368fccfd3ef5b;Scope::Formatter;expressions::Scope::Formatter}.
298 /// It is important not to change the formatting parameters in between the creation of the
299 /// compile-time scope and the creation of the evaluation-time scope. If done,
300 /// the expression results could differ when optimizations during compilation are performed.
301 ///
302 /// In the constructor of this class, a \alib{format;Formatter::Clone;clone} of the
303 /// \alib {format::Formatter;Default;default formatter} is copied here.
305
306 /// Optional pointer to a default or custom implementation of a repository that provides
307 /// expression strings for named nested expressions.
308 ///
309 /// \see Manual chapter \ref alib_expressions_nested_config.
311
312 // #############################################################################################
313 // Public Interface
314 // #############################################################################################
315 public:
316 //==========================================================================================
317 /// Constructor. Construction usually is three steps:
318 /// 1. Create class instance
319 /// 2. Set the various configuration options (fields prefixed <c>Cfg</c>).
320 /// 3. Invoke #SetupDefaults.
321 //==========================================================================================
323
324 //==========================================================================================
325 /// Destructor
326 //==========================================================================================
328 virtual ~Compiler();
329
330 //==========================================================================================
331 /// Registers a (custom) type name with this compiler. The name will be used to
332 /// display a type name to end-users, for example, when malformed expressions throw an
333 /// exception.
334 ///
335 /// The built-in types get registered in the constructor of the compiler, where the
336 /// type names are read from the \alib{resources;ResourcePool} of static library object
337 /// \alib{EXPRESSIONS}.
338 ///
339 /// It is recommended that custom plug-ins invoke this method in their constructor.
340 ///
341 /// \note
342 /// There is no general need to register types for using them
343 /// with \alib_expressions_nl. Parameter \p{name} of this method is exclusively
344 /// used to generate textual, human-readable output!
345 ///
346 /// @param sample A \ref alib_expressions_prereq_sb "sample value"
347 /// of the type, which is implicitly boxed when passed.
348 /// @param name The name of the type.
349 //==========================================================================================
351 void AddType(Type sample, const NString& name);
352
353 //==========================================================================================
354 /// Returns the name of the type of the boxed value.
355 /// Note that custom types need to be registered with method #AddType.
356 ///
357 /// If given argument \p{box} is \ref alib_boxing_more_void_void "a void box", the returned
358 /// string is <b>"NONE"</b>.
359 ///
360 /// @param box The box to receive the type name for.
361 /// @return The type name as string.
362 //==========================================================================================
364 NString TypeName(Type box);
365
366 //==========================================================================================
367 /// Writes the signature of a function (as for example found in
368 /// \alib{expressions::plugins;Calculus::FunctionEntry}) to a string buffer.
369 ///
370 /// @param boxArray The start of the array of pointers.
371 /// @param qty The array's length.
372 /// @param target The string to write into.
373 //==========================================================================================
375 void WriteFunctionSignature( Box** boxArray, size_t qty, AString& target );
376
377 //==========================================================================================
378 /// Writes the signature of an argument list to a string buffer.
379 ///
380 /// @param begin Iterator to the first argument.
381 /// @param end End-iterator.
382 /// @param target The string to write into.
383 //==========================================================================================
386 ArgIterator end,
387 AString& target );
388
389 //==========================================================================================
390 /// Completes construction according to configuration options provided with fields
391 /// prefixed <c>Cfg</c>.
392 /// In detail, the following actions are performed:
393 /// - If flag \alib{expressions;Compilation::DefaultUnaryOperators} is set in field
394 /// #CfgCompilation, then
395 /// - the unary operators listed in the \ref alib_enums_records "enum records" of
396 /// \alib{expressions;DefaultUnaryOperators} are added using #AddUnaryOperator.
397 /// - If flag \alib{expressions;Compilation::DefaultAlphabeticOperatorAliases} is set in
398 /// field #CfgCompilation, then the alphabetic alias names found in
399 /// the data records of enumeration
400 /// \alib{expressions;DefaultAlphabeticUnaryOperatorAliases}
401 /// are set in field #AlphabeticUnaryOperatorAliases. (As of the current version this
402 /// is only the token \b NOT aliasing operator <b>"!"</b>.
403 /// - If flag \alib{expressions;Compilation::DefaultBinaryOperators} is set in field
404 /// #CfgCompilation, then
405 /// - the binary operators listed in the data records of enumeration
406 /// \alib{expressions;DefaultBinaryOperators} are added using #AddBinaryOperator.
407 /// - If flag \alib{expressions;Compilation::AllowSubscriptOperator} is not set, the
408 /// subscript operator is omitted.
409 /// - If flag \alib{expressions;Compilation::DefaultAlphabeticOperatorAliases} is set in
410 /// field #CfgCompilation, then the alphabetic alias names found in
411 /// the data records of enumeration
412 /// \alib{expressions;DefaultAlphabeticBinaryOperatorAliases}
413 /// are set in field #AlphabeticBinaryOperatorAliases. (As of the current version this
414 /// is only the token \b NOT aliasing operator <b>"!"</b>.
415 /// - Strings <b>"++"</b> and <b>"--"</b> are added to field #CfgNormalizationDisallowed
416 /// to prevent the unintentional creation of these potential operators in normalizations.
417 /// (This way, a space character will be added between binary <b>"+"</b> and unary
418 /// <b>"+"</b>, respectively binary <b>"-"</b> and unary <b>"-"</b> operators,
419 /// even if the normalization options do not suggest to do this.
420 /// - Depending on the flags set in #CfgBuiltInPlugins, the plug-ins listed in
421 /// enumeration #BuiltInPlugins are created and added.
422 //==========================================================================================
424 void SetupDefaults();
425
426 //==========================================================================================
427 /// Firstly, this method parses the given expression string thereby builds an intermediate
428 /// internal \alib{expressions;detail::AST;abstract syntax tree}.
429 /// This tree is then translated into a \alib{expressions;detail::Program} which evaluates
430 /// the expression in respect to a \alib{expressions;Scope} when executed.
431 ///
432 /// For building the program, attached \alib{expressions;CompilerPlugin} instances
433 /// are queried.
434 ///
435 /// During this process, a \alib{expressions;Normalization;normalized} version of the input
436 /// string is always created. While the original input string can
437 /// be accessed with \alib{expressions;ExpressionVal::GetOriginalString}, the normalized version
438 /// can be retrieved after the compilation with method
439 /// \alib{expressions;ExpressionVal::GetNormalizedString}. During compilation, the normalization
440 /// rules (flags) stored in field #CfgNormalization are applied.
441 ///
442 /// For compilation, a compile-time scope object is created by calling virtual method
443 /// #createCompileTimeScope. If not overwritten, a standard scope object is used.
444 /// If custom callbacks exists that are invokable at compile-time
445 /// (to perform program optimization) and that at the same time rely on custom mechanics
446 /// provided with a custom scope class, then a custom, derived version of this class
447 /// has to be used that overrides method #createCompileTimeScope accordingly.
448 ///
449 /// @param expressionString The string to parse.
450 /// @return A shared pointer to the compiled expression. Contains \c nullptr on failure.
451 //==========================================================================================
452 virtual ALIB_DLL
453 Expression Compile( const String& expressionString );
454
455 //==========================================================================================
456 /// Compiles the given \p{expressionString} and adds a compiled expression to the map of
457 /// named expressions.
458 ///
459 /// @param name The name used to map the expression.
460 /// @param expressionString The string to parse.
461 /// If nulled, entry \p{name} is removed (if existing).
462 /// @return \c true if an expression with the same named existed and was replaced.
463 /// Otherwise, returns \c false.
464 //==========================================================================================
465 virtual ALIB_DLL
466 bool AddNamed( const String& name, const String& expressionString );
467
468 //==========================================================================================
469 /// Removes a named expression. This is just a shortcut to #AddNamed, providing
470 /// a nulled string for parameter \p{expressionString}.
471 ///
472 /// @param name The name of the expression to be removed.
473 /// @return \c true if an expression with the given name existed and was removed.
474 /// Otherwise, returns \c false.
475 //==========================================================================================
476 bool RemoveNamed( const String& name )
477 {
478 return AddNamed( name, NULL_STRING );
479 }
480
481 //==========================================================================================
482 /// Returns a named expression previously defined using #AddNamed.
483 /// In the case that no expression with the given \p{name} was defined and optional interface
484 /// #Repository is set, then this interface is used to retrieve a corresponding expression
485 /// string and compile the named expression 'on the fly'.
486 ///
487 /// \see
488 /// Manual chapter \ref alib_expressions_nested_config.
489 ///
490 /// @param name The name of the expression.
491 /// @return In case of success a shared pointer to the expression.
492 //==========================================================================================
493 virtual ALIB_DLL
494 Expression GetNamed( const String& name );
495
496 /// Provides access to the internal \alib{MonoAllocator}.
497 /// \note This method is deemed non-standard use of this class and the using code needs to
498 /// knowing what to do.
499 /// @return The internal monotonous allocator.
501
502 // #############################################################################################
503 // Protected Interface
504 // #############################################################################################
505 protected:
506 //==========================================================================================
507 /// This virtual method is called by #Compile to create the scope object used
508 /// for allocations that are made for intermediate results at compile-time.
509 ///
510 /// Compile-time allocations occur when expression terms that use purely constant arguments
511 /// are evaluated at compile-time. Such optimization consequently leads to the invocation
512 /// of callback functions at compile-time.
513 ///
514 /// If now, custom callback functions rely on custom allocation mechanics, provided with
515 /// custom scope types, then this method has to be overridden to return such a custom
516 /// scope object.
517 ///
518 /// @param expressionAllocator The allocator of the expression used to allocate the
519 /// compile-time scope.
520 /// @return The default implementation returns the standard scope object.
521 /// For its construction, the field #CfgFormatter is provided.<br>
522 /// Derived compilers may need to return a scope object of a derived type.
523 //==========================================================================================
524 virtual ALIB_DLL
525 Scope* createCompileTimeScope(MonoAllocator& expressionAllocator);
526
527 //==========================================================================================
528 /// Implements \alib{expressions;ExpressionVal::GetOptimizedString}.
529 ///
530 /// @param expression the expression to generate an optimized string for.
531 //==========================================================================================
534};
535
536
537
538namespace detail {
539 /// Base class exported by the main module \implude{Expressions} for technical reasons.
541 protected:
542 /// Friendship-access method used by derived implementation.
543 /// @param ev The expression to receive protected data from.
544 /// @return The expression's allocotor.
546
547 /// Friendship-access method used by derived implementation.
548 /// @param ev The expression to receive protected data from.
549 /// @return The expression's compile-time scope.
551
552 /// Friendship-access method used by derived implementation.
553 /// @param cmp The compiler to receive protected data from.
554 /// @return The compiler's plugins.
556 };
557
558 /// Base class exported by the main module \implude{Expressions} for technical reasons.
560 protected:
561 /// Friendship-access method used by derived implementation.
562 /// @param ev The expression to receive protected data from.
563 /// @return The expression's compile-time scope.
564 static Scope* getExpressionCTScope (ExpressionVal& ev) { return ev.ctScope; }
565 };
566
567
568}
569
570} // namespace alib[::expressions]
571
572DOX_MARKER([DOX_MANUAL_ALIASES_COMPILER])
573/// Type alias in namespace \b alib.
575
576} // namespace [alib]
577DOX_MARKER([DOX_MANUAL_ALIASES_COMPILER])
578
580
bool RemoveNamed(const String &name)
Definition compiler.inl:476
Normalization CfgNormalization
Definition compiler.inl:265
Compilation CfgCompilation
Compilation flags.
Definition compiler.inl:261
List< MonoAllocator, String > UnaryOperators
Definition compiler.inl:108
virtual ALIB_DLL Expression Compile(const String &expressionString)
Definition compiler.cpp:246
ALIB_DLL NString TypeName(Type box)
Definition compiler.cpp:436
StringVectorMA CfgNormalizationDisallowed
Definition compiler.inl:286
ALIB_DLL void WriteFunctionSignature(Box **boxArray, size_t qty, AString &target)
Definition compiler.cpp:450
virtual ALIB_DLL Expression GetNamed(const String &name)
Definition compiler.cpp:394
BuiltInPlugins CfgBuiltInPlugins
Definition compiler.inl:227
void AddBinaryOperator(const String &symbol, int precedence)
Definition compiler.inl:166
std::vector< lang::PluginContainer< CompilerPlugin, CompilePriorities >::Slot > Plugins
Alias shortcut to the type of the plug-in vector inherited from PluginContainer.
Definition compiler.inl:65
strings::util::Token CfgNestedExpressionFunction
Definition compiler.inl:252
virtual ALIB_DLL bool AddNamed(const String &name, const String &expressionString)
Definition compiler.cpp:360
ExpressionRepository * Repository
Definition compiler.inl:310
ALIB_DLL void getOptimizedExpressionString(ExpressionVal &expression)
Definition compiler.cpp:332
HashMap< MonoAllocator, String, int > BinaryOperators
Definition compiler.inl:157
ALIB_DLL void SetupDefaults()
Definition compiler.cpp:167
void AddUnaryOperator(const String &symbol)
Definition compiler.inl:137
@ AutoCast
Installs plugins::AutoCast.
Definition compiler.inl:206
@ IF_ALIB_CAMP
Installs plugins::DateAndTime. )
Definition compiler.inl:210
@ Arithmetics
Installs plugins::Arithmetics.
Definition compiler.inl:207
@ Strings
Installs plugins::Strings.
Definition compiler.inl:209
@ ElvisOperator
Installs plugins::ElvisOperator.
Definition compiler.inl:205
detail::Parser * parser
The expression parser.
Definition compiler.inl:77
virtual ALIB_DLL Scope * createCompileTimeScope(MonoAllocator &expressionAllocator)
Definition compiler.cpp:161
ALIB_DLL void AddType(Type sample, const NString &name)
Definition compiler.cpp:428
HashMap< MonoAllocator, AString, Expression, std::hash< String >, std::equal_to< String > > namedExpressions
The map of 'named' expressions.
Definition compiler.inl:89
HashMap< MonoAllocator, String, String, alib::hash_string_ignore_case< character >, alib::equal_to_string_ignore_case< character > > AlphabeticUnaryOperatorAliases
Definition compiler.inl:119
MonoAllocator & GetAllocator()
Definition compiler.inl:500
HashMap< MonoAllocator, lang::TypeFunctors::Key, NAString, lang::TypeFunctors::Hash, lang::TypeFunctors::EqualTo > typeMap
The map of Type names and bit flag values.
Definition compiler.inl:83
int GetBinaryOperatorPrecedence(const String &symbol)
Definition compiler.inl:178
virtual ALIB_DLL ~Compiler()
Destructor.
Definition compiler.cpp:155
HashMap< MonoAllocator, String, String, alib::hash_string_ignore_case< character >, alib::equal_to_string_ignore_case< character > > AlphabeticBinaryOperatorAliases
Definition compiler.inl:129
virtual bool Get(const String &identifier, AString &target)=0
virtual ~ExpressionRepository()
Virtual destructor.
Definition compiler.inl:30
Base class exported by the main module ALib.Expressions.H for technical reasons.
Definition compiler.inl:540
Scope * getExpressionCTScope(ExpressionVal &ev)
Definition compiler.inl:550
MonoAllocator & getExpressionAllocator(ExpressionVal &ev)
Definition compiler.inl:545
Compiler::PluginList & getCompilerPlugins(Compiler &cmp)
Definition compiler.inl:555
PluginList plugins
The plug-ins we have attached in descending priority order.
Definition plugins.inl:97
#define ALIB_DLL
Definition alib.inl:496
#define ALIB_ENUMS_MAKE_BITWISE(TEnum)
#define A_CHAR(STR)
#define ALIB_EXPORT
Definition alib.inl:488
#define ALIB_DBG(...)
Definition alib.inl:836
#define ALIB_ASSERT_ERROR(cond, domain,...)
Definition alib.inl:1049
@ DateAndTime
Collection of date and time functions based on alib::time.
StdVectorMono< Box >::iterator ArgIterator
const alib::boxing::Box & Type
constexpr String NULL_STRING
A nulled string of the default character type.
Definition string.inl:2463
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
strings::util::TStringVector< character, MonoAllocator > StringVectorMA
Type alias in namespace alib.
strings::TString< nchar > NString
Type alias in namespace alib.
Definition string.inl:2390
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace alib.
containers::HashMap< TAllocator, TKey, TMapped, THash, TEqual, THashCaching, TRecycling > HashMap
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
boxing::Box Box
Type alias in namespace alib.
Definition box.inl:1216
containers::SharedPtr< format::Formatter > SPFormatter
Definition formatter.inl:42
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2381
expressions::Compiler Compiler
Type alias in namespace alib.
Definition compiler.inl:574
containers::List< TAllocator, T, TRecycling > List
Type alias in namespace alib.
Definition list.inl:746
This detail class constitutes an abstract base class for expression parsers.
Definition parser.inl:15
Base class exported by the main module ALib.Expressions.H for technical reasons.
Definition compiler.inl:559
static Scope * getExpressionCTScope(ExpressionVal &ev)
Definition compiler.inl:564
Comparison functor for type const std::type_info*.
Hash code functor for type const std::type_info*.
const ::std::type_info * Key
The key type.