Changes in / [8f13c98:d2887f7]
- Location:
- src/Parser
- Files:
-
- 5 edited
-
DeclarationNode.cc (modified) (3 diffs)
-
ParseNode.h (modified) (3 diffs)
-
TypeData.cc (modified) (4 diffs)
-
TypeData.h (modified) (2 diffs)
-
parser.yy (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r8f13c98 rd2887f7 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 22 15:37:17 201813 // Update Count : 103 312 // Last Modified On : Mon Nov 20 09:21:52 2017 13 // Update Count : 1031 14 14 // 15 15 … … 120 120 } // DeclarationNode::clone 121 121 122 bool DeclarationNode::get_hasEllipsis() const { 123 return hasEllipsis; 124 } 125 122 126 void DeclarationNode::print( std::ostream &os, int indent ) const { 123 127 os << string( indent, ' ' ); … … 163 167 } 164 168 165 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ) {169 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) { 166 170 DeclarationNode * newnode = new DeclarationNode; 167 171 newnode->name = name; 168 172 newnode->type = new TypeData( TypeData::Function ); 169 173 newnode->type->function.params = param; 174 newnode->type->function.newStyle = newStyle; 170 175 newnode->type->function.body = body; 171 176 -
src/Parser/ParseNode.h
r8f13c98 rd2887f7 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 22 15:31:48 201813 // Update Count : 82 612 // Last Modified On : Mon Nov 27 17:33:35 2017 13 // Update Count : 824 14 14 // 15 15 … … 226 226 static DeclarationNode * newForall( DeclarationNode * ); 227 227 static DeclarationNode * newFromTypedef( std::string * ); 228 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );228 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false ); 229 229 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 230 230 static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body ); … … 288 288 Type * buildType() const; 289 289 290 bool get_hasEllipsis() const; 290 291 LinkageSpec::Spec get_linkage() const { return linkage; } 291 292 DeclarationNode * extractAggregate() const; -
src/Parser/TypeData.cc
r8f13c98 rd2887f7 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 22 15:49:00 201813 // Update Count : 5 9712 // Last Modified On : Mon Sep 25 18:33:41 2017 13 // Update Count : 587 14 14 // 15 15 … … 54 54 function.oldDeclList = nullptr; 55 55 function.body = nullptr; 56 function.newStyle = false; 56 57 function.withExprs = nullptr; 57 58 break; … … 194 195 newtype->function.oldDeclList = maybeClone( function.oldDeclList ); 195 196 newtype->function.body = maybeClone( function.body ); 197 newtype->function.newStyle = function.newStyle; 196 198 newtype->function.withExprs = maybeClone( function.withExprs ); 197 199 break; … … 879 881 FunctionType * buildFunction( const TypeData * td ) { 880 882 assert( td->kind == TypeData::Function ); 881 FunctionType * ft = new FunctionType( buildQualifiers( td ), ! td->function.params || td->function.params->hasEllipsis ); 883 bool hasEllipsis = td->function.params ? td->function.params->get_hasEllipsis() : true; 884 if ( ! td->function.params ) hasEllipsis = ! td->function.newStyle; 885 FunctionType * ft = new FunctionType( buildQualifiers( td ), hasEllipsis ); 882 886 buildList( td->function.params, ft->get_parameters() ); 883 887 buildForall( td->forall, ft->get_forall() ); -
src/Parser/TypeData.h
r8f13c98 rd2887f7 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 22 15:21:23 201813 // Update Count : 19 112 // Last Modified On : Fri Sep 1 23:33:45 2017 13 // Update Count : 190 14 14 // 15 15 … … 64 64 mutable DeclarationNode * oldDeclList; 65 65 StatementNode * body; 66 bool newStyle; 66 67 ExpressionNode * withExprs; // expressions from function's with_clause 67 68 }; -
src/Parser/parser.yy
r8f13c98 rd2887f7 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 22 15:31:19201813 // Update Count : 30 2712 // Last Modified On : Thu Feb 15 17:12:31 2018 13 // Update Count : 3006 14 14 // 15 15 … … 314 314 %type<decl> cfa_identifier_parameter_declarator_tuple cfa_identifier_parameter_ptr 315 315 316 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list _opt316 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list cfa_parameter_type_list_opt 317 317 318 318 %type<decl> cfa_typedef_declaration cfa_variable_declaration cfa_variable_specifier … … 322 322 %type<decl> KR_declaration_list KR_declaration_list_opt 323 323 324 %type<decl> parameter_declaration parameter_list parameter_type_list_opt 324 %type<decl> parameter_declaration parameter_list parameter_type_list 325 %type<decl> parameter_type_list_opt 325 326 326 327 %type<decl> paren_identifier paren_type … … 778 779 | unary_expression assignment_operator assignment_expression 779 780 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 780 | unary_expression '=' '{' initializer_list comma_opt '}' 781 { throw SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME781 | unary_expression '=' '{' initializer_list comma_opt '}' // FIX ME 782 { $$ = nullptr; } 782 783 ; 783 784 … … 848 849 | waitfor_statement 849 850 | exception_statement 850 | enable_disable_statement851 { throw SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME852 851 | asm_statement 853 852 ; … … 1065 1064 | RETURN comma_expression_opt ';' 1066 1065 { $$ = new StatementNode( build_return( $2 ) ); } 1067 | RETURN '{' initializer_list comma_opt '}' 1068 { throw SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME1066 | RETURN '{' initializer_list comma_opt '}' // FIX ME 1067 { $$ = nullptr; } 1069 1068 | THROW assignment_expression_opt ';' // handles rethrow 1070 1069 { $$ = new StatementNode( build_throw( $2 ) ); } … … 1194 1193 ; 1195 1194 1196 enable_disable_statement:1197 enable_disable_key identifier_list compound_statement1198 ;1199 1200 enable_disable_key:1201 ENABLE1202 | DISABLE1203 ;1204 1205 1195 asm_statement: 1206 1196 ASM asm_volatile_opt '(' string_literal ')' ';' … … 1402 1392 DeclarationNode * ret = new DeclarationNode; 1403 1393 ret->type = maybeClone( $1->type->base ); 1404 $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr ) );1394 $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr, true ) ); 1405 1395 } 1406 1396 ; … … 1432 1422 // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator). 1433 1423 { 1434 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 );1424 $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true ); 1435 1425 } 1436 1426 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' 1437 1427 { 1438 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 );1428 $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true ); 1439 1429 } 1440 1430 ; … … 2000 1990 ; 2001 1991 2002 cfa_parameter_type_list_opt: // CFA, abstract + real 1992 // Minimum of one parameter after which ellipsis is allowed only at the end. 1993 1994 cfa_parameter_type_list_opt: // CFA 2003 1995 // empty 2004 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }2005 | ELLIPSIS2006 1996 { $$ = nullptr; } 2007 | cfa_abstract_parameter_list 1997 | cfa_parameter_type_list 1998 ; 1999 2000 cfa_parameter_type_list: // CFA, abstract + real 2001 cfa_abstract_parameter_list 2008 2002 | cfa_parameter_list 2009 2003 | cfa_parameter_list pop ',' push cfa_abstract_parameter_list … … 2036 2030 // empty 2037 2031 { $$ = nullptr; } 2038 | ELLIPSIS 2039 { $$ = nullptr; } 2040 | parameter_list 2032 | parameter_type_list 2033 ; 2034 2035 parameter_type_list: 2036 parameter_list 2041 2037 | parameter_list pop ',' push ELLIPSIS 2042 2038 { $$ = $1->addVarArgs(); }
Note:
See TracChangeset
for help on using the changeset viewer.