Logo Search packages:      
Sourcecode: lttoolbox version File versions

unsigned short FSTProcessor::readGeneration ( FILE *  input,
FILE *  output 
) [private]

Read text from stream (generation version)

Parameters:
input the stream to read
Returns:
the next symbol in the stream

Definition at line 222 of file FSTProcessor.C.

References alphabet, outOfWord, readFullBlock(), and streamError().

{
  int val = fgetc_unlocked(input);

  if(feof(input))
  {
    return 0xffff;
  }
  
  if(outOfWord)
  {
    if(val == '^')
    {
      val = fgetc_unlocked(input);
      if(feof(input))
      {
        return 0xffff;
      }
    }
    else if(val == '\\')
    {
      fputc_unlocked(val,output);
      val = fgetc_unlocked(input);
      if(feof(input))
      {
        return 0xffff;
      }
      fputc_unlocked(val,output);
      skipUntil(input,output, '^');
      val = fgetc_unlocked(input);
      if(feof(input))
      {
        return 0xffff;
      }
    }
    else
    {
      fputc_unlocked(val, output);
      skipUntil(input, output, '^');
      val = fgetc_unlocked(input);
      if(feof(input))
      {
        return 0xffff;
      }
    }
    outOfWord = false;
  }

  if(val == '\\')
  {
    val = fgetc_unlocked(input);
    return static_cast<unsigned short>(val);
  }
  else if(val == '$')
  {
    outOfWord = true;
    return static_cast<unsigned short>('$');
  }
  else if(val == '<')
  {
    string cad = "";
    cad += char(val);
    while((val = fgetc_unlocked(input)) != '>')
    {
      if(feof(input))
      {
      streamError();
      }
      cad += char(val);
    }
    cad += char(val);

    return alphabet(cad);
  }
  else if(val == '[')
  {
    fputs_unlocked(readFullBlock(input, '[', ']').c_str(), output);
    return readGeneration(input, output);
  }
  else
  {
    return static_cast<unsigned short>(val);
  }

  return 0xffff;
}


Generated by  Doxygen 1.6.0   Back to index