Logo Search packages:      
Sourcecode: lttoolbox version File versions

void Compiler::insertEntryTokens ( vector< EntryToken > const &  elements  )  [private]

Insert a list of tokens into the paradigm / section being processed

Parameters:
elements the list

Definition at line 448 of file Compiler.C.

References alphabet, RegExpCompiler::compile(), current_paradigm, current_section, Transducer::getInitial(), RegExpCompiler::getTransducer(), RegExpCompiler::initialize(), Transducer::insertNewSingleTransduction(), Transducer::insertTransducer(), Transducer::linkStates(), matchTransduction(), paradigms, postsuffix_paradigms, prefix_paradigms, reader, sections, Transducer::setFinal(), and suffix_paradigms.

Referenced by procEntry().

{
  if(current_paradigm != "")
  {
    // compilation of paradigms
    Transducer &t = paradigms[current_paradigm];
    int e = t.getInitial();
    
    for(unsigned int i = 0, limit = elementos.size(); i < limit; i++)
    {
      if(elementos[i].isParadigm())
      {
      e = t.insertTransducer(e, paradigms[elementos[i].paradigmName()]);
      }
      else if(elementos[i].isSingleTransduction())
      {
        e = matchTransduction(elementos[i].left(), 
                                  elementos[i].right(), e, t);
      }
      else if(elementos[i].isRegExp())
      {
      RegExpCompiler analizador;
      analizador.initialize(alphabet);
      analizador.compile(elementos[i].regExp());
      e = t.insertTransducer(e, analizador.getTransducer(), alphabet("",""));
      }
      else
      {
        cerr << "Error (" << xmlTextReaderGetParserLineNumber(reader);
        cerr << "): Invalid entry token." << endl;
        exit(EXIT_FAILURE);
      }
    }
    t.setFinal(e);
  }
  else
  {
    // compilación de dictionary

    Transducer &t = sections[current_section];
    int e = t.getInitial();

    for(unsigned int i = 0, limit = elementos.size(); i < limit; i++)
    {
      if(elementos[i].isParadigm())
      {
        if(i == elementos.size()-1)
      {
        // paradigma sufijo
        if(suffix_paradigms[current_section].find(elementos[i].paradigmName()) != suffix_paradigms[current_section].end())
        {
          t.linkStates(e, suffix_paradigms[current_section][elementos[i].paradigmName()], 0);
            e = postsuffix_paradigms[current_section][elementos[i].paradigmName()];
        }
          else
          {
            e = t.insertNewSingleTransduction(alphabet("", ""), e);
            suffix_paradigms[current_section][elementos[i].paradigmName()] = e;
            e = t.insertTransducer(e, paradigms[elementos[i].paradigmName()]);
            postsuffix_paradigms[current_section][elementos[i].paradigmName()] = e;
        }
      }
        else if(i == 0)
      {
          // paradigma prefijo
        if(prefix_paradigms[current_section].find(elementos[i].paradigmName()) != prefix_paradigms[current_section].end())
        {
            e = prefix_paradigms[current_section][elementos[i].paradigmName()];
        }
        else
        {
            e = t.insertTransducer(e, paradigms[elementos[i].paradigmName()]);
            prefix_paradigms[current_section][elementos[i].paradigmName()] = e;
        }
        }
      else
      {
          // paradigma intermedio
          e = t.insertTransducer(e, paradigms[elementos[i].paradigmName()]);
      }
      }
      else if(elementos[i].isRegExp())
      {
      RegExpCompiler analizador;
      analizador.initialize(alphabet);
      analizador.compile(elementos[i].regExp());
      e = t.insertTransducer(e, analizador.getTransducer(), alphabet("",""));
      }
      else
      {
        e = matchTransduction(elementos[i].left(), elementos[i].right(), e, t);
      }
    }
    t.setFinal(e);
  }
}


Generated by  Doxygen 1.6.0   Back to index