redsnow 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/ext/snowcrash/Makefile +1 -1
- data/ext/snowcrash/bin/snowcrash +0 -0
- data/ext/snowcrash/configure +9 -9
- data/ext/snowcrash/ext/markdown-parser/Makefile +87 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/CONTRIBUTING.md +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/Makefile +2 -1
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/Makefile.win +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/examples/smartypants.c +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/examples/sundown.c +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/houdini.h +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/houdini_href_e.c +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/houdini_html_e.c +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/html.c +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/html.h +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/html_smartypants.c +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html_block_names.txt +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/autolink.c +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/autolink.h +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/buffer.c +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/buffer.h +1 -1
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/html_blocks.h +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/markdown.c +9 -3
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/markdown.h +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/src_map.c +11 -7
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/src_map.h +1 -1
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/stack.c +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/stack.h +0 -0
- data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/sundown.def +0 -0
- data/ext/snowcrash/ext/markdown-parser/msvc/markdown/markdown.vcproj +188 -0
- data/ext/snowcrash/ext/markdown-parser/msvc/msvc.sln +38 -0
- data/ext/snowcrash/ext/markdown-parser/msvc/sundown/sundown.vcproj +206 -0
- data/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.cc +92 -0
- data/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.h +82 -0
- data/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.cc +152 -0
- data/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.h +103 -0
- data/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.cc +388 -0
- data/ext/snowcrash/{src → ext/markdown-parser/src}/MarkdownParser.h +43 -33
- data/ext/snowcrash/snowcrash.gyp +114 -63
- data/ext/snowcrash/src/ActionParser.h +334 -398
- data/ext/snowcrash/src/AssetParser.h +82 -171
- data/ext/snowcrash/src/Blueprint.h +7 -2
- data/ext/snowcrash/src/BlueprintParser.h +212 -286
- data/ext/snowcrash/src/BlueprintUtility.h +2 -2
- data/ext/snowcrash/src/CBlueprint.h +1 -1
- data/ext/snowcrash/src/CSourceAnnotation.cc +11 -11
- data/ext/snowcrash/src/CSourceAnnotation.h +9 -9
- data/ext/snowcrash/src/CodeBlockUtility.h +199 -149
- data/ext/snowcrash/src/HeadersParser.h +197 -0
- data/ext/snowcrash/src/ParameterParser.h +429 -0
- data/ext/snowcrash/src/ParametersParser.h +136 -211
- data/ext/snowcrash/src/PayloadParser.h +458 -562
- data/ext/snowcrash/src/Platform.h +0 -3
- data/ext/snowcrash/src/ResourceGroupParser.h +183 -164
- data/ext/snowcrash/src/ResourceParser.h +325 -493
- data/ext/snowcrash/src/Section.cc +42 -0
- data/ext/snowcrash/src/Section.h +47 -0
- data/ext/snowcrash/src/SectionParser.h +229 -0
- data/ext/snowcrash/src/SectionParserData.h +81 -0
- data/ext/snowcrash/src/SectionProcessor.h +211 -0
- data/ext/snowcrash/src/Signature.cc +74 -0
- data/ext/snowcrash/src/Signature.h +32 -0
- data/ext/snowcrash/src/SourceAnnotation.h +7 -20
- data/ext/snowcrash/src/StringUtility.h +30 -10
- data/ext/snowcrash/src/SymbolTable.h +7 -7
- data/ext/snowcrash/src/UriTemplateParser.cc +10 -10
- data/ext/snowcrash/src/UriTemplateParser.h +11 -14
- data/ext/snowcrash/src/ValuesParser.h +122 -0
- data/ext/snowcrash/src/Version.h +2 -2
- data/ext/snowcrash/src/csnowcrash.cc +5 -5
- data/ext/snowcrash/src/csnowcrash.h +3 -3
- data/ext/snowcrash/src/snowcrash.cc +74 -4
- data/ext/snowcrash/src/snowcrash.h +9 -4
- data/ext/snowcrash/src/snowcrash/snowcrash.cc +16 -16
- data/ext/snowcrash/tools/homebrew/snowcrash.rb +3 -2
- data/ext/snowcrash/vcbuild.bat +13 -4
- data/lib/redsnow.rb +5 -5
- data/lib/redsnow/binding.rb +1 -1
- data/lib/redsnow/blueprint.rb +33 -2
- data/lib/redsnow/parseresult.rb +7 -4
- data/lib/redsnow/version.rb +1 -1
- data/test/redsnow_binding_test.rb +6 -6
- data/test/redsnow_parseresult_test.rb +1 -1
- metadata +62 -42
- data/ext/snowcrash/src/BlockUtility.h +0 -186
- data/ext/snowcrash/src/BlueprintParserCore.h +0 -190
- data/ext/snowcrash/src/BlueprintSection.h +0 -140
- data/ext/snowcrash/src/DescriptionSectionUtility.h +0 -156
- data/ext/snowcrash/src/HeaderParser.h +0 -289
- data/ext/snowcrash/src/ListBlockUtility.h +0 -273
- data/ext/snowcrash/src/ListUtility.h +0 -95
- data/ext/snowcrash/src/MarkdownBlock.cc +0 -176
- data/ext/snowcrash/src/MarkdownBlock.h +0 -93
- data/ext/snowcrash/src/MarkdownParser.cc +0 -266
- data/ext/snowcrash/src/ParameterDefinitonParser.h +0 -645
- data/ext/snowcrash/src/Parser.cc +0 -71
- data/ext/snowcrash/src/Parser.h +0 -29
- data/ext/snowcrash/src/ParserCore.cc +0 -120
- data/ext/snowcrash/src/ParserCore.h +0 -82
- data/ext/snowcrash/src/SectionUtility.h +0 -142
@@ -1,190 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// BlueprintParserCore.h
|
3
|
-
// snowcrash
|
4
|
-
//
|
5
|
-
// Created by Zdenek Nemec on 5/4/13.
|
6
|
-
// Copyright (c) 2013 Apiary Inc. All rights reserved.
|
7
|
-
//
|
8
|
-
|
9
|
-
#ifndef SNOWCRASH_BLUEPRINTPARSERCORE_H
|
10
|
-
#define SNOWCRASH_BLUEPRINTPARSERCORE_H
|
11
|
-
|
12
|
-
#include <algorithm>
|
13
|
-
#include <sstream>
|
14
|
-
#include "ParserCore.h"
|
15
|
-
#include "SourceAnnotation.h"
|
16
|
-
#include "MarkdownBlock.h"
|
17
|
-
#include "BlueprintSection.h"
|
18
|
-
#include "HTTP.h"
|
19
|
-
#include "Blueprint.h"
|
20
|
-
#include "BlueprintUtility.h"
|
21
|
-
#include "StringUtility.h"
|
22
|
-
#include "SymbolTable.h"
|
23
|
-
|
24
|
-
namespace snowcrash {
|
25
|
-
|
26
|
-
/**
|
27
|
-
* \brief Blueprint Parser Options.
|
28
|
-
*
|
29
|
-
* Controls blueprint parser behavior.
|
30
|
-
*/
|
31
|
-
enum BlueprintParserOption {
|
32
|
-
RenderDescriptionsOption = (1 << 0), /// < Render Markdown in description.
|
33
|
-
RequireBlueprintNameOption = (1 << 1) /// < Treat missing blueprint name as error
|
34
|
-
};
|
35
|
-
|
36
|
-
typedef unsigned int BlueprintParserOptions;
|
37
|
-
|
38
|
-
/**
|
39
|
-
* \brief Parsing subroutine result
|
40
|
-
*
|
41
|
-
* Consists of a parsing result report (first) and
|
42
|
-
* %BlockIterator (second) pointing to the last parsed
|
43
|
-
* markdown block.
|
44
|
-
*/
|
45
|
-
typedef std::pair<Result, BlockIterator> ParseSectionResult;
|
46
|
-
|
47
|
-
|
48
|
-
/**
|
49
|
-
* Parser Core Data
|
50
|
-
*/
|
51
|
-
struct BlueprintParserCore {
|
52
|
-
BlueprintParserCore(BlueprintParserOptions opts,
|
53
|
-
const SourceData& src,
|
54
|
-
const Blueprint& bp)
|
55
|
-
: options(opts), sourceData(src), blueprint(bp) {}
|
56
|
-
|
57
|
-
/** Parser Options */
|
58
|
-
BlueprintParserOptions options;
|
59
|
-
|
60
|
-
/** Symbol Table */
|
61
|
-
SymbolTable symbolTable;
|
62
|
-
|
63
|
-
/** Source Data */
|
64
|
-
const SourceData& sourceData;
|
65
|
-
|
66
|
-
/** AST being parsed **/
|
67
|
-
const Blueprint& blueprint;
|
68
|
-
|
69
|
-
private:
|
70
|
-
BlueprintParserCore();
|
71
|
-
BlueprintParserCore(const BlueprintParserCore&);
|
72
|
-
BlueprintParserCore& operator=(const BlueprintParserCore&);
|
73
|
-
};
|
74
|
-
|
75
|
-
/**
|
76
|
-
* SectionType Parser prototype.
|
77
|
-
*/
|
78
|
-
template<class T>
|
79
|
-
struct SectionParser {
|
80
|
-
|
81
|
-
/**
|
82
|
-
* \brief Parse section's blocks.
|
83
|
-
* \param section Actual section being parsed.
|
84
|
-
* \param cur Cursor within the section boundaries.
|
85
|
-
* \param parser Parser instance.
|
86
|
-
* \param output AST node parsed.
|
87
|
-
* \return %ParseSectionResult pointing to the last block parsed & including
|
88
|
-
* any possible source annotations in the form of results or warnings.
|
89
|
-
*/
|
90
|
-
static ParseSectionResult ParseSection(const BlueprintSection& section,
|
91
|
-
const BlockIterator& cur,
|
92
|
-
BlueprintParserCore& parser,
|
93
|
-
T& output);
|
94
|
-
|
95
|
-
/**
|
96
|
-
* \brief Optional post-parse processing.
|
97
|
-
*/
|
98
|
-
static void Finalize(const SectionBounds& bounds,
|
99
|
-
BlueprintParserCore& parser,
|
100
|
-
T& output,
|
101
|
-
Result& result);
|
102
|
-
};
|
103
|
-
|
104
|
-
/**
|
105
|
-
* \brief Internal list items classifier prototype.
|
106
|
-
*
|
107
|
-
* The classifier might look ahead.
|
108
|
-
* DO NOT provide generic implementation.
|
109
|
-
*/
|
110
|
-
template <class T>
|
111
|
-
FORCEINLINE SectionType ClassifyInternaListBlock(const BlockIterator& begin,
|
112
|
-
const BlockIterator& end);
|
113
|
-
/**
|
114
|
-
* \brief Classify a block with children list items.
|
115
|
-
*
|
116
|
-
* Classifies internal list block & descend to children list block classifiers.
|
117
|
-
* DO NOT provide generic implementation.
|
118
|
-
*/
|
119
|
-
template <class T>
|
120
|
-
FORCEINLINE SectionType ClassifyChildrenListBlock(const BlockIterator& begin,
|
121
|
-
const BlockIterator& end);
|
122
|
-
|
123
|
-
/**
|
124
|
-
* \brief Block Classifier prototype.
|
125
|
-
*
|
126
|
-
* The classifier might look ahead.
|
127
|
-
*/
|
128
|
-
template <class T>
|
129
|
-
FORCEINLINE SectionType ClassifyBlock(const BlockIterator& begin,
|
130
|
-
const BlockIterator& end,
|
131
|
-
const SectionType& context);
|
132
|
-
|
133
|
-
// Forward declaration of classifier helpers
|
134
|
-
extern bool HasResourceGroupSignature(const MarkdownBlock& block);
|
135
|
-
extern bool HasActionSignature(const MarkdownBlock& block);
|
136
|
-
extern bool HasResourceSignature(const MarkdownBlock& block);
|
137
|
-
extern bool HasPayloadSignature(const BlockIterator& begin, const BlockIterator& end);
|
138
|
-
extern bool HasPayloadAssetSignature(const BlockIterator& begin, const BlockIterator& end);
|
139
|
-
extern bool HasAssetSignature(const BlockIterator& begin, const BlockIterator& end);
|
140
|
-
extern bool HasHeaderSignature(const BlockIterator& begin, const BlockIterator& end);
|
141
|
-
extern bool HasParametersSignature(const BlockIterator& begin, const BlockIterator& end);
|
142
|
-
|
143
|
-
/**
|
144
|
-
* \brief A Markdown block parser.
|
145
|
-
*
|
146
|
-
* Iterates over blocks classifying sections and calling relevant %SectionParser P<T>.
|
147
|
-
*/
|
148
|
-
template <class T, class P>
|
149
|
-
struct BlockParser : public P {
|
150
|
-
|
151
|
-
// Iterate blocks, classify & parse
|
152
|
-
static ParseSectionResult Parse(const BlockIterator& begin,
|
153
|
-
const BlockIterator& end,
|
154
|
-
const BlueprintSection& parentSection,
|
155
|
-
BlueprintParserCore& parser,
|
156
|
-
T& output) {
|
157
|
-
Result result;
|
158
|
-
SectionType currentSectionType = UndefinedSectionType;
|
159
|
-
BlockIterator currentBlock = begin;
|
160
|
-
while (currentBlock != end) {
|
161
|
-
|
162
|
-
currentSectionType = ClassifyBlock<T>(currentBlock, end, currentSectionType);
|
163
|
-
BlueprintSection currentSection(currentSectionType, std::make_pair(begin, end), parentSection);
|
164
|
-
|
165
|
-
ParseSectionResult sectionResult = P::ParseSection(currentSection,
|
166
|
-
currentBlock,
|
167
|
-
parser,
|
168
|
-
output);
|
169
|
-
|
170
|
-
result += sectionResult.first;
|
171
|
-
if (result.error.code != Error::OK)
|
172
|
-
break;
|
173
|
-
|
174
|
-
if (sectionResult.second == currentBlock)
|
175
|
-
break;
|
176
|
-
|
177
|
-
currentBlock = sectionResult.second;
|
178
|
-
|
179
|
-
if (currentSectionType == UndefinedSectionType)
|
180
|
-
break;
|
181
|
-
}
|
182
|
-
|
183
|
-
P::Finalize(std::make_pair(begin, currentBlock), parser, output, result);
|
184
|
-
|
185
|
-
return std::make_pair(result, currentBlock);
|
186
|
-
}
|
187
|
-
};
|
188
|
-
}
|
189
|
-
|
190
|
-
#endif
|
@@ -1,140 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// BlueprintSection.h
|
3
|
-
// snowcrash
|
4
|
-
//
|
5
|
-
// Created by Zdenek Nemec on 11/1/13.
|
6
|
-
// Copyright (c) 2013 Apiary Inc. All rights reserved.
|
7
|
-
//
|
8
|
-
|
9
|
-
#ifndef SNOWCRASH_BLUEPRINTSECTION_H
|
10
|
-
#define SNOWCRASH_BLUEPRINTSECTION_H
|
11
|
-
|
12
|
-
#include "MarkdownBlock.h"
|
13
|
-
#include "Blueprint.h"
|
14
|
-
|
15
|
-
namespace snowcrash {
|
16
|
-
|
17
|
-
/**
|
18
|
-
* API Blueprint Sections Types. Block range classification.
|
19
|
-
*/
|
20
|
-
enum SectionType {
|
21
|
-
UndefinedSectionType, /// < Undefined section
|
22
|
-
BlueprintSectionType, /// < Blueprint overview
|
23
|
-
ResourceGroupSectionType, /// < Resource group
|
24
|
-
ResourceSectionType, /// < Resource
|
25
|
-
ResourceMethodSectionType, /// < Resource & Action combined (abbrev)
|
26
|
-
ActionSectionType, /// < Action
|
27
|
-
RequestSectionType, /// < Request
|
28
|
-
RequestBodySectionType, /// < Request & Payload body combined (abbrev)
|
29
|
-
ResponseSectionType, /// < Response
|
30
|
-
ResponseBodySectionType, /// < Response & Body combined (abbrev)
|
31
|
-
ObjectSectionType, /// < Object (deprecated)
|
32
|
-
ObjectBodySectionType, /// < Object & Body combined (abbrev, deprecated)
|
33
|
-
ModelSectionType, /// < Model
|
34
|
-
ModelBodySectionType, /// < Model & Body combined (abbrev)
|
35
|
-
BodySectionType, /// < Payload Body
|
36
|
-
DanglingBodySectionType, /// < Dangling Body (unrecognised section considered to be Body)
|
37
|
-
SchemaSectionType, /// < Payload Schema
|
38
|
-
DanglingSchemaSectionType, /// < Dangling Schema (unrecognised section considered to be Schema)
|
39
|
-
HeadersSectionType, /// < Headers
|
40
|
-
ForeignSectionType, /// < Foreign, unexpected section
|
41
|
-
ParametersSectionType, /// < Parameters
|
42
|
-
ParameterDefinitionSectionType, /// < One Parameter definition
|
43
|
-
ParameterValuesSectionType /// < Parameter value enumeration
|
44
|
-
};
|
45
|
-
|
46
|
-
/** \returns human readable name for given %SectionType */
|
47
|
-
FORCEINLINE std::string SectionName(const SectionType& section) {
|
48
|
-
switch (section) {
|
49
|
-
|
50
|
-
case ModelSectionType:
|
51
|
-
case ModelBodySectionType:
|
52
|
-
return "model";
|
53
|
-
|
54
|
-
case ObjectSectionType:
|
55
|
-
case ObjectBodySectionType:
|
56
|
-
return "object";
|
57
|
-
|
58
|
-
case RequestSectionType:
|
59
|
-
case RequestBodySectionType:
|
60
|
-
return "request";
|
61
|
-
|
62
|
-
case ResponseSectionType:
|
63
|
-
case ResponseBodySectionType:
|
64
|
-
return "response";
|
65
|
-
|
66
|
-
case BodySectionType:
|
67
|
-
case DanglingBodySectionType:
|
68
|
-
return "message-body";
|
69
|
-
|
70
|
-
case SchemaSectionType:
|
71
|
-
case DanglingSchemaSectionType:
|
72
|
-
return "message-schema";
|
73
|
-
|
74
|
-
case HeadersSectionType:
|
75
|
-
return "headers";
|
76
|
-
|
77
|
-
default:
|
78
|
-
return "section";
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
/** Markdown block iterator */
|
83
|
-
typedef MarkdownBlock::Stack::const_iterator BlockIterator;
|
84
|
-
|
85
|
-
/**
|
86
|
-
* \brief SectionType boundaries.
|
87
|
-
*
|
88
|
-
* A continuous range of markdown blocks <first, second).
|
89
|
-
*/
|
90
|
-
typedef std::pair<BlockIterator, BlockIterator> SectionBounds;
|
91
|
-
|
92
|
-
|
93
|
-
/**
|
94
|
-
* \brief API Blueprint Section Descriptor.
|
95
|
-
*/
|
96
|
-
class BlueprintSection {
|
97
|
-
|
98
|
-
public:
|
99
|
-
BlueprintSection(const SectionBounds& _bounds)
|
100
|
-
: type(UndefinedSectionType), bounds(_bounds), m_parent(NULL) {}
|
101
|
-
|
102
|
-
BlueprintSection(const SectionType _type,
|
103
|
-
const SectionBounds& _bounds,
|
104
|
-
const BlueprintSection& _parent)
|
105
|
-
: type(_type), bounds(_bounds), m_parent(&_parent) {}
|
106
|
-
|
107
|
-
/** Type of section */
|
108
|
-
const SectionType type;
|
109
|
-
|
110
|
-
/**
|
111
|
-
* Maximum boundaries of the section including any subsection.
|
112
|
-
*/
|
113
|
-
const SectionBounds bounds;
|
114
|
-
|
115
|
-
/**
|
116
|
-
* \return True if section's parent is specified, false otherwise.
|
117
|
-
*/
|
118
|
-
bool hasParent() const {
|
119
|
-
return (m_parent != NULL);
|
120
|
-
}
|
121
|
-
|
122
|
-
/**
|
123
|
-
* \return Parent section, throws exception if no parent is defined.
|
124
|
-
*/
|
125
|
-
const BlueprintSection& parent() const {
|
126
|
-
if (!hasParent())
|
127
|
-
throw "accessing parent of a root blueprint section";
|
128
|
-
return *m_parent;
|
129
|
-
}
|
130
|
-
|
131
|
-
private:
|
132
|
-
BlueprintSection();
|
133
|
-
BlueprintSection(const BlueprintSection&);
|
134
|
-
BlueprintSection& operator=(const BlueprintSection&);
|
135
|
-
|
136
|
-
const BlueprintSection* m_parent;
|
137
|
-
};
|
138
|
-
}
|
139
|
-
|
140
|
-
#endif
|
@@ -1,156 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// DescriptionSectionUtility.h
|
3
|
-
// snowcrash
|
4
|
-
//
|
5
|
-
// Created by Zdenek Nemec on 11/10/13.
|
6
|
-
// Copyright (c) 2013 Apiary Inc. All rights reserved.
|
7
|
-
//
|
8
|
-
|
9
|
-
#ifndef SNOWCRASH_DESCRIPTIONSECTIONUTILITY_H
|
10
|
-
#define SNOWCRASH_DESCRIPTIONSECTIONUTILITY_H
|
11
|
-
|
12
|
-
#include <sstream>
|
13
|
-
#include "MarkdownBlock.h"
|
14
|
-
#include "BlueprintParserCore.h"
|
15
|
-
#include "CodeBlockUtility.h"
|
16
|
-
|
17
|
-
namespace snowcrash {
|
18
|
-
|
19
|
-
|
20
|
-
/**
|
21
|
-
* \brief Skips to the end of the description list.
|
22
|
-
* \param begin Begin of the description list.
|
23
|
-
* \param end End of the block buffer.
|
24
|
-
* \param descriptionMap Output buffer containing skipped source map.
|
25
|
-
* \return An iterator pointing to the last block of a description list.
|
26
|
-
* Or, if one of description list items is recognized as a section, iterator
|
27
|
-
* pointing to this section.
|
28
|
-
*
|
29
|
-
* This functions checks any skipped list items for a section signature.
|
30
|
-
* If a section signature is found this function returns the first block
|
31
|
-
* of the recognized section. If no signature is found this function returns
|
32
|
-
* the last (closing) block of the description list.
|
33
|
-
*/
|
34
|
-
template <class T>
|
35
|
-
static BlockIterator SkipToDescriptionListEnd(const BlockIterator& begin,
|
36
|
-
const BlockIterator& end,
|
37
|
-
SourceDataBlock& descriptionMap) {
|
38
|
-
BlockIterator cur(begin);
|
39
|
-
if (++cur == end) // Skip leading ListBlockBeginType
|
40
|
-
return cur;
|
41
|
-
|
42
|
-
std::vector<SourceDataBlock> listItemMaps;
|
43
|
-
SectionType listItemSection = UndefinedSectionType;
|
44
|
-
BlockIterator recognizedCur = end;
|
45
|
-
|
46
|
-
while (cur != end &&
|
47
|
-
cur->type == ListItemBlockBeginType) {
|
48
|
-
|
49
|
-
// Classify list item
|
50
|
-
listItemSection = ClassifyInternaListBlock<T>(cur, end);
|
51
|
-
if (listItemSection != UndefinedSectionType) {
|
52
|
-
// Found a recognized section, record & skip to the end of the list.
|
53
|
-
recognizedCur = cur;
|
54
|
-
cur = SkipToClosingBlock(begin, end, ListBlockBeginType, ListBlockEndType);
|
55
|
-
}
|
56
|
-
else {
|
57
|
-
// Skip one list item & take note of its source map
|
58
|
-
cur = SkipToClosingBlock(cur, end, ListItemBlockBeginType, ListItemBlockEndType);
|
59
|
-
listItemMaps.push_back(cur->sourceMap);
|
60
|
-
|
61
|
-
if (cur != end)
|
62
|
-
++cur;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
// Resolve
|
67
|
-
if (listItemSection == UndefinedSectionType) {
|
68
|
-
descriptionMap = cur->sourceMap;
|
69
|
-
return cur;
|
70
|
-
}
|
71
|
-
else {
|
72
|
-
// Resolve correct description source map
|
73
|
-
descriptionMap.clear();
|
74
|
-
if (!cur->sourceMap.empty() &&
|
75
|
-
!listItemMaps.empty() &&
|
76
|
-
!listItemMaps.front().empty()) {
|
77
|
-
|
78
|
-
SourceDataRange r;
|
79
|
-
r.location = cur->sourceMap.front().location;
|
80
|
-
r.length = listItemMaps.front().front().location - r.location;
|
81
|
-
descriptionMap.push_back(r);
|
82
|
-
|
83
|
-
for (std::vector<SourceDataBlock>::iterator it = listItemMaps.begin();
|
84
|
-
it != listItemMaps.end();
|
85
|
-
++it) {
|
86
|
-
|
87
|
-
SourceDataRange gap;
|
88
|
-
gap.location = descriptionMap.back().location + descriptionMap.back().length;
|
89
|
-
gap.length = it->front().location - gap.location;
|
90
|
-
if (gap.length) {
|
91
|
-
SourceDataBlock gapBlock(1, gap);
|
92
|
-
AppendSourceDataBlock(descriptionMap, gapBlock);
|
93
|
-
}
|
94
|
-
|
95
|
-
AppendSourceDataBlock(descriptionMap, *it);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
return recognizedCur;
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
/**
|
104
|
-
* \brief Process a description block retrieving its content.
|
105
|
-
* \param section A section its block is being processed.
|
106
|
-
* \param cur Cursor to the block to process.
|
107
|
-
* \param sourceData Source data stream.
|
108
|
-
* \param output Output object to APPEND retrieved description into.
|
109
|
-
* \return Standard parser section result poinitng at the last block parsed.
|
110
|
-
*/
|
111
|
-
template <class T>
|
112
|
-
FORCEINLINE ParseSectionResult ParseDescriptionBlock(const BlueprintSection& section,
|
113
|
-
const BlockIterator& cur,
|
114
|
-
const SourceData& sourceData,
|
115
|
-
T& output) {
|
116
|
-
|
117
|
-
ParseSectionResult result = std::make_pair(Result(), cur);
|
118
|
-
BlockIterator sectionCur(cur);
|
119
|
-
|
120
|
-
if (sectionCur->type == QuoteBlockBeginType) {
|
121
|
-
sectionCur = SkipToClosingBlock(sectionCur, section.bounds.second, QuoteBlockBeginType, QuoteBlockEndType);
|
122
|
-
}
|
123
|
-
else if (sectionCur->type == ListBlockBeginType) {
|
124
|
-
|
125
|
-
SourceDataBlock descriptionMap;
|
126
|
-
sectionCur = SkipToDescriptionListEnd<T>(sectionCur, section.bounds.second, descriptionMap);
|
127
|
-
|
128
|
-
if (sectionCur->type != ListBlockEndType) {
|
129
|
-
// Found recognized lists in the list block
|
130
|
-
if (!descriptionMap.empty())
|
131
|
-
output.description += MapSourceData(sourceData, descriptionMap);
|
132
|
-
|
133
|
-
result.second = sectionCur;
|
134
|
-
return result;
|
135
|
-
}
|
136
|
-
}
|
137
|
-
else if (sectionCur->type == CodeBlockType) {
|
138
|
-
// Check code block for potential excessive indentation of a list item
|
139
|
-
CheckCodeBlockListItem<T>(section, sectionCur, sourceData, result.first);
|
140
|
-
}
|
141
|
-
else if (sectionCur->type == HeaderBlockType) {
|
142
|
-
// Check headers for potential keywords
|
143
|
-
CheckHeaderBlock<T>(section, sectionCur, sourceData, result.first);
|
144
|
-
}
|
145
|
-
|
146
|
-
if (!CheckCursor(section, sectionCur, sourceData, result.first))
|
147
|
-
return result;
|
148
|
-
|
149
|
-
output.description += MapSourceData(sourceData, sectionCur->sourceMap);
|
150
|
-
result.second = ++sectionCur;
|
151
|
-
|
152
|
-
return result;
|
153
|
-
}
|
154
|
-
}
|
155
|
-
|
156
|
-
#endif
|