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