redsnow 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/ext/snowcrash/bin/snowcrash +0 -0
- data/ext/snowcrash/snowcrash.xcworkspace/contents.xcworkspacedata +10 -0
- data/ext/snowcrash/src/ActionParser.h +35 -33
- data/ext/snowcrash/src/AssetParser.h +17 -17
- data/ext/snowcrash/src/Blueprint.h +101 -66
- data/ext/snowcrash/src/BlueprintParser.h +219 -10
- data/ext/snowcrash/src/BlueprintSourcemap.h +1 -1
- data/ext/snowcrash/src/BlueprintUtility.h +14 -14
- data/ext/snowcrash/src/CBlueprint.cc +29 -10
- data/ext/snowcrash/src/CBlueprint.h +19 -3
- data/ext/snowcrash/src/CBlueprintSourcemap.cc +20 -10
- data/ext/snowcrash/src/CBlueprintSourcemap.h +12 -3
- data/ext/snowcrash/src/CodeBlockUtility.h +25 -25
- data/ext/snowcrash/src/HTTP.cc +3 -0
- data/ext/snowcrash/src/HTTP.h +9 -6
- data/ext/snowcrash/src/HeadersParser.h +34 -14
- data/ext/snowcrash/src/ParameterParser.h +21 -21
- data/ext/snowcrash/src/ParametersParser.h +6 -5
- data/ext/snowcrash/src/PayloadParser.h +174 -129
- data/ext/snowcrash/src/RegexMatch.h +3 -3
- data/ext/snowcrash/src/ResourceGroupParser.h +5 -4
- data/ext/snowcrash/src/ResourceParser.h +30 -26
- data/ext/snowcrash/src/Section.cc +6 -6
- data/ext/snowcrash/src/Section.h +2 -2
- data/ext/snowcrash/src/SectionParser.h +41 -41
- data/ext/snowcrash/src/SectionParserData.h +10 -10
- data/ext/snowcrash/src/SectionProcessor.h +70 -30
- data/ext/snowcrash/src/Serialize.h +3 -3
- data/ext/snowcrash/src/SerializeJSON.cc +124 -96
- data/ext/snowcrash/src/SerializeJSON.h +1 -1
- data/ext/snowcrash/src/SerializeYAML.cc +71 -53
- data/ext/snowcrash/src/SerializeYAML.h +1 -1
- data/ext/snowcrash/src/Signature.cc +2 -2
- data/ext/snowcrash/src/Signature.h +1 -1
- data/ext/snowcrash/src/SourceAnnotation.h +23 -23
- data/ext/snowcrash/src/StringUtility.h +71 -9
- data/ext/snowcrash/src/SymbolTable.h +17 -17
- data/ext/snowcrash/src/UriTemplateParser.cc +5 -5
- data/ext/snowcrash/src/UriTemplateParser.h +9 -9
- data/ext/snowcrash/src/ValuesParser.h +2 -2
- data/ext/snowcrash/src/Version.h +1 -1
- data/ext/snowcrash/src/csnowcrash.cc +10 -8
- data/ext/snowcrash/src/snowcrash.cc +9 -9
- data/ext/snowcrash/src/snowcrash.h +6 -8
- data/ext/snowcrash/src/snowcrash/snowcrash.cc +14 -14
- data/ext/snowcrash/src/win/RegexMatch.cc +7 -7
- data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
- data/ext/snowcrash/tools/homebrew/snowcrash.rb +1 -1
- data/lib/redsnow/binding.rb +8 -2
- data/lib/redsnow/blueprint.rb +4 -3
- data/lib/redsnow/sourcemap.rb +6 -4
- data/lib/redsnow/version.rb +1 -1
- metadata +4 -17
@@ -17,13 +17,13 @@ namespace snowcrash {
|
|
17
17
|
// Perform snowcrash-specific regex evaluation
|
18
18
|
// returns true if target string matches given expression, false otherwise
|
19
19
|
bool RegexMatch(const std::string& target, const std::string& expression);
|
20
|
-
|
20
|
+
|
21
21
|
// Performs posix-regex and returns first captured group (excluding whole target)
|
22
22
|
std::string RegexCaptureFirst(const std::string& target, const std::string& expression);
|
23
|
-
|
23
|
+
|
24
24
|
// Array of capture groups
|
25
25
|
typedef std::vector<std::string> CaptureGroups;
|
26
|
-
|
26
|
+
|
27
27
|
// Performs posix-regex
|
28
28
|
// returns true if target string matches given expression, false otherwise
|
29
29
|
bool RegexCapture(const std::string& target, const std::string& expression, CaptureGroups& captureGroups, size_t groupSize = 8);
|
@@ -33,7 +33,7 @@ namespace snowcrash {
|
|
33
33
|
const MarkdownNodes& siblings,
|
34
34
|
SectionParserData& pd,
|
35
35
|
SectionLayout& layout,
|
36
|
-
|
36
|
+
const ParseResultRef<ResourceGroup>& out) {
|
37
37
|
|
38
38
|
MarkdownNodeIterator cur = node;
|
39
39
|
SectionType nestedType = nestedSectionType(cur);
|
@@ -61,11 +61,12 @@ namespace snowcrash {
|
|
61
61
|
static MarkdownNodeIterator processNestedSection(const MarkdownNodeIterator& node,
|
62
62
|
const MarkdownNodes& siblings,
|
63
63
|
SectionParserData& pd,
|
64
|
-
|
64
|
+
const ParseResultRef<ResourceGroup>& out) {
|
65
65
|
|
66
66
|
if (pd.sectionContext() == ResourceSectionType) {
|
67
67
|
|
68
|
-
|
68
|
+
IntermediateParseResult<Resource> resource(out.report);
|
69
|
+
|
69
70
|
MarkdownNodeIterator cur = ResourceParser::parse(node, siblings, pd, resource);
|
70
71
|
|
71
72
|
ResourceIterator duplicate = SectionProcessor<Resource>::findResource(out.node.resources, resource.node);
|
@@ -101,7 +102,7 @@ namespace snowcrash {
|
|
101
102
|
const MarkdownNodes& siblings,
|
102
103
|
SectionParserData& pd,
|
103
104
|
SectionType& lastSectionType,
|
104
|
-
|
105
|
+
const ParseResultRef<ResourceGroup>& out) {
|
105
106
|
|
106
107
|
if (SectionProcessor<Action>::actionType(node) == DependentActionType &&
|
107
108
|
!out.node.resources.empty()) {
|
@@ -17,10 +17,10 @@
|
|
17
17
|
#include "RegexMatch.h"
|
18
18
|
|
19
19
|
namespace snowcrash {
|
20
|
-
|
20
|
+
|
21
21
|
/** Nameless resource matching regex */
|
22
22
|
const char* const ResourceHeaderRegex = "^[[:blank:]]*(" HTTP_REQUEST_METHOD "[[:blank:]]+)?" URI_TEMPLATE "$";
|
23
|
-
|
23
|
+
|
24
24
|
/** Named resource matching regex */
|
25
25
|
const char* const NamedResourceHeaderRegex = "^[[:blank:]]*" SYMBOL_IDENTIFIER "[[:blank:]]+\\[" URI_TEMPLATE "]$";
|
26
26
|
|
@@ -37,7 +37,7 @@ namespace snowcrash {
|
|
37
37
|
const MarkdownNodes& siblings,
|
38
38
|
SectionParserData& pd,
|
39
39
|
SectionLayout& layout,
|
40
|
-
|
40
|
+
const ParseResultRef<Resource>& out) {
|
41
41
|
|
42
42
|
CaptureGroups captureGroups;
|
43
43
|
|
@@ -49,7 +49,8 @@ namespace snowcrash {
|
|
49
49
|
// Make this section an action
|
50
50
|
if (!captureGroups[2].empty()) {
|
51
51
|
|
52
|
-
|
52
|
+
IntermediateParseResult<Action> action(out.report);
|
53
|
+
|
53
54
|
MarkdownNodeIterator cur = ActionParser::parse(node, node->parent().children(), pd, action);
|
54
55
|
|
55
56
|
out.node.actions.push_back(action.node);
|
@@ -85,7 +86,7 @@ namespace snowcrash {
|
|
85
86
|
static MarkdownNodeIterator processNestedSection(const MarkdownNodeIterator& node,
|
86
87
|
const MarkdownNodes& siblings,
|
87
88
|
SectionParserData& pd,
|
88
|
-
|
89
|
+
const ParseResultRef<Resource>& out) {
|
89
90
|
|
90
91
|
switch (pd.sectionContext()) {
|
91
92
|
case ActionSectionType:
|
@@ -100,7 +101,7 @@ namespace snowcrash {
|
|
100
101
|
|
101
102
|
case HeadersSectionType:
|
102
103
|
{
|
103
|
-
|
104
|
+
ParseResultRef<Headers> headers(out.report, out.node.headers, out.sourceMap.headers);
|
104
105
|
return SectionProcessor<Action>::handleDeprecatedHeaders(node, siblings, pd, headers);
|
105
106
|
}
|
106
107
|
|
@@ -110,18 +111,18 @@ namespace snowcrash {
|
|
110
111
|
|
111
112
|
return node;
|
112
113
|
}
|
113
|
-
|
114
|
+
|
114
115
|
static MarkdownNodeIterator processUnexpectedNode(const MarkdownNodeIterator& node,
|
115
116
|
const MarkdownNodes& siblings,
|
116
117
|
SectionParserData& pd,
|
117
118
|
SectionType& sectionType,
|
118
|
-
|
119
|
-
|
119
|
+
const ParseResultRef<Resource>& out) {
|
120
|
+
|
120
121
|
if ((node->type == mdp::ParagraphMarkdownNodeType ||
|
121
122
|
node->type == mdp::CodeMarkdownNodeType) &&
|
122
123
|
(sectionType == ModelBodySectionType ||
|
123
124
|
sectionType == ModelSectionType)) {
|
124
|
-
|
125
|
+
|
125
126
|
mdp::ByteBuffer content = CodeBlockUtility::addDanglingAsset(node, pd, sectionType, out.report, out.node.model.body);
|
126
127
|
|
127
128
|
if (pd.exportSourceMap() && !content.empty()) {
|
@@ -130,7 +131,7 @@ namespace snowcrash {
|
|
130
131
|
|
131
132
|
// Update model in the symbol table as well
|
132
133
|
ResourceModelSymbolTable::iterator it = pd.symbolTable.resourceModels.find(out.node.model.name);
|
133
|
-
|
134
|
+
|
134
135
|
if (it != pd.symbolTable.resourceModels.end()) {
|
135
136
|
it->second.body = out.node.model.body;
|
136
137
|
|
@@ -138,20 +139,20 @@ namespace snowcrash {
|
|
138
139
|
pd.symbolSourceMapTable.resourceModels[out.node.model.name].body = out.sourceMap.model.body;
|
139
140
|
}
|
140
141
|
}
|
141
|
-
|
142
|
+
|
142
143
|
return ++MarkdownNodeIterator(node);
|
143
144
|
}
|
144
|
-
|
145
|
+
|
145
146
|
return SectionProcessorBase<Resource>::processUnexpectedNode(node, siblings, pd, sectionType, out);
|
146
147
|
}
|
147
|
-
|
148
|
+
|
148
149
|
static bool isDescriptionNode(const MarkdownNodeIterator& node,
|
149
150
|
SectionType sectionType) {
|
150
|
-
|
151
|
+
|
151
152
|
if (SectionProcessor<Action>::actionType(node) == CompleteActionType) {
|
152
153
|
return false;
|
153
154
|
}
|
154
|
-
|
155
|
+
|
155
156
|
return SectionProcessorBase<Resource>::isDescriptionNode(node, sectionType);
|
156
157
|
}
|
157
158
|
|
@@ -205,12 +206,12 @@ namespace snowcrash {
|
|
205
206
|
nestedType = SectionProcessor<Action>::sectionType(node);
|
206
207
|
|
207
208
|
if (nestedType == ActionSectionType) {
|
208
|
-
|
209
|
+
|
209
210
|
// Do not consider complete actions as nested
|
210
211
|
mdp::ByteBuffer method;
|
211
212
|
if (SectionProcessor<Action>::actionType(node) == CompleteActionType)
|
212
213
|
return UndefinedSectionType;
|
213
|
-
|
214
|
+
|
214
215
|
return nestedType;
|
215
216
|
}
|
216
217
|
|
@@ -233,7 +234,7 @@ namespace snowcrash {
|
|
233
234
|
|
234
235
|
static void finalize(const MarkdownNodeIterator& node,
|
235
236
|
SectionParserData& pd,
|
236
|
-
|
237
|
+
const ParseResultRef<Resource>& out) {
|
237
238
|
|
238
239
|
if (!out.node.uriTemplate.empty()) {
|
239
240
|
|
@@ -273,9 +274,10 @@ namespace snowcrash {
|
|
273
274
|
static MarkdownNodeIterator processAction(const MarkdownNodeIterator& node,
|
274
275
|
const MarkdownNodes& siblings,
|
275
276
|
SectionParserData& pd,
|
276
|
-
|
277
|
+
const ParseResultRef<Resource>& out) {
|
278
|
+
|
279
|
+
IntermediateParseResult<Action> action(out.report);
|
277
280
|
|
278
|
-
ParseResult<Action> action(out.report);
|
279
281
|
MarkdownNodeIterator cur = ActionParser::parse(node, siblings, pd, action);
|
280
282
|
|
281
283
|
ActionIterator duplicate = SectionProcessor<Action>::findAction(out.node.actions, action.node);
|
@@ -311,9 +313,10 @@ namespace snowcrash {
|
|
311
313
|
static MarkdownNodeIterator processParameters(const MarkdownNodeIterator& node,
|
312
314
|
const MarkdownNodes& siblings,
|
313
315
|
SectionParserData& pd,
|
314
|
-
|
316
|
+
const ParseResultRef<Resource>& out) {
|
317
|
+
|
318
|
+
IntermediateParseResult<Parameters> parameters(out.report);
|
315
319
|
|
316
|
-
ParseResult<Parameters> parameters(out.report);
|
317
320
|
MarkdownNodeIterator cur = ParametersParser::parse(node, siblings, pd, parameters);
|
318
321
|
|
319
322
|
if (!parameters.node.empty()) {
|
@@ -335,9 +338,10 @@ namespace snowcrash {
|
|
335
338
|
static MarkdownNodeIterator processModel(const MarkdownNodeIterator& node,
|
336
339
|
const MarkdownNodes& siblings,
|
337
340
|
SectionParserData& pd,
|
338
|
-
|
341
|
+
const ParseResultRef<Resource>& out) {
|
342
|
+
|
343
|
+
IntermediateParseResult<Payload> model(out.report);
|
339
344
|
|
340
|
-
ParseResult<Payload> model(out.report);
|
341
345
|
MarkdownNodeIterator cur = PayloadParser::parse(node, siblings, pd, model);
|
342
346
|
|
343
347
|
// Check whether there isn't a model already
|
@@ -417,7 +421,7 @@ namespace snowcrash {
|
|
417
421
|
static void checkParametersEligibility(const MarkdownNodeIterator& node,
|
418
422
|
const SectionParserData& pd,
|
419
423
|
Parameters& parameters,
|
420
|
-
|
424
|
+
const ParseResultRef<Resource>& out) {
|
421
425
|
|
422
426
|
for (ParameterIterator it = parameters.begin();
|
423
427
|
it != parameters.end();
|
@@ -16,26 +16,26 @@ std::string snowcrash::SectionName(const SectionType& section) {
|
|
16
16
|
case ModelSectionType:
|
17
17
|
case ModelBodySectionType:
|
18
18
|
return "model";
|
19
|
-
|
19
|
+
|
20
20
|
case RequestSectionType:
|
21
21
|
case RequestBodySectionType:
|
22
22
|
return "request";
|
23
|
-
|
23
|
+
|
24
24
|
case ResponseSectionType:
|
25
25
|
case ResponseBodySectionType:
|
26
26
|
return "response";
|
27
|
-
|
27
|
+
|
28
28
|
case BodySectionType:
|
29
29
|
case DanglingBodySectionType:
|
30
30
|
return "message-body";
|
31
|
-
|
31
|
+
|
32
32
|
case SchemaSectionType:
|
33
33
|
case DanglingSchemaSectionType:
|
34
34
|
return "message-schema";
|
35
|
-
|
35
|
+
|
36
36
|
case HeadersSectionType:
|
37
37
|
return "headers";
|
38
|
-
|
38
|
+
|
39
39
|
default:
|
40
40
|
return "section";
|
41
41
|
}
|
data/ext/snowcrash/src/Section.h
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
#include <string>
|
13
13
|
|
14
14
|
namespace snowcrash {
|
15
|
-
|
15
|
+
|
16
16
|
/**
|
17
17
|
* API Blueprint Sections Types.
|
18
18
|
*/
|
@@ -39,7 +39,7 @@ namespace snowcrash {
|
|
39
39
|
ValuesSectionType, /// < Value enumeration
|
40
40
|
ValueSectionType /// < One Value
|
41
41
|
};
|
42
|
-
|
42
|
+
|
43
43
|
/** \return Human readable name for given %SectionType */
|
44
44
|
extern std::string SectionName(const SectionType& section);
|
45
45
|
}
|
@@ -22,7 +22,7 @@ namespace snowcrash {
|
|
22
22
|
template<typename T, typename Adapter>
|
23
23
|
struct SectionParser {
|
24
24
|
|
25
|
-
|
25
|
+
|
26
26
|
/**
|
27
27
|
* \brief Parse a section of blueprint
|
28
28
|
* \param node Initial node to start parsing at
|
@@ -34,12 +34,12 @@ namespace snowcrash {
|
|
34
34
|
static MarkdownNodeIterator parse(const MarkdownNodeIterator& node,
|
35
35
|
const MarkdownNodes& siblings,
|
36
36
|
SectionParserData& pd,
|
37
|
-
|
38
|
-
|
37
|
+
const ParseResultRef<T>& out) {
|
38
|
+
|
39
39
|
SectionLayout layout = DefaultSectionLayout;
|
40
40
|
MarkdownNodeIterator cur = Adapter::startingNode(node);
|
41
41
|
const MarkdownNodes& collection = Adapter::startingNodeSiblings(node, siblings);
|
42
|
-
|
42
|
+
|
43
43
|
// Signature node
|
44
44
|
MarkdownNodeIterator lastCur = cur;
|
45
45
|
cur = SectionProcessor<T>::processSignature(cur, collection, pd, layout, out);
|
@@ -48,45 +48,45 @@ namespace snowcrash {
|
|
48
48
|
if (layout == ExclusiveNestedSectionLayout) {
|
49
49
|
|
50
50
|
cur = parseNestedSections(cur, collection, pd, out);
|
51
|
-
|
51
|
+
|
52
52
|
SectionProcessor<T>::finalize(node, pd, out);
|
53
|
-
|
53
|
+
|
54
54
|
return Adapter::nextStartingNode(node, siblings, cur);
|
55
55
|
}
|
56
|
-
|
56
|
+
|
57
57
|
// Parser redirect layout
|
58
58
|
if (layout == RedirectSectionLayout) {
|
59
59
|
SectionProcessor<T>::finalize(node, pd, out);
|
60
|
-
|
60
|
+
|
61
61
|
return Adapter::nextStartingNode(node, siblings, cur);
|
62
62
|
}
|
63
63
|
|
64
64
|
// Default layout
|
65
65
|
if (lastCur == cur)
|
66
66
|
return Adapter::nextStartingNode(node, siblings, cur);
|
67
|
-
|
67
|
+
|
68
68
|
// Description nodes
|
69
69
|
while(cur != collection.end() &&
|
70
70
|
SectionProcessor<T>::isDescriptionNode(cur, pd.sectionContext())) {
|
71
|
-
|
71
|
+
|
72
72
|
lastCur = cur;
|
73
73
|
cur = SectionProcessor<T>::processDescription(cur, collection, pd, out);
|
74
74
|
|
75
75
|
if (lastCur == cur)
|
76
76
|
return Adapter::nextStartingNode(node, siblings, cur);
|
77
77
|
}
|
78
|
-
|
78
|
+
|
79
79
|
// Content nodes
|
80
80
|
while(cur != collection.end() &&
|
81
81
|
SectionProcessor<T>::isContentNode(cur, pd.sectionContext())) {
|
82
|
-
|
82
|
+
|
83
83
|
lastCur = cur;
|
84
84
|
cur = SectionProcessor<T>::processContent(cur, collection, pd, out);
|
85
85
|
|
86
86
|
if (lastCur == cur)
|
87
87
|
return Adapter::nextStartingNode(node, siblings, cur);
|
88
88
|
}
|
89
|
-
|
89
|
+
|
90
90
|
// Nested Sections
|
91
91
|
cur = parseNestedSections(cur, collection, pd, out);
|
92
92
|
|
@@ -94,27 +94,27 @@ namespace snowcrash {
|
|
94
94
|
|
95
95
|
return Adapter::nextStartingNode(node, siblings, cur);
|
96
96
|
}
|
97
|
-
|
98
|
-
|
97
|
+
|
98
|
+
|
99
99
|
/** Parse nested sections */
|
100
100
|
static MarkdownNodeIterator parseNestedSections(const MarkdownNodeIterator& node,
|
101
101
|
const MarkdownNodes& collection,
|
102
102
|
SectionParserData& pd,
|
103
|
-
|
103
|
+
const ParseResultRef<T>& out) {
|
104
104
|
|
105
105
|
MarkdownNodeIterator cur = node;
|
106
106
|
MarkdownNodeIterator lastCur = cur;
|
107
|
-
|
107
|
+
|
108
108
|
SectionType lastSectionType = UndefinedSectionType;
|
109
|
-
|
109
|
+
|
110
110
|
// Nested sections
|
111
111
|
while(cur != collection.end()) {
|
112
|
-
|
112
|
+
|
113
113
|
lastCur = cur;
|
114
114
|
SectionType nestedType = SectionProcessor<T>::nestedSectionType(cur);
|
115
|
-
|
115
|
+
|
116
116
|
pd.sectionsContext.push_back(nestedType);
|
117
|
-
|
117
|
+
|
118
118
|
if (nestedType != UndefinedSectionType) {
|
119
119
|
cur = SectionProcessor<T>::processNestedSection(cur, collection, pd, out);
|
120
120
|
}
|
@@ -123,50 +123,50 @@ namespace snowcrash {
|
|
123
123
|
|
124
124
|
cur = SectionProcessor<T>::processUnexpectedNode(cur, collection, pd, lastSectionType, out);
|
125
125
|
}
|
126
|
-
|
126
|
+
|
127
127
|
if (cur != collection.end() &&
|
128
128
|
(pd.sectionContext() != UndefinedSectionType ||
|
129
129
|
(cur->type != mdp::ParagraphMarkdownNodeType &&
|
130
130
|
cur->type != mdp::CodeMarkdownNodeType))) {
|
131
|
-
|
131
|
+
|
132
132
|
lastSectionType = pd.sectionContext();
|
133
133
|
}
|
134
|
-
|
134
|
+
|
135
135
|
pd.sectionsContext.pop_back();
|
136
|
-
|
136
|
+
|
137
137
|
if (lastCur == cur)
|
138
138
|
break;
|
139
139
|
}
|
140
|
-
|
140
|
+
|
141
141
|
return cur;
|
142
142
|
}
|
143
143
|
};
|
144
|
-
|
144
|
+
|
145
145
|
/** Parser Adapter for parsing header-defined sections */
|
146
146
|
struct HeaderSectionAdapter {
|
147
|
-
|
147
|
+
|
148
148
|
/** \return Node to start parsing with */
|
149
149
|
static const MarkdownNodeIterator startingNode(const MarkdownNodeIterator& seed) {
|
150
150
|
if (seed->type != mdp::HeaderMarkdownNodeType)
|
151
151
|
throw ADAPTER_MISMATCH_ERR;
|
152
|
-
|
152
|
+
|
153
153
|
return seed;
|
154
154
|
}
|
155
|
-
|
155
|
+
|
156
156
|
/** \return Collection of siblings to starting Node */
|
157
157
|
static const MarkdownNodes& startingNodeSiblings(const MarkdownNodeIterator& seed,
|
158
158
|
const MarkdownNodes& siblings) {
|
159
159
|
return siblings;
|
160
160
|
}
|
161
|
-
|
161
|
+
|
162
162
|
/** \return Starting node for next parsing */
|
163
163
|
static const MarkdownNodeIterator nextStartingNode(const MarkdownNodeIterator& seed,
|
164
164
|
const MarkdownNodes& siblings,
|
165
165
|
const MarkdownNodeIterator& cur) {
|
166
166
|
return cur;
|
167
167
|
}
|
168
|
-
|
169
|
-
/**
|
168
|
+
|
169
|
+
/**
|
170
170
|
* \brief Adapter Markdown node skipping behavior trait.
|
171
171
|
*
|
172
172
|
* Adapter trait signalizing that the adapter can possibly skip some Markdown nodes on a nextStartingNode() call.
|
@@ -174,31 +174,31 @@ namespace snowcrash {
|
|
174
174
|
*/
|
175
175
|
static const bool nextSkipsUnexpected = false;
|
176
176
|
};
|
177
|
-
|
177
|
+
|
178
178
|
/** Parser Adapter for parsing list-defined sections */
|
179
179
|
struct ListSectionAdapter {
|
180
|
-
|
180
|
+
|
181
181
|
static const MarkdownNodeIterator startingNode(const MarkdownNodeIterator& seed) {
|
182
182
|
if (seed->type != mdp::ListItemMarkdownNodeType)
|
183
183
|
throw ADAPTER_MISMATCH_ERR;
|
184
|
-
|
184
|
+
|
185
185
|
return seed->children().begin();
|
186
186
|
}
|
187
|
-
|
187
|
+
|
188
188
|
static const MarkdownNodes& startingNodeSiblings(const MarkdownNodeIterator& seed,
|
189
189
|
const MarkdownNodes& siblings) {
|
190
190
|
return seed->children();
|
191
191
|
}
|
192
|
-
|
192
|
+
|
193
193
|
static const MarkdownNodeIterator nextStartingNode(const MarkdownNodeIterator& seed,
|
194
194
|
const MarkdownNodes& siblings,
|
195
195
|
const MarkdownNodeIterator& cur) {
|
196
196
|
if (seed == siblings.end())
|
197
197
|
return seed;
|
198
|
-
|
198
|
+
|
199
199
|
return ++MarkdownNodeIterator(seed);
|
200
200
|
}
|
201
|
-
|
201
|
+
|
202
202
|
static const bool nextSkipsUnexpected = true;
|
203
203
|
};
|
204
204
|
|
@@ -222,7 +222,7 @@ namespace snowcrash {
|
|
222
222
|
const MarkdownNodeIterator& cur) {
|
223
223
|
return cur;
|
224
224
|
}
|
225
|
-
|
225
|
+
|
226
226
|
static const bool nextSkipsUnexpected = false;
|
227
227
|
};
|
228
228
|
}
|