mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare/parser] IsReservedFunctionName returns a pointer
and is hence renamed GetReservedFunction
This commit is contained in:
committed by
Léa Saviot
parent
967343f75d
commit
4ef46b4fdb
@@ -18,13 +18,13 @@ Expression Parser::parse() {
|
||||
}
|
||||
|
||||
bool Parser::IsReservedName(const char * name, size_t nameLength) {
|
||||
return IsReservedFunctionName(name, nameLength)
|
||||
return GetReservedFunction(name, nameLength) != nullptr
|
||||
|| IsSpecialIdentifierName(name, nameLength);
|
||||
}
|
||||
|
||||
// Private
|
||||
|
||||
bool Parser::IsReservedFunctionName(const char * name, size_t nameLength, const Expression::FunctionHelper * const * * functionHelper) {
|
||||
const Expression::FunctionHelper * const * Parser::GetReservedFunction(const char * name, size_t nameLength) {
|
||||
const Expression::FunctionHelper * const * reservedFunction = &s_reservedFunctions[0];
|
||||
assert(reservedFunction < s_reservedFunctionsUpperBound);
|
||||
int nameDifference = Token::CompareNonNullTerminatedName(name, nameLength, (**reservedFunction).name());
|
||||
@@ -32,10 +32,10 @@ bool Parser::IsReservedFunctionName(const char * name, size_t nameLength, const
|
||||
reservedFunction++;
|
||||
nameDifference = Token::CompareNonNullTerminatedName(name, nameLength, (**reservedFunction).name());
|
||||
}
|
||||
if (functionHelper != nullptr) {
|
||||
*functionHelper = reservedFunction;
|
||||
if (reservedFunction < s_reservedFunctionsUpperBound && nameDifference == 0) {
|
||||
return reservedFunction;
|
||||
}
|
||||
return (reservedFunction < s_reservedFunctionsUpperBound && nameDifference == 0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Parser::IsSpecialIdentifierName(const char * name, size_t nameLength) {
|
||||
@@ -327,7 +327,8 @@ void Parser::parseBang(Expression & leftHandSide, Token::Type stoppingType) {
|
||||
}
|
||||
|
||||
bool Parser::currentTokenIsReservedFunction(const Expression::FunctionHelper * const * * functionHelper) const {
|
||||
return IsReservedFunctionName(m_currentToken.text(), m_currentToken.length(), functionHelper);
|
||||
*functionHelper = GetReservedFunction(m_currentToken.text(), m_currentToken.length());
|
||||
return *functionHelper != nullptr;
|
||||
}
|
||||
|
||||
bool Parser::currentTokenIsSpecialIdentifier() const {
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
static bool IsReservedName(const char * name, size_t nameLength);
|
||||
|
||||
private:
|
||||
static bool IsReservedFunctionName(const char * name, size_t nameLength, const Expression::FunctionHelper * const * * functionHelper = nullptr);
|
||||
static const Expression::FunctionHelper * const * GetReservedFunction(const char * name, size_t nameLength);
|
||||
static bool IsSpecialIdentifierName(const char * name, size_t nameLength);
|
||||
|
||||
Expression parseUntil(Token::Type stoppingType);
|
||||
|
||||
Reference in New Issue
Block a user