mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
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:
parent
6e1b0a7590
commit
c9c0fb28ee
13 changed files with 3508 additions and 26 deletions
28
common/expression.h
Normal file
28
common/expression.h
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue