• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HC_GEN_TOKEN_H
10 #define HC_GEN_TOKEN_H
11 
12 #include <memory>
13 #include <ostream>
14 #include <string>
15 
16 namespace OHOS {
17 namespace Hardware {
18 
19 enum TokenType {
20     NUMBER = 256,
21     TEMPLATE,
22     LITERAL,
23     STRING,
24     REF_PATH,
25     FILE_PATH,
26     ROOT,
27     INCLUDE,
28     DELETE,
29 };
30 
31 struct Token {
32     int32_t type;
33     std::string strval;
34     uint64_t numval;
35     std::shared_ptr<std::string> src;
36     int32_t lineNo;
37 
38     Token();
39     bool operator==(const Token &token) const;
40     bool operator!=(const Token &token) const;
41     bool operator==(int32_t otherType) const;
42     bool operator!=(int32_t otherType) const;
43     friend std::ostream &operator<<(std::ostream &stream, const Token &token);
44 };
45 
46 std::ostream &operator<<(std::ostream &stream, const Token &token);
47 std::string TokenType2String(int32_t type);
48 } // namespace Hardware
49 } // namespace OHOS
50 
51 #endif // HC_GEN_TOKEN_H
52