gt:   AbsVariable val=null; Token v;
context: /* Generated By:JavaCC: Do not edit this line. ExtendedSLParser.java */
  package jade.content.lang.sl;
  
  import jade.content.abs.*;
  import jade.content.onto.Ontology;
  import jade.core.CaseInsensitiveString;
  import jade.content.lang.Codec;
  
  import java.io.ByteArrayInputStream;
  import java.io.StringReader;
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  
  import java.util.Date;
  
  import org.apache.commons.codec.binary.Base64;
  
  
  /**
  * ExtendedSLParser. This same parser embeds also lower profiles of SL, namely SL-0, SL-1 and SL-2.
  * @author Fabio Bellifemine, TILab S.p.A. (formerly CSELT S.p.A.)
  * @author Nicolas Lhuillier (Motorola) (added support for PREFIXBYTELENGTHENCODEDSTRING)
  * @version $Date: 2005-05-13 18:14:10 +0200 (Fri, 13 May 2005) $ $Revision: 5696 $
  **/
  class ExtendedSLParser implements ExtendedSLParserConstants {
  
    private static final String META_EXCEPTION_MESSAGE = "Meta SL expressions are not allowed";
                  /** This variable is true, when meta symbols are allowed (metas are a semantics-specific extension to the SL Grammar) **/
                  private boolean metaAllowed = true; //FIXME to do set/unset this variable 
  
       /* Take a quoted FIPA SL0 String and convert to a 
        * normal Java-style String.  Remove the
        * leading/trailing quotation marks, and
        * un-escape any included quotation marks.
        * This must be the exact inverse of the 
        * escape() procedure in the SLEncoder.
       */
       private String unescape(String s) {
            StringBuffer result = new StringBuffer(s.length());
            for( int i=1; i<s.length()-1; i++)
                  if( s.charAt(i) == '\u005c\u005c' && s.charAt(i+1) == '\u005c"' ) {
                    result.append("\u005c"");
                    i++;
                  } else
                    result.append(s.charAt(i));
                  return result.toString();
       }
  
  
       /**
       * When an ActionExpression is parsed, if it is an AbsConcept then
       * it must be casted upto an AbsAgentAction. 
       **/
       private AbsTerm toAbsAgentAction(AbsTerm t) {
          if ((t instanceof AbsConcept) && (!(t instanceof AbsAgentAction))) {
                  AbsAgentAction act = new AbsAgentAction(t.getTypeName());
                  String[] slotNames = t.getNames();
                  if (slotNames != null) {
                          for (int i=0; i<slotNames.length; i++)
                                  act.set(slotNames[i], (AbsTerm) t.getAbsObject(slotNames[i]));
                  }
                  return act;
          } else
                  return t;
       }
  
    /**
     * By default an object of this type implements a Full ExtendedSLParser.
     * This method allows to change this default.
     * @param slType (0 for FIPa-SL0, 1 for SL1, 2 for SL2, >2 for full SL) 
    **/
    void setSLType(int slType) {
       this.slType = slType;
    }
  
  
    Ontology curOntology = null;
    /**
     * Reinitialize the parser such as it is ready to parse a new expression.
     * @param content the content to be parsed
     * @param o the ontology, null if no ontology (this parameter is used to get the names of the slots
     * when they are encoded as unnamed slots.
    */
    void reinit(Ontology o, String content) {
      curOntology = o;
      if (content == null) content = new String();
      ReInit(new StringReader(content));
    }
  
    /**
     * @param content the content to be parsed
     * @param o the ontology, null if no ontology (this parameter is used to get the names of the slots
     * when they are encoded as unnamed slots.
     * @deprecated since JADE 3.4 it is preferrable to use reinit() and then call directly the method corresponding to the production rule (e.g. Content())
    */
    AbsContentElement parse(Ontology o, String content) throws ParseException, TokenMgrError{
            reinit(o, content);
      AbsContentElementList tuple = Content();
      if (tuple.size() > 1)
        return tuple;
      else  // if there is a single ContentExpression than return just it, not the tuple
        return tuple.get(0);
    }
  
    /** (0 for FIPa-SL0, 1 for SL1, 2 for SL2, >2 for full SL) **/
    int slType=3;
  
    public static void main(String[] args) {
  
      ExtendedSLParser theParser = null;
      try {
        theParser = new ExtendedSLParser(System.in);
        theParser.setSLType(Integer.parseInt(args[0]));
      } catch (Exception e) {
        System.out.println("usage: ExtendedSLParser SLLevel\u005cn  where SLLevel can be 0 for SL0, 1 for SL1, 2 for SL2, 3 or more for full SL");
        System.exit(0);
      }
      if (theParser.slType < 3)
         System.out.println("SL-"+theParser.slType+" Parser Started ...");
      else
         System.out.println("Full-SL"+" Parser Started ...");
  
      SLCodec codec = new SLCodec();
      //Ontology o = new DefaultOntology();
  
      while (true) {
          System.out.println("insert an SL expression to parse: ");
        try {
          AbsContentElementList result = theParser.Content();
    String resultEncoded = codec.encode(result);
          System.out.println("\u005cn\u005cn RESULT of ExtendedSLParser.Content()=\u005cn"+resultEncoded);
    AbsContentElement result2 = codec.decode(resultEncoded);
          System.out.println("\u005cn\u005cn RESULT of SLCodec.decode(SLCodec.encode(ExtendedSLParser.Content()))=\u005cn"+codec.encode(result2));
          System.out.println("\u005cn\u005cn");
          //result.dump();
          //System.out.println("AFTER ENCODING: "+codec.encode(result,o));
        }
        catch(Exception pe) {
          pe.printStackTrace();
          System.exit(0);
        }
      }
    }
  
  /*   P R O D U C T I O N    R U L E S  */
  
  /**
  * This production rule represents the more general expression that can
  * serve as content for an ACL message. Since different communicative
  * acts have different content (action expressions for
  * <code>request</code>, predicate for <code>inform</code>, etc.), any
  * allowed SL content expression can be parsed from here.
  */
    final public AbsContentElementList Content() throws ParseException {
    AbsContentElementList tuple = new AbsContentElementList();
    AbsContentElement     val;
      LBrace();
      label_1:
      while (true) {
        val = ContentExpression();
                                      tuple.add(val);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case LBRACE:
        case WORD:
        case STRING_LITERAL:
        case METASYMBOL:
        case LBRACE2:
        case WORD2:
        case STRING_LITERAL2:
        case METASYMBOL2:
          ;
          break;
        default:
          jj_la1[0] = jj_gen;
          break label_1;
        }
      }
      RBrace();
    {if (true) return tuple;}
      throw new Error("Missing return statement in function");
    }
  
  /** Left Brace in all of the possible states of the Token Manager **/
    final public void LBrace() throws ParseException {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LBRACE:
        jj_consume_token(LBRACE);
        break;
      case LBRACE2:
        jj_consume_token(LBRACE2);
        break;
      default:
        jj_la1[1] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
  
                           // lbrace2 in the OperatorState of the Token Manager
  
  /** Right Brace in all of the possible states of the Token Manager **/
    final public void RBrace() throws ParseException {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case RBRACE:
        jj_consume_token(RBRACE);
        break;
      case RBRACE2:
        jj_consume_token(RBRACE2);
        break;
      default:
        jj_la1[2] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
  
                           // rbrace2 in the OperatorState of the Token Manager
    final public AbsContentElement ContentExpression() throws ParseException {
    AbsContentElement val=null; String s;
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case WORD:
      case STRING_LITERAL:
      case WORD2:
      case STRING_LITERAL2:
        s = String();
                        val=new AbsPredicate(s);
        break;
      case LBRACE:
      case LBRACE2:
        LBrace();
        val = ContentExpression_NoBrace();
        RBrace();
        break;
      case METASYMBOL:
      case METASYMBOL2:
        s = MetaSymbol();
                        AbsPredicate val1=new AbsPredicate(s); val1.setIsMetaFormula(true); val=val1;
        break;
      default:
        jj_la1[3] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    val.setIsAContentExpression(true); {if (true) return val;}
      throw new Error("Missing return statement in function");
    }
  
    final public AbsContentElement ContentExpression_NoBrace() throws ParseException {
    AbsContentElement val=null;
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case REFERENTIALOP:
        val = IdentifyingExpression_NoBrace();
        break;
      case ACTION:
      case ACTIONOPLL:
        val = ActionExpression_NoBrace();
        break;
      case WORD:
      case STRING_LITERAL:
      case MODALOP:
      case ACTIONOP:
      case UNARYLOGICALOP:
      case BINARYLOGICALOP:
      case QUANTIFIER:
      case WORD2:
      case STRING_LITERAL2:
        val = Wff_NoBrace();
        break;
      default:
        jj_la1[4] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    {if (true) return val;}
      throw new Error("Missing return statement in function");
    }
  
    final public AbsIRE IdentifyingExpression_NoBrace() throws ParseException {
    Token t; AbsIRE ire=null; AbsPredicate prop; AbsTerm term; AbsVariable var;
      t = jj_consume_token(REFERENTIALOP);
                      if (slType<2) {if (true) throw new ParseException("NotFullSL_IdentifyExpression_NotParsable_UseAtLeastSL2");}
      term = Term();
      /*var=Variable()*/ prop = Wff();
     ire = new AbsIRE(t.image);
     /*ire.setVariable(var);*/
     ire.setTerm(term);
     ire.setProposition(prop);
     {if (true) return ire;}
      throw new Error("Missing return statement in function");
    }
  
    final public AbsVariable Variable() throws ParseException {
  