add error locations to exceptions in the ADM parser
escape HTML entities in error messages for the WebUI
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
index dae1fb1..4ce840d 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/Lexer.java
@@ -96,6 +96,14 @@
new String(buffer, 0, bufpos);
}
+ public int getColumn() {
+ return column;
+ }
+
+ public int getLine() {
+ return line;
+ }
+
public static String tokenKindToString(int token) {
return tokenImage[token];
}
@@ -108,22 +116,14 @@
// Parse error management
// ================================================================================
- protected int parseError(String reason) throws [LEXER_NAME]Exception {
- StringBuilder message = new StringBuilder();
- message.append(reason).append("\n");
- message.append("Line: ").append(line).append("\n");
- message.append("Row: ").append(column).append("\n");
- throw new [LEXER_NAME]Exception(message.toString());
- }
-
protected int parseError(int ... tokens) throws [LEXER_NAME]Exception {
StringBuilder message = new StringBuilder();
- message.append("Error while parsing. ");
- message.append(" Line: ").append(line);
- message.append(" Row: ").append(column);
- message.append(" Expecting:");
- for (int tokenId : tokens){
- message.append(" ").append([LEXER_NAME].tokenKindToString(tokenId));
+ message.append("Parse error at (").append(line).append(", ").append(column).append(")");
+ if (tokens.length > 0) {
+ message.append(" expecting:");
+ for (int tokenId : tokens){
+ message.append(" ").append([LEXER_NAME].tokenKindToString(tokenId));
+ }
}
throw new [LEXER_NAME]Exception(message.toString());
}