This repository has been archived on 2023-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
plasp/include/plasp/LanguageDetection.h

50 lines
1.1 KiB
C++

#ifndef __PLASP__LANGUAGE_DETECTION_H
#define __PLASP__LANGUAGE_DETECTION_H
#include <plasp/Language.h>
#include <plasp/input/Parser.h>
namespace plasp
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// LanguageDetection
//
////////////////////////////////////////////////////////////////////////////////////////////////////
Language::Type detectLanguage(input::Parser<input::CaseInsensitiveParserPolicy> &parser)
{
parser.skipWhiteSpace();
// SAS begins with "begin_version"
if (parser.testAndSkip<std::string>("begin"))
{
parser.seek(0);
return Language::Type::SAS;
}
// Skip potential PDDL comments
while (parser.currentCharacter() == ';')
{
parser.skipLine();
parser.skipWhiteSpace();
}
// PDDL contains sections starting with "(define"
if (parser.testAndSkip<std::string>("(") && parser.testAndSkip<std::string>("define"))
{
parser.seek(std::ios::beg);
return Language::Type::PDDL;
}
parser.seek(std::ios::beg);
return Language::Type::Unknown;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
#endif