HOPS
HOPS class reference
MHO_VexParser.hh
Go to the documentation of this file.
1 #ifndef MHO_VexParser_HH__
2 #define MHO_VexParser_HH__
3 
4 #include <list>
5 #include <set>
6 #include <sstream>
7 #include <string>
8 #include <vector>
9 
10 #include "MHO_JSONHeaderWrapper.hh"
11 #include "MHO_Message.hh"
12 #include "MHO_Tokenizer.hh"
13 
14 #include "MHO_VexBlockParser.hh"
15 #include "MHO_VexDefinitions.hh"
16 #include "MHO_VexLine.hh"
17 
18 namespace hops
19 {
20 
33 {
34  public:
35  MHO_VexParser();
36  virtual ~MHO_VexParser();
37 
43  void SetVexFile(std::string filename);
49  void SetVexVersion(std::string version);
50 
56  void SetVexVersion(const char* version) { SetVexVersion(std::string(version)); };
57 
64 
65  private:
69  void DetermineFileVersion();
73  void ReadFile();
77  void RemoveComments();
81  void MarkLiterals();
85  void IndexStatements();
89  void SplitStatements();
93  void JoinLines();
97  void MarkBlocks();
104  std::vector< MHO_VexLine > CollectBlockLines(std::string block_name);
110  void ProcessBlocks(mho_json& root);
111 
118  bool IsPotentialBlockStart(std::string line);
126  bool IsBlockStart(std::string line, std::string blk_name);
127 
128  std::string fVexFileName;
129 
130  //token/delimiter definitions
131  MHO_VexDefinitions fVexDef;
132 
133  std::string fVexRevisionFlag;
134  std::string fVexDelim;
135  std::string fWhitespace;
136  std::string fBlockStartFlag;
137  std::string fStatementEndFlag;
138  std::string fRefFlag;
139 
140  std::string fStartLiteralFlag;
141  std::string fEndLiteralFlag;
142 
143  //workspace
144  std::string fLine; //the line from the input vex file
145  std::list< MHO_VexLine > fLines;
146  using line_itr = std::list< MHO_VexLine >::iterator;
147  std::set< std::string > fFoundBlocks;
148  std::map< std::string, line_itr > fBlockStartLines;
149  std::map< std::string, line_itr > fBlockStopLines;
150 
151  //format definition
152  std::string fFormatDirectory;
153  std::string fVexVersion;
154  std::vector< std::string > fBlockNames;
155 
156  //block parser
157  MHO_VexBlockParser fBlockParser;
158 };
159 
160 } // namespace hops
161 
162 #endif
nlohmann::json mho_json
Definition: MHO_JSONHeaderWrapper.hh:5
Class MHO_VexBlockParser.
Definition: MHO_VexBlockParser.hh:34
Class MHO_VexDefinitions.
Definition: MHO_VexDefinitions.hh:69
Class MHO_VexParser.
Definition: MHO_VexParser.hh:33
MHO_VexParser()
Definition: MHO_VexParser.cc:8
void SetVexVersion(const char *version)
Setter for vex version.
Definition: MHO_VexParser.hh:56
mho_json ParseVex()
Parses Vex file, processes blocks and returns JSON object with Vex revision flag.
Definition: MHO_VexParser.cc:28
void SetVexFile(std::string filename)
Setter for vex file.
Definition: MHO_VexParser.cc:16
virtual ~MHO_VexParser()
Definition: MHO_VexParser.cc:14
void SetVexVersion(std::string version)
Setter for vex version.
Definition: MHO_VexParser.cc:381
const char version[]
Definition: difx2mark4.c:37
Definition: MHO_ChannelLabeler.hh:17