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

package cx2x.translator.language;

/**
 * ClawLanguage class represent an analyzed pragma statement.
 *
 * @author clementval
 */
public class ClawLanguage {

  private ClawDirective _directive;
  private boolean _valid;

  /**
   * Constructs an empty ClawLanguage section.
   */
  public ClawLanguage(){
    _directive = null;
    _valid = false;
  }

  /**
   * Define the current language section as valid.
   */
  public void setValid(){
    _valid = true;
  }

  /**
   * Check whether the current language section is valid.
   * @return True if the language is valid.
   */
  public boolean isValid(){
    return _valid;
  }

  /**
   * Define the current directive of the language section.
   * @param directive A value of the ClawDirective enumeration.
   */
  public void setDirective(ClawDirective directive){
    _directive = directive;
  }

  /**
   * Get the current directive of the language section.
   * @return Value of the current directive.
   */
  public ClawDirective getDirective(){
    return _directive;
  }




}

@@ -129,16 +129,275 @@
 guage;%0A%0A
+import cx2x.xcodeml.exception.IllegalDirectiveException;%0Aimport org.antlr.v4.runtime.ANTLRInputStream;%0Aimport org.antlr.v4.runtime.BailErrorStrategy;%0Aimport org.antlr.v4.runtime.CommonTokenStream;%0Aimport org.antlr.v4.runtime.misc.ParseCancellationException;%0A%0A
 /**%0A * C
@@ -548,16 +548,45 @@
 ective;%0A
+  private String _groupName;%0A
   privat
@@ -601,16 +601,27 @@
 n _valid
+, _hasGroup
 ;%0A%0A  /**
@@ -668,34 +668,96 @@
 ection.%0A   *
-/%0A  public
+ WARNING: This ctor should only be used by the parser.%0A   */%0A  protected
  ClawLanguag
@@ -804,21 +804,68 @@
  false;%0A
+    _hasGroup = false;%0A    _groupName = null;%0A
   %7D%0A%0A
+%0A
   /**%0A  
@@ -871,269 +871,1569 @@
   * 
-Define the current language section as valid.%0A   */%0A  public void setValid()%7B%0A    _valid = true;%0A  %7D%0A%0A  /**%0A   * Check whether the current language section is valid.%0A   * @return True if the language is valid.%0A   */%0A  public boolean isValid()%7B%0A    return _valid
+Analyze a raw string input and match it with the CLAW language definition.%0A   * @param rawInput A string line to be analyzed against the CLAW language.%0A   * @return A ClawLanguage object with the corresponding extracted information.%0A   */%0A  public static ClawLanguage analyze(String rawInput)%0A      throws IllegalDirectiveException%0A  %7B%0A    // Instantiate the lexer with the raw string input%0A    ClawLexer lexer = new ClawLexer(new ANTLRInputStream(rawInput));%0A%0A    // Get a list of matched tokens%0A    CommonTokenStream tokens = new CommonTokenStream(lexer);%0A%0A    // Pass the tokens to the parser%0A    ClawParser parser = new ClawParser(tokens);%0A    parser.setErrorHandler(new BailErrorStrategy());%0A%0A    try %7B%0A      // Start the parser analysis from the %22analyze%22 entry point%0A      ClawParser.AnalyzeContext ctx = parser.analyze();%0A      // Get the ClawLanguage object return by the parser after analysis.%0A      return ctx.language;%0A    %7D catch(ParseCancellationException pcex)%7B%0A      throw new IllegalDirectiveException(rawInput, %22Unvalid CLAW directive%22);%0A    %7D%0A  %7D%0A%0A  /**%0A   * Check whether the current language section is valid.%0A   * @return True if the language is valid.%0A   */%0A  public boolean isValid()%7B%0A    return _valid;%0A  %7D%0A%0A  /**%0A   * Check whether a group option was specified.%0A   * @return True if group option was specified.%0A   */%0A  public boolean hasGroupOption()%7B%0A    return _hasGroup;%0A  %7D%0A%0A  public void setGroupOption(String groupName)%7B%0A    _hasGroup = true;%0A    _groupName = groupName;%0A  %7D%0A%0A  public String getGroupName()%7B%0A    return _groupName
 ;%0A  

Add static constructor with parser pass + group option information