Changeset 353d168 for src/Parser/parser.yy
- Timestamp:
- Aug 19, 2015, 3:59:45 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 830c21a
- Parents:
- 18997b9 (diff), 4aa0858 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r18997b9 r353d168 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jul 16 16:25:12201513 // Update Count : 1 26712 // Last Modified On : Tue Aug 11 16:01:49 2015 13 // Update Count : 1350 14 14 // 15 15 … … 115 115 StatementNode *sn; 116 116 ConstantNode *constant; 117 LabelNode *label; 117 118 InitializerNode *in; 119 bool flag; 118 120 } 119 121 … … 134 136 %type<en> argument_expression_list argument_expression for_control_expression assignment_opt 135 137 %type<en> subrange 138 %type<en> asm_operands_opt asm_operands_list asm_operand 139 %type<label> label_list 140 %type<constant> asm_clobbers_list_opt 141 %type<flag> asm_volatile_opt 136 142 137 143 // statements … … 332 338 | zero_one 333 339 { $$ = new VarRefNode( $1 ); } 334 | constant335 { $$ = $1; }336 | string_literal_list337 { $$ = $1; }338 340 | '(' comma_expression ')' 339 341 { $$ = $2; } … … 378 380 | assignment_expression 379 381 | no_attr_identifier ':' assignment_expression 380 { $$ = $3->set_a sArgName( $1 ); }382 { $$ = $3->set_argName( $1 ); } 381 383 // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient 382 384 // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used 383 385 // with an appropriate semantic check. 384 386 | '[' push assignment_expression pop ']' ':' assignment_expression 385 { $$ = $7->set_a sArgName( $3 ); }387 { $$ = $7->set_argName( $3 ); } 386 388 | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression 387 { $$ = $9->set_a sArgName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }389 { $$ = $9->set_argName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); } 388 390 ; 389 391 … … 408 410 unary_expression: 409 411 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, &&3 414 | constant 415 { $$ = $1; } 416 | string_literal_list 417 { $$ = $1; } 410 418 | ICR unary_expression 411 419 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2 ); } … … 635 643 // requires its own scope 636 644 push push 637 l abel_declaration_opt// GCC, local labels645 local_label_declaration_opt // GCC, local labels 638 646 block_item_list pop '}' // C99, intermix declarations and statements 639 647 { $$ = new CompoundStmtNode( $5 ); } … … 754 762 755 763 fall_through: // CFA 756 FALLTHRU { $$ = new StatementNode( StatementNode::Fallthru , 0, 0); }757 | FALLTHRU ';' { $$ = new StatementNode( StatementNode::Fallthru , 0, 0); }764 FALLTHRU { $$ = new StatementNode( StatementNode::Fallthru ); } 765 | FALLTHRU ';' { $$ = new StatementNode( StatementNode::Fallthru ); } 758 766 ; 759 767 … … 783 791 | CONTINUE ';' 784 792 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 785 { $$ = new StatementNode( StatementNode::Continue , 0, 0); }793 { $$ = new StatementNode( StatementNode::Continue ); } 786 794 | CONTINUE no_attr_identifier ';' // CFA, multi-level continue 787 795 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and … … 790 798 | BREAK ';' 791 799 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 792 { $$ = new StatementNode( StatementNode::Break , 0, 0); }800 { $$ = new StatementNode( StatementNode::Break ); } 793 801 | BREAK no_attr_identifier ';' // CFA, multi-level exit 794 802 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and … … 800 808 { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); } 801 809 | THROW ';' 802 { $$ = new StatementNode( StatementNode::Throw , 0, 0); }810 { $$ = new StatementNode( StatementNode::Throw ); } 803 811 ; 804 812 … … 863 871 864 872 asm_statement: 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 ); } 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; } 873 890 ; 874 891 875 892 asm_operands_opt: // GCC 876 893 // empty 894 { $$ = 0; } // use default argument 877 895 | asm_operands_list 878 896 ; … … 881 899 asm_operand 882 900 | asm_operands_list ',' asm_operand 901 { $$ = (ExpressionNode *)$1->set_link( $3 ); } 883 902 ; 884 903 885 904 asm_operand: // GCC 886 STRINGliteral '(' constant_expression ')' {} 887 ; 888 889 asm_clobbers_list: // GCC 890 STRINGliteral {} 891 | asm_clobbers_list ',' STRINGliteral 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 ); } 892 925 ; 893 926 … … 918 951 ; 919 952 920 l abel_declaration_opt:// GCC, local label953 local_label_declaration_opt: // GCC, local label 921 954 // empty 922 | l abel_declaration_list923 ; 924 925 l abel_declaration_list:// GCC, local label926 LABEL l abel_list ';'927 | l abel_declaration_list LABELlabel_list ';'928 ; 929 930 l abel_list:// GCC, local label931 no_attr_identifier_or_type_name {}932 | l abel_list ',' no_attr_identifier_or_type_name {}955 | local_label_declaration_list 956 ; 957 958 local_label_declaration_list: // GCC, local label 959 LABEL local_label_list ';' 960 | local_label_declaration_list LABEL local_label_list ';' 961 ; 962 963 local_label_list: // GCC, local label 964 no_attr_identifier_or_type_name {} 965 | local_label_list ',' no_attr_identifier_or_type_name {} 933 966 ; 934 967 … … 1660 1693 1661 1694 designator: 1662 '.' no_attr_identifier_or_type_name // C99, field name 1663 { $$ = new VarRefNode( $2 ); } 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 ) ); } 1664 1700 | '[' push assignment_expression pop ']' // C99, single array element 1665 1701 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple. 1666 { $$ = $3; }1702 { $$ = new DesignatorNode( $3, true ); } 1667 1703 | '[' push subrange pop ']' // CFA, multiple array elements 1668 { $$ = $3; }1704 { $$ = new DesignatorNode( $3, true ); } 1669 1705 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 1670 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5); }1706 { $$ = new DesignatorNode( new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ), true ); } 1671 1707 | '.' '[' push field_list pop ']' // CFA, tuple field selector 1672 { $$ = $4; }1708 { $$ = new DesignatorNode( $4 ); } 1673 1709 ; 1674 1710
Note:
See TracChangeset
for help on using the changeset viewer.