replicode
replistruct.h
Go to the documentation of this file.
1 #ifndef REPLISTRUCT_H
2 #define REPLISTRUCT_H
3 
4 #include <cstdint>
5 #include <string>
6 #include <list>
7 #include <unordered_map>
8 #include <vector>
9 
10 namespace r_comp {
11 
12 class RepliMacro;
13 class RepliCondition;
14 class RepliStruct {
15 public:
16  static std::unordered_map<std::string, RepliMacro *> RepliMacros;
17  static std::unordered_map<std::string, int64_t> Counters;
18  static std::list<RepliCondition *> Conditions;
20  static std::string GlobalFilename;
21 
24  std::string cmd;
25  std::string tail;
26  std::string label;
27  std::string error;
28  std::string fileName;
30  std::vector<RepliStruct *> args;
32 
34  ~RepliStruct();
35 
36  void reset(); // remove rags that are objects.
37 
38  uint64_t getIndent(std::istream *stream);
39  int64_t parse(std::istream *stream, uint64_t &curIndent, uint64_t &prevIndent, int64_t paramExpect = 0);
40  bool parseDirective(std::istream *stream, uint64_t &curIndent, uint64_t &prevIndent);
41  int64_t process();
42 
43  RepliStruct *findAtom(const std::string &name);
44  RepliStruct *loadReplicodeFile(const std::string &filename);
45 
46  RepliStruct *clone() const;
47  std::string print() const;
48  std::string printError() const;
49 
50  friend std::ostream& operator<<(std::ostream &os, const RepliStruct &structure);
51  friend std::ostream& operator<<(std::ostream &os, RepliStruct *structure);
52 private:
53  RepliStruct(const RepliStruct &);
54  RepliStruct();
55 };
56 
57 class RepliMacro {
58 public:
59  std::string name;
62  std::string error;
63 
64  RepliMacro(const std::string &name, RepliStruct *src, RepliStruct *dest);
65  ~RepliMacro();
66 
68  RepliStruct *expandMacro(RepliStruct *oldStruct);
69 };
70 
72 public:
73  std::string name;
74  bool reversed;
75 
76  RepliCondition(const std::string &name, bool reversed);
78  bool reverse();
79  bool isActive(std::unordered_map<std::string, RepliMacro*> &RepliMacros, std::unordered_map<std::string, int64_t> &Counters);
80 };
81 
82 
83 }
84 
85 #endif//REPLISTRUCT_H
RepliMacro(const std::string &name, RepliStruct *src, RepliStruct *dest)
Definition: replistruct.cpp:840
RepliStruct * clone() const
Definition: replistruct.cpp:802
Definition: replistruct.h:22
Type
Definition: replistruct.h:22
Type type
Definition: replistruct.h:23
Definition: replistruct.h:22
RepliStruct * loadReplicodeFile(const std::string &filename)
Definition: replistruct.cpp:655
RepliStruct * src
Definition: replistruct.h:60
uint64_t line
Definition: replistruct.h:29
uint64_t getIndent(std::istream *stream)
Definition: replistruct.cpp:47
~RepliStruct()
Definition: replistruct.cpp:25
int64_t parse(std::istream *stream, uint64_t &curIndent, uint64_t &prevIndent, int64_t paramExpect=0)
Definition: replistruct.cpp:68
bool reversed
Definition: replistruct.h:74
std::string error
Definition: replistruct.h:27
static std::list< RepliCondition * > Conditions
Definition: replistruct.h:18
std::string tail
Definition: replistruct.h:25
RepliStruct * parent
Definition: replistruct.h:31
void reset()
Definition: replistruct.cpp:29
uint64_t argCount()
Definition: replistruct.cpp:854
static std::string GlobalFilename
Definition: replistruct.h:20
std::string print() const
Definition: replistruct.cpp:682
static uint64_t GlobalLine
Definition: replistruct.h:19
Definition: replistruct.h:57
RepliStruct * dest
Definition: replistruct.h:61
RepliCondition(const std::string &name, bool reversed)
Definition: replistruct.cpp:940
RepliStruct * findAtom(const std::string &name)
Definition: replistruct.cpp:915
Definition: replistruct.h:71
std::string fileName
Definition: replistruct.h:28
std::string name
Definition: replistruct.h:59
Definition: replistruct.h:22
std::string printError() const
Definition: replistruct.cpp:817
~RepliCondition()
Definition: replistruct.cpp:946
RepliStruct * expandMacro(RepliStruct *oldStruct)
Definition: replistruct.cpp:861
Definition: replistruct.h:22
std::string label
Definition: replistruct.h:26
bool parseDirective(std::istream *stream, uint64_t &curIndent, uint64_t &prevIndent)
Definition: replistruct.cpp:425
std::vector< RepliStruct * > args
Definition: replistruct.h:30
Definition: replistruct.h:22
std::string cmd
Definition: replistruct.h:24
static std::unordered_map< std::string, RepliMacro * > RepliMacros
Definition: replistruct.h:16
int64_t process()
Definition: replistruct.cpp:497
std::string error
Definition: replistruct.h:62
Definition: replistruct.h:22
bool isActive(std::unordered_map< std::string, RepliMacro * > &RepliMacros, std::unordered_map< std::string, int64_t > &Counters)
Definition: replistruct.cpp:955
Definition: replistruct.h:22
friend std::ostream & operator<<(std::ostream &os, const RepliStruct &structure)
Definition: replistruct.cpp:723
bool reverse()
Definition: replistruct.cpp:949
~RepliMacro()
Definition: replistruct.cpp:847
Definition: image.h:41
static std::unordered_map< std::string, int64_t > Counters
Definition: replistruct.h:17
Definition: replistruct.h:14
std::string name
Definition: replistruct.h:73