You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

833 lines
20 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. /*
  2. Copyright 2018 0KIMS association.
  3. This file is part of circom (Zero Knowledge Circuit Compiler).
  4. circom is a free software: you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. circom is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  11. License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with circom. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. /* description: Construct AST for jaz language. */
  16. /* lexical grammar */
  17. %lex
  18. %%
  19. \s+ { /* skip whitespace */ }
  20. \/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/ { /* console.log("MULTILINE COMMENT: "+yytext); */ }
  21. \/\/.* { /* console.log("SINGLE LINE COMMENT: "+yytext); */ }
  22. var { return 'var'; }
  23. signal { return 'signal'; }
  24. private { return 'private'; }
  25. input { return 'input'; }
  26. output { return 'output'; }
  27. linearCombination { return 'linearCombination'; }
  28. component { return 'component'; }
  29. template { return 'template'; }
  30. function { return 'function'; }
  31. if { return 'if'; }
  32. else { return 'else'; }
  33. for { return 'for'; }
  34. while { return 'while'; }
  35. compute { return 'compute'; }
  36. do { return 'do'; }
  37. return { return 'return'; }
  38. include { return 'include'; }
  39. 0x[0-9A-Fa-f]* { return 'HEXNUMBER'; }
  40. [0-9]+ { return 'DECNUMBER'; }
  41. [a-zA-Z][a-zA-Z$_0-9]* { return 'IDENTIFIER'; }
  42. \"[^"]+\" { yytext = yytext.slice(1,-1); return 'STRING'; }
  43. \=\=\> { return '==>'; }
  44. \<\=\= { return '<=='; }
  45. \-\-\> { return '-->'; }
  46. \<\-\- { return '<--'; }
  47. \=\=\= { return '==='; }
  48. \>\>\= { return '>>='; }
  49. \<\<\= { return '<<='; }
  50. \&\& { return '&&'; }
  51. \|\| { return '||'; }
  52. \=\= { return '=='; }
  53. \<\= { return '<='; }
  54. \>\= { return '>='; }
  55. \!\= { return '!='; }
  56. \>\> { return '>>'; }
  57. \<\< { return '<<'; }
  58. \*\* { return '**'; }
  59. \+\+ { return '++'; }
  60. \-\- { return '--'; }
  61. \+\= { return '+='; }
  62. \-\= { return '-='; }
  63. \*\= { return '*='; }
  64. \/\= { return '/='; }
  65. \%\= { return '%='; }
  66. \|\= { return '|='; }
  67. \&\= { return '&='; }
  68. \^\= { return '^='; }
  69. \= { return '='; }
  70. \+ { return '+'; }
  71. \- { return '-'; }
  72. \* { return '*'; }
  73. \/ { return '/'; }
  74. \\ { return '\\'; }
  75. \% { return '%'; }
  76. \^ { return '^'; }
  77. \& { return '&'; }
  78. \| { return '|'; }
  79. \! { return '!'; }
  80. \~ { return '~'; }
  81. \< { return '<'; }
  82. \> { return '>'; }
  83. \! { return '!'; }
  84. \? { return '?'; }
  85. \: { return ':'; }
  86. \( { return '('; }
  87. \) { return ')'; }
  88. \[ { return '['; }
  89. \] { return ']'; }
  90. \{ { return '{'; }
  91. \} { return '}'; }
  92. \; { return ';'; }
  93. \, { return ','; }
  94. \. { return '.'; }
  95. <<EOF>> { return 'EOF'; }
  96. . { console.log("INVALID: " + yytext); return 'INVALID'}
  97. /lex
  98. %left ';'
  99. %right 'if' 'else'
  100. %left EMPTY
  101. %left IDLIST
  102. %left ','
  103. %right '?' ':' TERCOND '=' '+=' '-=' '*=' '/=' '%=' '>>=' '<<=' '&=' '|=' '^=' '<==' '==>' '===' '<--' '-->'
  104. %left '||'
  105. %left '&&'
  106. %left '|'
  107. %left '^'
  108. %left '&'
  109. %left '==' '!='
  110. %left '<=' '>=' '<' '>'
  111. %left '<<' '>>'
  112. %left '+' '-'
  113. %left '*' '/' '\\' '%'
  114. %left '**'
  115. %right '++' '--' UMINUS UPLUS '!' '~'
  116. %left '.'
  117. %left DECL
  118. %left PLUSPLUSRIGHT MINUSMINUSRIGHT '[' ']' '(' ')'
  119. %left HIGH
  120. %{
  121. const Scalar = require('ffjavascript').Scalar;
  122. const util = require('util');
  123. function setLines(dst, first, last) {
  124. last = last || first;
  125. dst.first_line = first.first_line;
  126. dst.first_column = first.first_column;
  127. dst.last_line = last.last_line;
  128. dst.last_column = last.last_column;
  129. }
  130. %}
  131. %start allStatments
  132. %% /* language grammar */
  133. allStatments
  134. : statmentList EOF
  135. {
  136. // console.log(JSON.stringify($1, null, 1));
  137. $$ = { type: "BLOCK", statements: $1.statments };
  138. setLines($$, @1);
  139. return $$
  140. }
  141. ;
  142. statmentList
  143. : statmentList statment
  144. {
  145. $1.statments.push($2);
  146. setLines($1, @1, @2);
  147. }
  148. | statment
  149. {
  150. $$ = { type: "STATMENTLIST", statments: [$1] };
  151. setLines($$, @1);
  152. }
  153. ;
  154. statment
  155. : functionDefinitionStatment
  156. {
  157. $$ = $1;
  158. }
  159. | templateDefinitionStatment
  160. {
  161. $$ = $1;
  162. }
  163. | ifStatment
  164. {
  165. $$ = $1;
  166. }
  167. | forStatment
  168. {
  169. $$ = $1;
  170. }
  171. | whileStatment
  172. {
  173. $$ = $1;
  174. }
  175. | doWhileStatment
  176. {
  177. $$ = $1;
  178. }
  179. | computeStatment
  180. {
  181. $$ = $1;
  182. }
  183. | returnStatment
  184. {
  185. $$ = $1;
  186. }
  187. | block
  188. {
  189. $$ = $1;
  190. }
  191. | expressionStatment
  192. {
  193. $$ = $1;
  194. }
  195. | includeStatment
  196. {
  197. $$ = $1;
  198. }
  199. ;
  200. functionDefinitionStatment
  201. : 'function' IDENTIFIER '(' identifierList ')' block
  202. {
  203. $$ = { type: "FUNCTIONDEF", name: $2, params: $4.identifiers, block: $6};
  204. setLines($$, @1, @6);
  205. }
  206. | 'function' IDENTIFIER '(' ')' block
  207. {
  208. $$ = { type: "FUNCTIONDEF", name: $2, params: [], block: $5 };
  209. setLines($$, @1, @5);
  210. }
  211. ;
  212. templateDefinitionStatment
  213. : 'template' IDENTIFIER '(' identifierList ')' block
  214. {
  215. $$ = { type: "TEMPLATEDEF", name: $2, params: $4.identifiers, block: $6 };
  216. setLines($$, @1, @6);
  217. }
  218. | 'template' IDENTIFIER '(' ')' block
  219. {
  220. $$ = { type: "TEMPLATEDEF", name: $2, params: [], block: $5 };
  221. setLines($$, @1, @5);
  222. }
  223. ;
  224. identifierList
  225. : identifierList ',' IDENTIFIER
  226. {
  227. $1.identifiers.push($3);
  228. setLines($1, @1, @3);
  229. }
  230. | IDENTIFIER %prec EMPTY
  231. {
  232. $$ = { type: "IDENTIFIERLIST", identifiers: [$1] };
  233. setLines($$, @1);
  234. }
  235. ;
  236. ifStatment
  237. : 'if' '(' expression ')' statment 'else' statment
  238. {
  239. $$ = { type: "IF", condition: $3, then: $5, else: $7 };
  240. setLines($$, @1, @7);
  241. }
  242. | 'if' '(' expression ')' statment
  243. {
  244. $$ = { type: "IF", condition: $3, then: $5 };
  245. setLines($$, @1, @5);
  246. }
  247. ;
  248. forStatment
  249. : 'for' '(' expression ';' expression ';' expression ')' statment
  250. {
  251. $$ = { type: "FOR", init: $3, condition: $5, step: $7, body: $9 };
  252. setLines($$, @1, @9);
  253. }
  254. ;
  255. whileStatment
  256. : 'while' '(' expression ')' statment
  257. {
  258. $$ = { type: "WHILE", condition: $3, body: $5 };
  259. setLines($$, @1, @5);
  260. }
  261. ;
  262. doWhileStatment
  263. : 'do' statment 'while' '(' expression ')'
  264. {
  265. $$ = { type: "DOWHILE", condition: $5, body: $2 };
  266. setLines($$, @1, @6);
  267. }
  268. ;
  269. computeStatment
  270. : 'compute' statment
  271. {
  272. $$ = { type: "COMPUTE", body: $2 };
  273. setLines($$, @1, @2);
  274. }
  275. ;
  276. returnStatment
  277. : 'return' expression ';'
  278. {
  279. $$ = { type: "RETURN", value: $2 };
  280. setLines($$, @1, @3);
  281. }
  282. | 'return' expression %prec ';'
  283. {
  284. $$ = { type: "RETURN", value: $2 }
  285. setLines($$, @1, @2);
  286. }
  287. ;
  288. includeStatment
  289. : 'include' STRING ';'
  290. {
  291. $$ = { type: "INCLUDE", file: $2 };
  292. setLines($$, @1, @3);
  293. }
  294. | 'include' STRING %prec ';'
  295. {
  296. $$ = { type: "INCLUDE", file: $2 }
  297. setLines($$, @1, @2);
  298. }
  299. ;
  300. block
  301. : '{' statmentList '}'
  302. {
  303. $$ = { type: "BLOCK", statements: $2.statments };
  304. setLines($$, @1, @3);
  305. }
  306. ;
  307. expressionStatment
  308. : expression ';' %prec ';'
  309. {
  310. $$ = $1;
  311. }
  312. | expression %prec ';'
  313. {
  314. $$ = $1;
  315. }
  316. ;
  317. expression
  318. : e17 %prec EMPTY
  319. {
  320. $$ = $1;
  321. }
  322. ;
  323. e17
  324. : leftHandExpression '=' e17
  325. {
  326. $$ = { type: "OP", op: "=", values: [$1, $3] };
  327. setLines($$, @1, @3);
  328. }
  329. | leftHandExpression '+=' e17
  330. {
  331. $$ = { type: "OP", op: "+=", values: [$1, $3] };
  332. setLines($$, @1, @3);
  333. }
  334. | leftHandExpression '-=' e17
  335. {
  336. $$ = { type: "OP", op: "-=", values: [$1, $3] };
  337. setLines($$, @1, @3);
  338. }
  339. | leftHandExpression '*=' e17
  340. {
  341. $$ = { type: "OP", op: "*=", values: [$1, $3] };
  342. setLines($$, @1, @3);
  343. }
  344. | leftHandExpression '/=' e17
  345. {
  346. $$ = { type: "OP", op: "/=", values: [$1, $3] };
  347. setLines($$, @1, @3);
  348. }
  349. | leftHandExpression '%=' e17
  350. {
  351. $$ = { type: "OP", op: "%=", values: [$1, $3] };
  352. setLines($$, @1, @3);
  353. }
  354. | leftHandExpression '<<=' e17
  355. {
  356. $$ = { type: "OP", op: "<<=", values: [$1, $3] };
  357. setLines($$, @1, @3);
  358. }
  359. | leftHandExpression '>>=' e17
  360. {
  361. $$ = { type: "OP", op: ">>=", values: [$1, $3] };
  362. setLines($$, @1, @3);
  363. }
  364. | leftHandExpression '&=' e17
  365. {
  366. $$ = { type: "OP", op: "&=", values: [$1, $3] };
  367. setLines($$, @1, @3);
  368. }
  369. | leftHandExpression '|=' e17
  370. {
  371. $$ = { type: "OP", op: "|=", values: [$1, $3] };
  372. setLines($$, @1, @3);
  373. }
  374. | leftHandExpression '^=' e17
  375. {
  376. $$ = { type: "OP", op: "^=", values: [$1, $3] };
  377. setLines($$, @1, @3);
  378. }
  379. | leftHandExpression '<==' e17
  380. {
  381. $$ = { type: "OP", op: "<==", values: [$1, $3] };
  382. setLines($$, @1, @3);
  383. }
  384. | e17 '==>' leftHandExpression
  385. {
  386. $$ = { type: "OP", op: "<==", values: [$3, $1] };
  387. setLines($$, @1, @3);
  388. }
  389. | leftHandExpression '<--' e17
  390. {
  391. $$ = { type: "OP", op: "<--", values: [$1, $3] };
  392. setLines($$, @1, @3);
  393. }
  394. | e17 '-->' leftHandExpression
  395. {
  396. $$ = { type: "OP", op: "<--", values: [$3, $1] };
  397. setLines($$, @1, @3);
  398. }
  399. | e16 '===' e17
  400. {
  401. $$ = { type: "OP", op: "===", values: [$1, $3] };
  402. setLines($$, @1, @3);
  403. }
  404. | e17 '?' e17 ':' e17 %prec TERCOND
  405. {
  406. $$ = { type: "OP", op: "?", values: [$1, $3, $5] };
  407. setLines($$, @1, @5);
  408. }
  409. | e16 %prec EMPTY
  410. {
  411. $$ = $1;
  412. }
  413. ;
  414. e16
  415. : rightArray
  416. {
  417. $$ = $1;
  418. }
  419. | e15 %prec EMPTY
  420. {
  421. $$ = $1;
  422. }
  423. ;
  424. e15
  425. : e15 '||' e14
  426. {
  427. $$ = { type: "OP", op: "||", values: [$1, $3] };
  428. setLines($$, @1, @3);
  429. }
  430. | e14 %prec EMPTY
  431. {
  432. $$ = $1;
  433. }
  434. ;
  435. e14
  436. : e14 '&&' e13
  437. {
  438. $$ = { type: "OP", op: "&&", values: [$1, $3] };
  439. setLines($$, @1, @3);
  440. }
  441. | e13 %prec EMPTY
  442. {
  443. $$ = $1;
  444. }
  445. ;
  446. e13
  447. : e13 '|' e12
  448. {
  449. $$ = { type: "OP", op: "|", values: [$1, $3] };
  450. setLines($$, @1, @3);
  451. }
  452. | e12 %prec EMPTY
  453. {
  454. $$ = $1;
  455. }
  456. ;
  457. e12
  458. : e12 '^' e11
  459. {
  460. $$ = { type: "OP", op: "^", values: [$1, $3] };
  461. setLines($$, @1, @3);
  462. }
  463. | e11 %prec EMPTY
  464. {
  465. $$ = $1;
  466. }
  467. ;
  468. e11
  469. : e11 '&' e10
  470. {
  471. $$ = { type: "OP", op: "&", values: [$1, $3] };
  472. setLines($$, @1, @3);
  473. }
  474. | e10 %prec EMPTY
  475. {
  476. $$ = $1;
  477. }
  478. ;
  479. e10
  480. : e10 '==' e9
  481. {
  482. $$ = { type: "OP", op: "==", values: [$1, $3] };
  483. setLines($$, @1, @3);
  484. }
  485. | e10 '!=' e9
  486. {
  487. $$ = { type: "OP", op: "!=", values: [$1, $3] };
  488. setLines($$, @1, @3);
  489. }
  490. | e9 %prec EMPTY
  491. {
  492. $$ = $1
  493. }
  494. ;
  495. e9
  496. : e9 '<=' e7
  497. {
  498. $$ = { type: "OP", op: "<=", values: [$1, $3] };
  499. setLines($$, @1, @3);
  500. }
  501. | e9 '>=' e7
  502. {
  503. $$ = { type: "OP", op: ">=", values: [$1, $3] };
  504. setLines($$, @1, @3);
  505. }
  506. | e9 '<' e7
  507. {
  508. $$ = { type: "OP", op: "<", values: [$1, $3] };
  509. setLines($$, @1, @3);
  510. }
  511. | e9 '>' e7
  512. {
  513. $$ = { type: "OP", op: ">", values: [$1, $3] };
  514. setLines($$, @1, @3);
  515. }
  516. | e7 %prec EMPTY
  517. {
  518. $$ = $1
  519. }
  520. ;
  521. e7
  522. : e7 '<<' e6
  523. {
  524. $$ = { type: "OP", op: "<<", values: [$1, $3] };
  525. setLines($$, @1, @3);
  526. }
  527. | e7 '>>' e6
  528. {
  529. $$ = { type: "OP", op: ">>", values: [$1, $3] };
  530. setLines($$, @1, @3);
  531. }
  532. | e6 %prec EMPTY
  533. {
  534. $$ = $1;
  535. }
  536. ;
  537. e6
  538. : e6 '+' e5
  539. {
  540. $$ = { type: "OP", op: "+", values: [$1, $3] };
  541. setLines($$, @1, @3);
  542. }
  543. | e6 '-' e5
  544. {
  545. $$ = { type: "OP", op: "-", values: [$1, $3] };
  546. setLines($$, @1, @3);
  547. }
  548. | e5 %prec EMPTY
  549. {
  550. $$ = $1;
  551. }
  552. ;
  553. e5
  554. : e5 '*' e4
  555. {
  556. $$ = { type: "OP", op: "*", values: [$1, $3] };
  557. setLines($$, @1, @3);
  558. }
  559. | e5 '/' e4
  560. {
  561. $$ = { type: "OP", op: "/", values: [$1, $3] };
  562. setLines($$, @1, @3);
  563. }
  564. | e5 '\\' e4
  565. {
  566. $$ = { type: "OP", op: "\\", values: [$1, $3] };
  567. setLines($$, @1, @3);
  568. }
  569. | e5 '%' e4
  570. {
  571. $$ = { type: "OP", op: "%", values: [$1, $3] };
  572. setLines($$, @1, @3);
  573. }
  574. | e4 %prec EMPTY
  575. {
  576. $$ = $1;
  577. }
  578. ;
  579. e4
  580. : e4 '**' e3
  581. {
  582. $$ = { type: "OP", op: "**", values: [$1, $3] };
  583. setLines($$, @1, @3);
  584. }
  585. | e3 %prec EMPTY
  586. {
  587. $$ = $1;
  588. }
  589. ;
  590. e3
  591. : '++' leftHandExpression
  592. {
  593. $$ = { type: "OP", op: "PLUSPLUSLEFT", values: [$2] };
  594. setLines($$, @1, @2);
  595. }
  596. | '--' leftHandExpression
  597. {
  598. $$ = { type: "OP", op: "MINUSMINUSLEFT", values: [$2] };
  599. setLines($$, @1, @2);
  600. }
  601. | '+' e3 %prec UPLUS
  602. {
  603. $$ = $2;
  604. setLines($$, @1, @2);
  605. }
  606. | '-' e3 %prec UMINUS
  607. {
  608. $$ = { type: "OP", op: "UMINUS", values: [$2] };
  609. setLines($$, @1, @2);
  610. }
  611. | '!' e3
  612. {
  613. $$ = { type: "OP", op: "!", values: [$2] };
  614. setLines($$, @1, @2);
  615. }
  616. | '~' e3
  617. {
  618. $$ = { type: "OP", op: "~", values: [$2] };
  619. setLines($$, @1, @2);
  620. }
  621. | e2 %prec EMPTY
  622. {
  623. $$ = $1;
  624. }
  625. ;
  626. e2
  627. : leftHandExpression '++' %prec PLUSPLUSRIGHT
  628. {
  629. $$ = {type: "OP", op: "PLUSPLUSRIGHT", values: [$1] };
  630. setLines($$, @1, @2);
  631. }
  632. | leftHandExpression '--' %prec MINUSMINUSRIGHT
  633. {
  634. $$ = {type: "OP", op: "MINUSMINUSRIGHT", values: [$1] };
  635. setLines($$, @1, @2);
  636. }
  637. | functionCall
  638. {
  639. $$ = $1;
  640. }
  641. | e0 %prec EMPTY
  642. {
  643. $$ = $1;
  644. }
  645. ;
  646. e0
  647. : leftHandExpression %prec EMPTY
  648. {
  649. $$ = $1
  650. }
  651. | DECNUMBER
  652. {
  653. $$ = {type: "NUMBER", value: Scalar.fromString($1) }
  654. setLines($$, @1);
  655. }
  656. | HEXNUMBER
  657. {
  658. $$ = {type: "NUMBER", value: Scalar.fromString($1.substr(2).toUpperCase(), 16) }
  659. setLines($$, @1);
  660. }
  661. | '(' expression ')' %prec EMPTY
  662. {
  663. $$ = $2;
  664. setLines($$, @1, @3);
  665. }
  666. ;
  667. leftHandExpression
  668. : simpleLeftHandExpression '.' simpleLeftHandExpression %prec EMPTY
  669. {
  670. $$ = {type: "PIN", component: $1, pin: $3 };
  671. setLines($$, @1, @3);
  672. }
  673. | declaration %prec DECL
  674. {
  675. $$ = $1
  676. }
  677. | simpleLeftHandExpression %prec EMPTY
  678. {
  679. $$ = $1
  680. }
  681. ;
  682. declaration
  683. : 'var' simpleLeftHandExpression %prec DECL
  684. {
  685. $$ = {type: "DECLARE", declareType: "VARIABLE", name: $2}
  686. setLines($$, @1, @2);
  687. }
  688. | 'signal' simpleLeftHandExpression %prec DECL
  689. {
  690. $$ = {type: "DECLARE", declareType: "SIGNAL", name: $2}
  691. setLines($$, @1, @2);
  692. }
  693. | 'signal' 'input' simpleLeftHandExpression %prec DECL
  694. {
  695. $$ = {type: "DECLARE", declareType: "SIGNALIN", name: $3};
  696. setLines($$, @1, @3);
  697. }
  698. | 'signal' 'private' 'input' simpleLeftHandExpression %prec DECL
  699. {
  700. $$ = {type: "DECLARE", declareType: "SIGNALIN", private: true, name: $4};
  701. setLines($$, @1, @4);
  702. }
  703. | 'signal' 'output' simpleLeftHandExpression %prec DECL
  704. {
  705. $$ = {type: "DECLARE", declareType: "SIGNALOUT", name: $3};
  706. setLines($$, @1, @3);
  707. }
  708. | 'component' simpleLeftHandExpression %prec DECL
  709. {
  710. $$ = {type: "DECLARE", declareType: "COMPONENT", name: $2}
  711. setLines($$, @1, @2);
  712. }
  713. ;
  714. simpleLeftHandExpression
  715. : simpleLeftHandExpression array
  716. {
  717. for (let i=0; i< $2.values.length; i++) {
  718. $1.selectors.push($2.values[i]);
  719. }
  720. setLines($1, @1, @2);
  721. }
  722. | IDENTIFIER %prec EMPTY
  723. {
  724. $$ = {type: "VARIABLE", name: $1 , selectors: []};
  725. setLines($$, @1);
  726. }
  727. ;
  728. functionCall
  729. : IDENTIFIER '(' expressionList ')'
  730. {
  731. $$ = {type: "FUNCTIONCALL", name: $1, params: $3.expressions}
  732. setLines($$, @1, @4);
  733. }
  734. | IDENTIFIER '(' ')'
  735. {
  736. $$ = {type: "FUNCTIONCALL", name: $1, params: []}
  737. setLines($$, @1, @3);
  738. }
  739. ;
  740. expressionList
  741. : expressionList ',' expression
  742. {
  743. $1.expressions.push($3);
  744. setLines($$, @1, @3);
  745. }
  746. | expression %prec ','
  747. {
  748. $$ = {type: "EXPRESSIONLST", expressions: [$1]};
  749. setLines($$, @1);
  750. }
  751. ;
  752. rightArray
  753. : array %prec EMPTY
  754. {
  755. $$ = $1;
  756. }
  757. ;
  758. array
  759. : '[' expressionList ']'
  760. {
  761. $$ = { type: "ARRAY", values: $2.expressions};
  762. setLines($$, @1, @3);
  763. }
  764. ;