10# if !defined (HPP_ALIB_EXPRESSIONS_DETAIL_PARSER_IMPL)
14# if !defined (HPP_ALIB_EXPRESSIONS_COMPILER)
18# if !defined (HPP_ALIB_MONOMEM_MASTRING)
21# if !defined (HPP_ALIB_STRINGS_FORMAT)
24# if !defined (HPP_ALIB_LANG_CAMP_INLINES)
31namespace alib {
namespace expressions {
namespace detail {
38: compiler ( pCompiler )
39, unaryOperators ( allocator )
40, binaryOperators( allocator )
54 "Doubly defined unary operator symbol {!Q'}.", op )
64 "Doubly defined unary operator symbol {!Q'}.", op.first )
67 if( !isalpha( op.first.CharAtStart() ) )
68 for(
auto it : op.first )
76 "Doubly defined binary operator symbol {!Q'}.", op.first )
77 if( op.first ==
A_CHAR(
"[]") )
85 for(
auto it : op.first )
93 "Doubly defined binary operator symbol {!Q'}.", op.first )
98 "Alias {!Q'} defined for unknown operator {!Q'}.",
102 if( !isalpha( op.first.CharAtStart() ) )
103 for(
auto it : op.first )
150 token= Tokens::SymbolicOp;
172 if( isalpha( first ) )
188 token= Tokens::AlphaUnOp;
201 token= Tokens::AlphaBinOp;
209 if( isalpha( first ) || first ==
'_' )
214 && ( isalnum( next=
scanner[endOfIdent] )
217 token= Tokens::Identifier;
226 if( isdigit( first ) )
231 && ( isdigit( next=
scanner[endOfDecPart] )
246 token = Tokens::LitFloat;
251 || numberParsed.
IndexOf(
'E') > 0
270 token= Tokens::LitInteger;
280 bool lastWasSlash=
false;
285 if( next ==
'\\' ) { lastWasSlash=
true;
continue; }
286 if( next ==
'\"' && !lastWasSlash )
break;
307 token = Tokens::LitString;
323#define Start parseConditional
346 if(
token != Tokens::EOT )
406 if(
token == Tokens::BraceOpen )
416 if(
token == Tokens::EOT )
438 if( parent ==
nullptr )
450 if(
token == Tokens::BraceOpen )
455 if(
token != Tokens::BraceClose )
482 if(
token == Tokens::Identifier ||
token == Tokens::AlphaBinOp )
488 if(
token == Tokens::BraceOpen )
495 if(
token == Tokens::BraceClose )
500 astFunction->
Arguments.EmplaceBack( Start() );
502 if(
token == Tokens::Comma )
505 if(
token != Tokens::BraceClose )
524 if(
token == Tokens::EOT )
531 if(
token == Tokens::BraceClose )
538 if(
token == Tokens::SubscriptOpen ||
token == Tokens::SubscriptClose )
545 if(
token == Tokens::Comma )
552 ALIB_ERROR(
"EXPR",
"Internal parser Error. This should never happen")
559 ||
token != Tokens::SubscriptOpen )
568 if(
token != Tokens::SubscriptClose )
588 if(
token == Tokens::SymbolicOp )
614 else if (
token == Tokens::AlphaUnOp )
618 return alphabeticOperator;
626 if (
token == Tokens::SymbolicOp )
657 else if (
token == Tokens::AlphaBinOp )
661 return alphabeticOperator;
HashMap< String, String, alib::hash_string_ignore_case< character >, alib::equal_to_string_ignore_case< character > > AlphabeticUnaryOperatorAliases
List< String > UnaryOperators
HashMap< String, int > BinaryOperators
int GetBinaryOperatorPrecedence(const String &symbol)
Compilation CfgCompilation
HashMap< String, String, alib::hash_string_ignore_case< character >, alib::equal_to_string_ignore_case< character > > AlphabeticBinaryOperatorAliases
std::vector< AST *, StdContMA< AST * > > * ASTs
ASTLiteral::NFHint tokLiteralHint
ALIB_API String getBinaryOp()
MonoAllocator * compileTimeAllocator
HashSet< String, alib::hash_string_ignore_case< character >, alib::equal_to_string_ignore_case< character > > binaryOperators
ParserImpl(Compiler &compiler, MonoAllocator *allocator)
NumberFormat * numberFormat
std::bitset< 256 > operatorChars
ALIB_API String getUnaryOp()
AST * parseSubscript(AST *function)
HashSet< String, alib::hash_string_ignore_case< character >, alib::equal_to_string_ignore_case< character > > unaryOperators
std::bitset< 256 > syntaxTokens
virtual ALIB_API detail::AST * Parse(const String &exprString, NumberFormat *nf, MonoAllocator *allocator) override
const String & GetResource(const NString &name)
Exception & Add(const NCString &file, int line, const NCString &func, TEnum type, TArgs &&... args)
ALIB_FORCE_INLINE T * Emplace(TArgs &&... args)
strings::TString< TChar > EmplaceString(const strings::TString< TChar > &src)
constexpr bool IsNull() const
integer IndexOf(TChar needle, integer startIdx=0) const
constexpr bool IsEmpty() const
constexpr bool IsNotEmpty() const
constexpr integer Length() const
TChar CharAtStart() const
constexpr bool IsNotNull() const
std::size_t HashcodeIgnoreCase() const
TString< TChar > Substring(integer regionStart, integer regionLength=MAX_LEN) const
bool Equals(const TString< TChar > &rhs) const
bool StartsWith(const TString &needle) const
constexpr const TChar * Buffer() const
ALIB_API bool ConsumeFloat(double &result, TNumberFormat< TChar > *numberFormat=nullptr)
integer ConsumeChars(integer regionLength, TSubstring *target=nullptr)
bool ConsumeInt(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
TSubstring & TrimStart(const TCString< TChar > &whiteSpaces=TT_StringConstants< TChar >::DefaultWhitespaces())
#define ALIB_CALLER_NULLED
#define ALIB_WARNINGS_RESTORE
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
@ AlphabeticOperatorsIgnoreCase
@ UnknownBinaryOperatorSymbol
@ UnknownUnaryOperatorSymbol
@ Off
Switch it off, switched off, etc.
lang::Exception Exception
Type alias in namespace alib.
expressions::Expressions EXPRESSIONS
strings::TSubstring< character > Substring
Type alias in namespace alib.
constexpr String NullString()
characters::character character
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
String Operator
The operator symbol.
AST * Lhs
The left-hand-side expression node.
List< AST * > Arguments
The argument nodes.
@ 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.