aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/diceparser.h
blob: 022f95e4de63bbdc1db02084d185b66a4d4e38fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef DICEPARSER_H
#define DICEPARSER_H

#include <QString>
#include <QMap>
#include "node/executionnode.h"

class Dice;

class DiceParser
{

public:
    enum DiceOperator {D};
    enum MathOperator {K,k,r,e};
    DiceParser();
    void parseLine(QString str);

private:
    bool readNumber(QString&  str, int& myNumber);
    bool readDice(QString&  str,Dice&);
    bool readDiceOperator(QString&,DiceOperator&);
    bool readDiceExpression(QString&,ExecutionNode* & node);
    bool readOperator(QString&);

    void setCurrentNode(ExecutionNode* node);

private:
    QMap<QString,DiceOperator>* m_mapDiceOp;
    ExecutionNode* m_start;
    ExecutionNode* m_current;
};

class Dice
{
public:
   DiceParser::DiceOperator m_diceOp;
   int m_faces;
};

#endif // DICEPARSER_H