Index: src/Parser/lex.ll
===================================================================
--- src/Parser/lex.ll	(revision afce1cf9fb278146b08c9dbe44f83a4f6b1de290)
+++ src/Parser/lex.ll	(revision e5fccf454d054b5dedcbb2908d1ac9b763bab7d1)
@@ -10,6 +10,6 @@
  * Created On       : Sat Sep 22 08:58:10 2001
  * Last Modified By : Peter A. Buhr
- * Last Modified On : Tue Aug 22 22:43:39 2017
- * Update Count     : 558
+ * Last Modified On : Wed Aug 30 07:53:24 2017
+ * Update Count     : 583
  */
 
@@ -19,5 +19,5 @@
 
 %{
-// This lexer assumes the program has been preprocessed by cpp. Hence, all user level preprocessor directive have been
+// The lexer assumes the program has been preprocessed by cpp. Hence, all user level preprocessor directive have been
 // performed and removed from the source. The only exceptions are preprocessor directives passed to the compiler (e.g.,
 // line-number directives) and C/C++ style comments, which are ignored.
@@ -25,6 +25,10 @@
 //**************************** Includes and Defines ****************************
 
+unsigned int column = 0;								// position of the end of the last token parsed
+#define YY_USER_ACTION column += yyleng;				// trigger before each matching rule's action
+
 #include <string>
 #include <cstdio>										// FILENAME_MAX
+using namespace std;
 
 #include "ParseNode.h"
@@ -32,13 +36,13 @@
 
 char *yyfilename;
-std::string *strtext;									// accumulate parts of character and string constant value
+string *strtext;										// accumulate parts of character and string constant value
 
 #define RETURN_LOCN(x)		yylval.tok.loc.file = yyfilename; yylval.tok.loc.line = yylineno; return( x )
-#define RETURN_VAL(x)		yylval.tok.str = new std::string( yytext ); RETURN_LOCN( x )
+#define RETURN_VAL(x)		yylval.tok.str = new string( yytext ); RETURN_LOCN( x )
 #define RETURN_CHAR(x)		yylval.tok.str = nullptr; RETURN_LOCN( x )
 #define RETURN_STR(x)		yylval.tok.str = strtext; RETURN_LOCN( x )
 
 #define WHITE_RETURN(x)		// do nothing
-#define NEWLINE_RETURN()	WHITE_RETURN( '\n' )
+#define NEWLINE_RETURN()	column = 0; WHITE_RETURN( '\n' )
 #define ASCIIOP_RETURN()	RETURN_CHAR( (int)yytext[0] ) // single character operator
 #define NAMEDOP_RETURN(x)	RETURN_CHAR( x )			// multichar operator, with a name
@@ -154,5 +158,5 @@
 		memcpy( &filename, begin_string + 1, length );	// copy file name from yytext
 		filename[ length ] = '\0';						// terminate string with sentinel
-		//std::cout << "file " << filename << " line " << lineno << std::endl;
+		//cout << "file " << filename << " line " << lineno << endl;
 		yylineno = lineno;
 		yyfilename = filename;
@@ -302,5 +306,5 @@
 
 				/* character constant, allows empty value */
-({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new std::string( yytext, yyleng ); }
+({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new string( yytext, yyleng ); }
 <QUOTE>[^'\\\n]* { strtext->append( yytext, yyleng ); }
 <QUOTE>['\n]	{ BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); }
@@ -308,5 +312,5 @@
 
 				/* string constant */
-({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new std::string( yytext, yyleng ); }
+({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new string( yytext, yyleng ); }
 <STRING>[^"\\\n]* { strtext->append( yytext, yyleng ); }
 <STRING>["\n]	{ BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); }
@@ -422,8 +426,14 @@
 }
 
-				/* unknown characters */
-.				{ printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno); }
+				/* unknown character */
+.				{ yyerror( "unknown character" ); }
 
 %%
+// ----end of lexer----
+
+void yyerror( const char * errmsg ) {
+	cout << (yyfilename ? yyfilename : "*unknown file*") << ':' << yylineno << ':' << column - yyleng + 1
+		 << ':' << SemanticError::error_str() << errmsg << " at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;
+}
 
 // Local Variables: //
Index: src/Parser/parser.yy
===================================================================
--- src/Parser/parser.yy	(revision afce1cf9fb278146b08c9dbe44f83a4f6b1de290)
+++ src/Parser/parser.yy	(revision e5fccf454d054b5dedcbb2908d1ac9b763bab7d1)
@@ -10,6 +10,6 @@
 // Created On       : Sat Sep  1 20:22:55 2001
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Aug 28 13:24:10 2017
-// Update Count     : 2720
+// Last Modified On : Wed Aug 30 07:04:19 2017
+// Update Count     : 2740
 //
 
@@ -48,9 +48,11 @@
 #include <cstdio>
 #include <stack>
+using namespace std;
+
 #include "ParseNode.h"
 #include "TypedefTable.h"
 #include "TypeData.h"
 #include "LinkageSpec.h"
-using namespace std;
+#include "Common/SemanticError.h"						// error_str
 
 extern DeclarationNode * parseTree;
@@ -3133,13 +3135,4 @@
 // ----end of grammar----
 
-extern char *yytext;
-
-void yyerror( const char * ) {
-	if ( yyfilename ) {
-		cout << yyfilename << ":";
-	} // if
-	cout << yylineno << ":1 syntax error at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << endl;
-}
-
 // Local Variables: //
 // mode: c++ //
