Changes in src/Parser/parser.yy [1b54b54:1b8f13f0]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r1b54b54 r1b8f13f0 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 21 08:45:07 201913 // Update Count : 4 23212 // Last Modified On : Thu Nov 8 18:08:23 2018 13 // Update Count : 4052 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 … … 191 193 return new ForCtrl( 192 194 distAttr( DeclarationNode::newTypeof( type, true ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), 193 // NULL comp/inc => leave blank 194 comp ? new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ) : 0, 195 inc ? new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto 196 OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) : 0 ); 195 new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ), 196 new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto 197 OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) ); 197 198 } // forCtrl 198 199 … … 200 201 if ( NameExpr * identifier = dynamic_cast<NameExpr *>(index->get_expr()) ) { 201 202 return forCtrl( type, new string( identifier->name ), start, compop, comp, inc ); 202 } else if ( CommaExpr * commaExpr = dynamic_cast<CommaExpr *>(index->get_expr()) ) {203 if ( NameExpr * identifier = dynamic_cast<NameExpr *>(commaExpr->arg1 ) ) {204 return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );205 } else {206 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;207 } // if208 203 } else { 209 204 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr; … … 268 263 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 269 264 %token BOOL COMPLEX IMAGINARY // C99 270 %token INT128 uuFLOAT80 uuFLOAT128 // GCC 271 %token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC 265 %token INT128 FLOAT80 FLOAT128 // GCC 272 266 %token ZERO_T ONE_T // CFA 273 267 %token VALIST // GCC … … 330 324 %type<en> argument_expression_list argument_expression default_initialize_opt 331 325 %type<ifctl> if_control_expression 332 %type<fctl> for_control_expression for_control_expression_list326 %type<fctl> for_control_expression 333 327 %type<compop> inclexcl 334 328 %type<en> subrange … … 990 984 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER 991 985 identifier_or_type_name ':' attribute_list_opt statement 992 { $$ = $4->add_label( $1, $3 ); } 986 { 987 $$ = $4->add_label( $1, $3 ); 988 } 993 989 ; 994 990 … … 1006 1002 statement_decl 1007 1003 | statement_decl_list statement_decl 1008 { assert( $1 ); $1->set_last( $2 ); $$ = $1;}1004 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } } 1009 1005 ; 1010 1006 … … 1013 1009 { $$ = new StatementNode( $1 ); } 1014 1010 | EXTENSION declaration // GCC 1015 { distExt( $2 ); $$ = new StatementNode( $2 ); } 1011 { 1012 distExt( $2 ); 1013 $$ = new StatementNode( $2 ); 1014 } 1016 1015 | function_definition 1017 1016 { $$ = new StatementNode( $1 ); } 1018 1017 | EXTENSION function_definition // GCC 1019 { distExt( $2 ); $$ = new StatementNode( $2 ); } 1018 { 1019 distExt( $2 ); 1020 $$ = new StatementNode( $2 ); 1021 } 1020 1022 | statement 1021 1023 ; … … 1024 1026 statement 1025 1027 | statement_list_nodecl statement 1026 { assert( $1 ); $1->set_last( $2 ); $$ = $1;}1028 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } } 1027 1029 ; 1028 1030 … … 1136 1138 | DO statement WHILE '(' ')' ';' // CFA => do while( 1 ) 1137 1139 { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), $2 ) ); } 1138 | FOR '(' push for_control_expression _list')' statement pop1140 | FOR '(' push for_control_expression ')' statement pop 1139 1141 { $$ = new StatementNode( build_for( $4, $6 ) ); } 1140 1142 | FOR '(' ')' statement // CFA => for ( ;; ) … … 1142 1144 ; 1143 1145 1144 for_control_expression_list:1145 for_control_expression1146 | for_control_expression_list ':' for_control_expression1147 { $$ = $3; }1148 ;1149 1150 1146 for_control_expression: 1151 ';' comma_expression_opt ';' comma_expression_opt 1152 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); } 1153 | comma_expression ';' comma_expression_opt ';' comma_expression_opt 1154 { $$ = new ForCtrl( $1, $3, $5 ); } 1155 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1156 { $$ = new ForCtrl( $1, $2, $4 ); } 1157 | comma_expression // CFA 1147 comma_expression // CFA 1158 1148 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1159 1149 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1160 | co mma_expression inclexcl comma_expression// CFA1150 | constant_expression inclexcl constant_expression // CFA 1161 1151 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1162 | co mma_expression inclexcl comma_expression '~' comma_expression // CFA1152 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1163 1153 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } 1164 1154 | comma_expression ';' comma_expression // CFA 1165 1155 { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1166 1156 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1167 | comma_expression ';' co mma_expression inclexcl comma_expression // CFA1157 | comma_expression ';' constant_expression inclexcl constant_expression // CFA 1168 1158 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1169 | comma_expression ';' co mma_expression inclexcl comma_expression '~' comma_expression // CFA1159 | comma_expression ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA 1170 1160 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); } 1171 | comma_expression ';' comma_expression '~' '@' '~' comma_expression // CFA1172 { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::LThan, nullptr, $7); }1173 | comma_expression ';' comma_expression ErangeDown '@' '~' comma_expression // CFA1174 { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::GThan, nullptr, $7); }1175 | comma_expression ';' comma_expression '~' '@' '~' '@' // CFA1176 { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::LThan, nullptr, nullptr); }1161 | comma_expression ';' comma_expression_opt ';' comma_expression_opt 1162 { $$ = new ForCtrl( $1, $3, $5 ); } 1163 | ';' comma_expression_opt ';' comma_expression_opt 1164 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); } 1165 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1166 { $$ = new ForCtrl( $1, $2, $4 ); } 1177 1167 ; 1178 1168 … … 1781 1771 | FLOAT 1782 1772 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); } 1773 | FLOAT80 1774 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); } 1775 | FLOAT128 1776 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float128 ); } 1783 1777 | DOUBLE 1784 1778 { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); } 1785 | uuFLOAT801786 { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat80 ); }1787 | uuFLOAT1281788 { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat128 ); }1789 | uFLOAT161790 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat16 ); }1791 | uFLOAT321792 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32 ); }1793 | uFLOAT32X1794 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32x ); }1795 | uFLOAT641796 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64 ); }1797 | uFLOAT64X1798 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64x ); }1799 | uFLOAT1281800 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat128 ); }1801 1779 | COMPLEX // C99 1802 1780 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
Note:
See TracChangeset
for help on using the changeset viewer.