]> git.localhorst.tv Git - l2e.git/commitdiff
made high level parser errors a bit more expressive
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 3 Sep 2012 19:56:12 +0000 (21:56 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 3 Sep 2012 19:56:12 +0000 (21:56 +0200)
src/loader/ParsedSource.cpp

index 90498e71f3e17ee5e2b96dea5d58803994851cc3..c0d3a411782fea5e840b97720b2222c8d120a416 100644 (file)
@@ -90,7 +90,14 @@ Definition &ParsedSource::GetDefinition(const std::string &name) {
        if (i != definitions.end()) {
                return *i->second;
        } else {
-               throw runtime_error("undefined identifier " + name);
+               string msg("undefined identifier " + name);
+               map<string, Declaration *>::const_iterator i(declarations.find(name));
+               if (i != declarations.end()) {
+                       msg += ", declared as " + i->second->TypeName();
+               } else {
+                       msg += ", not declared";
+               }
+               throw runtime_error(msg);
        }
 }
 
@@ -99,7 +106,14 @@ const Definition &ParsedSource::GetDefinition(const std::string &name) const {
        if (i != definitions.end()) {
                return *i->second;
        } else {
-               throw runtime_error("undefined identifier " + name);
+               string msg("undefined identifier " + name);
+               map<string, Declaration *>::const_iterator i(declarations.find(name));
+               if (i != declarations.end()) {
+                       msg += ", declared as " + i->second->TypeName();
+               } else {
+                       msg += ", not declared";
+               }
+               throw runtime_error(msg);
        }
 }