| 1 |
"use strict"; |
| 2 |
var wp; |
| 3 |
(wp ||= {}).blockSerializationSpecParser = (() => { |
| 4 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 5 |
var __commonJS = (cb, mod) => function __require() { |
| 6 |
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; |
| 7 |
}; |
| 8 |
|
| 9 |
// packages/block-serialization-spec-parser/parser.js |
| 10 |
var require_parser = __commonJS({ |
| 11 |
"packages/block-serialization-spec-parser/parser.js"(exports, module) { |
| 12 |
function peg$subclass(child, parent) { |
| 13 |
function ctor() { |
| 14 |
this.constructor = child; |
| 15 |
} |
| 16 |
ctor.prototype = parent.prototype; |
| 17 |
child.prototype = new ctor(); |
| 18 |
} |
| 19 |
function peg$SyntaxError(message, expected, found, location) { |
| 20 |
this.message = message; |
| 21 |
this.expected = expected; |
| 22 |
this.found = found; |
| 23 |
this.location = location; |
| 24 |
this.name = "SyntaxError"; |
| 25 |
if (typeof Error.captureStackTrace === "function") { |
| 26 |
Error.captureStackTrace(this, peg$SyntaxError); |
| 27 |
} |
| 28 |
} |
| 29 |
peg$subclass(peg$SyntaxError, Error); |
| 30 |
peg$SyntaxError.buildMessage = function(expected, found) { |
| 31 |
var DESCRIBE_EXPECTATION_FNS = { |
| 32 |
literal: function(expectation) { |
| 33 |
return '"' + literalEscape(expectation.text) + '"'; |
| 34 |
}, |
| 35 |
"class": function(expectation) { |
| 36 |
var escapedParts = "", i; |
| 37 |
for (i = 0; i < expectation.parts.length; i++) { |
| 38 |
escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]); |
| 39 |
} |
| 40 |
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; |
| 41 |
}, |
| 42 |
any: function(expectation) { |
| 43 |
return "any character"; |
| 44 |
}, |
| 45 |
end: function(expectation) { |
| 46 |
return "end of input"; |
| 47 |
}, |
| 48 |
other: function(expectation) { |
| 49 |
return expectation.description; |
| 50 |
} |
| 51 |
}; |
| 52 |
function hex(ch) { |
| 53 |
return ch.charCodeAt(0).toString(16).toUpperCase(); |
| 54 |
} |
| 55 |
function literalEscape(s) { |
| 56 |
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) { |
| 57 |
return "\\x0" + hex(ch); |
| 58 |
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { |
| 59 |
return "\\x" + hex(ch); |
| 60 |
}); |
| 61 |
} |
| 62 |
function classEscape(s) { |
| 63 |
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) { |
| 64 |
return "\\x0" + hex(ch); |
| 65 |
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { |
| 66 |
return "\\x" + hex(ch); |
| 67 |
}); |
| 68 |
} |
| 69 |
function describeExpectation(expectation) { |
| 70 |
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); |
| 71 |
} |
| 72 |
function describeExpected(expected2) { |
| 73 |
var descriptions = new Array(expected2.length), i, j; |
| 74 |
for (i = 0; i < expected2.length; i++) { |
| 75 |
descriptions[i] = describeExpectation(expected2[i]); |
| 76 |
} |
| 77 |
descriptions.sort(); |
| 78 |
if (descriptions.length > 0) { |
| 79 |
for (i = 1, j = 1; i < descriptions.length; i++) { |
| 80 |
if (descriptions[i - 1] !== descriptions[i]) { |
| 81 |
descriptions[j] = descriptions[i]; |
| 82 |
j++; |
| 83 |
} |
| 84 |
} |
| 85 |
descriptions.length = j; |
| 86 |
} |
| 87 |
switch (descriptions.length) { |
| 88 |
case 1: |
| 89 |
return descriptions[0]; |
| 90 |
case 2: |
| 91 |
return descriptions[0] + " or " + descriptions[1]; |
| 92 |
default: |
| 93 |
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; |
| 94 |
} |
| 95 |
} |
| 96 |
function describeFound(found2) { |
| 97 |
return found2 ? '"' + literalEscape(found2) + '"' : "end of input"; |
| 98 |
} |
| 99 |
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; |
| 100 |
}; |
| 101 |
function peg$parse(input, options) { |
| 102 |
options = options !== void 0 ? options : {}; |
| 103 |
var peg$FAILED = {}, peg$startRuleFunctions = { Block_List: peg$parseBlock_List }, peg$startRuleFunction = peg$parseBlock_List, peg$c0 = peg$anyExpectation(), peg$c1 = function(pre, b, html) { |
| 104 |
return [b, html]; |
| 105 |
}, peg$c2 = function(pre, bs, post) { |
| 106 |
return joinBlocks(pre, bs, post); |
| 107 |
}, peg$c3 = "<!--", peg$c4 = peg$literalExpectation("<!--", false), peg$c5 = "wp:", peg$c6 = peg$literalExpectation("wp:", false), peg$c7 = function(blockName, a) { |
| 108 |
return a; |
| 109 |
}, peg$c8 = "/-->", peg$c9 = peg$literalExpectation("/-->", false), peg$c10 = function(blockName, attrs) { |
| 110 |
return { |
| 111 |
blockName, |
| 112 |
attrs: attrs || {}, |
| 113 |
innerBlocks: [], |
| 114 |
innerHTML: "", |
| 115 |
innerContent: [] |
| 116 |
}; |
| 117 |
}, peg$c11 = function(s, children, e) { |
| 118 |
var innerParts = processInnerContent(children); |
| 119 |
var innerHTML = innerParts[0]; |
| 120 |
var innerBlocks = innerParts[1]; |
| 121 |
var innerContent = innerParts[2]; |
| 122 |
return { |
| 123 |
blockName: s.blockName, |
| 124 |
attrs: s.attrs, |
| 125 |
innerBlocks, |
| 126 |
innerHTML, |
| 127 |
innerContent |
| 128 |
}; |
| 129 |
}, peg$c12 = "-->", peg$c13 = peg$literalExpectation("-->", false), peg$c14 = function(blockName, attrs) { |
| 130 |
return { |
| 131 |
blockName, |
| 132 |
attrs: attrs || {} |
| 133 |
}; |
| 134 |
}, peg$c15 = "/wp:", peg$c16 = peg$literalExpectation("/wp:", false), peg$c17 = function(blockName) { |
| 135 |
return { |
| 136 |
blockName |
| 137 |
}; |
| 138 |
}, peg$c18 = "/", peg$c19 = peg$literalExpectation("/", false), peg$c20 = function(type) { |
| 139 |
return "core/" + type; |
| 140 |
}, peg$c21 = /^[a-z]/, peg$c22 = peg$classExpectation([["a", "z"]], false, false), peg$c23 = /^[a-z0-9_\-]/, peg$c24 = peg$classExpectation([["a", "z"], ["0", "9"], "_", "-"], false, false), peg$c25 = peg$otherExpectation("JSON-encoded attributes embedded in a block's opening comment"), peg$c26 = "{", peg$c27 = peg$literalExpectation("{", false), peg$c28 = "}", peg$c29 = peg$literalExpectation("}", false), peg$c30 = "", peg$c31 = function(attrs) { |
| 141 |
return maybeJSON(attrs); |
| 142 |
}, peg$c32 = /^[ \t\r\n]/, peg$c33 = peg$classExpectation([" ", " ", "\r", "\n"], false, false), peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result; |
| 143 |
if ("startRule" in options) { |
| 144 |
if (!(options.startRule in peg$startRuleFunctions)) { |
| 145 |
throw new Error(`Can't start parsing from rule "` + options.startRule + '".'); |
| 146 |
} |
| 147 |
peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; |
| 148 |
} |
| 149 |
function text() { |
| 150 |
return input.substring(peg$savedPos, peg$currPos); |
| 151 |
} |
| 152 |
function location() { |
| 153 |
return peg$computeLocation(peg$savedPos, peg$currPos); |
| 154 |
} |
| 155 |
function expected(description, location2) { |
| 156 |
location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos); |
| 157 |
throw peg$buildStructuredError( |
| 158 |
[peg$otherExpectation(description)], |
| 159 |
input.substring(peg$savedPos, peg$currPos), |
| 160 |
location2 |
| 161 |
); |
| 162 |
} |
| 163 |
function error(message, location2) { |
| 164 |
location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos); |
| 165 |
throw peg$buildSimpleError(message, location2); |
| 166 |
} |
| 167 |
function peg$literalExpectation(text2, ignoreCase) { |
| 168 |
return { type: "literal", text: text2, ignoreCase }; |
| 169 |
} |
| 170 |
function peg$classExpectation(parts, inverted, ignoreCase) { |
| 171 |
return { type: "class", parts, inverted, ignoreCase }; |
| 172 |
} |
| 173 |
function peg$anyExpectation() { |
| 174 |
return { type: "any" }; |
| 175 |
} |
| 176 |
function peg$endExpectation() { |
| 177 |
return { type: "end" }; |
| 178 |
} |
| 179 |
function peg$otherExpectation(description) { |
| 180 |
return { type: "other", description }; |
| 181 |
} |
| 182 |
function peg$computePosDetails(pos) { |
| 183 |
var details = peg$posDetailsCache[pos], p; |
| 184 |
if (details) { |
| 185 |
return details; |
| 186 |
} else { |
| 187 |
p = pos - 1; |
| 188 |
while (!peg$posDetailsCache[p]) { |
| 189 |
p--; |
| 190 |
} |
| 191 |
details = peg$posDetailsCache[p]; |
| 192 |
details = { |
| 193 |
line: details.line, |
| 194 |
column: details.column |
| 195 |
}; |
| 196 |
while (p < pos) { |
| 197 |
if (input.charCodeAt(p) === 10) { |
| 198 |
details.line++; |
| 199 |
details.column = 1; |
| 200 |
} else { |
| 201 |
details.column++; |
| 202 |
} |
| 203 |
p++; |
| 204 |
} |
| 205 |
peg$posDetailsCache[pos] = details; |
| 206 |
return details; |
| 207 |
} |
| 208 |
} |
| 209 |
function peg$computeLocation(startPos, endPos) { |
| 210 |
var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos); |
| 211 |
return { |
| 212 |
start: { |
| 213 |
offset: startPos, |
| 214 |
line: startPosDetails.line, |
| 215 |
column: startPosDetails.column |
| 216 |
}, |
| 217 |
end: { |
| 218 |
offset: endPos, |
| 219 |
line: endPosDetails.line, |
| 220 |
column: endPosDetails.column |
| 221 |
} |
| 222 |
}; |
| 223 |
} |
| 224 |
function peg$fail(expected2) { |
| 225 |
if (peg$currPos < peg$maxFailPos) { |
| 226 |
return; |
| 227 |
} |
| 228 |
if (peg$currPos > peg$maxFailPos) { |
| 229 |
peg$maxFailPos = peg$currPos; |
| 230 |
peg$maxFailExpected = []; |
| 231 |
} |
| 232 |
peg$maxFailExpected.push(expected2); |
| 233 |
} |
| 234 |
function peg$buildSimpleError(message, location2) { |
| 235 |
return new peg$SyntaxError(message, null, null, location2); |
| 236 |
} |
| 237 |
function peg$buildStructuredError(expected2, found, location2) { |
| 238 |
return new peg$SyntaxError( |
| 239 |
peg$SyntaxError.buildMessage(expected2, found), |
| 240 |
expected2, |
| 241 |
found, |
| 242 |
location2 |
| 243 |
); |
| 244 |
} |
| 245 |
function peg$parseBlock_List() { |
| 246 |
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; |
| 247 |
s0 = peg$currPos; |
| 248 |
s1 = peg$currPos; |
| 249 |
s2 = []; |
| 250 |
s3 = peg$currPos; |
| 251 |
s4 = peg$currPos; |
| 252 |
peg$silentFails++; |
| 253 |
s5 = peg$parseBlock(); |
| 254 |
peg$silentFails--; |
| 255 |
if (s5 === peg$FAILED) { |
| 256 |
s4 = void 0; |
| 257 |
} else { |
| 258 |
peg$currPos = s4; |
| 259 |
s4 = peg$FAILED; |
| 260 |
} |
| 261 |
if (s4 !== peg$FAILED) { |
| 262 |
if (input.length > peg$currPos) { |
| 263 |
s5 = input.charAt(peg$currPos); |
| 264 |
peg$currPos++; |
| 265 |
} else { |
| 266 |
s5 = peg$FAILED; |
| 267 |
if (peg$silentFails === 0) { |
| 268 |
peg$fail(peg$c0); |
| 269 |
} |
| 270 |
} |
| 271 |
if (s5 !== peg$FAILED) { |
| 272 |
s4 = [s4, s5]; |
| 273 |
s3 = s4; |
| 274 |
} else { |
| 275 |
peg$currPos = s3; |
| 276 |
s3 = peg$FAILED; |
| 277 |
} |
| 278 |
} else { |
| 279 |
peg$currPos = s3; |
| 280 |
s3 = peg$FAILED; |
| 281 |
} |
| 282 |
while (s3 !== peg$FAILED) { |
| 283 |
s2.push(s3); |
| 284 |
s3 = peg$currPos; |
| 285 |
s4 = peg$currPos; |
| 286 |
peg$silentFails++; |
| 287 |
s5 = peg$parseBlock(); |
| 288 |
peg$silentFails--; |
| 289 |
if (s5 === peg$FAILED) { |
| 290 |
s4 = void 0; |
| 291 |
} else { |
| 292 |
peg$currPos = s4; |
| 293 |
s4 = peg$FAILED; |
| 294 |
} |
| 295 |
if (s4 !== peg$FAILED) { |
| 296 |
if (input.length > peg$currPos) { |
| 297 |
s5 = input.charAt(peg$currPos); |
| 298 |
peg$currPos++; |
| 299 |
} else { |
| 300 |
s5 = peg$FAILED; |
| 301 |
if (peg$silentFails === 0) { |
| 302 |
peg$fail(peg$c0); |
| 303 |
} |
| 304 |
} |
| 305 |
if (s5 !== peg$FAILED) { |
| 306 |
s4 = [s4, s5]; |
| 307 |
s3 = s4; |
| 308 |
} else { |
| 309 |
peg$currPos = s3; |
| 310 |
s3 = peg$FAILED; |
| 311 |
} |
| 312 |
} else { |
| 313 |
peg$currPos = s3; |
| 314 |
s3 = peg$FAILED; |
| 315 |
} |
| 316 |
} |
| 317 |
if (s2 !== peg$FAILED) { |
| 318 |
s1 = input.substring(s1, peg$currPos); |
| 319 |
} else { |
| 320 |
s1 = s2; |
| 321 |
} |
| 322 |
if (s1 !== peg$FAILED) { |
| 323 |
s2 = []; |
| 324 |
s3 = peg$currPos; |
| 325 |
s4 = peg$parseBlock(); |
| 326 |
if (s4 !== peg$FAILED) { |
| 327 |
s5 = peg$currPos; |
| 328 |
s6 = []; |
| 329 |
s7 = peg$currPos; |
| 330 |
s8 = peg$currPos; |
| 331 |
peg$silentFails++; |
| 332 |
s9 = peg$parseBlock(); |
| 333 |
peg$silentFails--; |
| 334 |
if (s9 === peg$FAILED) { |
| 335 |
s8 = void 0; |
| 336 |
} else { |
| 337 |
peg$currPos = s8; |
| 338 |
s8 = peg$FAILED; |
| 339 |
} |
| 340 |
if (s8 !== peg$FAILED) { |
| 341 |
if (input.length > peg$currPos) { |
| 342 |
s9 = input.charAt(peg$currPos); |
| 343 |
peg$currPos++; |
| 344 |
} else { |
| 345 |
s9 = peg$FAILED; |
| 346 |
if (peg$silentFails === 0) { |
| 347 |
peg$fail(peg$c0); |
| 348 |
} |
| 349 |
} |
| 350 |
if (s9 !== peg$FAILED) { |
| 351 |
s8 = [s8, s9]; |
| 352 |
s7 = s8; |
| 353 |
} else { |
| 354 |
peg$currPos = s7; |
| 355 |
s7 = peg$FAILED; |
| 356 |
} |
| 357 |
} else { |
| 358 |
peg$currPos = s7; |
| 359 |
s7 = peg$FAILED; |
| 360 |
} |
| 361 |
while (s7 !== peg$FAILED) { |
| 362 |
s6.push(s7); |
| 363 |
s7 = peg$currPos; |
| 364 |
s8 = peg$currPos; |
| 365 |
peg$silentFails++; |
| 366 |
s9 = peg$parseBlock(); |
| 367 |
peg$silentFails--; |
| 368 |
if (s9 === peg$FAILED) { |
| 369 |
s8 = void 0; |
| 370 |
} else { |
| 371 |
peg$currPos = s8; |
| 372 |
s8 = peg$FAILED; |
| 373 |
} |
| 374 |
if (s8 !== peg$FAILED) { |
| 375 |
if (input.length > peg$currPos) { |
| 376 |
s9 = input.charAt(peg$currPos); |
| 377 |
peg$currPos++; |
| 378 |
} else { |
| 379 |
s9 = peg$FAILED; |
| 380 |
if (peg$silentFails === 0) { |
| 381 |
peg$fail(peg$c0); |
| 382 |
} |
| 383 |
} |
| 384 |
if (s9 !== peg$FAILED) { |
| 385 |
s8 = [s8, s9]; |
| 386 |
s7 = s8; |
| 387 |
} else { |
| 388 |
peg$currPos = s7; |
| 389 |
s7 = peg$FAILED; |
| 390 |
} |
| 391 |
} else { |
| 392 |
peg$currPos = s7; |
| 393 |
s7 = peg$FAILED; |
| 394 |
} |
| 395 |
} |
| 396 |
if (s6 !== peg$FAILED) { |
| 397 |
s5 = input.substring(s5, peg$currPos); |
| 398 |
} else { |
| 399 |
s5 = s6; |
| 400 |
} |
| 401 |
if (s5 !== peg$FAILED) { |
| 402 |
peg$savedPos = s3; |
| 403 |
s4 = peg$c1(s1, s4, s5); |
| 404 |
s3 = s4; |
| 405 |
} else { |
| 406 |
peg$currPos = s3; |
| 407 |
s3 = peg$FAILED; |
| 408 |
} |
| 409 |
} else { |
| 410 |
peg$currPos = s3; |
| 411 |
s3 = peg$FAILED; |
| 412 |
} |
| 413 |
while (s3 !== peg$FAILED) { |
| 414 |
s2.push(s3); |
| 415 |
s3 = peg$currPos; |
| 416 |
s4 = peg$parseBlock(); |
| 417 |
if (s4 !== peg$FAILED) { |
| 418 |
s5 = peg$currPos; |
| 419 |
s6 = []; |
| 420 |
s7 = peg$currPos; |
| 421 |
s8 = peg$currPos; |
| 422 |
peg$silentFails++; |
| 423 |
s9 = peg$parseBlock(); |
| 424 |
peg$silentFails--; |
| 425 |
if (s9 === peg$FAILED) { |
| 426 |
s8 = void 0; |
| 427 |
} else { |
| 428 |
peg$currPos = s8; |
| 429 |
s8 = peg$FAILED; |
| 430 |
} |
| 431 |
if (s8 !== peg$FAILED) { |
| 432 |
if (input.length > peg$currPos) { |
| 433 |
s9 = input.charAt(peg$currPos); |
| 434 |
peg$currPos++; |
| 435 |
} else { |
| 436 |
s9 = peg$FAILED; |
| 437 |
if (peg$silentFails === 0) { |
| 438 |
peg$fail(peg$c0); |
| 439 |
} |
| 440 |
} |
| 441 |
if (s9 !== peg$FAILED) { |
| 442 |
s8 = [s8, s9]; |
| 443 |
s7 = s8; |
| 444 |
} else { |
| 445 |
peg$currPos = s7; |
| 446 |
s7 = peg$FAILED; |
| 447 |
} |
| 448 |
} else { |
| 449 |
peg$currPos = s7; |
| 450 |
s7 = peg$FAILED; |
| 451 |
} |
| 452 |
while (s7 !== peg$FAILED) { |
| 453 |
s6.push(s7); |
| 454 |
s7 = peg$currPos; |
| 455 |
s8 = peg$currPos; |
| 456 |
peg$silentFails++; |
| 457 |
s9 = peg$parseBlock(); |
| 458 |
peg$silentFails--; |
| 459 |
if (s9 === peg$FAILED) { |
| 460 |
s8 = void 0; |
| 461 |
} else { |
| 462 |
peg$currPos = s8; |
| 463 |
s8 = peg$FAILED; |
| 464 |
} |
| 465 |
if (s8 !== peg$FAILED) { |
| 466 |
if (input.length > peg$currPos) { |
| 467 |
s9 = input.charAt(peg$currPos); |
| 468 |
peg$currPos++; |
| 469 |
} else { |
| 470 |
s9 = peg$FAILED; |
| 471 |
if (peg$silentFails === 0) { |
| 472 |
peg$fail(peg$c0); |
| 473 |
} |
| 474 |
} |
| 475 |
if (s9 !== peg$FAILED) { |
| 476 |
s8 = [s8, s9]; |
| 477 |
s7 = s8; |
| 478 |
} else { |
| 479 |
peg$currPos = s7; |
| 480 |
s7 = peg$FAILED; |
| 481 |
} |
| 482 |
} else { |
| 483 |
peg$currPos = s7; |
| 484 |
s7 = peg$FAILED; |
| 485 |
} |
| 486 |
} |
| 487 |
if (s6 !== peg$FAILED) { |
| 488 |
s5 = input.substring(s5, peg$currPos); |
| 489 |
} else { |
| 490 |
s5 = s6; |
| 491 |
} |
| 492 |
if (s5 !== peg$FAILED) { |
| 493 |
peg$savedPos = s3; |
| 494 |
s4 = peg$c1(s1, s4, s5); |
| 495 |
s3 = s4; |
| 496 |
} else { |
| 497 |
peg$currPos = s3; |
| 498 |
s3 = peg$FAILED; |
| 499 |
} |
| 500 |
} else { |
| 501 |
peg$currPos = s3; |
| 502 |
s3 = peg$FAILED; |
| 503 |
} |
| 504 |
} |
| 505 |
if (s2 !== peg$FAILED) { |
| 506 |
s3 = peg$currPos; |
| 507 |
s4 = []; |
| 508 |
if (input.length > peg$currPos) { |
| 509 |
s5 = input.charAt(peg$currPos); |
| 510 |
peg$currPos++; |
| 511 |
} else { |
| 512 |
s5 = peg$FAILED; |
| 513 |
if (peg$silentFails === 0) { |
| 514 |
peg$fail(peg$c0); |
| 515 |
} |
| 516 |
} |
| 517 |
while (s5 !== peg$FAILED) { |
| 518 |
s4.push(s5); |
| 519 |
if (input.length > peg$currPos) { |
| 520 |
s5 = input.charAt(peg$currPos); |
| 521 |
peg$currPos++; |
| 522 |
} else { |
| 523 |
s5 = peg$FAILED; |
| 524 |
if (peg$silentFails === 0) { |
| 525 |
peg$fail(peg$c0); |
| 526 |
} |
| 527 |
} |
| 528 |
} |
| 529 |
if (s4 !== peg$FAILED) { |
| 530 |
s3 = input.substring(s3, peg$currPos); |
| 531 |
} else { |
| 532 |
s3 = s4; |
| 533 |
} |
| 534 |
if (s3 !== peg$FAILED) { |
| 535 |
peg$savedPos = s0; |
| 536 |
s1 = peg$c2(s1, s2, s3); |
| 537 |
s0 = s1; |
| 538 |
} else { |
| 539 |
peg$currPos = s0; |
| 540 |
s0 = peg$FAILED; |
| 541 |
} |
| 542 |
} else { |
| 543 |
peg$currPos = s0; |
| 544 |
s0 = peg$FAILED; |
| 545 |
} |
| 546 |
} else { |
| 547 |
peg$currPos = s0; |
| 548 |
s0 = peg$FAILED; |
| 549 |
} |
| 550 |
return s0; |
| 551 |
} |
| 552 |
function peg$parseBlock() { |
| 553 |
var s0; |
| 554 |
s0 = peg$parseBlock_Void(); |
| 555 |
if (s0 === peg$FAILED) { |
| 556 |
s0 = peg$parseBlock_Balanced(); |
| 557 |
} |
| 558 |
return s0; |
| 559 |
} |
| 560 |
function peg$parseBlock_Void() { |
| 561 |
var s0, s1, s2, s3, s4, s5, s6, s7, s8; |
| 562 |
s0 = peg$currPos; |
| 563 |
if (input.substr(peg$currPos, 4) === peg$c3) { |
| 564 |
s1 = peg$c3; |
| 565 |
peg$currPos += 4; |
| 566 |
} else { |
| 567 |
s1 = peg$FAILED; |
| 568 |
if (peg$silentFails === 0) { |
| 569 |
peg$fail(peg$c4); |
| 570 |
} |
| 571 |
} |
| 572 |
if (s1 !== peg$FAILED) { |
| 573 |
s2 = peg$parse__(); |
| 574 |
if (s2 !== peg$FAILED) { |
| 575 |
if (input.substr(peg$currPos, 3) === peg$c5) { |
| 576 |
s3 = peg$c5; |
| 577 |
peg$currPos += 3; |
| 578 |
} else { |
| 579 |
s3 = peg$FAILED; |
| 580 |
if (peg$silentFails === 0) { |
| 581 |
peg$fail(peg$c6); |
| 582 |
} |
| 583 |
} |
| 584 |
if (s3 !== peg$FAILED) { |
| 585 |
s4 = peg$parseBlock_Name(); |
| 586 |
if (s4 !== peg$FAILED) { |
| 587 |
s5 = peg$parse__(); |
| 588 |
if (s5 !== peg$FAILED) { |
| 589 |
s6 = peg$currPos; |
| 590 |
s7 = peg$parseBlock_Attributes(); |
| 591 |
if (s7 !== peg$FAILED) { |
| 592 |
s8 = peg$parse__(); |
| 593 |
if (s8 !== peg$FAILED) { |
| 594 |
peg$savedPos = s6; |
| 595 |
s7 = peg$c7(s4, s7); |
| 596 |
s6 = s7; |
| 597 |
} else { |
| 598 |
peg$currPos = s6; |
| 599 |
s6 = peg$FAILED; |
| 600 |
} |
| 601 |
} else { |
| 602 |
peg$currPos = s6; |
| 603 |
s6 = peg$FAILED; |
| 604 |
} |
| 605 |
if (s6 === peg$FAILED) { |
| 606 |
s6 = null; |
| 607 |
} |
| 608 |
if (s6 !== peg$FAILED) { |
| 609 |
if (input.substr(peg$currPos, 4) === peg$c8) { |
| 610 |
s7 = peg$c8; |
| 611 |
peg$currPos += 4; |
| 612 |
} else { |
| 613 |
s7 = peg$FAILED; |
| 614 |
if (peg$silentFails === 0) { |
| 615 |
peg$fail(peg$c9); |
| 616 |
} |
| 617 |
} |
| 618 |
if (s7 !== peg$FAILED) { |
| 619 |
peg$savedPos = s0; |
| 620 |
s1 = peg$c10(s4, s6); |
| 621 |
s0 = s1; |
| 622 |
} else { |
| 623 |
peg$currPos = s0; |
| 624 |
s0 = peg$FAILED; |
| 625 |
} |
| 626 |
} else { |
| 627 |
peg$currPos = s0; |
| 628 |
s0 = peg$FAILED; |
| 629 |
} |
| 630 |
} else { |
| 631 |
peg$currPos = s0; |
| 632 |
s0 = peg$FAILED; |
| 633 |
} |
| 634 |
} else { |
| 635 |
peg$currPos = s0; |
| 636 |
s0 = peg$FAILED; |
| 637 |
} |
| 638 |
} else { |
| 639 |
peg$currPos = s0; |
| 640 |
s0 = peg$FAILED; |
| 641 |
} |
| 642 |
} else { |
| 643 |
peg$currPos = s0; |
| 644 |
s0 = peg$FAILED; |
| 645 |
} |
| 646 |
} else { |
| 647 |
peg$currPos = s0; |
| 648 |
s0 = peg$FAILED; |
| 649 |
} |
| 650 |
return s0; |
| 651 |
} |
| 652 |
function peg$parseBlock_Balanced() { |
| 653 |
var s0, s1, s2, s3, s4, s5, s6, s7, s8; |
| 654 |
s0 = peg$currPos; |
| 655 |
s1 = peg$parseBlock_Start(); |
| 656 |
if (s1 !== peg$FAILED) { |
| 657 |
s2 = []; |
| 658 |
s3 = peg$parseBlock(); |
| 659 |
if (s3 === peg$FAILED) { |
| 660 |
s3 = peg$currPos; |
| 661 |
s4 = []; |
| 662 |
s5 = peg$currPos; |
| 663 |
s6 = peg$currPos; |
| 664 |
peg$silentFails++; |
| 665 |
s7 = peg$parseBlock(); |
| 666 |
peg$silentFails--; |
| 667 |
if (s7 === peg$FAILED) { |
| 668 |
s6 = void 0; |
| 669 |
} else { |
| 670 |
peg$currPos = s6; |
| 671 |
s6 = peg$FAILED; |
| 672 |
} |
| 673 |
if (s6 !== peg$FAILED) { |
| 674 |
s7 = peg$currPos; |
| 675 |
peg$silentFails++; |
| 676 |
s8 = peg$parseBlock_End(); |
| 677 |
peg$silentFails--; |
| 678 |
if (s8 === peg$FAILED) { |
| 679 |
s7 = void 0; |
| 680 |
} else { |
| 681 |
peg$currPos = s7; |
| 682 |
s7 = peg$FAILED; |
| 683 |
} |
| 684 |
if (s7 !== peg$FAILED) { |
| 685 |
if (input.length > peg$currPos) { |
| 686 |
s8 = input.charAt(peg$currPos); |
| 687 |
peg$currPos++; |
| 688 |
} else { |
| 689 |
s8 = peg$FAILED; |
| 690 |
if (peg$silentFails === 0) { |
| 691 |
peg$fail(peg$c0); |
| 692 |
} |
| 693 |
} |
| 694 |
if (s8 !== peg$FAILED) { |
| 695 |
s6 = [s6, s7, s8]; |
| 696 |
s5 = s6; |
| 697 |
} else { |
| 698 |
peg$currPos = s5; |
| 699 |
s5 = peg$FAILED; |
| 700 |
} |
| 701 |
} else { |
| 702 |
peg$currPos = s5; |
| 703 |
s5 = peg$FAILED; |
| 704 |
} |
| 705 |
} else { |
| 706 |
peg$currPos = s5; |
| 707 |
s5 = peg$FAILED; |
| 708 |
} |
| 709 |
if (s5 !== peg$FAILED) { |
| 710 |
while (s5 !== peg$FAILED) { |
| 711 |
s4.push(s5); |
| 712 |
s5 = peg$currPos; |
| 713 |
s6 = peg$currPos; |
| 714 |
peg$silentFails++; |
| 715 |
s7 = peg$parseBlock(); |
| 716 |
peg$silentFails--; |
| 717 |
if (s7 === peg$FAILED) { |
| 718 |
s6 = void 0; |
| 719 |
} else { |
| 720 |
peg$currPos = s6; |
| 721 |
s6 = peg$FAILED; |
| 722 |
} |
| 723 |
if (s6 !== peg$FAILED) { |
| 724 |
s7 = peg$currPos; |
| 725 |
peg$silentFails++; |
| 726 |
s8 = peg$parseBlock_End(); |
| 727 |
peg$silentFails--; |
| 728 |
if (s8 === peg$FAILED) { |
| 729 |
s7 = void 0; |
| 730 |
} else { |
| 731 |
peg$currPos = s7; |
| 732 |
s7 = peg$FAILED; |
| 733 |
} |
| 734 |
if (s7 !== peg$FAILED) { |
| 735 |
if (input.length > peg$currPos) { |
| 736 |
s8 = input.charAt(peg$currPos); |
| 737 |
peg$currPos++; |
| 738 |
} else { |
| 739 |
s8 = peg$FAILED; |
| 740 |
if (peg$silentFails === 0) { |
| 741 |
peg$fail(peg$c0); |
| 742 |
} |
| 743 |
} |
| 744 |
if (s8 !== peg$FAILED) { |
| 745 |
s6 = [s6, s7, s8]; |
| 746 |
s5 = s6; |
| 747 |
} else { |
| 748 |
peg$currPos = s5; |
| 749 |
s5 = peg$FAILED; |
| 750 |
} |
| 751 |
} else { |
| 752 |
peg$currPos = s5; |
| 753 |
s5 = peg$FAILED; |
| 754 |
} |
| 755 |
} else { |
| 756 |
peg$currPos = s5; |
| 757 |
s5 = peg$FAILED; |
| 758 |
} |
| 759 |
} |
| 760 |
} else { |
| 761 |
s4 = peg$FAILED; |
| 762 |
} |
| 763 |
if (s4 !== peg$FAILED) { |
| 764 |
s3 = input.substring(s3, peg$currPos); |
| 765 |
} else { |
| 766 |
s3 = s4; |
| 767 |
} |
| 768 |
} |
| 769 |
while (s3 !== peg$FAILED) { |
| 770 |
s2.push(s3); |
| 771 |
s3 = peg$parseBlock(); |
| 772 |
if (s3 === peg$FAILED) { |
| 773 |
s3 = peg$currPos; |
| 774 |
s4 = []; |
| 775 |
s5 = peg$currPos; |
| 776 |
s6 = peg$currPos; |
| 777 |
peg$silentFails++; |
| 778 |
s7 = peg$parseBlock(); |
| 779 |
peg$silentFails--; |
| 780 |
if (s7 === peg$FAILED) { |
| 781 |
s6 = void 0; |
| 782 |
} else { |
| 783 |
peg$currPos = s6; |
| 784 |
s6 = peg$FAILED; |
| 785 |
} |
| 786 |
if (s6 !== peg$FAILED) { |
| 787 |
s7 = peg$currPos; |
| 788 |
peg$silentFails++; |
| 789 |
s8 = peg$parseBlock_End(); |
| 790 |
peg$silentFails--; |
| 791 |
if (s8 === peg$FAILED) { |
| 792 |
s7 = void 0; |
| 793 |
} else { |
| 794 |
peg$currPos = s7; |
| 795 |
s7 = peg$FAILED; |
| 796 |
} |
| 797 |
if (s7 !== peg$FAILED) { |
| 798 |
if (input.length > peg$currPos) { |
| 799 |
s8 = input.charAt(peg$currPos); |
| 800 |
peg$currPos++; |
| 801 |
} else { |
| 802 |
s8 = peg$FAILED; |
| 803 |
if (peg$silentFails === 0) { |
| 804 |
peg$fail(peg$c0); |
| 805 |
} |
| 806 |
} |
| 807 |
if (s8 !== peg$FAILED) { |
| 808 |
s6 = [s6, s7, s8]; |
| 809 |
s5 = s6; |
| 810 |
} else { |
| 811 |
peg$currPos = s5; |
| 812 |
s5 = peg$FAILED; |
| 813 |
} |
| 814 |
} else { |
| 815 |
peg$currPos = s5; |
| 816 |
s5 = peg$FAILED; |
| 817 |
} |
| 818 |
} else { |
| 819 |
peg$currPos = s5; |
| 820 |
s5 = peg$FAILED; |
| 821 |
} |
| 822 |
if (s5 !== peg$FAILED) { |
| 823 |
while (s5 !== peg$FAILED) { |
| 824 |
s4.push(s5); |
| 825 |
s5 = peg$currPos; |
| 826 |
s6 = peg$currPos; |
| 827 |
peg$silentFails++; |
| 828 |
s7 = peg$parseBlock(); |
| 829 |
peg$silentFails--; |
| 830 |
if (s7 === peg$FAILED) { |
| 831 |
s6 = void 0; |
| 832 |
} else { |
| 833 |
peg$currPos = s6; |
| 834 |
s6 = peg$FAILED; |
| 835 |
} |
| 836 |
if (s6 !== peg$FAILED) { |
| 837 |
s7 = peg$currPos; |
| 838 |
peg$silentFails++; |
| 839 |
s8 = peg$parseBlock_End(); |
| 840 |
peg$silentFails--; |
| 841 |
if (s8 === peg$FAILED) { |
| 842 |
s7 = void 0; |
| 843 |
} else { |
| 844 |
peg$currPos = s7; |
| 845 |
s7 = peg$FAILED; |
| 846 |
} |
| 847 |
if (s7 !== peg$FAILED) { |
| 848 |
if (input.length > peg$currPos) { |
| 849 |
s8 = input.charAt(peg$currPos); |
| 850 |
peg$currPos++; |
| 851 |
} else { |
| 852 |
s8 = peg$FAILED; |
| 853 |
if (peg$silentFails === 0) { |
| 854 |
peg$fail(peg$c0); |
| 855 |
} |
| 856 |
} |
| 857 |
if (s8 !== peg$FAILED) { |
| 858 |
s6 = [s6, s7, s8]; |
| 859 |
s5 = s6; |
| 860 |
} else { |
| 861 |
peg$currPos = s5; |
| 862 |
s5 = peg$FAILED; |
| 863 |
} |
| 864 |
} else { |
| 865 |
peg$currPos = s5; |
| 866 |
s5 = peg$FAILED; |
| 867 |
} |
| 868 |
} else { |
| 869 |
peg$currPos = s5; |
| 870 |
s5 = peg$FAILED; |
| 871 |
} |
| 872 |
} |
| 873 |
} else { |
| 874 |
s4 = peg$FAILED; |
| 875 |
} |
| 876 |
if (s4 !== peg$FAILED) { |
| 877 |
s3 = input.substring(s3, peg$currPos); |
| 878 |
} else { |
| 879 |
s3 = s4; |
| 880 |
} |
| 881 |
} |
| 882 |
} |
| 883 |
if (s2 !== peg$FAILED) { |
| 884 |
s3 = peg$parseBlock_End(); |
| 885 |
if (s3 !== peg$FAILED) { |
| 886 |
peg$savedPos = s0; |
| 887 |
s1 = peg$c11(s1, s2, s3); |
| 888 |
s0 = s1; |
| 889 |
} else { |
| 890 |
peg$currPos = s0; |
| 891 |
s0 = peg$FAILED; |
| 892 |
} |
| 893 |
} else { |
| 894 |
peg$currPos = s0; |
| 895 |
s0 = peg$FAILED; |
| 896 |
} |
| 897 |
} else { |
| 898 |
peg$currPos = s0; |
| 899 |
s0 = peg$FAILED; |
| 900 |
} |
| 901 |
return s0; |
| 902 |
} |
| 903 |
function peg$parseBlock_Start() { |
| 904 |
var s0, s1, s2, s3, s4, s5, s6, s7, s8; |
| 905 |
s0 = peg$currPos; |
| 906 |
if (input.substr(peg$currPos, 4) === peg$c3) { |
| 907 |
s1 = peg$c3; |
| 908 |
peg$currPos += 4; |
| 909 |
} else { |
| 910 |
s1 = peg$FAILED; |
| 911 |
if (peg$silentFails === 0) { |
| 912 |
peg$fail(peg$c4); |
| 913 |
} |
| 914 |
} |
| 915 |
if (s1 !== peg$FAILED) { |
| 916 |
s2 = peg$parse__(); |
| 917 |
if (s2 !== peg$FAILED) { |
| 918 |
if (input.substr(peg$currPos, 3) === peg$c5) { |
| 919 |
s3 = peg$c5; |
| 920 |
peg$currPos += 3; |
| 921 |
} else { |
| 922 |
s3 = peg$FAILED; |
| 923 |
if (peg$silentFails === 0) { |
| 924 |
peg$fail(peg$c6); |
| 925 |
} |
| 926 |
} |
| 927 |
if (s3 !== peg$FAILED) { |
| 928 |
s4 = peg$parseBlock_Name(); |
| 929 |
if (s4 !== peg$FAILED) { |
| 930 |
s5 = peg$parse__(); |
| 931 |
if (s5 !== peg$FAILED) { |
| 932 |
s6 = peg$currPos; |
| 933 |
s7 = peg$parseBlock_Attributes(); |
| 934 |
if (s7 !== peg$FAILED) { |
| 935 |
s8 = peg$parse__(); |
| 936 |
if (s8 !== peg$FAILED) { |
| 937 |
peg$savedPos = s6; |
| 938 |
s7 = peg$c7(s4, s7); |
| 939 |
s6 = s7; |
| 940 |
} else { |
| 941 |
peg$currPos = s6; |
| 942 |
s6 = peg$FAILED; |
| 943 |
} |
| 944 |
} else { |
| 945 |
peg$currPos = s6; |
| 946 |
s6 = peg$FAILED; |
| 947 |
} |
| 948 |
if (s6 === peg$FAILED) { |
| 949 |
s6 = null; |
| 950 |
} |
| 951 |
if (s6 !== peg$FAILED) { |
| 952 |
if (input.substr(peg$currPos, 3) === peg$c12) { |
| 953 |
s7 = peg$c12; |
| 954 |
peg$currPos += 3; |
| 955 |
} else { |
| 956 |
s7 = peg$FAILED; |
| 957 |
if (peg$silentFails === 0) { |
| 958 |
peg$fail(peg$c13); |
| 959 |
} |
| 960 |
} |
| 961 |
if (s7 !== peg$FAILED) { |
| 962 |
peg$savedPos = s0; |
| 963 |
s1 = peg$c14(s4, s6); |
| 964 |
s0 = s1; |
| 965 |
} else { |
| 966 |
peg$currPos = s0; |
| 967 |
s0 = peg$FAILED; |
| 968 |
} |
| 969 |
} else { |
| 970 |
peg$currPos = s0; |
| 971 |
s0 = peg$FAILED; |
| 972 |
} |
| 973 |
} else { |
| 974 |
peg$currPos = s0; |
| 975 |
s0 = peg$FAILED; |
| 976 |
} |
| 977 |
} else { |
| 978 |
peg$currPos = s0; |
| 979 |
s0 = peg$FAILED; |
| 980 |
} |
| 981 |
} else { |
| 982 |
peg$currPos = s0; |
| 983 |
s0 = peg$FAILED; |
| 984 |
} |
| 985 |
} else { |
| 986 |
peg$currPos = s0; |
| 987 |
s0 = peg$FAILED; |
| 988 |
} |
| 989 |
} else { |
| 990 |
peg$currPos = s0; |
| 991 |
s0 = peg$FAILED; |
| 992 |
} |
| 993 |
return s0; |
| 994 |
} |
| 995 |
function peg$parseBlock_End() { |
| 996 |
var s0, s1, s2, s3, s4, s5, s6; |
| 997 |
s0 = peg$currPos; |
| 998 |
if (input.substr(peg$currPos, 4) === peg$c3) { |
| 999 |
s1 = peg$c3; |
| 1000 |
peg$currPos += 4; |
| 1001 |
} else { |
| 1002 |
s1 = peg$FAILED; |
| 1003 |
if (peg$silentFails === 0) { |
| 1004 |
peg$fail(peg$c4); |
| 1005 |
} |
| 1006 |
} |
| 1007 |
if (s1 !== peg$FAILED) { |
| 1008 |
s2 = peg$parse__(); |
| 1009 |
if (s2 !== peg$FAILED) { |
| 1010 |
if (input.substr(peg$currPos, 4) === peg$c15) { |
| 1011 |
s3 = peg$c15; |
| 1012 |
peg$currPos += 4; |
| 1013 |
} else { |
| 1014 |
s3 = peg$FAILED; |
| 1015 |
if (peg$silentFails === 0) { |
| 1016 |
peg$fail(peg$c16); |
| 1017 |
} |
| 1018 |
} |
| 1019 |
if (s3 !== peg$FAILED) { |
| 1020 |
s4 = peg$parseBlock_Name(); |
| 1021 |
if (s4 !== peg$FAILED) { |
| 1022 |
s5 = peg$parse__(); |
| 1023 |
if (s5 !== peg$FAILED) { |
| 1024 |
if (input.substr(peg$currPos, 3) === peg$c12) { |
| 1025 |
s6 = peg$c12; |
| 1026 |
peg$currPos += 3; |
| 1027 |
} else { |
| 1028 |
s6 = peg$FAILED; |
| 1029 |
if (peg$silentFails === 0) { |
| 1030 |
peg$fail(peg$c13); |
| 1031 |
} |
| 1032 |
} |
| 1033 |
if (s6 !== peg$FAILED) { |
| 1034 |
peg$savedPos = s0; |
| 1035 |
s1 = peg$c17(s4); |
| 1036 |
s0 = s1; |
| 1037 |
} else { |
| 1038 |
peg$currPos = s0; |
| 1039 |
s0 = peg$FAILED; |
| 1040 |
} |
| 1041 |
} else { |
| 1042 |
peg$currPos = s0; |
| 1043 |
s0 = peg$FAILED; |
| 1044 |
} |
| 1045 |
} else { |
| 1046 |
peg$currPos = s0; |
| 1047 |
s0 = peg$FAILED; |
| 1048 |
} |
| 1049 |
} else { |
| 1050 |
peg$currPos = s0; |
| 1051 |
s0 = peg$FAILED; |
| 1052 |
} |
| 1053 |
} else { |
| 1054 |
peg$currPos = s0; |
| 1055 |
s0 = peg$FAILED; |
| 1056 |
} |
| 1057 |
} else { |
| 1058 |
peg$currPos = s0; |
| 1059 |
s0 = peg$FAILED; |
| 1060 |
} |
| 1061 |
return s0; |
| 1062 |
} |
| 1063 |
function peg$parseBlock_Name() { |
| 1064 |
var s0; |
| 1065 |
s0 = peg$parseNamespaced_Block_Name(); |
| 1066 |
if (s0 === peg$FAILED) { |
| 1067 |
s0 = peg$parseCore_Block_Name(); |
| 1068 |
} |
| 1069 |
return s0; |
| 1070 |
} |
| 1071 |
function peg$parseNamespaced_Block_Name() { |
| 1072 |
var s0, s1, s2, s3, s4; |
| 1073 |
s0 = peg$currPos; |
| 1074 |
s1 = peg$currPos; |
| 1075 |
s2 = peg$parseBlock_Name_Part(); |
| 1076 |
if (s2 !== peg$FAILED) { |
| 1077 |
if (input.charCodeAt(peg$currPos) === 47) { |
| 1078 |
s3 = peg$c18; |
| 1079 |
peg$currPos++; |
| 1080 |
} else { |
| 1081 |
s3 = peg$FAILED; |
| 1082 |
if (peg$silentFails === 0) { |
| 1083 |
peg$fail(peg$c19); |
| 1084 |
} |
| 1085 |
} |
| 1086 |
if (s3 !== peg$FAILED) { |
| 1087 |
s4 = peg$parseBlock_Name_Part(); |
| 1088 |
if (s4 !== peg$FAILED) { |
| 1089 |
s2 = [s2, s3, s4]; |
| 1090 |
s1 = s2; |
| 1091 |
} else { |
| 1092 |
peg$currPos = s1; |
| 1093 |
s1 = peg$FAILED; |
| 1094 |
} |
| 1095 |
} else { |
| 1096 |
peg$currPos = s1; |
| 1097 |
s1 = peg$FAILED; |
| 1098 |
} |
| 1099 |
} else { |
| 1100 |
peg$currPos = s1; |
| 1101 |
s1 = peg$FAILED; |
| 1102 |
} |
| 1103 |
if (s1 !== peg$FAILED) { |
| 1104 |
s0 = input.substring(s0, peg$currPos); |
| 1105 |
} else { |
| 1106 |
s0 = s1; |
| 1107 |
} |
| 1108 |
return s0; |
| 1109 |
} |
| 1110 |
function peg$parseCore_Block_Name() { |
| 1111 |
var s0, s1, s2; |
| 1112 |
s0 = peg$currPos; |
| 1113 |
s1 = peg$currPos; |
| 1114 |
s2 = peg$parseBlock_Name_Part(); |
| 1115 |
if (s2 !== peg$FAILED) { |
| 1116 |
s1 = input.substring(s1, peg$currPos); |
| 1117 |
} else { |
| 1118 |
s1 = s2; |
| 1119 |
} |
| 1120 |
if (s1 !== peg$FAILED) { |
| 1121 |
peg$savedPos = s0; |
| 1122 |
s1 = peg$c20(s1); |
| 1123 |
} |
| 1124 |
s0 = s1; |
| 1125 |
return s0; |
| 1126 |
} |
| 1127 |
function peg$parseBlock_Name_Part() { |
| 1128 |
var s0, s1, s2, s3, s4; |
| 1129 |
s0 = peg$currPos; |
| 1130 |
s1 = peg$currPos; |
| 1131 |
if (peg$c21.test(input.charAt(peg$currPos))) { |
| 1132 |
s2 = input.charAt(peg$currPos); |
| 1133 |
peg$currPos++; |
| 1134 |
} else { |
| 1135 |
s2 = peg$FAILED; |
| 1136 |
if (peg$silentFails === 0) { |
| 1137 |
peg$fail(peg$c22); |
| 1138 |
} |
| 1139 |
} |
| 1140 |
if (s2 !== peg$FAILED) { |
| 1141 |
s3 = []; |
| 1142 |
if (peg$c23.test(input.charAt(peg$currPos))) { |
| 1143 |
s4 = input.charAt(peg$currPos); |
| 1144 |
peg$currPos++; |
| 1145 |
} else { |
| 1146 |
s4 = peg$FAILED; |
| 1147 |
if (peg$silentFails === 0) { |
| 1148 |
peg$fail(peg$c24); |
| 1149 |
} |
| 1150 |
} |
| 1151 |
while (s4 !== peg$FAILED) { |
| 1152 |
s3.push(s4); |
| 1153 |
if (peg$c23.test(input.charAt(peg$currPos))) { |
| 1154 |
s4 = input.charAt(peg$currPos); |
| 1155 |
peg$currPos++; |
| 1156 |
} else { |
| 1157 |
s4 = peg$FAILED; |
| 1158 |
if (peg$silentFails === 0) { |
| 1159 |
peg$fail(peg$c24); |
| 1160 |
} |
| 1161 |
} |
| 1162 |
} |
| 1163 |
if (s3 !== peg$FAILED) { |
| 1164 |
s2 = [s2, s3]; |
| 1165 |
s1 = s2; |
| 1166 |
} else { |
| 1167 |
peg$currPos = s1; |
| 1168 |
s1 = peg$FAILED; |
| 1169 |
} |
| 1170 |
} else { |
| 1171 |
peg$currPos = s1; |
| 1172 |
s1 = peg$FAILED; |
| 1173 |
} |
| 1174 |
if (s1 !== peg$FAILED) { |
| 1175 |
s0 = input.substring(s0, peg$currPos); |
| 1176 |
} else { |
| 1177 |
s0 = s1; |
| 1178 |
} |
| 1179 |
return s0; |
| 1180 |
} |
| 1181 |
function peg$parseBlock_Attributes() { |
| 1182 |
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12; |
| 1183 |
peg$silentFails++; |
| 1184 |
s0 = peg$currPos; |
| 1185 |
s1 = peg$currPos; |
| 1186 |
s2 = peg$currPos; |
| 1187 |
if (input.charCodeAt(peg$currPos) === 123) { |
| 1188 |
s3 = peg$c26; |
| 1189 |
peg$currPos++; |
| 1190 |
} else { |
| 1191 |
s3 = peg$FAILED; |
| 1192 |
if (peg$silentFails === 0) { |
| 1193 |
peg$fail(peg$c27); |
| 1194 |
} |
| 1195 |
} |
| 1196 |
if (s3 !== peg$FAILED) { |
| 1197 |
s4 = []; |
| 1198 |
s5 = peg$currPos; |
| 1199 |
s6 = peg$currPos; |
| 1200 |
peg$silentFails++; |
| 1201 |
s7 = peg$currPos; |
| 1202 |
if (input.charCodeAt(peg$currPos) === 125) { |
| 1203 |
s8 = peg$c28; |
| 1204 |
peg$currPos++; |
| 1205 |
} else { |
| 1206 |
s8 = peg$FAILED; |
| 1207 |
if (peg$silentFails === 0) { |
| 1208 |
peg$fail(peg$c29); |
| 1209 |
} |
| 1210 |
} |
| 1211 |
if (s8 !== peg$FAILED) { |
| 1212 |
s9 = peg$parse__(); |
| 1213 |
if (s9 !== peg$FAILED) { |
| 1214 |
s10 = peg$c30; |
| 1215 |
if (s10 !== peg$FAILED) { |
| 1216 |
if (input.charCodeAt(peg$currPos) === 47) { |
| 1217 |
s11 = peg$c18; |
| 1218 |
peg$currPos++; |
| 1219 |
} else { |
| 1220 |
s11 = peg$FAILED; |
| 1221 |
if (peg$silentFails === 0) { |
| 1222 |
peg$fail(peg$c19); |
| 1223 |
} |
| 1224 |
} |
| 1225 |
if (s11 === peg$FAILED) { |
| 1226 |
s11 = null; |
| 1227 |
} |
| 1228 |
if (s11 !== peg$FAILED) { |
| 1229 |
if (input.substr(peg$currPos, 3) === peg$c12) { |
| 1230 |
s12 = peg$c12; |
| 1231 |
peg$currPos += 3; |
| 1232 |
} else { |
| 1233 |
s12 = peg$FAILED; |
| 1234 |
if (peg$silentFails === 0) { |
| 1235 |
peg$fail(peg$c13); |
| 1236 |
} |
| 1237 |
} |
| 1238 |
if (s12 !== peg$FAILED) { |
| 1239 |
s8 = [s8, s9, s10, s11, s12]; |
| 1240 |
s7 = s8; |
| 1241 |
} else { |
| 1242 |
peg$currPos = s7; |
| 1243 |
s7 = peg$FAILED; |
| 1244 |
} |
| 1245 |
} else { |
| 1246 |
peg$currPos = s7; |
| 1247 |
s7 = peg$FAILED; |
| 1248 |
} |
| 1249 |
} else { |
| 1250 |
peg$currPos = s7; |
| 1251 |
s7 = peg$FAILED; |
| 1252 |
} |
| 1253 |
} else { |
| 1254 |
peg$currPos = s7; |
| 1255 |
s7 = peg$FAILED; |
| 1256 |
} |
| 1257 |
} else { |
| 1258 |
peg$currPos = s7; |
| 1259 |
s7 = peg$FAILED; |
| 1260 |
} |
| 1261 |
peg$silentFails--; |
| 1262 |
if (s7 === peg$FAILED) { |
| 1263 |
s6 = void 0; |
| 1264 |
} else { |
| 1265 |
peg$currPos = s6; |
| 1266 |
s6 = peg$FAILED; |
| 1267 |
} |
| 1268 |
if (s6 !== peg$FAILED) { |
| 1269 |
if (input.length > peg$currPos) { |
| 1270 |
s7 = input.charAt(peg$currPos); |
| 1271 |
peg$currPos++; |
| 1272 |
} else { |
| 1273 |
s7 = peg$FAILED; |
| 1274 |
if (peg$silentFails === 0) { |
| 1275 |
peg$fail(peg$c0); |
| 1276 |
} |
| 1277 |
} |
| 1278 |
if (s7 !== peg$FAILED) { |
| 1279 |
s6 = [s6, s7]; |
| 1280 |
s5 = s6; |
| 1281 |
} else { |
| 1282 |
peg$currPos = s5; |
| 1283 |
s5 = peg$FAILED; |
| 1284 |
} |
| 1285 |
} else { |
| 1286 |
peg$currPos = s5; |
| 1287 |
s5 = peg$FAILED; |
| 1288 |
} |
| 1289 |
while (s5 !== peg$FAILED) { |
| 1290 |
s4.push(s5); |
| 1291 |
s5 = peg$currPos; |
| 1292 |
s6 = peg$currPos; |
| 1293 |
peg$silentFails++; |
| 1294 |
s7 = peg$currPos; |
| 1295 |
if (input.charCodeAt(peg$currPos) === 125) { |
| 1296 |
s8 = peg$c28; |
| 1297 |
peg$currPos++; |
| 1298 |
} else { |
| 1299 |
s8 = peg$FAILED; |
| 1300 |
if (peg$silentFails === 0) { |
| 1301 |
peg$fail(peg$c29); |
| 1302 |
} |
| 1303 |
} |
| 1304 |
if (s8 !== peg$FAILED) { |
| 1305 |
s9 = peg$parse__(); |
| 1306 |
if (s9 !== peg$FAILED) { |
| 1307 |
s10 = peg$c30; |
| 1308 |
if (s10 !== peg$FAILED) { |
| 1309 |
if (input.charCodeAt(peg$currPos) === 47) { |
| 1310 |
s11 = peg$c18; |
| 1311 |
peg$currPos++; |
| 1312 |
} else { |
| 1313 |
s11 = peg$FAILED; |
| 1314 |
if (peg$silentFails === 0) { |
| 1315 |
peg$fail(peg$c19); |
| 1316 |
} |
| 1317 |
} |
| 1318 |
if (s11 === peg$FAILED) { |
| 1319 |
s11 = null; |
| 1320 |
} |
| 1321 |
if (s11 !== peg$FAILED) { |
| 1322 |
if (input.substr(peg$currPos, 3) === peg$c12) { |
| 1323 |
s12 = peg$c12; |
| 1324 |
peg$currPos += 3; |
| 1325 |
} else { |
| 1326 |
s12 = peg$FAILED; |
| 1327 |
if (peg$silentFails === 0) { |
| 1328 |
peg$fail(peg$c13); |
| 1329 |
} |
| 1330 |
} |
| 1331 |
if (s12 !== peg$FAILED) { |
| 1332 |
s8 = [s8, s9, s10, s11, s12]; |
| 1333 |
s7 = s8; |
| 1334 |
} else { |
| 1335 |
peg$currPos = s7; |
| 1336 |
s7 = peg$FAILED; |
| 1337 |
} |
| 1338 |
} else { |
| 1339 |
peg$currPos = s7; |
| 1340 |
s7 = peg$FAILED; |
| 1341 |
} |
| 1342 |
} else { |
| 1343 |
peg$currPos = s7; |
| 1344 |
s7 = peg$FAILED; |
| 1345 |
} |
| 1346 |
} else { |
| 1347 |
peg$currPos = s7; |
| 1348 |
s7 = peg$FAILED; |
| 1349 |
} |
| 1350 |
} else { |
| 1351 |
peg$currPos = s7; |
| 1352 |
s7 = peg$FAILED; |
| 1353 |
} |
| 1354 |
peg$silentFails--; |
| 1355 |
if (s7 === peg$FAILED) { |
| 1356 |
s6 = void 0; |
| 1357 |
} else { |
| 1358 |
peg$currPos = s6; |
| 1359 |
s6 = peg$FAILED; |
| 1360 |
} |
| 1361 |
if (s6 !== peg$FAILED) { |
| 1362 |
if (input.length > peg$currPos) { |
| 1363 |
s7 = input.charAt(peg$currPos); |
| 1364 |
peg$currPos++; |
| 1365 |
} else { |
| 1366 |
s7 = peg$FAILED; |
| 1367 |
if (peg$silentFails === 0) { |
| 1368 |
peg$fail(peg$c0); |
| 1369 |
} |
| 1370 |
} |
| 1371 |
if (s7 !== peg$FAILED) { |
| 1372 |
s6 = [s6, s7]; |
| 1373 |
s5 = s6; |
| 1374 |
} else { |
| 1375 |
peg$currPos = s5; |
| 1376 |
s5 = peg$FAILED; |
| 1377 |
} |
| 1378 |
} else { |
| 1379 |
peg$currPos = s5; |
| 1380 |
s5 = peg$FAILED; |
| 1381 |
} |
| 1382 |
} |
| 1383 |
if (s4 !== peg$FAILED) { |
| 1384 |
if (input.charCodeAt(peg$currPos) === 125) { |
| 1385 |
s5 = peg$c28; |
| 1386 |
peg$currPos++; |
| 1387 |
} else { |
| 1388 |
s5 = peg$FAILED; |
| 1389 |
if (peg$silentFails === 0) { |
| 1390 |
peg$fail(peg$c29); |
| 1391 |
} |
| 1392 |
} |
| 1393 |
if (s5 !== peg$FAILED) { |
| 1394 |
s3 = [s3, s4, s5]; |
| 1395 |
s2 = s3; |
| 1396 |
} else { |
| 1397 |
peg$currPos = s2; |
| 1398 |
s2 = peg$FAILED; |
| 1399 |
} |
| 1400 |
} else { |
| 1401 |
peg$currPos = s2; |
| 1402 |
s2 = peg$FAILED; |
| 1403 |
} |
| 1404 |
} else { |
| 1405 |
peg$currPos = s2; |
| 1406 |
s2 = peg$FAILED; |
| 1407 |
} |
| 1408 |
if (s2 !== peg$FAILED) { |
| 1409 |
s1 = input.substring(s1, peg$currPos); |
| 1410 |
} else { |
| 1411 |
s1 = s2; |
| 1412 |
} |
| 1413 |
if (s1 !== peg$FAILED) { |
| 1414 |
peg$savedPos = s0; |
| 1415 |
s1 = peg$c31(s1); |
| 1416 |
} |
| 1417 |
s0 = s1; |
| 1418 |
peg$silentFails--; |
| 1419 |
if (s0 === peg$FAILED) { |
| 1420 |
s1 = peg$FAILED; |
| 1421 |
if (peg$silentFails === 0) { |
| 1422 |
peg$fail(peg$c25); |
| 1423 |
} |
| 1424 |
} |
| 1425 |
return s0; |
| 1426 |
} |
| 1427 |
function peg$parse__() { |
| 1428 |
var s0, s1; |
| 1429 |
s0 = []; |
| 1430 |
if (peg$c32.test(input.charAt(peg$currPos))) { |
| 1431 |
s1 = input.charAt(peg$currPos); |
| 1432 |
peg$currPos++; |
| 1433 |
} else { |
| 1434 |
s1 = peg$FAILED; |
| 1435 |
if (peg$silentFails === 0) { |
| 1436 |
peg$fail(peg$c33); |
| 1437 |
} |
| 1438 |
} |
| 1439 |
if (s1 !== peg$FAILED) { |
| 1440 |
while (s1 !== peg$FAILED) { |
| 1441 |
s0.push(s1); |
| 1442 |
if (peg$c32.test(input.charAt(peg$currPos))) { |
| 1443 |
s1 = input.charAt(peg$currPos); |
| 1444 |
peg$currPos++; |
| 1445 |
} else { |
| 1446 |
s1 = peg$FAILED; |
| 1447 |
if (peg$silentFails === 0) { |
| 1448 |
peg$fail(peg$c33); |
| 1449 |
} |
| 1450 |
} |
| 1451 |
} |
| 1452 |
} else { |
| 1453 |
s0 = peg$FAILED; |
| 1454 |
} |
| 1455 |
return s0; |
| 1456 |
} |
| 1457 |
function freeform(s) { |
| 1458 |
return s.length && { |
| 1459 |
blockName: null, |
| 1460 |
attrs: {}, |
| 1461 |
innerBlocks: [], |
| 1462 |
innerHTML: s, |
| 1463 |
innerContent: [s] |
| 1464 |
}; |
| 1465 |
} |
| 1466 |
function joinBlocks(pre, tokens, post) { |
| 1467 |
var blocks = [], i, l, html, item, token; |
| 1468 |
if (pre.length) { |
| 1469 |
blocks.push(freeform(pre)); |
| 1470 |
} |
| 1471 |
for (i = 0, l = tokens.length; i < l; i++) { |
| 1472 |
item = tokens[i]; |
| 1473 |
token = item[0]; |
| 1474 |
html = item[1]; |
| 1475 |
blocks.push(token); |
| 1476 |
if (html.length) { |
| 1477 |
blocks.push(freeform(html)); |
| 1478 |
} |
| 1479 |
} |
| 1480 |
if (post.length) { |
| 1481 |
blocks.push(freeform(post)); |
| 1482 |
} |
| 1483 |
return blocks; |
| 1484 |
} |
| 1485 |
function maybeJSON(s) { |
| 1486 |
try { |
| 1487 |
return JSON.parse(s); |
| 1488 |
} catch (e) { |
| 1489 |
return null; |
| 1490 |
} |
| 1491 |
} |
| 1492 |
function processInnerContent(list) { |
| 1493 |
var i, l, item; |
| 1494 |
var html = ""; |
| 1495 |
var blocks = []; |
| 1496 |
var content = []; |
| 1497 |
for (i = 0, l = list.length; i < l; i++) { |
| 1498 |
item = list[i]; |
| 1499 |
if ("string" === typeof item) { |
| 1500 |
html += item; |
| 1501 |
content.push(item); |
| 1502 |
} else { |
| 1503 |
blocks.push(item); |
| 1504 |
content.push(null); |
| 1505 |
} |
| 1506 |
} |
| 1507 |
; |
| 1508 |
return [html, blocks, content]; |
| 1509 |
} |
| 1510 |
peg$result = peg$startRuleFunction(); |
| 1511 |
if (peg$result !== peg$FAILED && peg$currPos === input.length) { |
| 1512 |
return peg$result; |
| 1513 |
} else { |
| 1514 |
if (peg$result !== peg$FAILED && peg$currPos < input.length) { |
| 1515 |
peg$fail(peg$endExpectation()); |
| 1516 |
} |
| 1517 |
throw peg$buildStructuredError( |
| 1518 |
peg$maxFailExpected, |
| 1519 |
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, |
| 1520 |
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) |
| 1521 |
); |
| 1522 |
} |
| 1523 |
} |
| 1524 |
module.exports = { |
| 1525 |
SyntaxError: peg$SyntaxError, |
| 1526 |
parse: peg$parse |
| 1527 |
}; |
| 1528 |
} |
| 1529 |
}); |
| 1530 |
return require_parser(); |
| 1531 |
})(); |
| 1532 |
//# sourceMappingURL=index.js.map |
| 1533 |
|