Changeset 6840e7c for src/Parser/parser.yy
- Timestamp:
- Oct 19, 2017, 12:01:04 PM (8 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 837ce06
- Parents:
- b96ec83 (diff), a15b72c (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
rb96ec83 r6840e7c 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Sep 14 23:07:12201713 // Update Count : 28 1512 // Last Modified On : Mon Oct 16 11:07:29 2017 13 // Update Count : 2892 14 14 // 15 15 … … 43 43 #define YYDEBUG_LEXER_TEXT (yylval) // lexer loads this up each time 44 44 #define YYDEBUG 1 // get the pretty debugging code to compile 45 #define YYERROR_VERBOSE 45 #define YYERROR_VERBOSE // more information in syntax errors 46 46 47 47 #undef __GNUC_MINOR__ … … 117 117 bool forall = false; // aggregate have one or more forall qualifiers ? 118 118 119 # define YYLLOC_DEFAULT(Cur, Rhs, N) \ 120 do \ 121 if (N) { \ 122 (Cur).first_line = YYRHSLOC(Rhs, 1).first_line; \ 123 (Cur).first_column = YYRHSLOC(Rhs, 1).first_column; \ 124 (Cur).last_line = YYRHSLOC(Rhs, N).last_line; \ 125 (Cur).last_column = YYRHSLOC(Rhs, N).last_column; \ 126 (Cur).filename = YYRHSLOC(Rhs, 1).filename; \ 127 } else { \ 128 (Cur).first_line = (Cur).last_line = \ 129 YYRHSLOC(Rhs, 0).last_line; \ 130 (Cur).first_column = (Cur).last_column = \ 131 YYRHSLOC(Rhs, 0).last_column; \ 132 (Cur).filename = YYRHSLOC(Rhs, 0).filename; \ 133 } \ 134 while (0) 119 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type 120 #define YYLLOC_DEFAULT(Cur, Rhs, N) \ 121 if ( N ) { \ 122 (Cur).first_line = YYRHSLOC( Rhs, 1 ).first_line; \ 123 (Cur).first_column = YYRHSLOC( Rhs, 1 ).first_column; \ 124 (Cur).last_line = YYRHSLOC( Rhs, N ).last_line; \ 125 (Cur).last_column = YYRHSLOC( Rhs, N ).last_column; \ 126 (Cur).filename = YYRHSLOC( Rhs, 1 ).filename; \ 127 } else { \ 128 (Cur).first_line = (Cur).last_line = YYRHSLOC( Rhs, 0 ).last_line; \ 129 (Cur).first_column = (Cur).last_column = YYRHSLOC( Rhs, 0 ).last_column; \ 130 (Cur).filename = YYRHSLOC( Rhs, 0 ).filename; \ 131 } 135 132 %} 136 133 137 134 %define parse.error verbose 138 135 139 // Types declaration 136 // Types declaration for productions 140 137 %union 141 138 { … … 173 170 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 174 171 %token BOOL COMPLEX IMAGINARY // C99 172 %token INT128 FLOAT80 FLOAT128 // GCC 175 173 %token ZERO_T ONE_T // CFA 176 174 %token VALIST // GCC … … 252 250 %type<sn> exception_statement handler_clause finally_clause 253 251 %type<catch_kind> handler_key 252 %type<sn> mutex_statement 254 253 %type<en> when_clause when_clause_opt waitfor timeout 255 254 %type<sn> waitfor_statement … … 458 457 | '(' compound_statement ')' // GCC, lambda expression 459 458 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 460 | primary_expression '{' argument_expression_list '}' // CFA, constructor call461 {462 Token fn;463 fn.str = new std::string( "?{}" ); // location undefined - use location of '{'?464 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );465 }466 459 | type_name '.' no_attr_identifier // CFA, nested type 467 460 { $$ = nullptr; } // FIX ME … … 478 471 // equivalent to the old x[i,j]. 479 472 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $4 ) ); } 473 | postfix_expression '{' argument_expression_list '}' // CFA, constructor call 474 { 475 Token fn; 476 fn.str = new std::string( "?{}" ); // location undefined - use location of '{'? 477 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) ); 478 } 480 479 | postfix_expression '(' argument_expression_list ')' 481 480 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } … … 809 808 | jump_statement 810 809 | with_statement 810 | mutex_statement 811 811 | waitfor_statement 812 812 | exception_statement … … 1033 1033 ; 1034 1034 1035 // If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so change syntax to "with mutex". 1036 mutex_statement: 1037 MUTEX '(' argument_expression_list ')' statement 1038 { $$ = nullptr; } // FIX ME 1039 ; 1040 1035 1041 when_clause: 1036 1042 WHEN '(' comma_expression ')' … … 1551 1557 | VOLATILE 1552 1558 { $$ = DeclarationNode::newTypeQualifier( Type::Volatile ); } 1553 | MUTEX1554 { $$ = DeclarationNode::newTypeQualifier( Type::Mutex ); }1555 1559 | ATOMIC 1556 1560 { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); } … … 1606 1610 1607 1611 basic_type_name: 1608 CHAR 1612 VOID 1613 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } 1614 | BOOL // C99 1615 { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 1616 | CHAR 1609 1617 { $$ = DeclarationNode::newBasicType( DeclarationNode::Char ); } 1618 | INT 1619 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); } 1620 | INT128 1621 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 ); } 1622 | FLOAT 1623 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); } 1624 | FLOAT80 1625 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); } 1626 | FLOAT128 1627 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float128 ); } 1610 1628 | DOUBLE 1611 1629 { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); } 1612 | FLOAT 1613 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); } 1614 | INT 1615 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); } 1616 | LONG 1617 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 1618 | SHORT 1619 { $$ = DeclarationNode::newLength( DeclarationNode::Short ); } 1630 | COMPLEX // C99 1631 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 1632 | IMAGINARY // C99 1633 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1620 1634 | SIGNED 1621 1635 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Signed ); } 1622 1636 | UNSIGNED 1623 1637 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); } 1624 | VOID 1625 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } 1626 | BOOL // C99 1627 { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 1628 | COMPLEX // C99 1629 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 1630 | IMAGINARY // C99 1631 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1638 | SHORT 1639 { $$ = DeclarationNode::newLength( DeclarationNode::Short ); } 1640 | LONG 1641 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 1632 1642 | ZERO_T 1633 1643 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } … … 2699 2709 paren_identifier attribute_list_opt 2700 2710 { $$ = $1->addQualifiers( $2 ); } 2711 | '&' MUTEX paren_identifier attribute_list_opt 2712 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); } 2701 2713 | identifier_parameter_ptr 2702 2714 | identifier_parameter_array attribute_list_opt … … 2739 2751 // 2740 2752 // typedef int foo; 2753 // forall( otype T ) foo( T ); 2741 2754 // int f( int foo ); // redefine typedef name in new scope 2742 2755 // … … 2746 2759 typedef attribute_list_opt 2747 2760 { $$ = $1->addQualifiers( $2 ); } 2761 | '&' MUTEX typedef attribute_list_opt 2762 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); } 2748 2763 | type_parameter_ptr 2749 2764 | type_parameter_array attribute_list_opt … … 2892 2907 abstract_parameter_declarator: 2893 2908 abstract_parameter_ptr 2909 | '&' MUTEX attribute_list_opt 2910 { $$ = DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf )->addQualifiers( $3 ); } 2894 2911 | abstract_parameter_array attribute_list_opt 2895 2912 { $$ = $1->addQualifiers( $2 ); }
Note:
See TracChangeset
for help on using the changeset viewer.