cast 0.0.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,15 @@
1
- ###
2
- ### ##################################################################
3
- ###
4
- ### All those Node classes.
5
- ###
6
- ### ##################################################################
7
- ###
1
+ ######################################################################
2
+ #
3
+ # All those Node classes.
4
+ #
5
+ ######################################################################
8
6
 
9
7
  module C
10
- ###
11
- ### ==================================================================
12
- ###
13
- ### Class declarations
14
- ###
15
- ### ==================================================================
16
- ###
8
+
9
+ # ------------------------------------------------------------------
10
+ # Class declarations
11
+ # ------------------------------------------------------------------
12
+
17
13
  class Statement < Node ; abstract; end
18
14
  class Label < Node ; abstract; end
19
15
  class Expression < Node ; abstract; end
@@ -55,6 +51,7 @@ module C
55
51
  class Comma < Expression ; end
56
52
  class Conditional < Expression ; end
57
53
  class Variable < Expression ; end
54
+ class BlockExpression < Expression ; end
58
55
 
59
56
  class Index < PostfixExpression ; end
60
57
  class Call < PostfixExpression ; end
@@ -128,30 +125,19 @@ module C
128
125
  class Complex < PrimitiveType ; end
129
126
  class Imaginary < PrimitiveType ; end
130
127
 
131
- ###
132
- ### ==================================================================
133
- ###
134
- ### Class implementations
135
- ###
136
- ### ==================================================================
137
- ###
138
-
139
- ###
140
- ### Node
141
- ###
128
+ # ------------------------------------------------------------------
129
+ # Class implementations
130
+ # ------------------------------------------------------------------
131
+
142
132
  class Node
143
133
  initializer
144
134
  end
145
- ###
146
- ### TranslationUnit
147
- ###
135
+
148
136
  class TranslationUnit
149
137
  child :entities, lambda{NodeChain.new}
150
138
  initializer :entities
151
139
  end
152
- ###
153
- ### Declaration
154
- ###
140
+
155
141
  class Declaration
156
142
  field :storage
157
143
  child :type
@@ -174,9 +160,7 @@ module C
174
160
  storage.equal? :register
175
161
  end
176
162
  end
177
- ###
178
- ### Declarator
179
- ###
163
+
180
164
  class Declarator
181
165
  child :indirect_type
182
166
  field :name
@@ -186,10 +170,10 @@ module C
186
170
  def declaration
187
171
  parent and parent.parent
188
172
  end
189
- ###
190
- ### Return (a copy of) the type of the variable this Declarator
191
- ### declares.
192
- ###
173
+ #
174
+ # Return (a copy of) the type of the variable this Declarator
175
+ # declares.
176
+ #
193
177
  def type
194
178
  if indirect_type
195
179
  ret = indirect_type.clone
@@ -200,9 +184,7 @@ module C
200
184
  end
201
185
  end
202
186
  end
203
- ###
204
- ### FunctionDef
205
- ###
187
+
206
188
  class FunctionDef
207
189
  field :storage
208
190
  field :inline?
@@ -217,65 +199,51 @@ module C
217
199
  def static?
218
200
  storage.equal? :static
219
201
  end
220
- def prototype= val
202
+ def prototype=(val)
221
203
  self.no_prototype = !val
222
204
  end
223
205
  def prototype?
224
206
  !no_prototype?
225
207
  end
226
208
  end
227
- ###
228
- ### Parameter
229
- ###
209
+
230
210
  class Parameter
231
211
  field :register?
232
212
  child :type
233
213
  field :name
234
214
  initializer :type, :name
235
215
  end
236
- ###
237
- ### Enumerator
238
- ###
216
+
239
217
  class Enumerator
240
218
  field :name
241
219
  child :val
242
220
  initializer :name, :val
243
221
  end
244
- ###
245
- ### MemberInit
246
- ###
222
+
247
223
  class MemberInit
248
- ## member is a _NodeList_ of:
249
- ## -- Member (for struct/union members)
250
- ## -- Expression (for array members)
224
+ # member is a _NodeList_ of:
225
+ # -- Member (for struct/union members)
226
+ # -- Expression (for array members)
251
227
  child :member
252
228
  child :init
253
229
  initializer :member, :init
254
230
  end
255
- ###
256
- ### Member
257
- ###
231
+
258
232
  class Member
259
233
  field :name
260
234
  initializer :name
261
235
  end
262
236
 
263
- ###
264
- ### ----------------------------------------------------------------
265
- ### Statements
266
- ### ----------------------------------------------------------------
237
+ # ------------------------------------------------------------------
238
+ # Statements
239
+ # ------------------------------------------------------------------
267
240
 
268
- ###
269
- ### Block
270
- ###
271
241
  class Block
272
242
  child :labels, lambda{NodeArray.new}
273
243
  child :stmts, lambda{NodeChain.new}
274
244
  initializer :stmts
275
245
  end
276
- ###
277
- ### If
278
- ###
246
+
279
247
  class If
280
248
  child :labels, lambda{NodeArray.new}
281
249
  child :cond
@@ -283,18 +251,14 @@ module C
283
251
  child :else
284
252
  initializer :cond, :then, :else
285
253
  end
286
- ###
287
- ### Switch
288
- ###
254
+
289
255
  class Switch
290
256
  child :labels, lambda{NodeArray.new}
291
257
  child :cond
292
258
  child :stmt
293
259
  initializer :cond, :stmt
294
260
  end
295
- ###
296
- ### While
297
- ###
261
+
298
262
  class While
299
263
  child :labels, lambda{NodeArray.new}
300
264
  field :do?
@@ -302,9 +266,7 @@ module C
302
266
  child :stmt
303
267
  initializer :cond, :stmt, :do?
304
268
  end
305
- ###
306
- ### For
307
- ###
269
+
308
270
  class For
309
271
  child :labels, lambda{NodeArray.new}
310
272
  child :init
@@ -313,406 +275,302 @@ module C
313
275
  child :stmt
314
276
  initializer :init, :cond, :iter, :stmt
315
277
  end
316
- ###
317
- ### Goto
318
- ###
278
+
319
279
  class Goto
320
280
  child :labels, lambda{NodeArray.new}
321
281
  field :target
322
282
  initializer :target
323
283
  end
324
- ###
325
- ### Continue
326
- ###
284
+
327
285
  class Continue
328
286
  child :labels, lambda{NodeArray.new}
329
287
  end
330
- ###
331
- ### Break
332
- ###
288
+
333
289
  class Break
334
290
  child :labels, lambda{NodeArray.new}
335
291
  end
336
- ###
337
- ### Return
338
- ###
292
+
339
293
  class Return
340
294
  child :labels, lambda{NodeArray.new}
341
295
  child :expr
342
296
  initializer :expr
343
297
  end
344
- ###
345
- ### ExpressionStatement
346
- ###
298
+
347
299
  class ExpressionStatement
348
300
  child :labels, lambda{NodeArray.new}
349
301
  child :expr
350
302
  initializer :expr
351
303
  end
352
304
 
353
- ###
354
- ### ----------------------------------------------------------------
355
- ### Labels
356
- ### ----------------------------------------------------------------
357
- ###
305
+ # ------------------------------------------------------------------
306
+ # Labels
307
+ # ------------------------------------------------------------------
358
308
 
359
- ###
360
- ### PlainLabel
361
- ###
362
309
  class PlainLabel
363
310
  field :name
364
311
  initializer :name
365
312
  end
366
313
 
367
- ###
368
- ### Default
369
- ###
370
314
  class Default
371
315
  end
372
316
 
373
- ###
374
- ### Case
375
- ###
376
317
  class Case
377
318
  child :expr
378
319
  initializer :expr
379
320
  end
380
321
 
381
- ###
382
- ### ----------------------------------------------------------------
383
- ### Expressions
384
- ### ----------------------------------------------------------------
385
- ###
322
+ # ------------------------------------------------------------------
323
+ # Expressions
324
+ # ------------------------------------------------------------------
386
325
 
387
- ###
388
- ### Comma
389
- ###
390
326
  class Comma
391
327
  child :exprs, lambda{NodeArray.new}
392
328
  initializer :exprs
393
329
  end
394
- ###
395
- ### Conditional
396
- ###
330
+
397
331
  class Conditional
398
332
  child :cond
399
333
  child :then
400
334
  child :else
401
335
  initializer :cond, :then, :else
402
336
  end
403
- ###
404
- ### Sizeof
405
- ###
406
- class Sizeof
407
- child :expr
408
- initializer :expr
409
- end
410
- ###
411
- ### Variable
412
- ###
337
+
413
338
  class Variable
414
339
  field :name
415
340
  initializer :name
416
341
  end
417
342
 
418
- ###
419
- ### ----------------------------------------------------------------
420
- ### PrefixExpressions
421
- ### ----------------------------------------------------------------
422
- ###
343
+ class BlockExpression
344
+ child :block, lambda{Block.new}
345
+ initializer :block
346
+ end
347
+
348
+ # ------------------------------------------------------------------
349
+ # PrefixExpressions
350
+ # ------------------------------------------------------------------
423
351
 
424
- ###
425
- ### Cast
426
- ###
427
352
  class Cast
428
353
  child :type
429
354
  child :expr
430
355
  initializer :type, :expr
431
356
  end
432
- ###
433
- ### Address
434
- ###
357
+
435
358
  class Address
436
359
  child :expr
437
360
  initializer :expr
438
361
  end
439
- ###
440
- ### Dereference
441
- ###
362
+
442
363
  class Dereference
443
364
  child :expr
444
365
  initializer :expr
445
366
  end
446
- ###
447
- ### Positive
448
- ###
367
+
368
+ class Sizeof
369
+ child :expr
370
+ initializer :expr
371
+ end
372
+
449
373
  class Positive
450
374
  child :expr
451
375
  initializer :expr
452
376
  end
453
- ###
454
- ### Negative
455
- ###
377
+
456
378
  class Negative
457
379
  child :expr
458
380
  initializer :expr
459
381
  end
460
- ###
461
- ### PreInc
462
- ###
382
+
463
383
  class PreInc
464
384
  child :expr
465
385
  initializer :expr
466
386
  end
467
- ###
468
- ### PreDec
469
- ###
387
+
470
388
  class PreDec
471
389
  child :expr
472
390
  initializer :expr
473
391
  end
474
- ###
475
- ### BitNot
476
- ###
392
+
477
393
  class BitNot
478
394
  child :expr
479
395
  initializer :expr
480
396
  end
481
- ###
482
- ### Not
483
- ###
397
+
484
398
  class Not
485
399
  child :expr
486
400
  initializer :expr
487
401
  end
488
402
 
489
- ###
490
- ### ----------------------------------------------------------------
491
- ### PostfixExpressions
492
- ### ----------------------------------------------------------------
493
- ###
403
+ # ------------------------------------------------------------------
404
+ # PostfixExpressions
405
+ # ------------------------------------------------------------------
494
406
 
495
- ###
496
- ### Index
497
- ###
498
407
  class Index
499
408
  child :expr
500
409
  child :index
501
410
  initializer :expr, :index
502
411
  end
503
- ###
504
- ### Call
505
- ###
412
+
506
413
  class Call
507
414
  child :expr
508
415
  child :args, lambda{NodeArray.new}
509
416
  initializer :expr, :args
510
417
  end
511
- ###
512
- ### Dot
513
- ###
418
+
514
419
  class Dot
515
420
  child :expr
516
421
  child :member
517
422
  initializer :expr, :member
518
423
  end
519
- ###
520
- ### Arrow
521
- ###
424
+
522
425
  class Arrow
523
426
  child :expr
524
427
  child :member
525
428
  initializer :expr, :member
526
429
  end
527
- ###
528
- ### PostInc
529
- ###
430
+
530
431
  class PostInc
531
432
  child :expr
532
433
  initializer :expr
533
434
  end
534
- ###
535
- ### PostDec
536
- ###
435
+
537
436
  class PostDec
538
437
  child :expr
539
438
  initializer :expr
540
439
  end
541
440
 
542
- ###
543
- ### ----------------------------------------------------------------
544
- ### BinaryExpressions
545
- ### ----------------------------------------------------------------
546
- ###
441
+ # ------------------------------------------------------------------
442
+ # BinaryExpressions
443
+ # ------------------------------------------------------------------
547
444
 
548
- ###
549
- ### BinaryExpression (abstract)
550
- ###
551
445
  class BinaryExpression
552
446
  class << self
553
- ###
554
- ### The operator (a String) pertaining to the class (e.g.,
555
- ### Add.operator is '+').
556
- ###
447
+ #
448
+ # The operator (a String) pertaining to the class (e.g.,
449
+ # Add.operator is '+').
450
+ #
557
451
  attr_accessor :operator
558
452
  end
559
453
  end
560
- ###
561
- ### Add
562
- ###
454
+
563
455
  class Add
564
456
  child :expr1
565
457
  child :expr2
566
458
  initializer :expr1, :expr2
567
459
  self.operator = '+'
568
460
  end
569
- ###
570
- ### Subtract
571
- ###
461
+
572
462
  class Subtract
573
463
  child :expr1
574
464
  child :expr2
575
465
  initializer :expr1, :expr2
576
466
  self.operator = '-'
577
467
  end
578
- ###
579
- ### Multiply
580
- ###
468
+
581
469
  class Multiply
582
470
  child :expr1
583
471
  child :expr2
584
472
  initializer :expr1, :expr2
585
473
  self.operator = '*'
586
474
  end
587
- ###
588
- ### Divide
589
- ###
475
+
590
476
  class Divide
591
477
  child :expr1
592
478
  child :expr2
593
479
  initializer :expr1, :expr2
594
480
  self.operator = '/'
595
481
  end
596
- ###
597
- ### Mod
598
- ###
482
+
599
483
  class Mod
600
484
  child :expr1
601
485
  child :expr2
602
486
  initializer :expr1, :expr2
603
487
  self.operator = '%'
604
488
  end
605
- ###
606
- ### Equal
607
- ###
489
+
608
490
  class Equal
609
491
  child :expr1
610
492
  child :expr2
611
493
  initializer :expr1, :expr2
612
494
  self.operator = '=='
613
495
  end
614
- ###
615
- ### NotEqual
616
- ###
496
+
617
497
  class NotEqual
618
498
  child :expr1
619
499
  child :expr2
620
500
  initializer :expr1, :expr2
621
501
  self.operator = '!='
622
502
  end
623
- ###
624
- ### Less
625
- ###
503
+
626
504
  class Less
627
505
  child :expr1
628
506
  child :expr2
629
507
  initializer :expr1, :expr2
630
508
  self.operator = '<'
631
509
  end
632
- ###
633
- ### More
634
- ###
510
+
635
511
  class More
636
512
  child :expr1
637
513
  child :expr2
638
514
  initializer :expr1, :expr2
639
515
  self.operator = '>'
640
516
  end
641
- ###
642
- ### LessOrEqual
643
- ###
517
+
644
518
  class LessOrEqual
645
519
  child :expr1
646
520
  child :expr2
647
521
  initializer :expr1, :expr2
648
522
  self.operator = '<='
649
523
  end
650
- ###
651
- ### MoreOrEqual
652
- ###
524
+
653
525
  class MoreOrEqual
654
526
  child :expr1
655
527
  child :expr2
656
528
  initializer :expr1, :expr2
657
529
  self.operator = '>='
658
530
  end
659
- ###
660
- ### BitAnd
661
- ###
531
+
662
532
  class BitAnd
663
533
  child :expr1
664
534
  child :expr2
665
535
  initializer :expr1, :expr2
666
536
  self.operator = '&'
667
537
  end
668
- ###
669
- ### BitOr
670
- ###
538
+
671
539
  class BitOr
672
540
  child :expr1
673
541
  child :expr2
674
542
  initializer :expr1, :expr2
675
543
  self.operator = '|'
676
544
  end
677
- ###
678
- ### BitXor
679
- ###
545
+
680
546
  class BitXor
681
547
  child :expr1
682
548
  child :expr2
683
549
  initializer :expr1, :expr2
684
550
  self.operator = '^'
685
551
  end
686
- ###
687
- ### ShiftLeft
688
- ###
552
+
689
553
  class ShiftLeft
690
554
  child :expr1
691
555
  child :expr2
692
556
  initializer :expr1, :expr2
693
557
  self.operator = '<<'
694
558
  end
695
- ###
696
- ### ShiftRight
697
- ###
559
+
698
560
  class ShiftRight
699
561
  child :expr1
700
562
  child :expr2
701
563
  initializer :expr1, :expr2
702
564
  self.operator = '>>'
703
565
  end
704
- ###
705
- ### And
706
- ###
566
+
707
567
  class And
708
568
  child :expr1
709
569
  child :expr2
710
570
  initializer :expr1, :expr2
711
571
  self.operator = '&&'
712
572
  end
713
- ###
714
- ### Or
715
- ###
573
+
716
574
  class Or
717
575
  child :expr1
718
576
  child :expr2
@@ -720,117 +578,90 @@ module C
720
578
  self.operator = '||'
721
579
  end
722
580
 
723
- ###
724
- ### ----------------------------------------------------------------
725
- ### AssignmentExpressions
726
- ### ----------------------------------------------------------------
727
- ###
581
+ # ------------------------------------------------------------------
582
+ # AssignmentExpressions
583
+ # ------------------------------------------------------------------
728
584
 
729
- ###
730
- ### AssignmentExpression (abstract)
731
- ###
732
585
  class AssignmentExpression
733
586
  class << self
734
- ###
735
- ### The operator (a String) pertaining to the class (e.g.,
736
- ### Assign.operator is '=').
737
- ###
587
+ #
588
+ # The operator (a String) pertaining to the class (e.g.,
589
+ # Assign.operator is '=').
590
+ #
738
591
  attr_accessor :operator
739
592
  end
740
593
  end
741
- ###
742
- ### Assign
743
- ###
594
+
744
595
  class Assign
745
596
  child :lval
746
597
  child :rval
747
598
  initializer :lval, :rval
748
599
  self.operator = '='
749
600
  end
750
- ###
751
- ### MultiplyAssign
752
- ###
601
+
753
602
  class MultiplyAssign
754
603
  child :lval
755
604
  child :rval
756
605
  initializer :lval, :rval
757
606
  self.operator = '*='
758
607
  end
759
- ###
760
- ### DivideAssign
761
- ###
608
+
762
609
  class DivideAssign
763
610
  child :lval
764
611
  child :rval
765
612
  initializer :lval, :rval
766
613
  self.operator = '/='
767
614
  end
768
- ###
769
- ### ModAssign
770
- ###
615
+
771
616
  class ModAssign
772
617
  child :lval
773
618
  child :rval
774
619
  initializer :lval, :rval
775
620
  self.operator = '%='
776
621
  end
777
- ###
778
- ### AddAssign
779
- ###
622
+
780
623
  class AddAssign
781
624
  child :lval
782
625
  child :rval
783
626
  initializer :lval, :rval
784
627
  self.operator = '+='
785
628
  end
786
- ###
787
- ### SubtractAssign
788
- ###
629
+
789
630
  class SubtractAssign
790
631
  child :lval
791
632
  child :rval
792
633
  initializer :lval, :rval
793
634
  self.operator = '-='
794
635
  end
795
- ###
796
- ### ShiftLeftAssign
797
- ###
636
+
798
637
  class ShiftLeftAssign
799
638
  child :lval
800
639
  child :rval
801
640
  initializer :lval, :rval
802
641
  self.operator = '<<='
803
642
  end
804
- ###
805
- ### ShiftRightAssign
806
- ###
643
+
807
644
  class ShiftRightAssign
808
645
  child :lval
809
646
  child :rval
810
647
  initializer :lval, :rval
811
648
  self.operator = '>>='
812
649
  end
813
- ###
814
- ### BitAndAssign
815
- ###
650
+
816
651
  class BitAndAssign
817
652
  child :lval
818
653
  child :rval
819
654
  initializer :lval, :rval
820
655
  self.operator = '&='
821
656
  end
822
- ###
823
- ### BitXorAssign
824
- ###
657
+
825
658
  class BitXorAssign
826
659
  child :lval
827
660
  child :rval
828
661
  initializer :lval, :rval
829
662
  self.operator = '^='
830
663
  end
831
- ###
832
- ### BitOrAssign
833
- ###
664
+
834
665
  class BitOrAssign
835
666
  child :lval
836
667
  child :rval
@@ -838,40 +669,46 @@ module C
838
669
  self.operator = '|='
839
670
  end
840
671
 
841
- ###
842
- ### ----------------------------------------------------------------
843
- ### Literals
844
- ### ----------------------------------------------------------------
845
- ###
672
+ # ------------------------------------------------------------------
673
+ # Literals
674
+ # ------------------------------------------------------------------
846
675
 
847
- ###
848
- ### StringLiteral
849
- ###
850
676
  class StringLiteral
677
+ field :prefix
851
678
  field :val
852
- initializer :val
679
+ initializer :val, :prefix
680
+ def wide?
681
+ prefix == 'L'
682
+ end
683
+ def wide=(val)
684
+ return if wide? == !!val
685
+ self.prefix = val ? 'L' : nil
686
+ end
853
687
  end
854
- ###
855
- ### CharLiteral
856
- ###
688
+
857
689
  class CharLiteral
690
+ field :prefix
858
691
  field :val
859
- initializer :val
692
+ initializer :val, :prefix
693
+ def wide?
694
+ prefix == 'L'
695
+ end
696
+ def wide=(val)
697
+ return if wide? == !!val
698
+ self.prefix = val ? 'L' : nil
699
+ end
860
700
  end
861
- ###
862
- ### CompoundLiteral
863
- ###
701
+
864
702
  class CompoundLiteral
865
703
  child :type
866
704
  child :member_inits, lambda{NodeArray.new}
867
705
  initializer :type, :member_inits
868
706
  end
869
- ###
870
- ### IntLiteral
871
- ###
707
+
872
708
  class IntLiteral
873
- field :val
874
709
  field :format, :dec
710
+ field :val
711
+ field :suffix
875
712
  initializer :val
876
713
  def dec?
877
714
  format.equal? :dec
@@ -883,23 +720,19 @@ module C
883
720
  format.equal? :oct
884
721
  end
885
722
  end
886
- ###
887
- ### FloatLiteral
888
- ###
723
+
889
724
  class FloatLiteral
725
+ field :format, :dec
890
726
  field :val
727
+ field :exponent
728
+ field :suffix
891
729
  initializer :val
892
730
  end
893
731
 
894
- ###
895
- ### ----------------------------------------------------------------
896
- ### Types
897
- ### ----------------------------------------------------------------
898
- ###
732
+ # ------------------------------------------------------------------
733
+ # Types
734
+ # ------------------------------------------------------------------
899
735
 
900
- ###
901
- ### DirectType (abstract)
902
- ###
903
736
  class DirectType
904
737
  def direct_type
905
738
  self
@@ -908,9 +741,7 @@ module C
908
741
  nil
909
742
  end
910
743
  end
911
- ###
912
- ### IndirectType (abstract)
913
- ###
744
+
914
745
  class IndirectType
915
746
  def direct_type
916
747
  if type.is_a? IndirectType
@@ -919,7 +750,7 @@ module C
919
750
  type
920
751
  end
921
752
  end
922
- def direct_type= val
753
+ def direct_type=(val)
923
754
  if type.is_a? IndirectType
924
755
  type.direct_type = val
925
756
  else
@@ -936,9 +767,7 @@ module C
936
767
  return ret
937
768
  end
938
769
  end
939
- ###
940
- ### Pointer
941
- ###
770
+
942
771
  class Pointer
943
772
  field :const?
944
773
  field :restrict?
@@ -946,9 +775,7 @@ module C
946
775
  child :type
947
776
  initializer :type
948
777
  end
949
- ###
950
- ### Array
951
- ###
778
+
952
779
  class Array
953
780
  field :const?
954
781
  field :restrict?
@@ -957,9 +784,7 @@ module C
957
784
  child :length
958
785
  initializer :type, :length
959
786
  end
960
- ###
961
- ### Function
962
- ###
787
+
963
788
  class Function
964
789
  field :const?
965
790
  field :restrict?
@@ -969,9 +794,7 @@ module C
969
794
  field :var_args?
970
795
  initializer :type, :params
971
796
  end
972
- ###
973
- ### Struct
974
- ###
797
+
975
798
  class Struct
976
799
  field :const?
977
800
  field :restrict?
@@ -980,9 +803,7 @@ module C
980
803
  child :members
981
804
  initializer :name, :members
982
805
  end
983
- ###
984
- ### Union
985
- ###
806
+
986
807
  class Union
987
808
  field :const?
988
809
  field :restrict?
@@ -991,9 +812,7 @@ module C
991
812
  child :members
992
813
  initializer :name, :members
993
814
  end
994
- ###
995
- ### Enum
996
- ###
815
+
997
816
  class Enum
998
817
  field :const?
999
818
  field :restrict?
@@ -1002,9 +821,7 @@ module C
1002
821
  child :members
1003
822
  initializer :name, :members
1004
823
  end
1005
- ###
1006
- ### CustomType
1007
- ###
824
+
1008
825
  class CustomType
1009
826
  field :const?
1010
827
  field :restrict?
@@ -1012,17 +829,13 @@ module C
1012
829
  field :name
1013
830
  initializer :name
1014
831
  end
1015
- ###
1016
- ### Void
1017
- ###
832
+
1018
833
  class Void
1019
834
  field :const?
1020
835
  field :restrict?
1021
836
  field :volatile?
1022
837
  end
1023
- ###
1024
- ### Int
1025
- ###
838
+
1026
839
  class Int
1027
840
  field :const?
1028
841
  field :restrict?
@@ -1033,11 +846,11 @@ module C
1033
846
  def signed?
1034
847
  !unsigned?
1035
848
  end
1036
- def signed= val
849
+ def signed=(val)
1037
850
  self.unsigned = !val
1038
851
  end
1039
852
  def short?
1040
- longness.equal? -1
853
+ longness.equal?(-1)
1041
854
  end
1042
855
  def plain?
1043
856
  longness.equal? 0
@@ -1049,9 +862,7 @@ module C
1049
862
  longness.equal? 2
1050
863
  end
1051
864
  end
1052
- ###
1053
- ### Float
1054
- ###
865
+
1055
866
  class Float
1056
867
  field :const?
1057
868
  field :restrict?
@@ -1068,15 +879,13 @@ module C
1068
879
  longness.equal? 2
1069
880
  end
1070
881
  end
1071
- ###
1072
- ### Char
1073
- ###
882
+
1074
883
  class Char
1075
884
  field :const?
1076
885
  field :restrict?
1077
886
  field :volatile?
1078
- ## 6.2.5p15: `char', `signed char', and `unsigned char' are
1079
- ## distinct types
887
+ # 6.2.5p15: `char', `signed char', and `unsigned char' are
888
+ # distinct types
1080
889
  field :signed
1081
890
  def signed?
1082
891
  signed.equal? true
@@ -1088,17 +897,13 @@ module C
1088
897
  signed.nil?
1089
898
  end
1090
899
  end
1091
- ###
1092
- ### Bool
1093
- ###
900
+
1094
901
  class Bool
1095
902
  field :const?
1096
903
  field :restrict?
1097
904
  field :volatile?
1098
905
  end
1099
- ###
1100
- ### Complex
1101
- ###
906
+
1102
907
  class Complex
1103
908
  field :const?
1104
909
  field :restrict?
@@ -1115,9 +920,7 @@ module C
1115
920
  longness.equal? 2
1116
921
  end
1117
922
  end
1118
- ###
1119
- ### Imaginary
1120
- ###
923
+
1121
924
  class Imaginary
1122
925
  field :const?
1123
926
  field :restrict?
@@ -1135,26 +938,22 @@ module C
1135
938
  end
1136
939
  end
1137
940
 
1138
- ###
1139
- ### ================================================================
1140
- ###
1141
- ### Tag classes
1142
- ###
1143
- ### ================================================================
1144
- ###
941
+ # ------------------------------------------------------------------
942
+ # Tag classes
943
+ # ------------------------------------------------------------------
1145
944
 
1146
- ## classify the node classes by including modules
945
+ # classify the node classes by including modules
1147
946
  tagger = lambda do |included, *includers|
1148
947
  includers.each{|mod| mod.send(:include, included)}
1149
948
  end
1150
949
 
1151
- ## expression classes
950
+ # expression classes
1152
951
  module ArithmeticExpression; end
1153
952
  module BitwiseExpression ; end
1154
953
  module LogicalExpression ; end
1155
954
  module RelationalExpression; end
1156
955
  module ShiftExpression ; end
1157
- ##
956
+ #
1158
957
  tagger.call(ArithmeticExpression,
1159
958
  PostInc, PostDec, Positive, Negative, PreInc, PreDec, Add,
1160
959
  Subtract, Multiply, Divide, Mod)
@@ -1167,13 +966,9 @@ module C
1167
966
  tagger.call(ShiftExpression,
1168
967
  ShiftLeft, ShiftRight)
1169
968
 
1170
- ###
1171
- ### ================================================================
1172
- ###
1173
- ### CORE_C_NODE_CLASSES
1174
- ###
1175
- ### ================================================================
1176
- ###
969
+ # ------------------------------------------------------------------
970
+ # CORE_C_NODE_CLASSES
971
+ # ------------------------------------------------------------------
1177
972
 
1178
973
  CORE_C_NODE_CLASSES = [
1179
974
  TranslationUnit,
@@ -1203,6 +998,7 @@ module C
1203
998
  Comma,
1204
999
  Conditional,
1205
1000
  Variable,
1001
+ BlockExpression,
1206
1002
 
1207
1003
  Index,
1208
1004
  Call,
@@ -1277,7 +1073,7 @@ module C
1277
1073
  Imaginary
1278
1074
  ]
1279
1075
 
1280
- ## check we didn't miss any
1076
+ # check we didn't miss any
1281
1077
  expected_classes = Node.subclasses_recursive.sort_by{|c| c.name}
1282
1078
  expected_classes -= NodeList.subclasses_recursive
1283
1079
  expected_classes -= [NodeList]
@@ -1296,6 +1092,6 @@ module C
1296
1092
  DirectType,
1297
1093
  PrimitiveType
1298
1094
  ]
1299
- ##
1095
+ #
1300
1096
  CORE_C_NODE_CLASSES.sort_by{|c| c.name} == expected_classes or raise
1301
1097
  end