diff options
Diffstat (limited to 'src/GCodes/GCodeBuffer/ExpressionParser.h')
-rw-r--r-- | src/GCodes/GCodeBuffer/ExpressionParser.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/GCodes/GCodeBuffer/ExpressionParser.h b/src/GCodes/GCodeBuffer/ExpressionParser.h index a4e6cb06..778a5b22 100644 --- a/src/GCodes/GCodeBuffer/ExpressionParser.h +++ b/src/GCodes/GCodeBuffer/ExpressionParser.h @@ -20,7 +20,6 @@ public: ExpressionParser(const GCodeBuffer& p_gb, const char *text, const char *textLimit, int p_column = -1) noexcept; ExpressionValue Parse(bool evaluate = true) THROWS(GCodeException); - ExpressionValue ParseSimple() THROWS(GCodeException); bool ParseBoolean() THROWS(GCodeException); float ParseFloat() THROWS(GCodeException); int32_t ParseInteger() THROWS(GCodeException); @@ -31,22 +30,27 @@ public: const char *GetEndptr() const noexcept { return currentp; } private: - GCodeException ConstructParseException(const char *str) const noexcept; - GCodeException ConstructParseException(const char *str, const char *param) const noexcept; - GCodeException ConstructParseException(const char *str, uint32_t param) const noexcept; + [[noreturn]] void __attribute__((noinline)) ThrowParseException(const char *str) const THROWS(GCodeException); + [[noreturn]] void __attribute__((noinline)) ThrowParseException(const char *str, const char *param) const THROWS(GCodeException); + [[noreturn]] void __attribute__((noinline)) ThrowParseException(const char *str, uint32_t param) const THROWS(GCodeException); - ExpressionValue ParseInternal(bool evaluate = true, uint8_t priority = 0) THROWS(GCodeException); - ExpressionValue ParseExpectKet(bool evaluate, char expectedKet) THROWS(GCodeException); - ExpressionValue ParseNumber() noexcept + void ParseInternal(ExpressionValue& val, bool evaluate, uint8_t priority) THROWS(GCodeException); + void ParseExpectKet(ExpressionValue& rslt, bool evaluate, char expectedKet) THROWS(GCodeException); + void __attribute__((noinline)) ParseNumber(ExpressionValue& rslt) noexcept pre(readPointer >= 0; isdigit(gb.buffer[readPointer])); - ExpressionValue ParseIdentifierExpression(bool evaluate, bool applyLengthOperator, bool applyExists) THROWS(GCodeException) + void __attribute__((noinline)) ParseIdentifierExpression(ExpressionValue& rslt, bool evaluate, bool applyLengthOperator, bool applyExists) THROWS(GCodeException) pre(readPointer >= 0; isalpha(gb.buffer[readPointer])); - ExpressionValue ParseQuotedString() THROWS(GCodeException); - ExpressionValue GetVariableValue(const VariableSet *vars, const char *name, bool parameter, bool wantExists) THROWS(GCodeException); + void __attribute__((noinline)) ParseQuotedString(ExpressionValue& rslt) THROWS(GCodeException); + void GetVariableValue(ExpressionValue& rslt, const VariableSet *vars, const char *name, bool parameter, bool wantExists) THROWS(GCodeException); void ConvertToFloat(ExpressionValue& val, bool evaluate) const THROWS(GCodeException); void ConvertToBool(ExpressionValue& val, bool evaluate) const THROWS(GCodeException); - void ConvertToString(ExpressionValue& val, bool evaluate) THROWS(GCodeException); + void ConvertToString(ExpressionValue& val, bool evaluate) noexcept; + + void CheckStack(uint32_t calledFunctionStackUsage) const THROWS(GCodeException); + + // The following must be declared 'noinline' because it allocates a large buffer on the stack and its caller is recursive + static void __attribute__((noinline)) StringConcat(ExpressionValue &val, ExpressionValue &val2) noexcept; void BalanceNumericTypes(ExpressionValue& val1, ExpressionValue& val2, bool evaluate) const THROWS(GCodeException); void BalanceTypes(ExpressionValue& val1, ExpressionValue& val2, bool evaluate) THROWS(GCodeException); |