Example #1
0
bool Parser::ParseValue(Statement* statement)
{
	if (GetCurrentChar() == '"') {
		NextChar();
		
		// "..."
		AutoDelete<Value> value(new Value());
		
		BString* string;
		if (statement->GetOption() != NULL) {
			string = fScanner.ScanInvocationValue();
			value.Get()->SetType(Value::kInvocationValue);
		} else {
			string = fScanner.ScanQuotedValue();
			value.Get()->SetType(Value::kQuotedValue);
		}
		
		if (string == NULL) {
			Error("Expected value");
			return false;
		}
		
		// " is expected
		if (GetCurrentChar() != '"') {
			Error("Expected \" at end of value");
			return false;
		}
		NextChar();
		
		value.Get()->SetValue(string);
		statement->SetValue(value.Release());		
	} else if (GetCurrentChar() == '^') {
		// ^ SymbolValue
		BString* symbol = fScanner.ScanOption();
		if (symbol == NULL) {
			Error("Symbol expected!");
			return false;
		}
		Value* value = new Value(symbol, Value::kSymbolValue);
		statement->SetValue(value);
	} else {
		// StringValue
		BString* stringValue = fScanner.ScanStringValue();
		if (stringValue == NULL) {
			Error("String value expected!");
			return false;
		}
		
		Value* value = new Value(stringValue, Value::kStringValue);
		statement->SetValue(value);
	}
	if (GetCurrentChar() == '/') {
		NextChar();
		return ParseTranslation(statement->GetValue(), kCr);
	}
	return true;
}
Example #2
0
	void ImportTranslationFiles(BSScaleformTranslator * translator)
	{
		char	appdataPath[MAX_PATH];
		ASSERT(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdataPath)));

		std::string	modlistPath = appdataPath;
		modlistPath += "\\Skyrim Special Edition\\plugins.txt";

		// Parse mod list file to acquire translation filenames
		IFileStream modlistFile;
		if(modlistFile.Open(modlistPath.c_str()))
		{
			while(!modlistFile.HitEOF())
			{
				char buf[512];
				modlistFile.ReadString(buf, 512, '\n', '\r');

				// skip comments
				if(buf[0] == '#')
					continue;				

				// Determine extension type
				std::string line = buf;

				// SE: added this
				if (line.length() > 0)
				{
					if (line.front() != '*')
						continue; // Skip not enabled files

					line = line.substr(1); // Remove the * from name
				}					

				std::string::size_type lastDelim = line.rfind('.');
				if(lastDelim != std::string::npos)
				{
					std::string ext = line.substr(lastDelim);

					if(_stricmp(ext.c_str(), ".ESM") == 0 || _stricmp(ext.c_str(),".ESP") == 0)
					{
						std::string name = line.substr(0, lastDelim);
						ParseTranslation(translator, name);
					}
				}
			}
		}

		modlistFile.Close();
	}
Example #3
0
bool Parser::ParseOption(Statement* statement)
{
	// ["^"]
	bool isSymbolValue = GetCurrentChar() == '^';
	if (isSymbolValue) {
		NextChar();
	}
	
	// [ ... Option ...]
	if (IsOptionChar(GetCurrentChar())) {
		
		BString* option = fScanner.ScanOption();
		if (option == NULL) {
			Error("Out of memory scanning option!");
			return false;
		}
		Value::Type type;
		if (isSymbolValue) {
			type = Value::kSymbolValue;
		} else {
			type = Value::kStringValue;
		}
		Value* value = new Value(option, type);
		statement->SetOption(value);
		
		SkipWhitespaceSeparator();
		// ["/" Translation ]
		if (GetCurrentChar() == '/') {
			NextChar();
			return ParseTranslation(value, ':');
		}
	} else {
		if (isSymbolValue) {
			Error("Expected symbol value!");
			return false;
		}
	}
	return true;
}