cmake/Source/cmCommandArgumentParserHelper.h

93 lines
2.6 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmCommandArgumentParserHelper_h
#define cmCommandArgumentParserHelper_h
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
#include <string>
#include <vector>
class cmMakefile;
class cmCommandArgumentParserHelper
{
2017-07-20 19:35:53 +02:00
CM_DISABLE_COPY(cmCommandArgumentParserHelper)
public:
2017-07-20 19:35:53 +02:00
struct ParserType
2016-07-09 11:21:54 +02:00
{
2018-04-23 21:13:27 +02:00
const char* str;
2017-07-20 19:35:53 +02:00
};
cmCommandArgumentParserHelper();
~cmCommandArgumentParserHelper();
int ParseString(const char* str, int verb);
// For the lexer:
void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
2016-07-09 11:21:54 +02:00
const char* str, int len = 0);
bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt,
2016-07-09 11:21:54 +02:00
char symbol);
int LexInput(char* buf, int maxlen);
void Error(const char* str);
// For yacc
2018-04-23 21:13:27 +02:00
const char* CombineUnions(const char* in1, const char* in2);
2018-04-23 21:13:27 +02:00
const char* ExpandSpecialVariable(const char* key, const char* var);
const char* ExpandVariable(const char* var);
const char* ExpandVariableForAt(const char* var);
void SetResult(const char* value);
void SetMakefile(const cmMakefile* mf);
std::string& GetResult() { return this->Result; }
void SetLineFile(long line, const char* file);
void SetEscapeQuotes(bool b) { this->EscapeQuotes = b; }
void SetNoEscapeMode(bool b) { this->NoEscapeMode = b; }
void SetReplaceAtSyntax(bool b) { this->ReplaceAtSyntax = b; }
void SetRemoveEmpty(bool b) { this->RemoveEmpty = b; }
2013-03-16 19:13:01 +02:00
const char* GetError() { return this->ErrorString.c_str(); }
private:
2015-04-27 22:25:09 +02:00
std::string::size_type InputBufferPos;
std::string InputBuffer;
std::vector<char> OutputBuffer;
void Print(const char* place, const char* str);
void SafePrintMissing(const char* str, int line, int cnt);
2018-04-23 21:13:27 +02:00
const char* AddString(const std::string& str);
void CleanupParser();
void SetError(std::string const& msg);
std::vector<char*> Variables;
const cmMakefile* Makefile;
std::string Result;
2015-11-17 17:22:37 +01:00
std::string ErrorString;
const char* FileName;
2015-11-17 17:22:37 +01:00
long FileLine;
int CurrentLine;
int Verbose;
2011-02-07 16:37:25 +01:00
bool WarnUninitialized;
bool CheckSystemVars;
bool EscapeQuotes;
bool NoEscapeMode;
bool ReplaceAtSyntax;
2013-03-16 19:13:01 +02:00
bool RemoveEmpty;
};
2017-07-20 19:35:53 +02:00
#define YYSTYPE cmCommandArgumentParserHelper::ParserType
#define YYSTYPE_IS_DECLARED
#define YY_EXTRA_TYPE cmCommandArgumentParserHelper*
#define YY_DECL \
int cmCommandArgument_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner)
#endif