00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #ifndef SKPARSEEXCEPTION_H
00022 #define SKPARSEEXCEPTION_H
00023 
00024 #include "skException.h"
00025 #include "skString.h"
00026 #include "skValist.h"
00027 #include "skStringBuffer.h"
00028 xskNAMED_LITERAL(QuoteStart,skSTR(" near \""));
00029 xskNAMED_LITERAL(QuoteEnd,skSTR("\""));
00033 class CLASSEXPORT skCompileError
00034 {
00035  public:
00039   skCompileError() 
00040     : m_LineNum(0){
00041   }
00045   skCompileError(const skCompileError& e) 
00046     : m_LineNum(e.m_LineNum),m_LexBuffer(e.m_LexBuffer),m_Msg(e.m_Msg){
00047   }
00051   skCompileError(skString location,int line_num,const skString& msg,const skString& lex_buffer)
00052     : m_LineNum(line_num),m_Location(location),m_LexBuffer(lex_buffer),m_Msg(msg){
00053   }
00057   skCompileError& operator=(const skCompileError& e){
00058     m_LineNum=e.m_LineNum;
00059     m_Msg=e.m_Msg;
00060     m_LexBuffer=e.m_LexBuffer;
00061     return *this;
00062   }
00066   skString location() const{
00067     return m_Location;
00068   }
00072   int lineNum() const{
00073     return m_LineNum;
00074   }
00078   skString msg() const{
00079     return m_Msg;
00080   }
00084   skString lexBuffer() const{
00085     return m_LexBuffer;
00086   }
00090   skString toString() const {
00091     return skString::addStrings(m_Location.ptr(),s_colon,skString::from(m_LineNum).ptr(),s_colon,m_Msg.ptr(),s_QuoteStart,m_LexBuffer.ptr(),s_QuoteEnd);
00092   }
00096   bool operator==(const skCompileError& err) const {
00097     return m_Msg==err.m_Msg;
00098   }
00099  private:
00100   int m_LineNum;
00101   skString m_Location;
00102   skString m_LexBuffer;
00103   skString m_Msg;
00104 };
00105 #ifdef INSTANTIATE_TEMPLATES
00106 EXTERN_TEMPLATE template class CLASSEXPORT skTVAList<skCompileError>;
00107 #endif
00108 
00111 class CLASSEXPORT skCompileErrorList : public skTVAList<skCompileError> 
00112 {
00113 };
00117 class CLASSEXPORT skParseException : public skException
00118 {
00119  public:
00123   skParseException(){
00124   }
00128   void setErrors(const skCompileErrorList& errors){
00129     m_Errors=errors;
00130   }
00134   const skCompileErrorList& getErrors() const{
00135     return m_Errors;
00136   }
00140   skString getMessage() const {
00141     skString ret;
00142     if (m_Errors.entries())
00143       ret=m_Errors[0].msg();
00144     return ret;
00145   }
00150   skString toString() const {
00151     skStringBuffer ret(50);
00152     for (unsigned int i=0;i<m_Errors.entries();i++){
00153       ret.append(m_Errors[i].toString());
00154       ret.append(skSTR("\n"));
00155     }
00156     return ret.toString();
00157   }
00158  private:
00159   skCompileErrorList m_Errors;
00160 };
00161 
00162 #endif