00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "jdl_parser.hpp"
00019
00020 using namespace jdl;
00021
00022 bool jdl::parse_string(jdl_parser& parser, std::string const& jdl){
00023 if(jdl.length() == 0)
00024 return false;
00025 try{
00026 return parser.parse(jdl);
00027 }catch(parser_error<Errors, char const *> ex){
00028 std::ostringstream err;
00029 err << "Syntax error occurred: " << endl;
00030 switch(ex.descriptor){
00031 case semicolon_expected:
00032 err << "';' expected";
00033 break;
00034 case right_quad_par_expected:
00035 err << "']' expected";
00036 break;
00037 case right_round_par_expected:
00038 err << "')' expected";
00039 break;
00040 case right_graph_par_expected:
00041 err << "'}' expected";
00042 break;
00043 case colon_expected:
00044 err << "':' expected";
00045 break;
00046 case attribute_expected:
00047 err << "valid attribute expected";
00048 break;
00049 default:
00050 err << "Error occured";
00051 }
00052 pair<int,int> err_desc = iter2RowCol(jdl, ex.where);
00053 throw jdl::parse_error(err.str(), err_desc.first, err_desc.second);
00054 }catch(semantic_error e){
00055 string error = e.what();
00056 pair<int,int> err_desc = iter2RowCol(jdl, e.where);
00057 throw jdl::parse_error(error, err_desc.first, err_desc.second);
00058 }
00059 }