roadrunner  2.6.0
Fast simulator for SBML models
rrScanner.h
1 #ifndef rrScannerH
2 #define rrScannerH
3 #include "rrExporter.h"
4 #include <vector>
5 #include <queue>
6 #include <fstream>
7 #include <sstream>
8 #include "rrHashTable.h"
9 #include "rrCodeTypes.h"
10 #include "rrToken.h"
11 using std::vector;
12 using std::queue;
13 using std::fstream;
14 using std::stringstream;
15 
16 namespace rr
17 {
18 
19 namespace TCharCode
20 {
21 enum TCharCode
22 {
23  cLETTER = 0,
24  cDIGIT,
25  cPOINT,
26  cDOUBLEQUOTE,
27  cUNDERSCORE,
28  cSPECIAL,
29  cWHITESPACE,
30  cETX
31 };
32 }
33 
34 
35 class RR_DECLSPEC Scanner
36 {
37  protected:
38  const char EOFCHAR; // Deemed end of std::string marker, used internally
39  const char CR;
40  const char LF;
41  std::vector<TCharCode::TCharCode> FCharTable;
42  std::vector<char> buffer;
43  queue<Token> tokenQueue;
44  std::map<std::string, CodeTypes::CodeTypes> wordTable;
45  std::stringstream *pStream;
46  std::streamsize bufferLength;
47  int bufferPtr; // Index of position in buffer containing current char
48  CodeTypes::CodeTypes ftoken;
49  int yylineno; // Current line number
50  void initScanner();
51  char getCharFromBuffer();
52  bool IsDoubleQuote(char ch);
53  void getNumber();
54  void getSpecial();
55  void getString();
56  void getTokenFromQueue();
57  void getWord();
58  void nextTokenInternal();
59 
60  public:
61  std::string timeWord1;
62  std::string timeWord2;
63  std::string timeWord3;
64  bool FromQueue;
65  bool IgnoreNewLines;
66  Token currentToken;
67  char fch; // Current character read
68  Token previousToken;
69  double tokenDouble;
70  int tokenInteger;
71  double tokenScalar; // Used to retrieve int or double
72  std::string tokenString;
73  int lineNumber();
74 
75  CodeTypes::CodeTypes token();
76 
77 
78  Scanner();
79  void startScanner();
80  bool IsQueueEmpty();
81  char nextChar();
82  std::string tokenToString(const CodeTypes::CodeTypes& code);
83  void AddTokenToQueue();
84  void nextToken();
85  void skipBlanks();
86  void UnGetToken();
87  void AssignStream(std::stringstream& str);
88 }; //class scanner
89 
90 } //rr
91 #endif
Definition: rrScanner.h:36
Definition: rrToken.h:12