VapourSynth-llvmexpr
Loading...
Searching...
No Matches
infix2postfix::preprocessor::Evaluator Class Reference

Public Member Functions

 Evaluator (const std::vector< Token > &tokens)
std::variant< int64_t, double > evaluate ()
std::optional< std::variant< int64_t, double > > tryEvaluate ()

Static Public Member Functions

static bool is_truthy (const std::variant< int64_t, double > &val)
static std::string toString (const std::variant< int64_t, double > &val)

Detailed Description

Definition at line 565 of file Preprocessor.cpp.

Constructor & Destructor Documentation

◆ Evaluator()

infix2postfix::preprocessor::Evaluator::Evaluator ( const std::vector< Token > & tokens)
inlineexplicit

Definition at line 567 of file Preprocessor.cpp.

568 : tokens(tokens), stream(tokens) {}

Member Function Documentation

◆ evaluate()

std::variant< int64_t, double > infix2postfix::preprocessor::Evaluator::evaluate ( )
inline

Definition at line 570 of file Preprocessor.cpp.

570 {
571 pos = 0;
572 skipWhitespace();
573
574 if (is_eof()) {
575 throw std::runtime_error("Cannot evaluate an empty expression");
576 }
577
578 Value result = parseConditional();
579 skipWhitespace();
580
581 if (!is_eof()) {
582 throw std::runtime_error("Unexpected tokens at end of expression");
583 }
584
585 return result.val;
586 }

Referenced by tryEvaluate().

◆ is_truthy()

bool infix2postfix::preprocessor::Evaluator::is_truthy ( const std::variant< int64_t, double > & val)
inlinestatic

Definition at line 598 of file Preprocessor.cpp.

598 {
599 return Value(val).is_truthy();
600 }

References infix2postfix::Value.

◆ toString()

std::string infix2postfix::preprocessor::Evaluator::toString ( const std::variant< int64_t, double > & val)
inlinestatic

Definition at line 602 of file Preprocessor.cpp.

602 {
603 return Value(val).to_string();
604 }

References infix2postfix::Value.

◆ tryEvaluate()

std::optional< std::variant< int64_t, double > > infix2postfix::preprocessor::Evaluator::tryEvaluate ( )
inline

Definition at line 588 of file Preprocessor.cpp.

588 {
589 try {
590 return evaluate();
591 } catch (const PreprocessorError&) {
592 throw;
593 } catch (const std::runtime_error&) {
594 return std::nullopt;
595 }
596 }
std::variant< int64_t, double > evaluate()

References evaluate().


The documentation for this class was generated from the following file: