improved parser

This commit is contained in:
2023-12-20 20:30:32 +03:00
parent 6ae8dac71f
commit a52671d44c

View File

@@ -1373,6 +1373,23 @@ set<ParallelRegion*> getAllRegionsByLine(const vector<ParallelRegion*>& regions,
return regFound;
}
static bool checkFormat(const string& toCheck, const string& given)
{
if (given == "" || given == "*")
{
if (toCheck == "for" || toCheck == "f90" || toCheck == "fdv" ||
toCheck == "ftn" || toCheck == "f95" || toCheck == "f03" ||
toCheck == "f")
{
return true;
}
}
else if (toCheck == given)
return true;
return false;
}
pair<vector<string>, vector<string>> splitCommandLineForParse(char** argv, int argc, bool& isInline)
{
#if __cplusplus >= 201703L
@@ -1390,30 +1407,27 @@ pair<vector<string>, vector<string>> splitCommandLineForParse(char** argv, int a
string ext = OnlyExt(arg.c_str());
convertToLower(ext);
if (ext.find("for") != string::npos ||
ext.find("f90") != string::npos ||
ext.find("fdv") != string::npos ||
ext.find("ftn") != string::npos ||
ext.find("f95") != string::npos ||
ext.find("f03") != string::npos ||
ext.find("f") != string::npos)
if (arg.find("*") != string::npos || checkFormat(ext, ""))
{
if (arg.find("*") == string::npos)
{
if (checkFormat(ext, ""))
files.insert(arg);
else
printf("skip file %s\n", arg.c_str());
}
else
{
#if __cplusplus >= 201703L
fs::path ext = fs::path(arg).filename().extension();
auto str_ext = ext.string();
convertToLower(str_ext);
for (auto& file : filesInDir)
{
auto cmp_ext = file.extension().string();
convertToLower(cmp_ext);
if (cmp_ext == str_ext)
if (checkFormat(cmp_ext, arg))
files.insert(file.filename().string());
else
printf(" skip file %s\n", arg.c_str());
}
#endif
}
@@ -1422,8 +1436,10 @@ pair<vector<string>, vector<string>> splitCommandLineForParse(char** argv, int a
{
if (arg == "-inl")
isInline = true;
else
else if (arg.find("-") != string::npos)
options.push_back(arg);
else
printf(" skip option %s\n", arg.c_str());
}
}
@@ -1441,6 +1457,11 @@ pair<vector<string>, vector<string>> splitCommandLineForParse(char** argv, int a
printf(" skip not existing file '%s'\n", elem.c_str());
}
printf(" options: ");
for (auto& opt : options)
printf("%s ", opt.c_str());
printf("\n");
return make_pair(options, filesV);
}