gt:         Rule oldRule = findRule("<prc>");
context: /*
  Grammatical Evolution in Java
  Release: GEVA-v2.0.zip
  Copyright (C) 2008 Michael O'Neill, Erik Hemberg, Anthony Brabazon, Conor Gilligan 
  Contributors Patrick Middleburgh, Eliott Bartley, Jonathan Hugosson, Jeff Wrigh
  
  Separate licences for asm, bsf, antlr, groovy, jscheme, commons-logging, jsci is included in the lib folder. 
  Separate licence for rieps is included in src/com folder.
  
  This licence refers to GEVA-v2.0.
  
  This software is distributed under the terms of the GNU General Public License.
  
  
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  />.
  */
  
  package Mapper;
  
  import Exceptions.BadParameterException;
  import Individuals.GEChromosome;
  import Individuals.Phenotype;
  import Util.Random.MersenneTwisterFast;
  import Util.Enums;
  import Parameter.ParameterI;
  
  import java.io.File;
  import java.util.Properties;
  
  import Util.Constants;
  import java.util.Stack;
  
  /**
   * Class for GEGrammar.
   * GEGrammar uses a GEChromosome to map out a Phenotype
   * @version 2006.1013
   * @author EHemberg
   */
  public class GEGrammar extends ContextFreeGrammar implements ParameterI {
  
      private int PRCSetSize;
      private int PRCRange;
      private int PRCPrecision;
      GEChromosome genotype;
      Phenotype phenotype;
      int maxWraps;
      int usedWraps;
      int usedCodons;
      String name;
      DerivationTree dT;
      int maxDerivationTreeDepth;
      int maxCurrentTreeDepth;
      int dTNodeCount;
      private String derivationTreeType;
  
      /** Creates a new instance of GEGrammar */
      public GEGrammar() {
          super();
          this.maxWraps = 1;
      }
  
      /**
       * New instance
       * @param file file to read grammar from
       */
      public GEGrammar(String file) {
          super();
          this.readBNFFile(file);
          this.maxWraps = 1;
      }
  
      /**
       * New instance
       * @param p properties
       */
      public GEGrammar(Properties p) {
          super();
          this.setProperties(p);
      }
  
      /**
       * Copy constructor. Does not copy the genotype and phenotype
       * @param copy grammar to copy
       */
      public GEGrammar(GEGrammar copy) {
          super(copy);
          this.derivationTreeType = copy.getDerivationString();
          this.setMaxWraps(copy.getMaxWraps());
          this.maxWraps = copy.maxWraps;
          // A copy of the derivation tree should be here
  
  
          this.maxDerivationTreeDepth = copy.getMaxDerivationTreeDepth();
          this.maxCurrentTreeDepth = copy.getMaxCurrentTreeDepth();
          if (dT != null) {
              this.dT = new DerivationTree(copy.dT);
          }
          this.dTNodeCount = copy.getDTNodeCount();
          this.name = copy.name;
          this.maxDerivationTreeDepth = copy.getMaxDerivationTreeDepth();
          this.maxCurrentTreeDepth = copy.getMaxCurrentTreeDepth();
      }
  
      /**
       * Set properties
       *
       * @param p object containing properties
       */
      public void setProperties(Properties p) {
          String file = null;
          String key;
          try {
              key = Constants.GRAMMAR_FILE;
              file = p.getProperty(key);
              if (file == null) {
                  throw new BadParameterException(key);
              }
          } catch (BadParameterException e) {
              System.out.println(e + " No default grammar");
          }
          File f = new File(file);
          if (!f.exists()) { // try classloader
              this.readBNFFile(file);
          } else {
              this.readBNFFileFromFilesystem(file);
          }
          int value;
          try {
              key = Constants.MAX_WRAPS;
              value = Integer.parseInt(p.getProperty(key));
              if (value < 0) {
                  throw new BadParameterException(key);
              }
          } catch (BadParameterException e) {
              value = 0;
              System.out.println(e + " default wraps:" + value);
          }
          this.maxWraps = value + 1;
  
  
          try {
              this.PRCSetSize = Integer.parseInt(p.getProperty(Constants.PRC_SETSIZE, Constants.DEFAULT_PRC_SETSIZE));
              this.PRCRange = Integer.parseInt(p.getProperty(Constants.PRC_RANGE, Constants.DEFAULT_PRC_RANGE));
              this.PRCPrecision = Integer.parseInt(p.getProperty(Constants.PRC_PRECISION, Constants.DEFAULT_PRC_PRECISION));
  
              if (PRCSetSize < 0) {
                  throw new BadParameterException(Constants.PRC_SETSIZE);
              }
              if (PRCRange < 0) {
                  throw new BadParameterException(Constants.PRC_RANGE);
              }
              if ((PRCPrecision < 0) || (PRCPrecision > 32)) {
                  throw new BadParameterException(Constants.PRC_PRECISION);
              }
          } catch (BadParameterException e) {
              value = 0;
              System.out.println(e + " constant range:" + value);
          }
          if (PRCSetSize > 0) {
              generatePRC();
          }
  
          this.maxWraps = value + 1;
          this.maxDerivationTreeDepth = Integer.parseInt(p.getProperty(Constants.MAX_DERIVATION_TREE_DEPTH, Constants.DEFAULT_MAX_DERIVATION_TREE_DEPTH));
          this.derivationTreeType = p.getProperty(Constants.DERIVATION_TREE);
          if(this.maxWraps>1 && this.derivationTreeType.equals("Mapper.ContextualDerivationTree"))
          {
              throw new IllegalArgumentException("Wrapping must be turned off for Context Sensitive trees");
          }
      }
  
      /**
       * Map input to output
       * @return validity of mapping
       */
      public boolean genotype2Phenotype() {
          return genotype2Phenotype(false);
      }
  
      /**
       * Map output to input
       * @return boolean Is the mapping valid
       */
      public boolean phenotype2Genotype() {
          return true;
      }
  
      /**
       * Replaces constants in the grammar with an array of randomly generated constants
       */
      public void generatePRC() {
  