Changeset df6cc9d for src/Parser/parser.yy
- Timestamp:
- Oct 19, 2022, 4:43:26 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 1a45263
- Parents:
- 9cd5bd2 (diff), 135143ba (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r9cd5bd2 rdf6cc9d 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 27 13:21:28202213 // Update Count : 5 66112 // Last Modified On : Fri Oct 14 14:04:43 2022 13 // Update Count : 5751 14 14 // 15 15 … … 103 103 // distribute declaration_specifier across all declared variables, e.g., static, const, but not __attribute__. 104 104 assert( declList ); 105 //printf( "distAttr1 typeSpec %p\n", typeSpec ); typeSpec->print( std::cout );105 // printf( "distAttr1 typeSpec %p\n", typeSpec ); typeSpec->print( std::cout ); 106 106 DeclarationNode * cur = declList, * cl = (new DeclarationNode)->addType( typeSpec ); 107 //printf( "distAttr2 cl %p\n", cl ); cl->type->print( std::cout );108 //cl->type->aggregate.name = cl->type->aggInst.aggregate->aggregate.name;107 // printf( "distAttr2 cl %p\n", cl ); cl->type->print( std::cout ); 108 // cl->type->aggregate.name = cl->type->aggInst.aggregate->aggregate.name; 109 109 110 110 for ( cur = dynamic_cast<DeclarationNode *>( cur->get_next() ); cur != nullptr; cur = dynamic_cast<DeclarationNode *>( cur->get_next() ) ) { … … 112 112 } // for 113 113 declList->addType( cl ); 114 //printf( "distAttr3 declList %p\n", declList ); declList->print( std::cout, 0 );114 // printf( "distAttr3 declList %p\n", declList ); declList->print( std::cout, 0 ); 115 115 return declList; 116 116 } // distAttr … … 248 248 } // forCtrl 249 249 250 static void IdentifierBeforeIdentifier( string & identifier1, string & identifier2, const char * kind ) { 251 SemanticError( yylloc, ::toString( "Adjacent identifiers \"", identifier1, "\" and \"", identifier2, "\" are not meaningful in a", kind, ".\n" 252 "Possible cause is misspelled type name or missing generic parameter." ) ); 253 } // IdentifierBeforeIdentifier 254 255 static void IdentifierBeforeType( string & identifier, const char * kind ) { 256 SemanticError( yylloc, ::toString( "Identifier \"", identifier, "\" cannot appear before a ", kind, ".\n" 257 "Possible cause is misspelled storage/CV qualifier, misspelled typename, or missing generic parameter." ) ); 258 } // IdentifierBeforeType 259 250 260 bool forall = false; // aggregate have one or more forall qualifiers ? 251 261 … … 295 305 %token TYPEDEF 296 306 %token EXTERN STATIC AUTO REGISTER 297 %token THREADLOCALGCC THREADLOCALC11 307 %token THREADLOCALGCC THREADLOCALC11 // GCC, C11 298 308 %token INLINE FORTRAN // C99, extension ISO/IEC 9899:1999 Section J.5.9(1) 299 309 %token NORETURN // C11 … … 308 318 %token DECIMAL32 DECIMAL64 DECIMAL128 // GCC 309 319 %token ZERO_T ONE_T // CFA 310 %token SIZEOF TYPEOF VA LIST AUTO_TYPE// GCC320 %token SIZEOF TYPEOF VA_LIST VA_ARG AUTO_TYPE // GCC 311 321 %token OFFSETOF BASETYPEOF TYPEID // CFA 312 322 %token ENUM STRUCT UNION … … 399 409 // declarations 400 410 %type<decl> abstract_declarator abstract_ptr abstract_array abstract_function array_dimension multi_array_dimension 401 %type<decl> abstract_parameter_declarator abstract_parameter_ptr abstract_parameter_array abstract_parameter_function array_parameter_dimension array_parameter_1st_dimension411 %type<decl> abstract_parameter_declarator_opt abstract_parameter_declarator abstract_parameter_ptr abstract_parameter_array abstract_parameter_function array_parameter_dimension array_parameter_1st_dimension 402 412 %type<decl> abstract_parameter_declaration 403 413 … … 651 661 // { SemanticError( yylloc, "Resume expression is currently unimplemented." ); $$ = nullptr; } 652 662 | IDENTIFIER IDENTIFIER // syntax error 653 { 654 SemanticError( yylloc, ::toString( "Adjacent identifiers are not meaningful in an expression. " 655 "Possible problem is identifier \"", *$1.str, 656 "\" is a misspelled typename or an incorrectly specified type name, " 657 "e.g., missing generic parameter or missing struct/union/enum before typename." ) ); 658 $$ = nullptr; 659 } 660 | IDENTIFIER direct_type // syntax error 661 { 662 SemanticError( yylloc, ::toString( "Identifier \"", *$1.str, "\" cannot appear before a type. " 663 "Possible problem is misspelled storage or CV qualifier." ) ); 664 $$ = nullptr; 665 } 663 { IdentifierBeforeIdentifier( *$1.str, *$2.str, "n expression" ); $$ = nullptr; } 664 | IDENTIFIER type_qualifier // syntax error 665 { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; } 666 | IDENTIFIER storage_class // syntax error 667 { IdentifierBeforeType( *$1.str, "storage class" ); $$ = nullptr; } 668 | IDENTIFIER basic_type_name // syntax error 669 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 670 | IDENTIFIER TYPEDEFname // syntax error 671 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 672 | IDENTIFIER TYPEGENname // syntax error 673 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 666 674 ; 667 675 … … 690 698 primary_expression 691 699 | postfix_expression '[' assignment_expression ',' tuple_expression_list ']' 692 693 694 700 // Historic, transitional: Disallow commas in subscripts. 701 // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts. 702 // Current: Commas in subscripts make tuples. 695 703 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); } 696 704 | postfix_expression '[' assignment_expression ']' … … 712 720 | postfix_expression '(' argument_expression_list_opt ')' 713 721 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 722 | VA_ARG '(' primary_expression ',' declaration_specifier_nobody abstract_parameter_declarator_opt ')' 723 // { SemanticError( yylloc, "va_arg is currently unimplemented." ); $$ = nullptr; } 724 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( new string( "__builtin_va_arg") ) ), 725 (ExpressionNode *)($3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) )) ) ); } 714 726 | postfix_expression '`' identifier // CFA, postfix call 715 727 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); } … … 2148 2160 | LONG 2149 2161 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 2150 | VA LIST // GCC, __builtin_va_list2162 | VA_LIST // GCC, __builtin_va_list 2151 2163 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 2152 2164 | AUTO_TYPE … … 2593 2605 { $$ = DeclarationNode::newEnumValueGeneric( $1, $2 ); } 2594 2606 | INLINE type_name 2595 { $$ = DeclarationNode::newEnum ValueGeneric( new string("inline"), nullptr); }2607 { $$ = DeclarationNode::newEnumInLine( *$2->type->symbolic.name ); } 2596 2608 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2597 2609 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $3, $4 ) ); } … … 2993 3005 { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); } 2994 3006 | declaration 3007 | IDENTIFIER IDENTIFIER 3008 { IdentifierBeforeIdentifier( *$1.str, *$2.str, " declaration" ); $$ = nullptr; } 3009 | IDENTIFIER type_qualifier // syntax error 3010 { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; } 3011 | IDENTIFIER storage_class // syntax error 3012 { IdentifierBeforeType( *$1.str, "storage class" ); $$ = nullptr; } 3013 | IDENTIFIER basic_type_name // syntax error 3014 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 3015 | IDENTIFIER TYPEDEFname // syntax error 3016 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 3017 | IDENTIFIER TYPEGENname // syntax error 3018 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 2995 3019 | external_function_definition 2996 3020 | EXTENSION external_definition // GCC, multiple __extension__ allowed, meaning unknown … … 3023 3047 $$ = $6; 3024 3048 } 3049 // global distribution 3025 3050 | type_qualifier_list 3026 3051 { … … 3047 3072 | declaration_qualifier_list type_qualifier_list 3048 3073 { 3049 if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }3050 if ( ($1->type && $1->type->forall) || $2->type->forall) forall = true; // remember generic type3074 if ( ($1->type && $1->type->qualifiers.val) || ($2->type && $2->type->qualifiers.val) ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 3075 if ( ($1->type && $1->type->forall) || ($2->type && $2->type->forall) ) forall = true; // remember generic type 3051 3076 } 3052 3077 '{' up external_definition_list_opt down '}' // CFA, namespace … … 3655 3680 // functions. 3656 3681 3682 abstract_parameter_declarator_opt: 3683 // empty 3684 { $$ = nullptr; } 3685 | abstract_parameter_declarator 3686 ; 3687 3657 3688 abstract_parameter_declarator: 3658 3689 abstract_parameter_ptr
Note:
See TracChangeset
for help on using the changeset viewer.