wxString wxStringFormatter::Parse(wxString input)
{
	if(CheckSyntax(input)) return input;
	input = DoBlocks(input);
	input = DoFunctions(input);
	input = ReplaceSymbols(input);
	input = DoConcat(input);
	return input;
}
wxString wxStringFormatter::DoFunction(wxString func, wxString block)
{
	wxLogDebug("DoFunction: " + block);
	if(GetFunction(func))
	{
		return GetFunction(func)->Parse(ReplaceSymbols(block));
	}
	return func + block;
}
示例#3
0
static
void
PrintDependency (
  INT8    *TargetFileName,
  INT8    *DependentFile
  )
/*++

Routine Description:

  Given a target (.obj) file name, and a dependent file name, do any string
  substitutions (per the command line options) on the file names, then
  print the dependency line of form:
  
  TargetFileName : DependentFile
  
Arguments:

  TargetFileName - build target file name
  DependentFile  - file on which TargetFileName depends

Returns:

  None
  
--*/
{
  INT8  Str[MAX_PATH];

  //
  // Go through the symbols and do replacements
  //
  strcpy (Str, TargetFileName);
  ReplaceSymbols (Str, sizeof (Str));
  fprintf (mGlobals.OutFptr, "%s : ", Str);
  strcpy (Str, DependentFile);
  ReplaceSymbols (Str, sizeof (Str));
  fprintf (mGlobals.OutFptr, "%s\n", Str);
  //
  // Add pseudo target to avoid incremental build failure when the file is deleted
  //
  fprintf (mGlobals.OutFptr, "%s : \n", Str);
}
示例#4
0
 void SymbolTable::ReplaceSymbols(SlimList* list) 
 {
   for (int i = 0; i < list->GetLength(); ++i) 
   {
     std::string src = list->GetStringAt(i);
     std::unique_ptr<SlimList> embeddedList(SlimList::Deserialize(src));
     if (!embeddedList) 
     {
       std::string replacedString = ReplaceStringFrom(src, src);
       list->ReplaceAt(i, replacedString.c_str());
     } 
     else 
     {
       ReplaceSymbols(embeddedList.get());
       std::string serializedReplacedList = SlimList::Serialize(embeddedList.get());
       list->ReplaceAt(i, serializedReplacedList.c_str());
     }
   }
 }
int wxStringFormatter::FindNextBlock(wxString& input, int pos, int& level)
{
	wxString str;
	wxLogDebug(wxString::Format("FindNextBlock: %d ", pos) + input);
	int blockOpen;
	int blockClose;

	blockClose = input.find_first_of(m_blockDelims, pos);

	if(DELIMS_B_CLOSE.Contains(input.GetChar(blockClose)))
	{
		return blockClose;
	}
	else if(DELIMS_B_OPEN.Contains(input.GetChar(blockClose)))
	{
		level++;
		blockOpen = blockClose;
		blockClose = FindNextBlock(input, blockClose+1, level);

		wxString block;
		block = input.SubString(blockOpen + 1, blockClose - 1);
		str.Printf("> %d %d", blockOpen + 1, blockClose - 1);
		wxLogDebug("block > " + block + str);
		block = DoFunctions(block);
		block = ReplaceSymbols(block);
		block = DoConcat(block);
		input.replace(blockOpen, (blockClose + 1) - blockOpen, block);
		level--;
	}
	else
	{
		wxLogDebug("not found");
		return wxNOT_FOUND;
	}

	if(level > 0)
	{
		return FindNextBlock(input, blockOpen, level);
	}
	return -1;
}