
//----------------------------------------------------
// The following code was generated by CUP v0.10k
// Tue Feb 11 17:07:17 PST 2014
//----------------------------------------------------

package GenRGenS.markov;

import java_cup.runtime.*;
import java.util.*;
import GenRGenS.utility.*;
import GenRGenS.*;

/** CUP v0.10k generated parser.
  * @version Tue Feb 11 17:07:17 PST 2014
  */
public class ParseMarkov extends java_cup.runtime.lr_parser {

  /** Default constructor. */
  public ParseMarkov() {super();}

  /** Constructor which sets the default scanner. */
  public ParseMarkov(java_cup.runtime.Scanner s) {super(s);}

  /** Production table. */
  protected static final short _production_table[][] = 
    unpackFromStrings(new String[] {
    "\000\053\000\002\002\004\000\002\003\011\000\002\004" +
    "\005\000\002\005\005\000\002\005\002\000\002\006\005" +
    "\000\002\006\002\000\002\007\005\000\002\007\005\000" +
    "\002\007\002\000\002\010\005\000\002\010\002\000\002" +
    "\011\005\000\002\011\005\000\002\011\004\000\002\011" +
    "\004\000\002\016\004\000\002\016\003\000\002\017\004" +
    "\000\002\017\004\000\002\017\003\000\002\017\003\000" +
    "\002\012\005\000\002\012\007\000\002\012\005\000\002" +
    "\021\005\000\002\021\004\000\002\022\005\000\002\022" +
    "\004\000\002\020\007\000\002\020\005\000\002\020\006" +
    "\000\002\013\005\000\002\013\004\000\002\013\002\000" +
    "\002\014\006\000\002\014\006\000\002\014\005\000\002" +
    "\014\005\000\002\014\006\000\002\014\006\000\002\014" +
    "\005\000\002\014\005" });

  /** Access to production table. */
  public short[][] production_table() {return _production_table;}

  /** Parse-action table. */
  protected static final short[][] _action_table = 
    unpackFromStrings(new String[] {
    "\000\106\000\004\004\006\001\002\000\004\002\110\001" +
    "\002\000\016\010\ufffd\020\ufffd\021\ufffd\022\ufffd\023\011" +
    "\024\ufffd\001\002\000\004\013\007\001\002\000\004\006" +
    "\010\001\002\000\016\010\uffff\020\uffff\021\uffff\022\uffff" +
    "\023\uffff\024\uffff\001\002\000\004\013\106\001\002\000" +
    "\014\010\ufffb\020\ufffb\021\ufffb\022\ufffb\024\013\001\002" +
    "\000\004\013\104\001\002\000\012\010\016\020\ufff8\021" +
    "\ufff8\022\ufff8\001\002\000\010\020\023\021\ufff6\022\ufff6" +
    "\001\002\000\004\013\017\001\002\000\006\011\021\012" +
    "\020\001\002\000\010\020\ufff9\021\ufff9\022\ufff9\001\002" +
    "\000\010\020\ufffa\021\ufffa\022\ufffa\001\002\000\006\021" +
    "\037\022\036\001\002\000\004\013\024\001\002\000\004" +
    "\032\026\001\002\000\006\021\ufff7\022\ufff7\001\002\000" +
    "\010\030\ufff0\031\ufff0\032\026\001\002\000\006\030\031" +
    "\031\030\001\002\000\010\021\ufff3\022\ufff3\032\026\001" +
    "\002\000\010\021\ufff2\022\ufff2\032\026\001\002\000\006" +
    "\021\ufff4\022\ufff4\001\002\000\006\021\ufff5\022\ufff5\001" +
    "\002\000\006\030\ufff1\031\ufff1\001\002\000\006\002\uffdf" +
    "\017\066\001\002\000\004\013\051\001\002\000\004\013" +
    "\040\001\002\000\004\032\026\001\002\000\006\002\uffeb" +
    "\017\uffeb\001\002\000\006\030\045\031\043\001\002\000" +
    "\016\002\uffed\014\uffed\017\uffed\030\045\031\043\032\uffed" +
    "\001\002\000\012\002\uffe7\014\uffe7\017\uffe7\032\026\001" +
    "\002\000\016\002\uffec\014\uffec\017\uffec\030\045\031\043" +
    "\032\uffec\001\002\000\012\002\uffee\014\uffee\017\uffee\032" +
    "\uffee\001\002\000\010\002\uffe8\014\uffe8\017\uffe8\001\002" +
    "\000\012\002\uffef\014\uffef\017\uffef\032\uffef\001\002\000" +
    "\004\032\026\001\002\000\010\002\uffe9\014\053\017\uffe9" +
    "\001\002\000\004\032\055\001\002\000\006\002\uffea\017" +
    "\uffea\001\002\000\004\015\056\001\002\000\004\032\026" +
    "\001\002\000\010\002\uffe3\014\063\017\uffe3\001\002\000" +
    "\006\030\045\031\043\001\002\000\012\002\uffe5\014\uffe5" +
    "\017\uffe5\032\026\001\002\000\010\002\uffe6\014\uffe6\017" +
    "\uffe6\001\002\000\010\002\uffe2\017\uffe2\032\055\001\002" +
    "\000\006\002\uffe4\017\uffe4\001\002\000\004\002\000\001" +
    "\002\000\004\013\067\001\002\000\006\002\uffe0\032\071" +
    "\001\002\000\004\002\uffe1\001\002\000\006\013\072\016" +
    "\073\001\002\000\006\032\101\033\100\001\002\000\006" +
    "\032\075\033\074\001\002\000\006\002\uffd7\032\071\001" +
    "\002\000\006\002\uffd8\032\071\001\002\000\004\002\uffda" +
    "\001\002\000\004\002\uffd9\001\002\000\006\002\uffdb\032" +
    "\071\001\002\000\006\002\uffdc\032\071\001\002\000\004" +
    "\002\uffde\001\002\000\004\002\uffdd\001\002\000\004\030" +
    "\105\001\002\000\012\010\ufffc\020\ufffc\021\ufffc\022\ufffc" +
    "\001\002\000\004\030\107\001\002\000\014\010\ufffe\020" +
    "\ufffe\021\ufffe\022\ufffe\024\ufffe\001\002\000\004\002\001" +
    "\001\002" });

  /** Access to parse-action table. */
  public short[][] action_table() {return _action_table;}

  /** <code>reduce_goto</code> table. */
  protected static final short[][] _reduce_table = 
    unpackFromStrings(new String[] {
    "\000\106\000\006\003\003\004\004\001\001\000\002\001" +
    "\001\000\004\005\011\001\001\000\002\001\001\000\002" +
    "\001\001\000\002\001\001\000\002\001\001\000\004\006" +
    "\013\001\001\000\002\001\001\000\004\007\014\001\001" +
    "\000\004\010\021\001\001\000\002\001\001\000\002\001" +
    "\001\000\002\001\001\000\002\001\001\000\004\012\034" +
    "\001\001\000\002\001\001\000\006\011\024\016\026\001" +
    "\001\000\002\001\001\000\004\016\033\001\001\000\002" +
    "\001\001\000\006\011\032\016\026\001\001\000\006\011" +
    "\031\016\026\001\001\000\002\001\001\000\002\001\001" +
    "\000\002\001\001\000\004\013\064\001\001\000\002\001" +
    "\001\000\002\001\001\000\006\016\041\021\040\001\001" +
    "\000\002\001\001\000\004\017\043\001\001\000\004\017" +
    "\047\001\001\000\006\016\041\021\046\001\001\000\004" +
    "\017\045\001\001\000\002\001\001\000\002\001\001\000" +
    "\002\001\001\000\006\016\041\021\051\001\001\000\002" +
    "\001\001\000\004\020\053\001\001\000\002\001\001\000" +
    "\002\001\001\000\006\016\057\022\056\001\001\000\002" +
    "\001\001\000\004\017\060\001\001\000\006\016\057\022" +
    "\061\001\001\000\002\001\001\000\004\020\063\001\001" +
    "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
    "\004\014\067\001\001\000\002\001\001\000\002\001\001" +
    "\000\002\001\001\000\002\001\001\000\004\014\076\001" +
    "\001\000\004\014\075\001\001\000\002\001\001\000\002" +
    "\001\001\000\004\014\102\001\001\000\004\014\101\001" +
    "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
    "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
    "\002\001\001" });

  /** Access to <code>reduce_goto</code> table. */
  public short[][] reduce_table() {return _reduce_table;}

  /** Instance of action encapsulation class. */
  protected CUP$ParseMarkov$actions action_obj;

  /** Action encapsulation object initializer. */
  protected void init_actions()
    {
      action_obj = new CUP$ParseMarkov$actions(this);
    }

  /** Invoke a user supplied parse action. */
  public java_cup.runtime.Symbol do_action(
    int                        act_num,
    java_cup.runtime.lr_parser parser,
    java.util.Stack            stack,
    int                        top)
    throws java.lang.Exception
  {
    /* call code in generated class */
    return action_obj.CUP$ParseMarkov$do_action(act_num, parser, stack, top);
  }

  /** Indicates start state. */
  public int start_state() {return 0;}
  /** Indicates start production. */
  public int start_production() {return 0;}

  /** <code>EOF</code> Symbol index. */
  public int EOF_sym() {return 0;}

  /** <code>error</code> Symbol index. */
  public int error_sym() {return 1;}




  private boolean _parseError = false;

  public boolean isParseError()
  { return _parseError; }

  public int getOrder()
  {
    return action_obj.getOrder();
  }

  public int getPhase()
  {
    return action_obj.getPhase();
  }

  public boolean isWord()
  {
    return action_obj.isWord();
  }

  public String[] getSymbols()
  {
    return action_obj.getSymbols();
  }

  public double[][][] getFrequencies()
  {
    return action_obj.getFrequencies();
  }

  public int[][] getStartSequences()
  {
    return action_obj.getStartSequences();
  }

  public double[] getCumulatedStartFrequencies()
  {
    return action_obj.getCumulatedStartFrequencies();
  }

  public int getNbDeadEnds()
  {
    return action_obj.getNbDeadEnds();
  }
  

  public void report_error(String message, Object info)
  {
    _parseError = true;
    if (info instanceof Symbol)
    {
      Symbol cur_token = (Symbol) info;
      int[] coord_left = ((GenRGenSScanner) getScanner()).getRelativePos(cur_token.left);
      int[] coord_right = ((GenRGenSScanner) getScanner()).getRelativePos(cur_token.right);
      if (coord_left[0] == coord_right[0])
      {
        GenRGenS.err.println("Syntax Error at line "+coord_right[0]+" chars "+ coord_left[1] +"-" + coord_right[1]);
      }
      else
      {
        GenRGenS.err.println("Syntax Error from line "+coord_left[0]+" char "+ coord_left[1] + " to line "+coord_right[0]+" char " + coord_right[1]);
      }
    }
    else
    {
      if (info instanceof String)
      {

        int[] coord_left = ((GenRGenSScanner) getScanner()).getRelativePos(cur_token.left);
        int[] coord_right = ((GenRGenSScanner) getScanner()).getRelativePos(cur_token.right);
        if (coord_left[0] == coord_right[0])
        {
          GenRGenS.err.println("At line "+coord_right[0]+" chars "+ coord_left[1] +"-" + coord_right[1] +" : " + message);
        }
        else
        {
          GenRGenS.err.println("From line "+coord_left[0]+" char "+ coord_left[1] + " to line "+coord_right[0]+" char " + coord_right[1] +" : " + message);
        }
      }
      else
      {
         GenRGenS.err.println(message);
      }
    }
  }
  public void report_fatal_error(String message, Object info) throws java.lang.Exception
  {
    _parseError = true;
    report_error(message,info);
    if (info instanceof Symbol)
    {
      Symbol cur_token = (Symbol) info;
      int[] coord_left = ((GenRGenSScanner) getScanner()).getRelativePos(cur_token.left);
      int[] coord_right = ((GenRGenSScanner) getScanner()).getRelativePos(cur_token.right);
      if (coord_left[0] == coord_right[0])
      {
        GenRGenS.err.println("Couldn't repair and continue parse at line "+coord_right[0]+".");
      }
      else
      {
        GenRGenS.err.println("Couldn't repair and continue parse at line "+coord_right[0]+".");
      }
    }
    else
    {
      Symbol current_token = cur_token;
      int[] coord_right = ((GenRGenSScanner) getScanner()).getRelativePos(current_token.right);
        GenRGenS.err.println("Couldn't repair and continue parse at line "+ coord_right[0]+".");
    }
    throw new Exception("Can't recover from previous error(s)");
  }


}

/** Cup generated class to encapsulate user supplied action code.*/
class CUP$ParseMarkov$actions {


  private int _order = -1;
  private int _phase = 1;
  private boolean _isWord = true;
  private int _nbDeadEnds = 0;
  private String[] symboles = new String[0];


  // Represents a list of  frequencies
  private double[][][] _frequencies = new double[0][0][0];

  // Represents a list of start sequences (each sequence is encoded by a list of numbers)
  private int[][] _startSequences = new int[0][0];
  // Represents a list of start sequences (each sequence is encoded by a list of numbers)
  private double[] _cumulatedStartFrequencies = new double[0];

  private Hashtable<String,Integer> _lexique = new Hashtable<String,Integer>(31);
  private int _nextTokenID = 0;

  // Start Sequences :
  private int _startSequencesSize = -1;
  private Vector<Vector<Integer> > _tmpStartSequences = new Vector<Vector<Integer> >();
  private Vector<Double> _tmpCumulatedStartFrequencies = new Vector<Double>();
  private double _partialStartFrequencySum = 0;


  public int getOrder()
  {
    return _order;
  }

  public int getPhase()
  {
    return _phase;
  }

  public boolean isWord()
  {
    return _isWord;
  }

  public String[] getSymbols()
  {
    return symboles;
  }

  public double[][][] getFrequencies()
  {
    return _frequencies;
  }

  public int[][] getStartSequences()
  {
    return _startSequences;
  }

  public double[] getCumulatedStartFrequencies()
  {
    return _cumulatedStartFrequencies;
  }

  private void addStartFrequency(Stack<String> pile, Double frequency)
  {
    if (_isWord)
    {
      String s;
      Vector<Integer> sequence = new Vector<Integer>();

      // Verification de même taille pour toutes les séquences Start
      if (_startSequencesSize == -1)
      {
        _startSequencesSize = pile.size();
      }
      else
      {
        if (_startSequencesSize != pile.size())
        {
          parser.done_parsing();
          parser.report_error("All start sequences should have the same size ...","");
        }
      }

      if(pile.size() < _order)
      {
          parser.done_parsing();
          parser.report_error("Size of a start sequence should be greater than Markov's order.","");
      }

      while(!pile.empty())
      {
        s = pile.pop();
        Integer i = _lexique.get(s);

        // Si le "mot" n'appartient pas au lexique, on l'y ajoute ...
        if(i == null)
        {
          _lexique.put(s,new Integer(_nextTokenID));
          // Ajout du "token" representant le mot au vecteur
          sequence.add(new Integer(_nextTokenID));

          _nextTokenID++;
        }
        else
        {
          // Ajout du "token" representant le mot au vecteur
          sequence.add(i);
        }
      }
      // Ajout de la sequence au tableau de stockage temporaire
      _tmpStartSequences.add(sequence);
      // Incrémentation de la somme partielle des frequences Start rencontrées ...
      _partialStartFrequencySum += frequency.doubleValue();
      _tmpCumulatedStartFrequencies.add(new Double(_partialStartFrequencySum));
    }
    else
    {
      if (pile.size() > 1)
      {
        parser.done_parsing();
        parser.report_error("Only one Word is allowed in LETTERS mode !!!",null);
      }

      String aWord = pile.pop();
      String s;
      Vector<Integer> sequence = new Vector<Integer>();

      // Verification de même taille pour toutes les séquences Start
      if (_startSequencesSize == -1)
      {
        _startSequencesSize = aWord.length();
      }
      else
      {
        if (_startSequencesSize != aWord.length())
        {
          parser.done_parsing();
          parser.report_error("All start sequences should have the same size ...",null);
        }
      }

      if(aWord.length() < _order)
      {
        parser.done_parsing();
        parser.report_error("Size of a start sequence should be greater or equal than Markov's order.",null);
      }

      for(int j = 0;j< aWord.length(); j++)
      {
        s = "" + aWord.charAt(j);
        Integer i = _lexique.get(s);

        // Si le "mot" n'appartient pas au lexique, on l'y ajoute ...
        if(i == null)
        {
          _lexique.put(s,new Integer(_nextTokenID));
          // Ajout du "token" representant le mot au vecteur
          sequence.add(new Integer(_nextTokenID));

          _nextTokenID++;
        }
        else
        {
          // Ajout du "token" representant le mot au vecteur
          sequence.add(i);
        }
      }
      // Ajout de la sequence au tableau de stockage temporaire
      _tmpStartSequences.add(sequence);
      // Incrémentation de la somme partielle des frequences Start rencontrées ...
      _partialStartFrequencySum += frequency.doubleValue();
      _tmpCumulatedStartFrequencies.add(new Double(_partialStartFrequencySum));
    }
  }

  private void gatherStartFrequencies()
  {
    if (GenRGenS.verbose)
    { GenRGenS.err.println("Gathering Start Frequencies ..."); }

    if (_tmpCumulatedStartFrequencies.size() != _tmpStartSequences.size())
    {
      parser.done_parsing();
      parser.report_error("Internal Error 01 : please report this bug to the developping team ...","");
    }
    _startSequences = new int[_tmpStartSequences.size()][_startSequencesSize];
    _cumulatedStartFrequencies = new double[_tmpCumulatedStartFrequencies.size()];

    for(int i = 0; i<_tmpStartSequences.size(); i++)
    {
      Vector<Integer> v = _tmpStartSequences.elementAt(i);
      if (v.size() != _startSequencesSize)
      {
        parser.done_parsing();
        parser.report_error("Internal Error 02 : please report this bug to the developping team ...","");
      }

      for(int j = 0; j<_startSequencesSize; j++)
      {
        Integer token = v.elementAt(j);
        _startSequences[i][j] = token.intValue();
      }

      Double frequency = _tmpCumulatedStartFrequencies.elementAt(i);
      _cumulatedStartFrequencies[i] = frequency.doubleValue();
    }
  }

  private void addFrequency(Stack<String> pile, Stack<Double> pileFreq, Couple accu, boolean checkSize)
  {
    Vector<Vector<Integer>> _tmpSequences = (Vector) accu.fst();
    Vector<Vector<Double>> _tmpFrequencies = (Vector) accu.snd();
    if (_isWord)
    {
      String s;
      Vector<Integer> sequence = new Vector<Integer>();
      // Verification de taille
      if ((pile.size() != _order + 1)&&(checkSize))
      {
        String seq = "[ ";
        while(pile.size()>0)
        {
          seq = seq + (String) pile.pop()+" ";
        }
        seq = seq + "]";
        parser.done_parsing();
        parser.report_error("Wrong size for sequence "+seq+" !\nThe size of a sequence should be equal to Markov's order + 1.",null);
      }

      while(!pile.empty())
      {
        s = pile.pop();
        Integer i = _lexique.get(s);

        // Si le "mot" n'appartient pas au lexique, on l'y ajoute ...
        if(i == null)
        {
          _lexique.put(s,new Integer(_nextTokenID));
          // Ajout du "token" representant le mot au vecteur
          sequence.add(new Integer(_nextTokenID));

          _nextTokenID++;
        }
        else
        {
          // Ajout du "token" representant le mot au vecteur
          sequence.add(i);
        }
      }
      // Ajout de la sequence au tableau de stockage temporaire
      _tmpSequences.add(sequence);

    }
    else
    {
      String s;
      Vector<Integer> sequence = new Vector<Integer>();
      if (pile.size() > 1)
      {
        String seq = "[ ";
        while(pile.size()>0)
        {
          seq = seq + (String) pile.pop()+" ";
        }
        seq = seq + "]";
        parser.done_parsing();
        parser.report_error("Bad sequence "+seq+"\nOnly one word is allowed in LETTERS mode !!!",null);
      }
      String aWord = pile.pop();


      if((aWord.length() != _order+1)&&(checkSize))
      {
        parser.done_parsing();
        parser.report_error("Wrong size for sequence "+aWord+"\nThe size of a sequence should be equal to Markov's order + 1.",null);
      }

      for(int j = 0;j< aWord.length(); j++)
      {
        s = "" + aWord.charAt(j);
        Integer i = (Integer) _lexique.get(s);

        // Si le "mot" n'appartient pas au lexique, on l'y ajoute ...
        if(i == null)
        {
          _lexique.put(s,new Integer(_nextTokenID));
          // Ajout du "token" representant le mot au vecteur
          sequence.add(new Integer(_nextTokenID));

          _nextTokenID++;
        }
        else
        {
          // Ajout du "token" representant le mot au vecteur
          sequence.add(i);
        }
      }
      // Ajout de la sequence au tableau de stockage temporaire
      _tmpSequences.add(sequence);
    }

    Vector<Double> frequencies = new Vector();

    if ((pileFreq.size() != _phase)&&(checkSize))
    {
      parser.done_parsing();
      parser.report_error("Expecting "+_phase+" frequency(ies), but getting "+pileFreq.size()+" frequency(ies)","");
    }

    if ((pileFreq.size() != _phase)&&(!checkSize))
    {
      parser.done_parsing();
      parser.report_error("Different number of phases are not supported for hidden states . Please provide exactly "+_phase+" frequencies.","");
    }

    while(!pileFreq.empty())
    {
      Double freq = pileFreq.pop();
      frequencies.add(freq);
    }
    _tmpFrequencies.add(frequencies);
  }



  private double convertFrequency(int nbMain,int nbState,Vector tmpSeq, int indexMain, int indexState, Vector<Integer> srcSeq , Vector<Double> srcFreqs, Vector destSeq, Vector destFreqs, 
      double[][][] mainFrequencies, int mainVoc, int stateVoc, int lastChar)
  {
    if(nbMain>nbState)
    {
      double tmp = 0;
      for(int i=0;i<mainVoc;i++)
      {
        for(int j=0;j<stateVoc;j++)
        {
          tmpSeq.add(new Integer(i*stateVoc+j));
          tmp += convertFrequency(nbMain-1,nbState,tmpSeq,indexMain*mainVoc+i,0,srcSeq,srcFreqs,destSeq,destFreqs,mainFrequencies,mainVoc,stateVoc,lastChar);
          tmpSeq.removeElementAt(tmpSeq.size()-1);
        }
      }
      return tmp;
    }
    else
    {
      if(nbMain<nbState)
      {
        double tmp = 0;
        int symb = ((Integer)srcSeq.elementAt(srcSeq.size()-nbState)).intValue()-mainVoc;
        for(int i=0;i<mainVoc;i++)
        {
          tmpSeq.add(new Integer(i*stateVoc+symb));
          tmp += convertFrequency(nbMain,nbState-1,tmpSeq,0,indexState*stateVoc+symb,srcSeq,srcFreqs,destSeq,destFreqs,mainFrequencies,mainVoc,stateVoc,lastChar);
          tmpSeq.removeElementAt(tmpSeq.size()-1);
        }
        return tmp;
      }
      else
      {
        if(nbMain<=1)
        {
          int symb = ((Integer)srcSeq.elementAt(srcSeq.size()-1)).intValue()-mainVoc;
          Vector backup =(Vector) tmpSeq.clone();
          backup.add(new Integer(lastChar*stateVoc+symb));
          destSeq.add(backup);
          Vector<Double> freqs = new Vector<Double>();
          for(int i=0;i<srcFreqs.size();i++)
          { 
            double f = (srcFreqs.elementAt(i)).doubleValue();
            freqs.add(new Double(f*mainFrequencies[indexMain][lastChar][i]));
          }
          destFreqs.add(freqs);
          return 1.;
        }
        else
        {
          double tmp = 0;
          int symb = ((Integer)srcSeq.elementAt(srcSeq.size()-nbState)).intValue()-mainVoc;
          for(int i=0;i<mainVoc;i++)
          {
            tmpSeq.add(new Integer(i*stateVoc+symb));
            tmp += convertFrequency(nbMain-1,nbState-1,tmpSeq,indexMain*mainVoc+i,indexState*stateVoc+symb,srcSeq,srcFreqs,destSeq,destFreqs,mainFrequencies,mainVoc,stateVoc,lastChar);
            tmpSeq.removeElementAt(tmpSeq.size()-1);
          }
          return tmp;
        }
      }
    }
  }


  private Couple convertToMarkov(Couple mainMarkovian, Stack hiddenStates)
  {
   GenRGenS.progress.setWorkName("Converting to a classical markov model...");
    String[] mySymboles = new String[_nextTokenID];
    Enumeration<String> enume = _lexique.keys();
    while(enume.hasMoreElements())
    {
      String s = enume.nextElement();
      Integer i = _lexique.get(s);
      mySymboles[i.intValue()] = s;
    }

    // On extrait le vocabulaire du modéle dominant
    Vector<Vector<Integer>> mainMarkovianSeqs = (Vector<Vector<Integer>>) mainMarkovian.fst();
    Vector<Vector<Double>> mainMarkovianFreqs = (Vector<Vector<Double>>) mainMarkovian.snd();
    boolean[] mainVoc = new boolean[_nextTokenID];
    int mainLexicalSize = 0;
    for(int i=0; i<mainVoc.length; i++)
    { mainVoc[i] = false; }
    for(int i=0; i<mainMarkovianSeqs.size(); i++)
    {
      Vector<Integer> seq =  mainMarkovianSeqs.elementAt(i);
      for(int j=0;j<seq.size();j++)
      {
        mainVoc[seq.elementAt(j).intValue()] = true;
      }
    }
    
    // On construit le tableau de fréquences du modèle dominant
    for(int i=0; i<mainVoc.length; i++)
    { if(mainVoc[i]) mainLexicalSize++;}
    int nbMainSeq = pow(mainLexicalSize,_order);
    double[][][] mainFrequencies = new double[nbMainSeq][mainLexicalSize][_phase];
    for(int i=0; i<mainMarkovianSeqs.size(); i++)
    {
      Vector<Integer> seq = mainMarkovianSeqs.elementAt(i);
      int index = indexOfSequence(seq,mainLexicalSize) ;
      int last = seq.elementAt(seq.size()-1).intValue();
      Vector<Double> freqs = mainMarkovianFreqs.elementAt(i);
      for(int j=0;j<freqs.size();j++)
      {
        Double f = (Double) freqs.elementAt(j);
        mainFrequencies[index][last][j] = f.doubleValue();
      }
    }
    
    // Construire un nouveau vocabulaire
    Hashtable newLexique = new Hashtable();
    String[] myNewSymboles = new String[mainLexicalSize*(_nextTokenID-mainLexicalSize)];
    for(int l=0;l<mainLexicalSize;l++)
    {
      for(int j=mainLexicalSize;j<_nextTokenID;j++)
      {
         newLexique.put(mySymboles[l]+"_"+mySymboles[j],new Integer(l*(_nextTokenID-mainLexicalSize)+(j-mainLexicalSize)));
         myNewSymboles[l*(_nextTokenID-mainLexicalSize)+(j-mainLexicalSize)] = mySymboles[j];
       }
    }

    // Conversion effective des fréquences vers un modele markovien
    int stateOrder = -1;
    Vector newSeqs = new Vector();
    Vector newFreqs = new Vector();
    long amount = 0;
    long progress = 0;
    while(!hiddenStates.isEmpty())
    {
      Couple hiddenStateDecl = (Couple) hiddenStates.pop();
      Integer state = _lexique.get(hiddenStateDecl.fst());
      Couple hiddenFreqsDecl = (Couple)hiddenStateDecl.snd();
      Vector hiddenSeqs = (Vector) hiddenFreqsDecl.fst();
      Vector hiddenFreqs = (Vector) hiddenFreqsDecl.snd();
      for(int i=0;i<hiddenSeqs.size();i++)
      {
        Vector seq = (Vector) hiddenSeqs.elementAt(i);
        if(stateOrder!=seq.size()-1)
        {
          if(stateOrder==-1)
          {
            stateOrder=seq.size()-1;
            amount = pow(mainLexicalSize*(_nextTokenID-mainLexicalSize),Math.max(_order+1,stateOrder+1));
            GenRGenS.progress.setAmount(amount);
            GenRGenS.progress.setProgress(progress);
          }
          else
          {
            parser.done_parsing();
            parser.report_error("Different orders for the hidden states are not supported!","");
          }
        }
        Vector freqs = (Vector) hiddenFreqs.elementAt(i);
        Vector tmpSeq = new Vector();
        double addedFreqs = convertFrequency(_order+1,stateOrder+1,tmpSeq,0,0,seq,freqs,newSeqs,newFreqs,mainFrequencies,mainLexicalSize,_nextTokenID-mainLexicalSize,state.intValue());
        progress += addedFreqs;
        GenRGenS.progress.setProgress(progress);
      }
    }

    GenRGenS.progress.setProgress(amount); 
    _lexique = newLexique;
    _order = Math.max(stateOrder,_order);
    _nextTokenID = newLexique.size();
    return (new Couple(myNewSymboles,new Couple(newSeqs,newFreqs)));
  }

  /**
   * Met en forme les frequences lues de façon ?ce qu'elle puissent être
   * utilisées par la classe HeterogeneousMarkov.
   * Teste au passage la présence d'"impasses"
  */

  private void gatherFrequencies(Couple c)
  {
    Vector<Vector<Integer>> _tmpSequences = (Vector) c.fst();
    Vector<Vector<Double>> _tmpFrequencies = (Vector) c.snd();
    if (GenRGenS.verbose)
    { GenRGenS.err.println("Gathering Frequencies ..."); }

    if (_tmpFrequencies.size() != _tmpSequences.size())
    {
      parser.done_parsing();
      parser.report_error("Internal Error 03 : please report this bug to the developping team ...","");
    }

    int nbContextes = pow(_lexique.size(),_order);
    _frequencies = new double[nbContextes][_phase][_lexique.size()+1];
    for(int i = 0; i<nbContextes; i++)
    {
      for(int j = 0; j<_phase; j++)
      {
        for(int k = 0; k<_lexique.size(); k++)
        {
          _frequencies[i][j][k] = 0.;
        }
      }
    }
    for(int i = 0; i<_tmpSequences.size(); i++)
    {
      Vector<Integer> seq = _tmpSequences.elementAt(i);
      Vector<Double> freqs = _tmpFrequencies.elementAt(i);
      if (freqs.size() != _phase)
      {
        parser.done_parsing();
        parser.report_error("Internal Error 04 : please report this bug to the developping team ...","");
      }

      int index = indexOfSequence(seq,_lexique.size());
      // Le numéro du dernier caractère de la sequence (celui ?générer)
      int last = ((Integer) seq.elementAt(seq.size()-1)).intValue();

      for(int j = 0; j<_phase; j++)
      {
        Double f = (Double) freqs.elementAt(j);
        if(_frequencies[index][j][last] == 0)
        {
          _frequencies[index][j][last] = f.doubleValue();
        }
        else
        {
          parser.done_parsing();
          parser.report_error("Attempting to redefine a frequency !",null);
        }
        _frequencies[index][j][_lexique.size()] += f.doubleValue();
      }
    }
    symboles = new String[_lexique.size()];
    Enumeration<String> enume = _lexique.keys();
    while(enume.hasMoreElements())
    {
      String s = enume.nextElement();
      Integer i = _lexique.get(s);
      symboles[i.intValue()] = s;
    }
    if (MarkovianGenerationConfiguration.ExactSizeMarkovianGeneration)
    {
      testDeadEnds();
    }
  }

  private void testDeadEnds()
  {
    
    if (GenRGenS.verbose)
    { GenRGenS.err.println("Looking for \"Deadends\" ..."); }
    /* On ajoute des couples (a,b) ?ReachedStates o?a est l'index de la
       sequence "contexte" et b la phase du symbole suivant.*/
    LinkedList ReachedStates = new LinkedList();
    int borne = pow(_lexique.size(),_order);
    boolean[][] reached = new boolean[borne][_phase];
    int phaseActuelle = 0;
    
    for(int i=0; i<borne; i++)
    {
      for(int j=0; j<_phase; j++)
      {
        reached[i][j] = false;
      }
    }

    if (_cumulatedStartFrequencies.length != 0)
    {
      for(int i=0; i<_startSequences.length;i++)
      {
        int[] a = _startSequences[i];
        int index = indexOfArray(a,_lexique.size());
        Couple c = new Couple(new Integer(index), new Integer((a.length)%_phase));
        ReachedStates.addFirst(c);
        reached[index][_order % _phase] = true;
      }
    }
    else
    {
      for(int i=0; i<borne; i++)
      {
        if (_frequencies[i][0][_lexique.size()]>0)
        {
          Couple c = new Couple(new Integer(i), new Integer((_order) % _phase));
          ReachedStates.addFirst(c);
          reached[i][_order % _phase] = true;
        }
      }
    }
    // Maintenant on a dans ReachedStates les "contextes" START ...
    String[] symb = getSymbols();
    while(ReachedStates.size()!=0)
    {
      Couple c = (Couple) ReachedStates.removeLast();
      int index = ((Integer)c.fst()).intValue();
      int nphase = (((Integer)c.snd()).intValue()) ;
      GenRGenS.err.println("["+sequenceOfIndex(index,_lexique.size(),_order,symb)+","+nphase+"]");
      if (_frequencies[index][nphase][_lexique.size()]>0)
      {
        for(int i=0; i<_lexique.size() ; i++)
        {
          if (_frequencies[index][nphase][i]>0)
          {
            int nindex = ((index * _lexique.size()) + i) % borne;
            if (!reached[nindex][(nphase+1)%_phase])
            {
              ReachedStates.addFirst(new Couple(new Integer(nindex), new Integer((nphase+1)%_phase)));
              reached[nindex][(nphase+1)%_phase] = true;
            }
          }
        }
      }
      else
      {
          _nbDeadEnds ++;
          GenRGenS.err.println("Warning, deadend : "+sequenceOfIndex(index, _lexique.size(),_order,symb)+" leads to nowhere on phase "+nphase+".");
      }
    }
  }

  public void setSymbols(String[] tab)
  {
    symboles = tab;
  }

  public int getNbDeadEnds()
  {
    return _nbDeadEnds;
  }

  private int indexOfArray(int[] a, int basis)
  {
    int tailleVocabulaire = basis;
    int value = 0;
    int base = 1;
    for(int i = a.length - 1; i >= a.length-_order; i--)
    {
      value += a[i] * base;
      base *= tailleVocabulaire;
    }
    return value;
  }

  private String sequenceOfIndex(int index,int base, int expectedSize, String[] lexique)
  {
    Vector seq = sequenceOfIndex2(index,base,expectedSize);
    String value = "";     
    for(int i = 0;i<seq.size();i++)
    {
      value += lexique[((Integer)seq.elementAt(i)).intValue()];
    }
    return value;
  }


  /**
    Prends les n-1 premiers éléments d'un vecteur de n dimensions, et
    calcule un entier décrivant complétement le sous vecteur sur la base
    du nombre de valeurs potentiellement prise par chacune de ses
    composantes.
  */
  private int indexOfSequence(Vector intVector, int basis)
  {
    int tailleVocabulaire = basis;
    int value = 0;
    int base = 1;
    for(int i = intVector.size() - 2; i >=0; i--)
    {
      Integer token = (Integer) intVector.elementAt(i);
      value += token.intValue() * base;
      base *= tailleVocabulaire;
    }
    return value;
  }

  private Vector sequenceOfIndex2(int index, int base, int expectedSize)
  {
    Vector value = new Vector();
    while(index > 0)
    {
      value.add(new Integer(index%base));
      index = index / base;
    }
    while(value.size() < _order)
    { value.add(new Integer(0));}
    return value;
  }

  /**
    Simulation d'une file :
    Définition des opérations push et pop
    fonctionnant par effet de bord.
  */
  private void fpush(LinkedList l, Object o)
  {
    Couple c = (Couple) o;
    l.addFirst(o);
  }
  private Object fpop(LinkedList l)
  {
    Object o = l.removeLast();
    Couple c = (Couple) o;
    return o;
  }
  private boolean fempty(LinkedList l)
  {
    return (l.size() == 0);
  }


  /**
    Fonction puissance classique (définie pour des exposants positifs).
  */
  private int pow(int a, int b)
  {
    if (b==0)
    {
      return 1;
    }
    else
    {
      if (b%2==0)
      {
        return(pow(a*a,b/2));
      }
      else
      {
        return(a*pow(a*a,b/2));
      }
    }
  }

  /**
    Modifie la representation en String (ah ah ah ...) d'un token :
    un token de representation src prendra comme representation dest.
  */
  private void replace(String src, String dest)
  {
    boolean found = false;
    for(int i=0;i<symboles.length;i++)
    {
      if(symboles[i].equals(src))
      {
        symboles[i] = dest;
        found = true;
      }
    }
    if (!found)
    {
      parser.done_parsing();
      parser.report_error("The left value for the alias declaration \""+src+" = "+dest+"\" doesn't exist !","");
    }
  }

  private final ParseMarkov parser;

  /** Constructor */
  CUP$ParseMarkov$actions(ParseMarkov parser) {
    this.parser = parser;
  }

  /** Method with the actual generated action code. */
  public final java_cup.runtime.Symbol CUP$ParseMarkov$do_action(
    int                        CUP$ParseMarkov$act_num,
    java_cup.runtime.lr_parser CUP$ParseMarkov$parser,
    java.util.Stack            CUP$ParseMarkov$stack,
    int                        CUP$ParseMarkov$top)
    throws java.lang.Exception
    {
      /* Symbol object for return from actions */
      java_cup.runtime.Symbol CUP$ParseMarkov$result;

      /* select the action based on the action number */
      switch (CUP$ParseMarkov$act_num)
        {
          /*. . . . . . . . . . . . . . . . . . . .*/
          case 42: // AliasesList ::= IDENT ARROW STRING 
            {
              Object RESULT = null;
		int i_srcleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int i_srcright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		String i_src = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int i_destleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int i_destright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		String i_dest = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  replace(i_src,i_dest);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(10/*AliasesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 41: // AliasesList ::= IDENT ARROW IDENT 
            {
              Object RESULT = null;
		int i_srcleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int i_srcright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		String i_src = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int i_destleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int i_destright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		String i_dest = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  replace(i_src,i_dest);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(10/*AliasesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 40: // AliasesList ::= IDENT ARROW STRING AliasesList 
            {
              Object RESULT = null;
		int i_srcleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left;
		int i_srcright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).right;
		String i_src = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).value;
		int i_destleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int i_destright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		String i_dest = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		
                                                  replace(i_src,i_dest);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(10/*AliasesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 39: // AliasesList ::= IDENT ARROW IDENT AliasesList 
            {
              Object RESULT = null;
		int i_srcleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left;
		int i_srcright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).right;
		String i_src = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).value;
		int i_destleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int i_destright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		String i_dest = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		
                                                  replace(i_src,i_dest);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(10/*AliasesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 38: // AliasesList ::= IDENT EQUALS STRING 
            {
              Object RESULT = null;
		int i_srcleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int i_srcright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		String i_src = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int i_destleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int i_destright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		String i_dest = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  replace(i_src,i_dest);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(10/*AliasesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 37: // AliasesList ::= IDENT EQUALS IDENT 
            {
              Object RESULT = null;
		int i_srcleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int i_srcright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		String i_src = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int i_destleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int i_destright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		String i_dest = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  replace(i_src,i_dest);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(10/*AliasesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 36: // AliasesList ::= IDENT EQUALS STRING AliasesList 
            {
              Object RESULT = null;
		int i_srcleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left;
		int i_srcright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).right;
		String i_src = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).value;
		int i_destleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int i_destright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		String i_dest = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		
                                                  replace(i_src,i_dest);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(10/*AliasesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 35: // AliasesList ::= IDENT EQUALS IDENT AliasesList 
            {
              Object RESULT = null;
		int i_srcleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left;
		int i_srcright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).right;
		String i_src = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).value;
		int i_destleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int i_destright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		String i_dest = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		
                                                  replace(i_src,i_dest);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(10/*AliasesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 34: // AliasesDeclaration ::= 
            {
              Object RESULT = null;
		 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(9/*AliasesDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 33: // AliasesDeclaration ::= ALIASES EQUALS 
            {
              Object RESULT = null;
		
                                                  parser.done_parsing();
                                                  parser.report_error("You should define at least one alias !",null);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(9/*AliasesDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 32: // AliasesDeclaration ::= ALIASES EQUALS AliasesList 
            {
              Object RESULT = null;
		 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(9/*AliasesDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 31: // HiddenStatesDefinitions ::= IDENT DBLPOINT FrequenciesListNoSize SEMI 
            {
              Stack RESULT = null;
		int stateleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left;
		int stateright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).right;
		String state = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).value;
		int cleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int cright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Couple c = (Couple)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		
                                                   Stack s = new Stack();
                                                   Couple ctmp = new Couple(state,c);
                                                   s.push(ctmp);
                                                   RESULT = s;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(14/*HiddenStatesDefinitions*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-3)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 30: // HiddenStatesDefinitions ::= IDENT DBLPOINT FrequenciesListNoSize 
            {
              Stack RESULT = null;
		int stateleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int stateright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		String state = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int cleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int cright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Couple c = (Couple)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                   Stack s = new Stack();
                                                   Couple ctmp = new Couple(state,c);
                                                   s.push(ctmp);
                                                   RESULT = s;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(14/*HiddenStatesDefinitions*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 29: // HiddenStatesDefinitions ::= IDENT DBLPOINT FrequenciesListNoSize SEMI HiddenStatesDefinitions 
            {
              Stack RESULT = null;
		int stateleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-4)).left;
		int stateright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-4)).right;
		String state = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-4)).value;
		int cleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int cright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		Couple c = (Couple)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int sleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int sright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Stack s = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                   Couple ctmp = new Couple(state,c);
                                                   s.push(ctmp);
                                                   RESULT = s;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(14/*HiddenStatesDefinitions*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-4)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 28: // FrequenciesListNoSize ::= StringList DoubleList 
            {
              Couple RESULT = null;
		int p1left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int p1right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Stack p1 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		int p2left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int p2right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Stack p2 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 
                                                   Vector freqs = new Vector();
                                                   Vector seqs = new Vector();
                                                   Couple c = new Couple(seqs,freqs);
                                                   addFrequency(p1,p2,c,false); 
                                                   RESULT = c;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(16/*FrequenciesListNoSize*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 27: // FrequenciesListNoSize ::= StringList DoubleList FrequenciesListNoSize 
            {
              Couple RESULT = null;
		int p1left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int p1right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		Stack p1 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int p2left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int p2right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Stack p2 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		int cleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int cright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Couple c = (Couple)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 
                                                   addFrequency(p1,p2,c,false); 
                                                   RESULT = c;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(16/*FrequenciesListNoSize*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 26: // FrequenciesList ::= StringList DoubleList 
            {
              Couple RESULT = null;
		int p1left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int p1right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Stack p1 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		int p2left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int p2right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Stack p2 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 
                                                   Vector freqs = new Vector();
                                                   Vector seqs = new Vector();
                                                   Couple c = new Couple(seqs,freqs);
                                                   addFrequency(p1,p2,c,true); 
                                                   RESULT = c;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(15/*FrequenciesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 25: // FrequenciesList ::= StringList DoubleList FrequenciesList 
            {
              Couple RESULT = null;
		int p1left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int p1right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		Stack p1 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int p2left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int p2right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Stack p2 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		int cleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int cright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Couple c = (Couple)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 
                                                   addFrequency(p1,p2,c,true); 
                                                   RESULT = c;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(15/*FrequenciesList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 24: // FrequenciesDeclaration ::= HMMFREQUENCIES EQUALS FrequenciesList 
            {
              Object RESULT = null;
		int cleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int cright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Couple c = (Couple)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 
                                                  parser.done_parsing();
                                                  parser.report_error("Definition required for the hidden states emission probabilities !",null);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(8/*FrequenciesDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 23: // FrequenciesDeclaration ::= HMMFREQUENCIES EQUALS FrequenciesList SEMI HiddenStatesDefinitions 
            {
              Object RESULT = null;
		int cleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int cright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		Couple c = (Couple)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int sleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int sright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Stack s = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 
                                                  Couple c2 = convertToMarkov(c,s);
                                                  gatherFrequencies((Couple)c2.snd());
                                                  setSymbols((String[])c2.fst());
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(8/*FrequenciesDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-4)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 22: // FrequenciesDeclaration ::= FREQUENCIES EQUALS FrequenciesList 
            {
              Object RESULT = null;
		int cleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int cright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Couple c = (Couple)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 
                                                  gatherFrequencies(c);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(8/*FrequenciesDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 21: // DoubleList ::= ENTIER 
            {
              Stack RESULT = null;
		int ileft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int iright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Integer i = (Integer)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  Stack<Double> pile = new Stack<Double>();
                                                  pile.push(new Double(i));
                                                  RESULT = pile;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(13/*DoubleList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 20: // DoubleList ::= REEL 
            {
              Stack RESULT = null;
		int ileft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int iright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Double i = (Double)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  Stack<Double> pile = new Stack<Double>();
                                                  pile.push(i);
                                                  RESULT = pile;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(13/*DoubleList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 19: // DoubleList ::= ENTIER DoubleList 
            {
              Stack RESULT = null;
		int ileft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int iright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Integer i = (Integer)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		int pleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int pright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Stack p = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  p.push(new Double(i));
                                                  RESULT = p;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(13/*DoubleList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 18: // DoubleList ::= REEL DoubleList 
            {
              Stack RESULT = null;
		int ileft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int iright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Double i = (Double)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		int pleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int pright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Stack p = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  p.push(i);
                                                  RESULT = p;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(13/*DoubleList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 17: // StringList ::= IDENT 
            {
              Stack RESULT = null;
		int sleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int sright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		String s = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  Stack pile = new Stack();
                                                  pile.push(s);
                                                  RESULT = pile;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(12/*StringList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 16: // StringList ::= IDENT StringList 
            {
              Stack RESULT = null;
		int sleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int sright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		String s = (String)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		int pleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int pright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Stack p = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  p.push(s);
                                                  RESULT = p;
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(12/*StringList*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 15: // StartSequences ::= StringList ENTIER 
            {
              Object RESULT = null;
		int p1left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int p1right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Stack p1 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		int nleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int nright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Integer n = (Integer)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 addStartFrequency(p1,new Double(n)); 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(7/*StartSequences*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 14: // StartSequences ::= StringList REEL 
            {
              Object RESULT = null;
		int p1left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int p1right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Stack p1 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		int nleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int nright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Double n = (Double)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 addStartFrequency(p1,n); 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(7/*StartSequences*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 13: // StartSequences ::= StringList ENTIER StartSequences 
            {
              Object RESULT = null;
		int p1left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int p1right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		Stack p1 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int nleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int nright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Integer n = (Integer)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		 addStartFrequency(p1,new Double(n)); 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(7/*StartSequences*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 12: // StartSequences ::= StringList REEL StartSequences 
            {
              Object RESULT = null;
		int p1left = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left;
		int p1right = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).right;
		Stack p1 = (Stack)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).value;
		int nleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int nright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Double n = (Double)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		 addStartFrequency(p1,n); 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(7/*StartSequences*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 11: // StartSequencesDeclaration ::= 
            {
              Object RESULT = null;
		  
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(6/*StartSequencesDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 10: // StartSequencesDeclaration ::= START EQUALS StartSequences 
            {
              Object RESULT = null;
		 gatherStartFrequencies(); 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(6/*StartSequencesDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 9: // SymbolTypeDeclaration ::= 
            {
              Object RESULT = null;
		 _isWord = true; 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(5/*SymbolTypeDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 8: // SymbolTypeDeclaration ::= SYMBOLS EQUALS LETTERS 
            {
              Object RESULT = null;
		 _isWord = false; 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(5/*SymbolTypeDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 7: // SymbolTypeDeclaration ::= SYMBOLS EQUALS WORDS 
            {
              Object RESULT = null;
		 _isWord = true; 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(5/*SymbolTypeDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 6: // PhaseDeclaration ::= 
            {
              Object RESULT = null;
		 _phase = 1; 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(4/*PhaseDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 5: // PhaseDeclaration ::= PHASE EQUALS ENTIER 
            {
              Object RESULT = null;
		int nleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int nright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Integer n = (Integer)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		
                                                  if(n.intValue()>0)
                                                  {
                                                    _phase = n.intValue();
                                                  }
                                                  else
                                                  {
                                                    parser.done_parsing();
                                                    parser.report_error("NBPhase must be > 0 !",null);
                                                  }
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(4/*PhaseDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 4: // OrderDeclaration ::= 
            {
              Object RESULT = null;
		
                                                  parser.done_parsing();
                                                  parser.report_error("You must define markovian order !",null);
                                                
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(3/*OrderDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 3: // OrderDeclaration ::= ORDER EQUALS ENTIER 
            {
              Object RESULT = null;
		int nleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).left;
		int nright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right;
		Integer n = (Integer)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).value;
		 _order = n.intValue(); 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(3/*OrderDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 2: // TypeDeclaration ::= TYPE EQUALS MARKOV 
            {
              Object RESULT = null;
		 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(2/*TypeDeclaration*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-2)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 1: // MarkovDescription ::= TypeDeclaration OrderDeclaration PhaseDeclaration SymbolTypeDeclaration StartSequencesDeclaration FrequenciesDeclaration AliasesDeclaration 
            {
              Object RESULT = null;
		 
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(1/*MarkovDescription*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-6)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          return CUP$ParseMarkov$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 0: // $START ::= MarkovDescription EOF 
            {
              Object RESULT = null;
		int start_valleft = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left;
		int start_valright = ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).right;
		Object start_val = (Object)((java_cup.runtime.Symbol) CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).value;
		RESULT = start_val;
              CUP$ParseMarkov$result = new java_cup.runtime.Symbol(0/*$START*/, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-1)).left, ((java_cup.runtime.Symbol)CUP$ParseMarkov$stack.elementAt(CUP$ParseMarkov$top-0)).right, RESULT);
            }
          /* ACCEPT */
          CUP$ParseMarkov$parser.done_parsing();
          return CUP$ParseMarkov$result;

          /* . . . . . .*/
          default:
            throw new Exception(
               "Invalid action number found in internal parse table");

        }
    }
}

