1 //----------------------------------------------------------------------------
\r
3 // Compile intermediate codes
\r
4 // $Date: 2003/01/17 19:37:43 $
\r
6 //----------------------------------------------------------------------------
\r
13 #include "QParseInfo.h"
\r
19 QCompiler(std::istream &is);
\r
20 virtual ~QCompiler();
\r
22 void ReadFromStream(std::istream &is);
\r
23 bool HasError(void) {
\r
26 bool GetState(void) {
\r
30 typedef enum _opnumber {
\r
35 static const int opn_max;
\r
38 virtual bool CompileOneLine(const QParseInfo &pinfo) = 0;
\r
39 virtual void CatchError(const QParseInfo &pinfo, const int at) = 0;
\r
41 QParseInfo ParseOneLine(const std::string &strline) const;
\r
42 bool ExtractComArg(const std::string &strline, const char bra, const char ket,
\r
43 std::string &Com, std::string &Arg) const;
\r
44 bool ExtractField(const std::string &strline, const char delim,
\r
45 std::vector<std::string> &Args) const ;
\r
46 int GetComint(const std::string &_str) const;
\r
49 std::vector<std::string> mLines;
\r
51 bool mState; // true == finished
\r
53 //------------------------------------------------------------------------
\r
54 // Syntax of intermediate code (see also `QCompiler.cpp')
\r
55 //------------------------------------------------------------------------
\r
57 typedef enum _argtype {
\r
64 // Command numbers, each of which corresponds to the index num of OPSTR
\r
66 typedef enum _commandnumber {
\r
86 char opstr[opn_length];
\r
88 int arg_types[opn_arg_max];
\r
91 static const QGATES qgates[];
\r
93 static const char OP_BRA;
\r
94 static const char OP_KET;
\r
95 static const char QB_BRA;
\r
96 static const char QB_KET;
\r
97 static const char DELIM;
\r
100 #endif //QCOMPILER_H
\r