ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
ast.cpp
1//##################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2025 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6//##################################################################################################
7#include "alib_precompile.hpp"
8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
10#endif
11#if ALIB_C20_MODULES
12 module;
13#endif
14//========================================= Global Fragment ========================================
17
18//============================================== Module ============================================
19#if ALIB_C20_MODULES
20 module ALib.Expressions.Impl;
21 import ALib.Characters.Functions;
22 import ALib.Strings;
23#else
25#endif
26//========================================== Implementation ========================================
27namespace alib { namespace expressions { namespace detail {
28
29
30
31//##################################################################################################
32// Anonymous helpers
33//##################################################################################################
34//! @cond NO_DOX
35namespace {
36
37const String normSpace(A_CHAR(" "));
38const String normBracketOpen [4] {A_CHAR("("), A_CHAR("( "), A_CHAR(" ("), A_CHAR(" ( ")};
39const String normBracketClose[4] {A_CHAR(")"), A_CHAR(" )"), A_CHAR(") "), A_CHAR(" ) ")};
40
41#define SPACE(flag) ( HasBits(format, Normalization::flag ) ? normSpace : EMPTY_STRING )
42#define COND_SPACE(flag, force) if( HasBits(format, Normalization::flag ) || force ) normalized << ' '
43
44void checkForbiddenStrings( Compiler& compiler , AString& normalized,
45 integer positionToCheck, integer spaceInsertionPos ) {
46 for( auto& it : compiler.CfgNormalizationDisallowed )
47 if( it.Length() > spaceInsertionPos
48 && normalized.ContainsAt( it, positionToCheck ) )
49 {
50 normalized.InsertAt( A_CHAR(" "), positionToCheck + spaceInsertionPos );
51 return;
52} }
53} // anonymous namespace
54//! @endcond
55
56//##################################################################################################
57// Optimize implementations
58//##################################################################################################
59AST* ASTLiteral ::Optimize( Normalization ) { return this; }
61AST* ASTFunction ::Optimize( Normalization normalization ) {
62 for( auto& arg : Arguments )
63 arg= arg->Optimize( normalization );
64 return this;
65}
66
68 Lhs= Lhs->Optimize( normalization );
69 Rhs= Rhs->Optimize( normalization );
70 return this;
71}
72
74 Q= Q->Optimize( normalization );
75 T= T->Optimize( normalization );
76 F= F->Optimize( normalization );
77 return this;
78}
79
80
81
83 Argument= Argument->Optimize( normalization );
84
85 if( HasBits( normalization, Normalization::RemoveRedundantUnaryOpsOnNumberLiterals ) ) {
86 if( Argument->NodeType == Types::Literal && (Operator == A_CHAR("+") || Operator == A_CHAR("-")) ) {
87 ASTLiteral* astLiteral= dynamic_cast<ASTLiteral*>( Argument );
88
89 if( astLiteral->Value.IsType<integer>() ) {
90 if( Operator.CharAtStart<NC>() == '-' )
91 astLiteral->Value= - astLiteral->Value.Unbox<integer>();
92 Argument= nullptr;
93 return astLiteral;
94 }
95
96 if( astLiteral->Value.IsType<double>() ) {
97 if( Operator.CharAtStart<NC>() == '-' )
98 astLiteral->Value= - astLiteral->Value.Unbox<double>();
99 Argument= nullptr;
100 return astLiteral;
101 } } }
102
103 return this;
104}
105
106
107
108//##################################################################################################
109// Assemble implementations
110//##################################################################################################
111
112void ASTLiteral::Assemble( Program& program, MonoAllocator&, AString & normalized ) {
113 integer idxInNormalized= normalized.Length();
114
115 auto* func= Value.GetFunction<FToLiteral>( lang::Reach::Local );
116 if( func ) {
117 Value.CallDirect <FToLiteral>( func, normalized );
118 }
119 else if( Value.IsType<String>() ) {
120 normalized << '"';
121 integer startExternalization= normalized.Length();
122 normalized << Value;
123 normalized << Escape( lang::Switch::On, startExternalization );
124 normalized << '"';
125 }
126 else if( Value.IsType<double>() ) {
128 auto oldFlags= nf->Flags;
131 nf->Flags+= NumberFormatFlags::ForceScientific;
132
133 normalized << alib::Dec( Value.Unbox<double>(), &program.compiler.CfgFormatter->DefaultNumberFormat);
134 nf->Flags= oldFlags;
135 }
136 else if( Value.IsType<integer>() ) {
140 else if( HasBits(program.compiler.CfgNormalization, Normalization::ForceOctal ) )
142 else if( HasBits(program.compiler.CfgNormalization, Normalization::ForceBinary ) )
144
146 integer value= Value.Unbox<integer>();
147 if( format == NFHint::Hexadecimal ) normalized << nf->HexLiteralPrefix << Hex(uint64_t(value), 0, nf );
148 else if( format == NFHint::Octal ) normalized << nf->OctLiteralPrefix << Oct(uint64_t(value), 0, nf );
149 else if( format == NFHint::Binary ) normalized << nf->BinLiteralPrefix << Bin(uint64_t(value), 0, nf );
150 else normalized << Dec(value, 0, nf);
151 }
152 else
153 normalized << Value;
154
155 program.AssembleConstant( Value, Position, idxInNormalized );
156}
157
158void ASTIdentifier::Assemble( Program& program, MonoAllocator&, AString & normalized ) {
159 auto format= program.compiler.CfgNormalization;
160
161 String64 identifier;
163 identifier << Name;
164
165 program.AssembleFunction( identifier, true, 0, Position, normalized.Length() );
166
167 normalized << (HasBits( format, Normalization::ReplaceFunctionNames ) ? identifier : Name);
168}
169
170
171void ASTFunction::Assemble( Program& program, MonoAllocator& allocator, AString& normalized ) {
172 auto format= program.compiler.CfgNormalization;
173 String64 functionName;
175
176 bool completeIdentifierNames= HasBits( format, Normalization::ReplaceFunctionNames );
177 functionName << Name;
178
179 integer namePos= normalized.Length();
180 normalized << functionName;
181 integer nameLen= normalized.Length() - namePos;
182 normalized << SPACE(FunctionSpaceBeforeOpeningBracket);
183
184 int qtyArgs= int(Arguments.size());
185
186 // the function used for nested expressions?
187 bool replacedNestedExpressionIdentifierByLiteral= false;
188 bool thirdArgumentIsThrowIdentifier= false;
190 if( qtyArgs < 1 || qtyArgs > 3 ) {
193 }
194
195 // if an identifier is given for the first argument, we optionally convert the identifier
196 // to a string value.
198 && (*Arguments.begin())->NodeType == Types::Identifier )
199 {
200 ASTIdentifier* astIdentifier= dynamic_cast<ASTIdentifier*>( *Arguments.begin() );
201 ASTLiteral* astLiteral = allocator().New<ASTLiteral>( astIdentifier->Name, astIdentifier->Position );
202 *Arguments.begin()= astLiteral;
203 replacedNestedExpressionIdentifierByLiteral= true;
204 }
205
206 // if third parameter given it must be an identifier and equal to "throw"
207 if( qtyArgs == 3 ) {
208 auto argIt= Arguments.begin();
209 ++argIt;
210 ++argIt;
211 if( (*argIt)->NodeType != Types::Identifier
212 || !dynamic_cast<ASTIdentifier*>( (*argIt) )->Name.Equals<NC, lang::Case::Ignore>(
214 {
217 }
218 thirdArgumentIsThrowIdentifier= true;
219 } }
220
221
222 if( qtyArgs > 0 ) {
223 normalized << '(' << SPACE(FunctionInnerBracketSpace);
224 int no= -1;
225 for( auto* argAst : Arguments ) {
226 ++no;
227 if( no==0 ) {
228 // optionally remove quotes if we previously converted an identifier to string-type
229 if( replacedNestedExpressionIdentifierByLiteral
231 {
232 {
233 ALIB_STRING_RESETTER(normalized);
234 argAst->Assemble( program, allocator, normalized );
235 }
236 normalized << dynamic_cast<ASTLiteral*>(argAst)->Value.Unbox<String>();
237 continue;
238 } }
239 else
240 normalized << SPACE(FunctionSpaceBeforeComma) << ',' << SPACE(FunctionSpaceAfterComma);
241
242 if( no != 2 || !thirdArgumentIsThrowIdentifier )
243 argAst->Assemble( program, allocator, normalized );
244 else
245 normalized << program.compiler.CfgNestedExpressionThrowIdentifier;
246 }
247 normalized << SPACE(FunctionInnerBracketSpace) << ')';
248 }
249 else
251 ? A_CHAR("()") : A_CHAR("( )") );
252
253
254 program.AssembleFunction( functionName, false, qtyArgs, Position, namePos );
255 if( completeIdentifierNames )
256 normalized.ReplaceSubstring<NC>( functionName, namePos, nameLen );
257}
258
259
260void ASTUnaryOp::Assemble( Program& program, MonoAllocator& allocator, AString & normalized ) {
261 auto format= program.compiler.CfgNormalization;
262 String op= Operator;
263
264 bool isVerbalOp= isalpha(op.CharAtStart());
265
266
267 // if a) this is the unary operator used for nested expressions
268 // and b) an identifier terminal follows, we optionally convert the identifier to a string
269 // value.
270 bool replacedNestedExpressionIdentifierByLiteral= false;
272 String nonVerbalOp;
273 if( !isVerbalOp )
274 nonVerbalOp= op;
275 else {
276 auto it= program.compiler.AlphabeticUnaryOperatorAliases.Find(op);
277 if( it != program.compiler.AlphabeticUnaryOperatorAliases.end() )
278 nonVerbalOp= it.Mapped();
279 else
280 nonVerbalOp= EMPTY_STRING;
281 }
282
283 if( program.compiler.CfgNestedExpressionOperator == nonVerbalOp
284 && Argument->NodeType == Types::Identifier )
285 {
286 ASTIdentifier* astIdentifier= dynamic_cast<ASTIdentifier*>( Argument );
287 ASTLiteral* astLiteral = allocator().New<ASTLiteral>(astIdentifier->Name, astIdentifier->Position );
288 Argument= astLiteral;
289 replacedNestedExpressionIdentifierByLiteral= true;
290 } }
291
292 //------------------------------------- normal unary operators -----------------------------------
293 auto opIdx= normalized.Length();
294 normalized << op;
295 auto opLen= normalized.Length() - opIdx;
296
297 // args in brackets if its a binary or ternary expression (-> if it has lower precedence)
298 bool brackets= HasBits(format, Normalization::RedundantUnaryOpBrackets)
299 || ( Argument->NodeType == Types::UnaryOp
301 || Argument->NodeType == Types::BinaryOp
302 || Argument->NodeType == Types::TernaryOp;
303
304 bool opSpaceIfNotVerbal= !brackets
306 : HasBits(format, Normalization::UnaryOpSpace ) );
307 normalized << ( brackets
308 ? normBracketOpen[ HasBits(format, Normalization::UnaryOpInnerBracketSpace )
310 : String( (opSpaceIfNotVerbal || isVerbalOp ) ? A_CHAR(" ") : A_CHAR("") )
311 );
312
313 // recursion
314 integer lenBeforeArgument= normalized.Length();
315 Argument->Assemble( program, allocator, normalized );
316
317 // optionally remove quotes if we previously converted an identifier to string-type
318 if( replacedNestedExpressionIdentifierByLiteral
320 {
321 normalized.ShortenTo( lenBeforeArgument );
322 normalized << dynamic_cast<ASTLiteral*>( Argument )->Value.Unbox<String>();
323 }
324
325 if( brackets )
326 normalized << normBracketClose[HasBits(format, Normalization::UnaryOpInnerBracketSpace )];
327
328 // check plugins
329 program.AssembleUnaryOp( op, Position, opIdx );
330
331 // did the compiler plug-in replace the operator (was given an alias operator)?
332 if( op != Operator || isVerbalOp ) {
333 if( isVerbalOp ) {
334 // replace in any case: class program would have changed the op only if the corresponding
335 // flags had been set:
336 normalized.ReplaceSubstring<NC>( op, opIdx, opLen );
337 opLen= op.Length();
338
339 // we have to check only two of four format flags here, the rest was is (was) done in program
343 for( integer i= opIdx ; i < opIdx + opLen ; ++i )
345 ? characters::ToLower( normalized[i] )
346 : characters::ToUpper( normalized[i] );
347
348 // remove space that was inserted for non-verbal op, if op is now symbolic
349 if( !opSpaceIfNotVerbal && !isalpha(op.CharAtStart() ) )
350 normalized.Delete( opIdx + opLen, 1 );
351
352 }
353
354 else if( HasBits(format, Normalization::ReplaceAliasOperators ) ) {
355 normalized.ReplaceSubstring<NC>( op, opIdx, opLen );
356 opLen= op.Length();
357 } }
358
359
360 // check if a forbidden string occurred due to writing operator with no spaces/brackets and
361 // the subsequent writing of probably nested unary operators, negative literals, etc.
362 checkForbiddenStrings( program.compiler, normalized, opIdx, opLen );
363}
364
365
366void ASTBinaryOp::Assemble( Program& program, MonoAllocator& allocator, AString & normalized ) {
367 auto format= program.compiler.CfgNormalization;
368 String op= Operator;
369
370 //------------ Special treatment for subscript operator (needs different normalization) ----------
371 if( op == A_CHAR("[]") ) {
372 // LHS recursion
373 Lhs->Assemble( program, allocator, normalized );
374
375 COND_SPACE(SubscriptSpaceBeforeBrackets, false);
376 normalized << '[';
377
378
379 // RHS recursion
380 COND_SPACE(SubscriptInnerBracketSpace, false );
381 auto opIdx= normalized.Length();
382 Rhs->Assemble( program, allocator, normalized );
383 COND_SPACE(SubscriptInnerBracketSpace, false );
384 normalized << ']';
385
386 // check plugins
387 program.AssembleBinaryOp( op, Position, opIdx );
388
389 return;
390 }
391
392 // Add brackets for LHS, if one of the two is true for it:
393 // - it is a ternary op (always has lower precedence)
394 // - it is a binary op with lower precedence
395 // In the case that operators precedences are equal, we do not need brackets, as the
396 // left-hand side is parsed first.
397 int precedence= program.compiler.GetBinaryOperatorPrecedence( Operator );
398 int lhsBinaryPrecedence= Lhs->NodeType == Types::BinaryOp
399 ? program.compiler.GetBinaryOperatorPrecedence(dynamic_cast<ASTBinaryOp*>( Lhs )->Operator)
400 : 0;
401 int rhsBinaryPrecedence= Rhs->NodeType == Types::BinaryOp
402 ? program.compiler.GetBinaryOperatorPrecedence(dynamic_cast<ASTBinaryOp*>( Rhs )->Operator)
403 : 0;
404
405
406 bool lhsBrackets= Lhs->NodeType == Types::TernaryOp
407 || ( lhsBinaryPrecedence
409 || precedence > lhsBinaryPrecedence
411 && rhsBinaryPrecedence )
412 )
413 );
414
415 int bracketStringIdx= (HasBits(format, Normalization::InnerBracketSpace ) +
417
418 // LHS recursion
419 if( lhsBrackets ) normalized << normBracketOpen[bracketStringIdx];
420 Lhs->Assemble( program, allocator, normalized );
421 if( lhsBrackets ) normalized << normBracketClose[bracketStringIdx];
422
423 bool isVerbalOp= isalpha(op.CharAtStart());
424
425 COND_SPACE( BinaryOpSpaces, isVerbalOp );
426 auto opIdx= normalized.Length();
427 normalized << op;
428 auto opLen= normalized.Length() - opIdx;
429 COND_SPACE( BinaryOpSpaces, isVerbalOp );
430
431 // Add brackets for RHS, if one of the two is true for it:
432 // - it is a ternary op (always has lower precedence)
433 // - it is a binary op with lower or equal precedence
434 // In fact, there are more situations where brackets can be removed, for example, in:
435 // 1 + (2 + 3)
436 // but this is kept. The reason, why we don't remove, if operators are equal is:
437 // 1 - (2 - 3)
438 // Here, we must not remove the brackets. This generally means, we do not have enough
439 // information about the algebraic rules of our operators to remove the brackets in all
440 // cases!
441
442 bool rhsBrackets= Rhs->NodeType == Types::TernaryOp
443 || ( rhsBinaryPrecedence
445 || ( precedence >= rhsBinaryPrecedence )
447 && precedence < rhsBinaryPrecedence )
449 && lhsBinaryPrecedence )
450 )
451 );
452
453
454 // RHS recursion
455 if( rhsBrackets ) normalized << normBracketOpen[bracketStringIdx];
456 Rhs->Assemble( program, allocator, normalized );
457 if( rhsBrackets ) normalized << normBracketClose[bracketStringIdx];
458
459 // check plugins
460 program.AssembleBinaryOp( op, Position, opIdx );
461
462 // did the compiler plug-in replace the operator (was given an alias operator)?
463 if( op != Operator || isVerbalOp ) {
464 if( isVerbalOp ) {
465 // replace in any case: class program would have changed the op only if the corresponding
466 // flags had been set:
467 normalized.ReplaceSubstring<NC>( op, opIdx, opLen );
468 opLen= op.Length();
469
470 // we have to check only two of four format flags here, the rest was is (was) done in program
474 for( integer i= opIdx ; i < opIdx + opLen ; ++i )
476 ? characters::ToLower( normalized[i] )
477 : characters::ToUpper( normalized[i] );
478
479 // remove operator spaces if they were inserted for non-verbal op, if op is now symbolic
480 if( !HasBits(format, Normalization::BinaryOpSpaces) && !isalpha(op.CharAtStart() ) ) {
481 normalized.Delete( opIdx + opLen, 1 );
482 normalized.Delete( opIdx - 1 , 1 );
483 }
484
485 }
486
487 else if( HasBits(format, Normalization::ReplaceAliasOperators ) ) {
488 normalized.ReplaceSubstring<NC>( op, opIdx, opLen );
489 opLen= op.Length();
490 } }
491
492 // check if a forbidden string occurred due to writing operator with no spaces/brackets and
493 // the subsequent writing of probably nested unary operators, negative literals, etc.
494 checkForbiddenStrings( program.compiler, normalized, opIdx, opLen );
495}
496
497
498void ASTConditional::Assemble( Program& program, MonoAllocator& allocator, AString & normalized ) {
499 auto format= program.compiler.CfgNormalization;
500
501 int bracketStringIdx= (HasBits(format, Normalization::InnerBracketSpace ) +
503
504
505 // Q
506 Q->Assemble( program, allocator, normalized );
507 normalized << SPACE(ConditionalOpSpaceBeforeQM);
508 program.AssembleCondFinalize_Q( Position, normalized.Length() );
509 normalized << A_CHAR("?") << SPACE(ConditionalOpSpaceAfterQM);
510
511 // T
512 integer idxInNormalized= normalized.Length();
513
514 bool brackets= T->NodeType == Types::TernaryOp
516
517 if( brackets ) normalized << normBracketOpen[bracketStringIdx];
518 T->Assemble( program, allocator, normalized );
519 if( brackets ) normalized << normBracketClose[bracketStringIdx];
520
521 // :
522 normalized << SPACE(ConditionalOpSpaceBeforeColon);
523
524 program.AssembleCondFinalize_T( ColonPosition, normalized.Length() );
525
526 normalized << ":" << SPACE(ConditionalOpSpaceAfterColon);
527
528
529 // F
530 brackets= F->NodeType == Types::TernaryOp
532
533 if( brackets ) normalized << normBracketOpen[bracketStringIdx];
534 F->Assemble( program, allocator, normalized );
535 if( brackets ) normalized << normBracketClose[bracketStringIdx];
536
537 program.AssembleCondFinalize_F( Position, idxInNormalized );
538}
539
540}}} // namespace [alib::expressions::detail]
bool IsType() const
TValue Unbox() const
Definition box.inl:595
Normalization CfgNormalization
Definition compiler.inl:260
Compilation CfgCompilation
Compilation flags.
Definition compiler.inl:256
strings::util::Token CfgNestedExpressionFunction
Definition compiler.inl:247
HashMap< MonoAllocator, String, String, alib::hash_string_ignore_case< character >, alib::equal_to_string_ignore_case< character > > AlphabeticUnaryOperatorAliases
Definition compiler.inl:117
int GetBinaryOperatorPrecedence(const String &symbol)
Definition compiler.inl:174
ALIB_DLL void AssembleUnaryOp(String &op, integer idxInOriginal, integer idxInNormalized)
Definition program.cpp:381
ALIB_DLL void AssembleFunction(AString &functionName, bool isIdentifier, int qtyArgs, integer idxInOriginal, integer idxInNormalized)
Definition program.cpp:205
ALIB_DLL void AssembleBinaryOp(String &op, integer idxInOriginal, integer idxInNormalized)
Definition program.cpp:552
ALIB_DLL void AssembleCondFinalize_Q(integer idxInOriginal, integer idxInNormalized)
Definition program.cpp:742
ALIB_DLL void AssembleConstant(Box &value, integer idxInOriginal, integer idxInNormalized)
Definition program.cpp:191
Compiler & compiler
The compiler that created this object.
Definition program.inl:30
ALIB_DLL void AssembleCondFinalize_F(integer idxInOriginal, integer idxInNormalized)
Definition program.cpp:792
ALIB_DLL void AssembleCondFinalize_T(integer idxInOriginal, integer idxInNormalized)
Definition program.cpp:771
NumberFormat DefaultNumberFormat
Definition formatter.inl:96
TAString & Delete(integer regionStart, integer regionLength=MAX_LEN)
TAString & ReplaceSubstring(const TString< TChar > &src, integer regionStart, integer regionLength)
TAString & ShortenTo(integer newLength)
Definition tastring.inl:787
void DbgDisableBufferReplacementWarning()
Definition tastring.inl:244
constexpr integer Length() const
Definition string.inl:316
TChar CharAtStart() const
Definition string.inl:433
bool Equals(const TString< TChar > &rhs) const
Definition string.inl:531
ALIB_DLL bool Match(const String &needle)
Definition token.cpp:278
#define ALIB_CALLER_NULLED
Definition alib.inl:1027
#define A_CHAR(STR)
#define ALIB_STRING_RESETTER(astring)
TChar ToUpper(TChar c)
TChar ToLower(TChar c)
@ ReplaceVerbalOperatorsToLowerCase
See sibling flag ReplaceVerbalOperatorsToSymbolic.
@ NONE
All flags are cleared, may be used for testing bits.
@ ReplaceVerbalOperatorsToUpperCase
See sibling flag ReplaceVerbalOperatorsToSymbolic.
@ Local
Denotes local reach.
@ On
Switch it on, switched on, etc.
strings::TEscape< character > Escape
Type alias in namespace alib.
Definition format.inl:532
strings::TDec< character > Dec
Type alias in namespace alib.
Definition format.inl:541
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
LocalString< 64 > String64
Type alias name for TLocalString<character,64>.
constexpr const String EMPTY_STRING
An empty string of the default character type.
Definition string.inl:2251
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
strings::TNumberFormat< character > NumberFormat
Type alias in namespace alib.
strings::TOct< character > Oct
Type alias in namespace alib.
Definition format.inl:559
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
strings::THex< character > Hex
Type alias in namespace alib.
Definition format.inl:550
exceptions::Exception Exception
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2189
expressions::Compiler Compiler
Type alias in namespace alib.
Definition compiler.inl:540
strings::TBin< character > Bin
Type alias in namespace alib.
Definition format.inl:568
virtual void Assemble(Program &program, MonoAllocator &allocator, AString &normalized) override
Definition ast.cpp:366
virtual AST * Optimize(Normalization normalization) override
Definition ast.cpp:67
ASTBinaryOp(const String &op, AST *lhs, AST *rhs, integer position)
Definition ast_impl.inl:207
AST * Lhs
The left-hand-side expression node.
Definition ast_impl.inl:199
String Operator
The operator symbol.
Definition ast_impl.inl:198
virtual void Assemble(Program &program, MonoAllocator &allocator, AString &normalized) override
Definition ast.cpp:498
integer ColonPosition
The index of the colon in the expression string.
Definition ast_impl.inl:232
virtual AST * Optimize(Normalization normalization) override
Definition ast.cpp:73
String Name
The function name as parsed.
Definition ast_impl.inl:135
virtual void Assemble(Program &program, MonoAllocator &allocator, AString &normalized) override
Definition ast.cpp:171
ListMA< AST * > Arguments
The argument nodes.
Definition ast_impl.inl:136
Abstract syntax tree node representing identifiers.
Definition ast_impl.inl:108
String Name
The name of the identifier as parsed from the expression string.
Definition ast_impl.inl:109
virtual AST * Optimize(Normalization normalization) override
Definition ast.cpp:60
virtual void Assemble(Program &program, MonoAllocator &allocator, AString &normalized) override
Definition ast.cpp:158
Abstract syntax tree node representing identifiers.
Definition ast_impl.inl:52
@ Scientific
Float was given in scientific format.
Definition ast_impl.inl:59
@ Hexadecimal
Integral value was given in hexadecimal format.
Definition ast_impl.inl:60
@ Binary
Integral value was given in binary format.
Definition ast_impl.inl:62
@ Octal
Integral value was given in octal format.
Definition ast_impl.inl:61
Box Value
The value of the literal.
Definition ast_impl.inl:65
virtual void Assemble(Program &program, MonoAllocator &allocator, AString &normalized) override
Definition ast.cpp:112
virtual AST * Optimize(Normalization normalization) override
Definition ast.cpp:82
AST * Argument
The argument node.
Definition ast_impl.inl:169
String Operator
The operator symbol.
Definition ast_impl.inl:168
virtual void Assemble(Program &program, MonoAllocator &allocator, AString &normalized) override
Definition ast.cpp:260
integer Position
Position in the original expression string.
Definition ast_impl.inl:18
AST()=delete
Deleted default constructor.
TCString< TChar > BinLiteralPrefix
NumberFormatFlags Flags
The flag field.
TCString< TChar > HexLiteralPrefix
TCString< TChar > OctLiteralPrefix