/src/CMake/Source/cmExprParserHelper.h
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #pragma once |
4 | | |
5 | | #include "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <cstdint> |
8 | | #include <string> |
9 | | #include <vector> |
10 | | |
11 | | class cmExprParserHelper |
12 | | { |
13 | | public: |
14 | | struct ParserType |
15 | | { |
16 | | std::int64_t Number; |
17 | | }; |
18 | | |
19 | | cmExprParserHelper(); |
20 | | ~cmExprParserHelper(); |
21 | | |
22 | | int ParseString(char const* str, int verb); |
23 | | |
24 | | int LexInput(char* buf, int maxlen); |
25 | | void Error(char const* str); |
26 | | void Warning(std::string str); |
27 | | |
28 | | void SetResult(std::int64_t value); |
29 | | |
30 | 1.41k | std::int64_t GetResult() const { return this->Result; } |
31 | | |
32 | 1.41k | char const* GetError() { return this->ErrorString.c_str(); } |
33 | | |
34 | | void UnexpectedChar(char c); |
35 | | |
36 | 1.41k | std::string const& GetWarning() const { return this->WarningString; } |
37 | | |
38 | | std::int64_t ShL(std::int64_t l, std::int64_t r); |
39 | | std::int64_t ShR(std::int64_t l, std::int64_t r); |
40 | | std::int64_t Add(std::int64_t l, std::int64_t r); |
41 | | std::int64_t Sub(std::int64_t l, std::int64_t r); |
42 | | std::int64_t Mul(std::int64_t l, std::int64_t r); |
43 | | std::int64_t Div(std::int64_t l, std::int64_t r); |
44 | | std::int64_t Mod(std::int64_t l, std::int64_t r); |
45 | | std::int64_t Neg(std::int64_t x); |
46 | | |
47 | | static bool AddOverflow(long l, long r, long* p); |
48 | | static bool AddOverflow(long long l, long long r, long long* p); |
49 | | static bool SubOverflow(long l, long r, long* p); |
50 | | static bool SubOverflow(long long l, long long r, long long* p); |
51 | | static bool MulOverflow(long l, long r, long* p); |
52 | | static bool MulOverflow(long long l, long long r, long long* p); |
53 | | |
54 | | private: |
55 | | std::string::size_type InputBufferPos; |
56 | | std::string InputBuffer; |
57 | | std::vector<char> OutputBuffer; |
58 | | int CurrentLine; |
59 | | int Verbose; |
60 | | |
61 | | void Print(char const* place, char const* str); |
62 | | |
63 | | void SetError(std::string errorString); |
64 | | |
65 | | std::int64_t Result; |
66 | | char const* FileName; |
67 | | long FileLine; |
68 | | std::string ErrorString; |
69 | | std::string WarningString; |
70 | | }; |
71 | | |
72 | 7.09k | #define YYSTYPE cmExprParserHelper::ParserType |
73 | | #define YYSTYPE_IS_DECLARED |
74 | | #define YY_EXTRA_TYPE cmExprParserHelper* |
75 | | #define YY_DECL int cmExpr_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) |