-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjectFSM.h
More file actions
44 lines (33 loc) · 1.68 KB
/
objectFSM.h
File metadata and controls
44 lines (33 loc) · 1.68 KB
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
42
43
44
#ifndef OBJECTFSM_H
#define OBJECTFSM_H
/*******************************************************************************
* INCLUDE HEADER FILES
******************************************************************************/
#include <iostream>
#include "genericFSM.h"
#include "eventClass.h"
/*******************************************************************************
* ENUMERATIONS AND STRUCTURES AND TYPEDEFS
******************************************************************************/
#define OX(x) (static_cast<void (genericFSM::*)(genericEvent*)>(&objectFSM::x))
/*******************************************************************************
* CLASS PROTOTYPE
******************************************************************************/
class objectFSM;
class objectFSM : public genericFSM
{
public:
objectFSM() : genericFSM(&objectTable[0][0], 3, 6, INIT_OBJ, OX(assignValue)) {}
private:
const fsmCell objectTable[3][6] = {
//Event " Event , Event : Event } Invalid char Event EOF
{{STRING,OX(end)}, {ERROR,OX(error)}, {ERROR,OX(error)}, {END,OX(end)}, {ERROR,OX(error)}, {ERROR,OX(error)} }, //State INIT_OBJ
{{ERROR,OX(error)}, {ERROR,OX(error)}, {VALUE,OX(end)}, {STRING,OX(end)}, {ERROR,OX(error)}, {ERROR,OX(error)} }, //State STRING
{{ERROR,OX(error)}, {INIT_OBJ,OX(nothing)}, {ERROR,OX(error)}, {END,OX(end)}, {ERROR,OX(error)}, {ERROR,OX(error)} }, //State VALUE
};
void assignValue(genericEvent* ev);
void nextFSM(genericFSM** stackFSM, uint& stackLevel) override;
enum objStates : stateType { INIT_OBJ, STRING, VALUE };
typedef enum { QUOTES, COMMA, COLON, C_BRACE, _EOF, INVALID_CHAR } objectEvents;
};
#endif // OBJECTFSM_H