redsnow 0.0.8 → 0.1.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 +1 -0
- data/ext/snowcrash/bin/snowcrash +0 -0
- data/ext/snowcrash/src/ParameterDefinitonParser.h +110 -35
- data/ext/snowcrash/src/Version.h +1 -1
- data/ext/snowcrash/tools/homebrew/snowcrash.rb +1 -1
- data/lib/redsnow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a8a38283797a2cafbccf55b139a0b19e1c4eb8a
|
4
|
+
data.tar.gz: 276d98c64b94e5e1ae32b5843732a2940e60fde0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab1ebb2eb3f8453d1d3813b737faeea77189e6e945c4f47fe5a035e8c7194e931c7b23587333b2fad55215d76d14517572d62bdf492eb70b5d44c3244f3c0cca
|
7
|
+
data.tar.gz: 36cbd238f7710f0cab49ba18791b369ce842d011831a1e3cb88300902ee37e5426e963b642987f16504ec8354520ea988e105d65e4ee7ede30a845bc8383079b
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Changelog
|
2
|
+
- 0.1.0 - Snow Crash updated to [0.12.1](https://github.com/apiaryio/snowcrash/releases/tag/v0.12.1)
|
2
3
|
- 0.0.8 - Add support for [Parse Result](https://github.com/apiaryio/api-blueprint-ast/blob/master/Parse%20Result.md)
|
3
4
|
- 0.0.7 - Fixed dependency, first public version
|
4
5
|
- 0.0.1 - 0.0.6 Developement versions
|
data/ext/snowcrash/bin/snowcrash
CHANGED
Binary file
|
@@ -22,17 +22,13 @@
|
|
22
22
|
#define PARAMETER_VALUE "`([^`]+)`"
|
23
23
|
|
24
24
|
/** Parameter Identifier */
|
25
|
-
#define PARAMETER_IDENTIFIER "([[:alnum:]_.-]+
|
25
|
+
#define PARAMETER_IDENTIFIER "(([[:alnum:]_.-])*|(%[A-Fa-f0-9]{2})*)+"
|
26
26
|
|
27
27
|
/** Lead in and out for comma separated values regex */
|
28
28
|
#define CSV_LEADINOUT "[[:blank:]]*,?[[:blank:]]*"
|
29
29
|
|
30
30
|
namespace snowcrashconst {
|
31
31
|
|
32
|
-
/** Parameter Abbreviated definition matching regex */
|
33
|
-
const char* const ParameterAbbrevDefinitionRegex = "^" PARAMETER_IDENTIFIER \
|
34
|
-
"([[:blank:]]*=[[:blank:]]*`([^`]*)`[[:blank:]]*)?([[:blank:]]*\\(([^)]*)\\)[[:blank:]]*)?([[:blank:]]*\\.\\.\\.[[:blank:]]*(.*))?$";
|
35
|
-
|
36
32
|
/** Parameter Required matching regex */
|
37
33
|
const char* const ParameterRequiredRegex = "^[[:blank:]]*[Rr]equired[[:blank:]]*$";
|
38
34
|
|
@@ -53,6 +49,8 @@ namespace snowcrashconst {
|
|
53
49
|
|
54
50
|
/** Values expected content */
|
55
51
|
const char* const ExpectedValuesContent = "nested list of possible parameter values, one element per list item e.g. '`value`'";
|
52
|
+
|
53
|
+
const std::string DescriptionIdentifier = "...";
|
56
54
|
}
|
57
55
|
|
58
56
|
namespace snowcrash {
|
@@ -91,7 +89,65 @@ namespace snowcrash {
|
|
91
89
|
|
92
90
|
return UndefinedSectionType;
|
93
91
|
}
|
94
|
-
|
92
|
+
|
93
|
+
/** Determine if a signature is a valid parameter*/
|
94
|
+
FORCEINLINE bool IsValidParameterSignature(const SourceData& signature) {
|
95
|
+
|
96
|
+
SourceData innerSignature = signature;
|
97
|
+
innerSignature = TrimString(innerSignature);
|
98
|
+
|
99
|
+
if (innerSignature.length() == 0) {
|
100
|
+
return false; // Empty string, invalid
|
101
|
+
}
|
102
|
+
|
103
|
+
size_t firstSpace = innerSignature.find(" ");
|
104
|
+
if (firstSpace == std::string::npos) {
|
105
|
+
return RegexMatch(innerSignature, "^" PARAMETER_IDENTIFIER "$");
|
106
|
+
}
|
107
|
+
|
108
|
+
std::string paramName = innerSignature.substr(0, firstSpace);
|
109
|
+
if (!RegexMatch(paramName, "^" PARAMETER_IDENTIFIER "$")) {
|
110
|
+
return false; // Invalid param name
|
111
|
+
}
|
112
|
+
// Remove param name
|
113
|
+
innerSignature = innerSignature.substr(firstSpace + 1);
|
114
|
+
|
115
|
+
size_t descriptionPos = innerSignature.find(snowcrashconst::DescriptionIdentifier);
|
116
|
+
// Remove description
|
117
|
+
if (descriptionPos != std::string::npos) {
|
118
|
+
innerSignature = innerSignature.substr(0, descriptionPos);
|
119
|
+
innerSignature = TrimString(innerSignature);
|
120
|
+
}
|
121
|
+
|
122
|
+
size_t attributesPos = innerSignature.find("(");
|
123
|
+
if (attributesPos != std::string::npos) {
|
124
|
+
size_t endOfAttributesPos = innerSignature.find_last_of(")");
|
125
|
+
if (endOfAttributesPos == std::string::npos) {
|
126
|
+
return false; // Expecting close of attributes
|
127
|
+
}
|
128
|
+
// Remove attributes
|
129
|
+
innerSignature = innerSignature.substr(0, attributesPos);
|
130
|
+
innerSignature = TrimString(innerSignature);
|
131
|
+
}
|
132
|
+
|
133
|
+
if (innerSignature.length() == 0) {
|
134
|
+
return true;
|
135
|
+
}
|
136
|
+
|
137
|
+
if (innerSignature.substr(0,1) == "=") {
|
138
|
+
innerSignature = innerSignature.substr(1);
|
139
|
+
innerSignature = TrimString(innerSignature);
|
140
|
+
if (innerSignature.length() == 0) {
|
141
|
+
return false; // No default value
|
142
|
+
}
|
143
|
+
if (innerSignature.substr(0,1) == "`" && innerSignature.substr(innerSignature.length()-1,1) == "`") {
|
144
|
+
return true;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
|
95
151
|
/**
|
96
152
|
* Returns true if given block has a parameter definition signature, false otherwise.
|
97
153
|
*/
|
@@ -114,9 +170,9 @@ namespace snowcrash {
|
|
114
170
|
SourceData remainingContent;
|
115
171
|
SourceData content = GetListItemSignature(begin, end, remainingContent);
|
116
172
|
content = TrimString(content);
|
117
|
-
return
|
173
|
+
return IsValidParameterSignature(content);
|
118
174
|
}
|
119
|
-
|
175
|
+
|
120
176
|
/**
|
121
177
|
* Block Classifier, Parameter context.
|
122
178
|
*/
|
@@ -230,6 +286,8 @@ namespace snowcrash {
|
|
230
286
|
return result;
|
231
287
|
|
232
288
|
}
|
289
|
+
|
290
|
+
|
233
291
|
|
234
292
|
/**
|
235
293
|
* Retrieve and process parameter definition signature.
|
@@ -240,41 +298,57 @@ namespace snowcrash {
|
|
240
298
|
Result& result,
|
241
299
|
Parameter& parameter) {
|
242
300
|
|
243
|
-
|
244
301
|
// Set default values
|
245
302
|
parameter.use = UndefinedParameterUse;
|
246
303
|
|
247
304
|
// Process signature
|
248
305
|
SourceData remainingContent;
|
249
306
|
SourceData signature = GetListItemSignature(cur, section.bounds.second, remainingContent);
|
250
|
-
|
307
|
+
|
251
308
|
TrimString(signature);
|
252
|
-
|
253
|
-
if (
|
254
|
-
captureGroups.size() == 8) {
|
255
|
-
|
256
|
-
// Name
|
257
|
-
parameter.name = captureGroups[1];
|
258
|
-
TrimString(parameter.name);
|
259
|
-
|
260
|
-
// Default value
|
261
|
-
if (!captureGroups[3].empty())
|
262
|
-
parameter.defaultValue = captureGroups[3];
|
263
|
-
|
264
|
-
// Additional Attributes
|
265
|
-
if (!captureGroups[5].empty())
|
266
|
-
ProcessSignatureAdditionalTraits(section, cur, captureGroups[5], sourceData, result, parameter);
|
267
|
-
|
268
|
-
// Description
|
269
|
-
if (!captureGroups[7].empty())
|
270
|
-
parameter.description = captureGroups[7];
|
309
|
+
|
310
|
+
if (IsValidParameterSignature(signature)) {
|
271
311
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
312
|
+
SourceData innerSignature = signature;
|
313
|
+
innerSignature = TrimString(innerSignature);
|
314
|
+
|
315
|
+
size_t firstSpace = innerSignature.find(" ");
|
316
|
+
if (firstSpace == std::string::npos) {
|
317
|
+
// Name
|
318
|
+
parameter.name = signature;
|
319
|
+
}
|
320
|
+
else {
|
321
|
+
parameter.name = innerSignature.substr(0, firstSpace);
|
322
|
+
innerSignature = innerSignature.substr(firstSpace + 1);
|
323
|
+
size_t descriptionPos = innerSignature.find(snowcrashconst::DescriptionIdentifier);
|
324
|
+
if (descriptionPos != std::string::npos) {
|
325
|
+
// Description
|
326
|
+
parameter.description = innerSignature.substr(descriptionPos);
|
327
|
+
parameter.description = TrimString(parameter.description.replace(0, snowcrashconst::DescriptionIdentifier.length(), ""));
|
328
|
+
innerSignature = innerSignature.substr(0, descriptionPos);
|
329
|
+
innerSignature = TrimString(innerSignature);
|
330
|
+
}
|
331
|
+
|
332
|
+
size_t attributesPos = innerSignature.find("(");
|
333
|
+
if (attributesPos != std::string::npos) {
|
334
|
+
size_t endOfAttributesPos = innerSignature.find_last_of(")");
|
335
|
+
if (endOfAttributesPos - attributesPos > 1) {
|
336
|
+
std::string attributes = innerSignature.substr(attributesPos, endOfAttributesPos - attributesPos);
|
337
|
+
attributes = attributes.substr(1);
|
338
|
+
ProcessSignatureAdditionalTraits(section, cur, attributes, sourceData, result, parameter);
|
339
|
+
innerSignature = innerSignature.substr(0, attributesPos);
|
340
|
+
innerSignature = TrimString(innerSignature);
|
341
|
+
}
|
342
|
+
}
|
343
|
+
|
344
|
+
if (innerSignature.length() > 0) {
|
345
|
+
// Remove =
|
346
|
+
parameter.defaultValue = innerSignature;
|
347
|
+
parameter.defaultValue.erase(std::remove(parameter.defaultValue.begin(), parameter.defaultValue.end(), '='), parameter.defaultValue.end());
|
348
|
+
parameter.defaultValue.erase(std::remove(parameter.defaultValue.begin(), parameter.defaultValue.end(), '`'), parameter.defaultValue.end());
|
349
|
+
parameter.defaultValue = TrimString(parameter.defaultValue);
|
350
|
+
}
|
276
351
|
}
|
277
|
-
|
278
352
|
// Check possible required vs default clash
|
279
353
|
if (parameter.use != OptionalParameterUse &&
|
280
354
|
!parameter.defaultValue.empty()) {
|
@@ -290,7 +364,6 @@ namespace snowcrash {
|
|
290
364
|
LogicalErrorWarning,
|
291
365
|
sourceBlock));
|
292
366
|
}
|
293
|
-
|
294
367
|
}
|
295
368
|
else {
|
296
369
|
// ERR: unable to parse
|
@@ -301,6 +374,7 @@ namespace snowcrash {
|
|
301
374
|
sourceBlock));
|
302
375
|
}
|
303
376
|
}
|
377
|
+
|
304
378
|
|
305
379
|
/** Parse additional parameter attributes from abbrev definition bracket */
|
306
380
|
static void ProcessSignatureAdditionalTraits(const BlueprintSection& section,
|
@@ -562,6 +636,7 @@ namespace snowcrash {
|
|
562
636
|
return;
|
563
637
|
}
|
564
638
|
|
639
|
+
|
565
640
|
};
|
566
641
|
|
567
642
|
typedef BlockParser<Parameter, SectionParser<Parameter> > ParameterDefinitionParser;
|
data/ext/snowcrash/src/Version.h
CHANGED
data/lib/redsnow/version.rb
CHANGED