Ejemplo n.º 1
0
bool FortranFormat::ProcessToken(String & field)
   {
   // This flag only gets set if we encounter the final bracket or a ':'
   endOfPattern = false;

   // Read input from file, if appropriate
   if (inputPos == -1)
      {
      inputLine.ReadLine(input);
      inputPos = 0;
      }

   // First read repeat count specifier
   if (repeatCount == 0)
      repeatCount = GetIntegerFromFormat();

   // By default, the repeat count should be 1
   if (repeatCount == 0)
      repeatCount = 1;

   int repeatPos = formatPos;

   // Check if this is a new bracketed grouping
   if (format[formatPos] == '(')
      {
      formatPos++;

      bracketStack.Push(formatPos);
      bracketCounter.Push(repeatCount);
      bracketCount.Push(repeatCount);

      repeatCount = 0;

      return false;
      }

   // Check if this an 'X' field
   if (format[formatPos] == 'X')
      {
      formatPos++;

      // No width specifier allowed for these fields
      RejectWidth('X');

      // Skip appropriate number of characters
      inputPos += repeatCount;

      // Reset repeat count
      repeatCount = 0;

      FinishField();

      return false;
      }

   // Check if this is a '/' (vertical tab field)
   if (format[formatPos] == '/')
      {
      formatPos++;

      // No width specifier allowed for these fields
      RejectWidth('/');

      // Skip the appropriate number of lines
      while (repeatCount--)
         inputLine.ReadLine(input);

      inputPos = 0;

      // Separators are optional, so we might already be at the next field
      if (format[formatPos] == ',' || format[formatPos] || ')')
         FinishField();

      return false;
      }

   // Check that we haven't encountered a rare, but unsupported input type
   if (format[formatPos] == 'Q' || format[formatPos] == 'P' || format[formatPos] == 'B')
      {
      formatPos++;

      int problemStart = formatPos;

      while (format[formatPos] != ',' && format[formatPos] != ')' && format[formatPos] != '/')
         formatPos++;

      error("Unsupported pattern in FORMAT statement\n\n"
            "Statement \"%s\" includes unsupporterd pattern '%s'\n",
            (const char *) format,
            (const char *) format.SubStr(problemStart, formatPos - problemStart));
      }

   if (format[formatPos] == ':')
      {
      formatPos++;

      if (format[formatPos] == ',' || format[formatPos] || ')')
         FinishField();

      repeatCount = 0;

      endOfPattern = true;

      return false;
      }

   // All the other types we recognize include a width specifier

   // Identify the location of the type specifier
   int typeStart = formatPos;

   while (CharacterFollows())
      formatPos++;

   int typeLen = formatPos - typeStart;

   // Retrieve the field width
   int width = GetIntegerFromFormat();

   if (width == 0)
      error("Unrecognized FORMAT statement\n\n"
            "Statement \"%s\" is missing a width specifier for a field of type '%s'\n",
            (const char *) format, (const char *) format.SubStr(typeStart, typeLen));

   // Check for horizontal tab character
   if (format[typeStart] == 'T')
      {
      // Move left by a specified number of characters
      if (format[typeStart + 1] == 'L')
         inputPos = width > inputPos ? 0 : inputPos - width;
      // Move right by a specified number of characters
      else if (format[typeStart + 1] == 'R')
         inputPos += width;
      // Or simply set the appropriate horizontal position
      else
         inputPos = width;

      repeatCount--;

      if (repeatCount)
         formatPos = repeatPos;
      else
         FinishField();

      return false;
      }

   // Assume that if we got here, we are looking at a data field!
   field.Copy(inputLine, inputPos, width);
   field.Trim();

   inputPos += width;

   repeatCount--;

   if (repeatCount)
      formatPos = repeatPos;
   else
      FinishField();

   return true;
   }
Ejemplo n.º 2
0
void BBDataBuffer::_LoadAsync( const String &cpath,BBThread *thread ){

	String path=cpath.Copy();
	
	if( _Load( path ) ) thread->SetResult( this );
}