ProtoParser.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <?php
  2. /*
  3. DON'T EDIT THIS FILE!
  4. This file was automatically generated by the Lime parser generator.
  5. The real source code you should be looking at is in one or more
  6. grammar files in the Lime format.
  7. THE ONLY REASON TO LOOK AT THIS FILE is to see where in the grammar
  8. file that your error happened, because there are enough comments to
  9. help you debug your grammar.
  10. If you ignore this warning, you're shooting yourself in the brain,
  11. not the foot.
  12. */
  13. class ProtoParser extends lime_parser {
  14. var $qi = 0;
  15. var $i = array (
  16. 0 =>
  17. array (
  18. 'directives' => 's 1',
  19. 'directive' => 's 30',
  20. 'include' => 's 33',
  21. 'file' => 's 35',
  22. '\'start\'' => 'a \'start\'',
  23. 'message' => 'r 1',
  24. ),
  25. 1 =>
  26. array (
  27. 'messages' => 's 2',
  28. 'msgspec' => 's 3',
  29. 'message' => 's 5',
  30. ),
  31. 2 =>
  32. array (
  33. '#' => 'r 0',
  34. ),
  35. 3 =>
  36. array (
  37. 'msgspec' => 's 3',
  38. 'messages' => 's 4',
  39. 'message' => 's 5',
  40. '#' => 'r 4',
  41. ),
  42. 4 =>
  43. array (
  44. '#' => 'r 5',
  45. ),
  46. 5 =>
  47. array (
  48. 'name' => 's 6',
  49. ),
  50. 6 =>
  51. array (
  52. 'spar' => 's 7',
  53. ),
  54. 7 =>
  55. array (
  56. 'entries' => 's 8',
  57. 'entry' => 's 11',
  58. 'cardinality' => 's 13',
  59. 'repeated' => 's 26',
  60. 'optional' => 's 27',
  61. 'required' => 's 28',
  62. ),
  63. 8 =>
  64. array (
  65. 'epar' => 's 9',
  66. ),
  67. 9 =>
  68. array (
  69. 'semicolon' => 's 10',
  70. ),
  71. 10 =>
  72. array (
  73. 'message' => 'r 6',
  74. '#' => 'r 6',
  75. ),
  76. 11 =>
  77. array (
  78. 'entry' => 's 11',
  79. 'entries' => 's 12',
  80. 'cardinality' => 's 13',
  81. 'repeated' => 's 26',
  82. 'optional' => 's 27',
  83. 'required' => 's 28',
  84. 'epar' => 'r 7',
  85. ),
  86. 12 =>
  87. array (
  88. 'epar' => 'r 8',
  89. ),
  90. 13 =>
  91. array (
  92. 'type' => 's 14',
  93. 'uint' => 's 19',
  94. 'data' => 's 20',
  95. 'message' => 's 24',
  96. ),
  97. 14 =>
  98. array (
  99. 'name' => 's 15',
  100. ),
  101. 15 =>
  102. array (
  103. 'equals' => 's 16',
  104. ),
  105. 16 =>
  106. array (
  107. 'number' => 's 17',
  108. ),
  109. 17 =>
  110. array (
  111. 'semicolon' => 's 18',
  112. ),
  113. 18 =>
  114. array (
  115. 'repeated' => 'r 9',
  116. 'optional' => 'r 9',
  117. 'required' => 'r 9',
  118. 'epar' => 'r 9',
  119. ),
  120. 19 =>
  121. array (
  122. 'name' => 'r 14',
  123. ),
  124. 20 =>
  125. array (
  126. 'srpar' => 's 21',
  127. 'name' => 'r 15',
  128. ),
  129. 21 =>
  130. array (
  131. 'string' => 's 22',
  132. ),
  133. 22 =>
  134. array (
  135. 'erpar' => 's 23',
  136. ),
  137. 23 =>
  138. array (
  139. 'name' => 'r 16',
  140. ),
  141. 24 =>
  142. array (
  143. 'name' => 's 25',
  144. ),
  145. 25 =>
  146. array (
  147. 'name' => 'r 17',
  148. ),
  149. 26 =>
  150. array (
  151. 'uint' => 'r 10',
  152. 'data' => 'r 10',
  153. 'message' => 'r 10',
  154. ),
  155. 27 =>
  156. array (
  157. 'uint' => 'r 11',
  158. 'data' => 'r 11',
  159. 'message' => 'r 11',
  160. ),
  161. 28 =>
  162. array (
  163. 'repeated' => 's 29',
  164. 'uint' => 'r 12',
  165. 'data' => 'r 12',
  166. 'message' => 'r 12',
  167. ),
  168. 29 =>
  169. array (
  170. 'uint' => 'r 13',
  171. 'data' => 'r 13',
  172. 'message' => 'r 13',
  173. ),
  174. 30 =>
  175. array (
  176. 'semicolon' => 's 31',
  177. ),
  178. 31 =>
  179. array (
  180. 'directive' => 's 30',
  181. 'directives' => 's 32',
  182. 'include' => 's 33',
  183. 'message' => 'r 1',
  184. ),
  185. 32 =>
  186. array (
  187. 'message' => 'r 2',
  188. ),
  189. 33 =>
  190. array (
  191. 'string' => 's 34',
  192. ),
  193. 34 =>
  194. array (
  195. 'semicolon' => 'r 3',
  196. ),
  197. 35 =>
  198. array (
  199. '#' => 'r 18',
  200. ),
  201. );
  202. function reduce_0_file_1($tokens, &$result) {
  203. #
  204. # (0) file := directives messages
  205. #
  206. $result = reset($tokens);
  207. $result = array(
  208. "directives" => $tokens[0],
  209. "messages" => $tokens[1]
  210. );
  211. }
  212. function reduce_1_directives_1($tokens, &$result) {
  213. #
  214. # (1) directives :=
  215. #
  216. $result = reset($tokens);
  217. $result = array();
  218. }
  219. function reduce_2_directives_2($tokens, &$result) {
  220. #
  221. # (2) directives := directive semicolon directives
  222. #
  223. $result = reset($tokens);
  224. $result = array_merge(array($tokens[0]), $tokens[2]);
  225. }
  226. function reduce_3_directive_1($tokens, &$result) {
  227. #
  228. # (3) directive := include string
  229. #
  230. $result = reset($tokens);
  231. $result = array(
  232. "type" => "include",
  233. "file" => $tokens[1]
  234. );
  235. }
  236. function reduce_4_messages_1($tokens, &$result) {
  237. #
  238. # (4) messages := msgspec
  239. #
  240. $result = reset($tokens);
  241. $result = array($tokens[0]);
  242. }
  243. function reduce_5_messages_2($tokens, &$result) {
  244. #
  245. # (5) messages := msgspec messages
  246. #
  247. $result = reset($tokens);
  248. $result = array_merge(array($tokens[0]), $tokens[1]);
  249. }
  250. function reduce_6_msgspec_1($tokens, &$result) {
  251. #
  252. # (6) msgspec := message name spar entries epar semicolon
  253. #
  254. $result = reset($tokens);
  255. $result = array(
  256. "name" => $tokens[1],
  257. "entries" => $tokens[3]
  258. );
  259. }
  260. function reduce_7_entries_1($tokens, &$result) {
  261. #
  262. # (7) entries := entry
  263. #
  264. $result = reset($tokens);
  265. $result = array($tokens[0]);
  266. }
  267. function reduce_8_entries_2($tokens, &$result) {
  268. #
  269. # (8) entries := entry entries
  270. #
  271. $result = reset($tokens);
  272. $result = array_merge(array($tokens[0]), $tokens[1]);
  273. }
  274. function reduce_9_entry_1($tokens, &$result) {
  275. #
  276. # (9) entry := cardinality type name equals number semicolon
  277. #
  278. $result = reset($tokens);
  279. $result = array(
  280. "cardinality" => $tokens[0],
  281. "type" => $tokens[1],
  282. "name" => $tokens[2],
  283. "id" => $tokens[4]
  284. );
  285. }
  286. function reduce_10_cardinality_1($tokens, &$result) {
  287. #
  288. # (10) cardinality := repeated
  289. #
  290. $result = reset($tokens);
  291. $result = "repeated";
  292. }
  293. function reduce_11_cardinality_2($tokens, &$result) {
  294. #
  295. # (11) cardinality := optional
  296. #
  297. $result = reset($tokens);
  298. $result = "optional";
  299. }
  300. function reduce_12_cardinality_3($tokens, &$result) {
  301. #
  302. # (12) cardinality := required
  303. #
  304. $result = reset($tokens);
  305. $result = "required";
  306. }
  307. function reduce_13_cardinality_4($tokens, &$result) {
  308. #
  309. # (13) cardinality := required repeated
  310. #
  311. $result = reset($tokens);
  312. $result = "required repeated";
  313. }
  314. function reduce_14_type_1($tokens, &$result) {
  315. #
  316. # (14) type := uint
  317. #
  318. $result = reset($tokens);
  319. $result = array(
  320. "type" => "uint",
  321. "size" => $tokens[0]
  322. );
  323. }
  324. function reduce_15_type_2($tokens, &$result) {
  325. #
  326. # (15) type := data
  327. #
  328. $result = reset($tokens);
  329. $result = array(
  330. "type" => "data"
  331. );
  332. }
  333. function reduce_16_type_3($tokens, &$result) {
  334. #
  335. # (16) type := data srpar string erpar
  336. #
  337. $result = reset($tokens);
  338. $result = array(
  339. "type" => "constdata",
  340. "size" => $tokens[2]
  341. );
  342. }
  343. function reduce_17_type_4($tokens, &$result) {
  344. #
  345. # (17) type := message name
  346. #
  347. $result = reset($tokens);
  348. $result = array(
  349. "type" => "message",
  350. "message" => $tokens[1]
  351. );
  352. }
  353. function reduce_18_start_1($tokens, &$result) {
  354. #
  355. # (18) 'start' := file
  356. #
  357. $result = reset($tokens);
  358. }
  359. var $method = array (
  360. 0 => 'reduce_0_file_1',
  361. 1 => 'reduce_1_directives_1',
  362. 2 => 'reduce_2_directives_2',
  363. 3 => 'reduce_3_directive_1',
  364. 4 => 'reduce_4_messages_1',
  365. 5 => 'reduce_5_messages_2',
  366. 6 => 'reduce_6_msgspec_1',
  367. 7 => 'reduce_7_entries_1',
  368. 8 => 'reduce_8_entries_2',
  369. 9 => 'reduce_9_entry_1',
  370. 10 => 'reduce_10_cardinality_1',
  371. 11 => 'reduce_11_cardinality_2',
  372. 12 => 'reduce_12_cardinality_3',
  373. 13 => 'reduce_13_cardinality_4',
  374. 14 => 'reduce_14_type_1',
  375. 15 => 'reduce_15_type_2',
  376. 16 => 'reduce_16_type_3',
  377. 17 => 'reduce_17_type_4',
  378. 18 => 'reduce_18_start_1',
  379. );
  380. var $a = array (
  381. 0 =>
  382. array (
  383. 'symbol' => 'file',
  384. 'len' => 2,
  385. 'replace' => true,
  386. ),
  387. 1 =>
  388. array (
  389. 'symbol' => 'directives',
  390. 'len' => 0,
  391. 'replace' => true,
  392. ),
  393. 2 =>
  394. array (
  395. 'symbol' => 'directives',
  396. 'len' => 3,
  397. 'replace' => true,
  398. ),
  399. 3 =>
  400. array (
  401. 'symbol' => 'directive',
  402. 'len' => 2,
  403. 'replace' => true,
  404. ),
  405. 4 =>
  406. array (
  407. 'symbol' => 'messages',
  408. 'len' => 1,
  409. 'replace' => true,
  410. ),
  411. 5 =>
  412. array (
  413. 'symbol' => 'messages',
  414. 'len' => 2,
  415. 'replace' => true,
  416. ),
  417. 6 =>
  418. array (
  419. 'symbol' => 'msgspec',
  420. 'len' => 6,
  421. 'replace' => true,
  422. ),
  423. 7 =>
  424. array (
  425. 'symbol' => 'entries',
  426. 'len' => 1,
  427. 'replace' => true,
  428. ),
  429. 8 =>
  430. array (
  431. 'symbol' => 'entries',
  432. 'len' => 2,
  433. 'replace' => true,
  434. ),
  435. 9 =>
  436. array (
  437. 'symbol' => 'entry',
  438. 'len' => 6,
  439. 'replace' => true,
  440. ),
  441. 10 =>
  442. array (
  443. 'symbol' => 'cardinality',
  444. 'len' => 1,
  445. 'replace' => true,
  446. ),
  447. 11 =>
  448. array (
  449. 'symbol' => 'cardinality',
  450. 'len' => 1,
  451. 'replace' => true,
  452. ),
  453. 12 =>
  454. array (
  455. 'symbol' => 'cardinality',
  456. 'len' => 1,
  457. 'replace' => true,
  458. ),
  459. 13 =>
  460. array (
  461. 'symbol' => 'cardinality',
  462. 'len' => 2,
  463. 'replace' => true,
  464. ),
  465. 14 =>
  466. array (
  467. 'symbol' => 'type',
  468. 'len' => 1,
  469. 'replace' => true,
  470. ),
  471. 15 =>
  472. array (
  473. 'symbol' => 'type',
  474. 'len' => 1,
  475. 'replace' => true,
  476. ),
  477. 16 =>
  478. array (
  479. 'symbol' => 'type',
  480. 'len' => 4,
  481. 'replace' => true,
  482. ),
  483. 17 =>
  484. array (
  485. 'symbol' => 'type',
  486. 'len' => 2,
  487. 'replace' => true,
  488. ),
  489. 18 =>
  490. array (
  491. 'symbol' => '\'start\'',
  492. 'len' => 1,
  493. 'replace' => true,
  494. ),
  495. );
  496. }