c99x-act.scm 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  1. ;; c99x-act.scm
  2. ;; Copyright (C) 2016-2018 Matthew R. Wette
  3. ;;
  4. ;; This library is free software; you can redistribute it and/or
  5. ;; modify it under the terms of the GNU Lesser General Public
  6. ;; License as published by the Free Software Foundation; either
  7. ;; version 3 of the License, or (at your option) any later version.
  8. ;; See the file COPYING included with the this distribution.
  9. (define c99x-act-v
  10. (vector
  11. ;; $start => expression
  12. (lambda ($1 . $rest) $1)
  13. ;; primary-expression => identifier
  14. (lambda ($1 . $rest) `(p-expr ,$1))
  15. ;; primary-expression => constant
  16. (lambda ($1 . $rest) `(p-expr ,$1))
  17. ;; primary-expression => string-literal
  18. (lambda ($1 . $rest) `(p-expr ,$1))
  19. ;; primary-expression => "(" expression ")"
  20. (lambda ($3 $2 $1 . $rest) $2)
  21. ;; primary-expression => "(" "{" $P1 block-item-list $P2 "}" ")"
  22. (lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
  23. `(stmt-expr (@ (extension "GNUC")) ,$4))
  24. ;; $P1 =>
  25. (lambda ($2 $1 . $rest) (cpi-push))
  26. ;; $P2 =>
  27. (lambda ($4 $3 $2 $1 . $rest) (cpi-pop))
  28. ;; postfix-expression => primary-expression
  29. (lambda ($1 . $rest) $1)
  30. ;; postfix-expression => postfix-expression "[" expression "]"
  31. (lambda ($4 $3 $2 $1 . $rest)
  32. `(array-ref ,$3 ,$1))
  33. ;; postfix-expression => postfix-expression "(" argument-expression-list...
  34. (lambda ($4 $3 $2 $1 . $rest)
  35. `(fctn-call ,$1 ,(tl->list $3)))
  36. ;; postfix-expression => postfix-expression "(" ")"
  37. (lambda ($3 $2 $1 . $rest)
  38. `(fctn-call ,$1 (expr-list)))
  39. ;; postfix-expression => postfix-expression "." identifier
  40. (lambda ($3 $2 $1 . $rest) `(d-sel ,$3 ,$1))
  41. ;; postfix-expression => postfix-expression "->" identifier
  42. (lambda ($3 $2 $1 . $rest) `(i-sel ,$3 ,$1))
  43. ;; postfix-expression => postfix-expression "++"
  44. (lambda ($2 $1 . $rest) `(post-inc ,$1))
  45. ;; postfix-expression => postfix-expression "--"
  46. (lambda ($2 $1 . $rest) `(post-dec ,$1))
  47. ;; postfix-expression => "(" type-name ")" "{" initializer-list "}"
  48. (lambda ($6 $5 $4 $3 $2 $1 . $rest)
  49. `(comp-lit ,$2 ,(tl->list $5)))
  50. ;; postfix-expression => "(" type-name ")" "{" initializer-list "," "}"
  51. (lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
  52. `(comp-lit ,$2 ,(tl->list $5)))
  53. ;; argument-expression-list => assignment-expression
  54. (lambda ($1 . $rest) (make-tl 'expr-list $1))
  55. ;; argument-expression-list => argument-expression-list "," assignment-e...
  56. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  57. ;; argument-expression-list => arg-expr-hack
  58. (lambda ($1 . $rest) (make-tl 'expr-list $1))
  59. ;; argument-expression-list => argument-expression-list "," arg-expr-hack
  60. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  61. ;; arg-expr-hack => declaration-specifiers abstract-declarator
  62. (lambda ($2 $1 . $rest)
  63. `(param-decl ,(tl->list $1) $2))
  64. ;; arg-expr-hack => declaration-specifiers
  65. (lambda ($1 . $rest)
  66. `(param-decl ,(tl->list $1)))
  67. ;; unary-expression => postfix-expression
  68. (lambda ($1 . $rest) $1)
  69. ;; unary-expression => "++" unary-expression
  70. (lambda ($2 $1 . $rest) `(pre-inc ,$2))
  71. ;; unary-expression => "--" unary-expression
  72. (lambda ($2 $1 . $rest) `(pre-dec ,$2))
  73. ;; unary-expression => unary-operator cast-expression
  74. (lambda ($2 $1 . $rest) (list $1 $2))
  75. ;; unary-expression => "sizeof" unary-expression
  76. (lambda ($2 $1 . $rest) `(sizeof-expr ,$2))
  77. ;; unary-expression => "sizeof" "(" type-name ")"
  78. (lambda ($4 $3 $2 $1 . $rest) `(sizeof-type ,$3))
  79. ;; unary-operator => "&"
  80. (lambda ($1 . $rest) 'ref-to)
  81. ;; unary-operator => "*"
  82. (lambda ($1 . $rest) 'de-ref)
  83. ;; unary-operator => "+"
  84. (lambda ($1 . $rest) 'pos)
  85. ;; unary-operator => "-"
  86. (lambda ($1 . $rest) 'neg)
  87. ;; unary-operator => "~"
  88. (lambda ($1 . $rest) 'bitwise-not)
  89. ;; unary-operator => "!"
  90. (lambda ($1 . $rest) 'not)
  91. ;; cast-expression => unary-expression
  92. (lambda ($1 . $rest) $1)
  93. ;; cast-expression => "(" type-name ")" cast-expression
  94. (lambda ($4 $3 $2 $1 . $rest) `(cast ,$2 ,$4))
  95. ;; multiplicative-expression => cast-expression
  96. (lambda ($1 . $rest) $1)
  97. ;; multiplicative-expression => multiplicative-expression "*" cast-expre...
  98. (lambda ($3 $2 $1 . $rest) `(mul ,$1 ,$3))
  99. ;; multiplicative-expression => multiplicative-expression "/" cast-expre...
  100. (lambda ($3 $2 $1 . $rest) `(div ,$1 ,$3))
  101. ;; multiplicative-expression => multiplicative-expression "%" cast-expre...
  102. (lambda ($3 $2 $1 . $rest) `(mod ,$1 ,$3))
  103. ;; additive-expression => multiplicative-expression
  104. (lambda ($1 . $rest) $1)
  105. ;; additive-expression => additive-expression "+" multiplicative-expression
  106. (lambda ($3 $2 $1 . $rest) `(add ,$1 ,$3))
  107. ;; additive-expression => additive-expression "-" multiplicative-expression
  108. (lambda ($3 $2 $1 . $rest) `(sub ,$1 ,$3))
  109. ;; shift-expression => additive-expression
  110. (lambda ($1 . $rest) $1)
  111. ;; shift-expression => shift-expression "<<" additive-expression
  112. (lambda ($3 $2 $1 . $rest) `(lshift ,$1 ,$3))
  113. ;; shift-expression => shift-expression ">>" additive-expression
  114. (lambda ($3 $2 $1 . $rest) `(rshift ,$1 ,$3))
  115. ;; relational-expression => shift-expression
  116. (lambda ($1 . $rest) $1)
  117. ;; relational-expression => relational-expression "<" shift-expression
  118. (lambda ($3 $2 $1 . $rest) `(lt ,$1 ,$3))
  119. ;; relational-expression => relational-expression ">" shift-expression
  120. (lambda ($3 $2 $1 . $rest) `(gt ,$1 ,$3))
  121. ;; relational-expression => relational-expression "<=" shift-expression
  122. (lambda ($3 $2 $1 . $rest) `(le ,$1 ,$3))
  123. ;; relational-expression => relational-expression ">=" shift-expression
  124. (lambda ($3 $2 $1 . $rest) `(ge ,$1 ,$3))
  125. ;; equality-expression => relational-expression
  126. (lambda ($1 . $rest) $1)
  127. ;; equality-expression => equality-expression "==" relational-expression
  128. (lambda ($3 $2 $1 . $rest) `(eq ,$1 ,$3))
  129. ;; equality-expression => equality-expression "!=" relational-expression
  130. (lambda ($3 $2 $1 . $rest) `(ne ,$1 ,$3))
  131. ;; bitwise-and-expression => equality-expression
  132. (lambda ($1 . $rest) $1)
  133. ;; bitwise-and-expression => bitwise-and-expression "&" equality-expression
  134. (lambda ($3 $2 $1 . $rest)
  135. `(bitwise-and ,$1 ,$3))
  136. ;; bitwise-xor-expression => bitwise-and-expression
  137. (lambda ($1 . $rest) $1)
  138. ;; bitwise-xor-expression => bitwise-xor-expression "^" bitwise-and-expr...
  139. (lambda ($3 $2 $1 . $rest)
  140. `(bitwise-xor ,$1 ,$3))
  141. ;; bitwise-or-expression => bitwise-xor-expression
  142. (lambda ($1 . $rest) $1)
  143. ;; bitwise-or-expression => bitwise-or-expression "|" bitwise-xor-expres...
  144. (lambda ($3 $2 $1 . $rest) `(bitwise-or ,$1 ,$3))
  145. ;; logical-and-expression => bitwise-or-expression
  146. (lambda ($1 . $rest) $1)
  147. ;; logical-and-expression => logical-and-expression "&&" bitwise-or-expr...
  148. (lambda ($3 $2 $1 . $rest) `(and ,$1 ,$3))
  149. ;; logical-or-expression => logical-and-expression
  150. (lambda ($1 . $rest) $1)
  151. ;; logical-or-expression => logical-or-expression "||" logical-and-expre...
  152. (lambda ($3 $2 $1 . $rest) `(or ,$1 ,$3))
  153. ;; conditional-expression => logical-or-expression
  154. (lambda ($1 . $rest) $1)
  155. ;; conditional-expression => logical-or-expression "?" expression ":" co...
  156. (lambda ($5 $4 $3 $2 $1 . $rest)
  157. `(cond-expr ,$1 ,$3 ,$5))
  158. ;; assignment-expression => conditional-expression
  159. (lambda ($1 . $rest) $1)
  160. ;; assignment-expression => unary-expression assignment-operator assignm...
  161. (lambda ($3 $2 $1 . $rest)
  162. `(assn-expr ,$1 (op ,$2) ,$3))
  163. ;; assignment-operator => "="
  164. (lambda ($1 . $rest) $1)
  165. ;; assignment-operator => "+="
  166. (lambda ($1 . $rest) $1)
  167. ;; assignment-operator => "-="
  168. (lambda ($1 . $rest) $1)
  169. ;; assignment-operator => "*="
  170. (lambda ($1 . $rest) $1)
  171. ;; assignment-operator => "/="
  172. (lambda ($1 . $rest) $1)
  173. ;; assignment-operator => "%="
  174. (lambda ($1 . $rest) $1)
  175. ;; assignment-operator => "<<="
  176. (lambda ($1 . $rest) $1)
  177. ;; assignment-operator => ">>="
  178. (lambda ($1 . $rest) $1)
  179. ;; assignment-operator => "&="
  180. (lambda ($1 . $rest) $1)
  181. ;; assignment-operator => "^="
  182. (lambda ($1 . $rest) $1)
  183. ;; assignment-operator => "|="
  184. (lambda ($1 . $rest) $1)
  185. ;; expression => assignment-expression
  186. (lambda ($1 . $rest) $1)
  187. ;; expression => expression "," assignment-expression
  188. (lambda ($3 $2 $1 . $rest)
  189. (if (eqv? 'comma-expr (sx-tag $1))
  190. (append $1 (list $3))
  191. `(comma-expr ,$1 ,$3)))
  192. ;; constant-expression => conditional-expression
  193. (lambda ($1 . $rest) $1)
  194. ;; declaration => declaration-no-comment ";"
  195. (lambda ($2 $1 . $rest) $1)
  196. ;; declaration => declaration-no-comment ";" code-comment
  197. (lambda ($3 $2 $1 . $rest) (sx-attr-add $1 $3))
  198. ;; declaration-no-comment => declaration-specifiers init-declarator-list
  199. (lambda ($2 $1 . $rest)
  200. (save-typenames `(decl ,$1 ,$2)))
  201. ;; declaration-no-comment => declaration-specifiers
  202. (lambda ($1 . $rest) `(decl ,$1))
  203. ;; declaration-specifiers => declaration-specifiers-1
  204. (lambda ($1 . $rest)
  205. (process-specs (tl->list $1)))
  206. ;; declaration-specifiers-1 => storage-class-specifier
  207. (lambda ($1 . $rest)
  208. (make-tl 'decl-spec-list $1))
  209. ;; declaration-specifiers-1 => storage-class-specifier declaration-speci...
  210. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  211. ;; declaration-specifiers-1 => type-specifier
  212. (lambda ($1 . $rest)
  213. (make-tl 'decl-spec-list $1))
  214. ;; declaration-specifiers-1 => type-specifier declaration-specifiers-1
  215. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  216. ;; declaration-specifiers-1 => type-qualifier
  217. (lambda ($1 . $rest)
  218. (make-tl 'decl-spec-list $1))
  219. ;; declaration-specifiers-1 => type-qualifier declaration-specifiers-1
  220. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  221. ;; declaration-specifiers-1 => function-specifier
  222. (lambda ($1 . $rest)
  223. (make-tl 'decl-spec-list $1))
  224. ;; declaration-specifiers-1 => function-specifier declaration-specifiers-1
  225. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  226. ;; declaration-specifiers-1 => attribute-specifier
  227. (lambda ($1 . $rest)
  228. (make-tl 'decl-spec-list $1))
  229. ;; declaration-specifiers-1 => attribute-specifier declaration-specifiers-1
  230. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  231. ;; storage-class-specifier => "auto"
  232. (lambda ($1 . $rest) '(stor-spec (auto)))
  233. ;; storage-class-specifier => "extern"
  234. (lambda ($1 . $rest) '(stor-spec (extern)))
  235. ;; storage-class-specifier => "register"
  236. (lambda ($1 . $rest) '(stor-spec (register)))
  237. ;; storage-class-specifier => "static"
  238. (lambda ($1 . $rest) '(stor-spec (static)))
  239. ;; storage-class-specifier => "typedef"
  240. (lambda ($1 . $rest) '(stor-spec (typedef)))
  241. ;; type-specifier => "void"
  242. (lambda ($1 . $rest) '(type-spec (void)))
  243. ;; type-specifier => fixed-type-specifier
  244. (lambda ($1 . $rest) `(type-spec ,$1))
  245. ;; type-specifier => float-type-specifier
  246. (lambda ($1 . $rest) `(type-spec ,$1))
  247. ;; type-specifier => fixpt-type-specifier
  248. (lambda ($1 . $rest) `(type-spec ,$1))
  249. ;; type-specifier => "_Bool"
  250. (lambda ($1 . $rest)
  251. '(type-spec (fixed-type "_Bool")))
  252. ;; type-specifier => complex-type-specifier
  253. (lambda ($1 . $rest) `(type-spec ,$1))
  254. ;; type-specifier => struct-or-union-specifier
  255. (lambda ($1 . $rest) `(type-spec ,$1))
  256. ;; type-specifier => enum-specifier
  257. (lambda ($1 . $rest) `(type-spec ,$1))
  258. ;; type-specifier => typedef-name
  259. (lambda ($1 . $rest) `(type-spec ,$1))
  260. ;; fixed-type-specifier => "short"
  261. (lambda ($1 . $rest) '(fixed-type "short"))
  262. ;; fixed-type-specifier => "short" "int"
  263. (lambda ($2 $1 . $rest)
  264. '(fixed-type "short int"))
  265. ;; fixed-type-specifier => "signed" "short"
  266. (lambda ($2 $1 . $rest)
  267. '(fixed-type "signed short"))
  268. ;; fixed-type-specifier => "signed" "short" "int"
  269. (lambda ($3 $2 $1 . $rest)
  270. '(fixed-type "signed short int"))
  271. ;; fixed-type-specifier => "int"
  272. (lambda ($1 . $rest) '(fixed-type "int"))
  273. ;; fixed-type-specifier => "signed"
  274. (lambda ($1 . $rest) '(fixed-type "signed"))
  275. ;; fixed-type-specifier => "signed" "int"
  276. (lambda ($2 $1 . $rest)
  277. '(fixed-type "signed int"))
  278. ;; fixed-type-specifier => "long"
  279. (lambda ($1 . $rest) '(fixed-type "long"))
  280. ;; fixed-type-specifier => "long" "int"
  281. (lambda ($2 $1 . $rest) '(fixed-type "long int"))
  282. ;; fixed-type-specifier => "signed" "long"
  283. (lambda ($2 $1 . $rest)
  284. '(fixed-type "signed long"))
  285. ;; fixed-type-specifier => "signed" "long" "int"
  286. (lambda ($3 $2 $1 . $rest)
  287. '(fixed-type "signed long int"))
  288. ;; fixed-type-specifier => "long" "long"
  289. (lambda ($2 $1 . $rest)
  290. '(fixed-type "long long"))
  291. ;; fixed-type-specifier => "long" "long" "int"
  292. (lambda ($3 $2 $1 . $rest)
  293. '(fixed-type "long long int"))
  294. ;; fixed-type-specifier => "signed" "long" "long"
  295. (lambda ($3 $2 $1 . $rest)
  296. '(fixed-type "signed long long"))
  297. ;; fixed-type-specifier => "signed" "long" "long" "int"
  298. (lambda ($4 $3 $2 $1 . $rest)
  299. '(fixed-type "signed long long int"))
  300. ;; fixed-type-specifier => "unsigned" "short" "int"
  301. (lambda ($3 $2 $1 . $rest)
  302. '(fixed-type "unsigned short int"))
  303. ;; fixed-type-specifier => "unsigned" "short"
  304. (lambda ($2 $1 . $rest)
  305. '(fixed-type "unsigned short"))
  306. ;; fixed-type-specifier => "unsigned" "int"
  307. (lambda ($2 $1 . $rest)
  308. '(fixed-type "unsigned int"))
  309. ;; fixed-type-specifier => "unsigned"
  310. (lambda ($1 . $rest) '(fixed-type "unsigned"))
  311. ;; fixed-type-specifier => "unsigned" "long" "int"
  312. (lambda ($3 $2 $1 . $rest)
  313. '(fixed-type "unsigned long"))
  314. ;; fixed-type-specifier => "unsigned" "long"
  315. (lambda ($2 $1 . $rest)
  316. '(fixed-type "unsigned long"))
  317. ;; fixed-type-specifier => "unsigned" "long" "long" "int"
  318. (lambda ($4 $3 $2 $1 . $rest)
  319. '(fixed-type "unsigned long long int"))
  320. ;; fixed-type-specifier => "unsigned" "long" "long"
  321. (lambda ($3 $2 $1 . $rest)
  322. '(fixed-type "unsigned long long"))
  323. ;; fixed-type-specifier => "char"
  324. (lambda ($1 . $rest) '(fixed-type "char"))
  325. ;; fixed-type-specifier => "signed" "char"
  326. (lambda ($2 $1 . $rest)
  327. '(fixed-type "signed char"))
  328. ;; fixed-type-specifier => "unsigned" "char"
  329. (lambda ($2 $1 . $rest)
  330. '(fixed-type "unsigned char"))
  331. ;; float-type-specifier => "float"
  332. (lambda ($1 . $rest) '(float-type "float"))
  333. ;; float-type-specifier => "double"
  334. (lambda ($1 . $rest) '(float-type "double"))
  335. ;; float-type-specifier => "long" "double"
  336. (lambda ($2 $1 . $rest)
  337. '(float-type "long double"))
  338. ;; complex-type-specifier => "_Complex"
  339. (lambda ($1 . $rest) '(complex-type "_Complex"))
  340. ;; complex-type-specifier => "float" "_Complex"
  341. (lambda ($2 $1 . $rest)
  342. '(complex-type "float _Complex"))
  343. ;; complex-type-specifier => "double" "_Complex"
  344. (lambda ($2 $1 . $rest)
  345. '(complex-type "double _Complex"))
  346. ;; complex-type-specifier => "long" "double" "_Complex"
  347. (lambda ($3 $2 $1 . $rest)
  348. '(complex-type "long double _Complex"))
  349. ;; fixpt-type-specifier => "short" "_Fract"
  350. (lambda ($2 $1 . $rest)
  351. '(fixpt-type "short _Fract"))
  352. ;; fixpt-type-specifier => "_Fract"
  353. (lambda ($1 . $rest) '(fixpt-type "_Fract"))
  354. ;; fixpt-type-specifier => "long" "_Fract"
  355. (lambda ($2 $1 . $rest)
  356. '(fixpt-type "long _Fract"))
  357. ;; fixpt-type-specifier => "signed" "short" "_Fract"
  358. (lambda ($3 $2 $1 . $rest)
  359. '(fixpt-type "signd short _Fract"))
  360. ;; fixpt-type-specifier => "signed" "_Fract"
  361. (lambda ($2 $1 . $rest)
  362. '(fixpt-type "signed _Fract"))
  363. ;; fixpt-type-specifier => "signed" "long _Fract"
  364. (lambda ($2 $1 . $rest)
  365. '(fixpt-type "signed long _Fract"))
  366. ;; fixpt-type-specifier => "unsigned" "short" "_Fract"
  367. (lambda ($3 $2 $1 . $rest)
  368. '(fixpt-type "unsigned short _Fract"))
  369. ;; fixpt-type-specifier => "unsigned" "_Fract"
  370. (lambda ($2 $1 . $rest)
  371. '(fixpt-type "unsigned _Fract"))
  372. ;; fixpt-type-specifier => "unsigned" "long _Fract"
  373. (lambda ($2 $1 . $rest)
  374. '(fixpt-type "unsigned long _Fract"))
  375. ;; fixpt-type-specifier => "short" "_Accum"
  376. (lambda ($2 $1 . $rest)
  377. '(fixpt-type "short _Accum"))
  378. ;; fixpt-type-specifier => "_Accum"
  379. (lambda ($1 . $rest) '(fixpt-type "_Accum"))
  380. ;; fixpt-type-specifier => "long _Accum"
  381. (lambda ($1 . $rest) '(fixpt-type "long _Accum"))
  382. ;; fixpt-type-specifier => "signed" "short" "_Accum"
  383. (lambda ($3 $2 $1 . $rest)
  384. '(fixpt-type "signd short _Accum"))
  385. ;; fixpt-type-specifier => "signed" "_Accum"
  386. (lambda ($2 $1 . $rest)
  387. '(fixpt-type "signed _Accum"))
  388. ;; fixpt-type-specifier => "signed" "long" "_Accum"
  389. (lambda ($3 $2 $1 . $rest)
  390. '(fixpt-type "signed long _Accum"))
  391. ;; fixpt-type-specifier => "unsigned" "short" "_Accum"
  392. (lambda ($3 $2 $1 . $rest)
  393. '(fixpt-type "unsigned short _Accum"))
  394. ;; fixpt-type-specifier => "unsigned" "_Accum"
  395. (lambda ($2 $1 . $rest)
  396. '(fixpt-type "unsigned _Accum"))
  397. ;; fixpt-type-specifier => "unsigned" "long" "_Accum"
  398. (lambda ($3 $2 $1 . $rest)
  399. '(fixpt-type "unsigned long _Accum"))
  400. ;; fixpt-type-specifier => "_Sat" "short" "_Fract"
  401. (lambda ($3 $2 $1 . $rest)
  402. '(fixpt-type "_Sat short _Fract"))
  403. ;; fixpt-type-specifier => "_Sat" "_Fract"
  404. (lambda ($2 $1 . $rest)
  405. '(fixpt-type "_Sat _Fract"))
  406. ;; fixpt-type-specifier => "_Sat" "long" "_Fract"
  407. (lambda ($3 $2 $1 . $rest)
  408. '(fixpt-type "_Sat long _Fract"))
  409. ;; fixpt-type-specifier => "_Sat" "signed" "short" "_Fract"
  410. (lambda ($4 $3 $2 $1 . $rest)
  411. '(fixpt-type "_Sat signd short _Fract"))
  412. ;; fixpt-type-specifier => "_Sat" "signed" "_Fract"
  413. (lambda ($3 $2 $1 . $rest)
  414. '(fixpt-type "_Sat signed _Fract"))
  415. ;; fixpt-type-specifier => "_Sat" "signed" "long _Fract"
  416. (lambda ($3 $2 $1 . $rest)
  417. '(fixpt-type "_Sat signed long _Fract"))
  418. ;; fixpt-type-specifier => "_Sat" "unsigned" "short" "_Fract"
  419. (lambda ($4 $3 $2 $1 . $rest)
  420. '(fixpt-type "_Sat unsigned short _Fract"))
  421. ;; fixpt-type-specifier => "_Sat" "unsigned" "_Fract"
  422. (lambda ($3 $2 $1 . $rest)
  423. '(fixpt-type "_Sat unsigned _Fract"))
  424. ;; fixpt-type-specifier => "_Sat" "unsigned" "long" "_Fract"
  425. (lambda ($4 $3 $2 $1 . $rest)
  426. '(fixpt-type "_Sat unsigned long _Fract"))
  427. ;; fixpt-type-specifier => "_Sat" "short" "_Accum"
  428. (lambda ($3 $2 $1 . $rest)
  429. '(fixpt-type "_Sat short _Accum"))
  430. ;; fixpt-type-specifier => "_Sat" "_Accum"
  431. (lambda ($2 $1 . $rest)
  432. '(fixpt-type "_Sat _Accum"))
  433. ;; fixpt-type-specifier => "_Sat" "long" "_Accum"
  434. (lambda ($3 $2 $1 . $rest)
  435. '(fixpt-type "_Sat long _Accum"))
  436. ;; fixpt-type-specifier => "_Sat" "signed" "short" "_Accum"
  437. (lambda ($4 $3 $2 $1 . $rest)
  438. '(fixpt-type "_Sat signd short _Accum"))
  439. ;; fixpt-type-specifier => "_Sat" "signed" "_Accum"
  440. (lambda ($3 $2 $1 . $rest)
  441. '(fixpt-type "_Sat signed _Accum"))
  442. ;; fixpt-type-specifier => "_Sat" "signed" "long" "_Accum"
  443. (lambda ($4 $3 $2 $1 . $rest)
  444. '(fixpt-type "_Sat signed long _Accum"))
  445. ;; fixpt-type-specifier => "_Sat" "unsigned" "short" "_Accum"
  446. (lambda ($4 $3 $2 $1 . $rest)
  447. '(fixpt-type "_Sat unsigned short _Accum"))
  448. ;; fixpt-type-specifier => "_Sat" "unsigned" "_Accum"
  449. (lambda ($3 $2 $1 . $rest)
  450. '(fixpt-type "_Sat unsigned _Accum"))
  451. ;; fixpt-type-specifier => "_Sat" "unsigned" "long" "_Accum"
  452. (lambda ($4 $3 $2 $1 . $rest)
  453. '(fixpt-type "_Sat unsigned long _Accum"))
  454. ;; struct-or-union-specifier => "struct" opt-attr-specs ident-like "{" s...
  455. (lambda ($6 $5 $4 $3 $2 $1 . $rest)
  456. (sx-join* 'struct-def $2 $3 (tl->list $5)))
  457. ;; struct-or-union-specifier => "struct" opt-attr-specs "{" struct-decla...
  458. (lambda ($5 $4 $3 $2 $1 . $rest)
  459. (sx-join* 'struct-def $2 (tl->list $4)))
  460. ;; struct-or-union-specifier => "struct" opt-attr-specs ident-like
  461. (lambda ($3 $2 $1 . $rest)
  462. (sx-join* 'struct-ref $1 $3))
  463. ;; struct-or-union-specifier => "union" opt-attr-specs ident-like "{" st...
  464. (lambda ($6 $5 $4 $3 $2 $1 . $rest)
  465. (sx-join* 'union-def $2 $3 (tl->list $5)))
  466. ;; struct-or-union-specifier => "union" opt-attr-specs "{" struct-declar...
  467. (lambda ($5 $4 $3 $2 $1 . $rest)
  468. (sx-join* 'union-def $2 (tl->list $4)))
  469. ;; struct-or-union-specifier => "union" opt-attr-specs ident-like
  470. (lambda ($3 $2 $1 . $rest)
  471. (sx-join* 'union-ref $2 $3))
  472. ;; ident-like => identifier
  473. (lambda ($1 . $rest) $1)
  474. ;; ident-like => typedef-name
  475. (lambda ($1 . $rest) `(ident ,(sx-ref $1 1)))
  476. ;; opt-attr-specs =>
  477. (lambda $rest (list))
  478. ;; opt-attr-specs => attribute-specifiers
  479. (lambda ($1 . $rest) `(@ ,(attrl->attrs $1)))
  480. ;; struct-declaration-list => struct-declaration
  481. (lambda ($1 . $rest) (make-tl 'field-list $1))
  482. ;; struct-declaration-list => lone-comment
  483. (lambda ($1 . $rest) (make-tl 'field-list $1))
  484. ;; struct-declaration-list => struct-declaration-list struct-declaration
  485. (lambda ($2 $1 . $rest) (tl-append $1 $2))
  486. ;; struct-declaration-list => struct-declaration-list lone-comment
  487. (lambda ($2 $1 . $rest) (tl-append $1 $2))
  488. ;; struct-declaration-list => ";"
  489. (lambda ($1 . $rest) (make-tl 'field-list))
  490. ;; struct-declaration-list => struct-declaration-list ";"
  491. (lambda ($2 $1 . $rest) $1)
  492. ;; struct-declaration => struct-declaration-no-comment ";"
  493. (lambda ($2 $1 . $rest) $1)
  494. ;; struct-declaration => struct-declaration-no-comment ";" code-comment
  495. (lambda ($3 $2 $1 . $rest) (sx-attr-add $1 $3))
  496. ;; struct-declaration-no-comment => specifier-qualifier-list struct-decl...
  497. (lambda ($2 $1 . $rest)
  498. `(comp-decl ,$1 ,(tl->list $2)))
  499. ;; struct-declaration-no-comment => specifier-qualifier-list
  500. (lambda ($1 . $rest) `(comp-decl ,$1))
  501. ;; specifier-qualifier-list => specifier-qualifier-list-1
  502. (lambda ($1 . $rest)
  503. (process-specs (tl->list $1)))
  504. ;; specifier-qualifier-list-1 => type-specifier
  505. (lambda ($1 . $rest)
  506. (make-tl 'decl-spec-list $1))
  507. ;; specifier-qualifier-list-1 => type-specifier specifier-qualifier-list-1
  508. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  509. ;; specifier-qualifier-list-1 => type-qualifier
  510. (lambda ($1 . $rest)
  511. (make-tl 'decl-spec-list $1))
  512. ;; specifier-qualifier-list-1 => type-qualifier specifier-qualifier-list-1
  513. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  514. ;; specifier-qualifier-list-1 => attribute-specifier
  515. (lambda ($1 . $rest)
  516. (make-tl 'decl-spec-list $1))
  517. ;; specifier-qualifier-list-1 => attribute-specifier specifier-qualifier...
  518. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  519. ;; specifier-qualifier-list/no-attr => specifier-qualifier-list/no-attr-1
  520. (lambda ($1 . $rest) (tl->list $1))
  521. ;; specifier-qualifier-list/no-attr-1 => type-specifier
  522. (lambda ($1 . $rest)
  523. (make-tl 'decl-spec-list $1))
  524. ;; specifier-qualifier-list/no-attr-1 => type-specifier specifier-qualif...
  525. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  526. ;; specifier-qualifier-list/no-attr-1 => type-qualifier
  527. (lambda ($1 . $rest)
  528. (make-tl 'decl-spec-list $1))
  529. ;; specifier-qualifier-list/no-attr-1 => type-qualifier specifier-qualif...
  530. (lambda ($2 $1 . $rest) (tl-insert $2 $1))
  531. ;; struct-declarator-list => struct-declarator
  532. (lambda ($1 . $rest)
  533. (make-tl 'comp-declr-list $1))
  534. ;; struct-declarator-list => struct-declarator-list "," struct-declarator
  535. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  536. ;; struct-declarator-list => struct-declarator-list "," attribute-specif...
  537. (lambda ($4 $3 $2 $1 . $rest)
  538. (tl-append $1 $3 $4))
  539. ;; struct-declarator => struct-declarator-1
  540. (lambda ($1 . $rest) (process-declr $1))
  541. ;; struct-declarator-1 => declarator
  542. (lambda ($1 . $rest) `(comp-declr ,$1))
  543. ;; struct-declarator-1 => declarator attribute-specifiers
  544. (lambda ($2 $1 . $rest) `(comp-declr ,$1 ,$2))
  545. ;; struct-declarator-1 => declarator ":" constant-expression
  546. (lambda ($3 $2 $1 . $rest)
  547. `(comp-declr (bit-field ,$1 ,$3)))
  548. ;; struct-declarator-1 => ":" constant-expression
  549. (lambda ($2 $1 . $rest)
  550. `(comp-declr (bit-field ,$2)))
  551. ;; enum-specifier => "enum" ident-like "{" enumerator-list "}"
  552. (lambda ($5 $4 $3 $2 $1 . $rest)
  553. `(enum-def ,$2 ,(tl->list $4)))
  554. ;; enum-specifier => "enum" ident-like "{" enumerator-list "," "}"
  555. (lambda ($6 $5 $4 $3 $2 $1 . $rest)
  556. `(enum-def ,$2 ,(tl->list $4)))
  557. ;; enum-specifier => "enum" "{" enumerator-list "}"
  558. (lambda ($4 $3 $2 $1 . $rest)
  559. `(enum-def ,(tl->list $3)))
  560. ;; enum-specifier => "enum" "{" enumerator-list "," "}"
  561. (lambda ($5 $4 $3 $2 $1 . $rest)
  562. `(enum-def ,(tl->list $3)))
  563. ;; enum-specifier => "enum" ident-like
  564. (lambda ($2 $1 . $rest) `(enum-ref ,$2))
  565. ;; enumerator-list => enumerator
  566. (lambda ($1 . $rest) (make-tl 'enum-def-list $1))
  567. ;; enumerator-list => enumerator-list "," enumerator
  568. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  569. ;; enumerator => identifier
  570. (lambda ($1 . $rest) `(enum-defn ,$1))
  571. ;; enumerator => identifier attribute-specifiers
  572. (lambda ($2 $1 . $rest) `(enum-defn ,$1 ,$2))
  573. ;; enumerator => identifier "=" constant-expression
  574. (lambda ($3 $2 $1 . $rest) `(enum-defn ,$1 ,$3))
  575. ;; type-qualifier => "const"
  576. (lambda ($1 . $rest) `(type-qual ,$1))
  577. ;; type-qualifier => "volatile"
  578. (lambda ($1 . $rest) `(type-qual ,$1))
  579. ;; type-qualifier => "restrict"
  580. (lambda ($1 . $rest) `(type-qual ,$1))
  581. ;; function-specifier => "inline"
  582. (lambda ($1 . $rest) `(fctn-spec ,$1))
  583. ;; function-specifier => "_Noreturn"
  584. (lambda ($1 . $rest) `(fctn-spec ,$1))
  585. ;; attribute-specifiers => attribute-specifier
  586. (lambda ($1 . $rest) $1)
  587. ;; attribute-specifiers => attribute-specifiers attribute-specifier
  588. (lambda ($2 $1 . $rest) (append $1 (cdr $2)))
  589. ;; attribute-specifier => "__attribute__" "(" "(" attribute-list ")" ")"
  590. (lambda ($6 $5 $4 $3 $2 $1 . $rest) $4)
  591. ;; attribute-specifier => attr-name
  592. (lambda ($1 . $rest)
  593. `(attribute-list (attribute ,$1)))
  594. ;; attr-name => "__packed__"
  595. (lambda ($1 . $rest) '(ident "__packed__"))
  596. ;; attr-name => "__aligned__"
  597. (lambda ($1 . $rest) '(ident "__aligned__"))
  598. ;; attr-name => "__alignof__"
  599. (lambda ($1 . $rest) '(ident "__alignof__"))
  600. ;; attribute-list => attribute-list-1
  601. (lambda ($1 . $rest) (tl->list $1))
  602. ;; attribute-list-1 => attribute
  603. (lambda ($1 . $rest)
  604. (make-tl 'attribute-list $1))
  605. ;; attribute-list-1 => attribute-list-1 "," attribute
  606. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  607. ;; attribute-list-1 => attribute-list-1 ","
  608. (lambda ($2 $1 . $rest) $1)
  609. ;; attribute => attr-word
  610. (lambda ($1 . $rest) `(attribute ,$1))
  611. ;; attribute => attr-word "(" attr-expr-list ")"
  612. (lambda ($4 $3 $2 $1 . $rest)
  613. `(attribute ,$1 ,$3))
  614. ;; attribute => "const"
  615. (lambda ($1 . $rest)
  616. `(attribute (ident "const")))
  617. ;; attr-word => attr-name
  618. (lambda ($1 . $rest) $1)
  619. ;; attr-word => identifier
  620. (lambda ($1 . $rest) $1)
  621. ;; attr-expr-list => attr-expr-list-1
  622. (lambda ($1 . $rest) (tl->list $1))
  623. ;; attr-expr-list-1 => attribute-expr
  624. (lambda ($1 . $rest)
  625. (make-tl 'attr-expr-list $1))
  626. ;; attr-expr-list-1 => attr-expr-list-1 "," attribute-expr
  627. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  628. ;; attribute-expr => type-name
  629. (lambda ($1 . $rest) $1)
  630. ;; attribute-expr => '$fixed
  631. (lambda ($1 . $rest) `(fixed ,$1))
  632. ;; attribute-expr => string-literal
  633. (lambda ($1 . $rest) $1)
  634. ;; attribute-expr => identifier
  635. (lambda ($1 . $rest) $1)
  636. ;; attribute-expr => attr-word "(" attr-expr-list ")"
  637. (lambda ($4 $3 $2 $1 . $rest)
  638. `(attribute ,$1 ,$3))
  639. ;; init-declarator-list => init-declarator-list-1
  640. (lambda ($1 . $rest) (tl->list $1))
  641. ;; init-declarator-list-1 => init-declarator
  642. (lambda ($1 . $rest)
  643. (make-tl 'init-declr-list $1))
  644. ;; init-declarator-list-1 => init-declarator-list-1 "," init-declarator
  645. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  646. ;; init-declarator-list-1 => init-declarator-list-1 "," attribute-specif...
  647. (lambda ($4 $3 $2 $1 . $rest)
  648. (tl-append $1 $3 $4))
  649. ;; init-declarator => init-declarator-1
  650. (lambda ($1 . $rest) (process-declr $1))
  651. ;; init-declarator-1 => declarator
  652. (lambda ($1 . $rest) `(init-declr ,$1))
  653. ;; init-declarator-1 => declarator "=" initializer
  654. (lambda ($3 $2 $1 . $rest) `(init-declr ,$1 ,$3))
  655. ;; init-declarator-1 => declarator asm-expression
  656. (lambda ($2 $1 . $rest) `(init-declr ,$1 ,$2))
  657. ;; init-declarator-1 => declarator asm-expression "=" initializer
  658. (lambda ($4 $3 $2 $1 . $rest)
  659. `(init-declr ,$1 ,$2 ,$4))
  660. ;; init-declarator-1 => declarator attribute-specifiers
  661. (lambda ($2 $1 . $rest) `(init-declr ,$1 ,$2))
  662. ;; init-declarator-1 => declarator attribute-specifiers "=" initializer
  663. (lambda ($4 $3 $2 $1 . $rest)
  664. `(init-declr ,$1 ,$2 ,$4))
  665. ;; init-declarator-1 => declarator asm-expression attribute-specifiers
  666. (lambda ($3 $2 $1 . $rest)
  667. `(init-declr ,$1 ,$2 ,$3))
  668. ;; declarator => pointer direct-declarator
  669. (lambda ($2 $1 . $rest) `(ptr-declr ,$1 ,$2))
  670. ;; declarator => direct-declarator
  671. (lambda ($1 . $rest) $1)
  672. ;; pointer => "*" type-qualifier-list pointer
  673. (lambda ($3 $2 $1 . $rest) `(pointer ,$2 ,$3))
  674. ;; pointer => "*" type-qualifier-list
  675. (lambda ($2 $1 . $rest) `(pointer ,$2))
  676. ;; pointer => "*" pointer
  677. (lambda ($2 $1 . $rest) `(pointer ,$2))
  678. ;; pointer => "*" attribute-specifiers pointer
  679. (lambda ($3 $2 $1 . $rest) `(pointer ,$3))
  680. ;; pointer => "*"
  681. (lambda ($1 . $rest) '(pointer))
  682. ;; direct-declarator => identifier
  683. (lambda ($1 . $rest) $1)
  684. ;; direct-declarator => "(" declarator ")"
  685. (lambda ($3 $2 $1 . $rest) `(scope ,$2))
  686. ;; direct-declarator => "(" attribute-specifier declarator ")"
  687. (lambda ($4 $3 $2 $1 . $rest) `(scope ,$2))
  688. ;; direct-declarator => direct-declarator "[" type-qualifier-list assign...
  689. (lambda ($5 $4 $3 $2 $1 . $rest)
  690. `(array-of ,$1 ,$3 ,$4))
  691. ;; direct-declarator => direct-declarator "[" type-qualifier-list "]"
  692. (lambda ($4 $3 $2 $1 . $rest)
  693. `(array-of ,$1 ,$3))
  694. ;; direct-declarator => direct-declarator "[" assignment-expression "]"
  695. (lambda ($4 $3 $2 $1 . $rest)
  696. `(array-of ,$1 ,$3))
  697. ;; direct-declarator => direct-declarator "[" "]"
  698. (lambda ($3 $2 $1 . $rest) `(array-of ,$1))
  699. ;; direct-declarator => direct-declarator "[" "static" type-qualifier-li...
  700. (lambda ($6 $5 $4 $3 $2 $1 . $rest)
  701. `(array-of ,$1 ,$4 ,$5))
  702. ;; direct-declarator => direct-declarator "[" type-qualifier-list "stati...
  703. (lambda ($6 $5 $4 $3 $2 $1 . $rest)
  704. `(array-of ,$1 ,4 ,$5))
  705. ;; direct-declarator => direct-declarator "[" type-qualifier-list "*" "]"
  706. (lambda ($5 $4 $3 $2 $1 . $rest)
  707. `(array-of ,$1 ,$3 (var-len)))
  708. ;; direct-declarator => direct-declarator "[" "*" "]"
  709. (lambda ($4 $3 $2 $1 . $rest)
  710. `(array-of ,$1 (var-len)))
  711. ;; direct-declarator => direct-declarator "(" parameter-type-list ")"
  712. (lambda ($4 $3 $2 $1 . $rest)
  713. `(ftn-declr ,$1 ,$3))
  714. ;; direct-declarator => direct-declarator "(" identifier-list ")"
  715. (lambda ($4 $3 $2 $1 . $rest)
  716. `(ftn-declr ,$1 ,$3))
  717. ;; direct-declarator => direct-declarator "(" ")"
  718. (lambda ($3 $2 $1 . $rest)
  719. `(ftn-declr ,$1 (param-list)))
  720. ;; type-qualifier-list => type-qualifier-list-1
  721. (lambda ($1 . $rest) (tl->list $1))
  722. ;; type-qualifier-list-1 => type-qualifier
  723. (lambda ($1 . $rest)
  724. (make-tl 'type-qual-list $1))
  725. ;; type-qualifier-list-1 => type-qualifier-list-1 type-qualifier
  726. (lambda ($2 $1 . $rest) (tl-append $1 $2))
  727. ;; parameter-type-list => parameter-list
  728. (lambda ($1 . $rest) (tl->list $1))
  729. ;; parameter-type-list => parameter-list "," "..."
  730. (lambda ($3 $2 $1 . $rest)
  731. (tl->list (tl-append $1 '(ellipsis))))
  732. ;; parameter-list => parameter-declaration
  733. (lambda ($1 . $rest) (make-tl 'param-list $1))
  734. ;; parameter-list => parameter-list "," parameter-declaration
  735. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  736. ;; parameter-declaration => declaration-specifiers declarator
  737. (lambda ($2 $1 . $rest)
  738. `(param-decl ,$1 (param-declr ,$2)))
  739. ;; parameter-declaration => declaration-specifiers abstract-declarator
  740. (lambda ($2 $1 . $rest)
  741. `(param-decl ,$1 (param-declr ,$2)))
  742. ;; parameter-declaration => declaration-specifiers
  743. (lambda ($1 . $rest) `(param-decl ,$1))
  744. ;; identifier-list => identifier-list-1
  745. (lambda ($1 . $rest) (tl->list $1))
  746. ;; identifier-list-1 => identifier
  747. (lambda ($1 . $rest) (make-tl 'ident-list $1))
  748. ;; identifier-list-1 => identifier-list-1 "," identifier
  749. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  750. ;; type-name => specifier-qualifier-list/no-attr abstract-declarator
  751. (lambda ($2 $1 . $rest) `(type-name ,$1 ,$2))
  752. ;; type-name => declaration-specifiers
  753. (lambda ($1 . $rest) `(type-name ,$1))
  754. ;; abstract-declarator => pointer direct-abstract-declarator
  755. (lambda ($2 $1 . $rest) `(abs-declr ,$1 ,$2))
  756. ;; abstract-declarator => pointer
  757. (lambda ($1 . $rest) `(abs-declr ,$1))
  758. ;; abstract-declarator => direct-abstract-declarator
  759. (lambda ($1 . $rest) `(abs-declr ,$1))
  760. ;; direct-abstract-declarator => "(" abstract-declarator ")"
  761. (lambda ($3 $2 $1 . $rest) `(declr-scope ,$2))
  762. ;; direct-abstract-declarator => direct-abstract-declarator "[" type-qua...
  763. (lambda ($5 $4 $3 $2 $1 . $rest)
  764. `(declr-array ,$1 ,$3 ,$4))
  765. ;; direct-abstract-declarator => direct-abstract-declarator "[" type-qua...
  766. (lambda ($4 $3 $2 $1 . $rest)
  767. `(declr-array ,$1 ,$3))
  768. ;; direct-abstract-declarator => direct-abstract-declarator "[" assignme...
  769. (lambda ($4 $3 $2 $1 . $rest)
  770. `(declr-array ,$1 ,$3))
  771. ;; direct-abstract-declarator => direct-abstract-declarator "[" "]"
  772. (lambda ($3 $2 $1 . $rest) `(declr-array ,$1))
  773. ;; direct-abstract-declarator => direct-abstract-declarator "[" "static"...
  774. (lambda ($6 $5 $4 $3 $2 $1 . $rest)
  775. `(declr-array
  776. ,$1
  777. ,(tl->list (tl-insert $4 '(stor-spec "static")))
  778. ,$5))
  779. ;; direct-abstract-declarator => direct-abstract-declarator "[" "static"...
  780. (lambda ($5 $4 $3 $2 $1 . $rest)
  781. `(declr-array
  782. ,$1
  783. ,(tl->list (tl-insert $4 '(stor-spec "static")))))
  784. ;; direct-abstract-declarator => direct-abstract-declarator "[" type-qua...
  785. (lambda ($6 $5 $4 $3 $2 $1 . $rest)
  786. `(declr-array
  787. ,$1
  788. ,(tl->list (tl-insert $3 '(stor-spec "static")))
  789. ,$5))
  790. ;; direct-abstract-declarator => "[" type-qualifier-list assignment-expr...
  791. (lambda ($4 $3 $2 $1 . $rest)
  792. `(declr-anon-array ,$2 ,$3))
  793. ;; direct-abstract-declarator => "[" type-qualifier-list "]"
  794. (lambda ($3 $2 $1 . $rest)
  795. `(declr-anon-array ,$2))
  796. ;; direct-abstract-declarator => "[" assignment-expression "]"
  797. (lambda ($3 $2 $1 . $rest)
  798. `(declr-anon-array ,$2))
  799. ;; direct-abstract-declarator => "[" "]"
  800. (lambda ($2 $1 . $rest) `(declr-anon-array))
  801. ;; direct-abstract-declarator => "[" "static" type-qualifier-list assign...
  802. (lambda ($5 $4 $3 $2 $1 . $rest)
  803. `(declr-anon-array
  804. ,(tl->list (tl-insert $3 '(stor-spec "static")))
  805. ,$4))
  806. ;; direct-abstract-declarator => "[" "static" type-qualifier-list "]"
  807. (lambda ($4 $3 $2 $1 . $rest)
  808. `(declr-anon-array
  809. ,(tl->list (tl-insert $3 '(stor-spec "static")))))
  810. ;; direct-abstract-declarator => "[" type-qualifier-list "static" assign...
  811. (lambda ($5 $4 $3 $2 $1 . $rest)
  812. `(declr-anon-array
  813. ,(tl->list (tl-insert $2 '(stor-spec "static")))
  814. ,$4))
  815. ;; direct-abstract-declarator => direct-abstract-declarator "[" "*" "]"
  816. (lambda ($4 $3 $2 $1 . $rest) `(declr-star ,$1))
  817. ;; direct-abstract-declarator => "[" "*" "]"
  818. (lambda ($3 $2 $1 . $rest) '(declr-star))
  819. ;; direct-abstract-declarator => direct-abstract-declarator "(" paramete...
  820. (lambda ($4 $3 $2 $1 . $rest)
  821. `(abs-ftn-declr ,$1 ,$3))
  822. ;; direct-abstract-declarator => direct-abstract-declarator "(" ")"
  823. (lambda ($3 $2 $1 . $rest) `(abs-ftn-declr ,$1))
  824. ;; direct-abstract-declarator => "(" parameter-type-list ")"
  825. (lambda ($3 $2 $1 . $rest) `(anon-ftn-declr ,$2))
  826. ;; direct-abstract-declarator => "(" ")"
  827. (lambda ($2 $1 . $rest) '(anon-ftn-declr))
  828. ;; typedef-name => 'typename
  829. (lambda ($1 . $rest) `(typename ,$1))
  830. ;; initializer => assignment-expression
  831. (lambda ($1 . $rest) `(initzer ,$1))
  832. ;; initializer => "{" initializer-list "}"
  833. (lambda ($3 $2 $1 . $rest)
  834. `(initzer ,(tl->list $2)))
  835. ;; initializer => "{" initializer-list "," "}"
  836. (lambda ($4 $3 $2 $1 . $rest)
  837. `(initzer ,(tl->list $2)))
  838. ;; initializer-list => designation initializer
  839. (lambda ($2 $1 . $rest)
  840. (make-tl 'initzer-list $1 $2))
  841. ;; initializer-list => initializer
  842. (lambda ($1 . $rest) (make-tl 'initzer-list $1))
  843. ;; initializer-list => initializer-list "," designation initializer
  844. (lambda ($4 $3 $2 $1 . $rest)
  845. (tl-append $1 $3 $4))
  846. ;; initializer-list => initializer-list "," initializer
  847. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  848. ;; designation => designator-list "="
  849. (lambda ($2 $1 . $rest) `(desig ,$1))
  850. ;; designator-list => designator
  851. (lambda ($1 . $rest) (make-tl 'desgr-list $1))
  852. ;; designator-list => designator-list designator
  853. (lambda ($2 $1 . $rest) (tl-append $1 $2))
  854. ;; designator => "[" constant-expression "]"
  855. (lambda ($3 $2 $1 . $rest) `(array-dsgr ,$2))
  856. ;; designator => "." identifier
  857. (lambda ($2 $1 . $rest) `(sel-dsgr ,$2))
  858. ;; statement => labeled-statement
  859. (lambda ($1 . $rest) $1)
  860. ;; statement => compound-statement
  861. (lambda ($1 . $rest) $1)
  862. ;; statement => expression-statement
  863. (lambda ($1 . $rest) $1)
  864. ;; statement => selection-statement
  865. (lambda ($1 . $rest) $1)
  866. ;; statement => iteration-statement
  867. (lambda ($1 . $rest) $1)
  868. ;; statement => jump-statement
  869. (lambda ($1 . $rest) $1)
  870. ;; statement => asm-statement
  871. (lambda ($1 . $rest) $1)
  872. ;; statement => pragma
  873. (lambda ($1 . $rest) $1)
  874. ;; statement => cpp-statement
  875. (lambda ($1 . $rest) $1)
  876. ;; labeled-statement => identifier ":" statement
  877. (lambda ($3 $2 $1 . $rest)
  878. `(labeled-stmt ,$1 ,$3))
  879. ;; labeled-statement => identifier ":" attribute-specifier statement
  880. (lambda ($4 $3 $2 $1 . $rest)
  881. `(labeled-stmt ,$1 ,$4))
  882. ;; labeled-statement => "case" constant-expression ":" statement
  883. (lambda ($4 $3 $2 $1 . $rest) `(case ,$2 ,$4))
  884. ;; labeled-statement => "default" ":" statement
  885. (lambda ($3 $2 $1 . $rest) `(default ,$3))
  886. ;; compound-statement => "{" $P3 block-item-list $P4 "}"
  887. (lambda ($5 $4 $3 $2 $1 . $rest)
  888. `(compd-stmt ,(tl->list $3)))
  889. ;; compound-statement => "{" "}"
  890. (lambda ($2 $1 . $rest)
  891. `(compd-stmt (block-item-list)))
  892. ;; $P3 =>
  893. (lambda ($1 . $rest) (cpi-push))
  894. ;; $P4 =>
  895. (lambda ($3 $2 $1 . $rest) (cpi-pop))
  896. ;; block-item-list => block-item
  897. (lambda ($1 . $rest)
  898. (make-tl 'block-item-list $1))
  899. ;; block-item-list => block-item-list block-item
  900. (lambda ($2 $1 . $rest) (tl-append $1 $2))
  901. ;; block-item => declaration
  902. (lambda ($1 . $rest) $1)
  903. ;; block-item => statement
  904. (lambda ($1 . $rest) $1)
  905. ;; expression-statement => expression ";"
  906. (lambda ($2 $1 . $rest) `(expr-stmt ,$1))
  907. ;; expression-statement => ";"
  908. (lambda ($1 . $rest) '(expr-stmt))
  909. ;; selection-statement => "if" "(" expression ")" statement
  910. (lambda ($5 $4 $3 $2 $1 . $rest) `(if ,$3 ,$5))
  911. ;; selection-statement => "if" "(" expression ")" statement "else" state...
  912. (lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
  913. `(if ,$3 ,$5 ,$7))
  914. ;; selection-statement => "switch" "(" expression ")" statement
  915. (lambda ($5 $4 $3 $2 $1 . $rest)
  916. `(switch ,$3 ,$5))
  917. ;; iteration-statement => "while" "(" expression ")" statement
  918. (lambda ($5 $4 $3 $2 $1 . $rest)
  919. `(while ,$3 ,$5))
  920. ;; iteration-statement => "do" statement "while" "(" expression ")" ";"
  921. (lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
  922. `(do-while ,$2 ,$5))
  923. ;; iteration-statement => "for" "(" initial-clause opt-expression ";" op...
  924. (lambda ($8 $7 $6 $5 $4 $3 $2 $1 . $rest)
  925. `(for ,$3 ,$4 ,$6 ,$8))
  926. ;; initial-clause => expression ";"
  927. (lambda ($2 $1 . $rest) $1)
  928. ;; initial-clause => ";"
  929. (lambda ($1 . $rest) '(expr))
  930. ;; initial-clause => declaration
  931. (lambda ($1 . $rest) $1)
  932. ;; opt-expression =>
  933. (lambda $rest '(expr))
  934. ;; opt-expression => expression
  935. (lambda ($1 . $rest) $1)
  936. ;; jump-statement => "goto" identifier ";"
  937. (lambda ($3 $2 $1 . $rest) `(goto ,$2))
  938. ;; jump-statement => "continue" ";"
  939. (lambda ($2 $1 . $rest) '(continue))
  940. ;; jump-statement => "break" ";"
  941. (lambda ($2 $1 . $rest) '(break))
  942. ;; jump-statement => "return" expression ";"
  943. (lambda ($3 $2 $1 . $rest) `(return ,$2))
  944. ;; jump-statement => "return" ";"
  945. (lambda ($2 $1 . $rest) `(return (expr)))
  946. ;; asm-statement => asm-expression ";"
  947. (lambda ($2 $1 . $rest) $1)
  948. ;; asm-expression => "__asm__" opt-asm-specifiers "(" string-literal ")"
  949. (lambda ($5 $4 $3 $2 $1 . $rest)
  950. `(asm-expr (@ (extension "GNUC")) ,$4))
  951. ;; asm-expression => "__asm__" opt-asm-specifiers "(" string-literal asm...
  952. (lambda ($6 $5 $4 $3 $2 $1 . $rest)
  953. `(asm-expr
  954. (@ (extension "GNUC"))
  955. ,$4
  956. ,(tl->list $5)))
  957. ;; asm-expression => "__asm__" opt-asm-specifiers "(" string-literal asm...
  958. (lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
  959. `(asm-expr
  960. (@ (extension "GNUC"))
  961. ,$4
  962. ,(tl->list $5)
  963. ,(tl->list $6)))
  964. ;; asm-expression => "__asm__" opt-asm-specifiers "(" string-literal asm...
  965. (lambda ($8 $7 $6 $5 $4 $3 $2 $1 . $rest)
  966. `(asm-expr
  967. (@ (extension "GNUC"))
  968. ,$4
  969. ,(tl->list $5)
  970. ,(tl->list $6)
  971. ,(tl->list $7)))
  972. ;; opt-asm-specifiers =>
  973. (lambda $rest (list))
  974. ;; opt-asm-specifiers => "volatile"
  975. (lambda ($1 . $rest) $1)
  976. ;; asm-outputs => ":"
  977. (lambda ($1 . $rest) (make-tl 'asm-outputs))
  978. ;; asm-outputs => ":" asm-output
  979. (lambda ($2 $1 . $rest)
  980. (make-tl 'asm-outputs $2))
  981. ;; asm-outputs => asm-outputs "," asm-output
  982. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  983. ;; asm-output => string-literal "(" identifier ")"
  984. (lambda ($4 $3 $2 $1 . $rest)
  985. `(asm-operand ,$1 ,$3))
  986. ;; asm-output => "[" identifier "]" string-literal "(" identifier ")"
  987. (lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
  988. `(asm-operand ,$2 ,$4 ,$6))
  989. ;; asm-inputs => ":"
  990. (lambda ($1 . $rest) (make-tl 'asm-inputs))
  991. ;; asm-inputs => ":" asm-input
  992. (lambda ($2 $1 . $rest) (make-tl 'asm-inputs $2))
  993. ;; asm-inputs => asm-inputs "," asm-input
  994. (lambda ($3 $2 $1 . $rest) (tl-append $1 $3))
  995. ;; asm-input => string-literal "(" expression ")"
  996. (lambda ($4 $3 $2 $1 . $rest)
  997. `(asm-operand ,$1 ,$3))
  998. ;; asm-input => "[" identifier "]" string-literal "(" expression ")"
  999. (lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
  1000. `(asm-operand ,$2 ,$4 ,$6))
  1001. ;; asm-clobbers => ":"
  1002. (lambda ($1 . $rest) (make-tl 'asm-clobbers))
  1003. ;; asm-clobbers => ":" string-literal
  1004. (lambda ($2 $1 . $rest)
  1005. (tl-extend (make-tl 'asm-clobbers) $2))
  1006. ;; asm-clobbers => asm-clobbers "," string-literal
  1007. (lambda ($3 $2 $1 . $rest)
  1008. (tl-extend $1 (cdr $3)))
  1009. ;; translation-unit => external-declaration-list
  1010. (lambda ($1 . $rest) (tl->list $1))
  1011. ;; external-declaration-list =>
  1012. (lambda $rest (make-tl 'trans-unit))
  1013. ;; external-declaration-list => external-declaration-list external-decla...
  1014. (lambda ($2 $1 . $rest)
  1015. (if (eqv? (sx-tag $2) 'extern-block)
  1016. (tl-extend $1 (sx-tail $2 1))
  1017. (tl-append $1 $2)))
  1018. ;; external-declaration => function-definition
  1019. (lambda ($1 . $rest) $1)
  1020. ;; external-declaration => declaration
  1021. (lambda ($1 . $rest) $1)
  1022. ;; external-declaration => lone-comment
  1023. (lambda ($1 . $rest) $1)
  1024. ;; external-declaration => cpp-statement
  1025. (lambda ($1 . $rest) $1)
  1026. ;; external-declaration => pragma
  1027. (lambda ($1 . $rest) $1)
  1028. ;; external-declaration => "extern" '$string "{" $P5 external-declaratio...
  1029. (lambda ($7 $6 $5 $4 $3 $2 $1 . $rest)
  1030. `(extern-block
  1031. (extern-begin ,$2)
  1032. ,@(sx-tail (tl->list $5) 1)
  1033. (extern-end)))
  1034. ;; external-declaration => ";"
  1035. (lambda ($1 . $rest)
  1036. `(decl (@ (extension "GNUC"))))
  1037. ;; $P5 =>
  1038. (lambda ($3 $2 $1 . $rest) (cpi-dec-blev!))
  1039. ;; $P6 =>
  1040. (lambda ($5 $4 $3 $2 $1 . $rest) (cpi-inc-blev!))
  1041. ;; function-definition => declaration-specifiers declarator compound-sta...
  1042. (lambda ($3 $2 $1 . $rest)
  1043. `(fctn-defn ,$1 ,$2 ,$3))
  1044. ;; identifier => '$ident
  1045. (lambda ($1 . $rest) `(ident ,$1))
  1046. ;; constant => '$fixed
  1047. (lambda ($1 . $rest) `(fixed ,$1))
  1048. ;; constant => '$float
  1049. (lambda ($1 . $rest) `(float ,$1))
  1050. ;; constant => '$chlit
  1051. (lambda ($1 . $rest) `(char ,$1))
  1052. ;; constant => '$chlit/L
  1053. (lambda ($1 . $rest)
  1054. `(char (@ (type "wchar_t")) ,$1))
  1055. ;; constant => '$chlit/u
  1056. (lambda ($1 . $rest)
  1057. `(char (@ (type "char16_t")) ,$1))
  1058. ;; constant => '$chlit/U
  1059. (lambda ($1 . $rest)
  1060. `(char (@ (type "char32_t")) ,$1))
  1061. ;; string-literal => string-literal-1
  1062. (lambda ($1 . $rest) (tl->list $1))
  1063. ;; string-literal-1 => '$string
  1064. (lambda ($1 . $rest) (make-tl 'string $1))
  1065. ;; string-literal-1 => string-literal-1 '$string
  1066. (lambda ($2 $1 . $rest) (tl-append $1 $2))
  1067. ;; code-comment => '$code-comm
  1068. (lambda ($1 . $rest) `(comment ,$1))
  1069. ;; lone-comment => '$lone-comm
  1070. (lambda ($1 . $rest) `(comment ,$1))
  1071. ;; cpp-statement => 'cpp-stmt
  1072. (lambda ($1 . $rest) `(cpp-stmt ,$1))
  1073. ;; pragma => '$pragma
  1074. (lambda ($1 . $rest) `(pragma ,$1))
  1075. ;; pragma => "_Pragma" "(" string-literal ")"
  1076. (lambda ($4 $3 $2 $1 . $rest) `(pragma ,$3))
  1077. ))
  1078. ;;; end tables