parser.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. // Do not edit the parser directly. This is a generated file created using a build script and the PEG grammar.
  2. module.exports = (function() {
  3. /*
  4. * Generated by PEG.js 0.8.0.
  5. *
  6. * http://pegjs.majda.cz/
  7. */
  8. function peg$subclass(child, parent) {
  9. function ctor() { this.constructor = child; }
  10. ctor.prototype = parent.prototype;
  11. child.prototype = new ctor();
  12. }
  13. function SyntaxError(message, expected, found, offset, line, column) {
  14. this.message = message;
  15. this.expected = expected;
  16. this.found = found;
  17. this.offset = offset;
  18. this.line = line;
  19. this.column = column;
  20. this.name = "SyntaxError";
  21. }
  22. peg$subclass(SyntaxError, Error);
  23. function parse(input) {
  24. var options = arguments.length > 1 ? arguments[1] : {},
  25. peg$FAILED = {},
  26. peg$startRuleFunctions = { start: peg$parsestart },
  27. peg$startRuleFunction = peg$parsestart,
  28. peg$c0 = [],
  29. peg$c1 = { type: "other", description: "buffer" },
  30. peg$c2 = peg$FAILED,
  31. peg$c3 = function(e, w) { return {"buffer": e + w.join('')} },
  32. peg$c4 = void 0,
  33. peg$c5 = function(c) { return c },
  34. peg$c6 = function(b) { return {"buffer": b.join('')} },
  35. peg$c7 = ":",
  36. peg$c8 = { type: "literal", value: ":", description: "\":\"" },
  37. peg$c9 = function(c) {return c},
  38. peg$c10 = function(c, e) { return {color: c, text: e.join('')}},
  39. peg$c11 = { type: "any", description: "any character" },
  40. peg$c12 = function(a) {return a},
  41. peg$c13 = "{",
  42. peg$c14 = { type: "literal", value: "{", description: "\"{\"" },
  43. peg$c15 = function(out) {return out},
  44. peg$c16 = "}",
  45. peg$c17 = { type: "literal", value: "}", description: "\"}\"" },
  46. peg$c18 = "\\",
  47. peg$c19 = { type: "literal", value: "\\", description: "\"\\\\\"" },
  48. peg$c20 = /^[a-zA-Z.]/,
  49. peg$c21 = { type: "class", value: "[a-zA-Z.]", description: "[a-zA-Z.]" },
  50. peg$c22 = function(c) { return c.join('') },
  51. peg$c23 = null,
  52. peg$c24 = function(r, e) {return {reset: true, text: e ? e.join('') : '' }},
  53. peg$c25 = function(after) {return after},
  54. peg$c26 = "\n",
  55. peg$c27 = { type: "literal", value: "\n", description: "\"\\n\"" },
  56. peg$c28 = "\r\n",
  57. peg$c29 = { type: "literal", value: "\r\n", description: "\"\\r\\n\"" },
  58. peg$c30 = "\r",
  59. peg$c31 = { type: "literal", value: "\r", description: "\"\\r\"" },
  60. peg$c32 = "\u2028",
  61. peg$c33 = { type: "literal", value: "\u2028", description: "\"\\u2028\"" },
  62. peg$c34 = "\u2029",
  63. peg$c35 = { type: "literal", value: "\u2029", description: "\"\\u2029\"" },
  64. peg$c36 = /^[\t\x0B\f \xA0\uFEFF]/,
  65. peg$c37 = { type: "class", value: "[\\t\\x0B\\f \\xA0\\uFEFF]", description: "[\\t\\x0B\\f \\xA0\\uFEFF]" },
  66. peg$currPos = 0,
  67. peg$reportedPos = 0,
  68. peg$cachedPos = 0,
  69. peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
  70. peg$maxFailPos = 0,
  71. peg$maxFailExpected = [],
  72. peg$silentFails = 0,
  73. peg$result;
  74. if ("startRule" in options) {
  75. if (!(options.startRule in peg$startRuleFunctions)) {
  76. throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
  77. }
  78. peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
  79. }
  80. function text() {
  81. return input.substring(peg$reportedPos, peg$currPos);
  82. }
  83. function offset() {
  84. return peg$reportedPos;
  85. }
  86. function line() {
  87. return peg$computePosDetails(peg$reportedPos).line;
  88. }
  89. function column() {
  90. return peg$computePosDetails(peg$reportedPos).column;
  91. }
  92. function expected(description) {
  93. throw peg$buildException(
  94. null,
  95. [{ type: "other", description: description }],
  96. peg$reportedPos
  97. );
  98. }
  99. function error(message) {
  100. throw peg$buildException(message, null, peg$reportedPos);
  101. }
  102. function peg$computePosDetails(pos) {
  103. function advance(details, startPos, endPos) {
  104. var p, ch;
  105. for (p = startPos; p < endPos; p++) {
  106. ch = input.charAt(p);
  107. if (ch === "\n") {
  108. if (!details.seenCR) { details.line++; }
  109. details.column = 1;
  110. details.seenCR = false;
  111. } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
  112. details.line++;
  113. details.column = 1;
  114. details.seenCR = true;
  115. } else {
  116. details.column++;
  117. details.seenCR = false;
  118. }
  119. }
  120. }
  121. if (peg$cachedPos !== pos) {
  122. if (peg$cachedPos > pos) {
  123. peg$cachedPos = 0;
  124. peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
  125. }
  126. advance(peg$cachedPosDetails, peg$cachedPos, pos);
  127. peg$cachedPos = pos;
  128. }
  129. return peg$cachedPosDetails;
  130. }
  131. function peg$fail(expected) {
  132. if (peg$currPos < peg$maxFailPos) { return; }
  133. if (peg$currPos > peg$maxFailPos) {
  134. peg$maxFailPos = peg$currPos;
  135. peg$maxFailExpected = [];
  136. }
  137. peg$maxFailExpected.push(expected);
  138. }
  139. function peg$buildException(message, expected, pos) {
  140. function cleanupExpected(expected) {
  141. var i = 1;
  142. expected.sort(function(a, b) {
  143. if (a.description < b.description) {
  144. return -1;
  145. } else if (a.description > b.description) {
  146. return 1;
  147. } else {
  148. return 0;
  149. }
  150. });
  151. while (i < expected.length) {
  152. if (expected[i - 1] === expected[i]) {
  153. expected.splice(i, 1);
  154. } else {
  155. i++;
  156. }
  157. }
  158. }
  159. function buildMessage(expected, found) {
  160. function stringEscape(s) {
  161. function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
  162. return s
  163. .replace(/\\/g, '\\\\')
  164. .replace(/"/g, '\\"')
  165. .replace(/\x08/g, '\\b')
  166. .replace(/\t/g, '\\t')
  167. .replace(/\n/g, '\\n')
  168. .replace(/\f/g, '\\f')
  169. .replace(/\r/g, '\\r')
  170. .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
  171. .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
  172. .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
  173. .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
  174. }
  175. var expectedDescs = new Array(expected.length),
  176. expectedDesc, foundDesc, i;
  177. for (i = 0; i < expected.length; i++) {
  178. expectedDescs[i] = expected[i].description;
  179. }
  180. expectedDesc = expected.length > 1
  181. ? expectedDescs.slice(0, -1).join(", ")
  182. + " or "
  183. + expectedDescs[expected.length - 1]
  184. : expectedDescs[0];
  185. foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
  186. return "Expected " + expectedDesc + " but " + foundDesc + " found.";
  187. }
  188. var posDetails = peg$computePosDetails(pos),
  189. found = pos < input.length ? input.charAt(pos) : null;
  190. if (expected !== null) {
  191. cleanupExpected(expected);
  192. }
  193. return new SyntaxError(
  194. message !== null ? message : buildMessage(expected, found),
  195. expected,
  196. found,
  197. pos,
  198. posDetails.line,
  199. posDetails.column
  200. );
  201. }
  202. function peg$parsestart() {
  203. var s0;
  204. s0 = peg$parsebody();
  205. return s0;
  206. }
  207. function peg$parsebody() {
  208. var s0, s1;
  209. s0 = [];
  210. s1 = peg$parseitem();
  211. while (s1 !== peg$FAILED) {
  212. s0.push(s1);
  213. s1 = peg$parseitem();
  214. }
  215. return s0;
  216. }
  217. function peg$parseitem() {
  218. var s0;
  219. s0 = peg$parsetag();
  220. if (s0 === peg$FAILED) {
  221. s0 = peg$parsebuffer();
  222. if (s0 === peg$FAILED) {
  223. s0 = peg$parsereset();
  224. }
  225. }
  226. return s0;
  227. }
  228. function peg$parsebuffer() {
  229. var s0, s1, s2, s3, s4, s5;
  230. peg$silentFails++;
  231. s0 = peg$currPos;
  232. s1 = peg$parseeol();
  233. if (s1 !== peg$FAILED) {
  234. s2 = [];
  235. s3 = peg$parsews();
  236. while (s3 !== peg$FAILED) {
  237. s2.push(s3);
  238. s3 = peg$parsews();
  239. }
  240. if (s2 !== peg$FAILED) {
  241. peg$reportedPos = s0;
  242. s1 = peg$c3(s1, s2);
  243. s0 = s1;
  244. } else {
  245. peg$currPos = s0;
  246. s0 = peg$c2;
  247. }
  248. } else {
  249. peg$currPos = s0;
  250. s0 = peg$c2;
  251. }
  252. if (s0 === peg$FAILED) {
  253. s0 = peg$currPos;
  254. s1 = [];
  255. s2 = peg$currPos;
  256. s3 = peg$currPos;
  257. peg$silentFails++;
  258. s4 = peg$parsetag();
  259. peg$silentFails--;
  260. if (s4 === peg$FAILED) {
  261. s3 = peg$c4;
  262. } else {
  263. peg$currPos = s3;
  264. s3 = peg$c2;
  265. }
  266. if (s3 !== peg$FAILED) {
  267. s4 = peg$currPos;
  268. peg$silentFails++;
  269. s5 = peg$parsereset();
  270. peg$silentFails--;
  271. if (s5 === peg$FAILED) {
  272. s4 = peg$c4;
  273. } else {
  274. peg$currPos = s4;
  275. s4 = peg$c2;
  276. }
  277. if (s4 !== peg$FAILED) {
  278. s5 = peg$parseany();
  279. if (s5 !== peg$FAILED) {
  280. peg$reportedPos = s2;
  281. s3 = peg$c5(s5);
  282. s2 = s3;
  283. } else {
  284. peg$currPos = s2;
  285. s2 = peg$c2;
  286. }
  287. } else {
  288. peg$currPos = s2;
  289. s2 = peg$c2;
  290. }
  291. } else {
  292. peg$currPos = s2;
  293. s2 = peg$c2;
  294. }
  295. if (s2 !== peg$FAILED) {
  296. while (s2 !== peg$FAILED) {
  297. s1.push(s2);
  298. s2 = peg$currPos;
  299. s3 = peg$currPos;
  300. peg$silentFails++;
  301. s4 = peg$parsetag();
  302. peg$silentFails--;
  303. if (s4 === peg$FAILED) {
  304. s3 = peg$c4;
  305. } else {
  306. peg$currPos = s3;
  307. s3 = peg$c2;
  308. }
  309. if (s3 !== peg$FAILED) {
  310. s4 = peg$currPos;
  311. peg$silentFails++;
  312. s5 = peg$parsereset();
  313. peg$silentFails--;
  314. if (s5 === peg$FAILED) {
  315. s4 = peg$c4;
  316. } else {
  317. peg$currPos = s4;
  318. s4 = peg$c2;
  319. }
  320. if (s4 !== peg$FAILED) {
  321. s5 = peg$parseany();
  322. if (s5 !== peg$FAILED) {
  323. peg$reportedPos = s2;
  324. s3 = peg$c5(s5);
  325. s2 = s3;
  326. } else {
  327. peg$currPos = s2;
  328. s2 = peg$c2;
  329. }
  330. } else {
  331. peg$currPos = s2;
  332. s2 = peg$c2;
  333. }
  334. } else {
  335. peg$currPos = s2;
  336. s2 = peg$c2;
  337. }
  338. }
  339. } else {
  340. s1 = peg$c2;
  341. }
  342. if (s1 !== peg$FAILED) {
  343. peg$reportedPos = s0;
  344. s1 = peg$c6(s1);
  345. }
  346. s0 = s1;
  347. }
  348. peg$silentFails--;
  349. if (s0 === peg$FAILED) {
  350. s1 = peg$FAILED;
  351. if (peg$silentFails === 0) { peg$fail(peg$c1); }
  352. }
  353. return s0;
  354. }
  355. function peg$parsetag() {
  356. var s0, s1, s2, s3, s4, s5, s6, s7, s8;
  357. s0 = peg$currPos;
  358. s1 = peg$parseld();
  359. if (s1 !== peg$FAILED) {
  360. s2 = peg$parsecolor();
  361. if (s2 !== peg$FAILED) {
  362. if (input.charCodeAt(peg$currPos) === 58) {
  363. s3 = peg$c7;
  364. peg$currPos++;
  365. } else {
  366. s3 = peg$FAILED;
  367. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  368. }
  369. if (s3 !== peg$FAILED) {
  370. s4 = [];
  371. s5 = peg$currPos;
  372. s6 = peg$currPos;
  373. peg$silentFails++;
  374. s7 = peg$parseld();
  375. peg$silentFails--;
  376. if (s7 === peg$FAILED) {
  377. s6 = peg$c4;
  378. } else {
  379. peg$currPos = s6;
  380. s6 = peg$c2;
  381. }
  382. if (s6 !== peg$FAILED) {
  383. s7 = peg$currPos;
  384. peg$silentFails++;
  385. s8 = peg$parserd();
  386. peg$silentFails--;
  387. if (s8 === peg$FAILED) {
  388. s7 = peg$c4;
  389. } else {
  390. peg$currPos = s7;
  391. s7 = peg$c2;
  392. }
  393. if (s7 !== peg$FAILED) {
  394. s8 = peg$parseany();
  395. if (s8 !== peg$FAILED) {
  396. peg$reportedPos = s5;
  397. s6 = peg$c9(s8);
  398. s5 = s6;
  399. } else {
  400. peg$currPos = s5;
  401. s5 = peg$c2;
  402. }
  403. } else {
  404. peg$currPos = s5;
  405. s5 = peg$c2;
  406. }
  407. } else {
  408. peg$currPos = s5;
  409. s5 = peg$c2;
  410. }
  411. if (s5 !== peg$FAILED) {
  412. while (s5 !== peg$FAILED) {
  413. s4.push(s5);
  414. s5 = peg$currPos;
  415. s6 = peg$currPos;
  416. peg$silentFails++;
  417. s7 = peg$parseld();
  418. peg$silentFails--;
  419. if (s7 === peg$FAILED) {
  420. s6 = peg$c4;
  421. } else {
  422. peg$currPos = s6;
  423. s6 = peg$c2;
  424. }
  425. if (s6 !== peg$FAILED) {
  426. s7 = peg$currPos;
  427. peg$silentFails++;
  428. s8 = peg$parserd();
  429. peg$silentFails--;
  430. if (s8 === peg$FAILED) {
  431. s7 = peg$c4;
  432. } else {
  433. peg$currPos = s7;
  434. s7 = peg$c2;
  435. }
  436. if (s7 !== peg$FAILED) {
  437. s8 = peg$parseany();
  438. if (s8 !== peg$FAILED) {
  439. peg$reportedPos = s5;
  440. s6 = peg$c9(s8);
  441. s5 = s6;
  442. } else {
  443. peg$currPos = s5;
  444. s5 = peg$c2;
  445. }
  446. } else {
  447. peg$currPos = s5;
  448. s5 = peg$c2;
  449. }
  450. } else {
  451. peg$currPos = s5;
  452. s5 = peg$c2;
  453. }
  454. }
  455. } else {
  456. s4 = peg$c2;
  457. }
  458. if (s4 !== peg$FAILED) {
  459. peg$reportedPos = s0;
  460. s1 = peg$c10(s2, s4);
  461. s0 = s1;
  462. } else {
  463. peg$currPos = s0;
  464. s0 = peg$c2;
  465. }
  466. } else {
  467. peg$currPos = s0;
  468. s0 = peg$c2;
  469. }
  470. } else {
  471. peg$currPos = s0;
  472. s0 = peg$c2;
  473. }
  474. } else {
  475. peg$currPos = s0;
  476. s0 = peg$c2;
  477. }
  478. return s0;
  479. }
  480. function peg$parseany() {
  481. var s0, s1;
  482. s0 = peg$parseesc_left();
  483. if (s0 === peg$FAILED) {
  484. s0 = peg$parseesc_right();
  485. if (s0 === peg$FAILED) {
  486. s0 = peg$currPos;
  487. if (input.length > peg$currPos) {
  488. s1 = input.charAt(peg$currPos);
  489. peg$currPos++;
  490. } else {
  491. s1 = peg$FAILED;
  492. if (peg$silentFails === 0) { peg$fail(peg$c11); }
  493. }
  494. if (s1 !== peg$FAILED) {
  495. peg$reportedPos = s0;
  496. s1 = peg$c12(s1);
  497. }
  498. s0 = s1;
  499. }
  500. }
  501. return s0;
  502. }
  503. function peg$parseesc_left() {
  504. var s0, s1, s2;
  505. s0 = peg$currPos;
  506. s1 = peg$parseesc_seq();
  507. if (s1 !== peg$FAILED) {
  508. if (input.charCodeAt(peg$currPos) === 123) {
  509. s2 = peg$c13;
  510. peg$currPos++;
  511. } else {
  512. s2 = peg$FAILED;
  513. if (peg$silentFails === 0) { peg$fail(peg$c14); }
  514. }
  515. if (s2 !== peg$FAILED) {
  516. peg$reportedPos = s0;
  517. s1 = peg$c15(s2);
  518. s0 = s1;
  519. } else {
  520. peg$currPos = s0;
  521. s0 = peg$c2;
  522. }
  523. } else {
  524. peg$currPos = s0;
  525. s0 = peg$c2;
  526. }
  527. return s0;
  528. }
  529. function peg$parseesc_right() {
  530. var s0, s1, s2;
  531. s0 = peg$currPos;
  532. s1 = peg$parseesc_seq();
  533. if (s1 !== peg$FAILED) {
  534. if (input.charCodeAt(peg$currPos) === 125) {
  535. s2 = peg$c16;
  536. peg$currPos++;
  537. } else {
  538. s2 = peg$FAILED;
  539. if (peg$silentFails === 0) { peg$fail(peg$c17); }
  540. }
  541. if (s2 !== peg$FAILED) {
  542. peg$reportedPos = s0;
  543. s1 = peg$c15(s2);
  544. s0 = s1;
  545. } else {
  546. peg$currPos = s0;
  547. s0 = peg$c2;
  548. }
  549. } else {
  550. peg$currPos = s0;
  551. s0 = peg$c2;
  552. }
  553. return s0;
  554. }
  555. function peg$parseesc_seq() {
  556. var s0;
  557. if (input.charCodeAt(peg$currPos) === 92) {
  558. s0 = peg$c18;
  559. peg$currPos++;
  560. } else {
  561. s0 = peg$FAILED;
  562. if (peg$silentFails === 0) { peg$fail(peg$c19); }
  563. }
  564. return s0;
  565. }
  566. function peg$parsecolor() {
  567. var s0, s1, s2;
  568. s0 = peg$currPos;
  569. s1 = [];
  570. if (peg$c20.test(input.charAt(peg$currPos))) {
  571. s2 = input.charAt(peg$currPos);
  572. peg$currPos++;
  573. } else {
  574. s2 = peg$FAILED;
  575. if (peg$silentFails === 0) { peg$fail(peg$c21); }
  576. }
  577. if (s2 !== peg$FAILED) {
  578. while (s2 !== peg$FAILED) {
  579. s1.push(s2);
  580. if (peg$c20.test(input.charAt(peg$currPos))) {
  581. s2 = input.charAt(peg$currPos);
  582. peg$currPos++;
  583. } else {
  584. s2 = peg$FAILED;
  585. if (peg$silentFails === 0) { peg$fail(peg$c21); }
  586. }
  587. }
  588. } else {
  589. s1 = peg$c2;
  590. }
  591. if (s1 !== peg$FAILED) {
  592. peg$reportedPos = s0;
  593. s1 = peg$c22(s1);
  594. }
  595. s0 = s1;
  596. return s0;
  597. }
  598. function peg$parsereset() {
  599. var s0, s1, s2, s3;
  600. s0 = peg$currPos;
  601. s1 = peg$currPos;
  602. s2 = peg$currPos;
  603. peg$silentFails++;
  604. s3 = peg$parseesc_right();
  605. peg$silentFails--;
  606. if (s3 === peg$FAILED) {
  607. s2 = peg$c4;
  608. } else {
  609. peg$currPos = s2;
  610. s2 = peg$c2;
  611. }
  612. if (s2 !== peg$FAILED) {
  613. s3 = peg$parserd();
  614. if (s3 !== peg$FAILED) {
  615. s2 = [s2, s3];
  616. s1 = s2;
  617. } else {
  618. peg$currPos = s1;
  619. s1 = peg$c2;
  620. }
  621. } else {
  622. peg$currPos = s1;
  623. s1 = peg$c2;
  624. }
  625. if (s1 !== peg$FAILED) {
  626. s2 = peg$parseafter();
  627. if (s2 === peg$FAILED) {
  628. s2 = peg$c23;
  629. }
  630. if (s2 !== peg$FAILED) {
  631. peg$reportedPos = s0;
  632. s1 = peg$c24(s1, s2);
  633. s0 = s1;
  634. } else {
  635. peg$currPos = s0;
  636. s0 = peg$c2;
  637. }
  638. } else {
  639. peg$currPos = s0;
  640. s0 = peg$c2;
  641. }
  642. return s0;
  643. }
  644. function peg$parseafter() {
  645. var s0, s1, s2, s3, s4;
  646. s0 = [];
  647. s1 = peg$currPos;
  648. s2 = peg$currPos;
  649. peg$silentFails++;
  650. s3 = peg$parseld();
  651. peg$silentFails--;
  652. if (s3 === peg$FAILED) {
  653. s2 = peg$c4;
  654. } else {
  655. peg$currPos = s2;
  656. s2 = peg$c2;
  657. }
  658. if (s2 !== peg$FAILED) {
  659. s3 = peg$currPos;
  660. peg$silentFails++;
  661. s4 = peg$parserd();
  662. peg$silentFails--;
  663. if (s4 === peg$FAILED) {
  664. s3 = peg$c4;
  665. } else {
  666. peg$currPos = s3;
  667. s3 = peg$c2;
  668. }
  669. if (s3 !== peg$FAILED) {
  670. s4 = peg$parseany();
  671. if (s4 !== peg$FAILED) {
  672. peg$reportedPos = s1;
  673. s2 = peg$c25(s4);
  674. s1 = s2;
  675. } else {
  676. peg$currPos = s1;
  677. s1 = peg$c2;
  678. }
  679. } else {
  680. peg$currPos = s1;
  681. s1 = peg$c2;
  682. }
  683. } else {
  684. peg$currPos = s1;
  685. s1 = peg$c2;
  686. }
  687. if (s1 !== peg$FAILED) {
  688. while (s1 !== peg$FAILED) {
  689. s0.push(s1);
  690. s1 = peg$currPos;
  691. s2 = peg$currPos;
  692. peg$silentFails++;
  693. s3 = peg$parseld();
  694. peg$silentFails--;
  695. if (s3 === peg$FAILED) {
  696. s2 = peg$c4;
  697. } else {
  698. peg$currPos = s2;
  699. s2 = peg$c2;
  700. }
  701. if (s2 !== peg$FAILED) {
  702. s3 = peg$currPos;
  703. peg$silentFails++;
  704. s4 = peg$parserd();
  705. peg$silentFails--;
  706. if (s4 === peg$FAILED) {
  707. s3 = peg$c4;
  708. } else {
  709. peg$currPos = s3;
  710. s3 = peg$c2;
  711. }
  712. if (s3 !== peg$FAILED) {
  713. s4 = peg$parseany();
  714. if (s4 !== peg$FAILED) {
  715. peg$reportedPos = s1;
  716. s2 = peg$c25(s4);
  717. s1 = s2;
  718. } else {
  719. peg$currPos = s1;
  720. s1 = peg$c2;
  721. }
  722. } else {
  723. peg$currPos = s1;
  724. s1 = peg$c2;
  725. }
  726. } else {
  727. peg$currPos = s1;
  728. s1 = peg$c2;
  729. }
  730. }
  731. } else {
  732. s0 = peg$c2;
  733. }
  734. return s0;
  735. }
  736. function peg$parseld() {
  737. var s0;
  738. if (input.charCodeAt(peg$currPos) === 123) {
  739. s0 = peg$c13;
  740. peg$currPos++;
  741. } else {
  742. s0 = peg$FAILED;
  743. if (peg$silentFails === 0) { peg$fail(peg$c14); }
  744. }
  745. return s0;
  746. }
  747. function peg$parserd() {
  748. var s0;
  749. if (input.charCodeAt(peg$currPos) === 125) {
  750. s0 = peg$c16;
  751. peg$currPos++;
  752. } else {
  753. s0 = peg$FAILED;
  754. if (peg$silentFails === 0) { peg$fail(peg$c17); }
  755. }
  756. return s0;
  757. }
  758. function peg$parseeol() {
  759. var s0;
  760. if (input.charCodeAt(peg$currPos) === 10) {
  761. s0 = peg$c26;
  762. peg$currPos++;
  763. } else {
  764. s0 = peg$FAILED;
  765. if (peg$silentFails === 0) { peg$fail(peg$c27); }
  766. }
  767. if (s0 === peg$FAILED) {
  768. if (input.substr(peg$currPos, 2) === peg$c28) {
  769. s0 = peg$c28;
  770. peg$currPos += 2;
  771. } else {
  772. s0 = peg$FAILED;
  773. if (peg$silentFails === 0) { peg$fail(peg$c29); }
  774. }
  775. if (s0 === peg$FAILED) {
  776. if (input.charCodeAt(peg$currPos) === 13) {
  777. s0 = peg$c30;
  778. peg$currPos++;
  779. } else {
  780. s0 = peg$FAILED;
  781. if (peg$silentFails === 0) { peg$fail(peg$c31); }
  782. }
  783. if (s0 === peg$FAILED) {
  784. if (input.charCodeAt(peg$currPos) === 8232) {
  785. s0 = peg$c32;
  786. peg$currPos++;
  787. } else {
  788. s0 = peg$FAILED;
  789. if (peg$silentFails === 0) { peg$fail(peg$c33); }
  790. }
  791. if (s0 === peg$FAILED) {
  792. if (input.charCodeAt(peg$currPos) === 8233) {
  793. s0 = peg$c34;
  794. peg$currPos++;
  795. } else {
  796. s0 = peg$FAILED;
  797. if (peg$silentFails === 0) { peg$fail(peg$c35); }
  798. }
  799. }
  800. }
  801. }
  802. }
  803. return s0;
  804. }
  805. function peg$parsews() {
  806. var s0;
  807. if (peg$c36.test(input.charAt(peg$currPos))) {
  808. s0 = input.charAt(peg$currPos);
  809. peg$currPos++;
  810. } else {
  811. s0 = peg$FAILED;
  812. if (peg$silentFails === 0) { peg$fail(peg$c37); }
  813. }
  814. if (s0 === peg$FAILED) {
  815. s0 = peg$parseeol();
  816. }
  817. return s0;
  818. }
  819. peg$result = peg$startRuleFunction();
  820. if (peg$result !== peg$FAILED && peg$currPos === input.length) {
  821. return peg$result;
  822. } else {
  823. if (peg$result !== peg$FAILED && peg$currPos < input.length) {
  824. peg$fail({ type: "end", description: "end of input" });
  825. }
  826. throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
  827. }
  828. }
  829. return {
  830. SyntaxError: SyntaxError,
  831. parse: parse
  832. };
  833. })()