Index: src/Common/SemanticError.cc
===================================================================
--- src/Common/SemanticError.cc	(revision fa2de9578cda12bc9dfa0f3bc8f2c87a3754e630)
+++ src/Common/SemanticError.cc	(revision 294647bb36b8887ef83cb50ce4390321fab6d613)
@@ -34,5 +34,7 @@
 
 void SemanticError::append( const std::string & msg ) {
-  errors.push_back( std::string( "Error: ") + msg );
+  using std::to_string;
+  const std::string loc = location.linenumber >= 0 ? "At \"" + to_string(location) + "\" " : "";
+  errors.push_back( loc + "Error: " + msg );
 }
 
@@ -45,4 +47,12 @@
 }
 
+void SemanticError::set_location( const CodeLocation& location ) {
+  this->location = location;
+  using std::to_string;
+  const std::string loc = location.linenumber >= 0 ? "At \"" + to_string(location) + "\" " : "";
+  auto& error = *errors.begin();
+  error.insert( 0, loc.c_str());
+}
+
 // Local Variables: //
 // tab-width: 4 //
Index: src/Common/SemanticError.h
===================================================================
--- src/Common/SemanticError.h	(revision fa2de9578cda12bc9dfa0f3bc8f2c87a3754e630)
+++ src/Common/SemanticError.h	(revision 294647bb36b8887ef83cb50ce4390321fab6d613)
@@ -23,4 +23,6 @@
 #include <iostream>
 
+#include "utility.h"
+
 class SemanticError : public std::exception {
   public:
@@ -35,8 +37,10 @@
 	void print( std::ostream &os );
 
+	void set_location( const CodeLocation& location );
 	// constructs an exception using the given message and the printed
 	// representation of the obj (T must have a print method)
   private:
 	std::list< std::string > errors;
+	CodeLocation location;
 };
 
Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision fa2de9578cda12bc9dfa0f3bc8f2c87a3754e630)
+++ src/Common/utility.h	(revision 294647bb36b8887ef83cb50ce4390321fab6d613)
@@ -25,6 +25,6 @@
 #include <sstream>
 #include <string>
+
 #include <cassert>
-
 template< typename T >
 static inline T * maybeClone( const T *orig ) {
@@ -303,4 +303,23 @@
 	return group_iterate_t<Args...>(args...);
 }
+
+struct CodeLocation {
+	int linenumber;
+	std::string filename;
+
+	CodeLocation() 
+		: linenumber( -1 )
+		, filename("")
+	{}
+
+	CodeLocation( const char* filename, int lineno )
+		: linenumber( lineno )
+		, filename(filename ? filename : "")
+	{}
+};
+
+inline std::string to_string( const CodeLocation& location ) {
+	return location.filename + ":" + std::to_string(location.linenumber);
+}
 #endif // _UTILITY_H
 
