Changes in src/Parser/parser.yy [51b1202:1db21619]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r51b1202 r1db21619 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Aug 11 16:01:49201513 // Update Count : 1 35012 // Last Modified On : Thu Jul 16 16:25:12 2015 13 // Update Count : 1267 14 14 // 15 15 … … 115 115 StatementNode *sn; 116 116 ConstantNode *constant; 117 LabelNode *label;118 117 InitializerNode *in; 119 bool flag;120 118 } 121 119 … … 136 134 %type<en> argument_expression_list argument_expression for_control_expression assignment_opt 137 135 %type<en> subrange 138 %type<en> asm_operands_opt asm_operands_list asm_operand139 %type<label> label_list140 %type<constant> asm_clobbers_list_opt141 %type<flag> asm_volatile_opt142 136 143 137 // statements … … 338 332 | zero_one 339 333 { $$ = new VarRefNode( $1 ); } 334 | constant 335 { $$ = $1; } 336 | string_literal_list 337 { $$ = $1; } 340 338 | '(' comma_expression ')' 341 339 { $$ = $2; } … … 380 378 | assignment_expression 381 379 | no_attr_identifier ':' assignment_expression 382 { $$ = $3->set_a rgName( $1 ); }380 { $$ = $3->set_asArgName( $1 ); } 383 381 // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient 384 382 // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used 385 383 // with an appropriate semantic check. 386 384 | '[' push assignment_expression pop ']' ':' assignment_expression 387 { $$ = $7->set_a rgName( $3 ); }385 { $$ = $7->set_asArgName( $3 ); } 388 386 | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression 389 { $$ = $9->set_a rgName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }387 { $$ = $9->set_asArgName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); } 390 388 ; 391 389 … … 410 408 unary_expression: 411 409 postfix_expression 412 // first location where constant/string can have operator applied: sizeof 3/sizeof "abc"413 // still requires semantics checks, e.g., ++3, 3--, *3, &&3414 | constant415 { $$ = $1; }416 | string_literal_list417 { $$ = $1; }418 410 | ICR unary_expression 419 411 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2 ); } … … 643 635 // requires its own scope 644 636 push push 645 l ocal_label_declaration_opt// GCC, local labels637 label_declaration_opt // GCC, local labels 646 638 block_item_list pop '}' // C99, intermix declarations and statements 647 639 { $$ = new CompoundStmtNode( $5 ); } … … 762 754 763 755 fall_through: // CFA 764 FALLTHRU { $$ = new StatementNode( StatementNode::Fallthru ); }765 | FALLTHRU ';' { $$ = new StatementNode( StatementNode::Fallthru ); }756 FALLTHRU { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); } 757 | FALLTHRU ';' { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); } 766 758 ; 767 759 … … 791 783 | CONTINUE ';' 792 784 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 793 { $$ = new StatementNode( StatementNode::Continue ); }785 { $$ = new StatementNode( StatementNode::Continue, 0, 0 ); } 794 786 | CONTINUE no_attr_identifier ';' // CFA, multi-level continue 795 787 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and … … 798 790 | BREAK ';' 799 791 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 800 { $$ = new StatementNode( StatementNode::Break ); }792 { $$ = new StatementNode( StatementNode::Break, 0, 0 ); } 801 793 | BREAK no_attr_identifier ';' // CFA, multi-level exit 802 794 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and … … 808 800 { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); } 809 801 | THROW ';' 810 { $$ = new StatementNode( StatementNode::Throw ); }802 { $$ = new StatementNode( StatementNode::Throw, 0, 0 ); } 811 803 ; 812 804 … … 871 863 872 864 asm_statement: 873 ASM asm_volatile_opt '(' string_literal_list ')' ';' 874 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, 0 ); } 875 | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC 876 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6 ); } 877 | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';' 878 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8 ); } 879 | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';' 880 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8, $10 ); } 881 | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';' 882 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12 ); } 883 ; 884 885 asm_volatile_opt: // GCC 886 // empty 887 { $$ = false; } 888 | VOLATILE 889 { $$ = true; } 865 ASM type_qualifier_list_opt '(' constant_expression ')' ';' 866 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); } 867 | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ')' ';' // remaining GCC 868 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); } 869 | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ')' ';' 870 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); } 871 | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list ')' ';' 872 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); } 890 873 ; 891 874 892 875 asm_operands_opt: // GCC 893 876 // empty 894 { $$ = 0; } // use default argument895 877 | asm_operands_list 896 878 ; … … 899 881 asm_operand 900 882 | asm_operands_list ',' asm_operand 901 { $$ = (ExpressionNode *)$1->set_link( $3 ); }902 883 ; 903 884 904 885 asm_operand: // GCC 905 string_literal_list '(' constant_expression ')' 906 { $$ = new AsmExprNode( 0, $1, $3 ); } 907 | '[' constant_expression ']' string_literal_list '(' constant_expression ')' 908 { $$ = new AsmExprNode( $2, $4, $6 ); } 909 ; 910 911 asm_clobbers_list_opt: // GCC 912 // empty 913 { $$ = 0; } // use default argument 914 | string_literal_list 915 { $$ = $1; } 916 | asm_clobbers_list_opt ',' string_literal_list 917 { $$ = (ConstantNode *)$1->set_link( $3 ); } 918 ; 919 920 label_list: 921 no_attr_identifier 922 { $$ = new LabelNode(); $$->append_label( $1 ); } 923 | label_list ',' no_attr_identifier 924 { $$ = $1; $1->append_label( $3 ); } 886 STRINGliteral '(' constant_expression ')' {} 887 ; 888 889 asm_clobbers_list: // GCC 890 STRINGliteral {} 891 | asm_clobbers_list ',' STRINGliteral 925 892 ; 926 893 … … 951 918 ; 952 919 953 l ocal_label_declaration_opt:// GCC, local label920 label_declaration_opt: // GCC, local label 954 921 // empty 955 | l ocal_label_declaration_list956 ; 957 958 l ocal_label_declaration_list:// GCC, local label959 LABEL l ocal_label_list ';'960 | l ocal_label_declaration_list LABEL local_label_list ';'961 ; 962 963 l ocal_label_list:// GCC, local label964 no_attr_identifier_or_type_name {}965 | l ocal_label_list ',' no_attr_identifier_or_type_name {}922 | label_declaration_list 923 ; 924 925 label_declaration_list: // GCC, local label 926 LABEL label_list ';' 927 | label_declaration_list LABEL label_list ';' 928 ; 929 930 label_list: // GCC, local label 931 no_attr_identifier_or_type_name {} 932 | label_list ',' no_attr_identifier_or_type_name {} 966 933 ; 967 934 … … 1693 1660 1694 1661 designator: 1695 // only ".0" and ".1" allowed => semantic check 1696 FLOATINGconstant 1697 { $$ = new DesignatorNode( new VarRefNode( $1 ) ); } 1698 | '.' no_attr_identifier_or_type_name // C99, field name 1699 { $$ = new DesignatorNode( new VarRefNode( $2 ) ); } 1662 '.' no_attr_identifier_or_type_name // C99, field name 1663 { $$ = new VarRefNode( $2 ); } 1700 1664 | '[' push assignment_expression pop ']' // C99, single array element 1701 1665 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple. 1702 { $$ = new DesignatorNode( $3, true ); }1666 { $$ = $3; } 1703 1667 | '[' push subrange pop ']' // CFA, multiple array elements 1704 { $$ = new DesignatorNode( $3, true ); }1668 { $$ = $3; } 1705 1669 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 1706 { $$ = new DesignatorNode( new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ), true); }1670 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ); } 1707 1671 | '.' '[' push field_list pop ']' // CFA, tuple field selector 1708 { $$ = new DesignatorNode( $4 ); }1672 { $$ = $4; } 1709 1673 ; 1710 1674
Note:
See TracChangeset
for help on using the changeset viewer.