diff --git a/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/Analyzer.java b/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/Analyzer.java index 46c88a17..e6f1a896 100644 --- a/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/Analyzer.java +++ b/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/Analyzer.java @@ -132,16 +132,19 @@ public List check(List pInputFiles, List pLanguageIds Runtime.getRuntime().gc(); } analyzers.add(service.submit(callableAnalysis)); - } } } for (Future> analysis : analyzers) { analysisResultCheckResult.addAll(analysis.get()); } - } catch (NullContributionException | ExecutionException | InterruptedException - | CoreException e) { + } catch (NullContributionException | InterruptedException | CoreException e) { + LOGGER.throwing(this.getClass().getName(), methodName, e); + } catch (ExecutionException exception) { + if (exception.getCause() instanceof JFlexException) { + throw (JFlexException) exception.getCause(); + } } return analysisResultCheckResult; } diff --git a/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/datas/AbstractChecker.java b/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/datas/AbstractChecker.java index 4eb57a3f..10931cfb 100755 --- a/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/datas/AbstractChecker.java +++ b/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/datas/AbstractChecker.java @@ -169,4 +169,17 @@ public File getInputFile() { return inputFile; } + /** + * @param str + * to set to ASCII decimal + * @return + * @return ASCII decimal of str + */ + public static final String toASCII(final String str) { + String code = ""; + for (char character : str.toCharArray()) { + code += (int) character; + } + return code; + } } diff --git a/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/exception/JFlexException.java b/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/exception/JFlexException.java index ab0f981b..b2f771e0 100755 --- a/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/exception/JFlexException.java +++ b/fr.cnes.analysis.tools.analyzer/src/fr/cnes/analysis/tools/analyzer/exception/JFlexException.java @@ -3,7 +3,7 @@ * This software is a free software, under the terms of the Eclipse Public License version 1.0. * http://www.eclipse.org/legal/epl-v10.html * - */ + */ package fr.cnes.analysis.tools.analyzer.exception; /** @@ -12,25 +12,129 @@ */ public class JFlexException extends Exception { - /** - * Serial Version UID. - */ - private static final long serialVersionUID = 4198004753881804823L; - - /** - * Default constructor. - */ - public JFlexException() { - super(); - } - - /** - * Constructor with original exception. - * - * @param exception - * the original exception. - */ - public JFlexException(final Exception exception) { - super(exception); - } + /** + * Serial Version UID. + */ + private static final long serialVersionUID = 4198004753881804823L; + /** fileName causing the exception */ + private String fileName; + /** Line location of the exception */ + private int line; + /** Column location of the exception */ + private int column; + /** Last word scanned during the analysis */ + private String lastScan; + /** Error message defined by the analyzer */ + private String message; + /** Rules causing the exception */ + private String ruleName; + + /** + * Default constructor. + */ + public JFlexException() { + super(); + } + + /** + * @param pRuleName + * Rules causing the exception + * @param pFileName + * fileName causing the exception + * @param pMessage + * Error message defined by the analyzer + * @param pLastScan + * Last word scanned during the analysis + * @param pLine + * Line location of the exception + * @param pColumn + * Column location of the exception + */ + public JFlexException(final String pRuleName, final String pFileName, final String pMessage, + final String pLastScan, final int pLine, final int pColumn) { + super(errorMessage(pRuleName, pFileName, pMessage, pLastScan, pLine, pColumn)); + this.ruleName = pRuleName; + this.fileName = pFileName; + this.message = pMessage; + this.line = pLine; + this.column = pColumn; + } + + /** + * @param pRuleName + * Rules causing the exception + * @param pFileName + * fileName causing the exception + * @param pMessage + * Error message defined by the analyzer + * @param pLastScan + * Last word scanned during the analysis + * @param pLine + * Line location of the exception + * @param pColumn + * Column location of the exception + * @return Exception message related to the parameters. + */ + 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" + + + "Last word scanned :" + pLastScan + "\n" + + "You can 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 + */ + public final String getFileName() { + return fileName; + } + + /** + * @return the line + */ + public final int getLine() { + return line; + } + + /** + * @return the column + */ + public final int getColumn() { + return column; + } + + /** + * @return the lastScan + */ + public final String getLastScan() { + return lastScan; + } + + /** + * @return the message + */ + public final String getErrorMessage() { + return message; + } + + /** + * @return the ruleName + */ + public final String getRuleName() { + return ruleName; + } } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.metrics/lex/ExampleMetric.lex b/fr.cnes.analysis.tools.fortran77.metrics/lex/ExampleMetric.lex index 4cca2718..ab1fbc4b 100755 --- a/fr.cnes.analysis.tools.fortran77.metrics/lex/ExampleMetric.lex +++ b/fr.cnes.analysis.tools.fortran77.metrics/lex/ExampleMetric.lex @@ -39,6 +39,7 @@ import fr.cnes.analysis.tools.analyzer.metrics.FunctionMetricValue; %class GeneratedMetricName %extends AbstractChecker %public +%column %line /* This three lines are not meant to be modified. */ @@ -84,6 +85,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* in this section. */ %{ String location = "MAIN PROGRAM"; + private String parsedFileName; FileMetricValue fileValue; public GeneratedMetricName(){ diff --git a/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METComplexitySimplified.lex b/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METComplexitySimplified.lex index 814f47f4..618778b4 100755 --- a/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METComplexitySimplified.lex +++ b/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METComplexitySimplified.lex @@ -37,8 +37,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %extends AbstractChecker %public %ignorecase -%line %column +%line + %function run %yylexthrow JFlexException @@ -77,10 +78,11 @@ STRING = \'[^\']*\' | \"[^\"]*\" String location = "MAIN PROGRAM"; + private String parsedFileName; float numCiclomatic = 0; float numCiclomaticTotal = 0; int functionLine = 0; - String parsedFileName; + public F77METComplexitySimplified() { @@ -90,7 +92,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); this.parsedFileName = file.toString(); LOGGER.finest("end method setInputFile"); } @@ -228,6 +231,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); - } + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METLineOfCode.lex b/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METLineOfCode.lex index 99f5f244..a3652a27 100755 --- a/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METLineOfCode.lex +++ b/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METLineOfCode.lex @@ -35,8 +35,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %extends AbstractChecker %public %ignorecase -%line %column +%line + %function run %yylexthrow JFlexException @@ -66,10 +67,11 @@ SPACE = [\ \r\f\t] private static final Logger LOGGER = Logger.getLogger(F77METLineOfCode.class.getName()); String location = "MAIN PROGRAM"; + private String parsedFileName; float numLines = 0; float numTotal = 0; int functionLine = 0; - String parsedFileName; + public F77METLineOfCode(){ @@ -79,7 +81,8 @@ SPACE = [\ \r\f\t] public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); this.parsedFileName = file.toString(); LOGGER.finest("end method setInputFile"); } @@ -260,6 +263,8 @@ SPACE = [\ \r\f\t] /* DEFAULT STATE */ /********************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); - } + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METNesting.lex b/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METNesting.lex index df203f68..d0f37c9d 100755 --- a/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METNesting.lex +++ b/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METNesting.lex @@ -36,8 +36,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %extends AbstractChecker %public %ignorecase -%line %column +%line + %function run %yylexthrow JFlexException @@ -73,13 +74,14 @@ SMBL = \& | \+ | \$ String location = "MAIN PROGRAM"; + private String parsedFileName; List identifiers = new LinkedList(); float numImbrics = 0; float numMaxImbrics = 0; float numImbricsTotal = 0; boolean end = true; int functionLine = 0; - String parsedFileName; + public F77METNesting(){ } @@ -88,7 +90,8 @@ SMBL = \& | \+ | \$ public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); this.parsedFileName = file.toString(); LOGGER.finest("end method setInputFile"); } @@ -260,6 +263,8 @@ SMBL = \& | \+ | \$ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); - } + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METRatioComment.lex b/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METRatioComment.lex index 1eab2b58..59bdcf8d 100755 --- a/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METRatioComment.lex +++ b/fr.cnes.analysis.tools.fortran77.metrics/lex/F77METRatioComment.lex @@ -33,8 +33,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %extends AbstractChecker %public %ignorecase -%line %column +%line + %function run %yylexthrow JFlexException @@ -60,11 +61,12 @@ END = END | end String location = "MAIN PROGRAM"; + private String parsedFileName; Float numLines = 0.0f; Float numComments = 0.0f; boolean endLine = true; int functionLine = 0; - String parsedFileName; + public F77METRatioComment() { @@ -74,7 +76,8 @@ END = END | end public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); this.parsedFileName = file.toString(); LOGGER.finest("end method setInputFile"); } @@ -299,7 +302,9 @@ END = END | end /*********************/ /* ERROR THROWN */ /*********************/ - [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); - } \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAFloatCompare.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAFloatCompare.lex index f7648bc4..eeef5683 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAFloatCompare.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAFloatCompare.lex @@ -96,8 +96,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.parsedFileName = file.toString(); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); } @@ -520,6 +521,8 @@ FUNCTION = {VAR}{SPACE}*"(" /* ERROR THROWN */ /*********************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+" \nIllegal character <" + yytext() + "> \nFile :"+ this.parsedFileName+" \nat line:"+yyline+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); - } \ No newline at end of file + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAInitialisation.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAInitialisation.lex index 3b4445da..0ef04f6f 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAInitialisation.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAInitialisation.lex @@ -144,8 +144,9 @@ SEE_FUNC = ([^a-zA-Z0-9\_])?("if" | "elseif" | "forall" | "while" | "where" | " public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.parsedFileName = file.toString(); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); } @@ -260,14 +261,19 @@ SEE_FUNC = ([^a-zA-Z0-9\_])?("if" | "elseif" | "forall" | "while" | "where" | " if(entList!=null && !entList.isEmpty()) for(int i=0;i\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; + throw new JFlexException(new Exception(errorMessage)); } } @@ -761,6 +767,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); - } \ No newline at end of file + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAInvariant.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAInvariant.lex index fa1d53e3..ce01dffa 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAInvariant.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATAInvariant.lex @@ -82,8 +82,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.parsedFileName = file.toString(); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); } @@ -104,8 +105,13 @@ STRING = \'[^\']*\' | \"[^\"]*\" LOGGER.finest("begin method printError"); for(int i=0; i < locations.size(); i++) { if(usedVariables.contains(variables.get(i))){ - 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)); + if(errors.size() > i){ + 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 errorMessage = "Class"+this.getClass().getName()+"\nImpossible to reach error's line for variable"+ variables.get(i)+" violation. <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; + throw new JFlexException(new Exception(errorMessage)); + } } } LOGGER.finest("end method printError"); @@ -321,6 +327,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATALoopCondition.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATALoopCondition.lex index 192b7b31..bfc5c02e 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATALoopCondition.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATALoopCondition.lex @@ -91,8 +91,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.parsedFileName = file.toString(); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); } @@ -100,14 +101,19 @@ STRING = \'[^\']*\' | \"[^\"]*\" - DO -> check conditionsDo list - WHILE -> check conditionsWhile list **/ - private void closeCondition() { + private void closeCondition() throws JFlexException { LOGGER.finest("begin method closeCondition"); int idLength = identifiers.size() - 1; - if (identifiers.get(idLength).equals("DO")) - closeDoLoop(); - else if (identifiers.get(idLength).equals("WHILE")) - closeWhileLoop(); - identifiers.remove(idLength); + if(idLength >= 0){ + if (identifiers.get(idLength).equals("DO")) + closeDoLoop(); + else if (identifiers.get(idLength).equals("WHILE")) + closeWhileLoop(); + identifiers.remove(idLength); + }else{ + String errorMessage = "Class"+this.getClass().getName()+"\nLoop's identifier unreachable while parsing <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; + throw new JFlexException(new Exception(errorMessage)); + } LOGGER.finest("end method closeCondition"); } @@ -403,6 +409,8 @@ WHILE = "while" . {} [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATANotUsed.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATANotUsed.lex index 3244b94a..f763055f 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATANotUsed.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDATANotUsed.lex @@ -80,8 +80,9 @@ EQUAL = \= [^\,\n\"\']* public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.parsedFileName = file.toString(); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); } @@ -271,6 +272,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDESIGNActiveWait.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDESIGNActiveWait.lex index dc3f6434..17715e60 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDESIGNActiveWait.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDESIGNActiveWait.lex @@ -72,8 +72,9 @@ WAIT = "sleep" | "wait" | "pause" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.parsedFileName = file.toString(); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); } @@ -220,6 +221,8 @@ WAIT = "sleep" | "wait" | "pause" /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDESIGNAlloc.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDESIGNAlloc.lex index cb7f52f6..18ac27ca 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMDESIGNAlloc.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMDESIGNAlloc.lex @@ -83,8 +83,9 @@ INT = [0-9]+ public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.parsedFileName = file.toString(); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); } @@ -383,6 +384,8 @@ INT = [0-9]+ /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWAbort.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWAbort.lex index 9d645eba..3d779770 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWAbort.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWAbort.lex @@ -69,6 +69,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -183,6 +184,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWBooleanExpression.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWBooleanExpression.lex index 85696737..2026f3d0 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWBooleanExpression.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWBooleanExpression.lex @@ -77,6 +77,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -201,6 +202,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWCheckCodeReturn.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWCheckCodeReturn.lex index 81435aeb..27108e38 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWCheckCodeReturn.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWCheckCodeReturn.lex @@ -148,6 +148,7 @@ AVOIDED = {SPACE}*( "abs" | "achar" | "acos" | "acosh" | "adjustl" | "adjustr" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); codeLevel.add(1); @@ -566,6 +567,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWCheckUser.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWCheckUser.lex index ee57a9ff..6d93fc5c 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWCheckUser.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWCheckUser.lex @@ -70,8 +70,9 @@ GETUID = "GETUID"{SPACE}*\({SPACE}*\) public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.parsedFileName = file.toString(); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); } @@ -222,6 +223,8 @@ GETUID = "GETUID"{SPACE}*\({SPACE}*\) /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWExit.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWExit.lex index 4a550293..f6b182cf 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWExit.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWExit.lex @@ -75,6 +75,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -205,6 +206,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWExitLoop.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWExitLoop.lex index 2d6f6151..b72fa28d 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWExitLoop.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWExitLoop.lex @@ -81,6 +81,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -225,6 +226,7 @@ END = [^a-zA-Z0-9\_]("end")[^a-zA-Z0-9\_]{SPACE}*({IF} | {SELECT} | {DO} | /* ERROR THROWN */ /*********************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); - } \ No newline at end of file + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWFileExistence.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWFileExistence.lex index 003b0c3e..7a140723 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWFileExistence.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWFileExistence.lex @@ -84,6 +84,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -267,6 +268,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); - } \ No newline at end of file + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWFilePath.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWFilePath.lex index dcd7612d..ffb6d40d 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWFilePath.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMFLOWFilePath.lex @@ -72,6 +72,7 @@ FILENAME = \'[\.]*[a-zA-Z\/][a-zA-Z0-9\_\/]*(\.[a-zA-Z0-9]+)?\' | public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -203,6 +204,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTBoolNegation.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTBoolNegation.lex index c946ac3d..dd89ecd1 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTBoolNegation.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTBoolNegation.lex @@ -72,6 +72,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -215,6 +216,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTBrace.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTBrace.lex index 8ae3f1a8..12f45dca 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTBrace.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTBrace.lex @@ -82,6 +82,7 @@ SPACE = [\ \r\t\f] public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -102,12 +103,17 @@ SPACE = [\ \r\t\f] parenthesis.remove(index); parenthesis.add(value); if (value == 0) { - if (operators.get(index) > 1){ - LOGGER.fine("Setting error line "+(yyline+1)+" because parentheses are needed for readability."); - setError(location,"Parentheses are needed for readability.", yyline+1); - } - parenthesis.remove(index); - operators.remove(index); + if(operators.size() > index){ + if (operators.get(index) > 1){ + LOGGER.fine("Setting error line "+(yyline+1)+" because parentheses are needed for readability."); + setError(location,"Parentheses are needed for readability.", yyline+1); + } + parenthesis.remove(index); + operators.remove(index); + }else{ + String errorMessage = "Class"+this.getClass().getName()+"\n Operator not reachable while parsing <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; + throw new JFlexException(new Exception(errorMessage)); + } } } LOGGER.finest("end method closeParenthesis"); @@ -374,6 +380,8 @@ SPACE = [\ \r\t\f] /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTCodeComment.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTCodeComment.lex index e2993b5a..8a3cf6c6 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTCodeComment.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTCodeComment.lex @@ -130,6 +130,7 @@ SPACE = [\ \r\t\f] public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -331,6 +332,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTGoTo.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTGoTo.lex index b7211ddb..17ae684b 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTGoTo.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTGoTo.lex @@ -69,6 +69,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -166,6 +167,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTLoopCondition.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTLoopCondition.lex index 1ca83636..f48b785f 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTLoopCondition.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMINSTLoopCondition.lex @@ -73,6 +73,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -190,6 +191,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMNAMEHomonymy.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMNAMEHomonymy.lex index 1fa60069..eb4c8a94 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMNAMEHomonymy.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMNAMEHomonymy.lex @@ -88,6 +88,7 @@ SPACE = [\ \r\t\f] public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -219,7 +220,11 @@ return getCheckResults(); {TYPE} {location = yytext(); LOGGER.fine("["+this.parsedFileName+":"+(yyline+1)+":"+yycolumn+"] - NEW_LINE -> NAMING (Transition : TYPE \""+yytext()+"\" )"); yybegin(NAMING);} - {END_TYPE} {locOrder.remove(locOrder.size()-1);} + {END_TYPE} { + if(locOrder.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis failure : Location unreachable.", yytext(), yyline, yycolumn); + } + locOrder.remove(locOrder.size()-1);} {DATA_TYPE} {par=0; LOGGER.fine("["+this.parsedFileName+":"+(yyline+1)+":"+yycolumn+"] - NEW_LINE -> DECLARATION (Transition : DATA_TYPE \""+yytext()+"\" )"); yybegin(DECLARATION);} @@ -240,7 +245,11 @@ return getCheckResults(); {TYPE} {location = yytext(); LOGGER.fine("["+this.parsedFileName+":"+(yyline+1)+":"+yycolumn+"] - LINE -> NAMING (Transition : TYPE \""+yytext()+"\" )"); yybegin(NAMING);} - {END_TYPE} {locOrder.remove(locOrder.size()-1);} + {END_TYPE} { + if(locOrder.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis failure : Location unreachable.", yytext(), yyline, yycolumn); + } + locOrder.remove(locOrder.size()-1);} {DATA_TYPE} {par=0; LOGGER.fine("["+this.parsedFileName+":"+(yyline+1)+":"+yycolumn+"] - LINE -> DECLARATION (Transition : DATA_TYPE \""+yytext()+"\" )"); yybegin(DECLARATION);} @@ -353,6 +362,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMPRESIndent.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMPRESIndent.lex index c4456987..8f63863f 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMPRESIndent.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMPRESIndent.lex @@ -96,6 +96,7 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -497,6 +498,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMPRESLengthLine.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMPRESLengthLine.lex index 75f40e65..11434c77 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMPRESLengthLine.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMPRESLengthLine.lex @@ -67,6 +67,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -197,6 +198,8 @@ return getCheckResults(); /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMPROJECTHeader.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMPROJECTHeader.lex index c14913c0..764c2f75 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMPROJECTHeader.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMPROJECTHeader.lex @@ -80,6 +80,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -110,7 +111,10 @@ STRING = \'[^\']*\' | \"[^\"]*\" private void raiseErrors() throws JFlexException { LOGGER.finest("begin method raiseErrors"); - + if(linesType.isEmpty()){ + String errorMessage = "Class"+this.getClass().getName()+"\nRaising violation failed. Line type unreachable while parsing <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; + throw new JFlexException(new Exception(errorMessage)); + } if (!linesType.get(0).equals("comment") && !linesType.get(1).equals("comment")){ LOGGER.fine("Setting error line 0 because no file header (file name not found). This module/function should have a header with a brief description.."); this.setError("No file header existing.","This module/function should have a header with a brief description.", 0); @@ -269,6 +273,8 @@ SPACE = [\ \f\t]+ /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/COMTYPEExpression.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/COMTYPEExpression.lex index 505a5647..846e577a 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/COMTYPEExpression.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/COMTYPEExpression.lex @@ -113,6 +113,7 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] | \* public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -386,6 +387,8 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] | \* /* ERROR STATE */ /************************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCCommon.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCCommon.lex index 0483363b..e3649faa 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCCommon.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCCommon.lex @@ -67,6 +67,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -184,6 +185,8 @@ RULE_WORD = {COMMON}([^\/\n]*)([\n]) /* ERROR THROWN */ /*********************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCElse.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCElse.lex index d5a4a753..9adafec8 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCElse.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCElse.lex @@ -74,6 +74,7 @@ INT = [0-9]+ public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -283,6 +284,8 @@ CONT = CONTINUE| continue /* ERROR THROWN */ /*********************/ [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCFunction.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCFunction.lex index 9fed3c4a..28b5669d 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCFunction.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCFunction.lex @@ -78,6 +78,7 @@ EQUAL = \= public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -223,6 +224,8 @@ return getCheckResults(); yybegin(COMMENT);} [^] { - String errorMessage = "Class"+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+(yyline+1)+" column:"+yycolumn; - throw new JFlexException(new Exception(errorMessage)); + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCLoop.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCLoop.lex index b44e0f0e..ef23fbb2 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCLoop.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77BLOCLoop.lex @@ -69,6 +69,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); @@ -201,4 +202,9 @@ INT = [0-9]+ yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAArray.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAArray.lex index ec00b8f0..33c8626c 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAArray.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAArray.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77DATAArray %extends AbstractChecker %public +%column %line %function run @@ -69,6 +70,8 @@ SMB = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] String variable = ""; /** boolean to know if the comment line exist **/ boolean comment = false; + /** name of the file parsed */ + private String parsedFileName; public F77DATAArray() { } @@ -76,7 +79,9 @@ SMB = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -158,4 +163,9 @@ SMB = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATACommon.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATACommon.lex index 4095a8a4..897e118e 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATACommon.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATACommon.lex @@ -33,6 +33,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77DATACommon %extends AbstractChecker %public +%column %line %function run @@ -74,7 +75,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.finest("begin method setInputFile"); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.finest("end method setInputFile"); } @@ -201,4 +203,11 @@ return getCheckResults(); } . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + + 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); + } + \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATADouble.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATADouble.lex index 659fe12e..23bf5d25 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATADouble.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATADouble.lex @@ -32,6 +32,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %extends AbstractChecker %public %line +%column %ignorecase %function run @@ -70,7 +71,9 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] | \~ /** Current variabe to analize **/ String variable = ""; /** Evluation boolean to detect if an error can be thrown or not **/ - boolean eval = false; + boolean eval = false; + /** name of the file parsed */ + private String parsedFileName; public F77DATADouble() { } @@ -78,7 +81,8 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] | \~ @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } /** If the var found is a double precision, check is there is a number after that @@ -158,4 +162,9 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] | \~ \n {eval = false; yybegin(NEW_LINE);} . {eval = false; yybegin(LINE);} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAIO.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAIO.lex index f862b694..6ec04721 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAIO.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAIO.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77DATAIO %extends AbstractChecker %public +%column %line %function run @@ -56,7 +57,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ String location = "MAIN PROGRAM"; - String io; + String io; + /** name of the file parsed */ + private String parsedFileName; public F77DATAIO() { } @@ -64,7 +67,8 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -111,4 +115,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAInitialisation.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAInitialisation.lex index 8dada63f..4152d377 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAInitialisation.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAInitialisation.lex @@ -32,6 +32,8 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %extends AbstractChecker %public %line +%column + %function run %yylexthrow JFlexException @@ -58,7 +60,9 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] %{ String location = "MAIN PROGRAM"; - List identifiers = new LinkedList(); + List identifiers = new LinkedList(); + /** name of the file parsed */ + private String parsedFileName; public F77DATAInitialisation() { } @@ -66,7 +70,8 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -130,4 +135,9 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATALoopDO.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATALoopDO.lex index 23b4692b..0f1c9036 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATALoopDO.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATALoopDO.lex @@ -60,7 +60,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" SPACE = [\ \t\r] %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77DATALoopDO() { @@ -69,7 +71,8 @@ SPACE = [\ \t\r] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -211,4 +214,9 @@ WRONG_TYPE = {REAL} | {DOUBLE_PREC} | {COMPLEX} | {LOGICAL} | {CHAR} /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAParameter.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAParameter.lex index 92ee36c6..33897590 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAParameter.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77DATAParameter.lex @@ -32,6 +32,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %extends AbstractChecker %public %line +%column %ignorecase %function run @@ -75,7 +76,9 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] | \* int par = 0; /** Paramters to throw error **/ String errors = ""; - boolean first = true; + boolean first = true; + /** name of the file parsed */ + private String parsedFileName; public F77DATAParameter() { @@ -84,7 +87,8 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] | \* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void checkFucntionParameter(String param) throws JFlexException { @@ -172,4 +176,9 @@ return getCheckResults(); \) {par--; if(par==0) yybegin(PARAMETERS); } [^] {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77ERROpenRead.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77ERROpenRead.lex index f0711862..bfd659d5 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77ERROpenRead.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77ERROpenRead.lex @@ -34,6 +34,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77ERROpenRead %extends AbstractChecker %public +%column %line %function run @@ -81,7 +82,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" String location = "MAIN PROGRAM"; boolean found = false; - boolean multLines = false; + boolean multLines = false; + /** name of the file parsed */ + private String parsedFileName; public F77ERROpenRead() { } @@ -89,7 +92,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -170,4 +174,9 @@ return getCheckResults(); /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTAssign.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTAssign.lex index e309511d..16a29ea3 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTAssign.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTAssign.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77INSTAssign %extends AbstractChecker %public +%column %line %function run @@ -50,7 +51,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* STRING = \'[^\']*\' | \"[^\"]*\" %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77INSTAssign() { @@ -59,7 +62,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -129,4 +133,9 @@ RULE_WORD = assign | ASSIGN /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTDimension.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTDimension.lex index 5d261ab5..1d60a5b8 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTDimension.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTDimension.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77INSTDimension %extends AbstractChecker %public +%column %line %function run @@ -50,7 +51,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* STRING = \'[^\']*\' | \"[^\"]*\" %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77INSTDimension() { @@ -59,7 +62,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -128,4 +132,9 @@ RULE_WORD = dimension | DIMENSION /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTEquivalence.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTEquivalence.lex index 7d19ed34..f36fb32c 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTEquivalence.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTEquivalence.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77INSTEquivalence %extends AbstractChecker %public +%column %line %function run @@ -51,6 +52,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + + /** name of the file parsed */ + private String parsedFileName; public F77INSTEquivalence() { @@ -59,7 +63,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -126,4 +131,9 @@ RULE_WORD = equivalence | EQUIVALENCE \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTFunction.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTFunction.lex index a2211cd7..400c0938 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTFunction.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTFunction.lex @@ -57,6 +57,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" String location = "MAIN PROGRAM"; Boolean explicitDeclaration = false; + + /** name of the file parsed */ + private String parsedFileName; public F77INSTFunction() { } @@ -64,7 +67,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -117,4 +121,10 @@ return getCheckResults(); \n {explicitDeclaration=false; yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } + \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTIf.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTIf.lex index a5bb44d1..93fcecad 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTIf.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTIf.lex @@ -57,7 +57,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" INT = [0-9]+ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; int bracket = 0; @@ -67,7 +69,8 @@ INT = [0-9]+ @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -163,4 +166,9 @@ CONT = CONTINUE | continue /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTInclude.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTInclude.lex index cae6490f..18ddcd54 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTInclude.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTInclude.lex @@ -74,7 +74,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" boolean include = false; private String fileName ; private File includeFile; - private String project; + private String project; + /** name of the file parsed */ + private String parsedFileName; public F77INSTInclude() { this.include = false; @@ -89,7 +91,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); project = getProjectPath(new Path(file.getAbsolutePath()).toOSString()); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void analyseFile(String fileN) throws JFlexException { @@ -210,4 +213,9 @@ return getCheckResults(); /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTPause.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTPause.lex index cd2f638d..780aaf55 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTPause.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTPause.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77INSTPause %extends AbstractChecker %public +%column %line %function run @@ -50,7 +51,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* STRING = \'[^\']*\' | \"[^\"]*\" %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77INSTPause() { @@ -59,7 +62,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -125,4 +129,9 @@ RULE_WORD = pause | PAUSE /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTReturn.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTReturn.lex index cb5c656d..1f9fbd5a 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTReturn.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTReturn.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77INSTReturn %extends AbstractChecker %public +%column %line %function run @@ -53,7 +54,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* A boolean to determine if RETURN has been found once is set. */ /* A last boolean is to determine if it is a RETURN (i) word. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77INSTReturn() { } @@ -61,7 +64,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -124,4 +128,9 @@ RULE_WORD = return | RETURN /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTSave.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTSave.lex index b97c651b..b484606f 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTSave.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77INSTSave.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77INSTSave %extends AbstractChecker %public +%column %line %function run @@ -57,7 +58,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; boolean comment = false; @@ -67,7 +70,8 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void checkSave() throws JFlexException{ @@ -116,4 +120,9 @@ return getCheckResults(); . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77METLine.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77METLine.lex index dad90d2e..0000b450 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77METLine.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77METLine.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F77METLine %extends AbstractChecker %public +%column %line %function run @@ -50,7 +51,9 @@ TYPE = {FUNC} | {PROC} | {SUB} | {PROG} | {MOD} VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; int lineChars = 0; boolean showError = false; @@ -61,7 +64,8 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -114,4 +118,9 @@ return getCheckResults(); } } - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEGenericIntrinsic.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEGenericIntrinsic.lex index bae0a995..1cf7c3ad 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEGenericIntrinsic.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEGenericIntrinsic.lex @@ -33,6 +33,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %extends AbstractChecker %public %line +%column %ignorecase %function run @@ -61,7 +62,9 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] List intrinseques = new LinkedList(); List intrinsequesGeneriques = new LinkedList(); - List variables = new LinkedList(); + List variables = new LinkedList(); + /** name of the file parsed */ + private String parsedFileName; public F77NAMEGenericIntrinsic() { List intr = Arrays.asList("IFIX","IDINT","FLOAT","SNGL","ICHAR","CHAR","DINT","DNINT","IDNINT","IABS","DABS","CABS","AMOD","DMOD","ISIGN","DSIGN","IDIM","DDIM","DPROD","MAX0","AMAX1","DMAX1","AMAX0","MAX1","MIN0","AMIN1","DMIN1","AMIN0","MIN1","DSQRT","CSQRT","DEXP","CEXP","ALOG","DLOG","CLOG","ALOG10","DLOG10","DSIN","CSIN","DCOS","CCOS","DTAN","DASIN","DACOS","DATAN","DATAN2","DSINH","DCOSH","DTANH"); @@ -73,7 +76,8 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void checkFunctionName(String text) throws JFlexException { @@ -129,4 +133,9 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | [0-9] \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEIntrinsic.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEIntrinsic.lex index 21b599eb..20a93005 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEIntrinsic.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEIntrinsic.lex @@ -37,6 +37,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F77NAMEIntrinsic %extends AbstractChecker %public +%column %line %function run @@ -59,7 +60,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; - List intrinseques = new LinkedList(); + List intrinseques = new LinkedList(); + /** name of the file parsed */ + private String parsedFileName; public F77NAMEIntrinsic() { //readFile(); @@ -70,7 +73,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void checkFunctionName(String text) throws JFlexException { @@ -147,4 +151,9 @@ return getCheckResults(); \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEKeyWords.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEKeyWords.lex index e9a47903..3e8a53a6 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEKeyWords.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMEKeyWords.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77NAMEKeyWords %extends AbstractChecker %public +%column %line %function run @@ -64,7 +65,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" SPACE = [\ \t\r] %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77NAMEKeyWords() { @@ -73,7 +76,8 @@ SPACE = [\ \t\r] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -124,5 +128,9 @@ SPACE = [\ \t\r] /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} - + [^] { + 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); + } diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMELabel.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMELabel.lex index 9aca5037..50d0392b 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMELabel.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77NAMELabel.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77NAMELabel %extends AbstractChecker %public +%column %line %function run @@ -55,7 +56,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* STRING = \'[^\']*\' | \"[^\"]*\" %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77NAMELabel() { @@ -64,7 +67,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -108,5 +112,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} - + [^] { + 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); + } diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77PROTODeclaration.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77PROTODeclaration.lex index dd98b5c3..53192eb6 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77PROTODeclaration.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77PROTODeclaration.lex @@ -33,6 +33,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %extends AbstractChecker %public %line +%column %ignorecase %function run @@ -74,7 +75,9 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | \* /** Posible list of error locatin **/ List errorLocation = new LinkedList(); /** Posible list of error lines **/ - List errorLine = new LinkedList(); + List errorLine = new LinkedList(); + /** name of the file parsed */ + private String parsedFileName; public F77PROTODeclaration() { @@ -89,7 +92,8 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | \* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } /** For each value of call functions see if the is a true error. An error is when the function called is @@ -187,5 +191,9 @@ SIMBOL = \& | \$ | \+ | [A-Za-z][\ ] | \. | \* /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} - + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFIO.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFIO.lex index 116d442f..771e344e 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFIO.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFIO.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77REFIO %extends AbstractChecker %public +%column %line %function run @@ -53,7 +54,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* INT = [0-9]+ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77REFIO() { @@ -62,7 +65,8 @@ INT = [0-9]+ @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -106,7 +110,6 @@ return getCheckResults(); \( {yybegin(RD_WR_PARAM);} \n {yybegin(NEW_LINE);} . {} - \, {yybegin(LINE);} {INT} {setError(location,"The logical entities shall be declared using a symbolic name.", yyline+1);} {VAR} {} @@ -114,4 +117,9 @@ return getCheckResults(); . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFOpen.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFOpen.lex index 5199a778..8b1bad47 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFOpen.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFOpen.lex @@ -34,6 +34,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F77REFOpen %extends AbstractChecker %public +%column %line %function run @@ -66,7 +67,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" boolean statusFound = false; boolean unknownFound = false; boolean positionFound = false; - boolean multLines = false; + boolean multLines = false; + /** name of the file parsed */ + private String parsedFileName; public F77REFOpen() { } @@ -74,7 +77,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } public void checkViolation(final boolean fileFound, final boolean scratchFound, final boolean statusFound, final boolean unknownFound, final boolean positionFound) throws JFlexException { @@ -151,4 +155,9 @@ POSITION = position | POSITION \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFParameter.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFParameter.lex index e90be816..5238f0c9 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFParameter.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77REFParameter.lex @@ -32,6 +32,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %extends AbstractChecker %public %line +%column %function run %yylexthrow JFlexException @@ -57,7 +58,9 @@ PARAM = [^\,\)\n\ ] %{ String location = "MAIN PROGRAM"; - List commonList = new LinkedList(); + List commonList = new LinkedList(); + /** name of the file parsed */ + private String parsedFileName; public F77REFParameter() { } @@ -65,7 +68,8 @@ PARAM = [^\,\)\n\ ] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -129,4 +133,9 @@ PARAM = [^\,\)\n\ ] . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77TYPEBasic.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77TYPEBasic.lex index fcf447e1..072a7a7c 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77TYPEBasic.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77TYPEBasic.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %extends AbstractChecker %public %line +%column %function run %yylexthrow JFlexException @@ -56,7 +57,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" SPACE = [\ \t\r] %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77TYPEBasic() { @@ -65,7 +68,8 @@ SPACE = [\ \t\r] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -109,4 +113,9 @@ SPACE = [\ \t\r] \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran77.rules/lex/F77TYPEHollerith.lex b/fr.cnes.analysis.tools.fortran77.rules/lex/F77TYPEHollerith.lex index 4bdb47a5..0b939531 100755 --- a/fr.cnes.analysis.tools.fortran77.rules/lex/F77TYPEHollerith.lex +++ b/fr.cnes.analysis.tools.fortran77.rules/lex/F77TYPEHollerith.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %extends AbstractChecker %public %line +%column %function run %yylexthrow JFlexException @@ -50,7 +51,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* STRING = \'[^\']*\' | \"[^\"]*\" %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + /** name of the file parsed */ + private String parsedFileName; public F77TYPEHollerith() { @@ -59,7 +62,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -130,4 +134,9 @@ RULE_WORD = [1-9]+[0-9]*[h|H][a-zA-Z\ \t]+ /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METComplexitySimplified.lex b/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METComplexitySimplified.lex index d2d554fd..a2f4fc63 100755 --- a/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METComplexitySimplified.lex +++ b/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METComplexitySimplified.lex @@ -35,8 +35,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %extends AbstractChecker %public %ignorecase -%line %column +%line + %function run %yylexthrow JFlexException @@ -78,6 +79,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" */ %{ String location = "MAIN PROGRAM"; + private String parsedFileName; float numCiclomatic = 0; float numCiclomaticTotal = 0; int functionLine = 0; @@ -88,7 +90,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void endLocation() throws JFlexException { @@ -157,4 +160,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METLineOfCode.lex b/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METLineOfCode.lex index b2532eac..5d5572f7 100755 --- a/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METLineOfCode.lex +++ b/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METLineOfCode.lex @@ -35,8 +35,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %extends AbstractChecker %public %ignorecase -%line %column +%line + %function run %yylexthrow JFlexException @@ -62,6 +63,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* comment's rate on each section (function, procedure, etc.). */ %{ String location = "MAIN PROGRAM"; + private String parsedFileName; float numLines = 1; float numTotal = 1; int functionLine = 0; @@ -72,7 +74,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void endLocation() throws JFlexException { final List list = this.getCheckResults(); @@ -151,4 +154,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METNesting.lex b/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METNesting.lex index bf40bb66..0cc6c63a 100755 --- a/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METNesting.lex +++ b/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METNesting.lex @@ -37,8 +37,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %extends AbstractChecker %public %ignorecase -%line %column +%line + %function run %yylexthrow JFlexException @@ -70,6 +71,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List identifiers = new LinkedList(); float numImbrics = 0; float numMaxImbrics = 0; @@ -83,7 +85,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void addImbrics() { @@ -191,4 +194,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + "> at line :"+yyline) );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METRatioComment.lex b/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METRatioComment.lex index 7bce627e..e9d33ea9 100755 --- a/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METRatioComment.lex +++ b/fr.cnes.analysis.tools.fortran90.metrics/lex/F90METRatioComment.lex @@ -35,8 +35,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %extends AbstractChecker %public %ignorecase -%line %column +%line + %function run %yylexthrow JFlexException @@ -58,6 +59,7 @@ END = END | end %{ String location = "MAIN PROGRAM"; + private String parsedFileName; Float numLines = 0.0f; Float numComments = 0.0f; int functionLine = 0; @@ -69,7 +71,8 @@ END = END | end @Override public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } // private void endLocation() throws JFlexException { @@ -215,4 +218,9 @@ END = END | end /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAFloatCompare.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAFloatCompare.lex index 91edd3ea..b2529bc8 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAFloatCompare.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAFloatCompare.lex @@ -34,6 +34,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class COMDATAFloatCompare %extends AbstractChecker %public +%column %line %ignorecase @@ -63,6 +64,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ /** This list store all variables name declared in a function, program, etc. **/ List allVariables = new LinkedList(); @@ -86,7 +88,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -385,4 +388,9 @@ DATA_TYPE = ("integer" | "logical" | "character" ) ( {SPACE} | {SPACE}*"(" | {S /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAInitialisation.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAInitialisation.lex index 46dd5913..016b34c1 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAInitialisation.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAInitialisation.lex @@ -36,6 +36,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMDATAInitialisation %extends AbstractChecker %public +%column %line %ignorecase @@ -94,6 +95,7 @@ SEE_FUNC = ([^a-zA-Z0-9\_])?("if" | "elseif" | "forall" | "while" | "where" | " %{ String location = "MAIN PROGRAM"; + private String parsedFileName; Map variables = new HashMap(); List dimension = new LinkedList(); @@ -116,6 +118,7 @@ SEE_FUNC = ([^a-zA-Z0-9\_])?("if" | "elseif" | "forall" | "while" | "where" | " boolean isIntentout=false; //name of sunroutine String nameType=""; + public COMDATAInitialisation() { } @@ -123,7 +126,9 @@ SEE_FUNC = ([^a-zA-Z0-9\_])?("if" | "elseif" | "forall" | "while" | "where" | " @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } //Mantis 316 EGL : detect initialized by local fonction @@ -230,13 +235,21 @@ SEE_FUNC = ([^a-zA-Z0-9\_])?("if" | "elseif" | "forall" | "while" | "where" | " if(entList!=null && !entList.isEmpty()) for(int i=0;i (i+3)){ + final String error= entList.get(i+3).substring(entList.get(i+3).indexOf("=")+1, entList.get(i+3).length()); + final String paramVar= entList.get(i).substring(entList.get(i).indexOf("=")+1, entList.get(i).length()); + if("true".equals(error)){ + final String dLocation= entList.get(i+1).substring(entList.get(i+1).indexOf("=")+1, entList.get(i+1).length()); + final String line= entList.get(i+2).substring(entList.get(i+2).indexOf("=")+1, entList.get(i+2).length()); + setError(dLocation,"The variable " + paramVar + " is used before being initialized. ", Integer.parseInt(line)); + + } + + }else{ + + String errorMessage = "Class"+this.getClass().getName()+"\nExcepted parameter of "+ entList.get(i) +" not reachable while parsing <" + yytext() + ">\nFile :"+ this.parsedFileName+"\nat line:"+yyline+" column:"+yycolumn; + throw new JFlexException(new Exception(errorMessage)); + } } @@ -548,4 +561,9 @@ return getCheckResults(); /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + "> at line :"+yyline) );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAInvariant.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAInvariant.lex index bcb3d5f6..a17e3801 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAInvariant.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATAInvariant.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMDATAInvariant %extends AbstractChecker %public +%column %line %ignorecase @@ -61,6 +62,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List variables = new LinkedList(); //mantis 322 use to keep used variables List usedVariables = new LinkedList(); @@ -74,7 +76,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -218,4 +221,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATALoopCondition.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATALoopCondition.lex index 8657d1e6..dda612bb 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATALoopCondition.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATALoopCondition.lex @@ -31,7 +31,9 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class COMDATALoopCondition %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -64,6 +66,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* A String name condition is created to store the current word. */ %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List identifiers = new LinkedList(); List conditionsDo = new LinkedList(); @@ -77,26 +80,33 @@ STRING = \'[^\']*\' | \"[^\"]*\" boolean doVar = true; String descr = ""; + public COMDATALoopCondition() { } @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } /** If the last identifier is: - DO -> check conditionsDo list - WHILE -> check conditionsWhile list **/ - private void closeCondition() { + private void closeCondition() throws JFlexException { int idLength = identifiers.size() - 1; - if (identifiers.get(idLength).equals("DO")) - closeDoLoop(); - else if (identifiers.get(idLength).equals("WHILE")) - closeWhileLoop(); - identifiers.remove(idLength); + if(idLength >= 0){ + if (identifiers.get(idLength).equals("DO")) + closeDoLoop(); + else if (identifiers.get(idLength).equals("WHILE")) + closeWhileLoop(); + identifiers.remove(idLength); + }else{ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Identifier unreachable", yytext(), yyline, yycolumn); + } } /** Delete the identifiers and variables in do loop **/ @@ -273,4 +283,9 @@ WHILE = "while" \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATANotUsed.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATANotUsed.lex index e0b03d12..156d6918 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATANotUsed.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDATANotUsed.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMDATANotUsed %extends AbstractChecker %public +%column %line %function run @@ -58,6 +59,7 @@ EQUAL = \= [^\,\n\"\']* %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List variables = new LinkedList(); List locations = new LinkedList(); List errors = new LinkedList(); @@ -69,7 +71,8 @@ EQUAL = \= [^\,\n\"\']* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -191,4 +194,9 @@ EQUAL = \= [^\,\n\"\']* /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDESIGNActiveWait.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDESIGNActiveWait.lex index bf1033aa..31f8abfa 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDESIGNActiveWait.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDESIGNActiveWait.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMDESIGNActiveWait %extends AbstractChecker %public +%column %line %ignorecase @@ -54,6 +55,7 @@ WAIT = "sleep" | "wait" | "pause" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List errors = new LinkedList(); int loop = 0; @@ -63,7 +65,8 @@ WAIT = "sleep" | "wait" | "pause" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -147,4 +150,9 @@ WAIT = "sleep" | "wait" | "pause" /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDESIGNAlloc.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDESIGNAlloc.lex index d286d574..ea12946d 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMDESIGNAlloc.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMDESIGNAlloc.lex @@ -37,6 +37,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMDESIGNAlloc %extends AbstractChecker %public +%column %line %ignorecase @@ -64,6 +65,7 @@ INT = [0-9]+ %{ String location = "MAIN PROGRAM"; + private String parsedFileName; Map memory = new HashMap(); Map files = new HashMap(); Map lines = new HashMap(); @@ -75,7 +77,8 @@ INT = [0-9]+ @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } /** @@ -280,4 +283,9 @@ INT = [0-9]+ /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWAbort.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWAbort.lex index 5a181acf..dcd00427 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWAbort.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWAbort.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWAbort %extends AbstractChecker %public +%column %line %ignorecase @@ -54,6 +55,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public COMFLOWAbort(){ } @@ -61,7 +63,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -128,4 +131,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWBooleanExpression.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWBooleanExpression.lex index fa7e9826..35bb1b50 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWBooleanExpression.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWBooleanExpression.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWBooleanExpression %extends AbstractChecker %public +%column %line %function run @@ -57,6 +58,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int numExpr = 0; int numPar = 0; boolean endLine = true; @@ -68,7 +70,8 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -149,4 +152,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCaseSwitch.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCaseSwitch.lex index e2aff7e0..37556753 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCaseSwitch.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCaseSwitch.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWCaseSwitch %extends AbstractChecker %public +%column %line %function run @@ -58,6 +59,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ String location = "MAIN PROGRAM"; + private String parsedFileName; Integer errorLine = 0; boolean caseDefault = false; @@ -67,7 +69,8 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -138,4 +141,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCheckCodeReturn.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCheckCodeReturn.lex index b78a44b4..3949f36e 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCheckCodeReturn.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCheckCodeReturn.lex @@ -33,7 +33,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWCheckCodeReturn %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -103,6 +105,7 @@ AVOIDED = {SPACE}*( "abs" | "achar" | "acos" | "acosh" | "adjustl" | "adjustr" %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ /** Boolean used to determine if a line continues or not. **/ boolean ampFound = false; @@ -127,13 +130,16 @@ AVOIDED = {SPACE}*( "abs" | "achar" | "acos" | "acosh" | "adjustl" | "adjustr" /** A boolean to determine if an else statement if found. **/ boolean elseFound = false; + public COMFLOWCheckCodeReturn() { } @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); codeLevel.add(1); } @@ -319,6 +325,9 @@ AVOIDED = {SPACE}*( "abs" | "achar" | "acos" | "acosh" | "adjustl" | "adjustr" LinkedList> tempLevel = new LinkedList>(); int i = 0; for(String var : variables){ + if(i>codeLevels.size()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Code level of variable "+var+"can not be reached.", yytext(), yyline, yycolumn); + } if (var.equals(variable) && isConflictLevel(codeLevels.get(i), codeLevel)) { setError(locations.get(i),"The return code of the function "+ variables.get(i) + " is not checked.", lines.get(i)); } else { @@ -448,4 +457,9 @@ AVOIDED = {SPACE}*( "abs" | "achar" | "acos" | "acosh" | "adjustl" | "adjustr" /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCheckUser.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCheckUser.lex index 9aca0fa7..fe91e964 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCheckUser.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWCheckUser.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWCheckUser %extends AbstractChecker %public +%column %line %ignorecase @@ -52,6 +53,7 @@ GETUID = "GETUID"{SPACE}*\({SPACE}*\) %{ String location = "MAIN PROGRAM"; + private String parsedFileName; boolean getuid = false; int line = 0; @@ -61,7 +63,8 @@ GETUID = "GETUID"{SPACE}*\({SPACE}*\) @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -166,4 +169,9 @@ GETUID = "GETUID"{SPACE}*\({SPACE}*\) /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWExit.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWExit.lex index 83389d34..79a3f3da 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWExit.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWExit.lex @@ -31,7 +31,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWExit %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -58,6 +60,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List loc = new LinkedList(); boolean returnExist = false; @@ -68,7 +71,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -113,9 +118,22 @@ STRING = \'[^\']*\' | \"[^\"]*\" {COMMENT_WORD} {yybegin(COMMENT);} {STRING} {} {TYPE} {location = yytext(); yybegin(NAMING);} - {END_TYPE} {loc.remove(loc.size()-1);} - {RETURN} {if(returnExist) setError(loc.get(loc.size()-1),"There is more than one exit in the function.", yyline+1); - else returnExist = true;} + {END_TYPE} { + if(loc.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Location unreachable.", yytext(), yyline, yycolumn); + } + loc.remove(loc.size()-1); + } + {RETURN} { + if(loc.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Location unreachable.", yytext(), yyline, yycolumn); + } + if(returnExist){ + setError(loc.get(loc.size()-1),"There is more than one exit in the function.", yyline+1); + }else{ + returnExist = true; + } + } \n {} . {yybegin(LINE);} @@ -125,9 +143,22 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ {STRING} {} {TYPE} {location=yytext(); yybegin(NAMING);} - {END_TYPE} {loc.remove(loc.size()-1);} - {RETURN} {if(returnExist) setError(loc.get(loc.size()-1),"There is more than one exit in the function.", yyline+1); - else returnExist = true;} + {END_TYPE} { + if(loc.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Location unreachable.", yytext(), yyline, yycolumn); + } + loc.remove(loc.size()-1); + } + {RETURN} { + if(loc.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Location unreachable.", yytext(), yyline, yycolumn); + } + if(returnExist){ + setError(loc.get(loc.size()-1),"There is more than one exit in the function.", yyline+1); + }else{ + returnExist = true; + } + } \n {yybegin(NEW_LINE);} . {} @@ -135,4 +166,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWExitLoop.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWExitLoop.lex index 7ffc4f40..6f1c86d2 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWExitLoop.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWExitLoop.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class COMFLOWExitLoop %extends AbstractChecker %public +%column %line %ignorecase @@ -56,6 +57,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ /** List of string used to store if and do statements. **/ List identifiers = new LinkedList(); @@ -70,7 +72,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -194,4 +197,9 @@ END = [^a-zA-Z0-9\_]("end")[^a-zA-Z0-9\_]{SPACE}*({IF} | {SELECT} | {DO} | /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWFileExistence.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWFileExistence.lex index 1576bad7..29b2dafb 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWFileExistence.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWFileExistence.lex @@ -31,7 +31,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWFileExistence %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -68,6 +70,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List files = new LinkedList(); List chars = new LinkedList(); boolean endLine = true; @@ -78,7 +81,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + parsedFileName = file.toString(); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -181,10 +186,16 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ {EXIST} {yybegin(COMMENT);} \& {endLine=false;} - \n {if(endLine) { - files.remove(files.size()-1); - yybegin(NEW_LINE); - } endLine = true; } + \n { + if(endLine) { + if(files.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analyzer failed to reach last file inquired.", yytext(), yyline, yycolumn); + } + files.remove(files.size()-1); + yybegin(NEW_LINE); + } + endLine = true; + } . {} @@ -212,4 +223,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWFilePath.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWFilePath.lex index 4949852d..c51d4688 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWFilePath.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWFilePath.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWFilePath %extends AbstractChecker %public +%column %line %ignorecase @@ -56,6 +57,7 @@ FILENAME = \'[\.]*[a-zA-Z\/][a-zA-Z0-9\_\/]*(\.[a-zA-Z0-9]+)?\' | %{ String location = "MAIN PROGRAM"; + private String parsedFileName; boolean lines = false; public COMFLOWFilePath(){ @@ -64,7 +66,8 @@ FILENAME = \'[\.]*[a-zA-Z\/][a-zA-Z0-9\_\/]*(\.[a-zA-Z0-9]+)?\' | @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -150,4 +153,9 @@ FILENAME = \'[\.]*[a-zA-Z\/][a-zA-Z0-9\_\/]*(\.[a-zA-Z0-9]+)?\' | /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWRecursion.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWRecursion.lex index e3fa3b84..41b67800 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWRecursion.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMFLOWRecursion.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class COMFLOWRecursion %extends AbstractChecker %public +%column %line %ignorecase @@ -49,6 +50,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public COMFLOWRecursion() { } @@ -56,7 +58,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -105,4 +108,9 @@ RULE_WORD = [^a-zA-Z0-9\_]"recursive"[^a-zA-Z0-9\_] \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTBoolNegation.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTBoolNegation.lex index 4aa61326..e9f71fbf 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTBoolNegation.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTBoolNegation.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTBoolNegation %extends AbstractChecker %public +%column %line %function run @@ -55,6 +56,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ String location = "MAIN PROGRAM"; + private String parsedFileName; boolean notFound = false; boolean parFound = false; boolean operFound = false; @@ -65,7 +67,8 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -143,4 +146,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTBrace.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTBrace.lex index 5bdc6758..1caa0bab 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTBrace.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTBrace.lex @@ -31,7 +31,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTBrace %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -62,6 +64,7 @@ SPACE = [\ \r\t\f] %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List parenthesis = new LinkedList(); List operators = new LinkedList(); boolean end = true; @@ -72,7 +75,9 @@ SPACE = [\ \r\t\f] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -85,6 +90,9 @@ SPACE = [\ \r\t\f] private void closeParenthesis() throws JFlexException { int index = parenthesis.size() - 1; int value = parenthesis.get(index) - 1; + if(index<0){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis couldn't handle parenthesis closure.", yytext(), yyline, yycolumn); + } parenthesis.remove(index); parenthesis.add(value); if (value == 0) { @@ -216,4 +224,9 @@ SPACE = [\ \r\t\f] /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTCodeComment.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTCodeComment.lex index f54473d1..9cae4f59 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTCodeComment.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTCodeComment.lex @@ -31,7 +31,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTCodeComment %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -109,6 +111,7 @@ SPACE = [\ \r\t\f] %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List loc = new LinkedList(); boolean endHeader = false; boolean params = false; @@ -120,6 +123,7 @@ SPACE = [\ \r\t\f] int nbTotal = 0; //percent of fault tolerance double rateLimit = 0.5; + @@ -129,7 +133,9 @@ SPACE = [\ \r\t\f] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -171,6 +177,9 @@ SPACE = [\ \r\t\f] \n { if(nbTotal >0) { if((nbError/nbTotal)>rateLimit){ + if(loc.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Location unreachable", yytext(), yyline, yycolumn); + } setError(loc.get(loc.size()-1),"Commented code is not allowed. It shall be suppressed.", yyline+1); } } @@ -212,7 +221,11 @@ SPACE = [\ \r\t\f] {COMMENT_WORD} {if(loc.size()>0)yybegin(COMMENT); else yybegin(HEADER);} {STRING} {} {TYPE} {location = yytext(); yybegin(NAMING);} - {END_TYPE} {loc.remove(loc.size()-1);} + {END_TYPE} { + if(loc.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Location unreachable", yytext(), yyline, yycolumn); + } + loc.remove(loc.size()-1);} \n {} \s {yybegin(LINE);} . {yybegin(LINE);} @@ -224,7 +237,11 @@ SPACE = [\ \r\t\f] {COMMENT_WORD} {if(loc.size()>0)yybegin(COMMENT); else yybegin(HEADER);} {STRING} {} {TYPE} {location = yytext(); yybegin(NAMING);} - {END_TYPE} {loc.remove(loc.size()-1);} + {END_TYPE} { + if(loc.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Location unreachable", yytext(), yyline, yycolumn); + } + loc.remove(loc.size()-1);} \n {yybegin(NEW_LINE);} {SPACE} {endHeader=false;} . {} @@ -256,4 +273,9 @@ SPACE = [\ \r\t\f] /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTGoTo.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTGoTo.lex index b8e44c58..faf2f710 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTGoTo.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTGoTo.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTGoTo %extends AbstractChecker %public +%column %line %ignorecase @@ -50,6 +51,7 @@ GOTO = [^a-zA-Z0-9\_]("go") {SPACE}*("to") %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public COMINSTGoTo(){ } @@ -57,7 +59,8 @@ GOTO = [^a-zA-Z0-9\_]("go") {SPACE}*("to") @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -128,4 +131,9 @@ GOTO = [^a-zA-Z0-9\_]("go") {SPACE}*("to") /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTLine.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTLine.lex index 51f44aed..94efaec3 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTLine.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTLine.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTLine %extends AbstractChecker %public +%column %line %function run @@ -52,6 +53,7 @@ CHAR = [a-zA-Z0-9] %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public COMINSTLine(){ } @@ -59,7 +61,8 @@ CHAR = [a-zA-Z0-9] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -135,4 +138,9 @@ CHAR = [a-zA-Z0-9] /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTLoopCondition.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTLoopCondition.lex index 097e0f2d..9e60d2f2 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTLoopCondition.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMINSTLoopCondition.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTLoopCondition %extends AbstractChecker %public +%column %line %ignorecase @@ -62,6 +63,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int par = 0; public COMINSTLoopCondition(){ @@ -70,7 +72,8 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -147,4 +150,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + "> at line "+yyline+1) );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMNAMEHomonymy.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMNAMEHomonymy.lex index 5a006460..90ca1185 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMNAMEHomonymy.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMNAMEHomonymy.lex @@ -36,7 +36,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMNAMEHomonymy %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -69,6 +71,7 @@ SPACE = [\ \r\t\f] %{ String location = "MAIN PROGRAM"; + private String parsedFileName; Map> hierarchy = new HashMap>(); Map> variables = new HashMap>(); List locOrder = new LinkedList(); @@ -76,6 +79,7 @@ SPACE = [\ \r\t\f] int par = 0; boolean end = true, endStruct = true; + public COMNAMEHomonymy(){ locOrder.add(location); } @@ -83,7 +87,9 @@ SPACE = [\ \r\t\f] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -182,7 +188,11 @@ SPACE = [\ \r\t\f] {COMMENT_WORD} {yybegin(COMMENT);} {STRING} {} {TYPE} {location = yytext(); yybegin(NAMING);} - {END_TYPE} {locOrder.remove(locOrder.size()-1);} + {END_TYPE} { + if(locOrder.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Location unreachable.", yytext(), yyline, yycolumn); + } + locOrder.remove(locOrder.size()-1);} {DATA_TYPE} {par=0; yybegin(DECL_PARAMS);} {STRUCT} {yybegin(TYPE_DEC);} {VAR} {} @@ -195,7 +205,11 @@ SPACE = [\ \r\t\f] /************************/ {STRING} {} {TYPE} {location = yytext(); yybegin(NAMING);} - {END_TYPE} {locOrder.remove(locOrder.size()-1);} + {END_TYPE} { + if(locOrder.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Location unreachable.", yytext(), yyline, yycolumn); + } + locOrder.remove(locOrder.size()-1);} {DATA_TYPE} {par=0; yybegin(DECL_PARAMS);} {STRUCT} {yybegin(TYPE_DEC);} {VAR} {yybegin(NOTHING);} @@ -277,4 +291,9 @@ SPACE = [\ \r\t\f] /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMPRESIndent.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMPRESIndent.lex index bf04a568..69c85ac7 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMPRESIndent.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMPRESIndent.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMPRESIndent %extends AbstractChecker %public +%column %line %ignorecase @@ -73,6 +74,7 @@ SPACE = [\ \r\t\f] %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int currentCol = 0; List theoricCol = new LinkedList(); List numbers = new LinkedList(); @@ -87,7 +89,8 @@ SPACE = [\ \r\t\f] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -269,4 +272,9 @@ SPACE = [\ \r\t\f] /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMPRESLengthLine.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMPRESLengthLine.lex index 6e6a754d..df273456 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMPRESLengthLine.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMPRESLengthLine.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMPRESLengthLine %extends AbstractChecker %public +%column %line %function run @@ -51,6 +52,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int chars = 1; @@ -60,7 +62,8 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -125,4 +128,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMPROJECTHeader.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMPROJECTHeader.lex index 10a472ff..f96ce77e 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMPROJECTHeader.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMPROJECTHeader.lex @@ -31,7 +31,9 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class COMPROJECTHeader %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -60,6 +62,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* A boolean called comment determines if a comment is set. */ %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List linesType = new LinkedList(); List locations = new LinkedList(); List lines = new LinkedList(); @@ -67,13 +70,16 @@ STRING = \'[^\']*\' | \"[^\"]*\" boolean first = true; int errorLine = 0; + public COMPROJECTHeader() { } @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -100,7 +106,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" } private void raiseErrors() throws JFlexException { - + if(this.linesType.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Line type unreachable.", yytext(), yyline, yycolumn); + } if (!this.linesType.get(0).equals("comment") && !this.linesType.get(1).equals("comment")) { this.setError("No file header existing.","This module/function should have a header with a brief description.", 0); @@ -275,4 +283,9 @@ SPACE = [\ \f\t]+ /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/COMTYPEExpression.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/COMTYPEExpression.lex index a1bf0785..359edc88 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/COMTYPEExpression.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/COMTYPEExpression.lex @@ -33,6 +33,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMTYPEExpression %extends AbstractChecker %public +%column %line %ignorecase @@ -87,6 +88,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; Map variables = new HashMap(); List arrays = new LinkedList(); List errors = new LinkedList(); @@ -108,7 +110,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -334,4 +337,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* ERROR STATE */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/ExampleRule.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/ExampleRule.lex index 2f999511..48a405d4 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/ExampleRule.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/ExampleRule.lex @@ -44,6 +44,7 @@ import fr.cnes.analysis.tools.analyzer.datas.Violation; %class GeneratedRuleName %extends AbstractChecker %public +%column %line /* This three lines are not meant to be modified. */ @@ -86,7 +87,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* All this code is not meant to be deleted, but some Java program can be added */ /* in this section. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; List list = new LinkedList(); public GeneratedRuleName() { @@ -95,7 +97,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -167,4 +170,4 @@ RULE_WORD = first_word | SECOND_WORD . {} /* Throw error if nothing is catch. */ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90BLOCFile.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90BLOCFile.lex index ad9b553a..554e4a5e 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90BLOCFile.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90BLOCFile.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90BLOCFile %extends AbstractChecker %public +%column %line %ignorecase @@ -62,6 +63,7 @@ UNIT = (("unit"){SPACE}*("="))?{SPACE}*{VAR} %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ /** List of String containing unit variable used for open statement. **/ List openUnits = new LinkedList(); @@ -76,7 +78,8 @@ UNIT = (("unit"){SPACE}*("="))?{SPACE}*{VAR} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -209,4 +212,9 @@ UNIT = (("unit"){SPACE}*("="))?{SPACE}*{VAR} /****************/ /* THROW ERROR */ /****************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAArray.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAArray.lex index ad60058f..231a763b 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAArray.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAArray.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DATAArray %extends AbstractChecker %public +%column %line %ignorecase @@ -70,7 +71,8 @@ SPACE = [\ \t\f\r] /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; /** Parameters' function list **/ List parameters = new LinkedList(); int parenthese = 0; @@ -82,7 +84,8 @@ SPACE = [\ \t\f\r] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -256,5 +259,9 @@ SPACE = [\ \t\f\r] /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} - + [^] { + 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); + } diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAArrayAccess.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAArrayAccess.lex index eb570a59..2a15a669 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAArrayAccess.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAArrayAccess.lex @@ -35,6 +35,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90DATAArrayAccess %extends AbstractChecker %public +%column %line %ignorecase @@ -80,7 +81,8 @@ SPACE = [\ \t\f] /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; /** Arrays declared in the file **/ List arrays = new LinkedList(); List arraysInd = new LinkedList(); @@ -97,7 +99,8 @@ SPACE = [\ \t\f] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -224,4 +227,9 @@ SPACE = [\ \t\f] /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAConstant.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAConstant.lex index a7dac8a6..7933e3c4 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAConstant.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAConstant.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90DATAConstant %extends AbstractChecker %public +%column %line %ignorecase @@ -71,7 +72,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; public F90DATAConstant() { } @@ -79,7 +81,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -134,4 +137,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAConstantFloat.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAConstantFloat.lex index ddb19568..fe9868fe 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAConstantFloat.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAConstantFloat.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DATAConstantFloat %extends AbstractChecker %public +%column %line %ignorecase @@ -75,7 +76,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; String constant = null; String variable = null; boolean wellDef = false; @@ -89,7 +91,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -173,4 +176,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATADeclaration.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATADeclaration.lex index 295adf5a..7bc51af0 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATADeclaration.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATADeclaration.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DATADeclaration %extends AbstractChecker %public +%column %line %ignorecase @@ -115,7 +116,8 @@ SPACE = [\ \t\f\r] /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; int line = 0; /** List of variables**/ List variables = new LinkedList(); @@ -133,7 +135,8 @@ SPACE = [\ \t\f\r] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void comparerError()throws JFlexException{ @@ -315,5 +318,9 @@ SPACE = [\ \t\f\r] /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} - + [^] { + 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); + } diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAFloat.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAFloat.lex index bf847cf5..3556ddd5 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAFloat.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAFloat.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DATAFloat %extends AbstractChecker %public +%column %line %ignorecase @@ -74,6 +75,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ /** Variable used to determine violations' location. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; final List floatList = new LinkedList(); /** Boolean used to determine if star is used in a write. **/ boolean star = false; @@ -96,6 +98,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* public final void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -195,4 +198,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAParameter.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAParameter.lex index 4eb62311..f522d432 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAParameter.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DATAParameter.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DATAParameter %extends AbstractChecker %public +%column %line %function run @@ -71,7 +72,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; boolean integerDef = false; public F90DATAParameter() { @@ -80,7 +82,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -146,4 +149,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNFree.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNFree.lex index c9256b0c..5f7de48e 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNFree.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNFree.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DESIGNFree %extends AbstractChecker %public +%column %line %ignorecase @@ -75,7 +76,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; String alloc = ""; public F90DESIGNFree() { @@ -84,7 +86,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -152,4 +155,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNIO.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNIO.lex index a4ded43a..2cdeaa1b 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNIO.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNIO.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DESIGNIO %extends AbstractChecker %public +%column %line %ignorecase @@ -76,7 +77,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; List unites = new LinkedList(); public F90DESIGNIO() { @@ -85,7 +87,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -172,4 +175,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNInclude.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNInclude.lex index 4b04a5e1..99bd4a8c 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNInclude.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNInclude.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DESIGNInclude %extends AbstractChecker %public +%column %line %ignorecase @@ -55,6 +56,7 @@ INCLUDE = [^a-zA-Z0-9\_]("include"){SPACE}+{STRING} %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ /** Used to determine if a comment is before an include declaration. **/ boolean comment = false; @@ -67,7 +69,8 @@ INCLUDE = [^a-zA-Z0-9\_]("include"){SPACE}+{STRING} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -134,4 +137,9 @@ INCLUDE = [^a-zA-Z0-9\_]("include"){SPACE}+{STRING} /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNInterface.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNInterface.lex index 2ba79133..ec4c7bae 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNInterface.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNInterface.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DESIGNInterface %extends AbstractChecker %public +%column %line %ignorecase @@ -61,6 +62,7 @@ ERROR = "allocatable" | "allocate" | "assign" | "backspace" | "block" | "call" %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variables to store the error in module definition line**/ boolean inter = false; boolean error = false; @@ -71,7 +73,8 @@ ERROR = "allocatable" | "allocate" | "assign" | "backspace" | "block" | "call" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -171,4 +174,9 @@ ERROR = "allocatable" | "allocate" | "assign" | "backspace" | "block" | "call" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsolete.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsolete.lex index 24613d83..b5f24a7f 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsolete.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsolete.lex @@ -33,6 +33,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90DESIGNObsolete %extends AbstractChecker %public +%column %line %ignorecase @@ -68,7 +69,8 @@ IF_BRANCH = [1-9]+[0-9]*{SPACE}*("end"){SPACE}*("if") CHAR = "character" {SPACE}* \* %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; /** Rule used to assert that arithmetical if is not used. **/ AbstractChecker rule1 = new F90DESIGNObsoleteArithmeticalIf(); /** Rule used to assert that do loop ending branch is done on a continue or an end do. **/ @@ -103,6 +105,7 @@ CHAR = "character" {SPACE}* \* this.rule4.setContribution(this.getContribution()); this.rule4.setInputFile(file); + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -253,4 +256,9 @@ CHAR = "character" {SPACE}* \* /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteArithmeticalIf.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteArithmeticalIf.lex index 1f51e43f..fe69c0fe 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteArithmeticalIf.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteArithmeticalIf.lex @@ -31,8 +31,9 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90DESIGNObsoleteArithmeticalIf %extends AbstractChecker %public -%line %column +%line + %function run %yylexthrow JFlexException @@ -58,6 +59,7 @@ INT = [0-9]+ %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int bracket = 0; @@ -67,7 +69,8 @@ INT = [0-9]+ @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -163,4 +166,9 @@ CONT = CONTINUE | continue /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoEnding.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoEnding.lex index 40073e5d..bc33d634 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoEnding.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoEnding.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90DESIGNObsoleteDoEnding %extends AbstractChecker %public +%column %line %function run @@ -51,6 +52,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; /** List of labels found during analysis, following a DO. **/ List labels = new LinkedList(); @@ -60,7 +62,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void addLabel(String label) throws JFlexException { @@ -182,4 +185,9 @@ INT = [0-9]+ /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoReal.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoReal.lex index ffb986c4..a24157dc 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoReal.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoReal.lex @@ -33,8 +33,9 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90DESIGNObsoleteDoReal %extends AbstractChecker %public -%line %column +%line + %function run %yylexthrow JFlexException @@ -61,6 +62,7 @@ SPACE = [\ \t\r] %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public F90DESIGNObsoleteDoReal() { @@ -69,7 +71,8 @@ SPACE = [\ \t\r] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -211,4 +214,9 @@ WRONG_TYPE = {REAL} | {DOUBLE_PREC} | {COMPLEX} | {LOGICAL} | {CHAR} /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoShared.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoShared.lex index 5521eabd..fc8450e6 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoShared.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90DESIGNObsoleteDoShared.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90DESIGNObsoleteDoShared %extends AbstractChecker %public +%column %line %function run @@ -53,6 +54,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List identifiers = new LinkedList(); @@ -62,7 +64,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void checkIndentifiers(String id) throws JFlexException { @@ -132,4 +135,9 @@ INT = [0-9]+ \n {yybegin(NEW_LINE);} . {} - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90ERRAllocate.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90ERRAllocate.lex index aa19b48e..da6ccfaf 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90ERRAllocate.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90ERRAllocate.lex @@ -35,6 +35,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90ERRAllocate %extends AbstractChecker %public +%column %line %ignorecase @@ -81,7 +82,8 @@ SPACE = [\ \t\f] /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; String stat = ""; boolean ifFound = false; String descr = ""; @@ -92,7 +94,8 @@ SPACE = [\ \t\f] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -184,4 +187,9 @@ SPACE = [\ \t\f] /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90ERROpenRead.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90ERROpenRead.lex index d7e3bd7e..d1e3c1c2 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90ERROpenRead.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90ERROpenRead.lex @@ -35,7 +35,9 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90ERROpenRead %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -77,7 +79,8 @@ IOSTAT = ("iostat") {SPACE}* \= {SPACE}* {VAR} /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; boolean iostat = false, file = false, add=false; boolean multLines = false; List files = new LinkedList(); @@ -90,7 +93,9 @@ IOSTAT = ("iostat") {SPACE}* \= {SPACE}* {VAR} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -162,6 +167,9 @@ IOSTAT = ("iostat") {SPACE}* \= {SPACE}* {VAR} yybegin(IF_STATE); } else { + if(files.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis failure : Last instruction stored unreachable.", yytext(), yyline, yycolumn); + } files.remove(files.size()-1); //delete the last element -> this instruction does not open a file yybegin(YYINITIAL); } @@ -225,4 +233,9 @@ IOSTAT = ("iostat") {SPACE}* \= {SPACE}* {VAR} /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTAssociated.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTAssociated.lex index 96579a84..f2bb5779 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTAssociated.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTAssociated.lex @@ -32,6 +32,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90INSTAssociated %extends AbstractChecker %public +%column %line %ignorecase @@ -69,6 +70,7 @@ ASSOCIATED = ("associated") %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ /** List of pointer name and associated boolean, which is true when pointer is assigned to a target. **/ Map pointers = new HashMap(); @@ -81,7 +83,8 @@ ASSOCIATED = ("associated") @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -193,4 +196,9 @@ ASSOCIATED = ("associated") /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTEntry.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTEntry.lex index 4864165e..910971ce 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTEntry.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTEntry.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90INSTEntry %extends AbstractChecker %public +%column %line %ignorecase @@ -49,7 +50,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ /** Variable used to store violation location and variable involved. **/ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; public F90INSTEntry() { } @@ -57,7 +59,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -113,4 +116,9 @@ RULE_WORD = [^a-zA-Z0-9\_]("entry")[^a-zA-Z0-9\_] /*********************/ /* ERROR THROWN */ /*********************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTEquivalence.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTEquivalence.lex index 7d46dd5b..d2126b30 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTEquivalence.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTEquivalence.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90INSTEquivalence %extends AbstractChecker %public +%column %line %ignorecase @@ -54,6 +55,7 @@ EQUIV = [^a-zA-Z0-9\_]("equivalence")[^a-zA-Z0-9\_] %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ public F90INSTEquivalence() { @@ -62,7 +64,8 @@ EQUIV = [^a-zA-Z0-9\_]("equivalence")[^a-zA-Z0-9\_] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -117,4 +120,9 @@ EQUIV = [^a-zA-Z0-9\_]("equivalence")[^a-zA-Z0-9\_] /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTIf.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTIf.lex index 015cc791..0c9bd75b 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTIf.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTIf.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90INSTIf %extends AbstractChecker %public +%column %line %ignorecase @@ -58,6 +59,7 @@ BRANCH = [^a-zA-Z0-9\_]("exit" | "cycle" | "goto" | "return")[^a-zA-Z0-9\_] %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ boolean hasBranch = false; boolean hasThen = false; @@ -70,7 +72,8 @@ BRANCH = [^a-zA-Z0-9\_]("exit" | "cycle" | "goto" | "return")[^a-zA-Z0-9\_] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -148,4 +151,9 @@ BRANCH = [^a-zA-Z0-9\_]("exit" | "cycle" | "goto" | "return")[^a-zA-Z0-9\_] /****************/ /* THROW ERROR */ /****************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTIntent.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTIntent.lex index ce0fc383..e5858df0 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTIntent.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTIntent.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90INSTIntent %extends AbstractChecker %public +%column %line %function run @@ -76,7 +77,8 @@ SPACE = [\ \t\f] /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; List params = new LinkedList(); boolean end = true; boolean intent = false; @@ -88,7 +90,8 @@ SPACE = [\ \t\f] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -200,4 +203,9 @@ SPACE = [\ \t\f] /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTNullify.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTNullify.lex index 4a666217..30b03c3a 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTNullify.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTNullify.lex @@ -32,6 +32,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90INSTNullify %extends AbstractChecker %public +%column %line %ignorecase @@ -55,6 +56,7 @@ NULLIFY = [^a-zA-Z0-9\_]("nullify"){SPACE}*("(") %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ List pointers = new LinkedList(); List lines = new LinkedList(); @@ -67,7 +69,8 @@ NULLIFY = [^a-zA-Z0-9\_]("nullify"){SPACE}*("(") @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -166,4 +169,9 @@ NULLIFY = [^a-zA-Z0-9\_]("nullify"){SPACE}*("(") /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTOnly.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTOnly.lex index 82e2d799..b69821e8 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTOnly.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTOnly.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90INSTOnly %extends AbstractChecker %public +%column %line %ignorecase @@ -55,6 +56,7 @@ ONLY = "only" %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ List intrinseques = new LinkedList(); boolean comment = false; @@ -65,7 +67,8 @@ ONLY = "only" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -117,4 +120,9 @@ ONLY = "only" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTOperator.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTOperator.lex index a29f766b..d8ae1d35 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTOperator.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTOperator.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90INSTOperator %extends AbstractChecker %public +%column %line %ignorecase @@ -55,6 +56,7 @@ OP_RELAT = ".eq." | ".ne." | ".lt." | ".le." | ".gt." | ".ge." %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ public F90INSTOperator() { @@ -63,7 +65,8 @@ OP_RELAT = ".eq." | ".ne." | ".lt." | ".le." | ".gt." | ".ge." @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -115,4 +118,9 @@ OP_RELAT = ".eq." | ".ne." | ".lt." | ".le." | ".gt." | ".ge." /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTPointer.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTPointer.lex index de5290a4..cc64f981 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTPointer.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90INSTPointer.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90INSTPointer %extends AbstractChecker %public +%column %line %ignorecase @@ -57,6 +58,7 @@ TIPUS = "type" %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; boolean dimension = false, type = false, pointer = false; @@ -66,7 +68,8 @@ TIPUS = "type" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -151,4 +154,9 @@ TIPUS = "type" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90NAMEGenericIntrinsic.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90NAMEGenericIntrinsic.lex index 4ada0dad..eb619ebf 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90NAMEGenericIntrinsic.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90NAMEGenericIntrinsic.lex @@ -33,6 +33,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90NAMEGenericIntrinsic %extends AbstractChecker %public +%column %line %ignorecase @@ -55,7 +56,8 @@ VAR_PAR = {VAR} [\ ]* \( STRING = \'[^\']*\' | \"[^\"]*\" %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; List intrinseques = new LinkedList(); List intrinsequesGeneriques = new LinkedList(); @@ -69,7 +71,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -141,4 +144,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90NAMEKeyWords.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90NAMEKeyWords.lex index 46250c76..9f9f9917 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90NAMEKeyWords.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90NAMEKeyWords.lex @@ -35,6 +35,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90NAMEKeyWords %extends AbstractChecker %public +%column %line %ignorecase @@ -104,7 +105,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" SPACE = [\ \t\f] %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; boolean end = true; public F90NAMEKeyWords() { @@ -113,7 +115,8 @@ SPACE = [\ \t\f] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -206,4 +209,9 @@ SPACE = [\ \t\f] /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90PROTOOverload.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90PROTOOverload.lex index 998150d9..b327b034 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90PROTOOverload.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90PROTOOverload.lex @@ -32,6 +32,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90PROTOOverload %extends AbstractChecker %public +%column %line %ignorecase @@ -59,6 +60,7 @@ OPERATEUR = "+" | "-" | "*" | "/" | "**" %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ Map operateurs = new HashMap(); String op; @@ -70,7 +72,8 @@ OPERATEUR = "+" | "-" | "*" | "/" | "**" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -191,4 +194,9 @@ OPERATEUR = "+" | "-" | "*" | "/" | "**" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFArray.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFArray.lex index 1553878e..45a961df 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFArray.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFArray.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90REFArray %extends AbstractChecker %public +%column %line %function run @@ -59,7 +60,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" SPACE = [\ \t\f] %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; /** List where to save the name of all the arrays **/ List arrays = new LinkedList(); /** Variable to print with the error **/ @@ -81,7 +83,8 @@ SPACE = [\ \t\f] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -229,4 +232,9 @@ SPACE = [\ \t\f] /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFInterface.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFInterface.lex index 2491042d..bc2cf19e 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFInterface.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFInterface.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90REFInterface %extends AbstractChecker %public +%column %line %ignorecase @@ -74,7 +75,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" /* A method called setError with String and integer parameters is used to store */ /* an error found during analysis. */ %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; List call = new LinkedList(); List callFrom = new LinkedList(); List locList = new LinkedList(); @@ -90,7 +92,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -204,4 +207,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFLabel.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFLabel.lex index bc355fc5..1af1b229 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFLabel.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFLabel.lex @@ -32,7 +32,9 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90REFLabel %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -57,6 +59,7 @@ FALSE_END = ("end"[\ ]*"if") | ("end"[\ ]*"do") | ("end"[\ ]*"file") | ("end"[\ %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ /** Boolean to determine if statement is completed. **/ Boolean endComplete = false; @@ -65,13 +68,16 @@ FALSE_END = ("end"[\ ]*"if") | ("end"[\ ]*"do") | ("end"[\ ]*"file") | ("end"[\ /** Boolean to determine if an IF statement if over. **/ boolean endLine = true; + public F90REFLabel() { } @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -138,6 +144,9 @@ FALSE_END = ("end"[\ ]*"if") | ("end"[\ ]*"do") | ("end"[\ ]*"file") | ("end"[\ {END} {if (!identifiers.isEmpty()) yybegin(END_STATE);} {END_FUN_TYPE} {String funType = yytext().toLowerCase().substring(3); if (!funType.contains("interface")) { + if(identifiers.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis failure : Identifier unreachable", yytext(), yyline, yycolumn); + } String type = identifiers.get(identifiers.size()-1).split(" ")[0]; if(type.equals("block")) { if (!funType.contains("block")) { @@ -204,4 +213,9 @@ FALSE_END = ("end"[\ ]*"if") | ("end"[\ ]*"do") | ("end"[\ ]*"file") | ("end"[\ /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFOpen.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFOpen.lex index 27916f8a..bd3fff60 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFOpen.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFOpen.lex @@ -34,6 +34,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90REFOpen %extends AbstractChecker %public +%column %line %ignorecase @@ -59,6 +60,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ /** Boolean to determine if FILE is found. **/ boolean fileFound = false; @@ -81,7 +83,8 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -206,4 +209,9 @@ IOSTAT = "iostat" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFVariable.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFVariable.lex index ed3c432b..6d6d0771 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFVariable.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90REFVariable.lex @@ -33,6 +33,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90REFVariable %extends AbstractChecker %public +%column %line %ignorecase @@ -61,7 +62,8 @@ CLE = "assign" | "backspace" | ("block"){SPACE}*("data") | "close" | "common" PARAM = \( [^\)]* \) %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; String functionName; Map> funcCalls = new HashMap>(); Map> funcDecls = new HashMap>(); @@ -72,7 +74,8 @@ PARAM = \( [^\)]* \) @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -196,4 +199,9 @@ PARAM = \( [^\)]* \) /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEDerivate.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEDerivate.lex index 69ee7aca..5d2ecf5c 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEDerivate.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEDerivate.lex @@ -31,7 +31,9 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90TYPEDerivate %extends AbstractChecker %public +%column %line + %ignorecase %function run @@ -53,7 +55,8 @@ STRUCT = "type"{SPACE}+{VAR} END_STRUCT = "end"{SPACE}*"type" %{ - String location = "MAIN PROGRAM"; + String location = "MAIN PROGRAM"; + private String parsedFileName; List locations = new LinkedList(); public F90TYPEDerivate() { @@ -62,7 +65,9 @@ END_STRUCT = "end"{SPACE}*"type" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -103,9 +108,17 @@ END_STRUCT = "end"{SPACE}*"type" /************************/ {STRING}|{FALSE} {} {TYPE} {location = yytext(); yybegin(NAMING);} - {END_TYPE} {locations.remove(locations.size() - 1);} + {END_TYPE} { + if(locations.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis failure : Location unreachable.", yytext(), yyline, yycolumn); + } + locations.remove(locations.size() - 1);} {END_STRUCT} {} - {STRUCT} {if (!locations.get(locations.size()-1).toLowerCase().contains("module")) + {STRUCT} { + if(locations.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis failure : Location unreachable.", yytext(), yyline, yycolumn); + } + if (!locations.get(locations.size()-1).toLowerCase().contains("module")) setError(location,"The " + yytext() + " must be defined inside the module structure." , yyline+1);} \n {} . {yybegin(LINE);} @@ -116,9 +129,18 @@ END_STRUCT = "end"{SPACE}*"type" /************************/ {STRING}|{FALSE} {} {TYPE} {location = yytext(); yybegin(NAMING);} - {END_TYPE} {locations.remove(locations.size() - 1);} + {END_TYPE} { + if(locations.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis failure : Location unreachable.", yytext(), yyline, yycolumn); + } + locations.remove(locations.size() - 1); + } {END_STRUCT} {} - {STRUCT} {if (!locations.get(locations.size()-1).toLowerCase().contains("module")) + {STRUCT} { + if(locations.isEmpty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis failure : Location unreachable.", yytext(), yyline, yycolumn); + } + if (!locations.get(locations.size()-1).toLowerCase().contains("module")) setError(location,"The " + yytext() + " must be defined inside the module structure." , yyline+1);} \n {yybegin(NEW_LINE);} . {} @@ -127,4 +149,9 @@ END_STRUCT = "end"{SPACE}*"type" /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEInteger.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEInteger.lex index 2661494c..566ee6c3 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEInteger.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEInteger.lex @@ -34,6 +34,7 @@ import fr.cnes.analysis.tools.analyzer.datas.CheckResult; %class F90TYPEInteger %extends AbstractChecker %public +%column %line %ignorecase @@ -60,6 +61,7 @@ SELECTED = ("selected_")("int"|"real"|"char")("_kind") %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Variable used to store file value and function values associated. **/ /** Boolean to determine if it is a real error **/ boolean error = false; @@ -74,7 +76,8 @@ SELECTED = ("selected_")("int"|"real"|"char")("_kind") @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -152,4 +155,9 @@ SELECTED = ("selected_")("int"|"real"|"char")("_kind") /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEReal.lex b/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEReal.lex index d327e801..26fea857 100755 --- a/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEReal.lex +++ b/fr.cnes.analysis.tools.fortran90.rules/lex/F90TYPEReal.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class F90TYPEReal %extends AbstractChecker %public +%column %line %ignorecase @@ -55,6 +56,7 @@ ERROR = ( "real" | ("double"){SPACE}*("precision") | "complex" ) %{ /** Variable used to store violation location and variable involved. **/ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Boolean to determine if it is a real error **/ boolean error = false; /** Boolean to determine if the variable name needs to be saved **/ @@ -68,7 +70,8 @@ ERROR = ( "real" | ("double"){SPACE}*("precision") | "complex" ) @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -145,4 +148,9 @@ ERROR = ( "real" | ("double"){SPACE}*("precision") | "complex" ) /************************/ /* THROW ERROR */ /************************/ - [^] {throw new JFlexException( new Exception("Illegal character <" + yytext() + ">") );} + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.metrics/lex/SHMETComplexitySimplified.lex b/fr.cnes.analysis.tools.shell.metrics/lex/SHMETComplexitySimplified.lex index 43eb0fbd..fd2b20b3 100755 --- a/fr.cnes.analysis.tools.shell.metrics/lex/SHMETComplexitySimplified.lex +++ b/fr.cnes.analysis.tools.shell.metrics/lex/SHMETComplexitySimplified.lex @@ -36,8 +36,9 @@ import org.eclipse.core.runtime.Path; %extends AbstractChecker %public %ignorecase -%line %column +%line + %function run %yylexthrow JFlexException @@ -71,6 +72,7 @@ ESAC = "esac" CASE_STATEMENT = ({SPACE}*([^\space\(\)\n]*|{VAR})+{SPACE}*)([\|]({SPACE}*([^\space\(\)\n]*|{VAR})+{SPACE}*))*[^\(\)][\)] %{ String location = "MAIN PROGRAM"; + private String parsedFileName; private Stack functionStack = new Stack<>(); float mainComplexity = 1; float totalComplexity = 0; @@ -78,7 +80,8 @@ CASE_STATEMENT = ({SPACE}*([^\space\(\)\n]*|{VAR})+{SPACE}*)([\|]({SPACE}*([^\s int functionLine = 0; Stack commandClosureStack = new Stack<>(); private static final Logger LOGGER = Logger.getLogger(SHMETComplexitySimplified.class.getName()); - + + public SHMETComplexitySimplified(){ } @@ -86,7 +89,9 @@ CASE_STATEMENT = ({SPACE}*([^\space\(\)\n]*|{VAR})+{SPACE}*)([\|]({SPACE}*([^\s @Override public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -441,6 +446,9 @@ CASE_STATEMENT = ({SPACE}*([^\space\(\)\n]*|{VAR})+{SPACE}*)([\|]({SPACE}*([^\s {FUNCSTART} {} {VAR} {} {END_COMMAND} { + if(commandClosureStack.empty()){ + throw new JFlexException(this.getClass().getName(), parsedFileName, "Analysis failure : Command closure unreachable.", yytext(), yyline, yycolumn); + } if(yytext().equals(commandClosureStack.peek())){ commandClosureStack.pop(); @@ -529,7 +537,9 @@ CASE_STATEMENT = ({SPACE}*([^\space\(\)\n]*|{VAR})+{SPACE}*)([\|]({SPACE}*([^\s /************************/ /* ERROR STATE */ /************************/ - [^] { - String errorMessage = "Class: "+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.getInputFile().getAbsolutePath() +"\nat line:"+yyline+" column:"+yycolumn+"\nLast word read : "+yytext(); - throw new JFlexException(new Exception(errorMessage)); + [^] { + 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); } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.metrics/lex/SHMETLineOfCode.lex b/fr.cnes.analysis.tools.shell.metrics/lex/SHMETLineOfCode.lex index 364c74d4..339f53e1 100755 --- a/fr.cnes.analysis.tools.shell.metrics/lex/SHMETLineOfCode.lex +++ b/fr.cnes.analysis.tools.shell.metrics/lex/SHMETLineOfCode.lex @@ -37,8 +37,9 @@ import org.eclipse.core.runtime.Path; %class SHMETLineOfCode %extends AbstractChecker %public -%line %column +%line + %function run %yylexthrow JFlexException @@ -67,6 +68,7 @@ FUNCEND = \} | \) | \)\) | \]\] | "fi" | "esac" | "done" %{ private String location = "MAIN PROGRAM"; + private String parsedFileName; private List identifiers = new LinkedList(); private float lines=0; private boolean emptyLine = true; @@ -85,7 +87,8 @@ FUNCEND = \} | \) | \)\) | \]\] | "fi" | "esac" | "done" public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.fine("begin method setInputFile"); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.fine("end method setInputFile"); } @@ -335,8 +338,9 @@ FUNCEND = \} | \) | \)\) | \]\] | "fi" | "esac" | "done" /************************/ /* ERROR STATE */ /************************/ - [^] { - String errorMessage = "Class: "+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.getInputFile().getAbsolutePath() +"\nat line:"+yyline+" column:"+yycolumn+"\nLast word read : "+yytext(); - throw new JFlexException(new Exception(errorMessage)); - } - + [^] { + 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); + } diff --git a/fr.cnes.analysis.tools.shell.metrics/lex/SHMETNesting.lex b/fr.cnes.analysis.tools.shell.metrics/lex/SHMETNesting.lex index d3021754..9176952b 100755 --- a/fr.cnes.analysis.tools.shell.metrics/lex/SHMETNesting.lex +++ b/fr.cnes.analysis.tools.shell.metrics/lex/SHMETNesting.lex @@ -37,8 +37,9 @@ import org.eclipse.core.runtime.Path; %class SHMETNesting %extends AbstractChecker %public -%line %column +%line + %function run %yylexthrow JFlexException @@ -67,6 +68,7 @@ FUNCEND = \} | \) | \)\) | \]\] | "fi" | "esac" | "done" %{ private String location = "MAIN PROGRAM"; + private String parsedFileName; private List identifiers = new LinkedList(); private Stack functionStack = new Stack<>(); private Stack mainNestingStack = new Stack<>(); @@ -82,7 +84,8 @@ FUNCEND = \} | \) | \)\) | \]\] | "fi" | "esac" | "done" public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.fine("begin method setInputFile"); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.fine("end method setInputFile"); } @@ -326,8 +329,9 @@ FUNCEND = \} | \) | \)\) | \]\] | "fi" | "esac" | "done" /************************/ /* ERROR STATE */ /************************/ - [^] { - String errorMessage = "Class: "+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.getInputFile().getAbsolutePath() +"\nat line:"+yyline+" column:"+yycolumn+"\nLast word read : "+yytext(); - throw new JFlexException(new Exception(errorMessage)); - } - + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.metrics/lex/SHMETRatioComment.lex b/fr.cnes.analysis.tools.shell.metrics/lex/SHMETRatioComment.lex index ac7d9c9b..bb18fe13 100755 --- a/fr.cnes.analysis.tools.shell.metrics/lex/SHMETRatioComment.lex +++ b/fr.cnes.analysis.tools.shell.metrics/lex/SHMETRatioComment.lex @@ -37,8 +37,9 @@ import org.eclipse.core.runtime.Path; %class SHMETRatioComment %extends AbstractChecker %public -%line %column +%line + %function run %yylexthrow JFlexException @@ -67,6 +68,7 @@ FUNCEND = \} | \) | \)\) | \]\] | "fi" | "esac" | "done" %{ private String location = "MAIN PROGRAM"; + private String parsedFileName; private List identifiers = new LinkedList(); private float lines=0; private boolean emptyLine = true; @@ -88,7 +90,8 @@ FUNCEND = \} | \) | \)\) | \]\] | "fi" | "esac" | "done" public void setInputFile(File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.fine("begin method setInputFile"); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.fine("end method setInputFile"); } @@ -385,8 +388,9 @@ FUNCEND = \} | \) | \)\) | \]\] | "fi" | "esac" | "done" /************************/ /* ERROR STATE */ /************************/ - [^] { - String errorMessage = "Class: "+this.getClass().getName()+"\nIllegal character <" + yytext() + ">\nFile :"+ this.getInputFile().getAbsolutePath() +"\nat line:"+yyline+" column:"+yycolumn+"\nLast word read : "+yytext(); - throw new JFlexException(new Exception(errorMessage)); - } - + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMDATAInvariant.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMDATAInvariant.lex index a296e1c8..31e4967b 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMDATAInvariant.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMDATAInvariant.lex @@ -33,6 +33,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMDATAInvariant %extends AbstractChecker %public +%column %line %function run @@ -107,6 +108,7 @@ CLE = "alias" | "apropos" | "apt-get" | "aptitude" | "ascp" | "aspell" | "awk %{ /* MAINPROGRAM: constant for main program localisation */ private static final String MAINPROGRAM = "MAIN PROGRAM"; + private String parsedFileName; private String location = MAINPROGRAM; /* VARIABLE: constant for variable error message */ private static final String VARIABLE = " -> The variable "; @@ -188,7 +190,9 @@ CLE = "alias" | "apropos" | "apt-get" | "aptitude" | "ascp" | "aspell" | "awk @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -268,7 +272,7 @@ CLE = "alias" | "apropos" | "apt-get" | "aptitude" | "ascp" | "aspell" | "awk String var = yytext().substring(varPos, yytext().length()-1); localAddVar(var); yybegin(INVARIANT);} - . {} + [^] {} } /************************/ @@ -294,4 +298,9 @@ CLE = "alias" | "apropos" | "apt-get" | "aptitude" | "ascp" | "aspell" | "awk /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMDATALoopCondition.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMDATALoopCondition.lex index c526480a..403f78c2 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMDATALoopCondition.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMDATALoopCondition.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMDATALoopCondition %extends AbstractChecker %public +%column %line %ignorecase @@ -52,6 +53,7 @@ DONE = "done" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List> conditions = new ArrayList>(); List variables = new ArrayList(); @@ -61,7 +63,9 @@ DONE = "done" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } /** @@ -134,7 +138,7 @@ DONE = "done" {VAR}\= {String var = yytext().substring(0, yytext().length()-1); checkVariable(var);} {DONE} {int index = conditions.size() - 1; if (index >= 0) {conditions.remove(index);}} {VAR} {} - . {} + [^] {} } /************************/ @@ -168,4 +172,9 @@ DONE = "done" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMDATANotUsed.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMDATANotUsed.lex index afe8b449..d7007b60 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMDATANotUsed.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMDATANotUsed.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMDATANotUsed %extends AbstractChecker %public +%column %line %ignorecase @@ -50,6 +51,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List variables = new ArrayList(); List allVariables = new ArrayList(); List lines = new ArrayList(); @@ -61,7 +63,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } /** @@ -136,7 +140,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* \$(\{)?{VAR} {String var = yytext().replaceAll("\\$","").replaceAll("\\{",""); allVariables.add(var);} \" {yybegin(STRING);} - . {} + [^] {} } /************************/ @@ -147,7 +151,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* \$(\{)?{VAR} {String var = yytext().replaceAll("\\$","").replaceAll("\\{",""); allVariables.add(var);} \" {yybegin(YYINITIAL);} - . {} + [^] {} } @@ -155,4 +159,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMDESIGNActiveWait.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMDESIGNActiveWait.lex index 30ab4ef5..8a31b494 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMDESIGNActiveWait.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMDESIGNActiveWait.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMDESIGNActiveWait %extends AbstractChecker %public +%column %line %ignorecase @@ -51,6 +52,7 @@ ACTWAIT = "while"{SPACE}*\[{SPACE}*"1"{SPACE}*\]{SPACE}* | %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public COMDESIGNActiveWait() { } @@ -58,6 +60,8 @@ ACTWAIT = "while"{SPACE}*\[{SPACE}*"1"{SPACE}*\]{SPACE}* | @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); + + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -105,11 +109,16 @@ ACTWAIT = "while"{SPACE}*\[{SPACE}*"1"{SPACE}*\]{SPACE}* | {ACTWAIT} {setError(location,"There is an active wait in this point.", yyline+1); } {STRING} {} {VAR} {} /* Clause to match with words */ - . {} + [^] {} } /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWAbort.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWAbort.lex index 6aa674d1..7fdbdd64 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWAbort.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWAbort.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWAbort %extends AbstractChecker %public +%column %line %ignorecase @@ -51,6 +52,7 @@ OPTIONS = \- ("9" | "SIGKILL" | "kill") %{ String location = "MAIN PROGRAM"; + private String parsedFileName; String errorKill = ""; public COMFLOWAbort() { @@ -59,7 +61,9 @@ OPTIONS = \- ("9" | "SIGKILL" | "kill") @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -106,7 +110,7 @@ OPTIONS = \- ("9" | "SIGKILL" | "kill") {ABORT} {errorKill= yytext(); yybegin(KILL);} {STRING} {} {VAR} {} /* Clause to match with words that contains "kill" */ - . {} + [^] {} } /************************/ @@ -125,4 +129,9 @@ OPTIONS = \- ("9" | "SIGKILL" | "kill") /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWBooleanExpression.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWBooleanExpression.lex index 51570544..6572976c 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWBooleanExpression.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWBooleanExpression.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWBooleanExpression %extends AbstractChecker %public +%column %line %ignorecase @@ -55,6 +56,7 @@ BOOL = \|\| | \&\& | \-"o" | \-"a" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int booleanExpressions = 0; public COMFLOWBooleanExpression() { @@ -63,7 +65,9 @@ BOOL = \|\| | \&\& | \-"o" | \-"a" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -112,7 +116,7 @@ BOOL = \|\| | \&\& | \-"o" | \-"a" {IF} {booleanExpressions=0; yybegin(CONDITIONAL);} {WHILE} {booleanExpressions=0; yybegin(LOOP);} {VAR} {} /* Clause to match with words that contains "kill" */ - . {} + [^] {} } /************************/ @@ -143,4 +147,9 @@ BOOL = \|\| | \&\& | \-"o" | \-"a" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWCaseSwitch.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWCaseSwitch.lex index fc25a414..809e6bcc 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWCaseSwitch.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWCaseSwitch.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWCaseSwitch %extends AbstractChecker %public +%column %line %ignorecase @@ -50,6 +51,7 @@ ESAC = "esac" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; boolean defaultExpr = false; public COMFLOWCaseSwitch() { @@ -58,7 +60,9 @@ ESAC = "esac" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -105,7 +109,7 @@ ESAC = "esac" {STRING} {} {CASE} {defaultExpr=false; yybegin(CONDITIONAL);} {VAR} {} /* Clause to match with words that contains "kill" */ - . {} + [^] {} } /************************/ @@ -123,4 +127,9 @@ ESAC = "esac" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWExit.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWExit.lex index bf5b9c78..6e5a1d41 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWExit.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWExit.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWExit %extends AbstractChecker %public +%column %line %ignorecase @@ -51,6 +52,7 @@ RETURN = "return" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int brackets=0; int returns=0; int lineError=0; @@ -61,7 +63,9 @@ RETURN = "return" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -108,7 +112,7 @@ RETURN = "return" {FUNCT} {location = yytext().substring(0,yytext().length()-2).trim(); returns=0; brackets=0; yybegin(FUNCTION);} {STRING} {} {VAR} {} /* Clause to match with words that contains "return" */ - . {} + [^] {} } /************************/ @@ -136,4 +140,9 @@ RETURN = "return" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWExitLoop.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWExitLoop.lex index 7382bcee..38360f73 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWExitLoop.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWExitLoop.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWExitLoop %extends AbstractChecker %public +%column %line %ignorecase @@ -55,6 +56,7 @@ BREAK = "break" | "exit" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; /* nb_loops counts the number of loop structures we are in */ /* It is used to ckeck that we are actually in a loop when raising a violation */ int nb_loops = 0; @@ -66,7 +68,9 @@ BREAK = "break" | "exit" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -116,11 +120,16 @@ BREAK = "break" | "exit" {DONE} {nb_loops --;} {BREAK} {if(nb_loops>0) setError(location,"There is more than one exit in the loop.", yyline+1); } {VAR} {} - . {} + [^] {} } /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWFileExistence.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWFileExistence.lex index e9fdc25a..eb80c7aa 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWFileExistence.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWFileExistence.lex @@ -33,8 +33,9 @@ import java.util.logging.Logger; %class COMFLOWFileExistence %extends AbstractChecker %public -%line %column +%line + %function run %yylexthrow JFlexException @@ -94,6 +95,7 @@ IGNORE = {REDIRECT_IGNORE} | {STRING_ESCAPED} | ([\\][\#]) | "ssh" private String location = "MAIN PROGRAM"; private String parsedFileName; + List filesExistence = new ArrayList(); private String stringBeginner = ""; @@ -108,6 +110,8 @@ IGNORE = {REDIRECT_IGNORE} | {STRING_ESCAPED} | ([\\][\#]) | "ssh" public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.fine("begin method setInputFile"); + + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.fine("end method setInputFile"); @@ -200,7 +204,7 @@ IGNORE = {REDIRECT_IGNORE} | {STRING_ESCAPED} | ([\\][\#]) | "ssh" LOGGER.fine("["+this.parsedFileName+":"+(yyline+1)+":"+yycolumn+"] - YYINITIAL -> STRING (Transition : STRING \""+yytext()+"\" )"); yybegin(STRING); } - . {} + [^] {} } @@ -267,4 +271,9 @@ IGNORE = {REDIRECT_IGNORE} | {STRING_ESCAPED} | ([\\][\#]) | "ssh" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWFilePath.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWFilePath.lex index 04ca16f4..8c3c9728 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWFilePath.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMFLOWFilePath.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMFLOWFilePath %extends AbstractChecker %public +%column %line %ignorecase @@ -51,6 +52,7 @@ FILEEXT = \.[a-zA-Z][^\.]{0,5} %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public COMFLOWFilePath() { } @@ -58,7 +60,9 @@ FILEEXT = \.[a-zA-Z][^\.]{0,5} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -105,7 +109,7 @@ FILEEXT = \.[a-zA-Z][^\.]{0,5} {FUNCT} {location = yytext().substring(0,yytext().length()-2).trim();} {POSERROR} {yybegin(INITIALISATION);} {VAR} {} /* Clause to match with words */ - . {} + [^] {} } /************************/ @@ -122,4 +126,9 @@ FILEEXT = \.[a-zA-Z][^\.]{0,5} /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTBoolNegation.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTBoolNegation.lex index e2932426..a974ca99 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTBoolNegation.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTBoolNegation.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTBoolNegation %extends AbstractChecker %public +%column %line %ignorecase @@ -54,6 +55,7 @@ OPER = \&\& | \|\| | \-"o" | \-"a" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Bool to knkow if there are open brackets **/ int bracket = 0, brace = 0, parenth = 0; @@ -63,7 +65,9 @@ OPER = \&\& | \|\| | \-"o" | \-"a" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -111,7 +115,7 @@ OPER = \&\& | \|\| | \-"o" | \-"a" {FUNCT} {location = yytext().substring(0,yytext().length()-2).trim();} {NOT} {bracket=0; brace=0; parenth=0; yybegin(LOGICAL);} {STRING} {} - . {} + [^] {} } /************************/ @@ -135,4 +139,9 @@ OPER = \&\& | \|\| | \-"o" | \-"a" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTBrace.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTBrace.lex index e130444f..68c341b3 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTBrace.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTBrace.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTBrace %extends AbstractChecker %public +%column %line %ignorecase @@ -60,6 +61,7 @@ BRACING = "expr" | "let" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List parenthesis = new LinkedList(); List operators = new LinkedList(); @@ -69,7 +71,9 @@ BRACING = "expr" | "let" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void addParenthesis(){ @@ -171,7 +175,7 @@ BRACING = "expr" | "let" "export" {yybegin(COMMENT);} {BRACING} {yybegin(BRACE);} {VAR} {} - . {} + [^] {} } /************************/ @@ -192,4 +196,9 @@ BRACING = "expr" | "let" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTCodeComment.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTCodeComment.lex index 07ba860a..ef64b567 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTCodeComment.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTCodeComment.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTCodeComment %extends AbstractChecker %public +%column %line %function run @@ -105,6 +106,7 @@ CLE = {RESERVED}| {POSIX} | {BUILTINS} %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List loc = new LinkedList(); public COMINSTCodeComment() { @@ -114,7 +116,9 @@ CLE = {RESERVED}| {POSIX} | {BUILTINS} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -172,7 +176,7 @@ CLE = {RESERVED}| {POSIX} | {BUILTINS} {FUNCTION} {yybegin(NAMING);} {FUNCT} {location = yytext().substring(0,yytext().length()-2).trim(); loc.add(location); yybegin(PREHEADER);} {STRING} {} - . {} + [^] {} } @@ -207,4 +211,9 @@ CLE = {RESERVED}| {POSIX} | {BUILTINS} /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTLine.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTLine.lex index b1601ec7..c98abd19 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTLine.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTLine.lex @@ -33,8 +33,9 @@ import java.util.logging.Logger; %class COMINSTLine %extends AbstractChecker %public -%line %column +%line + %function run %yylexthrow JFlexException @@ -64,7 +65,8 @@ CONDITIONAL_STRUCT = [\[][\[]({VAR}|{SPACE}|{VALUE}|{OPERATOR}|{BRACKET})*[\]][ %{ private static final Logger LOGGER = Logger.getLogger(COMINSTLine.class.getName()); String location = "MAIN PROGRAM"; - String parsedFileName; + private String parsedFileName; + public COMINSTLine() { @@ -75,6 +77,8 @@ CONDITIONAL_STRUCT = [\[][\[]({VAR}|{SPACE}|{VALUE}|{OPERATOR}|{BRACKET})*[\]][ public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.fine("begin method setInputFile"); + + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.fine("end method setInputFile"); @@ -167,10 +171,15 @@ CONDITIONAL_STRUCT = [\[][\[]({VAR}|{SPACE}|{VALUE}|{OPERATOR}|{BRACKET})*[\]][ LOGGER.fine("["+this.parsedFileName+":"+(yyline+1)+":"+yycolumn+"] - YYINITIAL -> IGNORE (NEW_INSTRUCTION : \""+yytext()+"\")"); yybegin(IGNORE); } - . {} + [^] {} } /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTLoopCondition.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTLoopCondition.lex index 71c43733..79465f27 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMINSTLoopCondition.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMINSTLoopCondition.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMINSTLoopCondition %extends AbstractChecker %public +%column %line %ignorecase @@ -66,6 +67,7 @@ LOOP = {WHILE} | {UNTIL} %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public COMINSTLoopCondition() { @@ -74,7 +76,9 @@ LOOP = {WHILE} | {UNTIL} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -122,7 +126,7 @@ LOOP = {WHILE} | {UNTIL} {FUNCT} {location = yytext().substring(0,yytext().length()-2).trim();} {STRING} {} {LOOP} {yybegin(LOOPCONDITION);} - . {} + [^] {} } /************************/ @@ -141,4 +145,9 @@ LOOP = {WHILE} | {UNTIL} /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMPRESHeader.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMPRESHeader.lex index eaf62e8f..3e8f56b4 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMPRESHeader.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMPRESHeader.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMPRESHeader %extends AbstractChecker %public +%column %line %ignorecase @@ -51,6 +52,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List linesType = new LinkedList(); List locations = new LinkedList(); List lines = new LinkedList(); @@ -64,7 +66,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void addType(String type, String location, int line){ @@ -191,4 +195,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMPRESIndent.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMPRESIndent.lex index 015467dd..e3182b7a 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMPRESIndent.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMPRESIndent.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMPRESIndent %extends AbstractChecker %public +%column %line %function run @@ -61,6 +62,7 @@ IGNORETEXT = "<<" {SPACE}* "EOF" [^"<<"]* "EOF" | ` [^`]* ` %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int currentPos = 0, pos = 0; List desiredPos = new ArrayList(); /* inTabs is true while parsing tabs at the beginning of a line */ @@ -79,7 +81,9 @@ IGNORETEXT = "<<" {SPACE}* "EOF" [^"<<"]* "EOF" | ` [^`]* ` @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } /** @@ -224,4 +228,9 @@ IGNORETEXT = "<<" {SPACE}* "EOF" [^"<<"]* "EOF" | ` [^`]* ` /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMPRESLengthLine.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMPRESLengthLine.lex index 553ce8a5..0133368e 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMPRESLengthLine.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMPRESLengthLine.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMPRESLengthLine %extends AbstractChecker %public +%column %line %ignorecase @@ -49,6 +50,7 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int length = 0; public COMPRESLengthLine() { @@ -58,7 +60,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void checkLine() throws JFlexException { @@ -107,4 +111,9 @@ VAR = [a-zA-Z][a-zA-Z0-9\_]* /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/COMTYPEExpression.lex b/fr.cnes.analysis.tools.shell.rules/lex/COMTYPEExpression.lex index 099cfe3e..a5213f4d 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/COMTYPEExpression.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/COMTYPEExpression.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class COMTYPEExpression %extends AbstractChecker %public +%column %line %ignorecase @@ -62,6 +63,7 @@ EXPR = {VARIABLE} {SPACE}+ {OPER} {SPACE}+ ({STRING}|{INT}|{VARIABLE}) %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List chars = new ArrayList(); List ints = new ArrayList(); String variableName = ""; @@ -106,7 +108,9 @@ EXPR = {VARIABLE} {SPACE}+ {OPER} {SPACE}+ ({STRING}|{INT}|{VARIABLE}) @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -196,4 +200,9 @@ EXPR = {VARIABLE} {SPACE}+ {OPER} {SPACE}+ ({STRING}|{INT}|{VARIABLE}) /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHDATAIFS.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHDATAIFS.lex index 301719c7..09f9cc5f 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHDATAIFS.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHDATAIFS.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHDATAIFS %extends AbstractChecker %public +%column %line %ignorecase @@ -53,6 +54,7 @@ IFS = "IFS"\= %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHDATAIFS() { @@ -61,7 +63,9 @@ IFS = "IFS"\= @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -117,4 +121,9 @@ IFS = "IFS"\= /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHDATAInteger.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHDATAInteger.lex index 454efcde..97c36f79 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHDATAInteger.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHDATAInteger.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHDATAInteger %extends AbstractChecker %public +%column %line %ignorecase @@ -58,6 +59,7 @@ TYPESET = "typeset"{SPACE}+\-"i" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List integers = new ArrayList(); public SHDATAInteger() { @@ -67,7 +69,9 @@ TYPESET = "typeset"{SPACE}+\-"i" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -151,4 +155,9 @@ TYPESET = "typeset"{SPACE}+\-"i" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHDESIGNBash.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHDESIGNBash.lex index 60075ee8..5a042759 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHDESIGNBash.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHDESIGNBash.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHDESIGNBash %extends AbstractChecker %public +%column %line %ignorecase @@ -51,6 +52,7 @@ CORRECT = \#\!\/"bin"\/"bash" | %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHDESIGNBash() { @@ -59,7 +61,9 @@ CORRECT = \#\!\/"bin"\/"bash" | @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -99,4 +103,9 @@ CORRECT = \#\!\/"bin"\/"bash" | /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHDESIGNOptions.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHDESIGNOptions.lex index a2f21fee..6fc891f2 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHDESIGNOptions.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHDESIGNOptions.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHDESIGNOptions %extends AbstractChecker %public +%column %line %function run @@ -54,6 +55,7 @@ ESAC = "esac" %{ private String location = "MAIN PROGRAM"; + private String parsedFileName; /* getopts = true if getopts has been found */ /* inGetopts = true if we are in the process of examining the different opts */ @@ -76,7 +78,9 @@ ESAC = "esac" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -170,4 +174,9 @@ ESAC = "esac" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHERRHelp.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHERRHelp.lex index af0f4c0a..b10ffe82 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHERRHelp.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHERRHelp.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHERRHelp %extends AbstractChecker %public +%column %line %ignorecase @@ -57,6 +58,7 @@ HELP = "help" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; /* getopts = true if getopts or getopt has been found */ /* inGetopts = true if we are in the process of examining the different opts */ /* There will be violations if no getopts has been found at the end (getopts = false) */ @@ -71,7 +73,9 @@ HELP = "help" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -154,4 +158,9 @@ HELP = "help" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHERRNoPipe.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHERRNoPipe.lex index 9bd60e61..24b1d710 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHERRNoPipe.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHERRNoPipe.lex @@ -33,6 +33,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHERRNoPipe %extends AbstractChecker %public +%column %line %ignorecase @@ -66,6 +67,7 @@ OR = \|\| %{ String location = "MAIN PROGRAM"; + private String parsedFileName; /** Is the state reached inside a case statement */ private boolean inCase = false; @@ -77,7 +79,9 @@ OR = \|\| @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -173,4 +177,9 @@ OR = \|\| /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHERRString.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHERRString.lex index 0d74a0ca..7c7b3212 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHERRString.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHERRString.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHERRString %extends AbstractChecker %public +%column %line %ignorecase @@ -52,6 +53,7 @@ COMPARISON = ("if" | "while") {SPACE}* \[ {SPACE} %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int brackets = 0; public SHERRString() { @@ -61,7 +63,9 @@ COMPARISON = ("if" | "while") {SPACE}* \[ {SPACE} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -127,4 +131,9 @@ COMPARISON = ("if" | "while") {SPACE}* \[ {SPACE} /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckArguments.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckArguments.lex index 3a07b5a4..35d4ac88 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckArguments.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckArguments.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHFLOWCheckArguments %extends AbstractChecker %public +%column %line %ignorecase @@ -54,6 +55,7 @@ ARGS = "if"{SPACE}+\[{SPACE}+\$\#{SPACE}+{COMP} %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int lastFunctionLine = 0; public SHFLOWCheckArguments() { @@ -63,7 +65,9 @@ ARGS = "if"{SPACE}+\[{SPACE}+\$\#{SPACE}+{COMP} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -136,4 +140,9 @@ ARGS = "if"{SPACE}+\[{SPACE}+\$\#{SPACE}+{COMP} /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckCodeReturn.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckCodeReturn.lex index e677b6eb..2e2065d9 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckCodeReturn.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckCodeReturn.lex @@ -32,6 +32,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHFLOWCheckCodeReturn %extends AbstractChecker %public +%column %line %function run @@ -52,6 +53,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ private String location = "MAIN PROGRAM"; + private String parsedFileName; /** Map with each function name and if contains a return or not **/ private Map functions = new HashMap(); /** The return of the last function is checked: avoid problems with last call **/ @@ -111,7 +113,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } @@ -169,7 +173,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" } else { functionCalled=false; }} - . {} + [^] {} } /************************/ @@ -237,4 +241,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckUser.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckUser.lex index 13c19f72..8411517e 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckUser.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHFLOWCheckUser.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHFLOWCheckUser %extends AbstractChecker %public +%column %line %ignorecase @@ -60,6 +61,7 @@ DIRECT_CHECK = {DIRECT_USER} {SPACE}+ {OP} {SPACE}+ {ROOT_VALUE} %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int errorLine = 0; String errorLocation = ""; String checkUser = ""; @@ -71,7 +73,9 @@ DIRECT_CHECK = {DIRECT_USER} {SPACE}+ {OP} {SPACE}+ {ROOT_VALUE} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } private void checkRootUser(String rootUser) { @@ -134,7 +138,7 @@ DIRECT_CHECK = {DIRECT_USER} {SPACE}+ {OP} {SPACE}+ {ROOT_VALUE} /************************/ { - . {} + [^] {} } /************************/ @@ -155,4 +159,9 @@ DIRECT_CHECK = {DIRECT_USER} {SPACE}+ {OP} {SPACE}+ {ROOT_VALUE} /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTBasename.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTBasename.lex index 8032e539..6921376d 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTBasename.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTBasename.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHINSTBasename %extends AbstractChecker %public +%column %line %ignorecase @@ -54,6 +55,7 @@ DIRNAME = "dirname"{SPACE}+\$"0" | "dirname"{SPACE}+\"\$"0"\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHINSTBasename() { @@ -62,7 +64,9 @@ DIRNAME = "dirname"{SPACE}+\$"0" | "dirname"{SPACE}+\"\$"0"\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -118,4 +122,9 @@ DIRNAME = "dirname"{SPACE}+\$"0" | "dirname"{SPACE}+\"\$"0"\" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTContinue.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTContinue.lex index 63942074..d17a9f1b 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTContinue.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTContinue.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHINSTContinue %extends AbstractChecker %public +%column %line %ignorecase @@ -49,6 +50,7 @@ CONTINUE = "continue" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHINSTContinue() { } @@ -56,7 +58,9 @@ CONTINUE = "continue" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -103,11 +107,16 @@ CONTINUE = "continue" {FUNC} {location = yytext(); yybegin(NAMING);} {CONTINUE} {setError(location,"The keyword CONTINUE is not allowed.", yyline+1); } {VAR} {} /* Clause to match with words that contains "continue" */ - . {} + [^] {} } /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTFind.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTFind.lex index f4caa4df..fe82f7ef 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTFind.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTFind.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHINSTFind %extends AbstractChecker %public +%column %line %ignorecase @@ -53,6 +54,7 @@ LS = "ls" | "/bin/ls" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHINSTFind() { @@ -61,7 +63,9 @@ LS = "ls" | "/bin/ls" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -117,4 +121,9 @@ LS = "ls" | "/bin/ls" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTGetOpts.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTGetOpts.lex index eff116b5..e0845d4a 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTGetOpts.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTGetOpts.lex @@ -31,8 +31,9 @@ import java.util.logging.Logger; %class SHINSTGetOpts %extends AbstractChecker %public -%line %column +%line + %function run %yylexthrow JFlexException @@ -55,7 +56,8 @@ ESCAPE_STRING = [\\]([\']|[\"]) %{ private static final Logger LOGGER = Logger.getLogger(SHINSTGetOpts.class.getName()); String location = "MAIN PROGRAM"; - String parsedFileName; + private String parsedFileName; + boolean foundGetOpts = false; @@ -74,6 +76,8 @@ ESCAPE_STRING = [\\]([\']|[\"]) public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.fine("begin method setInputFile"); + + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.fine("end method setInputFile"); @@ -161,7 +165,7 @@ ESCAPE_STRING = [\\]([\']|[\"]) } } - . { + [^] { escapeNext=false; } @@ -209,4 +213,9 @@ ESCAPE_STRING = [\\]([\']|[\"]) /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTInterpreter.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTInterpreter.lex index 446646f9..8d5898a7 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTInterpreter.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTInterpreter.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHINSTInterpreter %extends AbstractChecker %public +%column %line %ignorecase @@ -48,6 +49,7 @@ CORRECT = [\#][\!][\ ]*[\/] %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHINSTInterpreter() { @@ -56,7 +58,9 @@ CORRECT = [\#][\!][\ ]*[\/] @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -96,4 +100,9 @@ CORRECT = [\#][\!][\ ]*[\/] /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTKeywords.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTKeywords.lex index 8a6f0177..b188ed08 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTKeywords.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTKeywords.lex @@ -33,8 +33,9 @@ import java.util.logging.Logger; %class SHINSTKeywords %extends AbstractChecker %public -%line %column +%line + %function run %yylexthrow JFlexException @@ -66,7 +67,8 @@ NO_ERROR = (([a-zA-Z0-9\_]+{KEYWORD}|{KEYWORD}[a-zA-Z0-9\_]+)[\=])| {KEYWORD_VAR %{ private static final Logger LOGGER = Logger.getLogger(SHINSTKeywords.class.getName()); String location = "MAIN PROGRAM"; - String parsedFileName; + private String parsedFileName; + private boolean inString = false, escapeNext=false; private String stringBeginner="", commandBeginner=""; @@ -88,6 +90,8 @@ NO_ERROR = (([a-zA-Z0-9\_]+{KEYWORD}|{KEYWORD}[a-zA-Z0-9\_]+)[\=])| {KEYWORD_VAR public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); LOGGER.fine("begin method setInputFile"); + + this.parsedFileName = file.toString(); this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); LOGGER.fine("end method setInputFile"); @@ -275,4 +279,9 @@ NO_ERROR = (([a-zA-Z0-9\_]+{KEYWORD}|{KEYWORD}[a-zA-Z0-9\_]+)[\=])| {KEYWORD_VAR /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTLogical.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTLogical.lex index b0abafec..5f921c22 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTLogical.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTLogical.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHINSTLogical %extends AbstractChecker %public +%column %line %ignorecase @@ -56,6 +57,7 @@ ENDCOND = "do" | "then" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHINSTLogical() { @@ -64,7 +66,9 @@ ENDCOND = "do" | "then" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -142,4 +146,9 @@ ENDCOND = "do" | "then" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTPOSIX.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTPOSIX.lex index 8fab493a..7d3bb942 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTPOSIX.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTPOSIX.lex @@ -33,6 +33,7 @@ import java.util.regex.Matcher; %class SHINSTPOSIX %extends AbstractChecker %public +%column %line %function run @@ -95,6 +96,7 @@ VAR_ERROR = ([\$]{ERROR}) | ([\$][\{]{ERROR}[\}]) %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List variables = new ArrayList(); /** The next char must be escaped*/ private boolean escapeNext = false; @@ -131,7 +133,9 @@ VAR_ERROR = ([\$]{ERROR}) | ([\$][\{]{ERROR}[\}]) @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -276,4 +280,9 @@ VAR_ERROR = ([\$]{ERROR}) | ([\$][\{]{ERROR}[\}]) /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTSetShift.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTSetShift.lex index d53b3043..703f40a8 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTSetShift.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTSetShift.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHINSTSetShift %extends AbstractChecker %public +%column %line %ignorecase @@ -54,6 +55,7 @@ AVOID = "set"{SPACE}+\-"o"{SPACE}+"pipefail" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHINSTSetShift() { @@ -62,7 +64,9 @@ AVOID = "set"{SPACE}+\-"o"{SPACE}+"pipefail" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -119,4 +123,9 @@ AVOID = "set"{SPACE}+\-"o"{SPACE}+"pipefail" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTVariables.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTVariables.lex index 527e9a91..dcc758b2 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHINSTVariables.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHINSTVariables.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHINSTVariables %extends AbstractChecker %public +%column %line %function run @@ -57,6 +58,7 @@ VAR_ERROR = ([\$]({NAME}|{SHELL_VAR})) %{ String location = "MAIN PROGRAM"; + private String parsedFileName; private boolean goodPractice = false; private boolean escapeNext = true; private String stringBeginner = ""; @@ -67,7 +69,9 @@ VAR_ERROR = ([\$]({NAME}|{SHELL_VAR})) @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -207,4 +211,9 @@ VAR_ERROR = ([\$]({NAME}|{SHELL_VAR})) /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHIORedirect.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHIORedirect.lex index 59d7fbb8..1ffe4e4f 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHIORedirect.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHIORedirect.lex @@ -49,6 +49,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHIORedirect %extends AbstractChecker %public +%column %line %function run @@ -75,6 +76,7 @@ REDIRECT = {REDIRECT_RIGHT}|{REDIRECT_LEFT}|{REDIRECT_RL} %{ String location = "MAIN PROGRAM"; + private String parsedFileName; List redirections = new ArrayList(); private boolean isLastLineCommented = false; private boolean errorReported=false; @@ -86,7 +88,9 @@ REDIRECT = {REDIRECT_RIGHT}|{REDIRECT_LEFT}|{REDIRECT_RL} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -153,4 +157,9 @@ REDIRECT = {REDIRECT_RIGHT}|{REDIRECT_LEFT}|{REDIRECT_RL} /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHMETLimitAWK.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHMETLimitAWK.lex index c8c986f7..b9ae9bd2 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHMETLimitAWK.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHMETLimitAWK.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHMETLimitAWK %extends AbstractChecker %public +%column %line %ignorecase @@ -50,6 +51,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int actions=0, sym=0; int lineError=0; @@ -60,7 +62,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -128,4 +132,9 @@ STRING = \'[^\']*\' | \"[^\"]*\" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHMETLimitSed.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHMETLimitSed.lex index e04e8f73..d22500f8 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHMETLimitSed.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHMETLimitSed.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHMETLimitSed %extends AbstractChecker %public +%column %line %function run @@ -53,6 +54,7 @@ OPTION = "-e" | "--expression" | "-f" | "--file" | %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int actions=0, linesSed=0; int lineError=0; @@ -63,7 +65,9 @@ OPTION = "-e" | "--expression" | "-f" | "--file" | @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -143,4 +147,9 @@ OPTION = "-e" | "--expression" | "-f" | "--file" | /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHMETPipeLine.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHMETPipeLine.lex index b6222cb4..bd57bce8 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHMETPipeLine.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHMETPipeLine.lex @@ -31,6 +31,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHMETPipeLine %extends AbstractChecker %public +%column %line %ignorecase @@ -51,6 +52,7 @@ PIPELINE = \|{SPACE} | \|\n | \|\& %{ String location = "MAIN PROGRAM"; + private String parsedFileName; int bracket = 0; String type = ""; /** For each line a string that represent the line type: comment, empty, line **/ @@ -63,7 +65,9 @@ PIPELINE = \|{SPACE} | \|\n | \|\& @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } /** @@ -155,4 +159,9 @@ PIPELINE = \|{SPACE} | \|\n | \|\& /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHREFExport.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHREFExport.lex index 9516796c..74f336ac 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHREFExport.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHREFExport.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHREFExport %extends AbstractChecker %public +%column %line %ignorecase @@ -53,6 +54,7 @@ EXPORT = "export"{SPACE}+\-"f"{SPACE}+{VAR} %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHREFExport() { @@ -61,7 +63,9 @@ EXPORT = "export"{SPACE}+\-"f"{SPACE}+{VAR} @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -116,4 +120,9 @@ EXPORT = "export"{SPACE}+\-"f"{SPACE}+{VAR} /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.shell.rules/lex/SHSYNCSignals.lex b/fr.cnes.analysis.tools.shell.rules/lex/SHSYNCSignals.lex index b8c9c710..bcfba26b 100755 --- a/fr.cnes.analysis.tools.shell.rules/lex/SHSYNCSignals.lex +++ b/fr.cnes.analysis.tools.shell.rules/lex/SHSYNCSignals.lex @@ -30,6 +30,7 @@ import fr.cnes.analysis.tools.analyzer.exception.JFlexException; %class SHSYNCSignals %extends AbstractChecker %public +%column %line %ignorecase @@ -52,6 +53,7 @@ TRAP = "trap" %{ String location = "MAIN PROGRAM"; + private String parsedFileName; public SHSYNCSignals() { @@ -60,7 +62,9 @@ TRAP = "trap" @Override public void setInputFile(final File file) throws FileNotFoundException { super.setInputFile(file); - this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); + + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new Path(file.getAbsolutePath()).toOSString()); } %} @@ -126,4 +130,9 @@ TRAP = "trap" /************************/ /* ERROR STATE */ /************************/ - [^] {} \ No newline at end of file + [^] { + 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); + } \ No newline at end of file diff --git a/fr.cnes.analysis.tools.ui/src/fr/cnes/analysis/tools/ui/handler/AnalysisHandler.java b/fr.cnes.analysis.tools.ui/src/fr/cnes/analysis/tools/ui/handler/AnalysisHandler.java index b50bf731..f482984d 100644 --- a/fr.cnes.analysis.tools.ui/src/fr/cnes/analysis/tools/ui/handler/AnalysisHandler.java +++ b/fr.cnes.analysis.tools.ui/src/fr/cnes/analysis/tools/ui/handler/AnalysisHandler.java @@ -131,6 +131,12 @@ public void run() { AnalysisHandler.updateViolationsView(resultsViolation); AnalysisHandler.updateMetricsView(resultsMetric); AnalysisHandler.insertMarkers(results); + } else { + MessageDialog.openError( + PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(), + "i-Code CNES - Analysis failure", + analysisJob.getResult().getMessage()); } } }); @@ -143,7 +149,7 @@ public void run() { // Launching the analysis. analysisJob.schedule(); } catch (EmptySelectionException | CoreException exception) { - MessageDialog.openWarning(HandlerUtil.getActiveShell(event), "Core exception", + MessageDialog.openWarning(HandlerUtil.getActiveShell(event), "i-Code CNES - Warning", exception.getMessage()); } LOGGER.exiting(this.getClass().getName(), METHOD, null); diff --git a/fr.cnes.analysis.tools.ui/src/fr/cnes/analysis/tools/ui/handler/AnalysisJob.java b/fr.cnes.analysis.tools.ui/src/fr/cnes/analysis/tools/ui/handler/AnalysisJob.java index a4321b93..d5ad344b 100644 --- a/fr.cnes.analysis.tools.ui/src/fr/cnes/analysis/tools/ui/handler/AnalysisJob.java +++ b/fr.cnes.analysis.tools.ui/src/fr/cnes/analysis/tools/ui/handler/AnalysisJob.java @@ -73,6 +73,7 @@ protected IStatus run(IProgressMonitor monitor) { METHOD = "run"; LOGGER.entering(this.getClass().getName(), METHOD, monitor); IStatus status = Status.OK_STATUS; + monitor.setTaskName("Analyzing files..."); try { this.checks = analyzer.check(inputFiles, languageIds, excludedIds); } catch (IOException | JFlexException exception) {