2 #import xml.etree.ElementTree
10 enclosing_loop = None,
11 translate_identifier = {
20 self.top_level = top_level
21 self.enclosing_loop = enclosing_loop
22 self.translate_identifier = translate_identifier
24 class AST(element.Element):
26 class Text(element.Element):
27 # GENERATE ELEMENT() BEGIN
35 element.Element.__init__(
42 def copy(self, factory = None):
43 result = element.Element.copy(
45 Text if factory is None else factory
50 self.repr_serialize(params)
51 return 'ast.AST.Text({0:s})'.format(', '.join(params))
54 class DeclarationOrStatement(element.Element):
55 # GENERATE ELEMENT() BEGIN
58 tag = 'AST_DeclarationOrStatement',
63 element.Element.__init__(
70 def copy(self, factory = None):
71 result = element.Element.copy(
73 DeclarationOrStatement if factory is None else factory
78 self.repr_serialize(params)
79 return 'ast.AST.DeclarationOrStatement({0:s})'.format(', '.join(params))
81 def translate_declaration_or_statement(self, context):
82 #text = element.to_text(self).strip()
83 #assert text[-1] == ';'
84 #context.lines.append(
85 # '{0:s}{1:s}\n'.format(context.indent, text[:-1])
88 raise NotImplementedError
90 class Statement(DeclarationOrStatement):
91 # GENERATE ELEMENT() BEGIN
94 tag = 'AST_Statement',
99 AST.DeclarationOrStatement.__init__(
106 def copy(self, factory = None):
107 result = AST.DeclarationOrStatement.copy(
109 Statement if factory is None else factory
114 self.repr_serialize(params)
115 return 'ast.AST.Statement({0:s})'.format(', '.join(params))
118 class Declarator(element.Element):
119 # GENERATE ELEMENT() BEGIN
122 tag = 'AST_Declarator',
127 element.Element.__init__(
134 def copy(self, factory = None):
135 result = element.Element.copy(
137 Declarator if factory is None else factory
142 self.repr_serialize(params)
143 return 'ast.AST.Declarator({0:s})'.format(', '.join(params))
145 def get_type_and_name(self, base_type):
147 raise NotImplementedError
149 class Expression(element.Element):
150 # GENERATE ELEMENT() BEGIN
153 tag = 'AST_Expression',
158 element.Element.__init__(
165 def copy(self, factory = None):
166 result = element.Element.copy(
168 Expression if factory is None else factory
173 self.repr_serialize(params)
174 return 'ast.AST.Expression({0:s})'.format(', '.join(params))
176 def translate_expression(self, context, precedence):
177 #return element.to_text(self).strip()
179 raise NotImplementedError
180 def translate_statement_expression(self, context):
181 return self.translate_expression(context, 0)
183 class ExpressionUnary(Expression):
184 # GENERATE ELEMENT(str unary_operator, bool postfix) BEGIN
187 tag = 'AST_ExpressionUnary',
194 AST.Expression.__init__(
201 self.unary_operator = unary_operator
203 element.deserialize_bool(postfix)
204 if isinstance(postfix, str) else
207 def serialize(self, ref_list):
208 AST.Expression.serialize(self, ref_list)
209 self.set('unary_operator', element.serialize_str(self.unary_operator))
210 self.set('postfix', element.serialize_bool(self.postfix))
211 def deserialize(self, ref_list):
212 AST.Expression.deserialize(self, ref_list)
213 self.unary_operator = element.deserialize_str(self.get('unary_operator', ''))
214 self.postfix = element.deserialize_bool(self.get('postfix', 'false'))
215 def copy(self, factory = None):
216 result = AST.Expression.copy(
218 ExpressionUnary if factory is None else factory
220 result.unary_operator = self.unary_operator
221 result.postfix = self.postfix
223 def repr_serialize(self, params):
224 AST.Expression.repr_serialize(self, params)
225 if self.unary_operator != '':
227 'unary_operator = {0:s}'.format(repr(self.unary_operator))
229 if self.postfix != False:
231 'postfix = {0:s}'.format(repr(self.postfix))
235 self.repr_serialize(params)
236 return 'ast.AST.ExpressionUnary({0:s})'.format(', '.join(params))
238 def translate_expression(self, context, precedence):
240 text = '{0:s}{1:s}'.format(
241 self[0].translate_expression(context, 14),
245 text = '({0:s})'.format(text)
247 text = '{0:s}{1:s}'.format(
249 self[0].translate_expression(context, 13)
252 text = '({0:s})'.format(text)
255 class ExpressionBinary(Expression):
256 # GENERATE ELEMENT(str binary_operator, int precedence, bool right_to_left) BEGIN
259 tag = 'AST_ExpressionBinary',
263 binary_operator = '',
265 right_to_left = False
267 AST.Expression.__init__(
274 self.binary_operator = binary_operator
276 element.deserialize_int(precedence)
277 if isinstance(precedence, str) else
280 self.right_to_left = (
281 element.deserialize_bool(right_to_left)
282 if isinstance(right_to_left, str) else
285 def serialize(self, ref_list):
286 AST.Expression.serialize(self, ref_list)
287 self.set('binary_operator', element.serialize_str(self.binary_operator))
288 self.set('precedence', element.serialize_int(self.precedence))
289 self.set('right_to_left', element.serialize_bool(self.right_to_left))
290 def deserialize(self, ref_list):
291 AST.Expression.deserialize(self, ref_list)
292 self.binary_operator = element.deserialize_str(self.get('binary_operator', ''))
293 self.precedence = element.deserialize_int(self.get('precedence', '-1'))
294 self.right_to_left = element.deserialize_bool(self.get('right_to_left', 'false'))
295 def copy(self, factory = None):
296 result = AST.Expression.copy(
298 ExpressionBinary if factory is None else factory
300 result.binary_operator = self.binary_operator
301 result.precedence = self.precedence
302 result.right_to_left = self.right_to_left
304 def repr_serialize(self, params):
305 AST.Expression.repr_serialize(self, params)
306 if self.binary_operator != '':
308 'binary_operator = {0:s}'.format(repr(self.binary_operator))
310 if self.precedence != -1:
312 'precedence = {0:s}'.format(repr(self.precedence))
314 if self.right_to_left != False:
316 'right_to_left = {0:s}'.format(repr(self.right_to_left))
320 self.repr_serialize(params)
321 return 'ast.AST.ExpressionBinary({0:s})'.format(', '.join(params))
323 def translate_expression(self, context, precedence):
324 text = '{0:s}{1:s}{2:s}'.format(
325 self[0].translate_expression(
327 self.precedence + int(self.right_to_left)
329 self.binary_operator,
330 self[1].translate_expression(
332 self.precedence + int(not self.right_to_left)
335 if self.precedence < precedence:
336 text = '({0:s})'.format(text)
340 class Type(element.Element):
341 # GENERATE ELEMENT() BEGIN
349 element.Element.__init__(
356 def copy(self, factory = None):
357 result = element.Element.copy(
359 Type if factory is None else factory
364 self.repr_serialize(params)
365 return 'ast.AST.Type({0:s})'.format(', '.join(params))
367 def translate_size(self, context):
369 raise NotImplementedError
370 def translate_type(self, context):
372 raise NotImplementedError
373 def translate_zero(self, context):
375 raise NotImplementedError
377 class TypeVoid(Type):
378 # GENERATE ELEMENT() BEGIN
381 tag = 'AST_TypeVoid',
393 def copy(self, factory = None):
394 result = AST.Type.copy(
396 TypeVoid if factory is None else factory
401 self.repr_serialize(params)
402 return 'ast.AST.TypeVoid({0:s})'.format(', '.join(params))
408 # GENERATE ELEMENT(bool signed, int bits) BEGIN
426 element.deserialize_bool(signed)
427 if isinstance(signed, str) else
431 element.deserialize_int(bits)
432 if isinstance(bits, str) else
435 def serialize(self, ref_list):
436 AST.Type.serialize(self, ref_list)
437 self.set('signed', element.serialize_bool(self.signed))
438 self.set('bits', element.serialize_int(self.bits))
439 def deserialize(self, ref_list):
440 AST.Type.deserialize(self, ref_list)
441 self.signed = element.deserialize_bool(self.get('signed', 'false'))
442 self.bits = element.deserialize_int(self.get('bits', '-1'))
443 def copy(self, factory = None):
444 result = AST.Type.copy(
446 TypeInt if factory is None else factory
448 result.signed = self.signed
449 result.bits = self.bits
451 def repr_serialize(self, params):
452 AST.Type.repr_serialize(self, params)
453 if self.signed != False:
455 'signed = {0:s}'.format(repr(self.signed))
459 'bits = {0:s}'.format(repr(self.bits))
463 self.repr_serialize(params)
464 return 'ast.AST.TypeInt({0:s})'.format(', '.join(params))
467 return '{0:s}int{1:d}'.format(['u', ''][int(self.signed)], self.bits)
468 def translate_size(self, context):
469 return (self.bits + 7) // 8
470 def translate_type(self, context):
472 def translate_zero(self, context):
473 return '0' if context.top_level else 'None'
475 class TypeFloat(Type):
476 # GENERATE ELEMENT(int complex, int bits) BEGIN
479 tag = 'AST_TypeFloat',
494 element.deserialize_int(complex)
495 if isinstance(complex, str) else
499 element.deserialize_int(bits)
500 if isinstance(bits, str) else
503 def serialize(self, ref_list):
504 AST.Type.serialize(self, ref_list)
505 self.set('complex', element.serialize_int(self.complex))
506 self.set('bits', element.serialize_int(self.bits))
507 def deserialize(self, ref_list):
508 AST.Type.deserialize(self, ref_list)
509 self.complex = element.deserialize_int(self.get('complex', '-1'))
510 self.bits = element.deserialize_int(self.get('bits', '-1'))
511 def copy(self, factory = None):
512 result = AST.Type.copy(
514 TypeFloat if factory is None else factory
516 result.complex = self.complex
517 result.bits = self.bits
519 def repr_serialize(self, params):
520 AST.Type.repr_serialize(self, params)
521 if self.complex != -1:
523 'complex = {0:s}'.format(repr(self.complex))
527 'bits = {0:s}'.format(repr(self.bits))
531 self.repr_serialize(params)
532 return 'ast.AST.TypeFloat({0:s})'.format(', '.join(params))
535 return '{0:s}float{0:d}'.format(
536 ['', 'i', 'c'][int(self.complex)],
539 def translate_size(self, context):
540 return (self.bits + 7) // 8
541 def translate_type(self, context):
543 def translate_zero(self, context):
544 return '0.' if context.top_level else 'None'
546 class TypeBool(Type):
547 # GENERATE ELEMENT() BEGIN
550 tag = 'AST_TypeBool',
562 def copy(self, factory = None):
563 result = AST.Type.copy(
565 TypeBool if factory is None else factory
570 self.repr_serialize(params)
571 return 'ast.AST.TypeBool({0:s})'.format(', '.join(params))
575 def translate_size(self, context):
577 def translate_type(self, context):
579 def translate_zero(self, context):
580 return 'False' if context.top_level else 'None'
582 class TypePointer(Type):
583 # GENERATE ELEMENT(ref target_type) BEGIN
586 tag = 'AST_TypePointer',
599 self.target_type = target_type
600 def serialize(self, ref_list):
601 AST.Type.serialize(self, ref_list)
602 self.set('target_type', element.serialize_ref(self.target_type, ref_list))
603 def deserialize(self, ref_list):
604 AST.Type.deserialize(self, ref_list)
605 self.target_type = element.deserialize_ref(self.get('target_type', '-1'), ref_list)
606 def copy(self, factory = None):
607 result = AST.Type.copy(
609 TypePointer if factory is None else factory
611 result.target_type = self.target_type
613 def repr_serialize(self, params):
614 AST.Type.repr_serialize(self, params)
615 if self.target_type != None:
617 'target_type = {0:s}'.format(repr(self.target_type))
621 self.repr_serialize(params)
622 return 'ast.AST.TypePointer({0:s})'.format(', '.join(params))
625 return 'pointer<{0:s}>'.format(str(self.target_type))
626 def translate_size(self, context):
628 def translate_type(self, context):
630 isinstance(self.target_type, AST.TypeInt) and
631 self.target_type.bits == 8
634 def translate_zero(self, context):
636 isinstance(self.target_type, AST.TypeInt) and
637 self.target_type.bits == 8
639 return '\'\'' if context.top_level else 'None'
641 class TypeArray(Type):
642 # GENERATE ELEMENT(ref element_type, int element_count) BEGIN
645 tag = 'AST_TypeArray',
659 self.element_type = element_type
660 self.element_count = (
661 element.deserialize_int(element_count)
662 if isinstance(element_count, str) else
665 def serialize(self, ref_list):
666 AST.Type.serialize(self, ref_list)
667 self.set('element_type', element.serialize_ref(self.element_type, ref_list))
668 self.set('element_count', element.serialize_int(self.element_count))
669 def deserialize(self, ref_list):
670 AST.Type.deserialize(self, ref_list)
671 self.element_type = element.deserialize_ref(self.get('element_type', '-1'), ref_list)
672 self.element_count = element.deserialize_int(self.get('element_count', '-1'))
673 def copy(self, factory = None):
674 result = AST.Type.copy(
676 TypeArray if factory is None else factory
678 result.element_type = self.element_type
679 result.element_count = self.element_count
681 def repr_serialize(self, params):
682 AST.Type.repr_serialize(self, params)
683 if self.element_type != None:
685 'element_type = {0:s}'.format(repr(self.element_type))
687 if self.element_count != -1:
689 'element_count = {0:s}'.format(repr(self.element_count))
693 self.repr_serialize(params)
694 return 'ast.AST.TypeArray({0:s})'.format(', '.join(params))
697 return 'array<{0:s}: {1:s}>'.format(
698 str(self.element_type),
701 if self.element_count == -1 else
703 if self.element_count == -2 else
704 str(self.element_count)
707 def translate_size(self, context):
708 return self.element_type.translate_type(context) * self.element_count
709 def translate_zero(self, context):
710 return '[{0:s}]'.format(
712 [self.element_type.translate_zero(context)] * self.element_count
716 class TypeFunction(Type):
717 class Argument(element.Element):
718 # GENERATE ELEMENT(ref type, str name) BEGIN
721 tag = 'AST_TypeFunction_Argument',
728 element.Element.__init__(
737 def serialize(self, ref_list):
738 element.Element.serialize(self, ref_list)
739 self.set('type', element.serialize_ref(self.type, ref_list))
740 self.set('name', element.serialize_str(self.name))
741 def deserialize(self, ref_list):
742 element.Element.deserialize(self, ref_list)
743 self.type = element.deserialize_ref(self.get('type', '-1'), ref_list)
744 self.name = element.deserialize_str(self.get('name', ''))
745 def copy(self, factory = None):
746 result = element.Element.copy(
748 Argument if factory is None else factory
750 result.type = self.type
751 result.name = self.name
753 def repr_serialize(self, params):
754 element.Element.repr_serialize(self, params)
755 if self.type != None:
757 'type = {0:s}'.format(repr(self.type))
761 'name = {0:s}'.format(repr(self.name))
765 self.repr_serialize(params)
766 return 'ast.AST.TypeFunction.Argument({0:s})'.format(', '.join(params))
769 return '{0:s} {1:s}'.format(
771 'ABSTRACT' if self.name == '' else self.name
774 # GENERATE ELEMENT(ref return_type, bool varargs) BEGIN
777 tag = 'AST_TypeFunction',
791 self.return_type = return_type
793 element.deserialize_bool(varargs)
794 if isinstance(varargs, str) else
797 def serialize(self, ref_list):
798 AST.Type.serialize(self, ref_list)
799 self.set('return_type', element.serialize_ref(self.return_type, ref_list))
800 self.set('varargs', element.serialize_bool(self.varargs))
801 def deserialize(self, ref_list):
802 AST.Type.deserialize(self, ref_list)
803 self.return_type = element.deserialize_ref(self.get('return_type', '-1'), ref_list)
804 self.varargs = element.deserialize_bool(self.get('varargs', 'false'))
805 def copy(self, factory = None):
806 result = AST.Type.copy(
808 TypeFunction if factory is None else factory
810 result.return_type = self.return_type
811 result.varargs = self.varargs
813 def repr_serialize(self, params):
814 AST.Type.repr_serialize(self, params)
815 if self.return_type != None:
817 'return_type = {0:s}'.format(repr(self.return_type))
819 if self.varargs != False:
821 'varargs = {0:s}'.format(repr(self.varargs))
825 self.repr_serialize(params)
826 return 'ast.AST.TypeFunction({0:s})'.format(', '.join(params))
829 return 'function<{0:s} -> {1:s}>'.format(
832 if len(self) == 0 else
834 [str(i) for i in self] + (['...'] if self.varargs else [])
837 str(self.return_type)
841 class AlignAsExpression(element.Element):
842 # GENERATE ELEMENT() BEGIN
845 tag = 'AST_AlignAsExpression',
850 element.Element.__init__(
857 def copy(self, factory = None):
858 result = element.Element.copy(
860 AlignAsExpression if factory is None else factory
865 self.repr_serialize(params)
866 return 'ast.AST.AlignAsExpression({0:s})'.format(', '.join(params))
869 class AlignAsType(element.Element):
870 # GENERATE ELEMENT() BEGIN
873 tag = 'AST_AlignAsType',
878 element.Element.__init__(
885 def copy(self, factory = None):
886 result = element.Element.copy(
888 AlignAsType if factory is None else factory
893 self.repr_serialize(params)
894 return 'ast.AST.AlignAsType({0:s})'.format(', '.join(params))
897 class ArgumentExpressionList(element.Element):
898 # GENERATE ELEMENT() BEGIN
901 tag = 'AST_ArgumentExpressionList',
906 element.Element.__init__(
913 def copy(self, factory = None):
914 result = element.Element.copy(
916 ArgumentExpressionList if factory is None else factory
921 self.repr_serialize(params)
922 return 'ast.AST.ArgumentExpressionList({0:s})'.format(', '.join(params))
925 class BlockItemList(element.Element):
926 # GENERATE ELEMENT() BEGIN
929 tag = 'AST_BlockItemList',
934 element.Element.__init__(
941 def copy(self, factory = None):
942 result = element.Element.copy(
944 BlockItemList if factory is None else factory
949 self.repr_serialize(params)
950 return 'ast.AST.BlockItemList({0:s})'.format(', '.join(params))
952 def translate_block_item_list(self, context):
954 i.translate_declaration_or_statement(context)
956 class Declaration(DeclarationOrStatement):
957 # GENERATE ELEMENT() BEGIN
960 tag = 'AST_Declaration',
965 AST.DeclarationOrStatement.__init__(
972 def copy(self, factory = None):
973 result = AST.DeclarationOrStatement.copy(
975 Declaration if factory is None else factory
980 self.repr_serialize(params)
981 return 'ast.AST.Declaration({0:s})'.format(', '.join(params))
983 def translate_declaration_or_statement(self, context):
984 base_type = self[0].get_type()
986 type, name = i[0].get_type_and_name(base_type)
987 if not isinstance(type, AST.TypeFunction):
988 context.lines.append(
989 '{0:s}{1:s} = {2:s}\n'.format(
993 type.translate_zero(context)
994 if isinstance(i[1], AST.EqualsInitializerEmpty) else
995 i[1].translate_expression(context, 0)
1000 class DeclarationList(element.Element):
1001 # GENERATE ELEMENT() BEGIN
1004 tag = 'AST_DeclarationList',
1009 element.Element.__init__(
1016 def copy(self, factory = None):
1017 result = element.Element.copy(
1019 DeclarationList if factory is None else factory
1024 self.repr_serialize(params)
1025 return 'ast.AST.DeclarationList({0:s})'.format(', '.join(params))
1028 class DeclarationSpecifierList(element.Element):
1029 # GENERATE ELEMENT() BEGIN
1032 tag = 'AST_DeclarationSpecifierList',
1037 element.Element.__init__(
1044 def copy(self, factory = None):
1045 result = element.Element.copy(
1047 DeclarationSpecifierList if factory is None else factory
1052 self.repr_serialize(params)
1053 return 'ast.AST.DeclarationSpecifierList({0:s})'.format(', '.join(params))
1056 type_specifiers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
1058 if isinstance(i, AST.TypeSpecifier):
1059 type_specifiers[i.n] += 1
1060 return type_specifiers_to_type[tuple(type_specifiers)]
1062 class DeclaratorAbstract(Declarator):
1063 # GENERATE ELEMENT() BEGIN
1066 tag = 'AST_DeclaratorAbstract',
1071 AST.Declarator.__init__(
1078 def copy(self, factory = None):
1079 result = AST.Declarator.copy(
1081 DeclaratorAbstract if factory is None else factory
1086 self.repr_serialize(params)
1087 return 'ast.AST.DeclaratorAbstract({0:s})'.format(', '.join(params))
1089 def get_type_and_name(self, base_type):
1090 return base_type, ''
1092 class DeclaratorArray(Declarator):
1093 # GENERATE ELEMENT() BEGIN
1096 tag = 'AST_DeclaratorArray',
1101 AST.Declarator.__init__(
1108 def copy(self, factory = None):
1109 result = AST.Declarator.copy(
1111 DeclaratorArray if factory is None else factory
1116 self.repr_serialize(params)
1117 return 'ast.AST.DeclaratorArray({0:s})'.format(', '.join(params))
1119 def get_type_and_name(self, base_type):
1120 return self[0].get_type_and_name(
1122 element_type = base_type,
1123 element_count = int(
1124 element.get_text(self[2], 0),
1125 8 if element.get_text(self[2], 0)[:2] in octal_prefix else 0
1130 class DeclaratorEmpty(Declarator):
1131 # GENERATE ELEMENT() BEGIN
1134 tag = 'AST_DeclaratorEmpty',
1139 AST.Declarator.__init__(
1146 def copy(self, factory = None):
1147 result = AST.Declarator.copy(
1149 DeclaratorEmpty if factory is None else factory
1154 self.repr_serialize(params)
1155 return 'ast.AST.DeclaratorEmpty({0:s})'.format(', '.join(params))
1158 class DeclaratorFunction(Declarator):
1159 # GENERATE ELEMENT(bool varargs) BEGIN
1162 tag = 'AST_DeclaratorFunction',
1168 AST.Declarator.__init__(
1176 element.deserialize_bool(varargs)
1177 if isinstance(varargs, str) else
1180 def serialize(self, ref_list):
1181 AST.Declarator.serialize(self, ref_list)
1182 self.set('varargs', element.serialize_bool(self.varargs))
1183 def deserialize(self, ref_list):
1184 AST.Declarator.deserialize(self, ref_list)
1185 self.varargs = element.deserialize_bool(self.get('varargs', 'false'))
1186 def copy(self, factory = None):
1187 result = AST.Declarator.copy(
1189 DeclaratorFunction if factory is None else factory
1191 result.varargs = self.varargs
1193 def repr_serialize(self, params):
1194 AST.Declarator.repr_serialize(self, params)
1195 if self.varargs != False:
1197 'varargs = {0:s}'.format(repr(self.varargs))
1201 self.repr_serialize(params)
1202 return 'ast.AST.DeclaratorFunction({0:s})'.format(', '.join(params))
1204 def get_type_and_name(self, base_type):
1207 type, name = i[1].get_type_and_name(i[0].get_type())
1208 children.append(AST.TypeFunction.Argument(type = type, name = name))
1209 return self[0].get_type_and_name(
1211 children = children,
1212 return_type = base_type,
1213 varargs = self.varargs,
1217 class DeclaratorFunctionOldStyle(Declarator):
1218 # GENERATE ELEMENT() BEGIN
1221 tag = 'AST_DeclaratorFunctionOldStyle',
1226 AST.Declarator.__init__(
1233 def copy(self, factory = None):
1234 result = AST.Declarator.copy(
1236 DeclaratorFunctionOldStyle if factory is None else factory
1241 self.repr_serialize(params)
1242 return 'ast.AST.DeclaratorFunctionOldStyle({0:s})'.format(', '.join(params))
1245 class DeclaratorIdentifier(Declarator):
1246 # GENERATE ELEMENT() BEGIN
1249 tag = 'AST_DeclaratorIdentifier',
1254 AST.Declarator.__init__(
1261 def copy(self, factory = None):
1262 result = AST.Declarator.copy(
1264 DeclaratorIdentifier if factory is None else factory
1269 self.repr_serialize(params)
1270 return 'ast.AST.DeclaratorIdentifier({0:s})'.format(', '.join(params))
1272 def get_type_and_name(self, base_type):
1273 return base_type, element.get_text(self[0], 0)
1275 class DeclaratorPointer(Declarator):
1276 # GENERATE ELEMENT() BEGIN
1279 tag = 'AST_DeclaratorPointer',
1284 AST.Declarator.__init__(
1291 def copy(self, factory = None):
1292 result = AST.Declarator.copy(
1294 DeclaratorPointer if factory is None else factory
1299 self.repr_serialize(params)
1300 return 'ast.AST.DeclaratorPointer({0:s})'.format(', '.join(params))
1302 def get_type_and_name(self, base_type):
1303 return self[1].get_type_and_name(
1304 AST.TypePointer(target_type = base_type)
1307 class DefaultTypeName(element.Element):
1308 # GENERATE ELEMENT() BEGIN
1311 tag = 'AST_DefaultTypeName',
1316 element.Element.__init__(
1323 def copy(self, factory = None):
1324 result = element.Element.copy(
1326 DefaultTypeName if factory is None else factory
1331 self.repr_serialize(params)
1332 return 'ast.AST.DefaultTypeName({0:s})'.format(', '.join(params))
1335 class DesignatorField(element.Element):
1336 # GENERATE ELEMENT() BEGIN
1339 tag = 'AST_DesignatorField',
1344 element.Element.__init__(
1351 def copy(self, factory = None):
1352 result = element.Element.copy(
1354 DesignatorField if factory is None else factory
1359 self.repr_serialize(params)
1360 return 'ast.AST.DesignatorField({0:s})'.format(', '.join(params))
1363 class DesignatorIndex(element.Element):
1364 # GENERATE ELEMENT() BEGIN
1367 tag = 'AST_DesignatorIndex',
1372 element.Element.__init__(
1379 def copy(self, factory = None):
1380 result = element.Element.copy(
1382 DesignatorIndex if factory is None else factory
1387 self.repr_serialize(params)
1388 return 'ast.AST.DesignatorIndex({0:s})'.format(', '.join(params))
1391 class DesignatorInitializer(element.Element):
1392 # GENERATE ELEMENT() BEGIN
1395 tag = 'AST_DesignatorInitializer',
1400 element.Element.__init__(
1407 def copy(self, factory = None):
1408 result = element.Element.copy(
1410 DesignatorInitializer if factory is None else factory
1415 self.repr_serialize(params)
1416 return 'ast.AST.DesignatorInitializer({0:s})'.format(', '.join(params))
1419 class DesignatorInitializerList(element.Element):
1420 # GENERATE ELEMENT() BEGIN
1423 tag = 'AST_DesignatorInitializerList',
1428 element.Element.__init__(
1435 def copy(self, factory = None):
1436 result = element.Element.copy(
1438 DesignatorInitializerList if factory is None else factory
1443 self.repr_serialize(params)
1444 return 'ast.AST.DesignatorInitializerList({0:s})'.format(', '.join(params))
1447 class DesignatorList(element.Element):
1448 # GENERATE ELEMENT() BEGIN
1451 tag = 'AST_DesignatorList',
1456 element.Element.__init__(
1463 def copy(self, factory = None):
1464 result = element.Element.copy(
1466 DesignatorList if factory is None else factory
1471 self.repr_serialize(params)
1472 return 'ast.AST.DesignatorList({0:s})'.format(', '.join(params))
1475 class EnumSpecifier(element.Element):
1476 # GENERATE ELEMENT() BEGIN
1479 tag = 'AST_EnumSpecifier',
1484 element.Element.__init__(
1491 def copy(self, factory = None):
1492 result = element.Element.copy(
1494 EnumSpecifier if factory is None else factory
1499 self.repr_serialize(params)
1500 return 'ast.AST.EnumSpecifier({0:s})'.format(', '.join(params))
1503 class Enumerator(element.Element):
1504 # GENERATE ELEMENT() BEGIN
1507 tag = 'AST_Enumerator',
1512 element.Element.__init__(
1519 def copy(self, factory = None):
1520 result = element.Element.copy(
1522 Enumerator if factory is None else factory
1527 self.repr_serialize(params)
1528 return 'ast.AST.Enumerator({0:s})'.format(', '.join(params))
1531 class EnumeratorList(element.Element):
1532 # GENERATE ELEMENT() BEGIN
1535 tag = 'AST_EnumeratorList',
1540 element.Element.__init__(
1547 def copy(self, factory = None):
1548 result = element.Element.copy(
1550 EnumeratorList if factory is None else factory
1555 self.repr_serialize(params)
1556 return 'ast.AST.EnumeratorList({0:s})'.format(', '.join(params))
1559 class EqualsInitializerEmpty(element.Element):
1560 # GENERATE ELEMENT() BEGIN
1563 tag = 'AST_EqualsInitializerEmpty',
1568 element.Element.__init__(
1575 def copy(self, factory = None):
1576 result = element.Element.copy(
1578 EqualsInitializerEmpty if factory is None else factory
1583 self.repr_serialize(params)
1584 return 'ast.AST.EqualsInitializerEmpty({0:s})'.format(', '.join(params))
1587 class ExpressionAdd(ExpressionBinary):
1588 # GENERATE ELEMENT() BEGIN
1591 tag = 'AST_ExpressionAdd',
1595 binary_operator = '',
1597 right_to_left = False
1599 AST.ExpressionBinary.__init__(
1609 def copy(self, factory = None):
1610 result = AST.ExpressionBinary.copy(
1612 ExpressionAdd if factory is None else factory
1617 self.repr_serialize(params)
1618 return 'ast.AST.ExpressionAdd({0:s})'.format(', '.join(params))
1621 class ExpressionAddAssignment(ExpressionBinary):
1622 # GENERATE ELEMENT() BEGIN
1625 tag = 'AST_ExpressionAddAssignment',
1629 binary_operator = '',
1631 right_to_left = False
1633 AST.ExpressionBinary.__init__(
1643 def copy(self, factory = None):
1644 result = AST.ExpressionBinary.copy(
1646 ExpressionAddAssignment if factory is None else factory
1651 self.repr_serialize(params)
1652 return 'ast.AST.ExpressionAddAssignment({0:s})'.format(', '.join(params))
1655 class ExpressionAddressOf(ExpressionUnary):
1656 # GENERATE ELEMENT() BEGIN
1659 tag = 'AST_ExpressionAddressOf',
1663 unary_operator = '',
1666 AST.ExpressionUnary.__init__(
1675 def copy(self, factory = None):
1676 result = AST.ExpressionUnary.copy(
1678 ExpressionAddressOf if factory is None else factory
1683 self.repr_serialize(params)
1684 return 'ast.AST.ExpressionAddressOf({0:s})'.format(', '.join(params))
1687 class ExpressionAlignOfType(ExpressionUnary):
1688 # GENERATE ELEMENT() BEGIN
1691 tag = 'AST_ExpressionAlignOfType',
1695 unary_operator = '',
1698 AST.ExpressionUnary.__init__(
1707 def copy(self, factory = None):
1708 result = AST.ExpressionUnary.copy(
1710 ExpressionAlignOfType if factory is None else factory
1715 self.repr_serialize(params)
1716 return 'ast.AST.ExpressionAlignOfType({0:s})'.format(', '.join(params))
1719 class ExpressionArray(Expression):
1720 # GENERATE ELEMENT() BEGIN
1723 tag = 'AST_ExpressionArray',
1728 AST.Expression.__init__(
1735 def copy(self, factory = None):
1736 result = AST.Expression.copy(
1738 ExpressionArray if factory is None else factory
1743 self.repr_serialize(params)
1744 return 'ast.AST.ExpressionArray({0:s})'.format(', '.join(params))
1747 class ExpressionAssignment(ExpressionBinary):
1748 # GENERATE ELEMENT() BEGIN
1751 tag = 'AST_ExpressionAssignment',
1755 binary_operator = '',
1757 right_to_left = False
1759 AST.ExpressionBinary.__init__(
1769 def copy(self, factory = None):
1770 result = AST.ExpressionBinary.copy(
1772 ExpressionAssignment if factory is None else factory
1777 self.repr_serialize(params)
1778 return 'ast.AST.ExpressionAssignment({0:s})'.format(', '.join(params))
1781 class ExpressionAsterisk(Expression):
1782 # GENERATE ELEMENT() BEGIN
1785 tag = 'AST_ExpressionAsterisk',
1790 AST.Expression.__init__(
1797 def copy(self, factory = None):
1798 result = AST.Expression.copy(
1800 ExpressionAsterisk if factory is None else factory
1805 self.repr_serialize(params)
1806 return 'ast.AST.ExpressionAsterisk({0:s})'.format(', '.join(params))
1809 class ExpressionBitwiseAnd(ExpressionBinary):
1810 # GENERATE ELEMENT() BEGIN
1813 tag = 'AST_ExpressionBitwiseAnd',
1817 binary_operator = '',
1819 right_to_left = False
1821 AST.ExpressionBinary.__init__(
1831 def copy(self, factory = None):
1832 result = AST.ExpressionBinary.copy(
1834 ExpressionBitwiseAnd if factory is None else factory
1839 self.repr_serialize(params)
1840 return 'ast.AST.ExpressionBitwiseAnd({0:s})'.format(', '.join(params))
1843 class ExpressionBitwiseAndAssignment(ExpressionBinary):
1844 # GENERATE ELEMENT() BEGIN
1847 tag = 'AST_ExpressionBitwiseAndAssignment',
1851 binary_operator = '',
1853 right_to_left = False
1855 AST.ExpressionBinary.__init__(
1865 def copy(self, factory = None):
1866 result = AST.ExpressionBinary.copy(
1868 ExpressionBitwiseAndAssignment if factory is None else factory
1873 self.repr_serialize(params)
1874 return 'ast.AST.ExpressionBitwiseAndAssignment({0:s})'.format(', '.join(params))
1877 class ExpressionBitwiseNot(ExpressionUnary):
1878 # GENERATE ELEMENT() BEGIN
1881 tag = 'AST_ExpressionBitwiseNot',
1885 unary_operator = '',
1888 AST.ExpressionUnary.__init__(
1897 def copy(self, factory = None):
1898 result = AST.ExpressionUnary.copy(
1900 ExpressionBitwiseNot if factory is None else factory
1905 self.repr_serialize(params)
1906 return 'ast.AST.ExpressionBitwiseNot({0:s})'.format(', '.join(params))
1909 class ExpressionBitwiseOr(ExpressionBinary):
1910 # GENERATE ELEMENT() BEGIN
1913 tag = 'AST_ExpressionBitwiseOr',
1917 binary_operator = '',
1919 right_to_left = False
1921 AST.ExpressionBinary.__init__(
1931 def copy(self, factory = None):
1932 result = AST.ExpressionBinary.copy(
1934 ExpressionBitwiseOr if factory is None else factory
1939 self.repr_serialize(params)
1940 return 'ast.AST.ExpressionBitwiseOr({0:s})'.format(', '.join(params))
1943 class ExpressionBitwiseOrAssignment(ExpressionBinary):
1944 # GENERATE ELEMENT() BEGIN
1947 tag = 'AST_ExpressionBitwiseOrAssignment',
1951 binary_operator = '',
1953 right_to_left = False
1955 AST.ExpressionBinary.__init__(
1965 def copy(self, factory = None):
1966 result = AST.ExpressionBinary.copy(
1968 ExpressionBitwiseOrAssignment if factory is None else factory
1973 self.repr_serialize(params)
1974 return 'ast.AST.ExpressionBitwiseOrAssignment({0:s})'.format(', '.join(params))
1977 class ExpressionCall(Expression):
1978 # GENERATE ELEMENT() BEGIN
1981 tag = 'AST_ExpressionCall',
1986 AST.Expression.__init__(
1993 def copy(self, factory = None):
1994 result = AST.Expression.copy(
1996 ExpressionCall if factory is None else factory
2001 self.repr_serialize(params)
2002 return 'ast.AST.ExpressionCall({0:s})'.format(', '.join(params))
2004 def translate_expression(self, context, precedence):
2005 text = '{0:s}({1:s})'.format(
2006 self[0].translate_expression(context, 14),
2007 ', '.join([i.translate_expression(context, 1) for i in self[1]])
2010 text = '({0:s})'.format(text)
2013 class ExpressionCast(Expression):
2014 # GENERATE ELEMENT() BEGIN
2017 tag = 'AST_ExpressionCast',
2022 AST.Expression.__init__(
2029 def copy(self, factory = None):
2030 result = AST.Expression.copy(
2032 ExpressionCast if factory is None else factory
2037 self.repr_serialize(params)
2038 return 'ast.AST.ExpressionCast({0:s})'.format(', '.join(params))
2040 def translate_expression(self, context, precedence):
2041 type, _ = self[0][1].get_type_and_name(self[0][0].get_type())
2042 text = '{0:s}({1:s})'.format(
2043 type.translate_type(context),
2044 self[1].translate_expression(context, 0)
2047 text = '({0:s})'.format(text)
2050 class ExpressionCharConstant(Expression):
2051 # GENERATE ELEMENT() BEGIN
2054 tag = 'AST_ExpressionCharConstant',
2059 AST.Expression.__init__(
2066 def copy(self, factory = None):
2067 result = AST.Expression.copy(
2069 ExpressionCharConstant if factory is None else factory
2074 self.repr_serialize(params)
2075 return 'ast.AST.ExpressionCharConstant({0:s})'.format(', '.join(params))
2077 def translate_expression(self, context, precedence):
2078 return 'ord(\'{0:s}\')'.format(element.get_text(self[0], 0))
2080 class ExpressionComma(ExpressionBinary):
2081 # GENERATE ELEMENT() BEGIN
2084 tag = 'AST_ExpressionComma',
2088 binary_operator = '',
2090 right_to_left = False
2092 AST.ExpressionBinary.__init__(
2102 def copy(self, factory = None):
2103 result = AST.ExpressionBinary.copy(
2105 ExpressionComma if factory is None else factory
2110 self.repr_serialize(params)
2111 return 'ast.AST.ExpressionComma({0:s})'.format(', '.join(params))
2114 class ExpressionConditional(Expression):
2115 # GENERATE ELEMENT() BEGIN
2118 tag = 'AST_ExpressionConditional',
2123 AST.Expression.__init__(
2130 def copy(self, factory = None):
2131 result = AST.Expression.copy(
2133 ExpressionConditional if factory is None else factory
2138 self.repr_serialize(params)
2139 return 'ast.AST.ExpressionConditional({0:s})'.format(', '.join(params))
2141 def translate_expression(self, context, precedence):
2142 text = '{0:s} if {1:s} else {2:s}'.format(
2143 self[1].translate_expression(context, 3),
2144 self[0].translate_expression(context, 0),
2145 self[2].translate_expression(context, 2)
2148 text = '({0:s})'.format(text)
2151 class ExpressionDereference(ExpressionUnary):
2152 # GENERATE ELEMENT() BEGIN
2155 tag = 'AST_ExpressionDereference',
2159 unary_operator = '',
2162 AST.ExpressionUnary.__init__(
2171 def copy(self, factory = None):
2172 result = AST.ExpressionUnary.copy(
2174 ExpressionDereference if factory is None else factory
2179 self.repr_serialize(params)
2180 return 'ast.AST.ExpressionDereference({0:s})'.format(', '.join(params))
2183 class ExpressionDivide(ExpressionBinary):
2184 # GENERATE ELEMENT() BEGIN
2187 tag = 'AST_ExpressionDivide',
2191 binary_operator = '',
2193 right_to_left = False
2195 AST.ExpressionBinary.__init__(
2205 def copy(self, factory = None):
2206 result = AST.ExpressionBinary.copy(
2208 ExpressionDivide if factory is None else factory
2213 self.repr_serialize(params)
2214 return 'ast.AST.ExpressionDivide({0:s})'.format(', '.join(params))
2217 class ExpressionDivideAssignment(ExpressionBinary):
2218 # GENERATE ELEMENT() BEGIN
2221 tag = 'AST_ExpressionDivideAssignment',
2225 binary_operator = '',
2227 right_to_left = False
2229 AST.ExpressionBinary.__init__(
2239 def copy(self, factory = None):
2240 result = AST.ExpressionBinary.copy(
2242 ExpressionDivideAssignment if factory is None else factory
2247 self.repr_serialize(params)
2248 return 'ast.AST.ExpressionDivideAssignment({0:s})'.format(', '.join(params))
2251 class ExpressionEmpty(Expression):
2252 # GENERATE ELEMENT() BEGIN
2255 tag = 'AST_ExpressionEmpty',
2260 AST.Expression.__init__(
2267 def copy(self, factory = None):
2268 result = AST.Expression.copy(
2270 ExpressionEmpty if factory is None else factory
2275 self.repr_serialize(params)
2276 return 'ast.AST.ExpressionEmpty({0:s})'.format(', '.join(params))
2278 def translate_expression(self, context, precedence):
2280 def translate_statement_expression(self, context):
2283 class ExpressionEqual(ExpressionBinary):
2284 # GENERATE ELEMENT() BEGIN
2287 tag = 'AST_ExpressionEqual',
2291 binary_operator = '',
2293 right_to_left = False
2295 AST.ExpressionBinary.__init__(
2305 def copy(self, factory = None):
2306 result = AST.ExpressionBinary.copy(
2308 ExpressionEqual if factory is None else factory
2313 self.repr_serialize(params)
2314 return 'ast.AST.ExpressionEqual({0:s})'.format(', '.join(params))
2317 class ExpressionExclusiveOr(ExpressionBinary):
2318 # GENERATE ELEMENT() BEGIN
2321 tag = 'AST_ExpressionExclusiveOr',
2325 binary_operator = '',
2327 right_to_left = False
2329 AST.ExpressionBinary.__init__(
2339 def copy(self, factory = None):
2340 result = AST.ExpressionBinary.copy(
2342 ExpressionExclusiveOr if factory is None else factory
2347 self.repr_serialize(params)
2348 return 'ast.AST.ExpressionExclusiveOr({0:s})'.format(', '.join(params))
2351 class ExpressionExclusiveOrAssignment(ExpressionBinary):
2352 # GENERATE ELEMENT() BEGIN
2355 tag = 'AST_ExpressionExclusiveOrAssignment',
2359 binary_operator = '',
2361 right_to_left = False
2363 AST.ExpressionBinary.__init__(
2373 def copy(self, factory = None):
2374 result = AST.ExpressionBinary.copy(
2376 ExpressionExclusiveOrAssignment if factory is None else factory
2381 self.repr_serialize(params)
2382 return 'ast.AST.ExpressionExclusiveOrAssignment({0:s})'.format(', '.join(params))
2385 class ExpressionField(Expression):
2386 # GENERATE ELEMENT() BEGIN
2389 tag = 'AST_ExpressionField',
2394 AST.Expression.__init__(
2401 def copy(self, factory = None):
2402 result = AST.Expression.copy(
2404 ExpressionField if factory is None else factory
2409 self.repr_serialize(params)
2410 return 'ast.AST.ExpressionField({0:s})'.format(', '.join(params))
2412 def translate_expression(self, context, precedence):
2413 text = '{0:s}.{1:s}'.format(
2414 self[0].translate_expression(context, 14),
2415 self[1].translate_identifier(context)
2418 text = '({0:s})'.format(text)
2421 class ExpressionFieldDereference(Expression):
2422 # GENERATE ELEMENT() BEGIN
2425 tag = 'AST_ExpressionFieldDereference',
2430 AST.Expression.__init__(
2437 def copy(self, factory = None):
2438 result = AST.Expression.copy(
2440 ExpressionFieldDereference if factory is None else factory
2445 self.repr_serialize(params)
2446 return 'ast.AST.ExpressionFieldDereference({0:s})'.format(', '.join(params))
2448 def translate_expression(self, context, precedence):
2449 text = '{0:s}->{1:s}'.format(
2450 self[0].translate_expression(context, 14),
2451 self[1].translate_identifier(context)
2454 text = '({0:s})'.format(text)
2457 class ExpressionFloatLiteral(Expression):
2458 # GENERATE ELEMENT() BEGIN
2461 tag = 'AST_ExpressionFloatLiteral',
2466 AST.Expression.__init__(
2473 def copy(self, factory = None):
2474 result = AST.Expression.copy(
2476 ExpressionFloatLiteral if factory is None else factory
2481 self.repr_serialize(params)
2482 return 'ast.AST.ExpressionFloatLiteral({0:s})'.format(', '.join(params))
2485 class ExpressionFunctionName(Expression):
2486 # GENERATE ELEMENT() BEGIN
2489 tag = 'AST_ExpressionFunctionName',
2494 AST.Expression.__init__(
2501 def copy(self, factory = None):
2502 result = AST.Expression.copy(
2504 ExpressionFunctionName if factory is None else factory
2509 self.repr_serialize(params)
2510 return 'ast.AST.ExpressionFunctionName({0:s})'.format(', '.join(params))
2513 class ExpressionGreaterThan(ExpressionBinary):
2514 # GENERATE ELEMENT() BEGIN
2517 tag = 'AST_ExpressionGreaterThan',
2521 binary_operator = '',
2523 right_to_left = False
2525 AST.ExpressionBinary.__init__(
2535 def copy(self, factory = None):
2536 result = AST.ExpressionBinary.copy(
2538 ExpressionGreaterThan if factory is None else factory
2543 self.repr_serialize(params)
2544 return 'ast.AST.ExpressionGreaterThan({0:s})'.format(', '.join(params))
2547 class ExpressionGreaterThanOrEqual(ExpressionBinary):
2548 # GENERATE ELEMENT() BEGIN
2551 tag = 'AST_ExpressionGreaterThanOrEqual',
2555 binary_operator = '',
2557 right_to_left = False
2559 AST.ExpressionBinary.__init__(
2569 def copy(self, factory = None):
2570 result = AST.ExpressionBinary.copy(
2572 ExpressionGreaterThanOrEqual if factory is None else factory
2577 self.repr_serialize(params)
2578 return 'ast.AST.ExpressionGreaterThanOrEqual({0:s})'.format(', '.join(params))
2581 class ExpressionIdentifier(Expression):
2582 # GENERATE ELEMENT() BEGIN
2585 tag = 'AST_ExpressionIdentifier',
2590 AST.Expression.__init__(
2597 def copy(self, factory = None):
2598 result = AST.Expression.copy(
2600 ExpressionIdentifier if factory is None else factory
2605 self.repr_serialize(params)
2606 return 'ast.AST.ExpressionIdentifier({0:s})'.format(', '.join(params))
2608 def translate_expression(self, context, precedence):
2609 return self[0].translate_identifier(context)
2611 class ExpressionIndex(Expression):
2612 # GENERATE ELEMENT() BEGIN
2615 tag = 'AST_ExpressionIndex',
2620 AST.Expression.__init__(
2627 def copy(self, factory = None):
2628 result = AST.Expression.copy(
2630 ExpressionIndex if factory is None else factory
2635 self.repr_serialize(params)
2636 return 'ast.AST.ExpressionIndex({0:s})'.format(', '.join(params))
2638 def translate_expression(self, context, precedence):
2639 text = '{0:s}[{1:s}]'.format(
2640 self[0].translate_expression(context, 14),
2641 self[1].translate_expression(context, 0)
2644 text = '({0:s})'.format(text)
2647 class ExpressionIntLiteral(Expression):
2648 # GENERATE ELEMENT() BEGIN
2651 tag = 'AST_ExpressionIntLiteral',
2656 AST.Expression.__init__(
2663 def copy(self, factory = None):
2664 result = AST.Expression.copy(
2666 ExpressionIntLiteral if factory is None else factory
2671 self.repr_serialize(params)
2672 return 'ast.AST.ExpressionIntLiteral({0:s})'.format(', '.join(params))
2674 def translate_expression(self, context, precedence):
2675 text = element.get_text(self, 0)
2676 if text[:2] in octal_prefix:
2677 text = '0o' + text[1:]
2680 class Identifier(element.Element):
2681 # GENERATE ELEMENT() BEGIN
2684 tag = 'AST_Identifier',
2689 element.Element.__init__(
2696 def copy(self, factory = None):
2697 result = element.Element.copy(
2699 Identifier if factory is None else factory
2704 self.repr_serialize(params)
2705 return 'ast.AST.Identifier({0:s})'.format(', '.join(params))
2707 def translate_identifier(self, context):
2708 text = element.get_text(self, 0)
2709 return context.translate_identifier.get(text, text)
2711 class ExpressionLeftShiftAssignment(ExpressionBinary):
2712 # GENERATE ELEMENT() BEGIN
2715 tag = 'AST_ExpressionLeftShiftAssignment',
2719 binary_operator = '',
2721 right_to_left = False
2723 AST.ExpressionBinary.__init__(
2733 def copy(self, factory = None):
2734 result = AST.ExpressionBinary.copy(
2736 ExpressionLeftShiftAssignment if factory is None else factory
2741 self.repr_serialize(params)
2742 return 'ast.AST.ExpressionLeftShiftAssignment({0:s})'.format(', '.join(params))
2745 class ExpressionLessThan(ExpressionBinary):
2746 # GENERATE ELEMENT() BEGIN
2749 tag = 'AST_ExpressionLessThan',
2753 binary_operator = '',
2755 right_to_left = False
2757 AST.ExpressionBinary.__init__(
2767 def copy(self, factory = None):
2768 result = AST.ExpressionBinary.copy(
2770 ExpressionLessThan if factory is None else factory
2775 self.repr_serialize(params)
2776 return 'ast.AST.ExpressionLessThan({0:s})'.format(', '.join(params))
2779 class ExpressionLessThanOrEqual(ExpressionBinary):
2780 # GENERATE ELEMENT() BEGIN
2783 tag = 'AST_ExpressionLessThanOrEqual',
2787 binary_operator = '',
2789 right_to_left = False
2791 AST.ExpressionBinary.__init__(
2801 def copy(self, factory = None):
2802 result = AST.ExpressionBinary.copy(
2804 ExpressionLessThanOrEqual if factory is None else factory
2809 self.repr_serialize(params)
2810 return 'ast.AST.ExpressionLessThanOrEqual({0:s})'.format(', '.join(params))
2813 class ExpressionLogicalAnd(ExpressionBinary):
2814 # GENERATE ELEMENT() BEGIN
2817 tag = 'AST_ExpressionLogicalAnd',
2821 binary_operator = '',
2823 right_to_left = False
2825 AST.ExpressionBinary.__init__(
2835 def copy(self, factory = None):
2836 result = AST.ExpressionBinary.copy(
2838 ExpressionLogicalAnd if factory is None else factory
2843 self.repr_serialize(params)
2844 return 'ast.AST.ExpressionLogicalAnd({0:s})'.format(', '.join(params))
2847 class ExpressionLogicalNot(ExpressionUnary):
2848 # GENERATE ELEMENT() BEGIN
2851 tag = 'AST_ExpressionLogicalNot',
2855 unary_operator = '',
2858 AST.ExpressionUnary.__init__(
2867 def copy(self, factory = None):
2868 result = AST.ExpressionUnary.copy(
2870 ExpressionLogicalNot if factory is None else factory
2875 self.repr_serialize(params)
2876 return 'ast.AST.ExpressionLogicalNot({0:s})'.format(', '.join(params))
2879 class ExpressionLogicalOr(ExpressionBinary):
2880 # GENERATE ELEMENT() BEGIN
2883 tag = 'AST_ExpressionLogicalOr',
2887 binary_operator = '',
2889 right_to_left = False
2891 AST.ExpressionBinary.__init__(
2901 def copy(self, factory = None):
2902 result = AST.ExpressionBinary.copy(
2904 ExpressionLogicalOr if factory is None else factory
2909 self.repr_serialize(params)
2910 return 'ast.AST.ExpressionLogicalOr({0:s})'.format(', '.join(params))
2913 class ExpressionMinus(ExpressionUnary):
2914 # GENERATE ELEMENT() BEGIN
2917 tag = 'AST_ExpressionMinus',
2921 unary_operator = '',
2924 AST.ExpressionUnary.__init__(
2933 def copy(self, factory = None):
2934 result = AST.ExpressionUnary.copy(
2936 ExpressionMinus if factory is None else factory
2941 self.repr_serialize(params)
2942 return 'ast.AST.ExpressionMinus({0:s})'.format(', '.join(params))
2945 class ExpressionModulo(ExpressionBinary):
2946 # GENERATE ELEMENT() BEGIN
2949 tag = 'AST_ExpressionModulo',
2953 binary_operator = '',
2955 right_to_left = False
2957 AST.ExpressionBinary.__init__(
2967 def copy(self, factory = None):
2968 result = AST.ExpressionBinary.copy(
2970 ExpressionModulo if factory is None else factory
2975 self.repr_serialize(params)
2976 return 'ast.AST.ExpressionModulo({0:s})'.format(', '.join(params))
2979 class ExpressionModuloAssignment(ExpressionBinary):
2980 # GENERATE ELEMENT() BEGIN
2983 tag = 'AST_ExpressionModuloAssignment',
2987 binary_operator = '',
2989 right_to_left = False
2991 AST.ExpressionBinary.__init__(
3001 def copy(self, factory = None):
3002 result = AST.ExpressionBinary.copy(
3004 ExpressionModuloAssignment if factory is None else factory
3009 self.repr_serialize(params)
3010 return 'ast.AST.ExpressionModuloAssignment({0:s})'.format(', '.join(params))
3013 class ExpressionMultiply(ExpressionBinary):
3014 # GENERATE ELEMENT() BEGIN
3017 tag = 'AST_ExpressionMultiply',
3021 binary_operator = '',
3023 right_to_left = False
3025 AST.ExpressionBinary.__init__(
3035 def copy(self, factory = None):
3036 result = AST.ExpressionBinary.copy(
3038 ExpressionMultiply if factory is None else factory
3043 self.repr_serialize(params)
3044 return 'ast.AST.ExpressionMultiply({0:s})'.format(', '.join(params))
3047 class ExpressionMultiplyAssignment(ExpressionBinary):
3048 # GENERATE ELEMENT() BEGIN
3051 tag = 'AST_ExpressionMultiplyAssignment',
3055 binary_operator = '',
3057 right_to_left = False
3059 AST.ExpressionBinary.__init__(
3069 def copy(self, factory = None):
3070 result = AST.ExpressionBinary.copy(
3072 ExpressionMultiplyAssignment if factory is None else factory
3077 self.repr_serialize(params)
3078 return 'ast.AST.ExpressionMultiplyAssignment({0:s})'.format(', '.join(params))
3081 class ExpressionNotEqual(ExpressionBinary):
3082 # GENERATE ELEMENT() BEGIN
3085 tag = 'AST_ExpressionNotEqual',
3089 binary_operator = '',
3091 right_to_left = False
3093 AST.ExpressionBinary.__init__(
3103 def copy(self, factory = None):
3104 result = AST.ExpressionBinary.copy(
3106 ExpressionNotEqual if factory is None else factory
3111 self.repr_serialize(params)
3112 return 'ast.AST.ExpressionNotEqual({0:s})'.format(', '.join(params))
3115 class ExpressionPlus(ExpressionUnary):
3116 # GENERATE ELEMENT() BEGIN
3119 tag = 'AST_ExpressionPlus',
3123 unary_operator = '',
3126 AST.ExpressionUnary.__init__(
3135 def copy(self, factory = None):
3136 result = AST.ExpressionUnary.copy(
3138 ExpressionPlus if factory is None else factory
3143 self.repr_serialize(params)
3144 return 'ast.AST.ExpressionPlus({0:s})'.format(', '.join(params))
3147 class ExpressionPostDecrement(ExpressionUnary):
3148 # GENERATE ELEMENT() BEGIN
3151 tag = 'AST_ExpressionPostDecrement',
3155 unary_operator = '',
3158 AST.ExpressionUnary.__init__(
3167 def copy(self, factory = None):
3168 result = AST.ExpressionUnary.copy(
3170 ExpressionPostDecrement if factory is None else factory
3175 self.repr_serialize(params)
3176 return 'ast.AST.ExpressionPostDecrement({0:s})'.format(', '.join(params))
3178 def translate_statement_expression(self, context):
3179 return '{0:s} -= 1'.format(self[0].translate_expression(context, 0))
3181 class ExpressionPostIncrement(ExpressionUnary):
3182 # GENERATE ELEMENT() BEGIN
3185 tag = 'AST_ExpressionPostIncrement',
3189 unary_operator = '',
3192 AST.ExpressionUnary.__init__(
3201 def copy(self, factory = None):
3202 result = AST.ExpressionUnary.copy(
3204 ExpressionPostIncrement if factory is None else factory
3209 self.repr_serialize(params)
3210 return 'ast.AST.ExpressionPostIncrement({0:s})'.format(', '.join(params))
3212 def translate_statement_expression(self, context):
3213 return '{0:s} += 1'.format(self[0].translate_expression(context, 0))
3215 class ExpressionPreDecrement(ExpressionUnary):
3216 # GENERATE ELEMENT() BEGIN
3219 tag = 'AST_ExpressionPreDecrement',
3223 unary_operator = '',
3226 AST.ExpressionUnary.__init__(
3235 def copy(self, factory = None):
3236 result = AST.ExpressionUnary.copy(
3238 ExpressionPreDecrement if factory is None else factory
3243 self.repr_serialize(params)
3244 return 'ast.AST.ExpressionPreDecrement({0:s})'.format(', '.join(params))
3246 def translate_statement_expression(self, context):
3247 return '{0:s} -= 1'.format(self[0].translate_expression(context, 0))
3249 class ExpressionPreIncrement(ExpressionUnary):
3250 # GENERATE ELEMENT() BEGIN
3253 tag = 'AST_ExpressionPreIncrement',
3257 unary_operator = '',
3260 AST.ExpressionUnary.__init__(
3269 def copy(self, factory = None):
3270 result = AST.ExpressionUnary.copy(
3272 ExpressionPreIncrement if factory is None else factory
3277 self.repr_serialize(params)
3278 return 'ast.AST.ExpressionPreIncrement({0:s})'.format(', '.join(params))
3280 def translate_statement_expression(self, context):
3281 return '{0:s} += 1'.format(self[0].translate_expression(context, 0))
3283 class ExpressionRightShiftAssignment(ExpressionBinary):
3284 # GENERATE ELEMENT() BEGIN
3287 tag = 'AST_ExpressionRightShiftAssignment',
3291 binary_operator = '',
3293 right_to_left = False
3295 AST.ExpressionBinary.__init__(
3305 def copy(self, factory = None):
3306 result = AST.ExpressionBinary.copy(
3308 ExpressionRightShiftAssignment if factory is None else factory
3313 self.repr_serialize(params)
3314 return 'ast.AST.ExpressionRightShiftAssignment({0:s})'.format(', '.join(params))
3317 class ExpressionShiftLeft(ExpressionBinary):
3318 # GENERATE ELEMENT() BEGIN
3321 tag = 'AST_ExpressionShiftLeft',
3325 binary_operator = '',
3327 right_to_left = False
3329 AST.ExpressionBinary.__init__(
3339 def copy(self, factory = None):
3340 result = AST.ExpressionBinary.copy(
3342 ExpressionShiftLeft if factory is None else factory
3347 self.repr_serialize(params)
3348 return 'ast.AST.ExpressionShiftLeft({0:s})'.format(', '.join(params))
3351 class ExpressionShiftRight(ExpressionBinary):
3352 # GENERATE ELEMENT() BEGIN
3355 tag = 'AST_ExpressionShiftRight',
3359 binary_operator = '',
3361 right_to_left = False
3363 AST.ExpressionBinary.__init__(
3373 def copy(self, factory = None):
3374 result = AST.ExpressionBinary.copy(
3376 ExpressionShiftRight if factory is None else factory
3381 self.repr_serialize(params)
3382 return 'ast.AST.ExpressionShiftRight({0:s})'.format(', '.join(params))
3385 class ExpressionSizeOfExpression(ExpressionUnary):
3386 # GENERATE ELEMENT() BEGIN
3389 tag = 'AST_ExpressionSizeOfExpression',
3393 unary_operator = '',
3396 AST.ExpressionUnary.__init__(
3405 def copy(self, factory = None):
3406 result = AST.ExpressionUnary.copy(
3408 ExpressionSizeOfExpression if factory is None else factory
3413 self.repr_serialize(params)
3414 return 'ast.AST.ExpressionSizeOfExpression({0:s})'.format(', '.join(params))
3417 class ExpressionSizeOfType(ExpressionUnary):
3418 # GENERATE ELEMENT() BEGIN
3421 tag = 'AST_ExpressionSizeOfType',
3425 unary_operator = '',
3428 AST.ExpressionUnary.__init__(
3437 def copy(self, factory = None):
3438 result = AST.ExpressionUnary.copy(
3440 ExpressionSizeOfType if factory is None else factory
3445 self.repr_serialize(params)
3446 return 'ast.AST.ExpressionSizeOfType({0:s})'.format(', '.join(params))
3448 def translate_expression(self, context, precedence):
3449 type, _ = self[0][1].get_type_and_name(self[0][0].get_type())
3450 return str(type.translate_size(context))
3452 class ExpressionStringLiteral(Expression):
3453 # GENERATE ELEMENT() BEGIN
3456 tag = 'AST_ExpressionStringLiteral',
3461 AST.Expression.__init__(
3468 def copy(self, factory = None):
3469 result = AST.Expression.copy(
3471 ExpressionStringLiteral if factory is None else factory
3476 self.repr_serialize(params)
3477 return 'ast.AST.ExpressionStringLiteral({0:s})'.format(', '.join(params))
3479 def translate_expression(self, context, precedence):
3483 element.get_text(i, 0).
3484 replace('\\"', '"').
3485 replace('\'', '\\\'')
3491 class ExpressionSubtract(ExpressionBinary):
3492 # GENERATE ELEMENT() BEGIN
3495 tag = 'AST_ExpressionSubtract',
3499 binary_operator = '',
3501 right_to_left = False
3503 AST.ExpressionBinary.__init__(
3513 def copy(self, factory = None):
3514 result = AST.ExpressionBinary.copy(
3516 ExpressionSubtract if factory is None else factory
3521 self.repr_serialize(params)
3522 return 'ast.AST.ExpressionSubtract({0:s})'.format(', '.join(params))
3525 class ExpressionSubtractAssignment(ExpressionBinary):
3526 # GENERATE ELEMENT() BEGIN
3529 tag = 'AST_ExpressionSubtractAssignment',
3533 binary_operator = '',
3535 right_to_left = False
3537 AST.ExpressionBinary.__init__(
3547 def copy(self, factory = None):
3548 result = AST.ExpressionBinary.copy(
3550 ExpressionSubtractAssignment if factory is None else factory
3555 self.repr_serialize(params)
3556 return 'ast.AST.ExpressionSubtractAssignment({0:s})'.format(', '.join(params))
3559 class FunctionDefinition(DeclarationOrStatement):
3560 # GENERATE ELEMENT() BEGIN
3563 tag = 'AST_FunctionDefinition',
3568 AST.DeclarationOrStatement.__init__(
3575 def copy(self, factory = None):
3576 result = AST.DeclarationOrStatement.copy(
3578 FunctionDefinition if factory is None else factory
3583 self.repr_serialize(params)
3584 return 'ast.AST.FunctionDefinition({0:s})'.format(', '.join(params))
3586 def translate_declaration_or_statement(self, context):
3587 type, name = self[1].get_type_and_name(self[0].get_type())
3588 assert isinstance(type, AST.TypeFunction)
3589 context.lines.append(
3590 '\n{0:s}def {1:s}({2:s}):\n'.format(
3593 ', '.join([i.name for i in type])
3596 indent_save = context.indent
3597 context.indent += ' '
3598 assert context.top_level
3599 context.top_level = False
3600 self[3].translate_block_item_list(context)
3601 context.top_level = True
3602 context.indent = indent_save
3604 class FunctionSpecifier(element.Element):
3605 # GENERATE ELEMENT(int n) BEGIN
3608 tag = 'AST_FunctionSpecifier',
3614 element.Element.__init__(
3622 element.deserialize_int(n)
3623 if isinstance(n, str) else
3626 def serialize(self, ref_list):
3627 element.Element.serialize(self, ref_list)
3628 self.set('n', element.serialize_int(self.n))
3629 def deserialize(self, ref_list):
3630 element.Element.deserialize(self, ref_list)
3631 self.n = element.deserialize_int(self.get('n', '-1'))
3632 def copy(self, factory = None):
3633 result = element.Element.copy(
3635 FunctionSpecifier if factory is None else factory
3639 def repr_serialize(self, params):
3640 element.Element.repr_serialize(self, params)
3643 'n = {0:s}'.format(repr(self.n))
3647 self.repr_serialize(params)
3648 return 'ast.AST.FunctionSpecifier({0:s})'.format(', '.join(params))
3651 class GenericAssociation(element.Element):
3652 # GENERATE ELEMENT() BEGIN
3655 tag = 'AST_GenericAssociation',
3660 element.Element.__init__(
3667 def copy(self, factory = None):
3668 result = element.Element.copy(
3670 GenericAssociation if factory is None else factory
3675 self.repr_serialize(params)
3676 return 'ast.AST.GenericAssociation({0:s})'.format(', '.join(params))
3679 class GenericAssociationList(element.Element):
3680 # GENERATE ELEMENT() BEGIN
3683 tag = 'AST_GenericAssociationList',
3688 element.Element.__init__(
3695 def copy(self, factory = None):
3696 result = element.Element.copy(
3698 GenericAssociationList if factory is None else factory
3703 self.repr_serialize(params)
3704 return 'ast.AST.GenericAssociationList({0:s})'.format(', '.join(params))
3707 class GenericSelection(element.Element):
3708 # GENERATE ELEMENT() BEGIN
3711 tag = 'AST_GenericSelection',
3716 element.Element.__init__(
3723 def copy(self, factory = None):
3724 result = element.Element.copy(
3726 GenericSelection if factory is None else factory
3731 self.repr_serialize(params)
3732 return 'ast.AST.GenericSelection({0:s})'.format(', '.join(params))
3735 class IdentifierEmpty(element.Element):
3736 # GENERATE ELEMENT() BEGIN
3739 tag = 'AST_IdentifierEmpty',
3744 element.Element.__init__(
3751 def copy(self, factory = None):
3752 result = element.Element.copy(
3754 IdentifierEmpty if factory is None else factory
3759 self.repr_serialize(params)
3760 return 'ast.AST.IdentifierEmpty({0:s})'.format(', '.join(params))
3763 class IdentifierList(element.Element):
3764 # GENERATE ELEMENT() BEGIN
3767 tag = 'AST_IdentifierList',
3772 element.Element.__init__(
3779 def copy(self, factory = None):
3780 result = element.Element.copy(
3782 IdentifierList if factory is None else factory
3787 self.repr_serialize(params)
3788 return 'ast.AST.IdentifierList({0:s})'.format(', '.join(params))
3791 class InitDeclarator(element.Element):
3792 # GENERATE ELEMENT() BEGIN
3795 tag = 'AST_InitDeclarator',
3800 element.Element.__init__(
3807 def copy(self, factory = None):
3808 result = element.Element.copy(
3810 InitDeclarator if factory is None else factory
3815 self.repr_serialize(params)
3816 return 'ast.AST.InitDeclarator({0:s})'.format(', '.join(params))
3819 class InitDeclaratorList(element.Element):
3820 # GENERATE ELEMENT() BEGIN
3823 tag = 'AST_InitDeclaratorList',
3828 element.Element.__init__(
3835 def copy(self, factory = None):
3836 result = element.Element.copy(
3838 InitDeclaratorList if factory is None else factory
3843 self.repr_serialize(params)
3844 return 'ast.AST.InitDeclaratorList({0:s})'.format(', '.join(params))
3847 class ParameterDeclaration(element.Element):
3848 # GENERATE ELEMENT() BEGIN
3851 tag = 'AST_ParameterDeclaration',
3856 element.Element.__init__(
3863 def copy(self, factory = None):
3864 result = element.Element.copy(
3866 ParameterDeclaration if factory is None else factory
3871 self.repr_serialize(params)
3872 return 'ast.AST.ParameterDeclaration({0:s})'.format(', '.join(params))
3875 class ParameterDeclarationList(element.Element):
3876 # GENERATE ELEMENT() BEGIN
3879 tag = 'AST_ParameterDeclarationList',
3884 element.Element.__init__(
3891 def copy(self, factory = None):
3892 result = element.Element.copy(
3894 ParameterDeclarationList if factory is None else factory
3899 self.repr_serialize(params)
3900 return 'ast.AST.ParameterDeclarationList({0:s})'.format(', '.join(params))
3903 class SpecifierQualifierList(element.Element):
3904 # GENERATE ELEMENT() BEGIN
3907 tag = 'AST_SpecifierQualifierList',
3912 element.Element.__init__(
3919 def copy(self, factory = None):
3920 result = element.Element.copy(
3922 SpecifierQualifierList if factory is None else factory
3927 self.repr_serialize(params)
3928 return 'ast.AST.SpecifierQualifierList({0:s})'.format(', '.join(params))
3931 type_specifiers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
3933 if isinstance(i, AST.TypeSpecifier):
3934 type_specifiers[i.n] += 1
3935 return type_specifiers_to_type[tuple(type_specifiers)]
3937 class StatementBlock(Statement):
3938 # GENERATE ELEMENT() BEGIN
3941 tag = 'AST_StatementBlock',
3946 AST.Statement.__init__(
3953 def copy(self, factory = None):
3954 result = AST.Statement.copy(
3956 StatementBlock if factory is None else factory
3961 self.repr_serialize(params)
3962 return 'ast.AST.StatementBlock({0:s})'.format(', '.join(params))
3964 def translate_declaration_or_statement(self, context):
3966 self[0].translate_block_item_list(context)
3968 context.lines.append('{0:s}pass\n'.format(context.indent))
3970 class StatementBreak(Statement):
3971 # GENERATE ELEMENT() BEGIN
3974 tag = 'AST_StatementBreak',
3979 AST.Statement.__init__(
3986 def copy(self, factory = None):
3987 result = AST.Statement.copy(
3989 StatementBreak if factory is None else factory
3994 self.repr_serialize(params)
3995 return 'ast.AST.StatementBreak({0:s})'.format(', '.join(params))
3997 def translate_declaration_or_statement(self, context):
3998 context.lines.append('{0:s}break\n'.format(context.indent))
4000 class StatementCase(Statement):
4001 # GENERATE ELEMENT() BEGIN
4004 tag = 'AST_StatementCase',
4009 AST.Statement.__init__(
4016 def copy(self, factory = None):
4017 result = AST.Statement.copy(
4019 StatementCase if factory is None else factory
4024 self.repr_serialize(params)
4025 return 'ast.AST.StatementCase({0:s})'.format(', '.join(params))
4028 class StatementContinue(Statement):
4029 # GENERATE ELEMENT() BEGIN
4032 tag = 'AST_StatementContinue',
4037 AST.Statement.__init__(
4044 def copy(self, factory = None):
4045 result = AST.Statement.copy(
4047 StatementContinue if factory is None else factory
4052 self.repr_serialize(params)
4053 return 'ast.AST.StatementContinue({0:s})'.format(', '.join(params))
4055 def translate_declaration_or_statement(self, context):
4056 enclosing_loop_save = context.enclosing_loop
4057 context.enclosing_loop = None
4058 if isinstance(enclosing_loop_save, AST.StatementDoWhile):
4059 AST.StatementIfElse(
4061 enclosing_loop_save[1],
4062 AST.StatementContinue(),
4063 AST.StatementBreak()
4065 ).translate_declaration_or_statement(context)
4066 elif isinstance(enclosing_loop_save, AST.StatementFor):
4067 context.lines.append(
4068 '{0:s}{1:s}\n{2:s}continue\n'.format(
4070 enclosing_loop_save[2].translate_statement_expression(context),
4075 context.lines.append('{0:s}continue\n'.format(context.indent))
4076 context.enclosing_loop = enclosing_loop_save
4078 class StatementDefault(Statement):
4079 # GENERATE ELEMENT() BEGIN
4082 tag = 'AST_StatementDefault',
4087 AST.Statement.__init__(
4094 def copy(self, factory = None):
4095 result = AST.Statement.copy(
4097 StatementDefault if factory is None else factory
4102 self.repr_serialize(params)
4103 return 'ast.AST.StatementDefault({0:s})'.format(', '.join(params))
4106 class StatementDoWhile(Statement):
4107 # GENERATE ELEMENT() BEGIN
4110 tag = 'AST_StatementDoWhile',
4115 AST.Statement.__init__(
4122 def copy(self, factory = None):
4123 result = AST.Statement.copy(
4125 StatementDoWhile if factory is None else factory
4130 self.repr_serialize(params)
4131 return 'ast.AST.StatementDoWhile({0:s})'.format(', '.join(params))
4133 def translate_declaration_or_statement(self, context):
4135 isinstance(self[1], AST.ExpressionIntLiteral) and
4136 element.get_text(self[1], 0) == '0'
4138 self[0].translate_declaration_or_statement(context)
4140 context.lines.append('{0:s}while True:\n'.format(context.indent))
4141 indent_save = context.indent
4142 context.indent += ' '
4143 enclosing_loop_save = context.enclosing_loop
4144 context.enclosing_loop = self
4145 self[0].translate_declaration_or_statement(context)
4146 context.enclosing_loop = enclosing_loop_save
4149 AST.ExpressionLogicalNot(
4153 unary_operator = 'not '
4155 AST.StatementBreak()
4157 ).translate_declaration_or_statement(context)
4158 context.indent = indent_save
4160 class StatementExpression(Statement):
4161 # GENERATE ELEMENT() BEGIN
4164 tag = 'AST_StatementExpression',
4169 AST.Statement.__init__(
4176 def copy(self, factory = None):
4177 result = AST.Statement.copy(
4179 StatementExpression if factory is None else factory
4184 self.repr_serialize(params)
4185 return 'ast.AST.StatementExpression({0:s})'.format(', '.join(params))
4187 def translate_declaration_or_statement(self, context):
4188 context.lines.append(
4189 '{0:s}{1:s}\n'.format(
4191 self[0].translate_statement_expression(context)
4195 class StatementFor(Statement):
4196 # GENERATE ELEMENT() BEGIN
4199 tag = 'AST_StatementFor',
4204 AST.Statement.__init__(
4211 def copy(self, factory = None):
4212 result = AST.Statement.copy(
4214 StatementFor if factory is None else factory
4219 self.repr_serialize(params)
4220 return 'ast.AST.StatementFor({0:s})'.format(', '.join(params))
4222 def translate_declaration_or_statement(self, context):
4223 self[0].translate_declaration_or_statement(context)
4224 context.lines.append(
4225 '{0:s}while {1:s}:\n'.format(
4227 self[1].translate_expression(context, 0)
4230 indent_save = context.indent
4231 context.indent += ' '
4232 enclosing_loop_save = context.enclosing_loop
4233 context.enclosing_loop = self
4234 self[3].translate_declaration_or_statement(context)
4235 context.enclosing_loop = enclosing_loop_save
4236 context.lines.append(
4237 '{0:s}{1:s}\n'.format(
4239 self[2].translate_statement_expression(context)
4242 context.indent = indent_save
4244 class StatementGoto(Statement):
4245 # GENERATE ELEMENT() BEGIN
4248 tag = 'AST_StatementGoto',
4253 AST.Statement.__init__(
4260 def copy(self, factory = None):
4261 result = AST.Statement.copy(
4263 StatementGoto if factory is None else factory
4268 self.repr_serialize(params)
4269 return 'ast.AST.StatementGoto({0:s})'.format(', '.join(params))
4272 class StatementIf(Statement):
4273 # GENERATE ELEMENT() BEGIN
4276 tag = 'AST_StatementIf',
4281 AST.Statement.__init__(
4288 def copy(self, factory = None):
4289 result = AST.Statement.copy(
4291 StatementIf if factory is None else factory
4296 self.repr_serialize(params)
4297 return 'ast.AST.StatementIf({0:s})'.format(', '.join(params))
4299 def translate_declaration_or_statement(self, context):
4300 context.lines.append(
4301 '{0:s}if {1:s}:\n'.format(
4303 self[0].translate_expression(context, 0)
4306 indent_save = context.indent
4307 context.indent += ' '
4308 self[1].translate_declaration_or_statement(context)
4309 context.indent = indent_save
4311 class StatementIfElse(Statement):
4312 # GENERATE ELEMENT() BEGIN
4315 tag = 'AST_StatementIfElse',
4320 AST.Statement.__init__(
4327 def copy(self, factory = None):
4328 result = AST.Statement.copy(
4330 StatementIfElse if factory is None else factory
4335 self.repr_serialize(params)
4336 return 'ast.AST.StatementIfElse({0:s})'.format(', '.join(params))
4338 def translate_declaration_or_statement(self, context):
4339 context.lines.append(
4340 '{0:s}if {1:s}:\n'.format(
4342 self[0].translate_expression(context, 0)
4345 indent_save = context.indent
4346 context.indent += ' '
4347 self[1].translate_declaration_or_statement(context)
4348 context.lines.append('{0:s}else:\n'.format(indent_save))
4349 self[2].translate_declaration_or_statement(context)
4350 context.indent = indent_save
4352 class StatementLabel(Statement):
4353 # GENERATE ELEMENT() BEGIN
4356 tag = 'AST_StatementLabel',
4361 AST.Statement.__init__(
4368 def copy(self, factory = None):
4369 result = AST.Statement.copy(
4371 StatementLabel if factory is None else factory
4376 self.repr_serialize(params)
4377 return 'ast.AST.StatementLabel({0:s})'.format(', '.join(params))
4380 class StatementReturn(Statement):
4381 # GENERATE ELEMENT() BEGIN
4384 tag = 'AST_StatementReturn',
4389 AST.Statement.__init__(
4396 def copy(self, factory = None):
4397 result = AST.Statement.copy(
4399 StatementReturn if factory is None else factory
4404 self.repr_serialize(params)
4405 return 'ast.AST.StatementReturn({0:s})'.format(', '.join(params))
4407 def translate_declaration_or_statement(self, context):
4408 context.lines.append(
4409 '{0:s}return {1:s}\n'.format(
4411 self[0].translate_expression(context, 0)
4415 class StatementSwitch(Statement):
4416 # GENERATE ELEMENT() BEGIN
4419 tag = 'AST_StatementSwitch',
4424 AST.Statement.__init__(
4431 def copy(self, factory = None):
4432 result = AST.Statement.copy(
4434 StatementSwitch if factory is None else factory
4439 self.repr_serialize(params)
4440 return 'ast.AST.StatementSwitch({0:s})'.format(', '.join(params))
4443 class StatementWhile(Statement):
4444 # GENERATE ELEMENT() BEGIN
4447 tag = 'AST_StatementWhile',
4452 AST.Statement.__init__(
4459 def copy(self, factory = None):
4460 result = AST.Statement.copy(
4462 StatementWhile if factory is None else factory
4467 self.repr_serialize(params)
4468 return 'ast.AST.StatementWhile({0:s})'.format(', '.join(params))
4470 def translate_declaration_or_statement(self, context):
4471 context.lines.append(
4472 '{0:s}while {1:s}:\n'.format(
4474 self[0].translate_expression(context, 0)
4477 indent_save = context.indent
4478 context.indent += ' '
4479 enclosing_loop_save = context.enclosing_loop
4480 context.enclosing_loop = self
4481 self[1].translate_declaration_or_statement(context)
4482 context.enclosing_loop = enclosing_loop_save
4483 context.indent = indent_save
4485 class StaticAssertDeclaration(element.Element):
4486 # GENERATE ELEMENT() BEGIN
4489 tag = 'AST_StaticAssertDeclaration',
4494 element.Element.__init__(
4501 def copy(self, factory = None):
4502 result = element.Element.copy(
4504 StaticAssertDeclaration if factory is None else factory
4509 self.repr_serialize(params)
4510 return 'ast.AST.StaticAssertDeclaration({0:s})'.format(', '.join(params))
4513 class StorageClassSpecifier(element.Element):
4514 # GENERATE ELEMENT(int n) BEGIN
4517 tag = 'AST_StorageClassSpecifier',
4523 element.Element.__init__(
4531 element.deserialize_int(n)
4532 if isinstance(n, str) else
4535 def serialize(self, ref_list):
4536 element.Element.serialize(self, ref_list)
4537 self.set('n', element.serialize_int(self.n))
4538 def deserialize(self, ref_list):
4539 element.Element.deserialize(self, ref_list)
4540 self.n = element.deserialize_int(self.get('n', '-1'))
4541 def copy(self, factory = None):
4542 result = element.Element.copy(
4544 StorageClassSpecifier if factory is None else factory
4548 def repr_serialize(self, params):
4549 element.Element.repr_serialize(self, params)
4552 'n = {0:s}'.format(repr(self.n))
4556 self.repr_serialize(params)
4557 return 'ast.AST.StorageClassSpecifier({0:s})'.format(', '.join(params))
4560 class StructDeclaration(element.Element):
4561 # GENERATE ELEMENT() BEGIN
4564 tag = 'AST_StructDeclaration',
4569 element.Element.__init__(
4576 def copy(self, factory = None):
4577 result = element.Element.copy(
4579 StructDeclaration if factory is None else factory
4584 self.repr_serialize(params)
4585 return 'ast.AST.StructDeclaration({0:s})'.format(', '.join(params))
4588 class StructDeclarationList(element.Element):
4589 # GENERATE ELEMENT() BEGIN
4592 tag = 'AST_StructDeclarationList',
4597 element.Element.__init__(
4604 def copy(self, factory = None):
4605 result = element.Element.copy(
4607 StructDeclarationList if factory is None else factory
4612 self.repr_serialize(params)
4613 return 'ast.AST.StructDeclarationList({0:s})'.format(', '.join(params))
4616 class StructDeclarator(element.Element):
4617 # GENERATE ELEMENT() BEGIN
4620 tag = 'AST_StructDeclarator',
4625 element.Element.__init__(
4632 def copy(self, factory = None):
4633 result = element.Element.copy(
4635 StructDeclarator if factory is None else factory
4640 self.repr_serialize(params)
4641 return 'ast.AST.StructDeclarator({0:s})'.format(', '.join(params))
4644 class StructDeclaratorList(element.Element):
4645 # GENERATE ELEMENT() BEGIN
4648 tag = 'AST_StructDeclaratorList',
4653 element.Element.__init__(
4660 def copy(self, factory = None):
4661 result = element.Element.copy(
4663 StructDeclaratorList if factory is None else factory
4668 self.repr_serialize(params)
4669 return 'ast.AST.StructDeclaratorList({0:s})'.format(', '.join(params))
4672 class StructSpecifier(element.Element):
4673 # GENERATE ELEMENT() BEGIN
4676 tag = 'AST_StructSpecifier',
4681 element.Element.__init__(
4688 def copy(self, factory = None):
4689 result = element.Element.copy(
4691 StructSpecifier if factory is None else factory
4696 self.repr_serialize(params)
4697 return 'ast.AST.StructSpecifier({0:s})'.format(', '.join(params))
4700 class TypeName(element.Element):
4701 # GENERATE ELEMENT() BEGIN
4704 tag = 'AST_TypeName',
4709 element.Element.__init__(
4716 def copy(self, factory = None):
4717 result = element.Element.copy(
4719 TypeName if factory is None else factory
4724 self.repr_serialize(params)
4725 return 'ast.AST.TypeName({0:s})'.format(', '.join(params))
4728 class TypeQualifier(element.Element):
4729 # GENERATE ELEMENT(int n) BEGIN
4732 tag = 'AST_TypeQualifier',
4738 element.Element.__init__(
4746 element.deserialize_int(n)
4747 if isinstance(n, str) else
4750 def serialize(self, ref_list):
4751 element.Element.serialize(self, ref_list)
4752 self.set('n', element.serialize_int(self.n))
4753 def deserialize(self, ref_list):
4754 element.Element.deserialize(self, ref_list)
4755 self.n = element.deserialize_int(self.get('n', '-1'))
4756 def copy(self, factory = None):
4757 result = element.Element.copy(
4759 TypeQualifier if factory is None else factory
4763 def repr_serialize(self, params):
4764 element.Element.repr_serialize(self, params)
4767 'n = {0:s}'.format(repr(self.n))
4771 self.repr_serialize(params)
4772 return 'ast.AST.TypeQualifier({0:s})'.format(', '.join(params))
4775 class TypeQualifierList(element.Element):
4776 # GENERATE ELEMENT() BEGIN
4779 tag = 'AST_TypeQualifierList',
4784 element.Element.__init__(
4791 def copy(self, factory = None):
4792 result = element.Element.copy(
4794 TypeQualifierList if factory is None else factory
4799 self.repr_serialize(params)
4800 return 'ast.AST.TypeQualifierList({0:s})'.format(', '.join(params))
4803 class TypeQualifierOrStaticList(element.Element):
4804 # GENERATE ELEMENT() BEGIN
4807 tag = 'AST_TypeQualifierOrStaticList',
4812 element.Element.__init__(
4819 def copy(self, factory = None):
4820 result = element.Element.copy(
4822 TypeQualifierOrStaticList if factory is None else factory
4827 self.repr_serialize(params)
4828 return 'ast.AST.TypeQualifierOrStaticList({0:s})'.format(', '.join(params))
4831 class TypeSpecifier(element.Element):
4832 # GENERATE ELEMENT(int n) BEGIN
4835 tag = 'AST_TypeSpecifier',
4841 element.Element.__init__(
4849 element.deserialize_int(n)
4850 if isinstance(n, str) else
4853 def serialize(self, ref_list):
4854 element.Element.serialize(self, ref_list)
4855 self.set('n', element.serialize_int(self.n))
4856 def deserialize(self, ref_list):
4857 element.Element.deserialize(self, ref_list)
4858 self.n = element.deserialize_int(self.get('n', '-1'))
4859 def copy(self, factory = None):
4860 result = element.Element.copy(
4862 TypeSpecifier if factory is None else factory
4866 def repr_serialize(self, params):
4867 element.Element.repr_serialize(self, params)
4870 'n = {0:s}'.format(repr(self.n))
4874 self.repr_serialize(params)
4875 return 'ast.AST.TypeSpecifier({0:s})'.format(', '.join(params))
4878 class UnionSpecifier(element.Element):
4879 # GENERATE ELEMENT() BEGIN
4882 tag = 'AST_UnionSpecifier',
4887 element.Element.__init__(
4894 def copy(self, factory = None):
4895 result = element.Element.copy(
4897 UnionSpecifier if factory is None else factory
4902 self.repr_serialize(params)
4903 return 'ast.AST.UnionSpecifier({0:s})'.format(', '.join(params))
4906 class TranslationUnit(element.Element):
4907 # GENERATE ELEMENT() BEGIN
4910 tag = 'AST_TranslationUnit',
4915 element.Element.__init__(
4922 def copy(self, factory = None):
4923 result = element.Element.copy(
4925 TranslationUnit if factory is None else factory
4930 self.repr_serialize(params)
4931 return 'ast.AST.TranslationUnit({0:s})'.format(', '.join(params))
4933 def translate_translation_unit(self, context):
4935 i.translate_declaration_or_statement(context)
4937 # GENERATE ELEMENT() BEGIN
4945 element.Element.__init__(
4952 def copy(self, factory = None):
4953 result = element.Element.copy(
4955 AST if factory is None else factory
4960 self.repr_serialize(params)
4961 return 'ast.AST({0:s})'.format(', '.join(params))
4964 type_specifiers_to_type = {
4965 (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0): AST.TypeVoid(),
4966 (0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 8),
4967 (0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 8),
4968 (0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0): AST.TypeInt(signed = False, bits = 8),
4969 (0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 16),
4970 (0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 16),
4971 (0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0): AST.TypeInt(signed = False, bits = 16),
4972 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 32),
4973 (0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 32),
4974 (0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 32),
4975 (0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0): AST.TypeInt(signed = False, bits = 32),
4976 (0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 32),
4977 (0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 32),
4978 (0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 32),
4979 (0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0): AST.TypeInt(signed = False, bits = 32),
4980 (0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0): AST.TypeInt(signed = False, bits = 32),
4981 (0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 64),
4982 (0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0): AST.TypeInt(signed = True, bits = 64),
4983 (0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0): AST.TypeInt(signed = False, bits = 64),
4984 (0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0): AST.TypeFloat(complex = 0, bits = 32),
4985 (0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0): AST.TypeFloat(complex = 2, bits = 32),
4986 (0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1): AST.TypeFloat(complex = 1, bits = 32),
4987 (0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0): AST.TypeFloat(complex = 0, bits = 64),
4988 (0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0): AST.TypeFloat(complex = 1, bits = 64),
4989 (0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1): AST.TypeFloat(complex = 2, bits = 64),
4990 (0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0): AST.TypeBool()
4993 ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09']
4996 # GENERATE FACTORY(element.Element) BEGIN
4999 'AST_Text': AST.Text,
5000 'AST_DeclarationOrStatement': AST.DeclarationOrStatement,
5001 'AST_Statement': AST.Statement,
5002 'AST_Declarator': AST.Declarator,
5003 'AST_Expression': AST.Expression,
5004 'AST_ExpressionUnary': AST.ExpressionUnary,
5005 'AST_ExpressionBinary': AST.ExpressionBinary,
5006 'AST_Type': AST.Type,
5007 'AST_TypeVoid': AST.TypeVoid,
5008 'AST_TypeInt': AST.TypeInt,
5009 'AST_TypeFloat': AST.TypeFloat,
5010 'AST_TypeBool': AST.TypeBool,
5011 'AST_TypePointer': AST.TypePointer,
5012 'AST_TypeArray': AST.TypeArray,
5013 'AST_TypeFunction': AST.TypeFunction,
5014 'AST_TypeFunction_Argument': AST.TypeFunction.Argument,
5015 'AST_AlignAsExpression': AST.AlignAsExpression,
5016 'AST_AlignAsType': AST.AlignAsType,
5017 'AST_ArgumentExpressionList': AST.ArgumentExpressionList,
5018 'AST_BlockItemList': AST.BlockItemList,
5019 'AST_Declaration': AST.Declaration,
5020 'AST_DeclarationList': AST.DeclarationList,
5021 'AST_DeclarationSpecifierList': AST.DeclarationSpecifierList,
5022 'AST_DeclaratorAbstract': AST.DeclaratorAbstract,
5023 'AST_DeclaratorArray': AST.DeclaratorArray,
5024 'AST_DeclaratorEmpty': AST.DeclaratorEmpty,
5025 'AST_DeclaratorFunction': AST.DeclaratorFunction,
5026 'AST_DeclaratorFunctionOldStyle': AST.DeclaratorFunctionOldStyle,
5027 'AST_DeclaratorIdentifier': AST.DeclaratorIdentifier,
5028 'AST_DeclaratorPointer': AST.DeclaratorPointer,
5029 'AST_DefaultTypeName': AST.DefaultTypeName,
5030 'AST_DesignatorField': AST.DesignatorField,
5031 'AST_DesignatorIndex': AST.DesignatorIndex,
5032 'AST_DesignatorInitializer': AST.DesignatorInitializer,
5033 'AST_DesignatorInitializerList': AST.DesignatorInitializerList,
5034 'AST_DesignatorList': AST.DesignatorList,
5035 'AST_EnumSpecifier': AST.EnumSpecifier,
5036 'AST_Enumerator': AST.Enumerator,
5037 'AST_EnumeratorList': AST.EnumeratorList,
5038 'AST_EqualsInitializerEmpty': AST.EqualsInitializerEmpty,
5039 'AST_ExpressionAdd': AST.ExpressionAdd,
5040 'AST_ExpressionAddAssignment': AST.ExpressionAddAssignment,
5041 'AST_ExpressionAddressOf': AST.ExpressionAddressOf,
5042 'AST_ExpressionAlignOfType': AST.ExpressionAlignOfType,
5043 'AST_ExpressionArray': AST.ExpressionArray,
5044 'AST_ExpressionAssignment': AST.ExpressionAssignment,
5045 'AST_ExpressionAsterisk': AST.ExpressionAsterisk,
5046 'AST_ExpressionBitwiseAnd': AST.ExpressionBitwiseAnd,
5047 'AST_ExpressionBitwiseAndAssignment': AST.ExpressionBitwiseAndAssignment,
5048 'AST_ExpressionBitwiseNot': AST.ExpressionBitwiseNot,
5049 'AST_ExpressionBitwiseOr': AST.ExpressionBitwiseOr,
5050 'AST_ExpressionBitwiseOrAssignment': AST.ExpressionBitwiseOrAssignment,
5051 'AST_ExpressionCall': AST.ExpressionCall,
5052 'AST_ExpressionCast': AST.ExpressionCast,
5053 'AST_ExpressionCharConstant': AST.ExpressionCharConstant,
5054 'AST_ExpressionComma': AST.ExpressionComma,
5055 'AST_ExpressionConditional': AST.ExpressionConditional,
5056 'AST_ExpressionDereference': AST.ExpressionDereference,
5057 'AST_ExpressionDivide': AST.ExpressionDivide,
5058 'AST_ExpressionDivideAssignment': AST.ExpressionDivideAssignment,
5059 'AST_ExpressionEmpty': AST.ExpressionEmpty,
5060 'AST_ExpressionEqual': AST.ExpressionEqual,
5061 'AST_ExpressionExclusiveOr': AST.ExpressionExclusiveOr,
5062 'AST_ExpressionExclusiveOrAssignment': AST.ExpressionExclusiveOrAssignment,
5063 'AST_ExpressionField': AST.ExpressionField,
5064 'AST_ExpressionFieldDereference': AST.ExpressionFieldDereference,
5065 'AST_ExpressionFloatLiteral': AST.ExpressionFloatLiteral,
5066 'AST_ExpressionFunctionName': AST.ExpressionFunctionName,
5067 'AST_ExpressionGreaterThan': AST.ExpressionGreaterThan,
5068 'AST_ExpressionGreaterThanOrEqual': AST.ExpressionGreaterThanOrEqual,
5069 'AST_ExpressionIdentifier': AST.ExpressionIdentifier,
5070 'AST_ExpressionIndex': AST.ExpressionIndex,
5071 'AST_ExpressionIntLiteral': AST.ExpressionIntLiteral,
5072 'AST_Identifier': AST.Identifier,
5073 'AST_ExpressionLeftShiftAssignment': AST.ExpressionLeftShiftAssignment,
5074 'AST_ExpressionLessThan': AST.ExpressionLessThan,
5075 'AST_ExpressionLessThanOrEqual': AST.ExpressionLessThanOrEqual,
5076 'AST_ExpressionLogicalAnd': AST.ExpressionLogicalAnd,
5077 'AST_ExpressionLogicalNot': AST.ExpressionLogicalNot,
5078 'AST_ExpressionLogicalOr': AST.ExpressionLogicalOr,
5079 'AST_ExpressionMinus': AST.ExpressionMinus,
5080 'AST_ExpressionModulo': AST.ExpressionModulo,
5081 'AST_ExpressionModuloAssignment': AST.ExpressionModuloAssignment,
5082 'AST_ExpressionMultiply': AST.ExpressionMultiply,
5083 'AST_ExpressionMultiplyAssignment': AST.ExpressionMultiplyAssignment,
5084 'AST_ExpressionNotEqual': AST.ExpressionNotEqual,
5085 'AST_ExpressionPlus': AST.ExpressionPlus,
5086 'AST_ExpressionPostDecrement': AST.ExpressionPostDecrement,
5087 'AST_ExpressionPostIncrement': AST.ExpressionPostIncrement,
5088 'AST_ExpressionPreDecrement': AST.ExpressionPreDecrement,
5089 'AST_ExpressionPreIncrement': AST.ExpressionPreIncrement,
5090 'AST_ExpressionRightShiftAssignment': AST.ExpressionRightShiftAssignment,
5091 'AST_ExpressionShiftLeft': AST.ExpressionShiftLeft,
5092 'AST_ExpressionShiftRight': AST.ExpressionShiftRight,
5093 'AST_ExpressionSizeOfExpression': AST.ExpressionSizeOfExpression,
5094 'AST_ExpressionSizeOfType': AST.ExpressionSizeOfType,
5095 'AST_ExpressionStringLiteral': AST.ExpressionStringLiteral,
5096 'AST_ExpressionSubtract': AST.ExpressionSubtract,
5097 'AST_ExpressionSubtractAssignment': AST.ExpressionSubtractAssignment,
5098 'AST_FunctionDefinition': AST.FunctionDefinition,
5099 'AST_FunctionSpecifier': AST.FunctionSpecifier,
5100 'AST_GenericAssociation': AST.GenericAssociation,
5101 'AST_GenericAssociationList': AST.GenericAssociationList,
5102 'AST_GenericSelection': AST.GenericSelection,
5103 'AST_IdentifierEmpty': AST.IdentifierEmpty,
5104 'AST_IdentifierList': AST.IdentifierList,
5105 'AST_InitDeclarator': AST.InitDeclarator,
5106 'AST_InitDeclaratorList': AST.InitDeclaratorList,
5107 'AST_ParameterDeclaration': AST.ParameterDeclaration,
5108 'AST_ParameterDeclarationList': AST.ParameterDeclarationList,
5109 'AST_SpecifierQualifierList': AST.SpecifierQualifierList,
5110 'AST_StatementBlock': AST.StatementBlock,
5111 'AST_StatementBreak': AST.StatementBreak,
5112 'AST_StatementCase': AST.StatementCase,
5113 'AST_StatementContinue': AST.StatementContinue,
5114 'AST_StatementDefault': AST.StatementDefault,
5115 'AST_StatementDoWhile': AST.StatementDoWhile,
5116 'AST_StatementExpression': AST.StatementExpression,
5117 'AST_StatementFor': AST.StatementFor,
5118 'AST_StatementGoto': AST.StatementGoto,
5119 'AST_StatementIf': AST.StatementIf,
5120 'AST_StatementIfElse': AST.StatementIfElse,
5121 'AST_StatementLabel': AST.StatementLabel,
5122 'AST_StatementReturn': AST.StatementReturn,
5123 'AST_StatementSwitch': AST.StatementSwitch,
5124 'AST_StatementWhile': AST.StatementWhile,
5125 'AST_StaticAssertDeclaration': AST.StaticAssertDeclaration,
5126 'AST_StorageClassSpecifier': AST.StorageClassSpecifier,
5127 'AST_StructDeclaration': AST.StructDeclaration,
5128 'AST_StructDeclarationList': AST.StructDeclarationList,
5129 'AST_StructDeclarator': AST.StructDeclarator,
5130 'AST_StructDeclaratorList': AST.StructDeclaratorList,
5131 'AST_StructSpecifier': AST.StructSpecifier,
5132 'AST_TypeName': AST.TypeName,
5133 'AST_TypeQualifier': AST.TypeQualifier,
5134 'AST_TypeQualifierList': AST.TypeQualifierList,
5135 'AST_TypeQualifierOrStaticList': AST.TypeQualifierOrStaticList,
5136 'AST_TypeSpecifier': AST.TypeSpecifier,
5137 'AST_UnionSpecifier': AST.UnionSpecifier,
5138 'AST_TranslationUnit': AST.TranslationUnit
5140 def factory(tag, attrib = {}, *args, **kwargs):
5141 return tag_to_class.get(tag, element.Element)(tag, attrib, *args, **kwargs)