StructParser.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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 StructParser extends lime_parser {
  14. var $qi = 0;
  15. var $i = array (
  16. 0 =>
  17. array (
  18. 'directives' => 's 1',
  19. 'directive' => 's 33',
  20. 'include' => 's 36',
  21. 'file' => 's 38',
  22. '\'start\'' => 'a \'start\'',
  23. 'structure' => 'r 1',
  24. ),
  25. 1 =>
  26. array (
  27. 'structures' => 's 2',
  28. 'structspec' => 's 3',
  29. 'structure' => 's 5',
  30. ),
  31. 2 =>
  32. array (
  33. '#' => 'r 0',
  34. ),
  35. 3 =>
  36. array (
  37. 'structspec' => 's 3',
  38. 'structures' => 's 4',
  39. 'structure' => '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. 'srpar' => 's 7',
  53. ),
  54. 7 =>
  55. array (
  56. 'string' => 's 8',
  57. ),
  58. 8 =>
  59. array (
  60. 'erpar' => 's 9',
  61. ),
  62. 9 =>
  63. array (
  64. 'spar' => 's 10',
  65. ),
  66. 10 =>
  67. array (
  68. 'entries' => 's 11',
  69. 'entry' => 's 14',
  70. 'typespec' => 's 16',
  71. 'string' => 's 23',
  72. 'size' => 's 24',
  73. 'structure' => 's 28',
  74. ),
  75. 11 =>
  76. array (
  77. 'epar' => 's 12',
  78. ),
  79. 12 =>
  80. array (
  81. 'semicolon' => 's 13',
  82. ),
  83. 13 =>
  84. array (
  85. 'structure' => 'r 6',
  86. '#' => 'r 6',
  87. ),
  88. 14 =>
  89. array (
  90. 'entry' => 's 14',
  91. 'entries' => 's 15',
  92. 'typespec' => 's 16',
  93. 'string' => 's 23',
  94. 'size' => 's 24',
  95. 'structure' => 's 28',
  96. 'epar' => 'r 7',
  97. ),
  98. 15 =>
  99. array (
  100. 'epar' => 'r 8',
  101. ),
  102. 16 =>
  103. array (
  104. 'name' => 's 17',
  105. ),
  106. 17 =>
  107. array (
  108. 'semicolon' => 's 18',
  109. 'sbracket' => 's 19',
  110. ),
  111. 18 =>
  112. array (
  113. 'string' => 'r 9',
  114. 'size' => 'r 9',
  115. 'structure' => 'r 9',
  116. 'epar' => 'r 9',
  117. ),
  118. 19 =>
  119. array (
  120. 'string' => 's 20',
  121. ),
  122. 20 =>
  123. array (
  124. 'ebracket' => 's 21',
  125. ),
  126. 21 =>
  127. array (
  128. 'semicolon' => 's 22',
  129. ),
  130. 22 =>
  131. array (
  132. 'string' => 'r 10',
  133. 'size' => 'r 10',
  134. 'structure' => 'r 10',
  135. 'epar' => 'r 10',
  136. ),
  137. 23 =>
  138. array (
  139. 'name' => 'r 11',
  140. ),
  141. 24 =>
  142. array (
  143. 'string' => 's 25',
  144. ),
  145. 25 =>
  146. array (
  147. 'align' => 's 26',
  148. ),
  149. 26 =>
  150. array (
  151. 'string' => 's 27',
  152. ),
  153. 27 =>
  154. array (
  155. 'name' => 'r 12',
  156. ),
  157. 28 =>
  158. array (
  159. 'name' => 's 29',
  160. ),
  161. 29 =>
  162. array (
  163. 'srpar' => 's 30',
  164. ),
  165. 30 =>
  166. array (
  167. 'string' => 's 31',
  168. ),
  169. 31 =>
  170. array (
  171. 'erpar' => 's 32',
  172. ),
  173. 32 =>
  174. array (
  175. 'name' => 'r 13',
  176. ),
  177. 33 =>
  178. array (
  179. 'semicolon' => 's 34',
  180. ),
  181. 34 =>
  182. array (
  183. 'directive' => 's 33',
  184. 'directives' => 's 35',
  185. 'include' => 's 36',
  186. 'structure' => 'r 1',
  187. ),
  188. 35 =>
  189. array (
  190. 'structure' => 'r 2',
  191. ),
  192. 36 =>
  193. array (
  194. 'string' => 's 37',
  195. ),
  196. 37 =>
  197. array (
  198. 'semicolon' => 'r 3',
  199. ),
  200. 38 =>
  201. array (
  202. '#' => 'r 14',
  203. ),
  204. );
  205. function reduce_0_file_1($tokens, &$result) {
  206. #
  207. # (0) file := directives structures
  208. #
  209. $result = reset($tokens);
  210. $result = array(
  211. "directives" => $tokens[0],
  212. "structures" => $tokens[1]
  213. );
  214. }
  215. function reduce_1_directives_1($tokens, &$result) {
  216. #
  217. # (1) directives :=
  218. #
  219. $result = reset($tokens);
  220. $result = array();
  221. }
  222. function reduce_2_directives_2($tokens, &$result) {
  223. #
  224. # (2) directives := directive semicolon directives
  225. #
  226. $result = reset($tokens);
  227. $result = array_merge(array($tokens[0]), $tokens[2]);
  228. }
  229. function reduce_3_directive_1($tokens, &$result) {
  230. #
  231. # (3) directive := include string
  232. #
  233. $result = reset($tokens);
  234. $result = array(
  235. "type" => "include",
  236. "file" => $tokens[1]
  237. );
  238. }
  239. function reduce_4_structures_1($tokens, &$result) {
  240. #
  241. # (4) structures := structspec
  242. #
  243. $result = reset($tokens);
  244. $result = array($tokens[0]);
  245. }
  246. function reduce_5_structures_2($tokens, &$result) {
  247. #
  248. # (5) structures := structspec structures
  249. #
  250. $result = reset($tokens);
  251. $result = array_merge(array($tokens[0]), $tokens[1]);
  252. }
  253. function reduce_6_structspec_1($tokens, &$result) {
  254. #
  255. # (6) structspec := structure name srpar string erpar spar entries epar semicolon
  256. #
  257. $result = reset($tokens);
  258. $result = array(
  259. "name" => $tokens[1],
  260. "parameters" => $tokens[3],
  261. "entries" => $tokens[6]
  262. );
  263. }
  264. function reduce_7_entries_1($tokens, &$result) {
  265. #
  266. # (7) entries := entry
  267. #
  268. $result = reset($tokens);
  269. $result = array($tokens[0]);
  270. }
  271. function reduce_8_entries_2($tokens, &$result) {
  272. #
  273. # (8) entries := entry entries
  274. #
  275. $result = reset($tokens);
  276. $result = array_merge(array($tokens[0]), $tokens[1]);
  277. }
  278. function reduce_9_entry_1($tokens, &$result) {
  279. #
  280. # (9) entry := typespec name semicolon
  281. #
  282. $result = reset($tokens);
  283. $result = array(
  284. "type" => $tokens[0],
  285. "name" => $tokens[1],
  286. "num" => "1"
  287. );
  288. }
  289. function reduce_10_entry_2($tokens, &$result) {
  290. #
  291. # (10) entry := typespec name sbracket string ebracket semicolon
  292. #
  293. $result = reset($tokens);
  294. $result = array(
  295. "type" => $tokens[0],
  296. "name" => $tokens[1],
  297. "num" => $tokens[3]
  298. );
  299. }
  300. function reduce_11_typespec_1($tokens, &$result) {
  301. #
  302. # (11) typespec := string
  303. #
  304. $result = reset($tokens);
  305. $result = array(
  306. "type" => "sizealign",
  307. "ctype" => $tokens[0],
  308. "size" => "sizeof($tokens[0])",
  309. "align" => "__alignof__($tokens[0])"
  310. );
  311. }
  312. function reduce_12_typespec_2($tokens, &$result) {
  313. #
  314. # (12) typespec := size string align string
  315. #
  316. $result = reset($tokens);
  317. $result = array(
  318. "type" => "sizealign",
  319. "ctype" => "void",
  320. "size" => $tokens[1],
  321. "align" => $tokens[3]
  322. );
  323. }
  324. function reduce_13_typespec_3($tokens, &$result) {
  325. #
  326. # (13) typespec := structure name srpar string erpar
  327. #
  328. $result = reset($tokens);
  329. $result = array(
  330. "type" => "structure",
  331. "ctype" => $tokens[1],
  332. "name" => $tokens[1],
  333. "parameters" => $tokens[3]
  334. );
  335. }
  336. function reduce_14_start_1($tokens, &$result) {
  337. #
  338. # (14) 'start' := file
  339. #
  340. $result = reset($tokens);
  341. }
  342. var $method = array (
  343. 0 => 'reduce_0_file_1',
  344. 1 => 'reduce_1_directives_1',
  345. 2 => 'reduce_2_directives_2',
  346. 3 => 'reduce_3_directive_1',
  347. 4 => 'reduce_4_structures_1',
  348. 5 => 'reduce_5_structures_2',
  349. 6 => 'reduce_6_structspec_1',
  350. 7 => 'reduce_7_entries_1',
  351. 8 => 'reduce_8_entries_2',
  352. 9 => 'reduce_9_entry_1',
  353. 10 => 'reduce_10_entry_2',
  354. 11 => 'reduce_11_typespec_1',
  355. 12 => 'reduce_12_typespec_2',
  356. 13 => 'reduce_13_typespec_3',
  357. 14 => 'reduce_14_start_1',
  358. );
  359. var $a = array (
  360. 0 =>
  361. array (
  362. 'symbol' => 'file',
  363. 'len' => 2,
  364. 'replace' => true,
  365. ),
  366. 1 =>
  367. array (
  368. 'symbol' => 'directives',
  369. 'len' => 0,
  370. 'replace' => true,
  371. ),
  372. 2 =>
  373. array (
  374. 'symbol' => 'directives',
  375. 'len' => 3,
  376. 'replace' => true,
  377. ),
  378. 3 =>
  379. array (
  380. 'symbol' => 'directive',
  381. 'len' => 2,
  382. 'replace' => true,
  383. ),
  384. 4 =>
  385. array (
  386. 'symbol' => 'structures',
  387. 'len' => 1,
  388. 'replace' => true,
  389. ),
  390. 5 =>
  391. array (
  392. 'symbol' => 'structures',
  393. 'len' => 2,
  394. 'replace' => true,
  395. ),
  396. 6 =>
  397. array (
  398. 'symbol' => 'structspec',
  399. 'len' => 9,
  400. 'replace' => true,
  401. ),
  402. 7 =>
  403. array (
  404. 'symbol' => 'entries',
  405. 'len' => 1,
  406. 'replace' => true,
  407. ),
  408. 8 =>
  409. array (
  410. 'symbol' => 'entries',
  411. 'len' => 2,
  412. 'replace' => true,
  413. ),
  414. 9 =>
  415. array (
  416. 'symbol' => 'entry',
  417. 'len' => 3,
  418. 'replace' => true,
  419. ),
  420. 10 =>
  421. array (
  422. 'symbol' => 'entry',
  423. 'len' => 6,
  424. 'replace' => true,
  425. ),
  426. 11 =>
  427. array (
  428. 'symbol' => 'typespec',
  429. 'len' => 1,
  430. 'replace' => true,
  431. ),
  432. 12 =>
  433. array (
  434. 'symbol' => 'typespec',
  435. 'len' => 4,
  436. 'replace' => true,
  437. ),
  438. 13 =>
  439. array (
  440. 'symbol' => 'typespec',
  441. 'len' => 5,
  442. 'replace' => true,
  443. ),
  444. 14 =>
  445. array (
  446. 'symbol' => '\'start\'',
  447. 'len' => 1,
  448. 'replace' => true,
  449. ),
  450. );
  451. }