1 #ifndef EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
16 ////////////////////////////////////////////////////////////////////////////////
17 // Here we store a bunch of expressions for matching different parts of the file.
22 inline const RegEx
& Space() {
23 static const RegEx e
= RegEx(' ');
26 inline const RegEx
& Tab() {
27 static const RegEx e
= RegEx('\t');
30 inline const RegEx
& Blank() {
31 static const RegEx e
= Space() || Tab();
34 inline const RegEx
& Break() {
35 static const RegEx e
= RegEx('\n') || RegEx("\r\n");
38 inline const RegEx
& BlankOrBreak() {
39 static const RegEx e
= Blank() || Break();
42 inline const RegEx
& Digit() {
43 static const RegEx e
= RegEx('0', '9');
46 inline const RegEx
& Alpha() {
47 static const RegEx e
= RegEx('a', 'z') || RegEx('A', 'Z');
50 inline const RegEx
& AlphaNumeric() {
51 static const RegEx e
= Alpha() || Digit();
54 inline const RegEx
& Word() {
55 static const RegEx e
= AlphaNumeric() || RegEx('-');
58 inline const RegEx
& Hex() {
59 static const RegEx e
= Digit() || RegEx('A', 'F') || RegEx('a', 'f');
62 // Valid Unicode code points that are not part of c-printable (YAML 1.2, sec. 5.1)
63 inline const RegEx
& NotPrintable() {
64 static const RegEx e
= RegEx(0) ||
65 RegEx("\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x7F", REGEX_OR
) ||
67 (RegEx('\xC2') + (RegEx('\x80', '\x84') || RegEx('\x86', '\x9F')));
70 inline const RegEx
& Utf8_ByteOrderMark() {
71 static const RegEx e
= RegEx("\xEF\xBB\xBF");
77 inline const RegEx
& DocStart() {
78 static const RegEx e
= RegEx("---") + (BlankOrBreak() || RegEx());
81 inline const RegEx
& DocEnd() {
82 static const RegEx e
= RegEx("...") + (BlankOrBreak() || RegEx());
85 inline const RegEx
& DocIndicator() {
86 static const RegEx e
= DocStart() || DocEnd();
89 inline const RegEx
& BlockEntry() {
90 static const RegEx e
= RegEx('-') + (BlankOrBreak() || RegEx());
93 inline const RegEx
& Key() {
94 static const RegEx e
= RegEx('?');
97 inline const RegEx
& KeyInFlow() {
98 static const RegEx e
= RegEx('?') + BlankOrBreak();
101 inline const RegEx
& Value() {
102 static const RegEx e
= RegEx(':') + (BlankOrBreak() || RegEx());
105 inline const RegEx
& ValueInFlow() {
106 static const RegEx e
= RegEx(':') + (BlankOrBreak() || RegEx(",}", REGEX_OR
));
109 inline const RegEx
& ValueInJSONFlow() {
110 static const RegEx e
= RegEx(':');
113 inline const RegEx
Comment() {
114 static const RegEx e
= RegEx('#');
117 inline const RegEx
& Anchor() {
118 static const RegEx e
= !(RegEx("[]{},", REGEX_OR
) || BlankOrBreak());
121 inline const RegEx
& AnchorEnd() {
122 static const RegEx e
= RegEx("?:,]}%@`", REGEX_OR
) || BlankOrBreak();
125 inline const RegEx
& URI() {
126 static const RegEx e
= Word() || RegEx("#;/?:@&=+$,_.!~*'()[]", REGEX_OR
) || (RegEx('%') + Hex() + Hex());
129 inline const RegEx
& Tag() {
130 static const RegEx e
= Word() || RegEx("#;/?:@&=+$_.~*'", REGEX_OR
) || (RegEx('%') + Hex() + Hex());
134 // Plain scalar rules:
135 // . Cannot start with a blank.
136 // . Can never start with any of , [ ] { } # & * ! | > \' \" % @ `
137 // . In the block context - ? : must be not be followed with a space.
138 // . In the flow context ? is illegal and : and - must not be followed with a space.
139 inline const RegEx
& PlainScalar() {
140 static const RegEx e
= !(BlankOrBreak() || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR
) || (RegEx("-?:", REGEX_OR
) + (BlankOrBreak() || RegEx())));
143 inline const RegEx
& PlainScalarInFlow() {
144 static const RegEx e
= !(BlankOrBreak() || RegEx("?,[]{}#&*!|>\'\"%@`", REGEX_OR
) || (RegEx("-:", REGEX_OR
) + Blank()));
147 inline const RegEx
& EndScalar() {
148 static const RegEx e
= RegEx(':') + (BlankOrBreak() || RegEx());
151 inline const RegEx
& EndScalarInFlow() {
152 static const RegEx e
= (RegEx(':') + (BlankOrBreak() || RegEx() || RegEx(",]}", REGEX_OR
))) || RegEx(",?[]{}", REGEX_OR
);
156 inline const RegEx
& EscSingleQuote() {
157 static const RegEx e
= RegEx("\'\'");
160 inline const RegEx
& EscBreak() {
161 static const RegEx e
= RegEx('\\') + Break();
165 inline const RegEx
& ChompIndicator() {
166 static const RegEx e
= RegEx("+-", REGEX_OR
);
169 inline const RegEx
& Chomp() {
170 static const RegEx e
= (ChompIndicator() + Digit()) || (Digit() + ChompIndicator()) || ChompIndicator() || Digit();
174 // and some functions
175 std::string
Escape(Stream
& in
);
180 const char Directive
= '%';
181 const char FlowSeqStart
= '[';
182 const char FlowSeqEnd
= ']';
183 const char FlowMapStart
= '{';
184 const char FlowMapEnd
= '}';
185 const char FlowEntry
= ',';
186 const char Alias
= '*';
187 const char Anchor
= '&';
188 const char Tag
= '!';
189 const char LiteralScalar
= '|';
190 const char FoldedScalar
= '>';
191 const char VerbatimTagStart
= '<';
192 const char VerbatimTagEnd
= '>';
196 #endif // EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66