Changes in src/Parser/parser.yy [f9941ff:d48e529]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rf9941ff rd48e529 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Oct 25 12:28:54201713 // Update Count : 28 9312 // Last Modified On : Thu Sep 14 23:07:12 2017 13 // Update Count : 2815 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 // more information in syntax errors45 #define YYERROR_VERBOSE 46 46 47 47 #undef __GNUC_MINOR__ … … 117 117 bool forall = false; // aggregate have one or more forall qualifiers ? 118 118 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 } 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) 132 135 %} 133 136 134 137 %define parse.error verbose 135 138 136 // Types declaration for productions139 // Types declaration 137 140 %union 138 141 { … … 170 173 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 171 174 %token BOOL COMPLEX IMAGINARY // C99 172 %token INT128 FLOAT80 FLOAT128 // GCC173 175 %token ZERO_T ONE_T // CFA 174 176 %token VALIST // GCC … … 180 182 %token ATTRIBUTE EXTENSION // GCC 181 183 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 182 %token CHOOSE DISABLE ENABLE FALLTHRU FALLTHROUGHTRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA184 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA 183 185 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 184 186 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 … … 250 252 %type<sn> exception_statement handler_clause finally_clause 251 253 %type<catch_kind> handler_key 252 %type<sn> mutex_statement253 254 %type<en> when_clause when_clause_opt waitfor timeout 254 255 %type<sn> waitfor_statement … … 362 363 %precedence ELSE // token precedence for start of else clause in IF/WAITFOR statement 363 364 364 %locations // support location tracking for error messages365 %locations 365 366 366 367 %start translation_unit // parse-tree root … … 457 458 | '(' compound_statement ')' // GCC, lambda expression 458 459 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 460 | primary_expression '{' argument_expression_list '}' // CFA, constructor call 461 { 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 } 459 466 | type_name '.' no_attr_identifier // CFA, nested type 460 { throw SemanticError("Qualified names are currently unimplemented.");$$ = nullptr; } // FIX ME467 { $$ = nullptr; } // FIX ME 461 468 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 462 { throw SemanticError("Qualified names are currently unimplemented.");$$ = nullptr; } // FIX ME469 { $$ = nullptr; } // FIX ME 463 470 ; 464 471 … … 471 478 // equivalent to the old x[i,j]. 472 479 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $4 ) ); } 473 | postfix_expression '{' argument_expression_list '}' // CFA, constructor call474 {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 }479 480 | postfix_expression '(' argument_expression_list ')' 480 481 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } … … 808 809 | jump_statement 809 810 | with_statement 810 | mutex_statement811 811 | waitfor_statement 812 812 | exception_statement … … 974 974 ; 975 975 976 fall_through _name:// CFA976 fall_through: // CFA 977 977 FALLTHRU 978 | FALLTHROUGH979 ;980 981 fall_through: // CFA982 fall_through_name983 978 { $$ = nullptr; } 984 | fall_through_name';'979 | FALLTHRU ';' 985 980 { $$ = nullptr; } 986 981 ; … … 1038 1033 ; 1039 1034 1040 // If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so change syntax to "with mutex".1041 mutex_statement:1042 MUTEX '(' argument_expression_list ')' statement1043 { $$ = nullptr; } // FIX ME1044 ;1045 1046 1035 when_clause: 1047 1036 WHEN '(' comma_expression ')' … … 1562 1551 | VOLATILE 1563 1552 { $$ = DeclarationNode::newTypeQualifier( Type::Volatile ); } 1553 | MUTEX 1554 { $$ = DeclarationNode::newTypeQualifier( Type::Mutex ); } 1564 1555 | ATOMIC 1565 1556 { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); } … … 1615 1606 1616 1607 basic_type_name: 1617 VOID 1608 CHAR 1609 { $$ = DeclarationNode::newBasicType( DeclarationNode::Char ); } 1610 | DOUBLE 1611 { $$ = 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 ); } 1620 | SIGNED 1621 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Signed ); } 1622 | UNSIGNED 1623 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); } 1624 | VOID 1618 1625 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } 1619 1626 | BOOL // C99 1620 1627 { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 1621 | CHAR1622 { $$ = DeclarationNode::newBasicType( DeclarationNode::Char ); }1623 | INT1624 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); }1625 | INT1281626 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 ); }1627 | FLOAT1628 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); }1629 | FLOAT801630 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); }1631 | FLOAT1281632 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float128 ); }1633 | DOUBLE1634 { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); }1635 1628 | COMPLEX // C99 1636 1629 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 1637 1630 | IMAGINARY // C99 1638 1631 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1639 | SIGNED1640 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Signed ); }1641 | UNSIGNED1642 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); }1643 | SHORT1644 { $$ = DeclarationNode::newLength( DeclarationNode::Short ); }1645 | LONG1646 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }1647 1632 | ZERO_T 1648 1633 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } … … 2491 2476 | TYPEDEFname 2492 2477 | TYPEGENname 2493 | FALLTHROUGH2494 { $$ = Token{ new string( "fallthrough" ), { nullptr, -1 } }; }2495 2478 | CONST 2496 2479 { $$ = Token{ new string( "__const__" ), { nullptr, -1 } }; } … … 2716 2699 paren_identifier attribute_list_opt 2717 2700 { $$ = $1->addQualifiers( $2 ); } 2718 | '&' MUTEX paren_identifier attribute_list_opt2719 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); }2720 2701 | identifier_parameter_ptr 2721 2702 | identifier_parameter_array attribute_list_opt … … 2758 2739 // 2759 2740 // typedef int foo; 2760 // forall( otype T ) struct foo;2761 2741 // int f( int foo ); // redefine typedef name in new scope 2762 2742 // … … 2766 2746 typedef attribute_list_opt 2767 2747 { $$ = $1->addQualifiers( $2 ); } 2768 | '&' MUTEX typedef attribute_list_opt2769 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); }2770 2748 | type_parameter_ptr 2771 2749 | type_parameter_array attribute_list_opt … … 2914 2892 abstract_parameter_declarator: 2915 2893 abstract_parameter_ptr 2916 | '&' MUTEX attribute_list_opt2917 { $$ = DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf )->addQualifiers( $3 ); }2918 2894 | abstract_parameter_array attribute_list_opt 2919 2895 { $$ = $1->addQualifiers( $2 ); }
Note:
See TracChangeset
for help on using the changeset viewer.