jsonFieldExpressionParser.js 21 KB

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