nicer output
authorJens Thiele <jens.thiele@intra2net.com>
Wed, 20 Dec 2006 10:36:42 +0000 (10:36 +0000)
committerJens Thiele <jens.thiele@intra2net.com>
Wed, 20 Dec 2006 10:36:42 +0000 (10:36 +0000)
codegen/main.cpp

index a76baa7..fe400b2 100644 (file)
@@ -226,6 +226,20 @@ std::ostream &operator<<(std::ostream &o, const t2n_procedure &f) {
      return o;
 }
 
+std::pair<std::string, unsigned>
+get_file_and_line(const xmlpp::Element* root, const xmlpp::Element* element)
+{
+  return std::pair<std::string, unsigned>(get_file(root, element->get_attribute("file")->get_value()),
+                                         boost::lexical_cast<unsigned>(element->get_attribute("line")->get_value())-1);
+}
+
+std::string
+get_file_and_line_as_string(const xmlpp::Element* root, const xmlpp::Element* element)
+{
+  std::pair<std::string, unsigned> fl(get_file_and_line(root,element));
+  return std::string(fl.first)+":"+boost::lexical_cast<std::string>(fl.second);
+}
+
 class Parser
 {
 public:
@@ -284,13 +298,14 @@ protected:
                    if (f.args.back().second.name.empty()) {
                         assert(element->get_attribute("file"));
                         assert(element->get_attribute("line"));
-                        throw parse_error(get_file(root, element->get_attribute("file")->get_value()),
-                                          boost::lexical_cast<unsigned>(element->get_attribute("line")->get_value())-1,
+                        std::pair<std::string, unsigned> file_and_line(get_file_and_line(root, element));
+                        throw parse_error(file_and_line.first,
+                                          file_and_line.second,
                                           std::string("type of parameter `")+f.args.back().first+"' not (yet?) supported");
                    }
               }
          }
-         std::cerr << "Found function: " << f << std::endl;
+         std::cerr << get_file_and_line_as_string(root, element) << ": found procedure: " << f << std::endl;
          m_procedures.push_back(f);
      }