specialists/symbolic_fallback.hpp¶
Expression parser and evaluator for math validation (PTDS §5.2) More...
Namespaces¶
| Name |
|---|
| sgns |
| sgns::neoswarm |
| sgns::neoswarm::specialists |
Classes¶
| Name | |
|---|---|
| class | sgns::neoswarm::specialists::SymbolicFallback Evaluates mathematical expressions symbolically. |
Detailed Description¶
Expression parser and evaluator for math validation (PTDS §5.2)
Date: 2026-05-06
Source code¶
#ifndef NEOSWARM_SPECIALISTS_SYMBOLICFALLBACK_HPP
#define NEOSWARM_SPECIALISTS_SYMBOLICFALLBACK_HPP
#include "common/error.hpp"
#include <optional>
#include <string>
namespace sgns::neoswarm::specialists
{
class SymbolicFallback
{
public:
static constexpr float kConfidenceThreshold = 0.6f;
static std::optional<double> Evaluate( const std::string& expr );
static std::optional<double> ExtractAndEvaluate( const std::string& text );
static std::string FormatResult( double value );
private:
struct Parser
{
const std::string& input_;
size_t pos_ = 0;
double ParseExpr();
double ParseTerm();
double ParseFactor();
double ParsePrimary();
void SkipWhitespace();
char Peek() const;
char Consume();
};
};
} // namespace sgns::neoswarm::specialists
#endif // NEOSWARM_SPECIALISTS_SYMBOLICFALLBACK_HPP
Updated on 2026-07-25 at 22:56:57 +0000