casty 0.3.1

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