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

string State::filterFinals ( set< Node * > const &  finals,
Alphabet const &  a,
set< unsigned short > const &  escaped_chars,
bool  uppercase = false,
bool  firstupper = false,
int  firstchar = 0 
) const

Print all outputs of current parsing, preceeded by a bar '/', from the final nodes of the state

Parameters:
finals the set of final nodes
a the alphabet to decode strings
escaped_chars the set of chars to be preceeded with one backslash
uppercase true if the word is uppercase
firstupper true if the first letter of a word is uppercase
firstchar first character of the word
Returns:
the result of the transduction

Definition at line 252 of file State.C.

References Alphabet::getSymbol(), and state.

{
  string result = "";

  for(multimap<Node *, vector<unsigned short> *>::const_iterator it = state.begin(),
                                                                 limit = state.end(); 
      it != limit; it++)
  {
    if(finals.find(it->first) != finals.end())
    {
      result += '/';
      unsigned int const first_char = result.size() + firstchar;
      for(unsigned int i = 0, limit = it->second->size(); i < limit; i++)
      {
        if(escaped_chars.find((*(it->second))[i]) != escaped_chars.end())
        {
          result += '\\';
        }
        alphabet.getSymbol(result, (*(it->second))[i], uppercase);
      }
      if(firstupper)
      {
      if(result[first_char] == '~')
      {
        // skip post-generation mark
        result[first_char+1] = toupper(result[first_char+1]);
      }
      else
      {
          result[first_char] = toupper(result[first_char]);
      }
      }
    }
  }
  
  return result;
}


Generated by  Doxygen 1.6.0   Back to index