Changeset 2a8427c6
- Timestamp:
- Feb 22, 2018, 4:52:25 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 8f13c98
- Parents:
- 4ada74e
- Location:
- src/Parser
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r4ada74e r2a8427c6 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Nov 20 09:21:52 201713 // Update Count : 103 112 // Last Modified On : Thu Feb 22 15:37:17 2018 13 // Update Count : 1033 14 14 // 15 15 … … 120 120 } // DeclarationNode::clone 121 121 122 bool DeclarationNode::get_hasEllipsis() const {123 return hasEllipsis;124 }125 126 122 void DeclarationNode::print( std::ostream &os, int indent ) const { 127 123 os << string( indent, ' ' ); … … 167 163 } 168 164 169 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body , bool newStyle) {165 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ) { 170 166 DeclarationNode * newnode = new DeclarationNode; 171 167 newnode->name = name; 172 168 newnode->type = new TypeData( TypeData::Function ); 173 169 newnode->type->function.params = param; 174 newnode->type->function.newStyle = newStyle;175 170 newnode->type->function.body = body; 176 171 -
src/Parser/ParseNode.h
r4ada74e r2a8427c6 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Nov 27 17:33:35 201713 // Update Count : 82 412 // Last Modified On : Thu Feb 22 15:31:48 2018 13 // Update Count : 826 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 , bool newStyle = false);228 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 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;291 290 LinkageSpec::Spec get_linkage() const { return linkage; } 292 291 DeclarationNode * extractAggregate() const; -
src/Parser/TypeData.cc
r4ada74e r2a8427c6 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 25 18:33:41 201713 // Update Count : 5 8712 // Last Modified On : Thu Feb 22 15:49:00 2018 13 // Update Count : 597 14 14 // 15 15 … … 54 54 function.oldDeclList = nullptr; 55 55 function.body = nullptr; 56 function.newStyle = false;57 56 function.withExprs = nullptr; 58 57 break; … … 195 194 newtype->function.oldDeclList = maybeClone( function.oldDeclList ); 196 195 newtype->function.body = maybeClone( function.body ); 197 newtype->function.newStyle = function.newStyle;198 196 newtype->function.withExprs = maybeClone( function.withExprs ); 199 197 break; … … 881 879 FunctionType * buildFunction( const TypeData * td ) { 882 880 assert( td->kind == TypeData::Function ); 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 ); 881 FunctionType * ft = new FunctionType( buildQualifiers( td ), ! td->function.params || td->function.params->hasEllipsis ); 886 882 buildList( td->function.params, ft->get_parameters() ); 887 883 buildForall( td->forall, ft->get_forall() ); -
src/Parser/TypeData.h
r4ada74e r2a8427c6 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Sep 1 23:33:45 201713 // Update Count : 19 012 // Last Modified On : Thu Feb 22 15:21:23 2018 13 // Update Count : 191 14 14 // 15 15 … … 64 64 mutable DeclarationNode * oldDeclList; 65 65 StatementNode * body; 66 bool newStyle;67 66 ExpressionNode * withExprs; // expressions from function's with_clause 68 67 }; -
src/Parser/parser.yy
r4ada74e r2a8427c6 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 15 17:12:31201813 // Update Count : 30 0612 // Last Modified On : Thu Feb 22 15:31:19 2018 13 // Update Count : 3027 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 cfa_parameter_type_list_opt316 %type<decl> cfa_parameter_declaration cfa_parameter_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 325 %type<decl> parameter_type_list_opt 324 %type<decl> parameter_declaration parameter_list parameter_type_list_opt 326 325 327 326 %type<decl> paren_identifier paren_type … … 779 778 | unary_expression assignment_operator assignment_expression 780 779 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 781 | unary_expression '=' '{' initializer_list comma_opt '}' // FIX ME782 { $$ = nullptr; }780 | unary_expression '=' '{' initializer_list comma_opt '}' 781 { throw SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME 783 782 ; 784 783 … … 849 848 | waitfor_statement 850 849 | exception_statement 850 | enable_disable_statement 851 { throw SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME 851 852 | asm_statement 852 853 ; … … 1064 1065 | RETURN comma_expression_opt ';' 1065 1066 { $$ = new StatementNode( build_return( $2 ) ); } 1066 | RETURN '{' initializer_list comma_opt '}' // FIX ME1067 { $$ = nullptr; }1067 | RETURN '{' initializer_list comma_opt '}' 1068 { throw SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME 1068 1069 | THROW assignment_expression_opt ';' // handles rethrow 1069 1070 { $$ = new StatementNode( build_throw( $2 ) ); } … … 1193 1194 ; 1194 1195 1196 enable_disable_statement: 1197 enable_disable_key identifier_list compound_statement 1198 ; 1199 1200 enable_disable_key: 1201 ENABLE 1202 | DISABLE 1203 ; 1204 1195 1205 asm_statement: 1196 1206 ASM asm_volatile_opt '(' string_literal ')' ';' … … 1392 1402 DeclarationNode * ret = new DeclarationNode; 1393 1403 ret->type = maybeClone( $1->type->base ); 1394 $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr , true) );1404 $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr ) ); 1395 1405 } 1396 1406 ; … … 1422 1432 // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator). 1423 1433 { 1424 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 , true);1434 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); 1425 1435 } 1426 1436 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' 1427 1437 { 1428 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 , true);1438 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); 1429 1439 } 1430 1440 ; … … 1990 2000 ; 1991 2001 1992 // Minimum of one parameter after which ellipsis is allowed only at the end. 1993 1994 cfa_parameter_type_list_opt: // CFA 2002 cfa_parameter_type_list_opt: // CFA, abstract + real 1995 2003 // empty 2004 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } 2005 | ELLIPSIS 1996 2006 { $$ = nullptr; } 1997 | cfa_parameter_type_list 1998 ; 1999 2000 cfa_parameter_type_list: // CFA, abstract + real 2001 cfa_abstract_parameter_list 2007 | cfa_abstract_parameter_list 2002 2008 | cfa_parameter_list 2003 2009 | cfa_parameter_list pop ',' push cfa_abstract_parameter_list … … 2030 2036 // empty 2031 2037 { $$ = nullptr; } 2032 | parameter_type_list 2033 ; 2034 2035 parameter_type_list: 2036 parameter_list 2038 | ELLIPSIS 2039 { $$ = nullptr; } 2040 | parameter_list 2037 2041 | parameter_list pop ',' push ELLIPSIS 2038 2042 { $$ = $1->addVarArgs(); }
Note: See TracChangeset
for help on using the changeset viewer.