Counter expressions (#3534)

* Add peglib

* - Add expression engine
- Take an expression when setting a counter

* Shift + Click = Middleclick for counters

* minor cleanup for clangify

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Added tip entry
This commit is contained in:
Rob Blanckaert 2019-02-02 10:56:49 -08:00 committed by Zach H
parent 6e1b0a7590
commit c9c0fb28ee
13 changed files with 3508 additions and 26 deletions

28
common/expression.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef EXPRESSION_H
#define EXPRESSION_H
#include <QMap>
#include <QString>
#include <functional>
namespace peg
{
template <typename Annotation> struct AstBase;
struct EmptyType;
typedef AstBase<EmptyType> Ast;
} // namespace peg
class Expression
{
public:
double value;
explicit Expression(double initial = 0);
double parse(const QString &expr);
private:
double eval(const peg::Ast &ast);
QMap<QString, std::function<double(double)>> fns;
};
#endif