~ubuntu-branches/ubuntu/lucid/gauche-c-wrapper/lucid

« back to all changes in this revision

Viewing changes to lib/c-wrapper/c-grammar.scm

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2008-04-07 09:15:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080407091503-wu0h414koe95kj4i
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(lalr-parser
 
2
 (expect: 4)
 
3
 (output: c-grammar "c-wrapper/c-grammar.yy.scm")
 
4
 ; (out-table: "c-gram.out")
 
5
 (ID
 
6
  ;; For scheme
 
7
  SEMICOLON ;
 
8
  ;; COMMA=,  LCBRA={  RCBRA=} LSBRA=[  RSBRA=]
 
9
  ;; LPAREN=( RPAREN=) OR=| DOT=.
 
10
  COMMA LCBRA RCBRA LSBRA RSBRA 
 
11
  LPAREN RPAREN OR DOT COLON
 
12
 
 
13
  ~ ! + - * / ^ & % = ? < >
 
14
 
 
15
  IDENTIFIER CONSTANT STRING SIZEOF
 
16
  PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
 
17
  AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
 
18
  SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
 
19
  XOR_ASSIGN OR_ASSIGN TYPENAME
 
20
 
 
21
  TYPEDEF EXTERN STATIC AUTO REGISTER INLINE RESTRICT
 
22
  SIGNED UNSIGNED CONST VOLATILE
 
23
  STRUCT UNION ENUM ELLIPSIS RANGE
 
24
 
 
25
  CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
 
26
 
 
27
  ASM UNKNOWN EXTENSION
 
28
 
 
29
  AT_INTERFACE AT_IMPLEMENTATION AT_END AT_SELECTOR AT_DEFS AT_ENCODE
 
30
  AT_PUBLIC AT_PRIVATE AT_PROTECTED AT_PROTOCOL
 
31
  AT_CLASS AT_ALIAS AT_THROW AT_TRY AT_CATCH AT_FINALLY AT_SYNCHRONIZED
 
32
  OBJC_STRING
 
33
 
 
34
  START_MACRO
 
35
  )
 
36
 
 
37
 (program
 
38
  ()
 
39
  (file)
 
40
  (START_MACRO statement_list) : (%MACRO-BODY $2)
 
41
  )
 
42
 
 
43
 (file
 
44
  (external_definition) : (clear-arg-pool)
 
45
  (file external_definition) : (clear-arg-pool)
 
46
  )
 
47
 
 
48
 (external_definition
 
49
  (maybe_extension function_definition)
 
50
  (maybe_extension asm_definition)
 
51
  (maybe_extension external_declaration)
 
52
  (objc_definition)
 
53
  )
 
54
 
 
55
 (function_definition
 
56
  (declarator function_body) : (emit-define-inline 'int $1 $2)
 
57
  (declaration_specifiers declarator function_body)
 
58
  : (emit-define-inline $1 $2 $3)
 
59
  )
 
60
 
 
61
 (function_body
 
62
  (compound_statement) : (%FUNCTION-BODY $1)
 
63
  (declaration_list compound_statement) : #f ;; TODO: support K&R style
 
64
  )
 
65
 
 
66
 (external_declaration
 
67
  (declaration_specifiers SEMICOLON) : (do-external-declaration $1 #f)
 
68
  (declaration_specifiers init_declarator_list SEMICOLON)
 
69
  : (do-external-declaration $1 $2)
 
70
  )
 
71
 
 
72
 (declaration
 
73
  (declaration_specifiers SEMICOLON) : (declaration $1 '())
 
74
  (declaration_specifiers init_declarator_list SEMICOLON) : (declaration $1 $2)
 
75
  (extension declaration) : $2
 
76
  )
 
77
 
 
78
 (declaration_specifiers
 
79
  (storage_class_specifier)
 
80
  (storage_class_specifier declaration_specifiers) : (%APPEND $1 $2)
 
81
  (type_specifier) : $1
 
82
  (type_specifier declaration_specifiers) : (%APPEND $1 $2)
 
83
  )
 
84
 
 
85
 (init_declarator_list
 
86
  (init_declarator) : (%LIST $1)
 
87
  (init_declarator_list COMMA init_declarator) : (%ADD-LIST $1 $3)
 
88
  )
 
89
 
 
90
 (init_declarator
 
91
  (declarator maybe_asm = initializer) : (%ADD-LIST $1 (decl-init-value $4))
 
92
  (declarator maybe_asm) : $1
 
93
  )
 
94
 
 
95
 (storage_class_specifier
 
96
  (TYPEDEF) : '(TYPEDEF)
 
97
  (EXTERN) : '()
 
98
  (STATIC) : '()
 
99
  (AUTO) : '()
 
100
  (INLINE) : '()
 
101
  )
 
102
 
 
103
 (type_specifier
 
104
  (TYPENAME) : (%LIST $1)
 
105
  (SIGNED) : '(SIGNED)
 
106
  (UNSIGNED) : '(UNSIGNED)
 
107
  (CONST) : '()
 
108
  (REGISTER) : '()
 
109
  (VOLATILE) : '()
 
110
  (struct_or_union_specifier) : (%LIST $1)
 
111
  (enum_specifier) : (%LIST $1)
 
112
  (RESTRICT) : '()
 
113
  (TYPENAME objc_non_empty_protocol_references) : (%LIST $1)
 
114
  (objc_non_empty_protocol_references) : '(id)
 
115
  )
 
116
 
 
117
 (primary_expr 
 
118
  (identifier) : (%IDENTIFIER $1)
 
119
  (CONSTANT) : (cadr $1)
 
120
  (STRING) : $1
 
121
  (OBJC_STRING) : (%OBJC-STRING $1)
 
122
  (LPAREN expr RPAREN) : (%EXPR-IN-PARENS $2)
 
123
  (LPAREN compound_statement RPAREN) : (%COMPOUND-STATEMENT $2)
 
124
  (LPAREN type_name RPAREN LCBRA initializer_list RCBRA) : #f
 
125
  (objc_message_expr) : $1
 
126
  (objc_selector_expr) : $1
 
127
  (objc_protocol_expr) : #f
 
128
  (objc_encode_expr) : #f
 
129
  )
 
130
 
 
131
 (postfix_expr 
 
132
  (primary_expr) : $1
 
133
  (postfix_expr LSBRA expr RSBRA) : (%REF-ARRAY $1 $3)
 
134
  (postfix_expr LPAREN RPAREN) : (%FUNCALL $1 '())
 
135
  (postfix_expr LPAREN argument_expr_list RPAREN) : (%FUNCALL $1 $3)
 
136
  (postfix_expr DOT identifier) : (%DOT-REF $1 $3)
 
137
  (postfix_expr PTR_OP identifier) : (%PTR-REF $1 $3)
 
138
  (postfix_expr INC_OP) : (%POST-INC $1)
 
139
  (postfix_expr DEC_OP) : (%POST-DEC $1)
 
140
  )
 
141
 
 
142
 (argument_expr_list
 
143
  (assignment_expr) : (%LIST $1)
 
144
  (argument_expr_list COMMA assignment_expr) : (%ADD-LIST $1 $3)
 
145
  )
 
146
 
 
147
 (unary_expr 
 
148
  (postfix_expr) : $1
 
149
  (INC_OP unary_expr) : (%PRE-INC $2)
 
150
  (DEC_OP unary_expr) : (%PRE-DEC $2)
 
151
  (unary_operator cast_expr) : (%UNARY $1 $2)
 
152
  (SIZEOF unary_expr) : (%SIZEOF-EXPR $2)
 
153
  (SIZEOF LPAREN type_name RPAREN) : (%SIZEOF-TYPE $3)
 
154
  (extension cast_expr) : $2
 
155
  )
 
156
 
 
157
 (unary_operator 
 
158
  (&) : '&
 
159
  (*) : '*
 
160
  (+) : '+
 
161
  (-) : '-
 
162
  (~) : '~
 
163
  (!) : '!
 
164
  )
 
165
 
 
166
 (cast_expr
 
167
  (unary_expr) : $1
 
168
  (LPAREN type_name RPAREN cast_expr) : (%CAST $2 $4)
 
169
  )
 
170
 
 
171
 (multiplicative_expr
 
172
  (cast_expr) : $1
 
173
  (multiplicative_expr * cast_expr) : (%MUL $1 $3)
 
174
  (multiplicative_expr / cast_expr) : (%DIV $1 $3)
 
175
  (multiplicative_expr % cast_expr) : (%MOD $1 $3)
 
176
  )
 
177
 
 
178
 (additive_expr
 
179
  (multiplicative_expr) : $1
 
180
  (additive_expr + multiplicative_expr) : (%ADD $1 $3)
 
181
  (additive_expr - multiplicative_expr) : (%SUB $1 $3)
 
182
  )
 
183
 
 
184
 (shift_expr
 
185
  (additive_expr) : $1
 
186
  (shift_expr LEFT_OP additive_expr) : (%SHIFT-LEFT $1 $3)
 
187
  (shift_expr RIGHT_OP additive_expr) : (%SHIFT-RIGHT $1 $3)
 
188
  )
 
189
 
 
190
 (relational_expr
 
191
  (shift_expr) : $1
 
192
  (relational_expr < shift_expr) : (%LT $1 $3)
 
193
  (relational_expr > shift_expr) : (%GT $1 $3)
 
194
  (relational_expr LE_OP shift_expr) : (%LE $1 $3)
 
195
  (relational_expr GE_OP shift_expr) : (%GE $1 $3)
 
196
  )
 
197
 
 
198
 (equality_expr
 
199
  (relational_expr) : $1
 
200
  (equality_expr EQ_OP relational_expr) : (%EQ $1 $3)
 
201
  (equality_expr NE_OP relational_expr) : (%NE $1 $3)
 
202
  )
 
203
 
 
204
 (and_expr
 
205
  (equality_expr) : $1
 
206
  (and_expr & equality_expr) : (%BIT-AND $1 $3)
 
207
  )
 
208
 
 
209
 
 
210
 (exclusive_or_expr
 
211
  (and_expr) : $1
 
212
  (exclusive_or_expr ^ and_expr) : (%BIT-XOR $1 $3)
 
213
  )
 
214
 
 
215
 
 
216
 (inclusive_or_expr
 
217
  (exclusive_or_expr) : $1
 
218
  (inclusive_or_expr OR exclusive_or_expr) : (%BIT-OR $1 $3)
 
219
  )
 
220
 
 
221
 
 
222
 (logical_and_expr
 
223
  (inclusive_or_expr) : $1
 
224
  (logical_and_expr AND_OP inclusive_or_expr) : (%LOG-AND $1 $3)
 
225
  )
 
226
 
 
227
 (logical_or_expr
 
228
  (logical_and_expr) : $1
 
229
  (logical_or_expr OR_OP logical_and_expr) : (%LOG-OR $1 $3)
 
230
  )
 
231
 
 
232
 (conditional_expr
 
233
  (logical_or_expr) : $1
 
234
  (logical_or_expr ? logical_or_expr COLON conditional_expr) : (%IF $1 $3 $5)
 
235
  )
 
236
 
 
237
 (assignment_expr
 
238
  (conditional_expr) : $1
 
239
  (unary_expr = assignment_expr) : (%ASSIGN $1 $3)
 
240
  (unary_expr MUL_ASSIGN assignment_expr) : (%ASSIGN $1 (%MUL $1 $3))
 
241
  (unary_expr DIV_ASSIGN assignment_expr) : (%ASSIGN $1 (%DIV $1 $3))
 
242
  (unary_expr MOD_ASSIGN assignment_expr) : (%ASSIGN $1 (%MOD $1 $3))
 
243
  (unary_expr ADD_ASSIGN assignment_expr) : (%ASSIGN $1 (%ADD $1 $3))
 
244
  (unary_expr SUB_ASSIGN assignment_expr) : (%ASSIGN $1 (%SUB $1 $3))
 
245
  (unary_expr LEFT_ASSIGN assignment_expr) : (%ASSIGN $1 (%SHIFT-LEFT $1 $3))
 
246
  (unary_expr RIGHT_ASSIGN assignment_expr) : (%ASSIGN $1 (%SHIFT-RIGHT $1 $3))
 
247
  (unary_expr AND_ASSIGN assignment_expr) : (%ASSIGN $1 (%BIT-AND $1 $3))
 
248
  (unary_expr XOR_ASSIGN assignment_expr) : (%ASSIGN $1 (%BIT-XOR $1 $3))
 
249
  (unary_expr OR_ASSIGN assignment_expr) : (%ASSIGN $1 (%BIT-OR $1 $3))
 
250
  )
 
251
 
 
252
 (expr
 
253
  (assignment_expr) : $1
 
254
  (expr COMMA assignment_expr) : (%CONCAT-EXPR $1 $3)
 
255
  )    
 
256
 
 
257
 (constant_expr
 
258
  (conditional_expr) : $1
 
259
  )
 
260
 
 
261
 (struct_or_union_specifier
 
262
  (struct_or_union identifier LCBRA struct_declaration_list RCBRA)
 
263
  : (decl-struct-or-union $1 $2 $4)
 
264
  (struct_or_union LCBRA struct_declaration_list RCBRA)
 
265
  : (decl-struct-or-union $1 #f $3)
 
266
  (struct_or_union identifier)
 
267
  : (decl-struct-or-union $1 $2 #f)
 
268
  )
 
269
 
 
270
 (struct_or_union
 
271
  (STRUCT) : 'STRUCT
 
272
  (UNION) : 'UNION
 
273
  )
 
274
 
 
275
 (struct_declaration_list
 
276
  (struct_declaration) : $1
 
277
  (struct_declaration_list struct_declaration) : (%APPEND $1 $2)
 
278
  )
 
279
 
 
280
 (struct_declaration
 
281
  (type_specifier_list struct_declarator_list SEMICOLON) : (make-var-list $1 $2)
 
282
  (extension type_specifier_list struct_declarator_list SEMICOLON)
 
283
  : (make-var-list $2 $3)
 
284
  (struct_or_union_specifier SEMICOLON)
 
285
  : (make-var-list (%LIST $1) (%LIST (decl-identifier (gensym "%unnamed"))))
 
286
  (extension struct_or_union_specifier SEMICOLON)
 
287
  : (make-var-list (%LIST $2) (%LIST (decl-identifier (gensym "%unnamed"))))
 
288
  (AT_DEFS LPAREN TYPENAME RPAREN) : '()
 
289
  )
 
290
 
 
291
 (struct_declarator_list
 
292
  (struct_declarator) : (%LIST $1)
 
293
  (struct_declarator_list COMMA struct_declarator) : (%ADD-LIST $1 $3)
 
294
  )
 
295
 
 
296
 (struct_declarator
 
297
  (declarator) : $1
 
298
  (COLON constant_expr) : (decl-bitfield #f $2)
 
299
  (declarator COLON constant_expr) : (decl-bitfield $1 $3)
 
300
  )
 
301
 
 
302
 (enum_specifier
 
303
  (ENUM LCBRA enumerator_list RCBRA) : (decl-enum #f $3)
 
304
  (ENUM LCBRA enumerator_list COMMA RCBRA) : (decl-enum #f $3)
 
305
  (ENUM identifier LCBRA enumerator_list RCBRA) : (decl-enum $2 $4)
 
306
  (ENUM identifier LCBRA enumerator_list COMMA RCBRA) : (decl-enum $2 $4)
 
307
  (ENUM identifier) : (decl-enum $2 '())
 
308
  )
 
309
 
 
310
 (enumerator_list
 
311
  (enumerator) : (%LIST $1)
 
312
  (enumerator_list COMMA enumerator) : (%ADD-LIST $1 $3)
 
313
  )
 
314
 
 
315
 (enumerator
 
316
  (identifier) : (decl-enumerator $1 #f)
 
317
  (identifier = constant_expr) : (decl-enumerator $1 $3)
 
318
  )
 
319
 
 
320
 (declarator
 
321
  (declarator2) : $1
 
322
  (pointer declarator2) : (%APPEND $2 $1)
 
323
  )
 
324
 
 
325
 (declarator2
 
326
  (identifier) : (decl-identifier $1)
 
327
  (LPAREN declarator RPAREN) : $2
 
328
  (declarator2 LSBRA RSBRA) : (%APPEND $1 (decl-array #f))
 
329
  (declarator2 LSBRA array_qualifier_list RSBRA) : (%APPEND $1 (decl-array #f))
 
330
  (declarator2 LSBRA array_size_expr RSBRA) : (%APPEND $1 (decl-array $3))
 
331
  (declarator2 LSBRA array_qualifier_list array_size_expr RSBRA)
 
332
  : (%APPEND $1 (decl-array $4))
 
333
  (declarator2 LPAREN RPAREN) : (%APPEND $1 (decl-func '()))
 
334
  (declarator2 LPAREN parameter_type_list RPAREN) : (%APPEND $1 $3)
 
335
  (declarator2 LPAREN parameter_identifier_list RPAREN) : $1 ;; not supported
 
336
  )
 
337
 
 
338
 (pointer
 
339
  (*) : (decl-ptr)
 
340
  (* type_specifier_list) : (decl-ptr)
 
341
  (* pointer) : (%APPEND (decl-ptr) $2)
 
342
  (* type_specifier_list pointer) : (%APPEND (decl-ptr) $3)
 
343
  )
 
344
 
 
345
 (type_specifier_list
 
346
  (type_specifier) : $1
 
347
  (type_specifier_list type_specifier) : (%APPEND $1 $2)
 
348
  )
 
349
 
 
350
 (parameter_identifier_list
 
351
  (identifier_list)
 
352
  (identifier_list COMMA ELLIPSIS)
 
353
  )
 
354
 
 
355
 (identifier_list
 
356
  (identifier) : (list $1)
 
357
  (identifier_list COMMA identifier) : (%ADD-LIST $1 $3)
 
358
  )
 
359
 
 
360
 (parameter_type_list
 
361
  (parameter_list) : (decl-func $1)
 
362
  (parameter_list COMMA ELLIPSIS) : (decl-func-vaargs $1)
 
363
  )
 
364
 
 
365
 (parameter_list
 
366
  (parameter_declaration) : (%LIST $1)
 
367
  (parameter_list COMMA parameter_declaration) : (%ADD-LIST $1 $3)
 
368
  )
 
369
 
 
370
 (parameter_declaration
 
371
  (type_specifier_list declarator) : (parameter-decl $1 $2)
 
372
  (type_name) : $1
 
373
  )
 
374
 
 
375
 (type_name
 
376
  (type_specifier_list) : (make-var $1 '())
 
377
  (type_specifier_list abstract_declarator) : (make-var $1 $2)
 
378
  )
 
379
 
 
380
 (abstract_declarator
 
381
  (pointer) : $1
 
382
  (abstract_declarator2) : $1
 
383
  (pointer abstract_declarator2) : (%APPEND $2 $1)
 
384
  )
 
385
 
 
386
 
 
387
 (abstract_declarator2
 
388
  (LPAREN abstract_declarator RPAREN) : $2
 
389
  (LSBRA RSBRA) : (decl-ptr)
 
390
  (LSBRA array_qualifier_list RSBRA) : (decl-ptr)
 
391
  (LSBRA array_size_expr RSBRA) : (decl-array $2)
 
392
  (LSBRA array_qualifier_list array_size_expr RSBRA) : (decl-array $3)
 
393
  (abstract_declarator2 LSBRA RSBRA) : (%APPEND $1 (decl-ptr))
 
394
  (abstract_declarator2 LSBRA array_qualifier_list RSBRA) : (%APPEND $1 (decl-ptr))
 
395
  (abstract_declarator2 LSBRA array_size_expr RSBRA) : (%APPEND $1 (decl-array $3))
 
396
  (abstract_declarator2 LSBRA array_qualifier_list array_size_expr RSBRA)
 
397
  : (%APPEND $1 (decl-array $4))
 
398
  (LPAREN RPAREN) : (decl-func '())
 
399
  (LPAREN parameter_type_list RPAREN) : $2
 
400
  (abstract_declarator2 LPAREN RPAREN) : (%APPEND $1 (decl-func '()))
 
401
  (abstract_declarator2 LPAREN parameter_type_list RPAREN) : (%APPEND $1 $3)
 
402
  )
 
403
 
 
404
 (initializer
 
405
  (assignment_expr) : $1
 
406
  (LCBRA initializer_list RCBRA) : #f
 
407
  (LCBRA initializer_list COMMA RCBRA) : #f
 
408
  )
 
409
 
 
410
 (initializer_list
 
411
  (initializer)
 
412
  (initializer_list COMMA initializer)
 
413
  )
 
414
 
 
415
 (statement
 
416
  (labeled_statement) : #f
 
417
  (compound_statement) : $1
 
418
  (expression_statement) : $1
 
419
  (selection_statement) : $1
 
420
  (iteration_statement) : $1
 
421
  (jump_statement) : $1
 
422
  (asm_statement) : #f
 
423
  (objc_statement) : #f
 
424
  )
 
425
 
 
426
 (objc_statement
 
427
  (AT_THROW expr SEMICOLON) 
 
428
  (AT_THROW SEMICOLON) 
 
429
  (objc_try_catch_statement) 
 
430
  (AT_SYNCHRONIZED LPAREN expr RPAREN compound_statement)
 
431
  )
 
432
 
 
433
 (objc_catch_prefix
 
434
  (AT_CATCH LPAREN identifier RPAREN)
 
435
  )
 
436
 
 
437
 (objc_catch_clause
 
438
  (objc_catch_prefix compound_statement)
 
439
  )
 
440
 
 
441
 (objc_opt_catch_list
 
442
  ()
 
443
  (objc_opt_catch_list objc_catch_clause)
 
444
  )
 
445
 
 
446
 (objc_try_catch_clause
 
447
  (AT_TRY compound_statement objc_opt_catch_list)
 
448
  )
 
449
 
 
450
 (objc_finally_clause
 
451
  (AT_FINALLY compound_statement)
 
452
  )
 
453
 
 
454
 (objc_try_catch_statement
 
455
  (objc_try_catch_clause)
 
456
  (objc_try_catch_clause objc_finally_clause)
 
457
  )
 
458
 
 
459
 (labeled_statement
 
460
  (identifier COLON statement)
 
461
  (CASE constant_expr COLON statement)
 
462
  (DEFAULT COLON statement)
 
463
  )
 
464
 
 
465
 (compound_statement
 
466
  (LCBRA RCBRA) : (%COMPOUND-STATEMENT '(0))
 
467
  (LCBRA statement_list RCBRA) : (%COMPOUND-STATEMENT $2)
 
468
  (LCBRA declaration_list RCBRA) : (%COMPOUND-STATEMENT '(0))
 
469
  (LCBRA declaration_list statement_list RCBRA)
 
470
  : (%COMPOUND-STATEMENT-WITH-DECL $2 $3)
 
471
  (error RCBRA)
 
472
  )
 
473
 
 
474
 (declaration_list
 
475
  (declaration) : (%LIST $1)
 
476
  (declaration_list declaration) : (%ADD-LIST $1 $2)
 
477
  )
 
478
 
 
479
 (statement_list
 
480
  (statement) : (%LIST $1)
 
481
  (statement_list statement) : (%ADD-LIST $1 $2)
 
482
  )
 
483
 
 
484
 (expression_statement
 
485
  (SEMICOLON) : 0
 
486
  (expr SEMICOLON) : $1
 
487
  (error SEMICOLON) : #f
 
488
  )
 
489
 
 
490
 (selection_statement
 
491
  (IF LPAREN expr RPAREN statement) : (%IF $3 $5 0)
 
492
  (IF LPAREN expr RPAREN statement ELSE statement) : (%IF $3 $5 $7)
 
493
  (SWITCH LPAREN expr RPAREN statement) : #f
 
494
  )
 
495
 
 
496
 (iteration_statement
 
497
  (WHILE LPAREN expr RPAREN statement) : (%WHILE $3 $5)
 
498
  (DO statement WHILE LPAREN expr RPAREN SEMICOLON) : (%DO-WHILE $5 $2)
 
499
  (FOR LPAREN SEMICOLON SEMICOLON RPAREN statement) : (%FOR 0 1 0 $6)
 
500
  (FOR LPAREN SEMICOLON SEMICOLON expr RPAREN statement) : (%FOR 0 1 $5 $7)
 
501
  (FOR LPAREN SEMICOLON expr SEMICOLON RPAREN statement) : (%FOR 0 $4 0 $7)
 
502
  (FOR LPAREN SEMICOLON expr SEMICOLON expr RPAREN statement) : (%FOR 0 $4 $6 $8)
 
503
  (FOR LPAREN expr SEMICOLON SEMICOLON RPAREN statement) : (%FOR $3 1 0 $7)
 
504
  (FOR LPAREN expr SEMICOLON SEMICOLON expr RPAREN statement) : (%FOR $3 1 $6 $8)
 
505
  (FOR LPAREN expr SEMICOLON expr SEMICOLON RPAREN statement) : (%FOR $3 $5 0 $8)
 
506
  (FOR LPAREN expr SEMICOLON expr SEMICOLON expr RPAREN statement)
 
507
  : (%FOR $3 $5 $7 $9)
 
508
  )
 
509
 
 
510
 (jump_statement
 
511
  (GOTO identifier SEMICOLON) : #f
 
512
  (CONTINUE SEMICOLON) : (%CONTINUE)
 
513
  (BREAK SEMICOLON) : (%BREAK)
 
514
  (RETURN SEMICOLON) : (%RETURN 0)
 
515
  (RETURN expr SEMICOLON) : (%RETURN $2)
 
516
  )
 
517
 
 
518
 (identifier
 
519
  (IDENTIFIER) : $1
 
520
  )
 
521
 
 
522
 ;;
 
523
 ;; asm
 
524
 ;;
 
525
 (maybe_asm
 
526
  ()
 
527
  (asm_expr)
 
528
  )
 
529
 
 
530
 (asm_expr
 
531
  (ASM LPAREN string_list RPAREN)
 
532
  )
 
533
 
 
534
 (asm_statement
 
535
  (ASM LPAREN asm_argument RPAREN SEMICOLON)
 
536
  (ASM type_qualifier LPAREN asm_argument RPAREN SEMICOLON)
 
537
  )
 
538
 
 
539
 (type_qualifier
 
540
  (CONST)
 
541
  (VOLATILE)
 
542
  (RESTRICT)
 
543
  )
 
544
 
 
545
 (array_qualifier
 
546
  (STATIC)
 
547
  (RESTRICT)
 
548
  (CONST)
 
549
  (VOLATILE)
 
550
  )
 
551
 
 
552
 (array_qualifier_list
 
553
  (array_qualifier)
 
554
  (array_qualifier_list array_qualifier)
 
555
  )
 
556
 
 
557
 (array_size_expr
 
558
  (assignment_expr) : $1
 
559
  (*) : #f
 
560
  )
 
561
 
 
562
 (asm_argument
 
563
  (string_list)
 
564
  (string_list COLON asm_operands)
 
565
  (string_list COLON asm_operands COLON asm_operands)
 
566
  (string_list COLON asm_operands COLON asm_operands COLON asm_clobbers)
 
567
  )
 
568
 
 
569
 (string_list
 
570
  (STRING)
 
571
  (string_list STRING)
 
572
  )
 
573
 
 
574
 (asm_operands
 
575
  ()
 
576
  (asm_operands2)
 
577
  )
 
578
 
 
579
 (asm_operands2
 
580
  (asm_operand)
 
581
  (asm_operands2 COMMA asm_operand)
 
582
  )
 
583
 
 
584
 (asm_operand
 
585
  (STRING LPAREN expr RPAREN)
 
586
  (LSBRA identifier RSBRA STRING LPAREN expr RPAREN)
 
587
  )
 
588
 
 
589
 (asm_clobbers
 
590
  (STRING)
 
591
  (asm_clobbers COMMA STRING)
 
592
  )
 
593
 
 
594
 (asm_definition
 
595
  (asm_expr SEMICOLON)
 
596
  )
 
597
 
 
598
 ;;
 
599
 ;; extension
 
600
 ;;
 
601
 (maybe_extension
 
602
  ()
 
603
  (extension)
 
604
  )
 
605
 
 
606
 (extension
 
607
  (EXTENSION)
 
608
  )
 
609
 
 
610
 ;; Objective-C
 
611
 (objc_definition
 
612
  (objc_class_definition)
 
613
  (objc_class_declaration)
 
614
  (objc_alias_declaration)
 
615
  (objc_protocol_definition)
 
616
  (objc_method_definition)
 
617
  )
 
618
 
 
619
 (classname
 
620
  (identifier) : $1
 
621
  (TYPENAME) : $1
 
622
  )
 
623
 
 
624
 (classname_list
 
625
  (classname) : (%LIST $1)
 
626
  (classname_list COMMA classname) : (%ADD-LIST $1 $3)
 
627
  )
 
628
 
 
629
 (objc_class_declaration
 
630
  (AT_CLASS classname_list SEMICOLON) : (emit-define-objc-class $2)
 
631
  )
 
632
 
 
633
 (objc_alias_declaration
 
634
  (AT_ALIAS identifier identifier SEMICOLON) : #f
 
635
  )
 
636
  
 
637
 (objc_superclass
 
638
  (COLON classname)
 
639
  ()
 
640
  )
 
641
 
 
642
 (objc_class_ivars
 
643
  (LCBRA objc_ivar_declaration_list RCBRA)
 
644
  ()
 
645
  )
 
646
 
 
647
 (objc_class_definition
 
648
  (objc_interface_head objc_superclass objc_protocol_references
 
649
                objc_class_ivars
 
650
                objc_method_prototype_list
 
651
                AT_END)
 
652
  (AT_IMPLEMENTATION classname objc_superclass
 
653
                     objc_class_ivars)
 
654
  (objc_interface_head LPAREN classname RPAREN objc_protocol_references
 
655
                objc_method_prototype_list
 
656
                AT_END)
 
657
  (AT_IMPLEMENTATION classname LPAREN identifier RPAREN)
 
658
  )
 
659
 
 
660
 (objc_interface_head
 
661
  (AT_INTERFACE classname) : (emit-define-objc-class (%LIST $2))
 
662
  )
 
663
 
 
664
 (objc_protocol_definition
 
665
  (AT_PROTOCOL identifier objc_protocol_references objc_method_prototype_list AT_END)
 
666
  (AT_PROTOCOL identifier_list SEMICOLON)
 
667
  )
 
668
 
 
669
 (objc_protocol_references
 
670
  ()
 
671
  (objc_non_empty_protocol_references)
 
672
  )
 
673
 
 
674
 (objc_non_empty_protocol_references
 
675
  (< classname_list >)
 
676
  )
 
677
 
 
678
 (objc_ivar_declaration_list
 
679
  (objc_ivar_declaration_list objc_visibility_spec objc_ivar_declarations)
 
680
  (objc_ivar_declarations)
 
681
  )
 
682
 
 
683
 (objc_visibility_spec
 
684
  (AT_PRIVATE)
 
685
  (AT_PROTECTED)
 
686
  (AT_PUBLIC)
 
687
  )
 
688
 
 
689
 (objc_ivar_declarations
 
690
  ()
 
691
  (objc_ivar_declarations objc_ivar_declaration SEMICOLON)
 
692
  (objc_ivar_declarations SEMICOLON)
 
693
  )
 
694
 
 
695
 (objc_ivar_declaration
 
696
  (declaration_specifiers objc_ivars)
 
697
  )
 
698
 
 
699
 (objc_ivars
 
700
  ()
 
701
  (objc_ivar_declarator)
 
702
  (objc_ivars COMMA objc_ivar_declarator)
 
703
  )
 
704
 
 
705
 (objc_ivar_declarator
 
706
  (declarator)
 
707
  (declarator COLON assignment_expr)
 
708
  (COLON assignment_expr)
 
709
  )
 
710
 
 
711
 (objc_method_type
 
712
  (+)
 
713
  (-)
 
714
  )
 
715
 
 
716
 (objc_method_definition
 
717
  (objc_method_type objc_method_declaration optarglist compound_statement)
 
718
  )
 
719
 
 
720
 (objc_method_prototype_list
 
721
  ()
 
722
  (objc_method_prototype_list objc_method_prototype)
 
723
  (objc_method_prototype_list external_declaration)
 
724
  )
 
725
 
 
726
 (objc_method_prototype
 
727
  (objc_method_type objc_method_declaration SEMICOLON)
 
728
  : (apply emit-objc-method $2)
 
729
  )
 
730
 
 
731
 (objc_protocol_qualifier
 
732
  ()
 
733
  (identifier)
 
734
  )
 
735
 
 
736
 (objc_method_declaration
 
737
  (LPAREN objc_protocol_qualifier type_name RPAREN unary_selector)
 
738
  : (decl-objc-method $3 $5)
 
739
  (unary_selector) : (decl-objc-method (var-id) $1)
 
740
  (LPAREN objc_protocol_qualifier type_name RPAREN keyword_selector optparmlist)
 
741
  : (decl-objc-method $3 $5)
 
742
  (keyword_selector optparmlist) : (decl-objc-method (var-id) $1)
 
743
  )
 
744
 
 
745
 (optarglist
 
746
  ()
 
747
  (SEMICOLON myxdecls)
 
748
  )
 
749
 
 
750
 (myxdecls
 
751
  ()
 
752
  (mydecls)
 
753
  )
 
754
 
 
755
 (error_statement
 
756
  (error SEMICOLON)
 
757
  )
 
758
 
 
759
 (mydecls
 
760
  (mydecl)
 
761
  (error_statement)
 
762
  (mydecls mydecl)
 
763
  (mydecl error_statement)
 
764
  )
 
765
 
 
766
 (mydecl
 
767
  (declaration_specifiers parameter_list SEMICOLON)
 
768
  (declaration_specifiers SEMICOLON)
 
769
  )
 
770
 
 
771
 (optparmlist
 
772
  ()
 
773
  (COMMA ELLIPSIS)
 
774
  (COMMA parameter_list)
 
775
  )
 
776
 
 
777
 (unary_selector
 
778
  (selector) : (decl-keyword $1)
 
779
  )
 
780
 
 
781
 (keyword_selector
 
782
  (keyword_declarator) : (combine-decl-keyword $1)
 
783
  (keyword_selector keyword_declarator) : (combine-decl-keyword $1 $2)
 
784
  )
 
785
 
 
786
 (selector
 
787
  (identifier) : $1
 
788
  (TYPENAME) : $1
 
789
  (reserved_words) : $1
 
790
  )
 
791
 
 
792
 (reserved_words
 
793
  (ENUM)
 
794
  (STRUCT)
 
795
  (UNION)
 
796
  (IF)
 
797
  (ELSE)
 
798
  (WHILE)
 
799
  (DO)
 
800
  (FOR)
 
801
  (SWITCH)
 
802
  (CASE)
 
803
  (DEFAULT)
 
804
  (BREAK)
 
805
  (CONTINUE)
 
806
  (RETURN)
 
807
  (GOTO)
 
808
  (ASM)
 
809
  (SIZEOF)
 
810
  )
 
811
 
 
812
 (keyword_declarator
 
813
  (selector COLON LPAREN objc_protocol_qualifier type_name RPAREN identifier)
 
814
  : (decl-keyword $1 $5)
 
815
  (selector COLON identifier) : (decl-keyword $1 (var-id))
 
816
  (COLON LPAREN objc_protocol_qualifier type_name RPAREN identifier)
 
817
  : (decl-keyword "" $4)
 
818
  (COLON identifier) : (decl-keyword "" (var-id))
 
819
  )
 
820
 
 
821
 (message_args
 
822
  (selector) : (%QUOTE $1)
 
823
  (keyword_arg_list) : $1
 
824
  )
 
825
 
 
826
 (keyword_arg_list
 
827
  (keyword_arg) : $1
 
828
  (keyword_arg_list keyword_arg) : (%APPEND $1 $2)
 
829
  )
 
830
 
 
831
 (keyword_arg
 
832
  (selector COLON expr) : (%KEYWORD-ARG $1 $3)
 
833
  (COLON expr) : (%KEYWORD-ARG-WITHOUT-SELECTOR $2)
 
834
  )
 
835
 
 
836
 (receiver
 
837
  (expr) : $1
 
838
  (TYPENAME) : $1
 
839
  )
 
840
 
 
841
 (objc_message_expr
 
842
  (LSBRA receiver message_args RSBRA) : (%OBJC-MESSAGE-EXPR $2 $3)
 
843
  )
 
844
 
 
845
 (selector_arg
 
846
  (selector) : (x->string $1)
 
847
  (keyword_name_list) : (string-join (map x->string $1) ":")
 
848
  )
 
849
 
 
850
 (keyword_name_list
 
851
  (keyword_name) : (%LIST $1)
 
852
  (keyword_name_list keyword_name) : (%ADD-LIST $1 $2)
 
853
  )
 
854
 
 
855
 (keyword_name
 
856
  (selector COLON) : $1
 
857
  (COLON) : :
 
858
  )
 
859
 
 
860
 (objc_selector_expr
 
861
  (AT_SELECTOR LPAREN selector_arg RPAREN) : (%SELECTOR $3)
 
862
  )
 
863
 
 
864
 (objc_protocol_expr
 
865
  (AT_PROTOCOL LPAREN identifier RPAREN)
 
866
  )
 
867
 
 
868
 (objc_encode_expr
 
869
  (AT_ENCODE LPAREN TYPENAME RPAREN)
 
870
  )
 
871
 
 
872
 
 
873
;;  ;;
 
874
;;  ;; attribute
 
875
;;  ;;
 
876
;;  (maybe_attribute
 
877
;;   ()
 
878
;;   (attributes)
 
879
;;   )
 
880
 
 
881
;;  (attributes
 
882
;;   (attribute)
 
883
;;   (attributes attribute)
 
884
;;   )
 
885
 
 
886
;;  (attribute
 
887
;;   (ATTRIBUTE LPAREN LPAREN attribute_list RPAREN RPAREN)
 
888
;;   )
 
889
 
 
890
;;  (attribute_list
 
891
;;   (attribute2)
 
892
;;   (attribute_list COMMA attribute2)
 
893
;;   )
 
894
 
 
895
;;  (attribute2
 
896
;;   ()
 
897
;;   (attribute_word)
 
898
;;   (attribute_word LPAREN IDENTIFIER RPAREN)
 
899
;;   (attribute_word LPAREN IDENTIFIER COMMA expr RPAREN)
 
900
;;   (attribute_word LPAREN RPAREN)
 
901
;;   (attribute_word LPAREN expr RPAREN)
 
902
;;   )
 
903
 
 
904
;;  (attribute_word
 
905
;;   (identifier)
 
906
;;   (storage_class_specifier)
 
907
;;   (TYPENAME)
 
908
;;   (type_qualifier)
 
909
;;   )
 
910
  
 
911
 )
 
912