1 /* Hapy is a public domain software. See Hapy README file for the details. */ 2 3 #ifndef HAPY_RESULT__H 4 #define HAPY_RESULT__H 5 6 #include <Hapy/Top.h> 7 #include <Hapy/Pree.h> 8 9 namespace Hapy { 10 11 // parsing result 12 class Result { 13 public: 14 enum { scNone, scMore, scMatch, scMiss, scError }; 15 class StatusCode { 16 public: theCode(aCode)17 StatusCode(int aCode = scNone): theCode(aCode) {} 18 19 bool operator ==(const StatusCode &sc) const { return sc.theCode == theCode; } 20 bool operator !=(const StatusCode &sc) const { return !(*this == sc); } 21 sc()22 int sc() const { return theCode; } 23 const string &str() const; 24 25 private: 26 int theCode; 27 }; 28 Result()29 Result(): statusCode(scNone), maxPos(0) {} 30 known()31 bool known() const { return statusCode != scNone; } 32 33 string location() const; 34 35 public: 36 Pree pree; // parsing tree 37 StatusCode statusCode; // final status code 38 string::size_type maxPos; // maximum input position reached 39 string input; // a copy of the input string 40 }; 41 42 } // namespace 43 44 #endif 45 46