ast_transforms.pyc
1 o 2 U��c; � @ s0 d dl mZ dd� Zdd� Zdd� Zdd � Zd 3 S )� )�c_astc C s� t | tj�sJ �t | jtj�s| S t�g | jj�}d}| jjp g D ].}t |tjtjf�r>|j� |� t 4 ||j� |jd }q!|du rI|j� |� q!|j� |� q!|| _| S )a� The 'case' statements in a 'switch' come out of parsing with one 5 child node, so subsequent statements are just tucked to the parent 6 Compound. Additionally, consecutive (fall-through) case statements 7 come out messy. This is a peculiarity of the C grammar. The following: 8 9 switch (myvar) { 10 case 10: 11 k = 10; 12 p = k + 1; 13 return 10; 14 case 20: 15 case 30: 16 return 20; 17 default: 18 break; 19 } 20 21 Creates this tree (pseudo-dump): 22 23 Switch 24 ID: myvar 25 Compound: 26 Case 10: 27 k = 10 28 p = k + 1 29 return 10 30 Case 20: 31 Case 30: 32 return 20 33 Default: 34 break 35 36 The goal of this transform is to fix this mess, turning it into the 37 following: 38 39 Switch 40 ID: myvar 41 Compound: 42 Case 10: 43 k = 10 44 p = k + 1 45 return 10 46 Case 20: 47 Case 30: 48 return 20 49 Default: 50 break 51 52 A fixed AST node is returned. The argument may be modified. 53 N�����)� 54 isinstancer �Switch�stmt�Compound�coord�block_items�Case�Default�append�_extract_nested_case�stmts)Zswitch_nodeZnew_compoundZ last_case�child� r ��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pycparser\ast_transforms.py�fix_switch_cases s 3r c C s>