/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.xcodeml.exception;

/**
 * Exception thrown during the analysis of a directive.
 *
 * @author clementval
 */
public class IllegalDirectiveException extends Exception {
  private int _directiveLine = 0;
  private String _directive;

  /**
   * Constructs a new exception with a specific detail message and clause.
   * @param directive Illegal directive
   * @param message   Specific exception message.
   */
  public IllegalDirectiveException(String directive, String message){
    super(message);
    _directive = directive;
  }

  /**
   * Constructs a new exception with a specific detail message and line number.
   * @param directive Illegal directive
   * @param message   Specific exception message.
   * @param lineno    Line number of the directive.
   */
  public IllegalDirectiveException(String directive, String message, int lineno)
  {
    super(message);
    _directive = directive;
    _directiveLine = lineno;
  }
  /**
   * Get the illegal directive.
   * @return The illegal directive.
   */
  public String getDirective(){
    return _directive;
  }

  /**
   * Set the illegal directive.
   * @param directive The directive.
   */
  public void setDirective(String directive){
    _directive = directive;
  }

  /**
   * Set the line of the code that contains the illegal directive.
   * @param lineno Line number in the XcodeML that triggered the exception.
   */
  public void setDirectiveLine(int lineno) {
    _directiveLine = lineno;
  }

  /**
   * Get the line of the code that contains the illegale directive.
   * @return Line number in the XcodeML that triggered the exception.
   */
  public int getDirectiveLine() {
    return _directiveLine;
  }

  @Override
  public String getMessage() {
    return "Illegal directive: " + super.getMessage() + ". Directive: " +
        _directive + " - line: " + _directiveLine;
  }
}

@@ -309,16 +309,44 @@
 ne = 0;%0A
+  private int _charPos = 0;%0A
   privat
@@ -366,16 +366,16 @@
 ective;%0A
-
 %0A  /**%0A 
@@ -1067,16 +1067,587 @@
 no;%0A  %7D%0A
+%0A  /**%0A   * Constructs a new exception with a specific detail message, line number and%0A   * char position.%0A   * @param directive Illegal directive%0A   * @param message   Specific exception message.%0A   * @param lineno    Line number of the directive.%0A   * @param charPos   Character position where the directive error happened.%0A   */%0A  public IllegalDirectiveException(String directive, String message, int lineno,%0A                                   int charPos)%0A  %7B%0A    super(message);%0A    _directive = directive;%0A    _directiveLine = lineno;%0A    _charPos = charPos;%0A  %7D%0A%0A
   /**%0A  
@@ -2352,24 +2352,24 @@
 iveLine() %7B%0A
-
     return _
@@ -2388,16 +2388,200 @@
 e;%0A  %7D%0A%0A
+  /**%0A   * Get the character position where the directive error happened.%0A   * @return Character position in the line.%0A   */%0A  public int getCharPosition() %7B%0A    return _charPos;%0A  %7D%0A%0A
   @Overr

Add character position information to exception