[SYSTEMDS-615] Improved error handling parser syntax errors
diff --git a/src/main/java/org/apache/sysds/parser/dml/CustomErrorListener.java b/src/main/java/org/apache/sysds/parser/dml/CustomErrorListener.java
index 13e5f77..619a2ac 100644
--- a/src/main/java/org/apache/sysds/parser/dml/CustomErrorListener.java
+++ b/src/main/java/org/apache/sysds/parser/dml/CustomErrorListener.java
@@ -136,19 +136,17 @@
 	 * Syntax error occurred. Add the error to the list of parse issues.
 	 */
 	@Override
-	public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
-			String msg, RecognitionException e) {
+	public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol,
+		int line, int charPositionInLine, String msg, RecognitionException e)
+	{
+		msg = msg + " ("+offendingSymbol.toString()+")";
 		parseIssues.add(new ParseIssue(line, charPositionInLine, msg, currentFileName, ParseIssueType.SYNTAX_ERROR));
 		try {
 			setAtLeastOneError(true);
-			// Print error messages with file name
-			if (currentFileName == null)
-				log.error("line " + line + ":" + charPositionInLine + " " + msg);
-			else {
-				String fileName = currentFileName;
-				log.error(fileName + " line " + line + ":" + charPositionInLine + " " + msg);
-			}
-		} catch (Exception e1) {
+			String out = (currentFileName != null) ? (currentFileName + ", ") : "";
+			log.error(out + "line " + line + ":" + charPositionInLine + " " + msg);
+		}
+		catch (Exception e1) {
 			log.error("ERROR: while customizing error message:" + e1);
 		}
 	}
diff --git a/src/test/java/org/apache/sysds/test/functions/mlcontext/MLContextTest.java b/src/test/java/org/apache/sysds/test/functions/mlcontext/MLContextTest.java
index ac7b3e7..3e07b15 100644
--- a/src/test/java/org/apache/sysds/test/functions/mlcontext/MLContextTest.java
+++ b/src/test/java/org/apache/sysds/test/functions/mlcontext/MLContextTest.java
@@ -1494,6 +1494,26 @@
 		setExpectedStdOut("3 15.000000");
 		ml.execute(script);
 	}
+	
+	@Test
+	public void testErrorHandlingTwoIdentifiers() {
+		try {
+			System.out.println("MLContextTest - error handling two identifiers");
+			Script script = dml("foo bar");
+			ml.execute(script);
+		}
+		catch(Exception ex) {
+			Throwable t = ex;
+			while( t.getCause() != null )
+				t = t.getCause();
+			System.out.println(t.getMessage());
+			Assert.assertTrue(t.getMessage().contains("foo bar"));
+			//unfortunately, the generated antlr parser creates the concatenated msg
+			//we do a best effort error reporting here, by adding the offending symbol
+			//Assert.assertFalse(t.getMessage().contains("foobar"));
+			Assert.assertTrue(t.getMessage().contains("'bar'"));
+		}
+	}
 
 	@Test
 	public void testInputVariablesAddLongsDML() {