Skip to content

Commit

Permalink
Fix cnescatlab#50 Exception structure correction.
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar WALDMANN committed Sep 6, 2017
1 parent c543ac4 commit fa58b53
Show file tree
Hide file tree
Showing 184 changed files with 459 additions and 455 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,4 @@ public File getInputFile() {
return inputFile;
}

/**
* @param str
* to set to ASCII decimal
* @return
* @return ASCII decimal of <code>str</code>
*/
public static final String toASCII(final String str) {
String code = "";
for (char character : str.toCharArray()) {
code += (int) character;
}
return code;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*
*/
public class JFlexException extends Exception {
/** Line separator for system executing the log */
private static final String BLANK = System.getProperty("line.separator");

/**
* Serial Version UID.
Expand All @@ -36,6 +38,16 @@ public JFlexException() {
super();
}

/**
* Constructor with original exception.
*
* @param exception
* the original exception.
*/
public JFlexException(final Exception exception) {
super(exception);
}

/**
* @param pRuleName
* Rules causing the exception
Expand Down Expand Up @@ -77,25 +89,16 @@ public JFlexException(final String pRuleName, final String pFileName, final Stri
*/
private static String errorMessage(String pRuleName, String pFileName, String pMessage,
String pLastScan, int pLine, int pColumn) {
final String message = "i-Code CNES analysis encountered a problem.\n\n" + pMessage + "\n"
+ "CheckerId : " + pRuleName + "\n" + "File : " + pFileName + "\n" + "Line:"
+ pLine + "\n" + "Column:" + pColumn + "\n"
final String message = "i-Code CNES analysis encountered a problem." + BLANK + BLANK
+ pMessage + BLANK + "CheckerId: " + pRuleName + BLANK + "File: "
+ pFileName + BLANK + "Line:" + pLine + BLANK + "Column:" + pColumn + BLANK

+ "Last word scanned :" + pLastScan + "\n"
+ "You can report this issue on : https://github.com/dupuisa/i-CodeCNES/issues/";
+ "Last word scanned : [" + pLastScan + "] [" + toDecimalCode(pLastScan)
+ "]" + BLANK
+ "Please report this issue on : https://github.com/dupuisa/i-CodeCNES/issues/";
return message;
}

/**
* Constructor with original exception.
*
* @param exception
* the original exception.
*/
public JFlexException(final Exception exception) {
super(exception);
}

/**
* @return the fileName
*/
Expand Down Expand Up @@ -137,4 +140,18 @@ public final String getErrorMessage() {
public final String getRuleName() {
return ruleName;
}

/**
* @param str
* to set to ASCII decimal
* @return
* @return ASCII decimal of <code>str</code>
*/
public static final String toDecimalCode(final String str) {
String code = "";
for (char character : str.toCharArray()) {
code += (int) character + " ";
}
return code;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ STRING = \'[^\']*\' | \"[^\"]*\"


[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ SPACE = [\ \r\f\t]
/* DEFAULT STATE */
/********************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ SMBL = \& | \+ | \$


[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ END = END | end
/* ERROR THROWN */
/*********************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ FUNCTION = {VAR}{SPACE}*"("
/* ERROR THROWN */
/*********************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ SEE_FUNC = ([^a-zA-Z0-9\_])?("if" | "elseif" | "forall" | "while" | "where" | "

}
}else{
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Excepted parameter of "+ entList.get(i) +" unreachable.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}

}
Expand Down Expand Up @@ -769,8 +769,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ STRING = \'[^\']*\' | \"[^\"]*\"
LOGGER.fine("Setting error line "+errors.get(i)+" for the variable "+variables.get(i)+".");
setError(locations.get(i),"The variable " + variables.get(i) + " must be defined as constant.", errors.get(i));
}else{
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Error's line of variable's "+ variables.get(i)+" violation unreachable.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
}
}
Expand Down Expand Up @@ -329,8 +329,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ STRING = \'[^\']*\' | \"[^\"]*\"
closeWhileLoop();
identifiers.remove(idLength);
}else{
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Loop's identifier unreachable.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
LOGGER.finest("end method closeCondition");
}
Expand Down Expand Up @@ -411,8 +411,8 @@ WHILE = "while"
<LINE> . {}

[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
4 changes: 2 additions & 2 deletions fr.cnes.analysis.tools.fortran77.rules/lex/COMDATANotUsed.lex
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ WAIT = "sleep" | "wait" | "pause"
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
4 changes: 2 additions & 2 deletions fr.cnes.analysis.tools.fortran77.rules/lex/COMDESIGNAlloc.lex
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ INT = [0-9]+
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
4 changes: 2 additions & 2 deletions fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWAbort.lex
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ GETUID = "GETUID"{SPACE}*\({SPACE}*\)
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
4 changes: 2 additions & 2 deletions fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWExit.lex
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ END = [^a-zA-Z0-9\_]("end")[^a-zA-Z0-9\_]{SPACE}*({IF} | {SELECT} | {DO} |
/* ERROR THROWN */
/*********************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn); }
errorMessage, yytext(), yyline, yycolumn); }
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ return getCheckResults();
/* ERROR STATE */
/************************/
[^] {
String parsedWord = "Word ["+yytext()+"], code [" + toASCII(yytext()) + "]";

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, parsedWord, yyline, yycolumn);
errorMessage, yytext(), yyline, yycolumn);
}
Loading

0 comments on commit fa58b53

Please sign in to comment.