| 21 | "ANCHOR", "ALIAS", "TAG", "SCALAR"}; |
| 22 | |
| 23 | struct Token { |
| 24 | // enums |
| 25 | enum STATUS { VALID, INVALID, UNVERIFIED }; |
| 26 | enum TYPE { |
| 27 | DIRECTIVE, |
| 28 | DOC_START, |
| 29 | DOC_END, |
| 30 | BLOCK_SEQ_START, |
| 31 | BLOCK_MAP_START, |
| 32 | BLOCK_SEQ_END, |
| 33 | BLOCK_MAP_END, |
| 34 | BLOCK_ENTRY, |
| 35 | FLOW_SEQ_START, |
| 36 | FLOW_MAP_START, |
| 37 | FLOW_SEQ_END, |
| 38 | FLOW_MAP_END, |
| 39 | FLOW_MAP_COMPACT, |
| 40 | FLOW_ENTRY, |
| 41 | KEY, |
| 42 | VALUE, |
| 43 | ANCHOR, |
| 44 | ALIAS, |
| 45 | TAG, |
| 46 | PLAIN_SCALAR, |
| 47 | NON_PLAIN_SCALAR |
| 48 | }; |
| 49 | |
| 50 | // data |
| 51 | Token(TYPE type_, const Mark& mark_) |
| 52 | : status(VALID), type(type_), mark(mark_), value{}, params{}, data(0) {} |
| 53 | |
| 54 | friend std::ostream& operator<<(std::ostream& out, const Token& token) { |
| 55 | out << TokenNames[token.type] << std::string(": ") << token.value; |
| 56 | for (const std::string& param : token.params) |
| 57 | out << std::string(" ") << param; |
| 58 | return out; |
| 59 | } |
| 60 | |
| 61 | STATUS status; |
| 62 | TYPE type; |
| 63 | Mark mark; |
| 64 | std::string value; |
| 65 | std::vector<std::string> params; |
| 66 | int data; |
| 67 | }; |
| 68 | } // namespace YAML |
| 69 | |
| 70 | #endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |