1 | module.exports = (function() {
|
2 | |
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | function peg$subclass(child, parent) {
|
9 | function ctor() { this.constructor = child; }
|
10 | ctor.prototype = parent.prototype;
|
11 | child.prototype = new ctor();
|
12 | }
|
13 |
|
14 | function SyntaxError(message, expected, found, offset, line, column) {
|
15 | this.message = message;
|
16 | this.expected = expected;
|
17 | this.found = found;
|
18 | this.offset = offset;
|
19 | this.line = line;
|
20 | this.column = column;
|
21 |
|
22 | this.name = "SyntaxError";
|
23 | }
|
24 |
|
25 | peg$subclass(SyntaxError, Error);
|
26 |
|
27 | function parse(input) {
|
28 | var options = arguments.length > 1 ? arguments[1] : {},
|
29 |
|
30 | peg$FAILED = {},
|
31 |
|
32 | peg$startRuleFunctions = { elements: peg$parseelements },
|
33 | peg$startRuleFunction = peg$parseelements,
|
34 |
|
35 | peg$c0 = [],
|
36 | peg$c1 = peg$FAILED,
|
37 | peg$c2 = /^[a-zA-Z ]/,
|
38 | peg$c3 = { type: "class", value: "[a-zA-Z ]", description: "[a-zA-Z ]" },
|
39 | peg$c4 = function(c) { return c.join(''); },
|
40 | peg$c5 = function(b) {
|
41 | var top = b[0];
|
42 | var mid = b[1];
|
43 | if(b.length == 2){
|
44 | return top.name === "if" && mid.name === "else";
|
45 | }
|
46 | return false;
|
47 | },
|
48 | peg$c6 = void 0,
|
49 | peg$c7 = function(b) {
|
50 | var top = b[0];
|
51 | var mid = b[1];
|
52 | var newMid = { type: "mid_block_expression", name: mid.name };
|
53 | if(mid.content){
|
54 | newMid.content = mid.content;
|
55 | }
|
56 | top.nodes.push(newMid);
|
57 | top.nodes.push.apply(top.nodes, mid.nodes);
|
58 | return top;
|
59 | },
|
60 | peg$c8 = null,
|
61 | peg$c9 = function(name, m, b) {
|
62 | var e = { type: 'block_expression', name:name };
|
63 | if(m) {
|
64 | e.content = m;
|
65 | }
|
66 | if(b && b.length > 0){
|
67 | e.nodes = b[1];
|
68 | }
|
69 | return e;
|
70 | },
|
71 | peg$c10 = function(m) {
|
72 | return { type: 'expression', content:m };
|
73 | },
|
74 | peg$c11 = "-",
|
75 | peg$c12 = { type: "literal", value: "-", description: "\"-\"" },
|
76 | peg$c13 = "=",
|
77 | peg$c14 = { type: "literal", value: "=", description: "\"=\"" },
|
78 | peg$c15 = function(a) { return { attributes: a }; },
|
79 | peg$c16 = function(b) { return { attributeBindings: b }; },
|
80 | peg$c17 = function(t, idClass, attrs, i) {
|
81 | return !!t || !!idClass.length;
|
82 | },
|
83 | peg$c18 = function(t, idClass, attrs, i) {
|
84 | var element = {
|
85 | type: 'element',
|
86 | tag: t || 'div'
|
87 | };
|
88 | var attributes = idClass;
|
89 | var addAtributes = condense(attrs);
|
90 | addProperties(element, 'attributes', condense(attributes.concat(addAtributes.attributes)));
|
91 | addProperties(element, 'attributeBindings', condense(addAtributes.attributeBindings));
|
92 | addProperty(element, 'content', i);
|
93 | return element;
|
94 | },
|
95 | peg$c19 = "(",
|
96 | peg$c20 = { type: "literal", value: "(", description: "\"(\"" },
|
97 | peg$c21 = ")",
|
98 | peg$c22 = { type: "literal", value: ")", description: "\")\"" },
|
99 | peg$c23 = function(a) {
|
100 | return a;
|
101 | },
|
102 | peg$c24 = "{",
|
103 | peg$c25 = { type: "literal", value: "{", description: "\"{\"" },
|
104 | peg$c26 = "}",
|
105 | peg$c27 = { type: "literal", value: "}", description: "\"}\"" },
|
106 | peg$c28 = { type: "other", description: "Attribute List" },
|
107 | peg$c29 = function(a) {
|
108 | return condense(a);
|
109 | },
|
110 | peg$c30 = function(k, v) {
|
111 | var attr = {};
|
112 | attr[k] = v;
|
113 | return attr;
|
114 | },
|
115 | peg$c31 = function(e, b) {
|
116 | if(b && b.length > 0){
|
117 | e.nodes = b[1];
|
118 | }
|
119 | return e;
|
120 | },
|
121 | peg$c32 = "#",
|
122 | peg$c33 = { type: "literal", value: "#", description: "\"#\"" },
|
123 | peg$c34 = function(i) { return { id: i } },
|
124 | peg$c35 = "%",
|
125 | peg$c36 = { type: "literal", value: "%", description: "\"%\"" },
|
126 | peg$c37 = function(t) { return t; },
|
127 | peg$c38 = ".",
|
128 | peg$c39 = { type: "literal", value: ".", description: "\".\"" },
|
129 | peg$c40 = function(c) { return { class: c } },
|
130 | peg$c41 = "'",
|
131 | peg$c42 = { type: "literal", value: "'", description: "\"'\"" },
|
132 | peg$c43 = "\"",
|
133 | peg$c44 = { type: "literal", value: "\"", description: "\"\\\"\"" },
|
134 | peg$c45 = function(chars) { return chars.join('') },
|
135 | peg$c46 = /^[_a-z0-9\-]/i,
|
136 | peg$c47 = { type: "class", value: "[_a-z0-9\\-]i", description: "[_a-z0-9\\-]i" },
|
137 | peg$c48 = function(t) { return { type: 'text', content: t }; },
|
138 | peg$c49 = function(t) {
|
139 | var content = [];
|
140 | t.forEach(function(node){
|
141 | content.push(node);
|
142 | });
|
143 | if(t.length === 1 && typeof(t[0]) === 'string'){
|
144 | return t[0];
|
145 | }
|
146 | return content;
|
147 | },
|
148 | peg$c50 = "#{",
|
149 | peg$c51 = { type: "literal", value: "#{", description: "\"#{\"" },
|
150 | peg$c52 = function(t) { return { type: 'expression', content: t }; },
|
151 | peg$c53 = function(c) { return c; },
|
152 | peg$c54 = function(t) { return t.join(''); },
|
153 | peg$c55 = { type: "any", description: "any character" },
|
154 | peg$c56 = function(i) { return i !== TERM_CHAR },
|
155 | peg$c57 = function(i) { return i; },
|
156 | peg$c58 = /^[%.=\-]/,
|
157 | peg$c59 = { type: "class", value: "[%.=\\-]", description: "[%.=\\-]" },
|
158 | peg$c60 = /^[%.#=\-]/,
|
159 | peg$c61 = { type: "class", value: "[%.#=\\-]", description: "[%.#=\\-]" },
|
160 | peg$c62 = { type: "other", description: "INDENT" },
|
161 | peg$c63 = function(i) { return i === INDENT_CHAR },
|
162 | peg$c64 = function(i) { return ''; },
|
163 | peg$c65 = { type: "other", description: "DEDENT" },
|
164 | peg$c66 = function(i) { return i === DEDENT_CHAR },
|
165 | peg$c67 = { type: "other", description: "TERM" },
|
166 | peg$c68 = function(i) { return i === TERM_CHAR },
|
167 | peg$c69 = { type: "other", description: "required whitespace" },
|
168 | peg$c70 = { type: "other", description: "whitespace" },
|
169 | peg$c71 = /^[ \t\n\r]/,
|
170 | peg$c72 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
|
171 |
|
172 | peg$currPos = 0,
|
173 | peg$reportedPos = 0,
|
174 | peg$cachedPos = 0,
|
175 | peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
|
176 | peg$maxFailPos = 0,
|
177 | peg$maxFailExpected = [],
|
178 | peg$silentFails = 0,
|
179 |
|
180 | peg$result;
|
181 |
|
182 | if ("startRule" in options) {
|
183 | if (!(options.startRule in peg$startRuleFunctions)) {
|
184 | throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
185 | }
|
186 |
|
187 | peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
188 | }
|
189 |
|
190 | function text() {
|
191 | return input.substring(peg$reportedPos, peg$currPos);
|
192 | }
|
193 |
|
194 | function offset() {
|
195 | return peg$reportedPos;
|
196 | }
|
197 |
|
198 | function line() {
|
199 | return peg$computePosDetails(peg$reportedPos).line;
|
200 | }
|
201 |
|
202 | function column() {
|
203 | return peg$computePosDetails(peg$reportedPos).column;
|
204 | }
|
205 |
|
206 | function expected(description) {
|
207 | throw peg$buildException(
|
208 | null,
|
209 | [{ type: "other", description: description }],
|
210 | peg$reportedPos
|
211 | );
|
212 | }
|
213 |
|
214 | function error(message) {
|
215 | throw peg$buildException(message, null, peg$reportedPos);
|
216 | }
|
217 |
|
218 | function peg$computePosDetails(pos) {
|
219 | function advance(details, startPos, endPos) {
|
220 | var p, ch;
|
221 |
|
222 | for (p = startPos; p < endPos; p++) {
|
223 | ch = input.charAt(p);
|
224 | if (ch === "\n") {
|
225 | if (!details.seenCR) { details.line++; }
|
226 | details.column = 1;
|
227 | details.seenCR = false;
|
228 | } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
|
229 | details.line++;
|
230 | details.column = 1;
|
231 | details.seenCR = true;
|
232 | } else {
|
233 | details.column++;
|
234 | details.seenCR = false;
|
235 | }
|
236 | }
|
237 | }
|
238 |
|
239 | if (peg$cachedPos !== pos) {
|
240 | if (peg$cachedPos > pos) {
|
241 | peg$cachedPos = 0;
|
242 | peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
|
243 | }
|
244 | advance(peg$cachedPosDetails, peg$cachedPos, pos);
|
245 | peg$cachedPos = pos;
|
246 | }
|
247 |
|
248 | return peg$cachedPosDetails;
|
249 | }
|
250 |
|
251 | function peg$fail(expected) {
|
252 | if (peg$currPos < peg$maxFailPos) { return; }
|
253 |
|
254 | if (peg$currPos > peg$maxFailPos) {
|
255 | peg$maxFailPos = peg$currPos;
|
256 | peg$maxFailExpected = [];
|
257 | }
|
258 |
|
259 | peg$maxFailExpected.push(expected);
|
260 | }
|
261 |
|
262 | function peg$buildException(message, expected, pos) {
|
263 | function cleanupExpected(expected) {
|
264 | var i = 1;
|
265 |
|
266 | expected.sort(function(a, b) {
|
267 | if (a.description < b.description) {
|
268 | return -1;
|
269 | } else if (a.description > b.description) {
|
270 | return 1;
|
271 | } else {
|
272 | return 0;
|
273 | }
|
274 | });
|
275 |
|
276 | while (i < expected.length) {
|
277 | if (expected[i - 1] === expected[i]) {
|
278 | expected.splice(i, 1);
|
279 | } else {
|
280 | i++;
|
281 | }
|
282 | }
|
283 | }
|
284 |
|
285 | function buildMessage(expected, found) {
|
286 | function stringEscape(s) {
|
287 | function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
|
288 |
|
289 | return s
|
290 | .replace(/\\/g, '\\\\')
|
291 | .replace(/"/g, '\\"')
|
292 | .replace(/\x08/g, '\\b')
|
293 | .replace(/\t/g, '\\t')
|
294 | .replace(/\n/g, '\\n')
|
295 | .replace(/\f/g, '\\f')
|
296 | .replace(/\r/g, '\\r')
|
297 | .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
298 | .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
|
299 | .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
|
300 | .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
|
301 | }
|
302 |
|
303 | var expectedDescs = new Array(expected.length),
|
304 | expectedDesc, foundDesc, i;
|
305 |
|
306 | for (i = 0; i < expected.length; i++) {
|
307 | expectedDescs[i] = expected[i].description;
|
308 | }
|
309 |
|
310 | expectedDesc = expected.length > 1
|
311 | ? expectedDescs.slice(0, -1).join(", ")
|
312 | + " or "
|
313 | + expectedDescs[expected.length - 1]
|
314 | : expectedDescs[0];
|
315 |
|
316 | foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
|
317 |
|
318 | return "Expected " + expectedDesc + " but " + foundDesc + " found.";
|
319 | }
|
320 |
|
321 | var posDetails = peg$computePosDetails(pos),
|
322 | found = pos < input.length ? input.charAt(pos) : null;
|
323 |
|
324 | if (expected !== null) {
|
325 | cleanupExpected(expected);
|
326 | }
|
327 |
|
328 | return new SyntaxError(
|
329 | message !== null ? message : buildMessage(expected, found),
|
330 | expected,
|
331 | found,
|
332 | pos,
|
333 | posDetails.line,
|
334 | posDetails.column
|
335 | );
|
336 | }
|
337 |
|
338 | function peg$parseelements() {
|
339 | var s0, s1;
|
340 |
|
341 | s0 = [];
|
342 | s1 = peg$parseblockElement();
|
343 | if (s1 === peg$FAILED) {
|
344 | s1 = peg$parsemustache();
|
345 | if (s1 === peg$FAILED) {
|
346 | s1 = peg$parsetextLine();
|
347 | }
|
348 | }
|
349 | while (s1 !== peg$FAILED) {
|
350 | s0.push(s1);
|
351 | s1 = peg$parseblockElement();
|
352 | if (s1 === peg$FAILED) {
|
353 | s1 = peg$parsemustache();
|
354 | if (s1 === peg$FAILED) {
|
355 | s1 = peg$parsetextLine();
|
356 | }
|
357 | }
|
358 | }
|
359 |
|
360 | return s0;
|
361 | }
|
362 |
|
363 | function peg$parsemustacheContent() {
|
364 | var s0, s1, s2;
|
365 |
|
366 | s0 = peg$currPos;
|
367 | s1 = [];
|
368 | if (peg$c2.test(input.charAt(peg$currPos))) {
|
369 | s2 = input.charAt(peg$currPos);
|
370 | peg$currPos++;
|
371 | } else {
|
372 | s2 = peg$FAILED;
|
373 | if (peg$silentFails === 0) { peg$fail(peg$c3); }
|
374 | }
|
375 | if (s2 !== peg$FAILED) {
|
376 | while (s2 !== peg$FAILED) {
|
377 | s1.push(s2);
|
378 | if (peg$c2.test(input.charAt(peg$currPos))) {
|
379 | s2 = input.charAt(peg$currPos);
|
380 | peg$currPos++;
|
381 | } else {
|
382 | s2 = peg$FAILED;
|
383 | if (peg$silentFails === 0) { peg$fail(peg$c3); }
|
384 | }
|
385 | }
|
386 | } else {
|
387 | s1 = peg$c1;
|
388 | }
|
389 | if (s1 !== peg$FAILED) {
|
390 | peg$reportedPos = s0;
|
391 | s1 = peg$c4(s1);
|
392 | }
|
393 | s0 = s1;
|
394 |
|
395 | return s0;
|
396 | }
|
397 |
|
398 | function peg$parsemustache() {
|
399 | var s0;
|
400 |
|
401 | s0 = peg$parseblockChainExpression();
|
402 | if (s0 === peg$FAILED) {
|
403 | s0 = peg$parseblockExpression();
|
404 | if (s0 === peg$FAILED) {
|
405 | s0 = peg$parsemustacheExpression();
|
406 | }
|
407 | }
|
408 |
|
409 | return s0;
|
410 | }
|
411 |
|
412 | function peg$parseblockChainExpression() {
|
413 | var s0, s1, s2;
|
414 |
|
415 | s0 = peg$currPos;
|
416 | s1 = [];
|
417 | s2 = peg$parseblockExpression();
|
418 | if (s2 !== peg$FAILED) {
|
419 | while (s2 !== peg$FAILED) {
|
420 | s1.push(s2);
|
421 | s2 = peg$parseblockExpression();
|
422 | }
|
423 | } else {
|
424 | s1 = peg$c1;
|
425 | }
|
426 | if (s1 !== peg$FAILED) {
|
427 | peg$reportedPos = peg$currPos;
|
428 | s2 = peg$c5(s1);
|
429 | if (s2) {
|
430 | s2 = peg$c6;
|
431 | } else {
|
432 | s2 = peg$c1;
|
433 | }
|
434 | if (s2 !== peg$FAILED) {
|
435 | peg$reportedPos = s0;
|
436 | s1 = peg$c7(s1);
|
437 | s0 = s1;
|
438 | } else {
|
439 | peg$currPos = s0;
|
440 | s0 = peg$c1;
|
441 | }
|
442 | } else {
|
443 | peg$currPos = s0;
|
444 | s0 = peg$c1;
|
445 | }
|
446 |
|
447 | return s0;
|
448 | }
|
449 |
|
450 | function peg$parseblockExpression() {
|
451 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
|
452 |
|
453 | s0 = peg$currPos;
|
454 | s1 = peg$parse_();
|
455 | if (s1 !== peg$FAILED) {
|
456 | s2 = peg$parsedash();
|
457 | if (s2 !== peg$FAILED) {
|
458 | s3 = peg$parse_();
|
459 | if (s3 !== peg$FAILED) {
|
460 | s4 = peg$parsename();
|
461 | if (s4 !== peg$FAILED) {
|
462 | s5 = peg$parse_();
|
463 | if (s5 !== peg$FAILED) {
|
464 | s6 = peg$parsemustacheContent();
|
465 | if (s6 === peg$FAILED) {
|
466 | s6 = peg$c8;
|
467 | }
|
468 | if (s6 !== peg$FAILED) {
|
469 | s7 = peg$parse_();
|
470 | if (s7 !== peg$FAILED) {
|
471 | s8 = peg$parseTERM();
|
472 | if (s8 !== peg$FAILED) {
|
473 | s9 = peg$currPos;
|
474 | s10 = peg$parseINDENT();
|
475 | if (s10 !== peg$FAILED) {
|
476 | s11 = peg$parseelements();
|
477 | if (s11 !== peg$FAILED) {
|
478 | s12 = peg$parseDEDENT();
|
479 | if (s12 !== peg$FAILED) {
|
480 | s10 = [s10, s11, s12];
|
481 | s9 = s10;
|
482 | } else {
|
483 | peg$currPos = s9;
|
484 | s9 = peg$c1;
|
485 | }
|
486 | } else {
|
487 | peg$currPos = s9;
|
488 | s9 = peg$c1;
|
489 | }
|
490 | } else {
|
491 | peg$currPos = s9;
|
492 | s9 = peg$c1;
|
493 | }
|
494 | if (s9 === peg$FAILED) {
|
495 | s9 = peg$c8;
|
496 | }
|
497 | if (s9 !== peg$FAILED) {
|
498 | peg$reportedPos = s0;
|
499 | s1 = peg$c9(s4, s6, s9);
|
500 | s0 = s1;
|
501 | } else {
|
502 | peg$currPos = s0;
|
503 | s0 = peg$c1;
|
504 | }
|
505 | } else {
|
506 | peg$currPos = s0;
|
507 | s0 = peg$c1;
|
508 | }
|
509 | } else {
|
510 | peg$currPos = s0;
|
511 | s0 = peg$c1;
|
512 | }
|
513 | } else {
|
514 | peg$currPos = s0;
|
515 | s0 = peg$c1;
|
516 | }
|
517 | } else {
|
518 | peg$currPos = s0;
|
519 | s0 = peg$c1;
|
520 | }
|
521 | } else {
|
522 | peg$currPos = s0;
|
523 | s0 = peg$c1;
|
524 | }
|
525 | } else {
|
526 | peg$currPos = s0;
|
527 | s0 = peg$c1;
|
528 | }
|
529 | } else {
|
530 | peg$currPos = s0;
|
531 | s0 = peg$c1;
|
532 | }
|
533 | } else {
|
534 | peg$currPos = s0;
|
535 | s0 = peg$c1;
|
536 | }
|
537 |
|
538 | return s0;
|
539 | }
|
540 |
|
541 | function peg$parsemustacheExpression() {
|
542 | var s0, s1, s2, s3, s4, s5, s6;
|
543 |
|
544 | s0 = peg$currPos;
|
545 | s1 = peg$parse_();
|
546 | if (s1 !== peg$FAILED) {
|
547 | s2 = peg$parseequal();
|
548 | if (s2 !== peg$FAILED) {
|
549 | s3 = peg$parse_();
|
550 | if (s3 !== peg$FAILED) {
|
551 | s4 = peg$parsemustacheContent();
|
552 | if (s4 !== peg$FAILED) {
|
553 | s5 = peg$parse_();
|
554 | if (s5 !== peg$FAILED) {
|
555 | s6 = peg$parseTERM();
|
556 | if (s6 !== peg$FAILED) {
|
557 | peg$reportedPos = s0;
|
558 | s1 = peg$c10(s4);
|
559 | s0 = s1;
|
560 | } else {
|
561 | peg$currPos = s0;
|
562 | s0 = peg$c1;
|
563 | }
|
564 | } else {
|
565 | peg$currPos = s0;
|
566 | s0 = peg$c1;
|
567 | }
|
568 | } else {
|
569 | peg$currPos = s0;
|
570 | s0 = peg$c1;
|
571 | }
|
572 | } else {
|
573 | peg$currPos = s0;
|
574 | s0 = peg$c1;
|
575 | }
|
576 | } else {
|
577 | peg$currPos = s0;
|
578 | s0 = peg$c1;
|
579 | }
|
580 | } else {
|
581 | peg$currPos = s0;
|
582 | s0 = peg$c1;
|
583 | }
|
584 |
|
585 | return s0;
|
586 | }
|
587 |
|
588 | function peg$parsedash() {
|
589 | var s0;
|
590 |
|
591 | if (input.charCodeAt(peg$currPos) === 45) {
|
592 | s0 = peg$c11;
|
593 | peg$currPos++;
|
594 | } else {
|
595 | s0 = peg$FAILED;
|
596 | if (peg$silentFails === 0) { peg$fail(peg$c12); }
|
597 | }
|
598 |
|
599 | return s0;
|
600 | }
|
601 |
|
602 | function peg$parseequal() {
|
603 | var s0;
|
604 |
|
605 | if (input.charCodeAt(peg$currPos) === 61) {
|
606 | s0 = peg$c13;
|
607 | peg$currPos++;
|
608 | } else {
|
609 | s0 = peg$FAILED;
|
610 | if (peg$silentFails === 0) { peg$fail(peg$c14); }
|
611 | }
|
612 |
|
613 | return s0;
|
614 | }
|
615 |
|
616 | function peg$parseelement() {
|
617 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
618 |
|
619 | s0 = peg$currPos;
|
620 | s1 = peg$parsetag();
|
621 | if (s1 === peg$FAILED) {
|
622 | s1 = peg$c8;
|
623 | }
|
624 | if (s1 !== peg$FAILED) {
|
625 | s2 = [];
|
626 | s3 = peg$parseid();
|
627 | if (s3 === peg$FAILED) {
|
628 | s3 = peg$parseclass();
|
629 | }
|
630 | while (s3 !== peg$FAILED) {
|
631 | s2.push(s3);
|
632 | s3 = peg$parseid();
|
633 | if (s3 === peg$FAILED) {
|
634 | s3 = peg$parseclass();
|
635 | }
|
636 | }
|
637 | if (s2 !== peg$FAILED) {
|
638 | s3 = peg$parse_();
|
639 | if (s3 !== peg$FAILED) {
|
640 | s4 = [];
|
641 | s5 = peg$currPos;
|
642 | s6 = peg$parseattributes();
|
643 | if (s6 !== peg$FAILED) {
|
644 | peg$reportedPos = s5;
|
645 | s6 = peg$c15(s6);
|
646 | }
|
647 | s5 = s6;
|
648 | if (s5 === peg$FAILED) {
|
649 | s5 = peg$currPos;
|
650 | s6 = peg$parseattributeBindings();
|
651 | if (s6 !== peg$FAILED) {
|
652 | peg$reportedPos = s5;
|
653 | s6 = peg$c16(s6);
|
654 | }
|
655 | s5 = s6;
|
656 | }
|
657 | while (s5 !== peg$FAILED) {
|
658 | s4.push(s5);
|
659 | s5 = peg$currPos;
|
660 | s6 = peg$parseattributes();
|
661 | if (s6 !== peg$FAILED) {
|
662 | peg$reportedPos = s5;
|
663 | s6 = peg$c15(s6);
|
664 | }
|
665 | s5 = s6;
|
666 | if (s5 === peg$FAILED) {
|
667 | s5 = peg$currPos;
|
668 | s6 = peg$parseattributeBindings();
|
669 | if (s6 !== peg$FAILED) {
|
670 | peg$reportedPos = s5;
|
671 | s6 = peg$c16(s6);
|
672 | }
|
673 | s5 = s6;
|
674 | }
|
675 | }
|
676 | if (s4 !== peg$FAILED) {
|
677 | s5 = peg$parse_();
|
678 | if (s5 !== peg$FAILED) {
|
679 | s6 = peg$parseinlineText();
|
680 | if (s6 === peg$FAILED) {
|
681 | s6 = peg$c8;
|
682 | }
|
683 | if (s6 !== peg$FAILED) {
|
684 | s7 = peg$parse_();
|
685 | if (s7 !== peg$FAILED) {
|
686 | s8 = peg$parseTERM();
|
687 | if (s8 !== peg$FAILED) {
|
688 | peg$reportedPos = peg$currPos;
|
689 | s9 = peg$c17(s1, s2, s4, s6);
|
690 | if (s9) {
|
691 | s9 = peg$c6;
|
692 | } else {
|
693 | s9 = peg$c1;
|
694 | }
|
695 | if (s9 !== peg$FAILED) {
|
696 | peg$reportedPos = s0;
|
697 | s1 = peg$c18(s1, s2, s4, s6);
|
698 | s0 = s1;
|
699 | } else {
|
700 | peg$currPos = s0;
|
701 | s0 = peg$c1;
|
702 | }
|
703 | } else {
|
704 | peg$currPos = s0;
|
705 | s0 = peg$c1;
|
706 | }
|
707 | } else {
|
708 | peg$currPos = s0;
|
709 | s0 = peg$c1;
|
710 | }
|
711 | } else {
|
712 | peg$currPos = s0;
|
713 | s0 = peg$c1;
|
714 | }
|
715 | } else {
|
716 | peg$currPos = s0;
|
717 | s0 = peg$c1;
|
718 | }
|
719 | } else {
|
720 | peg$currPos = s0;
|
721 | s0 = peg$c1;
|
722 | }
|
723 | } else {
|
724 | peg$currPos = s0;
|
725 | s0 = peg$c1;
|
726 | }
|
727 | } else {
|
728 | peg$currPos = s0;
|
729 | s0 = peg$c1;
|
730 | }
|
731 | } else {
|
732 | peg$currPos = s0;
|
733 | s0 = peg$c1;
|
734 | }
|
735 |
|
736 | return s0;
|
737 | }
|
738 |
|
739 | function peg$parseattributes() {
|
740 | var s0, s1, s2, s3;
|
741 |
|
742 | s0 = peg$currPos;
|
743 | if (input.charCodeAt(peg$currPos) === 40) {
|
744 | s1 = peg$c19;
|
745 | peg$currPos++;
|
746 | } else {
|
747 | s1 = peg$FAILED;
|
748 | if (peg$silentFails === 0) { peg$fail(peg$c20); }
|
749 | }
|
750 | if (s1 !== peg$FAILED) {
|
751 | s2 = peg$parseattributeList();
|
752 | if (s2 !== peg$FAILED) {
|
753 | if (input.charCodeAt(peg$currPos) === 41) {
|
754 | s3 = peg$c21;
|
755 | peg$currPos++;
|
756 | } else {
|
757 | s3 = peg$FAILED;
|
758 | if (peg$silentFails === 0) { peg$fail(peg$c22); }
|
759 | }
|
760 | if (s3 !== peg$FAILED) {
|
761 | peg$reportedPos = s0;
|
762 | s1 = peg$c23(s2);
|
763 | s0 = s1;
|
764 | } else {
|
765 | peg$currPos = s0;
|
766 | s0 = peg$c1;
|
767 | }
|
768 | } else {
|
769 | peg$currPos = s0;
|
770 | s0 = peg$c1;
|
771 | }
|
772 | } else {
|
773 | peg$currPos = s0;
|
774 | s0 = peg$c1;
|
775 | }
|
776 |
|
777 | return s0;
|
778 | }
|
779 |
|
780 | function peg$parseattributeBindings() {
|
781 | var s0, s1, s2, s3;
|
782 |
|
783 | s0 = peg$currPos;
|
784 | if (input.charCodeAt(peg$currPos) === 123) {
|
785 | s1 = peg$c24;
|
786 | peg$currPos++;
|
787 | } else {
|
788 | s1 = peg$FAILED;
|
789 | if (peg$silentFails === 0) { peg$fail(peg$c25); }
|
790 | }
|
791 | if (s1 !== peg$FAILED) {
|
792 | s2 = peg$parseattributeList();
|
793 | if (s2 !== peg$FAILED) {
|
794 | if (input.charCodeAt(peg$currPos) === 125) {
|
795 | s3 = peg$c26;
|
796 | peg$currPos++;
|
797 | } else {
|
798 | s3 = peg$FAILED;
|
799 | if (peg$silentFails === 0) { peg$fail(peg$c27); }
|
800 | }
|
801 | if (s3 !== peg$FAILED) {
|
802 | peg$reportedPos = s0;
|
803 | s1 = peg$c23(s2);
|
804 | s0 = s1;
|
805 | } else {
|
806 | peg$currPos = s0;
|
807 | s0 = peg$c1;
|
808 | }
|
809 | } else {
|
810 | peg$currPos = s0;
|
811 | s0 = peg$c1;
|
812 | }
|
813 | } else {
|
814 | peg$currPos = s0;
|
815 | s0 = peg$c1;
|
816 | }
|
817 |
|
818 | return s0;
|
819 | }
|
820 |
|
821 | function peg$parseattributeList() {
|
822 | var s0, s1, s2;
|
823 |
|
824 | peg$silentFails++;
|
825 | s0 = peg$currPos;
|
826 | s1 = [];
|
827 | s2 = peg$parseattribute();
|
828 | while (s2 !== peg$FAILED) {
|
829 | s1.push(s2);
|
830 | s2 = peg$parseattribute();
|
831 | }
|
832 | if (s1 !== peg$FAILED) {
|
833 | peg$reportedPos = s0;
|
834 | s1 = peg$c29(s1);
|
835 | }
|
836 | s0 = s1;
|
837 | peg$silentFails--;
|
838 | if (s0 === peg$FAILED) {
|
839 | s1 = peg$FAILED;
|
840 | if (peg$silentFails === 0) { peg$fail(peg$c28); }
|
841 | }
|
842 |
|
843 | return s0;
|
844 | }
|
845 |
|
846 | function peg$parseattribute() {
|
847 | var s0, s1, s2, s3, s4, s5;
|
848 |
|
849 | s0 = peg$currPos;
|
850 | s1 = peg$parse_();
|
851 | if (s1 !== peg$FAILED) {
|
852 | s2 = peg$parsename();
|
853 | if (s2 !== peg$FAILED) {
|
854 | if (input.charCodeAt(peg$currPos) === 61) {
|
855 | s3 = peg$c13;
|
856 | peg$currPos++;
|
857 | } else {
|
858 | s3 = peg$FAILED;
|
859 | if (peg$silentFails === 0) { peg$fail(peg$c14); }
|
860 | }
|
861 | if (s3 !== peg$FAILED) {
|
862 | s4 = peg$parsename();
|
863 | if (s4 === peg$FAILED) {
|
864 | s4 = peg$parsequoted();
|
865 | }
|
866 | if (s4 !== peg$FAILED) {
|
867 | s5 = peg$parse_();
|
868 | if (s5 !== peg$FAILED) {
|
869 | peg$reportedPos = s0;
|
870 | s1 = peg$c30(s2, s4);
|
871 | s0 = s1;
|
872 | } else {
|
873 | peg$currPos = s0;
|
874 | s0 = peg$c1;
|
875 | }
|
876 | } else {
|
877 | peg$currPos = s0;
|
878 | s0 = peg$c1;
|
879 | }
|
880 | } else {
|
881 | peg$currPos = s0;
|
882 | s0 = peg$c1;
|
883 | }
|
884 | } else {
|
885 | peg$currPos = s0;
|
886 | s0 = peg$c1;
|
887 | }
|
888 | } else {
|
889 | peg$currPos = s0;
|
890 | s0 = peg$c1;
|
891 | }
|
892 |
|
893 | return s0;
|
894 | }
|
895 |
|
896 | function peg$parseblockElement() {
|
897 | var s0, s1, s2, s3, s4, s5;
|
898 |
|
899 | s0 = peg$currPos;
|
900 | s1 = peg$parseelement();
|
901 | if (s1 !== peg$FAILED) {
|
902 | s2 = peg$currPos;
|
903 | s3 = peg$parseINDENT();
|
904 | if (s3 !== peg$FAILED) {
|
905 | s4 = peg$parseelements();
|
906 | if (s4 !== peg$FAILED) {
|
907 | s5 = peg$parseDEDENT();
|
908 | if (s5 !== peg$FAILED) {
|
909 | s3 = [s3, s4, s5];
|
910 | s2 = s3;
|
911 | } else {
|
912 | peg$currPos = s2;
|
913 | s2 = peg$c1;
|
914 | }
|
915 | } else {
|
916 | peg$currPos = s2;
|
917 | s2 = peg$c1;
|
918 | }
|
919 | } else {
|
920 | peg$currPos = s2;
|
921 | s2 = peg$c1;
|
922 | }
|
923 | if (s2 === peg$FAILED) {
|
924 | s2 = peg$c8;
|
925 | }
|
926 | if (s2 !== peg$FAILED) {
|
927 | peg$reportedPos = s0;
|
928 | s1 = peg$c31(s1, s2);
|
929 | s0 = s1;
|
930 | } else {
|
931 | peg$currPos = s0;
|
932 | s0 = peg$c1;
|
933 | }
|
934 | } else {
|
935 | peg$currPos = s0;
|
936 | s0 = peg$c1;
|
937 | }
|
938 |
|
939 | return s0;
|
940 | }
|
941 |
|
942 | function peg$parseid() {
|
943 | var s0, s1, s2;
|
944 |
|
945 | s0 = peg$currPos;
|
946 | if (input.charCodeAt(peg$currPos) === 35) {
|
947 | s1 = peg$c32;
|
948 | peg$currPos++;
|
949 | } else {
|
950 | s1 = peg$FAILED;
|
951 | if (peg$silentFails === 0) { peg$fail(peg$c33); }
|
952 | }
|
953 | if (s1 !== peg$FAILED) {
|
954 | s2 = peg$parsename();
|
955 | if (s2 !== peg$FAILED) {
|
956 | peg$reportedPos = s0;
|
957 | s1 = peg$c34(s2);
|
958 | s0 = s1;
|
959 | } else {
|
960 | peg$currPos = s0;
|
961 | s0 = peg$c1;
|
962 | }
|
963 | } else {
|
964 | peg$currPos = s0;
|
965 | s0 = peg$c1;
|
966 | }
|
967 |
|
968 | return s0;
|
969 | }
|
970 |
|
971 | function peg$parsetag() {
|
972 | var s0, s1, s2;
|
973 |
|
974 | s0 = peg$currPos;
|
975 | if (input.charCodeAt(peg$currPos) === 37) {
|
976 | s1 = peg$c35;
|
977 | peg$currPos++;
|
978 | } else {
|
979 | s1 = peg$FAILED;
|
980 | if (peg$silentFails === 0) { peg$fail(peg$c36); }
|
981 | }
|
982 | if (s1 !== peg$FAILED) {
|
983 | s2 = peg$parsename();
|
984 | if (s2 !== peg$FAILED) {
|
985 | peg$reportedPos = s0;
|
986 | s1 = peg$c37(s2);
|
987 | s0 = s1;
|
988 | } else {
|
989 | peg$currPos = s0;
|
990 | s0 = peg$c1;
|
991 | }
|
992 | } else {
|
993 | peg$currPos = s0;
|
994 | s0 = peg$c1;
|
995 | }
|
996 |
|
997 | return s0;
|
998 | }
|
999 |
|
1000 | function peg$parseclass() {
|
1001 | var s0, s1, s2;
|
1002 |
|
1003 | s0 = peg$currPos;
|
1004 | if (input.charCodeAt(peg$currPos) === 46) {
|
1005 | s1 = peg$c38;
|
1006 | peg$currPos++;
|
1007 | } else {
|
1008 | s1 = peg$FAILED;
|
1009 | if (peg$silentFails === 0) { peg$fail(peg$c39); }
|
1010 | }
|
1011 | if (s1 !== peg$FAILED) {
|
1012 | s2 = peg$parsename();
|
1013 | if (s2 !== peg$FAILED) {
|
1014 | peg$reportedPos = s0;
|
1015 | s1 = peg$c40(s2);
|
1016 | s0 = s1;
|
1017 | } else {
|
1018 | peg$currPos = s0;
|
1019 | s0 = peg$c1;
|
1020 | }
|
1021 | } else {
|
1022 | peg$currPos = s0;
|
1023 | s0 = peg$c1;
|
1024 | }
|
1025 |
|
1026 | return s0;
|
1027 | }
|
1028 |
|
1029 | function peg$parsequoted() {
|
1030 | var s0, s1, s2, s3, s4;
|
1031 |
|
1032 | s0 = peg$currPos;
|
1033 | s1 = peg$currPos;
|
1034 | if (input.charCodeAt(peg$currPos) === 39) {
|
1035 | s2 = peg$c41;
|
1036 | peg$currPos++;
|
1037 | } else {
|
1038 | s2 = peg$FAILED;
|
1039 | if (peg$silentFails === 0) { peg$fail(peg$c42); }
|
1040 | }
|
1041 | if (s2 !== peg$FAILED) {
|
1042 | s3 = peg$parsename();
|
1043 | if (s3 !== peg$FAILED) {
|
1044 | if (input.charCodeAt(peg$currPos) === 39) {
|
1045 | s4 = peg$c41;
|
1046 | peg$currPos++;
|
1047 | } else {
|
1048 | s4 = peg$FAILED;
|
1049 | if (peg$silentFails === 0) { peg$fail(peg$c42); }
|
1050 | }
|
1051 | if (s4 !== peg$FAILED) {
|
1052 | s2 = [s2, s3, s4];
|
1053 | s1 = s2;
|
1054 | } else {
|
1055 | peg$currPos = s1;
|
1056 | s1 = peg$c1;
|
1057 | }
|
1058 | } else {
|
1059 | peg$currPos = s1;
|
1060 | s1 = peg$c1;
|
1061 | }
|
1062 | } else {
|
1063 | peg$currPos = s1;
|
1064 | s1 = peg$c1;
|
1065 | }
|
1066 | if (s1 === peg$FAILED) {
|
1067 | s1 = peg$currPos;
|
1068 | if (input.charCodeAt(peg$currPos) === 34) {
|
1069 | s2 = peg$c43;
|
1070 | peg$currPos++;
|
1071 | } else {
|
1072 | s2 = peg$FAILED;
|
1073 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1074 | }
|
1075 | if (s2 !== peg$FAILED) {
|
1076 | s3 = peg$parsename();
|
1077 | if (s3 !== peg$FAILED) {
|
1078 | if (input.charCodeAt(peg$currPos) === 34) {
|
1079 | s4 = peg$c43;
|
1080 | peg$currPos++;
|
1081 | } else {
|
1082 | s4 = peg$FAILED;
|
1083 | if (peg$silentFails === 0) { peg$fail(peg$c44); }
|
1084 | }
|
1085 | if (s4 !== peg$FAILED) {
|
1086 | s2 = [s2, s3, s4];
|
1087 | s1 = s2;
|
1088 | } else {
|
1089 | peg$currPos = s1;
|
1090 | s1 = peg$c1;
|
1091 | }
|
1092 | } else {
|
1093 | peg$currPos = s1;
|
1094 | s1 = peg$c1;
|
1095 | }
|
1096 | } else {
|
1097 | peg$currPos = s1;
|
1098 | s1 = peg$c1;
|
1099 | }
|
1100 | }
|
1101 | if (s1 !== peg$FAILED) {
|
1102 | peg$reportedPos = s0;
|
1103 | s1 = peg$c45(s1);
|
1104 | }
|
1105 | s0 = s1;
|
1106 |
|
1107 | return s0;
|
1108 | }
|
1109 |
|
1110 | function peg$parsename() {
|
1111 | var s0, s1, s2;
|
1112 |
|
1113 | s0 = peg$currPos;
|
1114 | s1 = [];
|
1115 | s2 = peg$parsenameChar();
|
1116 | if (s2 !== peg$FAILED) {
|
1117 | while (s2 !== peg$FAILED) {
|
1118 | s1.push(s2);
|
1119 | s2 = peg$parsenameChar();
|
1120 | }
|
1121 | } else {
|
1122 | s1 = peg$c1;
|
1123 | }
|
1124 | if (s1 !== peg$FAILED) {
|
1125 | peg$reportedPos = s0;
|
1126 | s1 = peg$c45(s1);
|
1127 | }
|
1128 | s0 = s1;
|
1129 |
|
1130 | return s0;
|
1131 | }
|
1132 |
|
1133 | function peg$parsenameChar() {
|
1134 | var s0;
|
1135 |
|
1136 | if (peg$c46.test(input.charAt(peg$currPos))) {
|
1137 | s0 = input.charAt(peg$currPos);
|
1138 | peg$currPos++;
|
1139 | } else {
|
1140 | s0 = peg$FAILED;
|
1141 | if (peg$silentFails === 0) { peg$fail(peg$c47); }
|
1142 | }
|
1143 |
|
1144 | return s0;
|
1145 | }
|
1146 |
|
1147 | function peg$parsetextLine() {
|
1148 | var s0, s1, s2, s3, s4, s5;
|
1149 |
|
1150 | s0 = peg$currPos;
|
1151 | s1 = peg$parse_();
|
1152 | if (s1 !== peg$FAILED) {
|
1153 | s2 = peg$currPos;
|
1154 | peg$silentFails++;
|
1155 | s3 = peg$parsenonTextStart();
|
1156 | peg$silentFails--;
|
1157 | if (s3 === peg$FAILED) {
|
1158 | s2 = peg$c6;
|
1159 | } else {
|
1160 | peg$currPos = s2;
|
1161 | s2 = peg$c1;
|
1162 | }
|
1163 | if (s2 !== peg$FAILED) {
|
1164 | s3 = peg$parsetext();
|
1165 | if (s3 !== peg$FAILED) {
|
1166 | s4 = peg$parse_();
|
1167 | if (s4 !== peg$FAILED) {
|
1168 | s5 = peg$parseTERM();
|
1169 | if (s5 !== peg$FAILED) {
|
1170 | peg$reportedPos = s0;
|
1171 | s1 = peg$c48(s3);
|
1172 | s0 = s1;
|
1173 | } else {
|
1174 | peg$currPos = s0;
|
1175 | s0 = peg$c1;
|
1176 | }
|
1177 | } else {
|
1178 | peg$currPos = s0;
|
1179 | s0 = peg$c1;
|
1180 | }
|
1181 | } else {
|
1182 | peg$currPos = s0;
|
1183 | s0 = peg$c1;
|
1184 | }
|
1185 | } else {
|
1186 | peg$currPos = s0;
|
1187 | s0 = peg$c1;
|
1188 | }
|
1189 | } else {
|
1190 | peg$currPos = s0;
|
1191 | s0 = peg$c1;
|
1192 | }
|
1193 |
|
1194 | return s0;
|
1195 | }
|
1196 |
|
1197 | function peg$parseinlineText() {
|
1198 | var s0, s1, s2, s3, s4;
|
1199 |
|
1200 | s0 = peg$currPos;
|
1201 | s1 = peg$currPos;
|
1202 | peg$silentFails++;
|
1203 | s2 = peg$parsenonInlineTextStart();
|
1204 | peg$silentFails--;
|
1205 | if (s2 === peg$FAILED) {
|
1206 | s1 = peg$c6;
|
1207 | } else {
|
1208 | peg$currPos = s1;
|
1209 | s1 = peg$c1;
|
1210 | }
|
1211 | if (s1 !== peg$FAILED) {
|
1212 | s2 = peg$parse_();
|
1213 | if (s2 !== peg$FAILED) {
|
1214 | s3 = [];
|
1215 | s4 = peg$parseinterpolation();
|
1216 | if (s4 === peg$FAILED) {
|
1217 | s4 = peg$parseinterpolationText();
|
1218 | }
|
1219 | while (s4 !== peg$FAILED) {
|
1220 | s3.push(s4);
|
1221 | s4 = peg$parseinterpolation();
|
1222 | if (s4 === peg$FAILED) {
|
1223 | s4 = peg$parseinterpolationText();
|
1224 | }
|
1225 | }
|
1226 | if (s3 !== peg$FAILED) {
|
1227 | peg$reportedPos = s0;
|
1228 | s1 = peg$c49(s3);
|
1229 | s0 = s1;
|
1230 | } else {
|
1231 | peg$currPos = s0;
|
1232 | s0 = peg$c1;
|
1233 | }
|
1234 | } else {
|
1235 | peg$currPos = s0;
|
1236 | s0 = peg$c1;
|
1237 | }
|
1238 | } else {
|
1239 | peg$currPos = s0;
|
1240 | s0 = peg$c1;
|
1241 | }
|
1242 |
|
1243 | return s0;
|
1244 | }
|
1245 |
|
1246 | function peg$parseinterpolation() {
|
1247 | var s0, s1, s2, s3;
|
1248 |
|
1249 | s0 = peg$currPos;
|
1250 | if (input.substr(peg$currPos, 2) === peg$c50) {
|
1251 | s1 = peg$c50;
|
1252 | peg$currPos += 2;
|
1253 | } else {
|
1254 | s1 = peg$FAILED;
|
1255 | if (peg$silentFails === 0) { peg$fail(peg$c51); }
|
1256 | }
|
1257 | if (s1 !== peg$FAILED) {
|
1258 | s2 = peg$parsemustacheContent();
|
1259 | if (s2 !== peg$FAILED) {
|
1260 | if (input.charCodeAt(peg$currPos) === 125) {
|
1261 | s3 = peg$c26;
|
1262 | peg$currPos++;
|
1263 | } else {
|
1264 | s3 = peg$FAILED;
|
1265 | if (peg$silentFails === 0) { peg$fail(peg$c27); }
|
1266 | }
|
1267 | if (s3 !== peg$FAILED) {
|
1268 | peg$reportedPos = s0;
|
1269 | s1 = peg$c52(s2);
|
1270 | s0 = s1;
|
1271 | } else {
|
1272 | peg$currPos = s0;
|
1273 | s0 = peg$c1;
|
1274 | }
|
1275 | } else {
|
1276 | peg$currPos = s0;
|
1277 | s0 = peg$c1;
|
1278 | }
|
1279 | } else {
|
1280 | peg$currPos = s0;
|
1281 | s0 = peg$c1;
|
1282 | }
|
1283 |
|
1284 | return s0;
|
1285 | }
|
1286 |
|
1287 | function peg$parseinterpolationText() {
|
1288 | var s0, s1, s2, s3, s4;
|
1289 |
|
1290 | s0 = peg$currPos;
|
1291 | s1 = [];
|
1292 | s2 = peg$currPos;
|
1293 | s3 = peg$currPos;
|
1294 | peg$silentFails++;
|
1295 | if (input.substr(peg$currPos, 2) === peg$c50) {
|
1296 | s4 = peg$c50;
|
1297 | peg$currPos += 2;
|
1298 | } else {
|
1299 | s4 = peg$FAILED;
|
1300 | if (peg$silentFails === 0) { peg$fail(peg$c51); }
|
1301 | }
|
1302 | peg$silentFails--;
|
1303 | if (s4 === peg$FAILED) {
|
1304 | s3 = peg$c6;
|
1305 | } else {
|
1306 | peg$currPos = s3;
|
1307 | s3 = peg$c1;
|
1308 | }
|
1309 | if (s3 !== peg$FAILED) {
|
1310 | s4 = peg$parsetextChar();
|
1311 | if (s4 !== peg$FAILED) {
|
1312 | peg$reportedPos = s2;
|
1313 | s3 = peg$c53(s4);
|
1314 | s2 = s3;
|
1315 | } else {
|
1316 | peg$currPos = s2;
|
1317 | s2 = peg$c1;
|
1318 | }
|
1319 | } else {
|
1320 | peg$currPos = s2;
|
1321 | s2 = peg$c1;
|
1322 | }
|
1323 | if (s2 !== peg$FAILED) {
|
1324 | while (s2 !== peg$FAILED) {
|
1325 | s1.push(s2);
|
1326 | s2 = peg$currPos;
|
1327 | s3 = peg$currPos;
|
1328 | peg$silentFails++;
|
1329 | if (input.substr(peg$currPos, 2) === peg$c50) {
|
1330 | s4 = peg$c50;
|
1331 | peg$currPos += 2;
|
1332 | } else {
|
1333 | s4 = peg$FAILED;
|
1334 | if (peg$silentFails === 0) { peg$fail(peg$c51); }
|
1335 | }
|
1336 | peg$silentFails--;
|
1337 | if (s4 === peg$FAILED) {
|
1338 | s3 = peg$c6;
|
1339 | } else {
|
1340 | peg$currPos = s3;
|
1341 | s3 = peg$c1;
|
1342 | }
|
1343 | if (s3 !== peg$FAILED) {
|
1344 | s4 = peg$parsetextChar();
|
1345 | if (s4 !== peg$FAILED) {
|
1346 | peg$reportedPos = s2;
|
1347 | s3 = peg$c53(s4);
|
1348 | s2 = s3;
|
1349 | } else {
|
1350 | peg$currPos = s2;
|
1351 | s2 = peg$c1;
|
1352 | }
|
1353 | } else {
|
1354 | peg$currPos = s2;
|
1355 | s2 = peg$c1;
|
1356 | }
|
1357 | }
|
1358 | } else {
|
1359 | s1 = peg$c1;
|
1360 | }
|
1361 | if (s1 !== peg$FAILED) {
|
1362 | peg$reportedPos = s0;
|
1363 | s1 = peg$c54(s1);
|
1364 | }
|
1365 | s0 = s1;
|
1366 |
|
1367 | return s0;
|
1368 | }
|
1369 |
|
1370 | function peg$parsetext() {
|
1371 | var s0, s1, s2;
|
1372 |
|
1373 | s0 = peg$currPos;
|
1374 | s1 = [];
|
1375 | s2 = peg$parsetextChar();
|
1376 | if (s2 !== peg$FAILED) {
|
1377 | while (s2 !== peg$FAILED) {
|
1378 | s1.push(s2);
|
1379 | s2 = peg$parsetextChar();
|
1380 | }
|
1381 | } else {
|
1382 | s1 = peg$c1;
|
1383 | }
|
1384 | if (s1 !== peg$FAILED) {
|
1385 | peg$reportedPos = s0;
|
1386 | s1 = peg$c54(s1);
|
1387 | }
|
1388 | s0 = s1;
|
1389 |
|
1390 | return s0;
|
1391 | }
|
1392 |
|
1393 | function peg$parsetextChar() {
|
1394 | var s0, s1, s2;
|
1395 |
|
1396 | s0 = peg$currPos;
|
1397 | if (input.length > peg$currPos) {
|
1398 | s1 = input.charAt(peg$currPos);
|
1399 | peg$currPos++;
|
1400 | } else {
|
1401 | s1 = peg$FAILED;
|
1402 | if (peg$silentFails === 0) { peg$fail(peg$c55); }
|
1403 | }
|
1404 | if (s1 !== peg$FAILED) {
|
1405 | peg$reportedPos = peg$currPos;
|
1406 | s2 = peg$c56(s1);
|
1407 | if (s2) {
|
1408 | s2 = peg$c6;
|
1409 | } else {
|
1410 | s2 = peg$c1;
|
1411 | }
|
1412 | if (s2 !== peg$FAILED) {
|
1413 | peg$reportedPos = s0;
|
1414 | s1 = peg$c57(s1);
|
1415 | s0 = s1;
|
1416 | } else {
|
1417 | peg$currPos = s0;
|
1418 | s0 = peg$c1;
|
1419 | }
|
1420 | } else {
|
1421 | peg$currPos = s0;
|
1422 | s0 = peg$c1;
|
1423 | }
|
1424 |
|
1425 | return s0;
|
1426 | }
|
1427 |
|
1428 | function peg$parsenonTextChar() {
|
1429 | var s0;
|
1430 |
|
1431 | s0 = peg$parseTERM();
|
1432 | if (s0 === peg$FAILED) {
|
1433 | s0 = peg$parseDEDENT();
|
1434 | if (s0 === peg$FAILED) {
|
1435 | s0 = peg$parseINDENT();
|
1436 | if (s0 === peg$FAILED) {
|
1437 | s0 = peg$parseEOF();
|
1438 | }
|
1439 | }
|
1440 | }
|
1441 |
|
1442 | return s0;
|
1443 | }
|
1444 |
|
1445 | function peg$parsenonInlineTextStart() {
|
1446 | var s0;
|
1447 |
|
1448 | if (peg$c58.test(input.charAt(peg$currPos))) {
|
1449 | s0 = input.charAt(peg$currPos);
|
1450 | peg$currPos++;
|
1451 | } else {
|
1452 | s0 = peg$FAILED;
|
1453 | if (peg$silentFails === 0) { peg$fail(peg$c59); }
|
1454 | }
|
1455 | if (s0 === peg$FAILED) {
|
1456 | s0 = peg$parseTERM();
|
1457 | if (s0 === peg$FAILED) {
|
1458 | s0 = peg$parseDEDENT();
|
1459 | }
|
1460 | }
|
1461 |
|
1462 | return s0;
|
1463 | }
|
1464 |
|
1465 | function peg$parsenonTextStart() {
|
1466 | var s0;
|
1467 |
|
1468 | if (peg$c60.test(input.charAt(peg$currPos))) {
|
1469 | s0 = input.charAt(peg$currPos);
|
1470 | peg$currPos++;
|
1471 | } else {
|
1472 | s0 = peg$FAILED;
|
1473 | if (peg$silentFails === 0) { peg$fail(peg$c61); }
|
1474 | }
|
1475 | if (s0 === peg$FAILED) {
|
1476 | s0 = peg$parseTERM();
|
1477 | if (s0 === peg$FAILED) {
|
1478 | s0 = peg$parseDEDENT();
|
1479 | }
|
1480 | }
|
1481 |
|
1482 | return s0;
|
1483 | }
|
1484 |
|
1485 | function peg$parseINDENT() {
|
1486 | var s0, s1, s2;
|
1487 |
|
1488 | peg$silentFails++;
|
1489 | s0 = peg$currPos;
|
1490 | if (input.length > peg$currPos) {
|
1491 | s1 = input.charAt(peg$currPos);
|
1492 | peg$currPos++;
|
1493 | } else {
|
1494 | s1 = peg$FAILED;
|
1495 | if (peg$silentFails === 0) { peg$fail(peg$c55); }
|
1496 | }
|
1497 | if (s1 !== peg$FAILED) {
|
1498 | peg$reportedPos = peg$currPos;
|
1499 | s2 = peg$c63(s1);
|
1500 | if (s2) {
|
1501 | s2 = peg$c6;
|
1502 | } else {
|
1503 | s2 = peg$c1;
|
1504 | }
|
1505 | if (s2 !== peg$FAILED) {
|
1506 | peg$reportedPos = s0;
|
1507 | s1 = peg$c64(s1);
|
1508 | s0 = s1;
|
1509 | } else {
|
1510 | peg$currPos = s0;
|
1511 | s0 = peg$c1;
|
1512 | }
|
1513 | } else {
|
1514 | peg$currPos = s0;
|
1515 | s0 = peg$c1;
|
1516 | }
|
1517 | peg$silentFails--;
|
1518 | if (s0 === peg$FAILED) {
|
1519 | s1 = peg$FAILED;
|
1520 | if (peg$silentFails === 0) { peg$fail(peg$c62); }
|
1521 | }
|
1522 |
|
1523 | return s0;
|
1524 | }
|
1525 |
|
1526 | function peg$parseDEDENT() {
|
1527 | var s0, s1, s2;
|
1528 |
|
1529 | peg$silentFails++;
|
1530 | s0 = peg$currPos;
|
1531 | if (input.length > peg$currPos) {
|
1532 | s1 = input.charAt(peg$currPos);
|
1533 | peg$currPos++;
|
1534 | } else {
|
1535 | s1 = peg$FAILED;
|
1536 | if (peg$silentFails === 0) { peg$fail(peg$c55); }
|
1537 | }
|
1538 | if (s1 !== peg$FAILED) {
|
1539 | peg$reportedPos = peg$currPos;
|
1540 | s2 = peg$c66(s1);
|
1541 | if (s2) {
|
1542 | s2 = peg$c6;
|
1543 | } else {
|
1544 | s2 = peg$c1;
|
1545 | }
|
1546 | if (s2 !== peg$FAILED) {
|
1547 | peg$reportedPos = s0;
|
1548 | s1 = peg$c64(s1);
|
1549 | s0 = s1;
|
1550 | } else {
|
1551 | peg$currPos = s0;
|
1552 | s0 = peg$c1;
|
1553 | }
|
1554 | } else {
|
1555 | peg$currPos = s0;
|
1556 | s0 = peg$c1;
|
1557 | }
|
1558 | peg$silentFails--;
|
1559 | if (s0 === peg$FAILED) {
|
1560 | s1 = peg$FAILED;
|
1561 | if (peg$silentFails === 0) { peg$fail(peg$c65); }
|
1562 | }
|
1563 |
|
1564 | return s0;
|
1565 | }
|
1566 |
|
1567 | function peg$parseTERM() {
|
1568 | var s0, s1, s2;
|
1569 |
|
1570 | peg$silentFails++;
|
1571 | s0 = peg$currPos;
|
1572 | if (input.length > peg$currPos) {
|
1573 | s1 = input.charAt(peg$currPos);
|
1574 | peg$currPos++;
|
1575 | } else {
|
1576 | s1 = peg$FAILED;
|
1577 | if (peg$silentFails === 0) { peg$fail(peg$c55); }
|
1578 | }
|
1579 | if (s1 !== peg$FAILED) {
|
1580 | peg$reportedPos = peg$currPos;
|
1581 | s2 = peg$c68(s1);
|
1582 | if (s2) {
|
1583 | s2 = peg$c6;
|
1584 | } else {
|
1585 | s2 = peg$c1;
|
1586 | }
|
1587 | if (s2 !== peg$FAILED) {
|
1588 | peg$reportedPos = s0;
|
1589 | s1 = peg$c64(s1);
|
1590 | s0 = s1;
|
1591 | } else {
|
1592 | peg$currPos = s0;
|
1593 | s0 = peg$c1;
|
1594 | }
|
1595 | } else {
|
1596 | peg$currPos = s0;
|
1597 | s0 = peg$c1;
|
1598 | }
|
1599 | peg$silentFails--;
|
1600 | if (s0 === peg$FAILED) {
|
1601 | s1 = peg$FAILED;
|
1602 | if (peg$silentFails === 0) { peg$fail(peg$c67); }
|
1603 | }
|
1604 |
|
1605 | return s0;
|
1606 | }
|
1607 |
|
1608 | function peg$parse__() {
|
1609 | var s0, s1;
|
1610 |
|
1611 | peg$silentFails++;
|
1612 | s0 = [];
|
1613 | s1 = peg$parsewhitespace();
|
1614 | if (s1 !== peg$FAILED) {
|
1615 | while (s1 !== peg$FAILED) {
|
1616 | s0.push(s1);
|
1617 | s1 = peg$parsewhitespace();
|
1618 | }
|
1619 | } else {
|
1620 | s0 = peg$c1;
|
1621 | }
|
1622 | peg$silentFails--;
|
1623 | if (s0 === peg$FAILED) {
|
1624 | s1 = peg$FAILED;
|
1625 | if (peg$silentFails === 0) { peg$fail(peg$c69); }
|
1626 | }
|
1627 |
|
1628 | return s0;
|
1629 | }
|
1630 |
|
1631 | function peg$parse_() {
|
1632 | var s0, s1;
|
1633 |
|
1634 | peg$silentFails++;
|
1635 | s0 = [];
|
1636 | s1 = peg$parsewhitespace();
|
1637 | while (s1 !== peg$FAILED) {
|
1638 | s0.push(s1);
|
1639 | s1 = peg$parsewhitespace();
|
1640 | }
|
1641 | peg$silentFails--;
|
1642 | if (s0 === peg$FAILED) {
|
1643 | s1 = peg$FAILED;
|
1644 | if (peg$silentFails === 0) { peg$fail(peg$c70); }
|
1645 | }
|
1646 |
|
1647 | return s0;
|
1648 | }
|
1649 |
|
1650 | function peg$parsewhitespace() {
|
1651 | var s0;
|
1652 |
|
1653 | if (peg$c71.test(input.charAt(peg$currPos))) {
|
1654 | s0 = input.charAt(peg$currPos);
|
1655 | peg$currPos++;
|
1656 | } else {
|
1657 | s0 = peg$FAILED;
|
1658 | if (peg$silentFails === 0) { peg$fail(peg$c72); }
|
1659 | }
|
1660 |
|
1661 | return s0;
|
1662 | }
|
1663 |
|
1664 | function peg$parseEOF() {
|
1665 | var s0, s1;
|
1666 |
|
1667 | s0 = peg$currPos;
|
1668 | peg$silentFails++;
|
1669 | if (input.length > peg$currPos) {
|
1670 | s1 = input.charAt(peg$currPos);
|
1671 | peg$currPos++;
|
1672 | } else {
|
1673 | s1 = peg$FAILED;
|
1674 | if (peg$silentFails === 0) { peg$fail(peg$c55); }
|
1675 | }
|
1676 | peg$silentFails--;
|
1677 | if (s1 === peg$FAILED) {
|
1678 | s0 = peg$c6;
|
1679 | } else {
|
1680 | peg$currPos = s0;
|
1681 | s0 = peg$c1;
|
1682 | }
|
1683 |
|
1684 | return s0;
|
1685 | }
|
1686 |
|
1687 |
|
1688 | var INDENT_CHAR = options.INDENT_CHAR || '\uEFEF',
|
1689 | DEDENT_CHAR = options.DEDENT_CHAR || '\uEFFE',
|
1690 | TERM_CHAR = options.TERM_CHAR || '\uEFFF';
|
1691 |
|
1692 | function array(input){
|
1693 | if(typeof(input) !== 'array'){
|
1694 | input = [input];
|
1695 | }
|
1696 | return input;
|
1697 | }
|
1698 |
|
1699 | function compact(input){
|
1700 | if(typeof(input) === 'array'){
|
1701 | if(input.length === 0){
|
1702 | return;
|
1703 | }
|
1704 | }else if(typeof(input) === 'object'){
|
1705 | if(Object.keys(input).length === 0){
|
1706 | return;
|
1707 | }
|
1708 | }
|
1709 | return input;
|
1710 | }
|
1711 |
|
1712 | function isArray(thing) {
|
1713 | if( Object.prototype.toString.call(thing) === '[object Array]' ) {
|
1714 | return true;
|
1715 | }
|
1716 | return false;
|
1717 | }
|
1718 |
|
1719 | function condense(objects) {
|
1720 | var target = {}, sources;
|
1721 | if(isArray(objects)){
|
1722 | sources = objects;
|
1723 | }else{
|
1724 | sources = [].slice.call(arguments, 0);
|
1725 | }
|
1726 | sources.forEach(function (source) {
|
1727 | for (var prop in source) {
|
1728 | if(target[prop]){
|
1729 | target[prop] = array(target[prop]);
|
1730 | target[prop].push(source[prop]);
|
1731 | }else{
|
1732 | target[prop] = source[prop];
|
1733 | }
|
1734 | }
|
1735 | });
|
1736 | return target;
|
1737 | }
|
1738 |
|
1739 | function addProperties(target, key, value) {
|
1740 | if(Object.keys(value).length > 0){
|
1741 | target[key] = value;
|
1742 | }
|
1743 | }
|
1744 |
|
1745 | function addProperty(target, key, value) {
|
1746 | if(typeof(value) !== 'undefined' && value !== null){
|
1747 | target[key] = value;
|
1748 | }
|
1749 | }
|
1750 |
|
1751 |
|
1752 | peg$result = peg$startRuleFunction();
|
1753 |
|
1754 | if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
1755 | return peg$result;
|
1756 | } else {
|
1757 | if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
1758 | peg$fail({ type: "end", description: "end of input" });
|
1759 | }
|
1760 |
|
1761 | throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
|
1762 | }
|
1763 | }
|
1764 |
|
1765 | return {
|
1766 | SyntaxError: SyntaxError,
|
1767 | parse: parse
|
1768 | };
|
1769 | })(); |
\ | No newline at end of file |