grammar.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. // Generated by CoffeeScript 1.10.0
  2. (function() {
  3. var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
  4. Parser = require('jison').Parser;
  5. unwrap = /^function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/;
  6. o = function(patternString, action, options) {
  7. var addLocationDataFn, match, patternCount;
  8. patternString = patternString.replace(/\s{2,}/g, ' ');
  9. patternCount = patternString.split(' ').length;
  10. if (!action) {
  11. return [patternString, '$$ = $1;', options];
  12. }
  13. action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())";
  14. action = action.replace(/\bnew /g, '$&yy.');
  15. action = action.replace(/\b(?:Block\.wrap|extend)\b/g, 'yy.$&');
  16. addLocationDataFn = function(first, last) {
  17. if (!last) {
  18. return "yy.addLocationDataFn(@" + first + ")";
  19. } else {
  20. return "yy.addLocationDataFn(@" + first + ", @" + last + ")";
  21. }
  22. };
  23. action = action.replace(/LOC\(([0-9]*)\)/g, addLocationDataFn('$1'));
  24. action = action.replace(/LOC\(([0-9]*),\s*([0-9]*)\)/g, addLocationDataFn('$1', '$2'));
  25. return [patternString, "$$ = " + (addLocationDataFn(1, patternCount)) + "(" + action + ");", options];
  26. };
  27. grammar = {
  28. Root: [
  29. o('', function() {
  30. return new Block;
  31. }), o('Body')
  32. ],
  33. Body: [
  34. o('Line', function() {
  35. return Block.wrap([$1]);
  36. }), o('Body TERMINATOR Line', function() {
  37. return $1.push($3);
  38. }), o('Body TERMINATOR')
  39. ],
  40. Line: [o('Expression'), o('Statement')],
  41. Statement: [
  42. o('Return'), o('Comment'), o('STATEMENT', function() {
  43. return new Literal($1);
  44. })
  45. ],
  46. Expression: [o('Value'), o('Invocation'), o('Code'), o('Operation'), o('Assign'), o('If'), o('Try'), o('While'), o('For'), o('Switch'), o('Class'), o('Throw')],
  47. Block: [
  48. o('INDENT OUTDENT', function() {
  49. return new Block;
  50. }), o('INDENT Body OUTDENT', function() {
  51. return $2;
  52. })
  53. ],
  54. Identifier: [
  55. o('IDENTIFIER', function() {
  56. return new Literal($1);
  57. })
  58. ],
  59. AlphaNumeric: [
  60. o('NUMBER', function() {
  61. return new Literal($1);
  62. }), o('String')
  63. ],
  64. String: [
  65. o('STRING', function() {
  66. return new Literal($1);
  67. }), o('STRING_START Body STRING_END', function() {
  68. return new Parens($2);
  69. })
  70. ],
  71. Regex: [
  72. o('REGEX', function() {
  73. return new Literal($1);
  74. }), o('REGEX_START Invocation REGEX_END', function() {
  75. return $2;
  76. })
  77. ],
  78. Literal: [
  79. o('AlphaNumeric'), o('JS', function() {
  80. return new Literal($1);
  81. }), o('Regex'), o('DEBUGGER', function() {
  82. return new Literal($1);
  83. }), o('UNDEFINED', function() {
  84. return new Undefined;
  85. }), o('NULL', function() {
  86. return new Null;
  87. }), o('BOOL', function() {
  88. return new Bool($1);
  89. })
  90. ],
  91. Assign: [
  92. o('Assignable = Expression', function() {
  93. return new Assign($1, $3);
  94. }), o('Assignable = TERMINATOR Expression', function() {
  95. return new Assign($1, $4);
  96. }), o('Assignable = INDENT Expression OUTDENT', function() {
  97. return new Assign($1, $4);
  98. })
  99. ],
  100. AssignObj: [
  101. o('ObjAssignable', function() {
  102. return new Value($1);
  103. }), o('ObjAssignable : Expression', function() {
  104. return new Assign(LOC(1)(new Value($1)), $3, 'object', {
  105. operatorToken: LOC(2)(new Literal($2))
  106. });
  107. }), o('ObjAssignable : INDENT Expression OUTDENT', function() {
  108. return new Assign(LOC(1)(new Value($1)), $4, 'object', {
  109. operatorToken: LOC(2)(new Literal($2))
  110. });
  111. }), o('SimpleObjAssignable = Expression', function() {
  112. return new Assign(LOC(1)(new Value($1)), $3, null, {
  113. operatorToken: LOC(2)(new Literal($2))
  114. });
  115. }), o('SimpleObjAssignable = INDENT Expression OUTDENT', function() {
  116. return new Assign(LOC(1)(new Value($1)), $4, null, {
  117. operatorToken: LOC(2)(new Literal($2))
  118. });
  119. }), o('Comment')
  120. ],
  121. SimpleObjAssignable: [o('Identifier'), o('ThisProperty')],
  122. ObjAssignable: [o('SimpleObjAssignable'), o('AlphaNumeric')],
  123. Return: [
  124. o('RETURN Expression', function() {
  125. return new Return($2);
  126. }), o('RETURN', function() {
  127. return new Return;
  128. })
  129. ],
  130. Comment: [
  131. o('HERECOMMENT', function() {
  132. return new Comment($1);
  133. })
  134. ],
  135. Code: [
  136. o('PARAM_START ParamList PARAM_END FuncGlyph Block', function() {
  137. return new Code($2, $5, $4);
  138. }), o('FuncGlyph Block', function() {
  139. return new Code([], $2, $1);
  140. })
  141. ],
  142. FuncGlyph: [
  143. o('->', function() {
  144. return 'func';
  145. }), o('=>', function() {
  146. return 'boundfunc';
  147. })
  148. ],
  149. OptComma: [o(''), o(',')],
  150. ParamList: [
  151. o('', function() {
  152. return [];
  153. }), o('Param', function() {
  154. return [$1];
  155. }), o('ParamList , Param', function() {
  156. return $1.concat($3);
  157. }), o('ParamList OptComma TERMINATOR Param', function() {
  158. return $1.concat($4);
  159. }), o('ParamList OptComma INDENT ParamList OptComma OUTDENT', function() {
  160. return $1.concat($4);
  161. })
  162. ],
  163. Param: [
  164. o('ParamVar', function() {
  165. return new Param($1);
  166. }), o('ParamVar ...', function() {
  167. return new Param($1, null, true);
  168. }), o('ParamVar = Expression', function() {
  169. return new Param($1, $3);
  170. }), o('...', function() {
  171. return new Expansion;
  172. })
  173. ],
  174. ParamVar: [o('Identifier'), o('ThisProperty'), o('Array'), o('Object')],
  175. Splat: [
  176. o('Expression ...', function() {
  177. return new Splat($1);
  178. })
  179. ],
  180. SimpleAssignable: [
  181. o('Identifier', function() {
  182. return new Value($1);
  183. }), o('Value Accessor', function() {
  184. return $1.add($2);
  185. }), o('Invocation Accessor', function() {
  186. return new Value($1, [].concat($2));
  187. }), o('ThisProperty')
  188. ],
  189. Assignable: [
  190. o('SimpleAssignable'), o('Array', function() {
  191. return new Value($1);
  192. }), o('Object', function() {
  193. return new Value($1);
  194. })
  195. ],
  196. Value: [
  197. o('Assignable'), o('Literal', function() {
  198. return new Value($1);
  199. }), o('Parenthetical', function() {
  200. return new Value($1);
  201. }), o('Range', function() {
  202. return new Value($1);
  203. }), o('This')
  204. ],
  205. Accessor: [
  206. o('. Identifier', function() {
  207. return new Access($2);
  208. }), o('?. Identifier', function() {
  209. return new Access($2, 'soak');
  210. }), o(':: Identifier', function() {
  211. return [LOC(1)(new Access(new Literal('prototype'))), LOC(2)(new Access($2))];
  212. }), o('?:: Identifier', function() {
  213. return [LOC(1)(new Access(new Literal('prototype'), 'soak')), LOC(2)(new Access($2))];
  214. }), o('::', function() {
  215. return new Access(new Literal('prototype'));
  216. }), o('Index')
  217. ],
  218. Index: [
  219. o('INDEX_START IndexValue INDEX_END', function() {
  220. return $2;
  221. }), o('INDEX_SOAK Index', function() {
  222. return extend($2, {
  223. soak: true
  224. });
  225. })
  226. ],
  227. IndexValue: [
  228. o('Expression', function() {
  229. return new Index($1);
  230. }), o('Slice', function() {
  231. return new Slice($1);
  232. })
  233. ],
  234. Object: [
  235. o('{ AssignList OptComma }', function() {
  236. return new Obj($2, $1.generated);
  237. })
  238. ],
  239. AssignList: [
  240. o('', function() {
  241. return [];
  242. }), o('AssignObj', function() {
  243. return [$1];
  244. }), o('AssignList , AssignObj', function() {
  245. return $1.concat($3);
  246. }), o('AssignList OptComma TERMINATOR AssignObj', function() {
  247. return $1.concat($4);
  248. }), o('AssignList OptComma INDENT AssignList OptComma OUTDENT', function() {
  249. return $1.concat($4);
  250. })
  251. ],
  252. Class: [
  253. o('CLASS', function() {
  254. return new Class;
  255. }), o('CLASS Block', function() {
  256. return new Class(null, null, $2);
  257. }), o('CLASS EXTENDS Expression', function() {
  258. return new Class(null, $3);
  259. }), o('CLASS EXTENDS Expression Block', function() {
  260. return new Class(null, $3, $4);
  261. }), o('CLASS SimpleAssignable', function() {
  262. return new Class($2);
  263. }), o('CLASS SimpleAssignable Block', function() {
  264. return new Class($2, null, $3);
  265. }), o('CLASS SimpleAssignable EXTENDS Expression', function() {
  266. return new Class($2, $4);
  267. }), o('CLASS SimpleAssignable EXTENDS Expression Block', function() {
  268. return new Class($2, $4, $5);
  269. })
  270. ],
  271. Invocation: [
  272. o('Value OptFuncExist Arguments', function() {
  273. return new Call($1, $3, $2);
  274. }), o('Invocation OptFuncExist Arguments', function() {
  275. return new Call($1, $3, $2);
  276. }), o('SUPER', function() {
  277. return new Call('super', [new Splat(new Literal('arguments'))]);
  278. }), o('SUPER Arguments', function() {
  279. return new Call('super', $2);
  280. })
  281. ],
  282. OptFuncExist: [
  283. o('', function() {
  284. return false;
  285. }), o('FUNC_EXIST', function() {
  286. return true;
  287. })
  288. ],
  289. Arguments: [
  290. o('CALL_START CALL_END', function() {
  291. return [];
  292. }), o('CALL_START ArgList OptComma CALL_END', function() {
  293. return $2;
  294. })
  295. ],
  296. This: [
  297. o('THIS', function() {
  298. return new Value(new Literal('this'));
  299. }), o('@', function() {
  300. return new Value(new Literal('this'));
  301. })
  302. ],
  303. ThisProperty: [
  304. o('@ Identifier', function() {
  305. return new Value(LOC(1)(new Literal('this')), [LOC(2)(new Access($2))], 'this');
  306. })
  307. ],
  308. Array: [
  309. o('[ ]', function() {
  310. return new Arr([]);
  311. }), o('[ ArgList OptComma ]', function() {
  312. return new Arr($2);
  313. })
  314. ],
  315. RangeDots: [
  316. o('..', function() {
  317. return 'inclusive';
  318. }), o('...', function() {
  319. return 'exclusive';
  320. })
  321. ],
  322. Range: [
  323. o('[ Expression RangeDots Expression ]', function() {
  324. return new Range($2, $4, $3);
  325. })
  326. ],
  327. Slice: [
  328. o('Expression RangeDots Expression', function() {
  329. return new Range($1, $3, $2);
  330. }), o('Expression RangeDots', function() {
  331. return new Range($1, null, $2);
  332. }), o('RangeDots Expression', function() {
  333. return new Range(null, $2, $1);
  334. }), o('RangeDots', function() {
  335. return new Range(null, null, $1);
  336. })
  337. ],
  338. ArgList: [
  339. o('Arg', function() {
  340. return [$1];
  341. }), o('ArgList , Arg', function() {
  342. return $1.concat($3);
  343. }), o('ArgList OptComma TERMINATOR Arg', function() {
  344. return $1.concat($4);
  345. }), o('INDENT ArgList OptComma OUTDENT', function() {
  346. return $2;
  347. }), o('ArgList OptComma INDENT ArgList OptComma OUTDENT', function() {
  348. return $1.concat($4);
  349. })
  350. ],
  351. Arg: [
  352. o('Expression'), o('Splat'), o('...', function() {
  353. return new Expansion;
  354. })
  355. ],
  356. SimpleArgs: [
  357. o('Expression'), o('SimpleArgs , Expression', function() {
  358. return [].concat($1, $3);
  359. })
  360. ],
  361. Try: [
  362. o('TRY Block', function() {
  363. return new Try($2);
  364. }), o('TRY Block Catch', function() {
  365. return new Try($2, $3[0], $3[1]);
  366. }), o('TRY Block FINALLY Block', function() {
  367. return new Try($2, null, null, $4);
  368. }), o('TRY Block Catch FINALLY Block', function() {
  369. return new Try($2, $3[0], $3[1], $5);
  370. })
  371. ],
  372. Catch: [
  373. o('CATCH Identifier Block', function() {
  374. return [$2, $3];
  375. }), o('CATCH Object Block', function() {
  376. return [LOC(2)(new Value($2)), $3];
  377. }), o('CATCH Block', function() {
  378. return [null, $2];
  379. })
  380. ],
  381. Throw: [
  382. o('THROW Expression', function() {
  383. return new Throw($2);
  384. })
  385. ],
  386. Parenthetical: [
  387. o('( Body )', function() {
  388. return new Parens($2);
  389. }), o('( INDENT Body OUTDENT )', function() {
  390. return new Parens($3);
  391. })
  392. ],
  393. WhileSource: [
  394. o('WHILE Expression', function() {
  395. return new While($2);
  396. }), o('WHILE Expression WHEN Expression', function() {
  397. return new While($2, {
  398. guard: $4
  399. });
  400. }), o('UNTIL Expression', function() {
  401. return new While($2, {
  402. invert: true
  403. });
  404. }), o('UNTIL Expression WHEN Expression', function() {
  405. return new While($2, {
  406. invert: true,
  407. guard: $4
  408. });
  409. })
  410. ],
  411. While: [
  412. o('WhileSource Block', function() {
  413. return $1.addBody($2);
  414. }), o('Statement WhileSource', function() {
  415. return $2.addBody(LOC(1)(Block.wrap([$1])));
  416. }), o('Expression WhileSource', function() {
  417. return $2.addBody(LOC(1)(Block.wrap([$1])));
  418. }), o('Loop', function() {
  419. return $1;
  420. })
  421. ],
  422. Loop: [
  423. o('LOOP Block', function() {
  424. return new While(LOC(1)(new Literal('true'))).addBody($2);
  425. }), o('LOOP Expression', function() {
  426. return new While(LOC(1)(new Literal('true'))).addBody(LOC(2)(Block.wrap([$2])));
  427. })
  428. ],
  429. For: [
  430. o('Statement ForBody', function() {
  431. return new For($1, $2);
  432. }), o('Expression ForBody', function() {
  433. return new For($1, $2);
  434. }), o('ForBody Block', function() {
  435. return new For($2, $1);
  436. })
  437. ],
  438. ForBody: [
  439. o('FOR Range', function() {
  440. return {
  441. source: LOC(2)(new Value($2))
  442. };
  443. }), o('FOR Range BY Expression', function() {
  444. return {
  445. source: LOC(2)(new Value($2)),
  446. step: $4
  447. };
  448. }), o('ForStart ForSource', function() {
  449. $2.own = $1.own;
  450. $2.name = $1[0];
  451. $2.index = $1[1];
  452. return $2;
  453. })
  454. ],
  455. ForStart: [
  456. o('FOR ForVariables', function() {
  457. return $2;
  458. }), o('FOR OWN ForVariables', function() {
  459. $3.own = true;
  460. return $3;
  461. })
  462. ],
  463. ForValue: [
  464. o('Identifier'), o('ThisProperty'), o('Array', function() {
  465. return new Value($1);
  466. }), o('Object', function() {
  467. return new Value($1);
  468. })
  469. ],
  470. ForVariables: [
  471. o('ForValue', function() {
  472. return [$1];
  473. }), o('ForValue , ForValue', function() {
  474. return [$1, $3];
  475. })
  476. ],
  477. ForSource: [
  478. o('FORIN Expression', function() {
  479. return {
  480. source: $2
  481. };
  482. }), o('FOROF Expression', function() {
  483. return {
  484. source: $2,
  485. object: true
  486. };
  487. }), o('FORIN Expression WHEN Expression', function() {
  488. return {
  489. source: $2,
  490. guard: $4
  491. };
  492. }), o('FOROF Expression WHEN Expression', function() {
  493. return {
  494. source: $2,
  495. guard: $4,
  496. object: true
  497. };
  498. }), o('FORIN Expression BY Expression', function() {
  499. return {
  500. source: $2,
  501. step: $4
  502. };
  503. }), o('FORIN Expression WHEN Expression BY Expression', function() {
  504. return {
  505. source: $2,
  506. guard: $4,
  507. step: $6
  508. };
  509. }), o('FORIN Expression BY Expression WHEN Expression', function() {
  510. return {
  511. source: $2,
  512. step: $4,
  513. guard: $6
  514. };
  515. })
  516. ],
  517. Switch: [
  518. o('SWITCH Expression INDENT Whens OUTDENT', function() {
  519. return new Switch($2, $4);
  520. }), o('SWITCH Expression INDENT Whens ELSE Block OUTDENT', function() {
  521. return new Switch($2, $4, $6);
  522. }), o('SWITCH INDENT Whens OUTDENT', function() {
  523. return new Switch(null, $3);
  524. }), o('SWITCH INDENT Whens ELSE Block OUTDENT', function() {
  525. return new Switch(null, $3, $5);
  526. })
  527. ],
  528. Whens: [
  529. o('When'), o('Whens When', function() {
  530. return $1.concat($2);
  531. })
  532. ],
  533. When: [
  534. o('LEADING_WHEN SimpleArgs Block', function() {
  535. return [[$2, $3]];
  536. }), o('LEADING_WHEN SimpleArgs Block TERMINATOR', function() {
  537. return [[$2, $3]];
  538. })
  539. ],
  540. IfBlock: [
  541. o('IF Expression Block', function() {
  542. return new If($2, $3, {
  543. type: $1
  544. });
  545. }), o('IfBlock ELSE IF Expression Block', function() {
  546. return $1.addElse(LOC(3, 5)(new If($4, $5, {
  547. type: $3
  548. })));
  549. })
  550. ],
  551. If: [
  552. o('IfBlock'), o('IfBlock ELSE Block', function() {
  553. return $1.addElse($3);
  554. }), o('Statement POST_IF Expression', function() {
  555. return new If($3, LOC(1)(Block.wrap([$1])), {
  556. type: $2,
  557. statement: true
  558. });
  559. }), o('Expression POST_IF Expression', function() {
  560. return new If($3, LOC(1)(Block.wrap([$1])), {
  561. type: $2,
  562. statement: true
  563. });
  564. })
  565. ],
  566. Operation: [
  567. o('UNARY Expression', function() {
  568. return new Op($1, $2);
  569. }), o('UNARY_MATH Expression', function() {
  570. return new Op($1, $2);
  571. }), o('- Expression', (function() {
  572. return new Op('-', $2);
  573. }), {
  574. prec: 'UNARY_MATH'
  575. }), o('+ Expression', (function() {
  576. return new Op('+', $2);
  577. }), {
  578. prec: 'UNARY_MATH'
  579. }), o('YIELD Statement', function() {
  580. return new Op($1, $2);
  581. }), o('YIELD Expression', function() {
  582. return new Op($1, $2);
  583. }), o('YIELD FROM Expression', function() {
  584. return new Op($1.concat($2), $3);
  585. }), o('-- SimpleAssignable', function() {
  586. return new Op('--', $2);
  587. }), o('++ SimpleAssignable', function() {
  588. return new Op('++', $2);
  589. }), o('SimpleAssignable --', function() {
  590. return new Op('--', $1, null, true);
  591. }), o('SimpleAssignable ++', function() {
  592. return new Op('++', $1, null, true);
  593. }), o('Expression ?', function() {
  594. return new Existence($1);
  595. }), o('Expression + Expression', function() {
  596. return new Op('+', $1, $3);
  597. }), o('Expression - Expression', function() {
  598. return new Op('-', $1, $3);
  599. }), o('Expression MATH Expression', function() {
  600. return new Op($2, $1, $3);
  601. }), o('Expression ** Expression', function() {
  602. return new Op($2, $1, $3);
  603. }), o('Expression SHIFT Expression', function() {
  604. return new Op($2, $1, $3);
  605. }), o('Expression COMPARE Expression', function() {
  606. return new Op($2, $1, $3);
  607. }), o('Expression LOGIC Expression', function() {
  608. return new Op($2, $1, $3);
  609. }), o('Expression RELATION Expression', function() {
  610. if ($2.charAt(0) === '!') {
  611. return new Op($2.slice(1), $1, $3).invert();
  612. } else {
  613. return new Op($2, $1, $3);
  614. }
  615. }), o('SimpleAssignable COMPOUND_ASSIGN Expression', function() {
  616. return new Assign($1, $3, $2);
  617. }), o('SimpleAssignable COMPOUND_ASSIGN INDENT Expression OUTDENT', function() {
  618. return new Assign($1, $4, $2);
  619. }), o('SimpleAssignable COMPOUND_ASSIGN TERMINATOR Expression', function() {
  620. return new Assign($1, $4, $2);
  621. }), o('SimpleAssignable EXTENDS Expression', function() {
  622. return new Extends($1, $3);
  623. })
  624. ]
  625. };
  626. operators = [['left', '.', '?.', '::', '?::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['right', '**'], ['right', 'UNARY_MATH'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', 'YIELD'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['left', 'POST_IF']];
  627. tokens = [];
  628. for (name in grammar) {
  629. alternatives = grammar[name];
  630. grammar[name] = (function() {
  631. var i, j, len, len1, ref, results;
  632. results = [];
  633. for (i = 0, len = alternatives.length; i < len; i++) {
  634. alt = alternatives[i];
  635. ref = alt[0].split(' ');
  636. for (j = 0, len1 = ref.length; j < len1; j++) {
  637. token = ref[j];
  638. if (!grammar[token]) {
  639. tokens.push(token);
  640. }
  641. }
  642. if (name === 'Root') {
  643. alt[1] = "return " + alt[1];
  644. }
  645. results.push(alt);
  646. }
  647. return results;
  648. })();
  649. }
  650. exports.parser = new Parser({
  651. tokens: tokens.join(' '),
  652. bnf: grammar,
  653. operators: operators.reverse(),
  654. startSymbol: 'Root'
  655. });
  656. }).call(this);