Changes in src/Parser/parser.yy [6d01d89:e15853c]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r6d01d89 re15853c 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 14 18:02:44201913 // Update Count : 4 21612 // Last Modified On : Wed Feb 13 17:56:23 2019 13 // Update Count : 4064 14 14 // 15 15 … … 99 99 // distribute declaration_specifier across all declared variables, e.g., static, const, __attribute__. 100 100 DeclarationNode * cur = declList, * cl = (new DeclarationNode)->addType( specifier ); 101 for ( cur = dynamic_cast<DeclarationNode *>( cur->get_next() ); cur != nullptr; cur = dynamic_cast<DeclarationNode *>( cur->get_next() ) ) { 101 //cur->addType( specifier ); 102 for ( cur = dynamic_cast< DeclarationNode * >( cur->get_next() ); cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) { 102 103 cl->cloneBaseType( cur ); 103 104 } // for 104 105 declList->addType( cl ); 106 // delete cl; 105 107 return declList; 106 108 } // distAttr … … 199 201 if ( NameExpr * identifier = dynamic_cast<NameExpr *>(index->get_expr()) ) { 200 202 return forCtrl( type, new string( identifier->name ), start, compop, comp, inc ); 201 } else if ( CommaExpr * commaExpr = dynamic_cast<CommaExpr *>(index->get_expr()) ) {202 if ( NameExpr * identifier = dynamic_cast<NameExpr *>(commaExpr->arg1 ) ) {203 return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );204 } else {205 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;206 } // if207 203 } else { 208 204 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr; … … 267 263 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 268 264 %token BOOL COMPLEX IMAGINARY // C99 269 %token INT128 FLOAT80 FLOAT128 // GCC 265 %token INT128 uuFLOAT80 uuFLOAT128 // GCC 266 %token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC 270 267 %token ZERO_T ONE_T // CFA 271 268 %token VALIST // GCC … … 328 325 %type<en> argument_expression_list argument_expression default_initialize_opt 329 326 %type<ifctl> if_control_expression 330 %type<fctl> for_control_expression for_control_expression_list327 %type<fctl> for_control_expression 331 328 %type<compop> inclexcl 332 329 %type<en> subrange … … 988 985 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER 989 986 identifier_or_type_name ':' attribute_list_opt statement 990 { $$ = $4->add_label( $1, $3 ); } 987 { 988 $$ = $4->add_label( $1, $3 ); 989 } 991 990 ; 992 991 … … 1004 1003 statement_decl 1005 1004 | statement_decl_list statement_decl 1006 { assert( $1 ); $1->set_last( $2 ); $$ = $1;}1005 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } } 1007 1006 ; 1008 1007 … … 1011 1010 { $$ = new StatementNode( $1 ); } 1012 1011 | EXTENSION declaration // GCC 1013 { distExt( $2 ); $$ = new StatementNode( $2 ); } 1012 { 1013 distExt( $2 ); 1014 $$ = new StatementNode( $2 ); 1015 } 1014 1016 | function_definition 1015 1017 { $$ = new StatementNode( $1 ); } 1016 1018 | EXTENSION function_definition // GCC 1017 { distExt( $2 ); $$ = new StatementNode( $2 ); } 1019 { 1020 distExt( $2 ); 1021 $$ = new StatementNode( $2 ); 1022 } 1018 1023 | statement 1019 1024 ; … … 1022 1027 statement 1023 1028 | statement_list_nodecl statement 1024 { assert( $1 ); $1->set_last( $2 ); $$ = $1;}1029 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } } 1025 1030 ; 1026 1031 … … 1134 1139 | DO statement WHILE '(' ')' ';' // CFA => do while( 1 ) 1135 1140 { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), $2 ) ); } 1136 | FOR '(' push for_control_expression _list')' statement pop1141 | FOR '(' push for_control_expression ')' statement pop 1137 1142 { $$ = new StatementNode( build_for( $4, $6 ) ); } 1138 1143 | FOR '(' ')' statement // CFA => for ( ;; ) … … 1140 1145 ; 1141 1146 1142 for_control_expression_list:1143 for_control_expression1144 | for_control_expression_list ':' for_control_expression1145 { $$ = $3; }1146 ;1147 1148 1147 for_control_expression: 1149 ';' comma_expression_opt ';' comma_expression_opt 1150 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); } 1151 | comma_expression ';' comma_expression_opt ';' comma_expression_opt 1152 { $$ = new ForCtrl( $1, $3, $5 ); } 1153 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1154 { $$ = new ForCtrl( $1, $2, $4 ); } 1155 | comma_expression // CFA 1148 comma_expression // CFA 1156 1149 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1157 1150 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1158 | co mma_expression inclexcl comma_expression// CFA1151 | constant_expression inclexcl constant_expression // CFA 1159 1152 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1160 | co mma_expression inclexcl comma_expression '~' comma_expression // CFA1153 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1161 1154 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } 1162 1155 | comma_expression ';' comma_expression // CFA 1163 1156 { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1164 1157 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1165 | comma_expression ';' co mma_expression inclexcl comma_expression // CFA1158 | comma_expression ';' constant_expression inclexcl constant_expression // CFA 1166 1159 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1167 | comma_expression ';' co mma_expression inclexcl comma_expression '~' comma_expression // CFA1160 | comma_expression ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA 1168 1161 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); } 1162 | comma_expression ';' comma_expression_opt ';' comma_expression_opt 1163 { $$ = new ForCtrl( $1, $3, $5 ); } 1164 | ';' comma_expression_opt ';' comma_expression_opt 1165 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); } 1166 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1167 { $$ = new ForCtrl( $1, $2, $4 ); } 1169 1168 ; 1170 1169 … … 1773 1772 | FLOAT 1774 1773 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); } 1775 | FLOAT801776 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); }1777 | FLOAT1281778 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float128 ); }1779 1774 | DOUBLE 1780 1775 { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); } 1776 | uuFLOAT80 1777 { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat80 ); } 1778 | uuFLOAT128 1779 { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat128 ); } 1780 | uFLOAT16 1781 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat16 ); } 1782 | uFLOAT32 1783 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32 ); } 1784 | uFLOAT32X 1785 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32x ); } 1786 | uFLOAT64 1787 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64 ); } 1788 | uFLOAT64X 1789 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64x ); } 1790 | uFLOAT128 1791 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat128 ); } 1781 1792 | COMPLEX // C99 1782 1793 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
Note:
See TracChangeset
for help on using the changeset viewer.