StringRef FileInfo::GetExtension( StringRef file ) { intp index= file.IndexOf('.'); if (index>0) { return file.SubString(index); } return StringRef::Empty; }
bool SirenTextParser::EndType(StringRef& refProto) { refProto = refProto.TrimBegin(); intp index = refProto.IndexOf('}'); if (index < 0) { Log::Error("Cannot find }"); return false; } refProto = refProto.SubString(index + 1); return EndBlock(refProto);; }
StringRef SirenTextParser::ReadAttribute(StringRef& refProto) { refProto = refProto.TrimBegin(); intp index = refProto.IndexOf(']'); if (index < 0) { Log::Error("Cannot find ] on attribute"); return false; } StringRef result = refProto.SubString(0, index); refProto = refProto.SubString(index + 1); return result; }
bool SirenTextParser::ReadFunctionArguments(StringRef& refProto, List<StringRef>& outArguments) { //read arguments intp endIndex = refProto.IndexOf(')'); if (endIndex < 0) { Log::Error("Invalid function.Lost ')' "); return false; } StringRef args = refProto.SubString(1, endIndex - 1); bool isSuccess = StringParser::Split(args, ",", outArguments, false); if (!isSuccess) { Log::FormatError("Invalid function argument:{}", args); return false; } refProto = refProto.SubString(endIndex); return EndBlock(refProto); }
bool ISirenFunction::Parse(SirenAssembly& assembly, StringRef& refProto) { //read arguments intp endIndex = refProto.IndexOf(')'); if (endIndex < 0) { Log::Error("Invalid function.Lost ')' "); return false; } StringRef args = refProto.SubString(1, endIndex - 1); bool isSuccess = StringParser::Split(args, ",", mArguments, false); if (!isSuccess) { Log::FormatError("Invalid function argument:{}", args); return false; } refProto = refProto.SubString(endIndex); return SirenTextParser::EndBlock(refProto); }