Changeset a77713b
- Timestamp:
- Feb 13, 2022, 4:38:25 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- a8ef59e
- Parents:
- ea89e36
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rea89e36 ra77713b 253 253 } // DeclarationNode::newAggregate 254 254 255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body ) {255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, bool ) { 256 256 DeclarationNode * newnode = new DeclarationNode; 257 257 newnode->type = new TypeData( TypeData::Enum ); … … 262 262 return newnode; 263 263 } // DeclarationNode::newEnum 264 265 264 266 265 267 DeclarationNode * DeclarationNode::newName( const string * name ) { -
src/Parser/ParseNode.h
rea89e36 ra77713b 235 235 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 236 236 static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 237 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body );237 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed ); 238 238 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); 239 239 static DeclarationNode * newName( const std::string * ); -
src/Parser/parser.yy
rea89e36 ra77713b 2277 2277 ; 2278 2278 2279 enum_type: // enum2279 enum_type: // static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed ); // enum 2280 2280 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2281 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }2281 { $$ = DeclarationNode::newEnum( nullptr, $4, true, false )->addQualifiers( $2 ); } 2282 2282 | ENUM attribute_list_opt identifier 2283 2283 { typedefTable.makeTypedef( *$3 ); } 2284 2284 '{' enumerator_list comma_opt '}' 2285 { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); }2285 { $$ = DeclarationNode::newEnum( $3, $6, true, false )->addQualifiers( $2 ); } 2286 2286 | ENUM attribute_list_opt typedef_name // unqualified type name 2287 2287 '{' enumerator_list comma_opt '}' 2288 { $$ = DeclarationNode::newEnum( $3->name, $5, true )->addQualifiers( $2 ); }2288 { $$ = DeclarationNode::newEnum( $3->name, $5, true, false )->addQualifiers( $2 ); } 2289 2289 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}' 2290 2290 { 2291 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2292 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2293 } 2294 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt 2291 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) 2292 { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2293 // SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2294 $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 ); 2295 } 2296 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt // Question: why attributes/qualifier after identifier 2295 2297 { 2296 2298 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } … … 2299 2301 '{' enumerator_list comma_opt '}' 2300 2302 { 2301 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;2303 $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ); 2302 2304 } 2303 2305 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}' … … 2305 2307 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2306 2308 typedefTable.makeTypedef( *$6->name ); 2307 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;2309 $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ); 2308 2310 } 2309 2311 | enum_type_nobody … … 2312 2314 enum_type_nobody: // enum - {...} 2313 2315 ENUM attribute_list_opt identifier 2314 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 ); }2316 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false, false )->addQualifiers( $2 ); } 2315 2317 | ENUM attribute_list_opt type_name // qualified type name 2316 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false )->addQualifiers( $2 ); }2318 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false, false )->addQualifiers( $2 ); } 2317 2319 ; 2318 2320
Note: See TracChangeset
for help on using the changeset viewer.