@@ -68,6 +68,11 @@ namespace YAML
6868 FetchArg,
6969 OpenBrace,
7070 CloseBrace,
71+ Exclamation,
72+ Caret,
73+ Asterisk,
74+ Tilde,
75+ Comma,
7176 };
7277 /* when adding a new token, also add to:
7378 - MapETokenName
@@ -92,17 +97,15 @@ namespace YAML
9297 None = 0 ,
9398 Key,
9499 Index,
95- SeqMapFilter,
96- KeyList,
100+ MapFilter,
97101 };
98102
99103 // Data for different selector types
100104 struct ArgNull {};
101105 struct ArgKey { PathArg key; };
102106 struct ArgIndex { size_t index; };
103- struct ArgKVPair { PathArg key; std::optional<PathArg> value; }; // used in some selectors
104- using ArgSeqMapFilter = ArgKVPair;
105- using ArgKeyList = std::vector<ArgKVPair>;
107+ struct ArgKVPair { KVToken key; KVToken value; EKVOp op = EKVOp::Equal; };
108+ using ArgMapFilter = std::vector<ArgKVPair>;
106109
107110 /* * \internal progressive scanner/parser for a YAML path as specified by YAML::Select
108111 This class implements two layers of the scan:
@@ -120,7 +123,7 @@ namespace YAML
120123 class PathScanner
121124 {
122125 public:
123- using tSelectorData = std::variant<ArgNull, ArgKey, ArgIndex, ArgSeqMapFilter >; // /< union of the selector data for all selector types
126+ using tSelectorData = std::variant<ArgNull, ArgKey, ArgIndex, ArgMapFilter >; // /< union of the selector data for all selector types
124127
125128 private:
126129 PathArg m_rpath; // remainder of path to be scanned
@@ -151,6 +154,8 @@ namespace YAML
151154
152155 void SkipWS ();
153156 bool NextSelectorToken (uint64_t validTokens, EPathError error = EPathError::InvalidToken);
157+ bool PeekSelectorToken (uint64_t validTokens);
158+ bool ReadKVToken (KVToken & result, uint64_t endTokens);
154159
155160 public:
156161 PathScanner (PathArg p, PathBoundArgs args = {}, PathException * diags = nullptr );
@@ -178,6 +183,14 @@ namespace YAML
178183
179184 inline static const uint64_t ValidTokensAtStart = BitsOf({ EToken::FetchArg, EToken::None, EToken::OpenBracket, EToken::OpenBrace, EToken::QuotedIdentifier, EToken::UnquotedIdentifier });
180185 };
186+
187+ template <typename T2, typename TEnum>
188+ T2 MapValue (TEnum value, std::initializer_list<std::pair<TEnum, T2>> values, T2 dflt = T2());
189+
190+ extern std::initializer_list<std::pair<EToken, char const *>> MapETokenName;
191+ extern std::initializer_list<std::pair<NodeType::value, char const *>> MapNodeTypeName;
192+ extern std::initializer_list<std::pair<ESelector, char const *>> MapESelectorName;
193+ extern std::initializer_list<std::pair<EPathError, char const *>> MapEPathErrorName;
181194 }
182195}
183196
@@ -211,5 +224,16 @@ namespace YAML
211224 return ((TBits (1 ) << TBits (v)) & bits) != 0 ;
212225 }
213226
227+ // / \internal helper to map enum values to names, used for diagnostics
228+ template <typename T2, typename TEnum>
229+ T2 MapValue (TEnum value, std::initializer_list<std::pair<TEnum, T2>> values, T2 dflt)
230+ {
231+ for (auto && p : values)
232+ if (p.first == value)
233+ return p.second ;
234+ return dflt;
235+ }
236+
237+
214238 }
215239}
0 commit comments