@wordpress/block-serialization-spec-parser 2.0.4 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/parser.php ADDED
@@ -0,0 +1,1681 @@
1
+ <?php
2
+ /*
3
+ * Generated by PEG.js 0.10.x with phpegjs plugin
4
+ *
5
+ * http://pegjs.majda.cz/
6
+ */
7
+
8
+
9
+ /* Useful functions: */
10
+
11
+ /* Gutenberg_PEG_chr_unicode - get unicode character from its char code */
12
+ if (!function_exists("Gutenberg_PEG_chr_unicode")) {
13
+ function Gutenberg_PEG_chr_unicode($code) {
14
+ return html_entity_decode("&#$code;", ENT_QUOTES, "UTF-8");
15
+ }
16
+ }
17
+ /* Gutenberg_PEG_ord_unicode - get unicode char code from string */
18
+ if (!function_exists("Gutenberg_PEG_ord_unicode")) {
19
+ function Gutenberg_PEG_ord_unicode($character) {
20
+ if (strlen($character) === 1) {
21
+ return ord($character);
22
+ }
23
+ $json = json_encode($character);
24
+ $utf16_1 = hexdec(substr($json, 3, 4));
25
+ if (substr($json, 7, 2) === "\u") {
26
+ $utf16_2 = hexdec(substr($json, 9, 4));
27
+ return 0x10000 + (($utf16_1 & 0x3ff) << 10) + ($utf16_2 & 0x3ff);
28
+ } else {
29
+ return $utf16_1;
30
+ }
31
+ }
32
+ }
33
+ /* Gutenberg_PEG_peg_char_class_test - simple character class test */
34
+ if (!function_exists("Gutenberg_PEG_peg_char_class_test")) {
35
+ function Gutenberg_PEG_peg_char_class_test($class, $character) {
36
+ $code = Gutenberg_PEG_ord_unicode($character);
37
+ foreach ($class as $range) {
38
+ if ($code >= $range[0] && $code <= $range[1]) {
39
+ return true;
40
+ }
41
+ }
42
+ return false;
43
+ }
44
+ }
45
+
46
+ /* Syntax error exception */
47
+ if (!class_exists("Gutenberg_PEG_SyntaxError", false)) {
48
+ class Gutenberg_PEG_SyntaxError extends Exception {
49
+ public $expected;
50
+ public $found;
51
+ public $grammarOffset;
52
+ public $grammarLine;
53
+ public $grammarColumn;
54
+ public $name;
55
+ public function __construct($message, $expected, $found, $offset, $line, $column) {
56
+ parent::__construct($message, 0);
57
+ $this->expected = $expected;
58
+ $this->found = $found;
59
+ $this->grammarOffset = $offset;
60
+ $this->grammarLine = $line;
61
+ $this->grammarColumn = $column;
62
+ $this->name = "Gutenberg_PEG_SyntaxError";
63
+ }
64
+ }
65
+ }
66
+
67
+ class Gutenberg_PEG_Parser {
68
+ private $peg_currPos = 0;
69
+ private $peg_reportedPos = 0;
70
+ private $peg_cachedPos = 0;
71
+ private $peg_cachedPosDetails = array('line' => 1, 'column' => 1, 'seenCR' => false );
72
+ private $peg_maxFailPos = 0;
73
+ private $peg_maxFailExpected = array();
74
+ private $peg_silentFails = 0;
75
+ private $input = array();
76
+ private $input_length = 0;
77
+
78
+ private function cleanup_state() {
79
+ $this->peg_currPos = 0;
80
+ $this->peg_reportedPos = 0;
81
+ $this->peg_cachedPos = 0;
82
+ $this->peg_cachedPosDetails = array('line' => 1, 'column' => 1, 'seenCR' => false );
83
+ $this->peg_maxFailPos = 0;
84
+ $this->peg_maxFailExpected = array();
85
+ $this->peg_silentFails = 0;
86
+ $this->input = array();
87
+ $this->input_length = 0;
88
+
89
+ }
90
+
91
+ private function input_substr($start, $length) {
92
+ if ($length === 1 && $start < $this->input_length) {
93
+ return $this->input[$start];
94
+ }
95
+ $substr = '';
96
+ $max = min($start + $length, $this->input_length);
97
+ for ($i = $start; $i < $max; $i++) {
98
+ $substr .= $this->input[$i];
99
+ }
100
+ return $substr;
101
+ }
102
+
103
+
104
+ private function text() {
105
+ return substr($this->input, $this->peg_reportedPos, $this->peg_reportedPos + $this->peg_currPos);
106
+ }
107
+
108
+ private function offset() {
109
+ return $this->peg_reportedPos;
110
+ }
111
+
112
+ private function line() {
113
+ $compute_pd = $this->peg_computePosDetails($this->peg_reportedPos);
114
+ return $compute_pd["line"];
115
+ }
116
+
117
+ private function column() {
118
+ $compute_pd = $this->peg_computePosDetails($this->peg_reportedPos);
119
+ return $compute_pd["column"];
120
+ }
121
+
122
+ private function expected($description) {
123
+ throw $this->peg_buildException(
124
+ null,
125
+ array(array("type" => "other", "description" => $description )),
126
+ $this->peg_reportedPos
127
+ );
128
+ }
129
+
130
+ private function error($message) {
131
+ throw $this->peg_buildException($message, null, $this->peg_reportedPos);
132
+ }
133
+
134
+ private function peg_advancePos(&$details, $startPos, $endPos) {
135
+ for ($p = $startPos; $p < $endPos; $p++) {
136
+ $ch = $this->input_substr($p, 1);
137
+ if ($ch === "\n") {
138
+ if (!$details["seenCR"]) { $details["line"]++; }
139
+ $details["column"] = 1;
140
+ $details["seenCR"] = false;
141
+ } else if ($ch === "\r" || $ch === "\u2028" || $ch === "\u2029") {
142
+ $details["line"]++;
143
+ $details["column"] = 1;
144
+ $details["seenCR"] = true;
145
+ } else {
146
+ $details["column"]++;
147
+ $details["seenCR"] = false;
148
+ }
149
+ }
150
+ }
151
+
152
+ private function peg_computePosDetails($pos) {
153
+ if ($this->peg_cachedPos !== $pos) {
154
+ if ($this->peg_cachedPos > $pos) {
155
+ $this->peg_cachedPos = 0;
156
+ $this->peg_cachedPosDetails = array( "line" => 1, "column" => 1, "seenCR" => false );
157
+ }
158
+ $this->peg_advancePos($this->peg_cachedPosDetails, $this->peg_cachedPos, $pos);
159
+ $this->peg_cachedPos = $pos;
160
+ }
161
+
162
+ return $this->peg_cachedPosDetails;
163
+ }
164
+
165
+ private function peg_fail($expected) {
166
+ if ($this->peg_currPos < $this->peg_maxFailPos) { return; }
167
+
168
+ if ($this->peg_currPos > $this->peg_maxFailPos) {
169
+ $this->peg_maxFailPos = $this->peg_currPos;
170
+ $this->peg_maxFailExpected = array();
171
+ }
172
+
173
+ $this->peg_maxFailExpected[] = $expected;
174
+ }
175
+
176
+ private function peg_buildException_expectedComparator($a, $b) {
177
+ if ($a["description"] < $b["description"]) {
178
+ return -1;
179
+ } else if ($a["description"] > $b["description"]) {
180
+ return 1;
181
+ } else {
182
+ return 0;
183
+ }
184
+ }
185
+
186
+ private function peg_buildException($message, $expected, $pos) {
187
+ $posDetails = $this->peg_computePosDetails($pos);
188
+ $found = $pos < $this->input_length ? $this->input[$pos] : null;
189
+
190
+ if ($expected !== null) {
191
+ usort($expected, array($this, "peg_buildException_expectedComparator"));
192
+ $i = 1;
193
+ while ($i < count($expected)) {
194
+ if ($expected[$i - 1] === $expected[$i]) {
195
+ array_splice($expected, $i, 1);
196
+ } else {
197
+ $i++;
198
+ }
199
+ }
200
+ }
201
+
202
+ if ($message === null) {
203
+ $expectedDescs = array_fill(0, count($expected), null);
204
+
205
+ for ($i = 0; $i < count($expected); $i++) {
206
+ $expectedDescs[$i] = $expected[$i]["description"];
207
+ }
208
+
209
+ $expectedDesc = count($expected) > 1
210
+ ? join(", ", array_slice($expectedDescs, 0, -1))
211
+ . " or "
212
+ . $expectedDescs[count($expected) - 1]
213
+ : $expectedDescs[0];
214
+
215
+ $foundDesc = $found ? json_encode($found) : "end of input";
216
+
217
+ $message = "Expected " . $expectedDesc . " but " . $foundDesc . " found.";
218
+ }
219
+
220
+ return new Gutenberg_PEG_SyntaxError(
221
+ $message,
222
+ $expected,
223
+ $found,
224
+ $pos,
225
+ $posDetails["line"],
226
+ $posDetails["column"]
227
+ );
228
+ }
229
+
230
+ private $peg_FAILED;
231
+ private $peg_c0;
232
+ private $peg_c1;
233
+ private $peg_c2;
234
+ private $peg_c3;
235
+ private $peg_c4;
236
+ private $peg_c5;
237
+ private $peg_c6;
238
+ private $peg_c7;
239
+ private $peg_c8;
240
+ private $peg_c9;
241
+ private $peg_c10;
242
+ private $peg_c11;
243
+ private $peg_c12;
244
+ private $peg_c13;
245
+ private $peg_c14;
246
+ private $peg_c15;
247
+ private $peg_c16;
248
+ private $peg_c17;
249
+ private $peg_c18;
250
+ private $peg_c19;
251
+ private $peg_c20;
252
+ private $peg_c21;
253
+ private $peg_c22;
254
+ private $peg_c23;
255
+ private $peg_c24;
256
+
257
+ private function peg_f0($pre, $b, $html) { return array( $b, $html ); }
258
+ private function peg_f1($pre, $bs, $post) { return peg_join_blocks( $pre, $bs, $post ); }
259
+ private function peg_f2($blockName, $a) { return $a; }
260
+ private function peg_f3($blockName, $attrs) {
261
+ return array(
262
+ 'blockName' => $blockName,
263
+ 'attrs' => empty( $attrs ) ? peg_empty_attrs() : $attrs,
264
+ 'innerBlocks' => array(),
265
+ 'innerHTML' => '',
266
+ 'innerContent' => array(),
267
+ );
268
+ }
269
+ private function peg_f4($s, $children, $e) {
270
+ list( $innerHTML, $innerBlocks, $innerContent ) = peg_process_inner_content( $children );
271
+
272
+ return array(
273
+ 'blockName' => $s['blockName'],
274
+ 'attrs' => empty( $s['attrs'] ) ? peg_empty_attrs() : $s['attrs'],
275
+ 'innerBlocks' => $innerBlocks,
276
+ 'innerHTML' => $innerHTML,
277
+ 'innerContent' => $innerContent,
278
+ );
279
+ }
280
+ private function peg_f5($blockName, $attrs) {
281
+ return array(
282
+ 'blockName' => $blockName,
283
+ 'attrs' => isset( $attrs ) ? $attrs : array(),
284
+ );
285
+ }
286
+ private function peg_f6($blockName) {
287
+ return array(
288
+ 'blockName' => $blockName,
289
+ );
290
+ }
291
+ private function peg_f7($type) { return "core/$type"; }
292
+ private function peg_f8($attrs) { return json_decode( $attrs, true ); }
293
+
294
+ private function peg_parseBlock_List() {
295
+
296
+ $s0 = $this->peg_currPos;
297
+ $s1 = $this->peg_currPos;
298
+ $s2 = array();
299
+ $s3 = $this->peg_currPos;
300
+ $s4 = $this->peg_currPos;
301
+ $this->peg_silentFails++;
302
+ $s5 = $this->peg_parseBlock();
303
+ $this->peg_silentFails--;
304
+ if ($s5 === $this->peg_FAILED) {
305
+ $s4 = null;
306
+ } else {
307
+ $this->peg_currPos = $s4;
308
+ $s4 = $this->peg_FAILED;
309
+ }
310
+ if ($s4 !== $this->peg_FAILED) {
311
+ if ($this->input_length > $this->peg_currPos) {
312
+ $s5 = $this->input_substr($this->peg_currPos, 1);
313
+ $this->peg_currPos++;
314
+ } else {
315
+ $s5 = $this->peg_FAILED;
316
+ if ($this->peg_silentFails === 0) {
317
+ $this->peg_fail($this->peg_c0);
318
+ }
319
+ }
320
+ if ($s5 !== $this->peg_FAILED) {
321
+ $s4 = array($s4, $s5);
322
+ $s3 = $s4;
323
+ } else {
324
+ $this->peg_currPos = $s3;
325
+ $s3 = $this->peg_FAILED;
326
+ }
327
+ } else {
328
+ $this->peg_currPos = $s3;
329
+ $s3 = $this->peg_FAILED;
330
+ }
331
+ while ($s3 !== $this->peg_FAILED) {
332
+ $s2[] = $s3;
333
+ $s3 = $this->peg_currPos;
334
+ $s4 = $this->peg_currPos;
335
+ $this->peg_silentFails++;
336
+ $s5 = $this->peg_parseBlock();
337
+ $this->peg_silentFails--;
338
+ if ($s5 === $this->peg_FAILED) {
339
+ $s4 = null;
340
+ } else {
341
+ $this->peg_currPos = $s4;
342
+ $s4 = $this->peg_FAILED;
343
+ }
344
+ if ($s4 !== $this->peg_FAILED) {
345
+ if ($this->input_length > $this->peg_currPos) {
346
+ $s5 = $this->input_substr($this->peg_currPos, 1);
347
+ $this->peg_currPos++;
348
+ } else {
349
+ $s5 = $this->peg_FAILED;
350
+ if ($this->peg_silentFails === 0) {
351
+ $this->peg_fail($this->peg_c0);
352
+ }
353
+ }
354
+ if ($s5 !== $this->peg_FAILED) {
355
+ $s4 = array($s4, $s5);
356
+ $s3 = $s4;
357
+ } else {
358
+ $this->peg_currPos = $s3;
359
+ $s3 = $this->peg_FAILED;
360
+ }
361
+ } else {
362
+ $this->peg_currPos = $s3;
363
+ $s3 = $this->peg_FAILED;
364
+ }
365
+ }
366
+ if ($s2 !== $this->peg_FAILED) {
367
+ $s1 = $this->input_substr($s1, $this->peg_currPos - $s1);
368
+ } else {
369
+ $s1 = $s2;
370
+ }
371
+ if ($s1 !== $this->peg_FAILED) {
372
+ $s2 = array();
373
+ $s3 = $this->peg_currPos;
374
+ $s4 = $this->peg_parseBlock();
375
+ if ($s4 !== $this->peg_FAILED) {
376
+ $s5 = $this->peg_currPos;
377
+ $s6 = array();
378
+ $s7 = $this->peg_currPos;
379
+ $s8 = $this->peg_currPos;
380
+ $this->peg_silentFails++;
381
+ $s9 = $this->peg_parseBlock();
382
+ $this->peg_silentFails--;
383
+ if ($s9 === $this->peg_FAILED) {
384
+ $s8 = null;
385
+ } else {
386
+ $this->peg_currPos = $s8;
387
+ $s8 = $this->peg_FAILED;
388
+ }
389
+ if ($s8 !== $this->peg_FAILED) {
390
+ if ($this->input_length > $this->peg_currPos) {
391
+ $s9 = $this->input_substr($this->peg_currPos, 1);
392
+ $this->peg_currPos++;
393
+ } else {
394
+ $s9 = $this->peg_FAILED;
395
+ if ($this->peg_silentFails === 0) {
396
+ $this->peg_fail($this->peg_c0);
397
+ }
398
+ }
399
+ if ($s9 !== $this->peg_FAILED) {
400
+ $s8 = array($s8, $s9);
401
+ $s7 = $s8;
402
+ } else {
403
+ $this->peg_currPos = $s7;
404
+ $s7 = $this->peg_FAILED;
405
+ }
406
+ } else {
407
+ $this->peg_currPos = $s7;
408
+ $s7 = $this->peg_FAILED;
409
+ }
410
+ while ($s7 !== $this->peg_FAILED) {
411
+ $s6[] = $s7;
412
+ $s7 = $this->peg_currPos;
413
+ $s8 = $this->peg_currPos;
414
+ $this->peg_silentFails++;
415
+ $s9 = $this->peg_parseBlock();
416
+ $this->peg_silentFails--;
417
+ if ($s9 === $this->peg_FAILED) {
418
+ $s8 = null;
419
+ } else {
420
+ $this->peg_currPos = $s8;
421
+ $s8 = $this->peg_FAILED;
422
+ }
423
+ if ($s8 !== $this->peg_FAILED) {
424
+ if ($this->input_length > $this->peg_currPos) {
425
+ $s9 = $this->input_substr($this->peg_currPos, 1);
426
+ $this->peg_currPos++;
427
+ } else {
428
+ $s9 = $this->peg_FAILED;
429
+ if ($this->peg_silentFails === 0) {
430
+ $this->peg_fail($this->peg_c0);
431
+ }
432
+ }
433
+ if ($s9 !== $this->peg_FAILED) {
434
+ $s8 = array($s8, $s9);
435
+ $s7 = $s8;
436
+ } else {
437
+ $this->peg_currPos = $s7;
438
+ $s7 = $this->peg_FAILED;
439
+ }
440
+ } else {
441
+ $this->peg_currPos = $s7;
442
+ $s7 = $this->peg_FAILED;
443
+ }
444
+ }
445
+ if ($s6 !== $this->peg_FAILED) {
446
+ $s5 = $this->input_substr($s5, $this->peg_currPos - $s5);
447
+ } else {
448
+ $s5 = $s6;
449
+ }
450
+ if ($s5 !== $this->peg_FAILED) {
451
+ $this->peg_reportedPos = $s3;
452
+ $s4 = $this->peg_f0($s1, $s4, $s5);
453
+ $s3 = $s4;
454
+ } else {
455
+ $this->peg_currPos = $s3;
456
+ $s3 = $this->peg_FAILED;
457
+ }
458
+ } else {
459
+ $this->peg_currPos = $s3;
460
+ $s3 = $this->peg_FAILED;
461
+ }
462
+ while ($s3 !== $this->peg_FAILED) {
463
+ $s2[] = $s3;
464
+ $s3 = $this->peg_currPos;
465
+ $s4 = $this->peg_parseBlock();
466
+ if ($s4 !== $this->peg_FAILED) {
467
+ $s5 = $this->peg_currPos;
468
+ $s6 = array();
469
+ $s7 = $this->peg_currPos;
470
+ $s8 = $this->peg_currPos;
471
+ $this->peg_silentFails++;
472
+ $s9 = $this->peg_parseBlock();
473
+ $this->peg_silentFails--;
474
+ if ($s9 === $this->peg_FAILED) {
475
+ $s8 = null;
476
+ } else {
477
+ $this->peg_currPos = $s8;
478
+ $s8 = $this->peg_FAILED;
479
+ }
480
+ if ($s8 !== $this->peg_FAILED) {
481
+ if ($this->input_length > $this->peg_currPos) {
482
+ $s9 = $this->input_substr($this->peg_currPos, 1);
483
+ $this->peg_currPos++;
484
+ } else {
485
+ $s9 = $this->peg_FAILED;
486
+ if ($this->peg_silentFails === 0) {
487
+ $this->peg_fail($this->peg_c0);
488
+ }
489
+ }
490
+ if ($s9 !== $this->peg_FAILED) {
491
+ $s8 = array($s8, $s9);
492
+ $s7 = $s8;
493
+ } else {
494
+ $this->peg_currPos = $s7;
495
+ $s7 = $this->peg_FAILED;
496
+ }
497
+ } else {
498
+ $this->peg_currPos = $s7;
499
+ $s7 = $this->peg_FAILED;
500
+ }
501
+ while ($s7 !== $this->peg_FAILED) {
502
+ $s6[] = $s7;
503
+ $s7 = $this->peg_currPos;
504
+ $s8 = $this->peg_currPos;
505
+ $this->peg_silentFails++;
506
+ $s9 = $this->peg_parseBlock();
507
+ $this->peg_silentFails--;
508
+ if ($s9 === $this->peg_FAILED) {
509
+ $s8 = null;
510
+ } else {
511
+ $this->peg_currPos = $s8;
512
+ $s8 = $this->peg_FAILED;
513
+ }
514
+ if ($s8 !== $this->peg_FAILED) {
515
+ if ($this->input_length > $this->peg_currPos) {
516
+ $s9 = $this->input_substr($this->peg_currPos, 1);
517
+ $this->peg_currPos++;
518
+ } else {
519
+ $s9 = $this->peg_FAILED;
520
+ if ($this->peg_silentFails === 0) {
521
+ $this->peg_fail($this->peg_c0);
522
+ }
523
+ }
524
+ if ($s9 !== $this->peg_FAILED) {
525
+ $s8 = array($s8, $s9);
526
+ $s7 = $s8;
527
+ } else {
528
+ $this->peg_currPos = $s7;
529
+ $s7 = $this->peg_FAILED;
530
+ }
531
+ } else {
532
+ $this->peg_currPos = $s7;
533
+ $s7 = $this->peg_FAILED;
534
+ }
535
+ }
536
+ if ($s6 !== $this->peg_FAILED) {
537
+ $s5 = $this->input_substr($s5, $this->peg_currPos - $s5);
538
+ } else {
539
+ $s5 = $s6;
540
+ }
541
+ if ($s5 !== $this->peg_FAILED) {
542
+ $this->peg_reportedPos = $s3;
543
+ $s4 = $this->peg_f0($s1, $s4, $s5);
544
+ $s3 = $s4;
545
+ } else {
546
+ $this->peg_currPos = $s3;
547
+ $s3 = $this->peg_FAILED;
548
+ }
549
+ } else {
550
+ $this->peg_currPos = $s3;
551
+ $s3 = $this->peg_FAILED;
552
+ }
553
+ }
554
+ if ($s2 !== $this->peg_FAILED) {
555
+ $s3 = $this->peg_currPos;
556
+ $s4 = array();
557
+ if ($this->input_length > $this->peg_currPos) {
558
+ $s5 = $this->input_substr($this->peg_currPos, 1);
559
+ $this->peg_currPos++;
560
+ } else {
561
+ $s5 = $this->peg_FAILED;
562
+ if ($this->peg_silentFails === 0) {
563
+ $this->peg_fail($this->peg_c0);
564
+ }
565
+ }
566
+ while ($s5 !== $this->peg_FAILED) {
567
+ $s4[] = $s5;
568
+ if ($this->input_length > $this->peg_currPos) {
569
+ $s5 = $this->input_substr($this->peg_currPos, 1);
570
+ $this->peg_currPos++;
571
+ } else {
572
+ $s5 = $this->peg_FAILED;
573
+ if ($this->peg_silentFails === 0) {
574
+ $this->peg_fail($this->peg_c0);
575
+ }
576
+ }
577
+ }
578
+ if ($s4 !== $this->peg_FAILED) {
579
+ $s3 = $this->input_substr($s3, $this->peg_currPos - $s3);
580
+ } else {
581
+ $s3 = $s4;
582
+ }
583
+ if ($s3 !== $this->peg_FAILED) {
584
+ $this->peg_reportedPos = $s0;
585
+ $s1 = $this->peg_f1($s1, $s2, $s3);
586
+ $s0 = $s1;
587
+ } else {
588
+ $this->peg_currPos = $s0;
589
+ $s0 = $this->peg_FAILED;
590
+ }
591
+ } else {
592
+ $this->peg_currPos = $s0;
593
+ $s0 = $this->peg_FAILED;
594
+ }
595
+ } else {
596
+ $this->peg_currPos = $s0;
597
+ $s0 = $this->peg_FAILED;
598
+ }
599
+
600
+ return $s0;
601
+ }
602
+
603
+ private function peg_parseBlock() {
604
+
605
+ $s0 = $this->peg_parseBlock_Void();
606
+ if ($s0 === $this->peg_FAILED) {
607
+ $s0 = $this->peg_parseBlock_Balanced();
608
+ }
609
+
610
+ return $s0;
611
+ }
612
+
613
+ private function peg_parseBlock_Void() {
614
+
615
+ $s0 = $this->peg_currPos;
616
+ if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c1) {
617
+ $s1 = $this->peg_c1;
618
+ $this->peg_currPos += 4;
619
+ } else {
620
+ $s1 = $this->peg_FAILED;
621
+ if ($this->peg_silentFails === 0) {
622
+ $this->peg_fail($this->peg_c2);
623
+ }
624
+ }
625
+ if ($s1 !== $this->peg_FAILED) {
626
+ $s2 = $this->peg_parse__();
627
+ if ($s2 !== $this->peg_FAILED) {
628
+ if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c3) {
629
+ $s3 = $this->peg_c3;
630
+ $this->peg_currPos += 3;
631
+ } else {
632
+ $s3 = $this->peg_FAILED;
633
+ if ($this->peg_silentFails === 0) {
634
+ $this->peg_fail($this->peg_c4);
635
+ }
636
+ }
637
+ if ($s3 !== $this->peg_FAILED) {
638
+ $s4 = $this->peg_parseBlock_Name();
639
+ if ($s4 !== $this->peg_FAILED) {
640
+ $s5 = $this->peg_parse__();
641
+ if ($s5 !== $this->peg_FAILED) {
642
+ $s6 = $this->peg_currPos;
643
+ $s7 = $this->peg_parseBlock_Attributes();
644
+ if ($s7 !== $this->peg_FAILED) {
645
+ $s8 = $this->peg_parse__();
646
+ if ($s8 !== $this->peg_FAILED) {
647
+ $this->peg_reportedPos = $s6;
648
+ $s7 = $this->peg_f2($s4, $s7);
649
+ $s6 = $s7;
650
+ } else {
651
+ $this->peg_currPos = $s6;
652
+ $s6 = $this->peg_FAILED;
653
+ }
654
+ } else {
655
+ $this->peg_currPos = $s6;
656
+ $s6 = $this->peg_FAILED;
657
+ }
658
+ if ($s6 === $this->peg_FAILED) {
659
+ $s6 = null;
660
+ }
661
+ if ($s6 !== $this->peg_FAILED) {
662
+ if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c5) {
663
+ $s7 = $this->peg_c5;
664
+ $this->peg_currPos += 4;
665
+ } else {
666
+ $s7 = $this->peg_FAILED;
667
+ if ($this->peg_silentFails === 0) {
668
+ $this->peg_fail($this->peg_c6);
669
+ }
670
+ }
671
+ if ($s7 !== $this->peg_FAILED) {
672
+ $this->peg_reportedPos = $s0;
673
+ $s1 = $this->peg_f3($s4, $s6);
674
+ $s0 = $s1;
675
+ } else {
676
+ $this->peg_currPos = $s0;
677
+ $s0 = $this->peg_FAILED;
678
+ }
679
+ } else {
680
+ $this->peg_currPos = $s0;
681
+ $s0 = $this->peg_FAILED;
682
+ }
683
+ } else {
684
+ $this->peg_currPos = $s0;
685
+ $s0 = $this->peg_FAILED;
686
+ }
687
+ } else {
688
+ $this->peg_currPos = $s0;
689
+ $s0 = $this->peg_FAILED;
690
+ }
691
+ } else {
692
+ $this->peg_currPos = $s0;
693
+ $s0 = $this->peg_FAILED;
694
+ }
695
+ } else {
696
+ $this->peg_currPos = $s0;
697
+ $s0 = $this->peg_FAILED;
698
+ }
699
+ } else {
700
+ $this->peg_currPos = $s0;
701
+ $s0 = $this->peg_FAILED;
702
+ }
703
+
704
+ return $s0;
705
+ }
706
+
707
+ private function peg_parseBlock_Balanced() {
708
+
709
+ $s0 = $this->peg_currPos;
710
+ $s1 = $this->peg_parseBlock_Start();
711
+ if ($s1 !== $this->peg_FAILED) {
712
+ $s2 = array();
713
+ $s3 = $this->peg_parseBlock();
714
+ if ($s3 === $this->peg_FAILED) {
715
+ $s3 = $this->peg_currPos;
716
+ $s4 = array();
717
+ $s5 = $this->peg_currPos;
718
+ $s6 = $this->peg_currPos;
719
+ $this->peg_silentFails++;
720
+ $s7 = $this->peg_parseBlock();
721
+ $this->peg_silentFails--;
722
+ if ($s7 === $this->peg_FAILED) {
723
+ $s6 = null;
724
+ } else {
725
+ $this->peg_currPos = $s6;
726
+ $s6 = $this->peg_FAILED;
727
+ }
728
+ if ($s6 !== $this->peg_FAILED) {
729
+ $s7 = $this->peg_currPos;
730
+ $this->peg_silentFails++;
731
+ $s8 = $this->peg_parseBlock_End();
732
+ $this->peg_silentFails--;
733
+ if ($s8 === $this->peg_FAILED) {
734
+ $s7 = null;
735
+ } else {
736
+ $this->peg_currPos = $s7;
737
+ $s7 = $this->peg_FAILED;
738
+ }
739
+ if ($s7 !== $this->peg_FAILED) {
740
+ if ($this->input_length > $this->peg_currPos) {
741
+ $s8 = $this->input_substr($this->peg_currPos, 1);
742
+ $this->peg_currPos++;
743
+ } else {
744
+ $s8 = $this->peg_FAILED;
745
+ if ($this->peg_silentFails === 0) {
746
+ $this->peg_fail($this->peg_c0);
747
+ }
748
+ }
749
+ if ($s8 !== $this->peg_FAILED) {
750
+ $s6 = array($s6, $s7, $s8);
751
+ $s5 = $s6;
752
+ } else {
753
+ $this->peg_currPos = $s5;
754
+ $s5 = $this->peg_FAILED;
755
+ }
756
+ } else {
757
+ $this->peg_currPos = $s5;
758
+ $s5 = $this->peg_FAILED;
759
+ }
760
+ } else {
761
+ $this->peg_currPos = $s5;
762
+ $s5 = $this->peg_FAILED;
763
+ }
764
+ if ($s5 !== $this->peg_FAILED) {
765
+ while ($s5 !== $this->peg_FAILED) {
766
+ $s4[] = $s5;
767
+ $s5 = $this->peg_currPos;
768
+ $s6 = $this->peg_currPos;
769
+ $this->peg_silentFails++;
770
+ $s7 = $this->peg_parseBlock();
771
+ $this->peg_silentFails--;
772
+ if ($s7 === $this->peg_FAILED) {
773
+ $s6 = null;
774
+ } else {
775
+ $this->peg_currPos = $s6;
776
+ $s6 = $this->peg_FAILED;
777
+ }
778
+ if ($s6 !== $this->peg_FAILED) {
779
+ $s7 = $this->peg_currPos;
780
+ $this->peg_silentFails++;
781
+ $s8 = $this->peg_parseBlock_End();
782
+ $this->peg_silentFails--;
783
+ if ($s8 === $this->peg_FAILED) {
784
+ $s7 = null;
785
+ } else {
786
+ $this->peg_currPos = $s7;
787
+ $s7 = $this->peg_FAILED;
788
+ }
789
+ if ($s7 !== $this->peg_FAILED) {
790
+ if ($this->input_length > $this->peg_currPos) {
791
+ $s8 = $this->input_substr($this->peg_currPos, 1);
792
+ $this->peg_currPos++;
793
+ } else {
794
+ $s8 = $this->peg_FAILED;
795
+ if ($this->peg_silentFails === 0) {
796
+ $this->peg_fail($this->peg_c0);
797
+ }
798
+ }
799
+ if ($s8 !== $this->peg_FAILED) {
800
+ $s6 = array($s6, $s7, $s8);
801
+ $s5 = $s6;
802
+ } else {
803
+ $this->peg_currPos = $s5;
804
+ $s5 = $this->peg_FAILED;
805
+ }
806
+ } else {
807
+ $this->peg_currPos = $s5;
808
+ $s5 = $this->peg_FAILED;
809
+ }
810
+ } else {
811
+ $this->peg_currPos = $s5;
812
+ $s5 = $this->peg_FAILED;
813
+ }
814
+ }
815
+ } else {
816
+ $s4 = $this->peg_FAILED;
817
+ }
818
+ if ($s4 !== $this->peg_FAILED) {
819
+ $s3 = $this->input_substr($s3, $this->peg_currPos - $s3);
820
+ } else {
821
+ $s3 = $s4;
822
+ }
823
+ }
824
+ while ($s3 !== $this->peg_FAILED) {
825
+ $s2[] = $s3;
826
+ $s3 = $this->peg_parseBlock();
827
+ if ($s3 === $this->peg_FAILED) {
828
+ $s3 = $this->peg_currPos;
829
+ $s4 = array();
830
+ $s5 = $this->peg_currPos;
831
+ $s6 = $this->peg_currPos;
832
+ $this->peg_silentFails++;
833
+ $s7 = $this->peg_parseBlock();
834
+ $this->peg_silentFails--;
835
+ if ($s7 === $this->peg_FAILED) {
836
+ $s6 = null;
837
+ } else {
838
+ $this->peg_currPos = $s6;
839
+ $s6 = $this->peg_FAILED;
840
+ }
841
+ if ($s6 !== $this->peg_FAILED) {
842
+ $s7 = $this->peg_currPos;
843
+ $this->peg_silentFails++;
844
+ $s8 = $this->peg_parseBlock_End();
845
+ $this->peg_silentFails--;
846
+ if ($s8 === $this->peg_FAILED) {
847
+ $s7 = null;
848
+ } else {
849
+ $this->peg_currPos = $s7;
850
+ $s7 = $this->peg_FAILED;
851
+ }
852
+ if ($s7 !== $this->peg_FAILED) {
853
+ if ($this->input_length > $this->peg_currPos) {
854
+ $s8 = $this->input_substr($this->peg_currPos, 1);
855
+ $this->peg_currPos++;
856
+ } else {
857
+ $s8 = $this->peg_FAILED;
858
+ if ($this->peg_silentFails === 0) {
859
+ $this->peg_fail($this->peg_c0);
860
+ }
861
+ }
862
+ if ($s8 !== $this->peg_FAILED) {
863
+ $s6 = array($s6, $s7, $s8);
864
+ $s5 = $s6;
865
+ } else {
866
+ $this->peg_currPos = $s5;
867
+ $s5 = $this->peg_FAILED;
868
+ }
869
+ } else {
870
+ $this->peg_currPos = $s5;
871
+ $s5 = $this->peg_FAILED;
872
+ }
873
+ } else {
874
+ $this->peg_currPos = $s5;
875
+ $s5 = $this->peg_FAILED;
876
+ }
877
+ if ($s5 !== $this->peg_FAILED) {
878
+ while ($s5 !== $this->peg_FAILED) {
879
+ $s4[] = $s5;
880
+ $s5 = $this->peg_currPos;
881
+ $s6 = $this->peg_currPos;
882
+ $this->peg_silentFails++;
883
+ $s7 = $this->peg_parseBlock();
884
+ $this->peg_silentFails--;
885
+ if ($s7 === $this->peg_FAILED) {
886
+ $s6 = null;
887
+ } else {
888
+ $this->peg_currPos = $s6;
889
+ $s6 = $this->peg_FAILED;
890
+ }
891
+ if ($s6 !== $this->peg_FAILED) {
892
+ $s7 = $this->peg_currPos;
893
+ $this->peg_silentFails++;
894
+ $s8 = $this->peg_parseBlock_End();
895
+ $this->peg_silentFails--;
896
+ if ($s8 === $this->peg_FAILED) {
897
+ $s7 = null;
898
+ } else {
899
+ $this->peg_currPos = $s7;
900
+ $s7 = $this->peg_FAILED;
901
+ }
902
+ if ($s7 !== $this->peg_FAILED) {
903
+ if ($this->input_length > $this->peg_currPos) {
904
+ $s8 = $this->input_substr($this->peg_currPos, 1);
905
+ $this->peg_currPos++;
906
+ } else {
907
+ $s8 = $this->peg_FAILED;
908
+ if ($this->peg_silentFails === 0) {
909
+ $this->peg_fail($this->peg_c0);
910
+ }
911
+ }
912
+ if ($s8 !== $this->peg_FAILED) {
913
+ $s6 = array($s6, $s7, $s8);
914
+ $s5 = $s6;
915
+ } else {
916
+ $this->peg_currPos = $s5;
917
+ $s5 = $this->peg_FAILED;
918
+ }
919
+ } else {
920
+ $this->peg_currPos = $s5;
921
+ $s5 = $this->peg_FAILED;
922
+ }
923
+ } else {
924
+ $this->peg_currPos = $s5;
925
+ $s5 = $this->peg_FAILED;
926
+ }
927
+ }
928
+ } else {
929
+ $s4 = $this->peg_FAILED;
930
+ }
931
+ if ($s4 !== $this->peg_FAILED) {
932
+ $s3 = $this->input_substr($s3, $this->peg_currPos - $s3);
933
+ } else {
934
+ $s3 = $s4;
935
+ }
936
+ }
937
+ }
938
+ if ($s2 !== $this->peg_FAILED) {
939
+ $s3 = $this->peg_parseBlock_End();
940
+ if ($s3 !== $this->peg_FAILED) {
941
+ $this->peg_reportedPos = $s0;
942
+ $s1 = $this->peg_f4($s1, $s2, $s3);
943
+ $s0 = $s1;
944
+ } else {
945
+ $this->peg_currPos = $s0;
946
+ $s0 = $this->peg_FAILED;
947
+ }
948
+ } else {
949
+ $this->peg_currPos = $s0;
950
+ $s0 = $this->peg_FAILED;
951
+ }
952
+ } else {
953
+ $this->peg_currPos = $s0;
954
+ $s0 = $this->peg_FAILED;
955
+ }
956
+
957
+ return $s0;
958
+ }
959
+
960
+ private function peg_parseBlock_Start() {
961
+
962
+ $s0 = $this->peg_currPos;
963
+ if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c1) {
964
+ $s1 = $this->peg_c1;
965
+ $this->peg_currPos += 4;
966
+ } else {
967
+ $s1 = $this->peg_FAILED;
968
+ if ($this->peg_silentFails === 0) {
969
+ $this->peg_fail($this->peg_c2);
970
+ }
971
+ }
972
+ if ($s1 !== $this->peg_FAILED) {
973
+ $s2 = $this->peg_parse__();
974
+ if ($s2 !== $this->peg_FAILED) {
975
+ if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c3) {
976
+ $s3 = $this->peg_c3;
977
+ $this->peg_currPos += 3;
978
+ } else {
979
+ $s3 = $this->peg_FAILED;
980
+ if ($this->peg_silentFails === 0) {
981
+ $this->peg_fail($this->peg_c4);
982
+ }
983
+ }
984
+ if ($s3 !== $this->peg_FAILED) {
985
+ $s4 = $this->peg_parseBlock_Name();
986
+ if ($s4 !== $this->peg_FAILED) {
987
+ $s5 = $this->peg_parse__();
988
+ if ($s5 !== $this->peg_FAILED) {
989
+ $s6 = $this->peg_currPos;
990
+ $s7 = $this->peg_parseBlock_Attributes();
991
+ if ($s7 !== $this->peg_FAILED) {
992
+ $s8 = $this->peg_parse__();
993
+ if ($s8 !== $this->peg_FAILED) {
994
+ $this->peg_reportedPos = $s6;
995
+ $s7 = $this->peg_f2($s4, $s7);
996
+ $s6 = $s7;
997
+ } else {
998
+ $this->peg_currPos = $s6;
999
+ $s6 = $this->peg_FAILED;
1000
+ }
1001
+ } else {
1002
+ $this->peg_currPos = $s6;
1003
+ $s6 = $this->peg_FAILED;
1004
+ }
1005
+ if ($s6 === $this->peg_FAILED) {
1006
+ $s6 = null;
1007
+ }
1008
+ if ($s6 !== $this->peg_FAILED) {
1009
+ if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c7) {
1010
+ $s7 = $this->peg_c7;
1011
+ $this->peg_currPos += 3;
1012
+ } else {
1013
+ $s7 = $this->peg_FAILED;
1014
+ if ($this->peg_silentFails === 0) {
1015
+ $this->peg_fail($this->peg_c8);
1016
+ }
1017
+ }
1018
+ if ($s7 !== $this->peg_FAILED) {
1019
+ $this->peg_reportedPos = $s0;
1020
+ $s1 = $this->peg_f5($s4, $s6);
1021
+ $s0 = $s1;
1022
+ } else {
1023
+ $this->peg_currPos = $s0;
1024
+ $s0 = $this->peg_FAILED;
1025
+ }
1026
+ } else {
1027
+ $this->peg_currPos = $s0;
1028
+ $s0 = $this->peg_FAILED;
1029
+ }
1030
+ } else {
1031
+ $this->peg_currPos = $s0;
1032
+ $s0 = $this->peg_FAILED;
1033
+ }
1034
+ } else {
1035
+ $this->peg_currPos = $s0;
1036
+ $s0 = $this->peg_FAILED;
1037
+ }
1038
+ } else {
1039
+ $this->peg_currPos = $s0;
1040
+ $s0 = $this->peg_FAILED;
1041
+ }
1042
+ } else {
1043
+ $this->peg_currPos = $s0;
1044
+ $s0 = $this->peg_FAILED;
1045
+ }
1046
+ } else {
1047
+ $this->peg_currPos = $s0;
1048
+ $s0 = $this->peg_FAILED;
1049
+ }
1050
+
1051
+ return $s0;
1052
+ }
1053
+
1054
+ private function peg_parseBlock_End() {
1055
+
1056
+ $s0 = $this->peg_currPos;
1057
+ if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c1) {
1058
+ $s1 = $this->peg_c1;
1059
+ $this->peg_currPos += 4;
1060
+ } else {
1061
+ $s1 = $this->peg_FAILED;
1062
+ if ($this->peg_silentFails === 0) {
1063
+ $this->peg_fail($this->peg_c2);
1064
+ }
1065
+ }
1066
+ if ($s1 !== $this->peg_FAILED) {
1067
+ $s2 = $this->peg_parse__();
1068
+ if ($s2 !== $this->peg_FAILED) {
1069
+ if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c9) {
1070
+ $s3 = $this->peg_c9;
1071
+ $this->peg_currPos += 4;
1072
+ } else {
1073
+ $s3 = $this->peg_FAILED;
1074
+ if ($this->peg_silentFails === 0) {
1075
+ $this->peg_fail($this->peg_c10);
1076
+ }
1077
+ }
1078
+ if ($s3 !== $this->peg_FAILED) {
1079
+ $s4 = $this->peg_parseBlock_Name();
1080
+ if ($s4 !== $this->peg_FAILED) {
1081
+ $s5 = $this->peg_parse__();
1082
+ if ($s5 !== $this->peg_FAILED) {
1083
+ if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c7) {
1084
+ $s6 = $this->peg_c7;
1085
+ $this->peg_currPos += 3;
1086
+ } else {
1087
+ $s6 = $this->peg_FAILED;
1088
+ if ($this->peg_silentFails === 0) {
1089
+ $this->peg_fail($this->peg_c8);
1090
+ }
1091
+ }
1092
+ if ($s6 !== $this->peg_FAILED) {
1093
+ $this->peg_reportedPos = $s0;
1094
+ $s1 = $this->peg_f6($s4);
1095
+ $s0 = $s1;
1096
+ } else {
1097
+ $this->peg_currPos = $s0;
1098
+ $s0 = $this->peg_FAILED;
1099
+ }
1100
+ } else {
1101
+ $this->peg_currPos = $s0;
1102
+ $s0 = $this->peg_FAILED;
1103
+ }
1104
+ } else {
1105
+ $this->peg_currPos = $s0;
1106
+ $s0 = $this->peg_FAILED;
1107
+ }
1108
+ } else {
1109
+ $this->peg_currPos = $s0;
1110
+ $s0 = $this->peg_FAILED;
1111
+ }
1112
+ } else {
1113
+ $this->peg_currPos = $s0;
1114
+ $s0 = $this->peg_FAILED;
1115
+ }
1116
+ } else {
1117
+ $this->peg_currPos = $s0;
1118
+ $s0 = $this->peg_FAILED;
1119
+ }
1120
+
1121
+ return $s0;
1122
+ }
1123
+
1124
+ private function peg_parseBlock_Name() {
1125
+
1126
+ $s0 = $this->peg_parseNamespaced_Block_Name();
1127
+ if ($s0 === $this->peg_FAILED) {
1128
+ $s0 = $this->peg_parseCore_Block_Name();
1129
+ }
1130
+
1131
+ return $s0;
1132
+ }
1133
+
1134
+ private function peg_parseNamespaced_Block_Name() {
1135
+
1136
+ $s0 = $this->peg_currPos;
1137
+ $s1 = $this->peg_currPos;
1138
+ $s2 = $this->peg_parseBlock_Name_Part();
1139
+ if ($s2 !== $this->peg_FAILED) {
1140
+ if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c11) {
1141
+ $s3 = $this->peg_c11;
1142
+ $this->peg_currPos++;
1143
+ } else {
1144
+ $s3 = $this->peg_FAILED;
1145
+ if ($this->peg_silentFails === 0) {
1146
+ $this->peg_fail($this->peg_c12);
1147
+ }
1148
+ }
1149
+ if ($s3 !== $this->peg_FAILED) {
1150
+ $s4 = $this->peg_parseBlock_Name_Part();
1151
+ if ($s4 !== $this->peg_FAILED) {
1152
+ $s2 = array($s2, $s3, $s4);
1153
+ $s1 = $s2;
1154
+ } else {
1155
+ $this->peg_currPos = $s1;
1156
+ $s1 = $this->peg_FAILED;
1157
+ }
1158
+ } else {
1159
+ $this->peg_currPos = $s1;
1160
+ $s1 = $this->peg_FAILED;
1161
+ }
1162
+ } else {
1163
+ $this->peg_currPos = $s1;
1164
+ $s1 = $this->peg_FAILED;
1165
+ }
1166
+ if ($s1 !== $this->peg_FAILED) {
1167
+ $s0 = $this->input_substr($s0, $this->peg_currPos - $s0);
1168
+ } else {
1169
+ $s0 = $s1;
1170
+ }
1171
+
1172
+ return $s0;
1173
+ }
1174
+
1175
+ private function peg_parseCore_Block_Name() {
1176
+
1177
+ $s0 = $this->peg_currPos;
1178
+ $s1 = $this->peg_currPos;
1179
+ $s2 = $this->peg_parseBlock_Name_Part();
1180
+ if ($s2 !== $this->peg_FAILED) {
1181
+ $s1 = $this->input_substr($s1, $this->peg_currPos - $s1);
1182
+ } else {
1183
+ $s1 = $s2;
1184
+ }
1185
+ if ($s1 !== $this->peg_FAILED) {
1186
+ $this->peg_reportedPos = $s0;
1187
+ $s1 = $this->peg_f7($s1);
1188
+ }
1189
+ $s0 = $s1;
1190
+
1191
+ return $s0;
1192
+ }
1193
+
1194
+ private function peg_parseBlock_Name_Part() {
1195
+
1196
+ $s0 = $this->peg_currPos;
1197
+ $s1 = $this->peg_currPos;
1198
+ if (Gutenberg_PEG_peg_char_class_test($this->peg_c13, $this->input_substr($this->peg_currPos, 1))) {
1199
+ $s2 = $this->input_substr($this->peg_currPos, 1);
1200
+ $this->peg_currPos++;
1201
+ } else {
1202
+ $s2 = $this->peg_FAILED;
1203
+ if ($this->peg_silentFails === 0) {
1204
+ $this->peg_fail($this->peg_c14);
1205
+ }
1206
+ }
1207
+ if ($s2 !== $this->peg_FAILED) {
1208
+ $s3 = array();
1209
+ if (Gutenberg_PEG_peg_char_class_test($this->peg_c15, $this->input_substr($this->peg_currPos, 1))) {
1210
+ $s4 = $this->input_substr($this->peg_currPos, 1);
1211
+ $this->peg_currPos++;
1212
+ } else {
1213
+ $s4 = $this->peg_FAILED;
1214
+ if ($this->peg_silentFails === 0) {
1215
+ $this->peg_fail($this->peg_c16);
1216
+ }
1217
+ }
1218
+ while ($s4 !== $this->peg_FAILED) {
1219
+ $s3[] = $s4;
1220
+ if (Gutenberg_PEG_peg_char_class_test($this->peg_c15, $this->input_substr($this->peg_currPos, 1))) {
1221
+ $s4 = $this->input_substr($this->peg_currPos, 1);
1222
+ $this->peg_currPos++;
1223
+ } else {
1224
+ $s4 = $this->peg_FAILED;
1225
+ if ($this->peg_silentFails === 0) {
1226
+ $this->peg_fail($this->peg_c16);
1227
+ }
1228
+ }
1229
+ }
1230
+ if ($s3 !== $this->peg_FAILED) {
1231
+ $s2 = array($s2, $s3);
1232
+ $s1 = $s2;
1233
+ } else {
1234
+ $this->peg_currPos = $s1;
1235
+ $s1 = $this->peg_FAILED;
1236
+ }
1237
+ } else {
1238
+ $this->peg_currPos = $s1;
1239
+ $s1 = $this->peg_FAILED;
1240
+ }
1241
+ if ($s1 !== $this->peg_FAILED) {
1242
+ $s0 = $this->input_substr($s0, $this->peg_currPos - $s0);
1243
+ } else {
1244
+ $s0 = $s1;
1245
+ }
1246
+
1247
+ return $s0;
1248
+ }
1249
+
1250
+ private function peg_parseBlock_Attributes() {
1251
+
1252
+ $this->peg_silentFails++;
1253
+ $s0 = $this->peg_currPos;
1254
+ $s1 = $this->peg_currPos;
1255
+ $s2 = $this->peg_currPos;
1256
+ if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c18) {
1257
+ $s3 = $this->peg_c18;
1258
+ $this->peg_currPos++;
1259
+ } else {
1260
+ $s3 = $this->peg_FAILED;
1261
+ if ($this->peg_silentFails === 0) {
1262
+ $this->peg_fail($this->peg_c19);
1263
+ }
1264
+ }
1265
+ if ($s3 !== $this->peg_FAILED) {
1266
+ $s4 = array();
1267
+ $s5 = $this->peg_currPos;
1268
+ $s6 = $this->peg_currPos;
1269
+ $this->peg_silentFails++;
1270
+ $s7 = $this->peg_currPos;
1271
+ if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c20) {
1272
+ $s8 = $this->peg_c20;
1273
+ $this->peg_currPos++;
1274
+ } else {
1275
+ $s8 = $this->peg_FAILED;
1276
+ if ($this->peg_silentFails === 0) {
1277
+ $this->peg_fail($this->peg_c21);
1278
+ }
1279
+ }
1280
+ if ($s8 !== $this->peg_FAILED) {
1281
+ $s9 = $this->peg_parse__();
1282
+ if ($s9 !== $this->peg_FAILED) {
1283
+ $s10 = $this->peg_c22;
1284
+ if ($s10 !== $this->peg_FAILED) {
1285
+ if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c11) {
1286
+ $s11 = $this->peg_c11;
1287
+ $this->peg_currPos++;
1288
+ } else {
1289
+ $s11 = $this->peg_FAILED;
1290
+ if ($this->peg_silentFails === 0) {
1291
+ $this->peg_fail($this->peg_c12);
1292
+ }
1293
+ }
1294
+ if ($s11 === $this->peg_FAILED) {
1295
+ $s11 = null;
1296
+ }
1297
+ if ($s11 !== $this->peg_FAILED) {
1298
+ if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c7) {
1299
+ $s12 = $this->peg_c7;
1300
+ $this->peg_currPos += 3;
1301
+ } else {
1302
+ $s12 = $this->peg_FAILED;
1303
+ if ($this->peg_silentFails === 0) {
1304
+ $this->peg_fail($this->peg_c8);
1305
+ }
1306
+ }
1307
+ if ($s12 !== $this->peg_FAILED) {
1308
+ $s8 = array($s8, $s9, $s10, $s11, $s12);
1309
+ $s7 = $s8;
1310
+ } else {
1311
+ $this->peg_currPos = $s7;
1312
+ $s7 = $this->peg_FAILED;
1313
+ }
1314
+ } else {
1315
+ $this->peg_currPos = $s7;
1316
+ $s7 = $this->peg_FAILED;
1317
+ }
1318
+ } else {
1319
+ $this->peg_currPos = $s7;
1320
+ $s7 = $this->peg_FAILED;
1321
+ }
1322
+ } else {
1323
+ $this->peg_currPos = $s7;
1324
+ $s7 = $this->peg_FAILED;
1325
+ }
1326
+ } else {
1327
+ $this->peg_currPos = $s7;
1328
+ $s7 = $this->peg_FAILED;
1329
+ }
1330
+ $this->peg_silentFails--;
1331
+ if ($s7 === $this->peg_FAILED) {
1332
+ $s6 = null;
1333
+ } else {
1334
+ $this->peg_currPos = $s6;
1335
+ $s6 = $this->peg_FAILED;
1336
+ }
1337
+ if ($s6 !== $this->peg_FAILED) {
1338
+ if ($this->input_length > $this->peg_currPos) {
1339
+ $s7 = $this->input_substr($this->peg_currPos, 1);
1340
+ $this->peg_currPos++;
1341
+ } else {
1342
+ $s7 = $this->peg_FAILED;
1343
+ if ($this->peg_silentFails === 0) {
1344
+ $this->peg_fail($this->peg_c0);
1345
+ }
1346
+ }
1347
+ if ($s7 !== $this->peg_FAILED) {
1348
+ $s6 = array($s6, $s7);
1349
+ $s5 = $s6;
1350
+ } else {
1351
+ $this->peg_currPos = $s5;
1352
+ $s5 = $this->peg_FAILED;
1353
+ }
1354
+ } else {
1355
+ $this->peg_currPos = $s5;
1356
+ $s5 = $this->peg_FAILED;
1357
+ }
1358
+ while ($s5 !== $this->peg_FAILED) {
1359
+ $s4[] = $s5;
1360
+ $s5 = $this->peg_currPos;
1361
+ $s6 = $this->peg_currPos;
1362
+ $this->peg_silentFails++;
1363
+ $s7 = $this->peg_currPos;
1364
+ if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c20) {
1365
+ $s8 = $this->peg_c20;
1366
+ $this->peg_currPos++;
1367
+ } else {
1368
+ $s8 = $this->peg_FAILED;
1369
+ if ($this->peg_silentFails === 0) {
1370
+ $this->peg_fail($this->peg_c21);
1371
+ }
1372
+ }
1373
+ if ($s8 !== $this->peg_FAILED) {
1374
+ $s9 = $this->peg_parse__();
1375
+ if ($s9 !== $this->peg_FAILED) {
1376
+ $s10 = $this->peg_c22;
1377
+ if ($s10 !== $this->peg_FAILED) {
1378
+ if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c11) {
1379
+ $s11 = $this->peg_c11;
1380
+ $this->peg_currPos++;
1381
+ } else {
1382
+ $s11 = $this->peg_FAILED;
1383
+ if ($this->peg_silentFails === 0) {
1384
+ $this->peg_fail($this->peg_c12);
1385
+ }
1386
+ }
1387
+ if ($s11 === $this->peg_FAILED) {
1388
+ $s11 = null;
1389
+ }
1390
+ if ($s11 !== $this->peg_FAILED) {
1391
+ if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c7) {
1392
+ $s12 = $this->peg_c7;
1393
+ $this->peg_currPos += 3;
1394
+ } else {
1395
+ $s12 = $this->peg_FAILED;
1396
+ if ($this->peg_silentFails === 0) {
1397
+ $this->peg_fail($this->peg_c8);
1398
+ }
1399
+ }
1400
+ if ($s12 !== $this->peg_FAILED) {
1401
+ $s8 = array($s8, $s9, $s10, $s11, $s12);
1402
+ $s7 = $s8;
1403
+ } else {
1404
+ $this->peg_currPos = $s7;
1405
+ $s7 = $this->peg_FAILED;
1406
+ }
1407
+ } else {
1408
+ $this->peg_currPos = $s7;
1409
+ $s7 = $this->peg_FAILED;
1410
+ }
1411
+ } else {
1412
+ $this->peg_currPos = $s7;
1413
+ $s7 = $this->peg_FAILED;
1414
+ }
1415
+ } else {
1416
+ $this->peg_currPos = $s7;
1417
+ $s7 = $this->peg_FAILED;
1418
+ }
1419
+ } else {
1420
+ $this->peg_currPos = $s7;
1421
+ $s7 = $this->peg_FAILED;
1422
+ }
1423
+ $this->peg_silentFails--;
1424
+ if ($s7 === $this->peg_FAILED) {
1425
+ $s6 = null;
1426
+ } else {
1427
+ $this->peg_currPos = $s6;
1428
+ $s6 = $this->peg_FAILED;
1429
+ }
1430
+ if ($s6 !== $this->peg_FAILED) {
1431
+ if ($this->input_length > $this->peg_currPos) {
1432
+ $s7 = $this->input_substr($this->peg_currPos, 1);
1433
+ $this->peg_currPos++;
1434
+ } else {
1435
+ $s7 = $this->peg_FAILED;
1436
+ if ($this->peg_silentFails === 0) {
1437
+ $this->peg_fail($this->peg_c0);
1438
+ }
1439
+ }
1440
+ if ($s7 !== $this->peg_FAILED) {
1441
+ $s6 = array($s6, $s7);
1442
+ $s5 = $s6;
1443
+ } else {
1444
+ $this->peg_currPos = $s5;
1445
+ $s5 = $this->peg_FAILED;
1446
+ }
1447
+ } else {
1448
+ $this->peg_currPos = $s5;
1449
+ $s5 = $this->peg_FAILED;
1450
+ }
1451
+ }
1452
+ if ($s4 !== $this->peg_FAILED) {
1453
+ if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c20) {
1454
+ $s5 = $this->peg_c20;
1455
+ $this->peg_currPos++;
1456
+ } else {
1457
+ $s5 = $this->peg_FAILED;
1458
+ if ($this->peg_silentFails === 0) {
1459
+ $this->peg_fail($this->peg_c21);
1460
+ }
1461
+ }
1462
+ if ($s5 !== $this->peg_FAILED) {
1463
+ $s3 = array($s3, $s4, $s5);
1464
+ $s2 = $s3;
1465
+ } else {
1466
+ $this->peg_currPos = $s2;
1467
+ $s2 = $this->peg_FAILED;
1468
+ }
1469
+ } else {
1470
+ $this->peg_currPos = $s2;
1471
+ $s2 = $this->peg_FAILED;
1472
+ }
1473
+ } else {
1474
+ $this->peg_currPos = $s2;
1475
+ $s2 = $this->peg_FAILED;
1476
+ }
1477
+ if ($s2 !== $this->peg_FAILED) {
1478
+ $s1 = $this->input_substr($s1, $this->peg_currPos - $s1);
1479
+ } else {
1480
+ $s1 = $s2;
1481
+ }
1482
+ if ($s1 !== $this->peg_FAILED) {
1483
+ $this->peg_reportedPos = $s0;
1484
+ $s1 = $this->peg_f8($s1);
1485
+ }
1486
+ $s0 = $s1;
1487
+ $this->peg_silentFails--;
1488
+ if ($s0 === $this->peg_FAILED) {
1489
+ $s1 = $this->peg_FAILED;
1490
+ if ($this->peg_silentFails === 0) {
1491
+ $this->peg_fail($this->peg_c17);
1492
+ }
1493
+ }
1494
+
1495
+ return $s0;
1496
+ }
1497
+
1498
+ private function peg_parse__() {
1499
+
1500
+ $s0 = array();
1501
+ if (Gutenberg_PEG_peg_char_class_test($this->peg_c23, $this->input_substr($this->peg_currPos, 1))) {
1502
+ $s1 = $this->input_substr($this->peg_currPos, 1);
1503
+ $this->peg_currPos++;
1504
+ } else {
1505
+ $s1 = $this->peg_FAILED;
1506
+ if ($this->peg_silentFails === 0) {
1507
+ $this->peg_fail($this->peg_c24);
1508
+ }
1509
+ }
1510
+ if ($s1 !== $this->peg_FAILED) {
1511
+ while ($s1 !== $this->peg_FAILED) {
1512
+ $s0[] = $s1;
1513
+ if (Gutenberg_PEG_peg_char_class_test($this->peg_c23, $this->input_substr($this->peg_currPos, 1))) {
1514
+ $s1 = $this->input_substr($this->peg_currPos, 1);
1515
+ $this->peg_currPos++;
1516
+ } else {
1517
+ $s1 = $this->peg_FAILED;
1518
+ if ($this->peg_silentFails === 0) {
1519
+ $this->peg_fail($this->peg_c24);
1520
+ }
1521
+ }
1522
+ }
1523
+ } else {
1524
+ $s0 = $this->peg_FAILED;
1525
+ }
1526
+
1527
+ return $s0;
1528
+ }
1529
+
1530
+ public function parse($input) {
1531
+ $arguments = func_get_args();
1532
+ $options = count($arguments) > 1 ? $arguments[1] : array();
1533
+ $this->cleanup_state();
1534
+
1535
+ if (is_array($input)) {
1536
+ $this->input = $input;
1537
+ } else {
1538
+ preg_match_all("/./us", $input, $match);
1539
+ $this->input = $match[0];
1540
+ }
1541
+ $this->input_length = count($this->input);
1542
+
1543
+ $this->peg_FAILED = new stdClass;
1544
+ $this->peg_c0 = array("type" => "any", "description" => "any character" );
1545
+ $this->peg_c1 = "<!--";
1546
+ $this->peg_c2 = array( "type" => "literal", "value" => "<!--", "description" => "\"<!--\"" );
1547
+ $this->peg_c3 = "wp:";
1548
+ $this->peg_c4 = array( "type" => "literal", "value" => "wp:", "description" => "\"wp:\"" );
1549
+ $this->peg_c5 = "/-->";
1550
+ $this->peg_c6 = array( "type" => "literal", "value" => "/-->", "description" => "\"/-->\"" );
1551
+ $this->peg_c7 = "-->";
1552
+ $this->peg_c8 = array( "type" => "literal", "value" => "-->", "description" => "\"-->\"" );
1553
+ $this->peg_c9 = "/wp:";
1554
+ $this->peg_c10 = array( "type" => "literal", "value" => "/wp:", "description" => "\"/wp:\"" );
1555
+ $this->peg_c11 = "/";
1556
+ $this->peg_c12 = array( "type" => "literal", "value" => "/", "description" => "\"/\"" );
1557
+ $this->peg_c13 = array(array(97,122));
1558
+ $this->peg_c14 = array( "type" => "class", "value" => "[a-z]", "description" => "[a-z]" );
1559
+ $this->peg_c15 = array(array(97,122), array(48,57), array(95,95), array(45,45));
1560
+ $this->peg_c16 = array( "type" => "class", "value" => "[a-z0-9_-]", "description" => "[a-z0-9_-]" );
1561
+ $this->peg_c17 = array("type" => "other", "description" => "JSON-encoded attributes embedded in a block's opening comment" );
1562
+ $this->peg_c18 = "{";
1563
+ $this->peg_c19 = array( "type" => "literal", "value" => "{", "description" => "\"{\"" );
1564
+ $this->peg_c20 = "}";
1565
+ $this->peg_c21 = array( "type" => "literal", "value" => "}", "description" => "\"}\"" );
1566
+ $this->peg_c22 = "";
1567
+ $this->peg_c23 = array(array(32,32), array(9,9), array(12,12), array(13,13), array(10,10));
1568
+ $this->peg_c24 = array( "type" => "class", "value" => "[ \t\f\r\n]", "description" => "[ \t\f\r\n]" );
1569
+
1570
+ $peg_startRuleFunctions = array( 'Block_List' => array($this, "peg_parseBlock_List") );
1571
+ $peg_startRuleFunction = array($this, "peg_parseBlock_List");
1572
+ if (isset($options["startRule"])) {
1573
+ if (!(isset($peg_startRuleFunctions[$options["startRule"]]))) {
1574
+ throw new Exception("Can't start parsing from rule \"" + $options["startRule"] + "\".");
1575
+ }
1576
+
1577
+ $peg_startRuleFunction = $peg_startRuleFunctions[$options["startRule"]];
1578
+ }
1579
+
1580
+ /* BEGIN initializer code */
1581
+
1582
+ // The `maybeJSON` function is not needed in PHP because its return semantics
1583
+ // are the same as `json_decode`
1584
+
1585
+ if ( ! function_exists( 'peg_empty_attrs' ) ) {
1586
+ function peg_empty_attrs() {
1587
+ static $empty_attrs = null;
1588
+
1589
+ if ( null === $empty_attrs ) {
1590
+ $empty_attrs = json_decode( '{}', true );
1591
+ }
1592
+
1593
+ return $empty_attrs;
1594
+ }
1595
+ }
1596
+
1597
+ // array arguments are backwards because of PHP
1598
+ if ( ! function_exists( 'peg_process_inner_content' ) ) {
1599
+ function peg_process_inner_content( $array ) {
1600
+ $html = '';
1601
+ $blocks = array();
1602
+ $content = array();
1603
+
1604
+ foreach ( $array as $item ) {
1605
+ if ( is_string( $item ) ) {
1606
+ $html .= $item;
1607
+ $content[] = $item;
1608
+ } else {
1609
+ $blocks[] = $item;
1610
+ $content[] = null;
1611
+ }
1612
+ }
1613
+
1614
+ return array( $html, $blocks, $content );
1615
+ }
1616
+ }
1617
+
1618
+ if ( ! function_exists( 'peg_join_blocks' ) ) {
1619
+ function peg_join_blocks( $pre, $tokens, $post ) {
1620
+ $blocks = array();
1621
+
1622
+ if ( ! empty( $pre ) ) {
1623
+ $blocks[] = array(
1624
+ 'blockName' => null,
1625
+ 'attrs' => peg_empty_attrs(),
1626
+ 'innerBlocks' => array(),
1627
+ 'innerHTML' => $pre,
1628
+ 'innerContent' => array( $pre ),
1629
+ );
1630
+ }
1631
+
1632
+ foreach ( $tokens as $token ) {
1633
+ list( $token, $html ) = $token;
1634
+
1635
+ $blocks[] = $token;
1636
+
1637
+ if ( ! empty( $html ) ) {
1638
+ $blocks[] = array(
1639
+ 'blockName' => null,
1640
+ 'attrs' => peg_empty_attrs(),
1641
+ 'innerBlocks' => array(),
1642
+ 'innerHTML' => $html,
1643
+ 'innerContent' => array( $html ),
1644
+ );
1645
+ }
1646
+ }
1647
+
1648
+ if ( ! empty( $post ) ) {
1649
+ $blocks[] = array(
1650
+ 'blockName' => null,
1651
+ 'attrs' => peg_empty_attrs(),
1652
+ 'innerBlocks' => array(),
1653
+ 'innerHTML' => $post,
1654
+ 'innerContent' => array( $post ),
1655
+ );
1656
+ }
1657
+
1658
+ return $blocks;
1659
+ }
1660
+ }
1661
+
1662
+
1663
+ /* END initializer code */
1664
+
1665
+ $peg_result = call_user_func($peg_startRuleFunction);
1666
+
1667
+ if ($peg_result !== $this->peg_FAILED && $this->peg_currPos === $this->input_length) {
1668
+ $this->cleanup_state(); // Free up memory
1669
+ return $peg_result;
1670
+ } else {
1671
+ if ($peg_result !== $this->peg_FAILED && $this->peg_currPos < $this->input_length) {
1672
+ $this->peg_fail(array("type" => "end", "description" => "end of input" ));
1673
+ }
1674
+
1675
+ $exception = $this->peg_buildException(null, $this->peg_maxFailExpected, $this->peg_maxFailPos);
1676
+ $this->cleanup_state(); // Free up memory
1677
+ throw $exception;
1678
+ }
1679
+ }
1680
+
1681
+ };