Logo Search packages:      
Sourcecode: lttoolbox version File versions  Download package

void Compiler::procEntry (  )  [private]

Parse the <e> element

Definition at line 578 of file Compiler.C.

References allBlanks(), attrib(), direction, insertEntryTokens(), latin1(), paradigms, procIdentity(), procPar(), procRegExp(), procTransduction(), reader, and skipBlanks().

Referenced by procNode().

{
  string atributo=this->attrib(COMPILER_RESTRICTION_ATTR);
  string ignore = this->attrib(COMPILER_IGNORE_ATTR);

  // if entry is masked by a restriction of direction or an ignore mark
  if((atributo != "" && atributo != direction) || ignore == COMPILER_IGNORE_YES_VAL)
  {
    // parse to the end of the entry
    string name = "";

    while(name != COMPILER_ENTRY_ELEM)
    {
      xmlTextReaderRead(reader);
      name = latin1(xmlTextReaderConstName(reader));
    }

    return;
  }

  vector<EntryToken> elementos;

  while(true)
  {
    int ret = xmlTextReaderRead(reader);
    if(ret != 1)
    {
      cerr << "Error (" << xmlTextReaderGetParserLineNumber(reader);
      cerr << "): Parse error." << endl;
      exit(EXIT_FAILURE);
    }
    string name = latin1(xmlTextReaderConstName(reader));
    skipBlanks(name);

    int tipo = xmlTextReaderNodeType(reader);
    if(name == COMPILER_PAIR_ELEM)
    {      
      elementos.push_back(procTransduction());
    }
    else if(name == COMPILER_IDENTITY_ELEM)
    {
      elementos.push_back(procIdentity());
    }
    else if(name == COMPILER_REGEXP_ELEM)
    {
      elementos.push_back(procRegExp());
    }
    else if(name == COMPILER_PAR_ELEM)
    {
      elementos.push_back(procPar());

      // detección del uso de paradigmas no definidos

      string const &p = elementos.rbegin()->paradigmName();

      if(paradigms.find(p) == paradigms.end())
      {
        cerr << "Error (" << xmlTextReaderGetParserLineNumber(reader);
        cerr << "): Undefined paradigm '" << p << "'." <<endl;
        exit(EXIT_FAILURE);
      }
      // descartar entradas con paradigms vacíos (por las direciones,
      // normalmente
      if(paradigms[p].isEmpty())
      {
        while(name != COMPILER_ENTRY_ELEM || tipo != XML_READER_TYPE_END_ELEMENT)
        {
          xmlTextReaderRead(reader);
          name = latin1(xmlTextReaderConstName(reader));
          tipo = xmlTextReaderNodeType(reader);
        }
        return;
      }
    }
    else if(name == COMPILER_ENTRY_ELEM && tipo == XML_READER_TYPE_END_ELEMENT)
    {
      // insertar los elementos de la entrada en el TL
      insertEntryTokens(elementos);
      return;
    }
    else if(name == "#text" && allBlanks())
    {
    }
    else
    {
      cerr << "Error (" << xmlTextReaderGetParserLineNumber(reader);
      cerr << "): Invalid inclusion of '<" << name << ">' into '<" << COMPILER_ENTRY_ELEM;
      cerr << ">'." << endl;
      exit(EXIT_FAILURE);
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index