NCDConfigParser_parse.y 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. /**
  2. * @file NCDConfigParser.y
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the author nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. %include {
  30. #include <string.h>
  31. #include <stddef.h>
  32. #include <misc/debug.h>
  33. #include <misc/concat_strings.h>
  34. #include <ncd/NCDAst.h>
  35. struct parser_out {
  36. int out_of_memory;
  37. int syntax_error;
  38. int have_ast;
  39. NCDProgram ast;
  40. };
  41. struct token {
  42. char *str;
  43. size_t len;
  44. };
  45. struct program {
  46. int have;
  47. NCDProgram v;
  48. };
  49. struct block {
  50. int have;
  51. NCDBlock v;
  52. };
  53. struct statement {
  54. int have;
  55. NCDStatement v;
  56. };
  57. struct ifblock {
  58. int have;
  59. NCDIfBlock v;
  60. };
  61. struct value {
  62. int have;
  63. NCDValue v;
  64. };
  65. static void free_token (struct token o) { free(o.str); }
  66. static void free_program (struct program o) { if (o.have) NCDProgram_Free(&o.v); }
  67. static void free_block (struct block o) { if (o.have) NCDBlock_Free(&o.v); }
  68. static void free_statement (struct statement o) { if (o.have) NCDStatement_Free(&o.v); }
  69. static void free_ifblock (struct ifblock o) { if (o.have) NCDIfBlock_Free(&o.v); }
  70. static void free_value (struct value o) { if (o.have) NCDValue_Free(&o.v); }
  71. }
  72. %extra_argument { struct parser_out *parser_out }
  73. %token_type { struct token }
  74. %token_destructor { free_token($$); }
  75. %type processes { struct program }
  76. %type statement { struct statement }
  77. %type elif_maybe { struct ifblock }
  78. %type elif { struct ifblock }
  79. %type else_maybe { struct block }
  80. %type statements { struct block }
  81. %type dotted_name { char * }
  82. %type statement_args_maybe { struct value }
  83. %type list_contents { struct value }
  84. %type list { struct value }
  85. %type map_contents { struct value }
  86. %type map { struct value }
  87. %type invoc { struct value }
  88. %type value { struct value }
  89. %type name_maybe { char * }
  90. %type process_or_template { int }
  91. // mention parser_out in some destructor to a void unused variable warning
  92. %destructor processes { (void)parser_out; free_program($$); }
  93. %destructor statement { free_statement($$); }
  94. %destructor elif_maybe { free_ifblock($$); }
  95. %destructor elif { free_ifblock($$); }
  96. %destructor else_maybe { free_block($$); }
  97. %destructor statements { free_block($$); }
  98. %destructor dotted_name { free($$); }
  99. %destructor statement_args_maybe { free_value($$); }
  100. %destructor list_contents { free_value($$); }
  101. %destructor list { free_value($$); }
  102. %destructor map_contents { free_value($$); }
  103. %destructor map { free_value($$); }
  104. %destructor invoc { free_value($$); }
  105. %destructor value { free_value($$); }
  106. %destructor name_maybe { free($$); }
  107. %stack_size 0
  108. %syntax_error {
  109. parser_out->syntax_error = 1;
  110. }
  111. // workaroud Lemon bug: if the stack overflows, the token that caused the overflow will be leaked
  112. %stack_overflow {
  113. if (yypMinor) {
  114. free_token(yypMinor->yy0);
  115. }
  116. }
  117. input ::= processes(A). {
  118. ASSERT(!parser_out->have_ast)
  119. if (A.have) {
  120. parser_out->have_ast = 1;
  121. parser_out->ast = A.v;
  122. }
  123. }
  124. processes(R) ::= . {
  125. NCDProgram prog;
  126. NCDProgram_Init(&prog);
  127. R.have = 1;
  128. R.v = prog;
  129. }
  130. processes(R) ::= INCLUDE STRING(A) processes(N). {
  131. ASSERT(A.str)
  132. if (!N.have) {
  133. goto failA0;
  134. }
  135. NCDProgramElem elem;
  136. if (!NCDProgramElem_InitInclude(&elem, A.str, A.len)) {
  137. goto failA0;
  138. }
  139. if (!NCDProgram_PrependElem(&N.v, elem)) {
  140. goto failA1;
  141. }
  142. R.have = 1;
  143. R.v = N.v;
  144. N.have = 0;
  145. goto doneA;
  146. failA1:
  147. NCDProgramElem_Free(&elem);
  148. failA0:
  149. R.have = 0;
  150. parser_out->out_of_memory = 1;
  151. doneA:
  152. free_token(A);
  153. free_program(N);
  154. }
  155. processes(R) ::= INCLUDE_GUARD STRING(A) processes(N). {
  156. ASSERT(A.str)
  157. if (!N.have) {
  158. goto failZ0;
  159. }
  160. NCDProgramElem elem;
  161. if (!NCDProgramElem_InitIncludeGuard(&elem, A.str, A.len)) {
  162. goto failZ0;
  163. }
  164. if (!NCDProgram_PrependElem(&N.v, elem)) {
  165. goto failZ1;
  166. }
  167. R.have = 1;
  168. R.v = N.v;
  169. N.have = 0;
  170. goto doneZ;
  171. failZ1:
  172. NCDProgramElem_Free(&elem);
  173. failZ0:
  174. R.have = 0;
  175. parser_out->out_of_memory = 1;
  176. doneZ:
  177. free_token(A);
  178. free_program(N);
  179. }
  180. processes(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE processes(N). {
  181. ASSERT(A.str)
  182. if (!B.have || !N.have) {
  183. goto failB0;
  184. }
  185. NCDProcess proc;
  186. if (!NCDProcess_Init(&proc, T, A.str, B.v)) {
  187. goto failB0;
  188. }
  189. B.have = 0;
  190. NCDProgramElem elem;
  191. NCDProgramElem_InitProcess(&elem, proc);
  192. if (!NCDProgram_PrependElem(&N.v, elem)) {
  193. goto failB1;
  194. }
  195. R.have = 1;
  196. R.v = N.v;
  197. N.have = 0;
  198. goto doneB;
  199. failB1:
  200. NCDProgramElem_Free(&elem);
  201. failB0:
  202. R.have = 0;
  203. parser_out->out_of_memory = 1;
  204. doneB:
  205. free_token(A);
  206. free_block(B);
  207. free_program(N);
  208. }
  209. statement(R) ::= dotted_name(A) ROUND_OPEN statement_args_maybe(B) ROUND_CLOSE name_maybe(C) SEMICOLON. {
  210. if (!A || !B.have) {
  211. goto failC0;
  212. }
  213. if (!NCDStatement_InitReg(&R.v, C, NULL, A, B.v)) {
  214. goto failC0;
  215. }
  216. B.have = 0;
  217. R.have = 1;
  218. goto doneC;
  219. failC0:
  220. R.have = 0;
  221. parser_out->out_of_memory = 1;
  222. doneC:
  223. free(A);
  224. free_value(B);
  225. free(C);
  226. }
  227. statement(R) ::= dotted_name(M) ARROW dotted_name(A) ROUND_OPEN statement_args_maybe(B) ROUND_CLOSE name_maybe(C) SEMICOLON. {
  228. if (!M || !A || !B.have) {
  229. goto failD0;
  230. }
  231. if (!NCDStatement_InitReg(&R.v, C, M, A, B.v)) {
  232. goto failD0;
  233. }
  234. B.have = 0;
  235. R.have = 1;
  236. goto doneD;
  237. failD0:
  238. R.have = 0;
  239. parser_out->out_of_memory = 1;
  240. doneD:
  241. free(M);
  242. free(A);
  243. free_value(B);
  244. free(C);
  245. }
  246. statement(R) ::= IF ROUND_OPEN value(A) ROUND_CLOSE CURLY_OPEN statements(B) CURLY_CLOSE elif_maybe(I) else_maybe(E) name_maybe(C) SEMICOLON. {
  247. if (!A.have || !B.have || !I.have) {
  248. goto failE0;
  249. }
  250. NCDIf ifc;
  251. NCDIf_Init(&ifc, A.v, B.v);
  252. A.have = 0;
  253. B.have = 0;
  254. if (!NCDIfBlock_PrependIf(&I.v, ifc)) {
  255. NCDIf_Free(&ifc);
  256. goto failE0;
  257. }
  258. if (!NCDStatement_InitIf(&R.v, C, I.v)) {
  259. goto failE0;
  260. }
  261. I.have = 0;
  262. if (E.have) {
  263. NCDStatement_IfAddElse(&R.v, E.v);
  264. E.have = 0;
  265. }
  266. R.have = 1;
  267. goto doneE;
  268. failE0:
  269. R.have = 0;
  270. parser_out->out_of_memory = 1;
  271. doneE:
  272. free_value(A);
  273. free_block(B);
  274. free_ifblock(I);
  275. free_block(E);
  276. free(C);
  277. }
  278. statement(R) ::= FOREACH ROUND_OPEN value(A) AS NAME(B) ROUND_CLOSE CURLY_OPEN statements(S) CURLY_CLOSE name_maybe(N) SEMICOLON. {
  279. if (!A.have || !B.str || !S.have) {
  280. goto failEA0;
  281. }
  282. if (!NCDStatement_InitForeach(&R.v, N, A.v, B.str, NULL, S.v)) {
  283. goto failEA0;
  284. }
  285. A.have = 0;
  286. S.have = 0;
  287. R.have = 1;
  288. goto doneEA0;
  289. failEA0:
  290. R.have = 0;
  291. parser_out->out_of_memory = 1;
  292. doneEA0:
  293. free_value(A);
  294. free_token(B);
  295. free_block(S);
  296. free(N);
  297. }
  298. statement(R) ::= FOREACH ROUND_OPEN value(A) AS NAME(B) COLON NAME(C) ROUND_CLOSE CURLY_OPEN statements(S) CURLY_CLOSE name_maybe(N) SEMICOLON. {
  299. if (!A.have || !B.str || !C.str || !S.have) {
  300. goto failEB0;
  301. }
  302. if (!NCDStatement_InitForeach(&R.v, N, A.v, B.str, C.str, S.v)) {
  303. goto failEB0;
  304. }
  305. A.have = 0;
  306. S.have = 0;
  307. R.have = 1;
  308. goto doneEB0;
  309. failEB0:
  310. R.have = 0;
  311. parser_out->out_of_memory = 1;
  312. doneEB0:
  313. free_value(A);
  314. free_token(B);
  315. free_token(C);
  316. free_block(S);
  317. free(N);
  318. }
  319. elif_maybe(R) ::= . {
  320. NCDIfBlock_Init(&R.v);
  321. R.have = 1;
  322. }
  323. elif_maybe(R) ::= elif(A). {
  324. R = A;
  325. }
  326. elif(R) ::= ELIF ROUND_OPEN value(A) ROUND_CLOSE CURLY_OPEN statements(B) CURLY_CLOSE. {
  327. if (!A.have || !B.have) {
  328. goto failF0;
  329. }
  330. NCDIfBlock_Init(&R.v);
  331. NCDIf ifc;
  332. NCDIf_Init(&ifc, A.v, B.v);
  333. A.have = 0;
  334. B.have = 0;
  335. if (!NCDIfBlock_PrependIf(&R.v, ifc)) {
  336. goto failF1;
  337. }
  338. R.have = 1;
  339. goto doneF0;
  340. failF1:
  341. NCDIf_Free(&ifc);
  342. NCDIfBlock_Free(&R.v);
  343. failF0:
  344. R.have = 0;
  345. parser_out->out_of_memory = 1;
  346. doneF0:
  347. free_value(A);
  348. free_block(B);
  349. }
  350. elif(R) ::= ELIF ROUND_OPEN value(A) ROUND_CLOSE CURLY_OPEN statements(B) CURLY_CLOSE elif(N). {
  351. if (!A.have || !B.have || !N.have) {
  352. goto failG0;
  353. }
  354. NCDIf ifc;
  355. NCDIf_Init(&ifc, A.v, B.v);
  356. A.have = 0;
  357. B.have = 0;
  358. if (!NCDIfBlock_PrependIf(&N.v, ifc)) {
  359. goto failG1;
  360. }
  361. R.have = 1;
  362. R.v = N.v;
  363. N.have = 0;
  364. goto doneG0;
  365. failG1:
  366. NCDIf_Free(&ifc);
  367. failG0:
  368. R.have = 0;
  369. parser_out->out_of_memory = 1;
  370. doneG0:
  371. free_value(A);
  372. free_block(B);
  373. free_ifblock(N);
  374. }
  375. else_maybe(R) ::= . {
  376. R.have = 0;
  377. }
  378. else_maybe(R) ::= ELSE CURLY_OPEN statements(B) CURLY_CLOSE. {
  379. R = B;
  380. }
  381. statement(R) ::= BLOCK CURLY_OPEN statements(S) CURLY_CLOSE name_maybe(N) SEMICOLON. {
  382. if (!S.have) {
  383. goto failGA0;
  384. }
  385. if (!NCDStatement_InitBlock(&R.v, N, S.v)) {
  386. goto failGA0;
  387. }
  388. S.have = 0;
  389. R.have = 1;
  390. goto doneGA0;
  391. failGA0:
  392. R.have = 0;
  393. parser_out->out_of_memory = 1;
  394. doneGA0:
  395. free_block(S);
  396. free(N);
  397. }
  398. statements(R) ::= statement(A). {
  399. if (!A.have) {
  400. goto failH0;
  401. }
  402. NCDBlock_Init(&R.v);
  403. if (!NCDBlock_PrependStatement(&R.v, A.v)) {
  404. goto failH1;
  405. }
  406. A.have = 0;
  407. R.have = 1;
  408. goto doneH;
  409. failH1:
  410. NCDBlock_Free(&R.v);
  411. failH0:
  412. R.have = 0;
  413. parser_out->out_of_memory = 1;
  414. doneH:
  415. free_statement(A);
  416. }
  417. statements(R) ::= statement(A) statements(N). {
  418. if (!A.have || !N.have) {
  419. goto failI0;
  420. }
  421. if (!NCDBlock_PrependStatement(&N.v, A.v)) {
  422. goto failI1;
  423. }
  424. A.have = 0;
  425. R.have = 1;
  426. R.v = N.v;
  427. N.have = 0;
  428. goto doneI;
  429. failI1:
  430. NCDBlock_Free(&R.v);
  431. failI0:
  432. R.have = 0;
  433. parser_out->out_of_memory = 1;
  434. doneI:
  435. free_statement(A);
  436. free_block(N);
  437. }
  438. dotted_name(R) ::= NAME(A). {
  439. ASSERT(A.str)
  440. R = A.str;
  441. }
  442. dotted_name(R) ::= NAME(A) DOT dotted_name(N). {
  443. ASSERT(A.str)
  444. if (!N) {
  445. goto failJ0;
  446. }
  447. if (!(R = concat_strings(3, A.str, ".", N))) {
  448. goto failJ0;
  449. }
  450. goto doneJ;
  451. failJ0:
  452. R = NULL;
  453. parser_out->out_of_memory = 1;
  454. doneJ:
  455. free_token(A);
  456. free(N);
  457. }
  458. statement_args_maybe(R) ::= . {
  459. R.have = 1;
  460. NCDValue_InitList(&R.v);
  461. }
  462. statement_args_maybe(R) ::= list_contents(A). {
  463. R = A;
  464. }
  465. list_contents(R) ::= value(A). {
  466. if (!A.have) {
  467. goto failL0;
  468. }
  469. NCDValue_InitList(&R.v);
  470. if (!NCDValue_ListPrepend(&R.v, A.v)) {
  471. goto failL1;
  472. }
  473. A.have = 0;
  474. R.have = 1;
  475. goto doneL;
  476. failL1:
  477. NCDValue_Free(&R.v);
  478. failL0:
  479. R.have = 0;
  480. parser_out->out_of_memory = 1;
  481. doneL:
  482. free_value(A);
  483. }
  484. list_contents(R) ::= value(A) COMMA list_contents(N). {
  485. if (!A.have || !N.have) {
  486. goto failM0;
  487. }
  488. if (!NCDValue_ListPrepend(&N.v, A.v)) {
  489. goto failM0;
  490. }
  491. A.have = 0;
  492. R.have = 1;
  493. R.v = N.v;
  494. N.have = 0;
  495. goto doneM;
  496. failM0:
  497. R.have = 0;
  498. parser_out->out_of_memory = 1;
  499. doneM:
  500. free_value(A);
  501. free_value(N);
  502. }
  503. list(R) ::= CURLY_OPEN CURLY_CLOSE. {
  504. R.have = 1;
  505. NCDValue_InitList(&R.v);
  506. }
  507. list(R) ::= CURLY_OPEN list_contents(A) CURLY_CLOSE. {
  508. R = A;
  509. }
  510. map_contents(R) ::= value(A) COLON value(B). {
  511. if (!A.have || !B.have) {
  512. goto failS0;
  513. }
  514. NCDValue_InitMap(&R.v);
  515. if (!NCDValue_MapPrepend(&R.v, A.v, B.v)) {
  516. goto failS1;
  517. }
  518. A.have = 0;
  519. B.have = 0;
  520. R.have = 1;
  521. goto doneS;
  522. failS1:
  523. NCDValue_Free(&R.v);
  524. failS0:
  525. R.have = 0;
  526. parser_out->out_of_memory = 1;
  527. doneS:
  528. free_value(A);
  529. free_value(B);
  530. }
  531. map_contents(R) ::= value(A) COLON value(B) COMMA map_contents(N). {
  532. if (!A.have || !B.have || !N.have) {
  533. goto failT0;
  534. }
  535. if (!NCDValue_MapPrepend(&N.v, A.v, B.v)) {
  536. goto failT0;
  537. }
  538. A.have = 0;
  539. B.have = 0;
  540. R.have = 1;
  541. R.v = N.v;
  542. N.have = 0;
  543. goto doneT;
  544. failT0:
  545. R.have = 0;
  546. parser_out->out_of_memory = 1;
  547. doneT:
  548. free_value(A);
  549. free_value(B);
  550. free_value(N);
  551. }
  552. map(R) ::= BRACKET_OPEN BRACKET_CLOSE. {
  553. R.have = 1;
  554. NCDValue_InitMap(&R.v);
  555. }
  556. map(R) ::= BRACKET_OPEN map_contents(A) BRACKET_CLOSE. {
  557. R = A;
  558. }
  559. invoc(R) ::= value(F) ROUND_OPEN list_contents(A) ROUND_CLOSE. {
  560. if (!F.have || !A.have) {
  561. goto failQ0;
  562. }
  563. if (!NCDValue_InitInvoc(&R.v, F.v, A.v)) {
  564. goto failQ0;
  565. }
  566. F.have = 0;
  567. A.have = 0;
  568. R.have = 1;
  569. goto doneQ;
  570. failQ0:
  571. R.have = 0;
  572. parser_out->out_of_memory = 1;
  573. doneQ:
  574. free_value(F);
  575. free_value(A);
  576. }
  577. value(R) ::= STRING(A). {
  578. ASSERT(A.str)
  579. if (!NCDValue_InitStringBin(&R.v, (uint8_t *)A.str, A.len)) {
  580. goto failU0;
  581. }
  582. R.have = 1;
  583. goto doneU;
  584. failU0:
  585. R.have = 0;
  586. parser_out->out_of_memory = 1;
  587. doneU:
  588. free_token(A);
  589. }
  590. value(R) ::= AT_SIGN dotted_name(A). {
  591. if (!A) {
  592. goto failUA0;
  593. }
  594. char *at_string = concat_strings(3, "__", A, "__");
  595. if (!at_string) {
  596. goto failUA0;
  597. }
  598. int res = NCDValue_InitString(&R.v, at_string);
  599. free(at_string);
  600. if (!res) {
  601. goto failUA0;
  602. }
  603. R.have = 1;
  604. goto doneUA0;
  605. failUA0:
  606. R.have = 0;
  607. parser_out->out_of_memory = 1;
  608. doneUA0:
  609. free(A);
  610. }
  611. value(R) ::= dotted_name(A). {
  612. if (!A) {
  613. goto failV0;
  614. }
  615. if (!NCDValue_InitVar(&R.v, A)) {
  616. goto failV0;
  617. }
  618. R.have = 1;
  619. goto doneV;
  620. failV0:
  621. R.have = 0;
  622. parser_out->out_of_memory = 1;
  623. doneV:
  624. free(A);
  625. }
  626. value(R) ::= list(A). {
  627. R = A;
  628. }
  629. value(R) ::= map(A). {
  630. R = A;
  631. }
  632. value(R) ::= ROUND_OPEN value(A) ROUND_CLOSE. {
  633. R = A;
  634. }
  635. value(R) ::= invoc(A). {
  636. R = A;
  637. }
  638. name_maybe(R) ::= . {
  639. R = NULL;
  640. }
  641. name_maybe(R) ::= NAME(A). {
  642. ASSERT(A.str)
  643. R = A.str;
  644. }
  645. process_or_template(R) ::= PROCESS. {
  646. R = 0;
  647. }
  648. process_or_template(R) ::= TEMPLATE. {
  649. R = 1;
  650. }