Changes in src/Parser/parser.yy [f259682:92355883]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (45 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rf259682 r92355883 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 18 22:51:30202313 // Update Count : 63 9112 // Last Modified On : Sat Jun 17 18:53:24 2023 13 // Update Count : 6347 14 14 // 15 15 … … 385 385 %type<str> string_literal_list 386 386 387 %type<enum_hiding> hide_opt visible_hide_opt387 %type<enum_hiding> hide_opt visible_hide_opt 388 388 389 389 // expressions 390 390 %type<expr> constant 391 %type<expr> tuple tuple_expression_list391 %type<expr> tuple tuple_expression_list 392 392 %type<oper> ptrref_operator unary_operator assignment_operator simple_assignment_operator compound_assignment_operator 393 393 %type<expr> primary_expression postfix_expression unary_expression 394 %type<expr> cast_expression_list cast_expression exponential_expression multiplicative_expression additive_expression395 %type<expr> shift_expression relational_expression equality_expression394 %type<expr> cast_expression_list cast_expression exponential_expression multiplicative_expression additive_expression 395 %type<expr> shift_expression relational_expression equality_expression 396 396 %type<expr> AND_expression exclusive_OR_expression inclusive_OR_expression 397 397 %type<expr> logical_AND_expression logical_OR_expression 398 398 %type<expr> conditional_expression constant_expression assignment_expression assignment_expression_opt 399 %type<expr> comma_expression comma_expression_opt400 %type<expr> argument_expression_list_opt argument_expression_list argument_expression default_initializer_opt399 %type<expr> comma_expression comma_expression_opt 400 %type<expr> argument_expression_list_opt argument_expression_list argument_expression default_initializer_opt 401 401 %type<ifctl> conditional_declaration 402 %type<forctl> for_control_expression for_control_expression_list402 %type<forctl> for_control_expression for_control_expression_list 403 403 %type<oper> upupeq updown updowneq downupdowneq 404 404 %type<expr> subrange 405 405 %type<decl> asm_name_opt 406 %type<expr> asm_operands_opt asm_operands_list asm_operand406 %type<expr> asm_operands_opt asm_operands_list asm_operand 407 407 %type<labels> label_list 408 408 %type<expr> asm_clobbers_list_opt … … 412 412 413 413 // statements 414 %type<stmt> statement labeled_statement compound_statement414 %type<stmt> statement labeled_statement compound_statement 415 415 %type<stmt> statement_decl statement_decl_list statement_list_nodecl 416 416 %type<stmt> selection_statement if_statement 417 %type<clause> switch_clause_list_opt switch_clause_list417 %type<clause> switch_clause_list_opt switch_clause_list 418 418 %type<expr> case_value 419 %type<clause> case_clause case_value_list case_label case_label_list419 %type<clause> case_clause case_value_list case_label case_label_list 420 420 %type<stmt> iteration_statement jump_statement 421 %type<stmt> expression_statement asm_statement421 %type<stmt> expression_statement asm_statement 422 422 %type<stmt> with_statement 423 423 %type<expr> with_clause_opt … … 427 427 %type<stmt> mutex_statement 428 428 %type<expr> when_clause when_clause_opt waitfor waituntil timeout 429 %type<stmt> waitfor_statement waituntil_statement429 %type<stmt> waitfor_statement waituntil_statement 430 430 %type<wfs> wor_waitfor_clause 431 431 %type<wucn> waituntil_clause wand_waituntil_clause wor_waituntil_clause … … 601 601 // around the list separator. 602 602 // 603 // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX603 // int f( forall(T) T (*f1) T , forall( S ) S (*f2)( S ) ); 604 604 // push pop push pop 605 605 … … 689 689 // | RESUME '(' comma_expression ')' compound_statement 690 690 // { SemanticError( yylloc, "Resume expression is currently unimplemented." ); $$ = nullptr; } 691 | IDENTIFIER IDENTIFIER // invalid syntax rule 691 | IDENTIFIER IDENTIFIER // invalid syntax rules 692 692 { IdentifierBeforeIdentifier( *$1.str, *$2.str, "n expression" ); $$ = nullptr; } 693 | IDENTIFIER type_qualifier // invalid syntax rule 693 | IDENTIFIER type_qualifier // invalid syntax rules 694 694 { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; } 695 | IDENTIFIER storage_class // invalid syntax rule 695 | IDENTIFIER storage_class // invalid syntax rules 696 696 { IdentifierBeforeType( *$1.str, "storage class" ); $$ = nullptr; } 697 | IDENTIFIER basic_type_name // invalid syntax rule 697 | IDENTIFIER basic_type_name // invalid syntax rules 698 698 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 699 | IDENTIFIER TYPEDEFname // invalid syntax rule 699 | IDENTIFIER TYPEDEFname // invalid syntax rules 700 700 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 701 | IDENTIFIER TYPEGENname // invalid syntax rule 701 | IDENTIFIER TYPEGENname // invalid syntax rules 702 702 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 703 703 ; … … 1275 1275 | DEFAULT ':' { $$ = new ClauseNode( build_default( yylloc ) ); } 1276 1276 // A semantic check is required to ensure only one default clause per switch/choose statement. 1277 | DEFAULT error // invalid syntax rule 1277 | DEFAULT error // invalid syntax rules 1278 1278 { SemanticError( yylloc, "syntax error, colon missing after default." ); $$ = nullptr; } 1279 1279 ; … … 1405 1405 else { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; } 1406 1406 } 1407 | comma_expression updowneq comma_expression '~' '@' // CFA, invalid syntax rule 1407 | comma_expression updowneq comma_expression '~' '@' // CFA, invalid syntax rules 1408 1408 { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; } 1409 | '@' updowneq '@' // CFA, invalid syntax rule 1409 | '@' updowneq '@' // CFA, invalid syntax rules 1410 1410 { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; } 1411 | '@' updowneq comma_expression '~' '@' // CFA, invalid syntax rule 1411 | '@' updowneq comma_expression '~' '@' // CFA, invalid syntax rules 1412 1412 { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; } 1413 | comma_expression updowneq '@' '~' '@' // CFA, invalid syntax rule 1413 | comma_expression updowneq '@' '~' '@' // CFA, invalid syntax rules 1414 1414 { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; } 1415 | '@' updowneq '@' '~' '@' // CFA, invalid syntax rule 1415 | '@' updowneq '@' '~' '@' // CFA, invalid syntax rules 1416 1416 { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; } 1417 1417 … … 1434 1434 else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, NEW_ONE ); 1435 1435 } 1436 | comma_expression ';' '@' updowneq '@' // CFA, invalid syntax rule 1436 | comma_expression ';' '@' updowneq '@' // CFA, invalid syntax rules 1437 1437 { SemanticError( yylloc, "syntax error, missing low/high value for up/down-to range so index is uninitialized." ); $$ = nullptr; } 1438 1438 1439 1439 | comma_expression ';' comma_expression updowneq comma_expression '~' comma_expression // CFA 1440 1440 { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), $7 ); } 1441 | comma_expression ';' '@' updowneq comma_expression '~' comma_expression // CFA, invalid syntax rule 1441 | comma_expression ';' '@' updowneq comma_expression '~' comma_expression // CFA, invalid syntax rules 1442 1442 { 1443 1443 if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } … … 1452 1452 | comma_expression ';' comma_expression updowneq comma_expression '~' '@' // CFA 1453 1453 { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), nullptr ); } 1454 | comma_expression ';' '@' updowneq comma_expression '~' '@' // CFA, invalid syntax rule 1454 | comma_expression ';' '@' updowneq comma_expression '~' '@' // CFA, invalid syntax rules 1455 1455 { 1456 1456 if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; } … … 1511 1511 else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, nullptr ); 1512 1512 } 1513 | declaration '@' updowneq '@' '~' '@' // CFA, invalid syntax rule 1513 | declaration '@' updowneq '@' '~' '@' // CFA, invalid syntax rules 1514 1514 { SemanticError( yylloc, "syntax error, missing low/high value for up/down-to range so index is uninitialized." ); $$ = nullptr; } 1515 1515 … … 1666 1666 { $$ = build_waitfor_timeout( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ); } 1667 1667 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1668 | wor_waitfor_clause wor when_clause_opt timeout statement wor ELSE statement // invalid syntax rule 1668 | wor_waitfor_clause wor when_clause_opt timeout statement wor ELSE statement // invalid syntax rules 1669 1669 { SemanticError( yylloc, "syntax error, else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; } 1670 1670 | wor_waitfor_clause wor when_clause_opt timeout statement wor when_clause ELSE statement … … 1708 1708 | wor_waituntil_clause wor when_clause_opt ELSE statement 1709 1709 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, build_waituntil_else( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); } 1710 | wor_waituntil_clause wor when_clause_opt timeout statement %prec THEN 1711 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, build_waituntil_timeout( yylloc, $3, $4, maybe_build_compound( yylloc, $5 ) ) ); } 1712 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1713 | wor_waituntil_clause wor when_clause_opt timeout statement wor ELSE statement // invalid syntax rules 1714 { SemanticError( yylloc, "syntax error, else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; } 1715 | wor_waituntil_clause wor when_clause_opt timeout statement wor when_clause ELSE statement 1716 { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, 1717 new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::OR, 1718 build_waituntil_timeout( yylloc, $3, $4, maybe_build_compound( yylloc, $5 ) ), 1719 build_waituntil_else( yylloc, $7, maybe_build_compound( yylloc, $9 ) ) ) ); } 1710 1720 ; 1711 1721 1712 1722 waituntil_statement: 1713 1723 wor_waituntil_clause %prec THEN 1714 { $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) ); } 1724 // SKULLDUGGERY: create an empty compound statement to test parsing of waituntil statement. 1725 { 1726 $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) ); 1727 // $$ = new StatementNode( build_compound( yylloc, nullptr ) ); 1728 } 1715 1729 ; 1716 1730 … … 1854 1868 1855 1869 KR_parameter_list: 1856 c_declaration';'1857 { $$ = $ 1; }1858 | KR_parameter_list c_declaration';'1859 { $$ = $1->appendList( $ 2); }1870 push c_declaration pop ';' 1871 { $$ = $2; } 1872 | KR_parameter_list push c_declaration pop ';' 1873 { $$ = $1->appendList( $3 ); } 1860 1874 ; 1861 1875 … … 1993 2007 TYPEDEF cfa_variable_specifier 1994 2008 { 1995 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, " cfa_typedef_declaration1" );2009 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "1" ); 1996 2010 $$ = $2->addTypedef(); 1997 2011 } 1998 2012 | TYPEDEF cfa_function_specifier 1999 2013 { 2000 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, " cfa_typedef_declaration2" );2014 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "2" ); 2001 2015 $$ = $2->addTypedef(); 2002 2016 } 2003 2017 | cfa_typedef_declaration pop ',' push identifier 2004 2018 { 2005 typedefTable.addToEnclosingScope( *$5, TYPEDEFname, " cfa_typedef_declaration3" );2019 typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" ); 2006 2020 $$ = $1->appendList( $1->cloneType( $5 ) ); 2007 2021 } … … 2014 2028 TYPEDEF type_specifier declarator 2015 2029 { 2016 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, " typedef_declaration 1" );2030 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" ); 2017 2031 if ( $2->type->forall || ($2->type->kind == TypeData::Aggregate && $2->type->aggregate.params) ) { 2018 2032 SemanticError( yylloc, "forall qualifier in typedef is currently unimplemented." ); $$ = nullptr; 2019 2033 } else $$ = $3->addType( $2 )->addTypedef(); // watchout frees $2 and $3 2020 2034 } 2021 | typedef_declaration ','declarator2022 { 2023 typedefTable.addToEnclosingScope( *$ 3->name, TYPEDEFname, "typedef_declaration 2" );2024 $$ = $1->appendList( $1->cloneBaseType( $ 3)->addTypedef() );2035 | typedef_declaration pop ',' push declarator 2036 { 2037 typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname, "5" ); 2038 $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() ); 2025 2039 } 2026 2040 | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 ) … … 2038 2052 SemanticError( yylloc, "TYPEDEF expression is deprecated, use typeof(...) instead." ); $$ = nullptr; 2039 2053 } 2040 | typedef_expression ','identifier '=' assignment_expression2054 | typedef_expression pop ',' push identifier '=' assignment_expression 2041 2055 { 2042 2056 SemanticError( yylloc, "TYPEDEF expression is deprecated, use typeof(...) instead." ); $$ = nullptr; … … 2451 2465 | aggregate_key attribute_list_opt identifier 2452 2466 { 2453 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname , "aggregate_type: 1" );2467 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef 2454 2468 forall = false; // reset 2455 2469 } … … 2460 2474 | aggregate_key attribute_list_opt TYPEDEFname // unqualified type name 2461 2475 { 2462 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname , "aggregate_type: 2" );2476 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef 2463 2477 forall = false; // reset 2464 2478 } … … 2470 2484 | aggregate_key attribute_list_opt TYPEGENname // unqualified type name 2471 2485 { 2472 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname , "aggregate_type: 3" );2486 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef 2473 2487 forall = false; // reset 2474 2488 } … … 2491 2505 aggregate_key attribute_list_opt identifier 2492 2506 { 2493 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname , "aggregate_type_nobody");2507 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); 2494 2508 forall = false; // reset 2495 2509 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); … … 2666 2680 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2667 2681 { $$ = DeclarationNode::newEnum( nullptr, $4, true, false )->addQualifiers( $2 ); } 2668 | ENUM attribute_list_opt '!' '{' enumerator_list comma_opt '}' // invalid syntax rule2669 { SemanticError( yylloc, "syntax error, hiding '!' the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }2670 2682 | ENUM attribute_list_opt identifier 2671 { typedefTable.makeTypedef( *$3 , "enum_type 1"); }2683 { typedefTable.makeTypedef( *$3 ); } 2672 2684 hide_opt '{' enumerator_list comma_opt '}' 2673 2685 { $$ = DeclarationNode::newEnum( $3, $7, true, false, nullptr, $5 )->addQualifiers( $2 ); } 2674 | ENUM attribute_list_opt typedef_name hide_opt '{' enumerator_list comma_opt '}' // unqualified type name 2686 | ENUM attribute_list_opt typedef_name // unqualified type name 2687 hide_opt '{' enumerator_list comma_opt '}' 2675 2688 { $$ = DeclarationNode::newEnum( $3->name, $6, true, false, nullptr, $4 )->addQualifiers( $2 ); } 2676 2689 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}' … … 2681 2694 $$ = DeclarationNode::newEnum( nullptr, $7, true, true, $3 )->addQualifiers( $5 ); 2682 2695 } 2683 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '!' '{' enumerator_list comma_opt '}' // unqualified type name2684 { SemanticError( yylloc, "syntax error, hiding '!' the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }2685 | ENUM '(' ')' attribute_list_opt '{' enumerator_list comma_opt '}'2686 {2687 $$ = DeclarationNode::newEnum( nullptr, $6, true, true )->addQualifiers( $4 );2688 }2689 | ENUM '(' ')' attribute_list_opt '!' '{' enumerator_list comma_opt '}' // invalid syntax rule2690 { SemanticError( yylloc, "syntax error, hiding '!' the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }2691 2696 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt 2692 2697 { 2693 if ( $3 ->storageClasses.any() || $3->type->qualifiers.val != 0) {2698 if ( $3 && ($3->storageClasses.any() || $3->type->qualifiers.val != 0 )) { 2694 2699 SemanticError( yylloc, "syntax error, storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); 2695 2700 } 2696 typedefTable.makeTypedef( *$6 , "enum_type 2");2701 typedefTable.makeTypedef( *$6 ); 2697 2702 } 2698 2703 hide_opt '{' enumerator_list comma_opt '}' … … 2700 2705 $$ = DeclarationNode::newEnum( $6, $11, true, true, $3, $9 )->addQualifiers( $5 )->addQualifiers( $7 ); 2701 2706 } 2702 | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt hide_opt '{' enumerator_list comma_opt '}' 2703 { 2704 $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 ); 2705 } 2706 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}' 2707 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt 2708 hide_opt '{' enumerator_list comma_opt '}' 2707 2709 { 2708 2710 $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3, $8 )->addQualifiers( $5 )->addQualifiers( $7 ); 2709 }2710 | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'2711 {2712 $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );2713 2711 } 2714 2712 | enum_type_nobody … … 2724 2722 enum_type_nobody: // enum - {...} 2725 2723 ENUM attribute_list_opt identifier 2726 { 2727 typedefTable.makeTypedef( *$3, "enum_type_nobody 1" ); 2728 $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); 2729 } 2724 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); } 2730 2725 | ENUM attribute_list_opt type_name 2731 { 2732 typedefTable.makeTypedef( *$3->type->symbolic.name, "enum_type_nobody 2" ); 2733 $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); 2734 } 2726 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); } 2735 2727 ; 2736 2728 … … 2800 2792 { $$ = nullptr; } 2801 2793 | parameter_list 2802 | parameter_list ','ELLIPSIS2794 | parameter_list pop ',' push ELLIPSIS 2803 2795 { $$ = $1->addVarArgs(); } 2804 2796 ; … … 2807 2799 abstract_parameter_declaration 2808 2800 | parameter_declaration 2809 | parameter_list ','abstract_parameter_declaration2810 { $$ = $1->appendList( $ 3); }2811 | parameter_list ','parameter_declaration2812 { $$ = $1->appendList( $ 3); }2801 | parameter_list pop ',' push abstract_parameter_declaration 2802 { $$ = $1->appendList( $5 ); } 2803 | parameter_list pop ',' push parameter_declaration 2804 { $$ = $1->appendList( $5 ); } 2813 2805 ; 2814 2806 … … 2829 2821 2830 2822 cfa_abstract_parameter_declaration: // CFA, new & old style parameter declaration 2831 abstract_parameter_declaration 2823 // empty 2824 { $$ = nullptr; } 2825 | abstract_parameter_declaration 2832 2826 | cfa_identifier_parameter_declarator_no_tuple 2833 2827 | cfa_abstract_tuple … … 2975 2969 type_class identifier_or_type_name 2976 2970 { 2977 typedefTable.addToScope( *$2, TYPEDEFname, " type_parameter 1" );2971 typedefTable.addToScope( *$2, TYPEDEFname, "9" ); 2978 2972 if ( $1 == ast::TypeDecl::Otype ) { SemanticError( yylloc, "otype keyword is deprecated, use T " ); } 2979 2973 if ( $1 == ast::TypeDecl::Dtype ) { SemanticError( yylloc, "dtype keyword is deprecated, use T &" ); } … … 2983 2977 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 2984 2978 | identifier_or_type_name new_type_class 2985 { typedefTable.addToScope( *$1, TYPEDEFname, " type_parameter 2" ); }2979 { typedefTable.addToScope( *$1, TYPEDEFname, "9" ); } 2986 2980 type_initializer_opt assertion_list_opt 2987 2981 { $$ = DeclarationNode::newTypeParam( $2, $1 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 2988 2982 | '[' identifier_or_type_name ']' 2989 2983 { 2990 typedefTable.addToScope( *$2, TYPEDIMname, " type_parameter 3" );2984 typedefTable.addToScope( *$2, TYPEDIMname, "9" ); 2991 2985 $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dimension, $2 ); 2992 2986 } … … 3070 3064 identifier_or_type_name 3071 3065 { 3072 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, " type_declarator_name 1" );3066 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 3073 3067 $$ = DeclarationNode::newTypeDecl( $1, nullptr ); 3074 3068 } 3075 3069 | identifier_or_type_name '(' type_parameter_list ')' 3076 3070 { 3077 typedefTable.addToEnclosingScope( *$1, TYPEGENname, " type_declarator_name 2" );3071 typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" ); 3078 3072 $$ = DeclarationNode::newTypeDecl( $1, $3 ); 3079 3073 } … … 3169 3163 | IDENTIFIER IDENTIFIER 3170 3164 { IdentifierBeforeIdentifier( *$1.str, *$2.str, " declaration" ); $$ = nullptr; } 3171 | IDENTIFIER type_qualifier // invalid syntax rule 3165 | IDENTIFIER type_qualifier // invalid syntax rules 3172 3166 { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; } 3173 | IDENTIFIER storage_class // invalid syntax rule 3167 | IDENTIFIER storage_class // invalid syntax rules 3174 3168 { IdentifierBeforeType( *$1.str, "storage class" ); $$ = nullptr; } 3175 | IDENTIFIER basic_type_name // invalid syntax rule 3169 | IDENTIFIER basic_type_name // invalid syntax rules 3176 3170 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 3177 | IDENTIFIER TYPEDEFname // invalid syntax rule 3171 | IDENTIFIER TYPEDEFname // invalid syntax rules 3178 3172 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 3179 | IDENTIFIER TYPEGENname // invalid syntax rule 3173 | IDENTIFIER TYPEGENname // invalid syntax rules 3180 3174 { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; } 3181 3175 | external_function_definition … … 3464 3458 3465 3459 variable_function: 3466 '(' variable_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3467 { $$ = $2->addParamList( $ 5); }3468 | '(' attribute_list variable_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3469 { $$ = $3->addQualifiers( $2 )->addParamList( $ 6); }3460 '(' variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3461 { $$ = $2->addParamList( $6 ); } 3462 | '(' attribute_list variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3463 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3470 3464 | '(' variable_function ')' // redundant parenthesis 3471 3465 { $$ = $2; } … … 3487 3481 3488 3482 function_no_ptr: 3489 paren_identifier '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3490 { $$ = $1->addParamList( $ 3); }3491 | '(' function_ptr ')' '(' p arameter_type_list_opt')'3492 { $$ = $2->addParamList( $ 5); }3493 | '(' attribute_list function_ptr ')' '(' p arameter_type_list_opt')'3494 { $$ = $3->addQualifiers( $2 )->addParamList( $ 6); }3483 paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3484 { $$ = $1->addParamList( $4 ); } 3485 | '(' function_ptr ')' '(' push parameter_type_list_opt pop ')' 3486 { $$ = $2->addParamList( $6 ); } 3487 | '(' attribute_list function_ptr ')' '(' push parameter_type_list_opt pop ')' 3488 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3495 3489 | '(' function_no_ptr ')' // redundant parenthesis 3496 3490 { $$ = $2; } … … 3541 3535 paren_identifier '(' identifier_list ')' // function_declarator handles empty parameter 3542 3536 { $$ = $1->addIdList( $3 ); } 3543 | '(' KR_function_ptr ')' '(' p arameter_type_list_opt')'3544 { $$ = $2->addParamList( $ 5); }3545 | '(' attribute_list KR_function_ptr ')' '(' p arameter_type_list_opt')'3546 { $$ = $3->addQualifiers( $2 )->addParamList( $ 6); }3537 | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')' 3538 { $$ = $2->addParamList( $6 ); } 3539 | '(' attribute_list KR_function_ptr ')' '(' push parameter_type_list_opt pop ')' 3540 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3547 3541 | '(' KR_function_no_ptr ')' // redundant parenthesis 3548 3542 { $$ = $2; } … … 3588 3582 { 3589 3583 // hide type name in enclosing scope by variable name 3590 typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, " paren_type" );3584 typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" ); 3591 3585 } 3592 3586 | '(' paren_type ')' … … 3633 3627 3634 3628 variable_type_function: 3635 '(' variable_type_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3636 { $$ = $2->addParamList( $ 5); }3637 | '(' attribute_list variable_type_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3638 { $$ = $3->addQualifiers( $2 )->addParamList( $ 6); }3629 '(' variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3630 { $$ = $2->addParamList( $6 ); } 3631 | '(' attribute_list variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3632 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3639 3633 | '(' variable_type_function ')' // redundant parenthesis 3640 3634 { $$ = $2; } … … 3656 3650 3657 3651 function_type_no_ptr: 3658 paren_type '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3659 { $$ = $1->addParamList( $ 3); }3660 | '(' function_type_ptr ')' '(' p arameter_type_list_opt')'3661 { $$ = $2->addParamList( $ 5); }3662 | '(' attribute_list function_type_ptr ')' '(' p arameter_type_list_opt')'3663 { $$ = $3->addQualifiers( $2 )->addParamList( $ 6); }3652 paren_type '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3653 { $$ = $1->addParamList( $4 ); } 3654 | '(' function_type_ptr ')' '(' push parameter_type_list_opt pop ')' 3655 { $$ = $2->addParamList( $6 ); } 3656 | '(' attribute_list function_type_ptr ')' '(' push parameter_type_list_opt pop ')' 3657 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3664 3658 | '(' function_type_no_ptr ')' // redundant parenthesis 3665 3659 { $$ = $2; } … … 3732 3726 3733 3727 identifier_parameter_function: 3734 paren_identifier '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3735 { $$ = $1->addParamList( $ 3); }3736 | '(' identifier_parameter_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3737 { $$ = $2->addParamList( $ 5); }3728 paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3729 { $$ = $1->addParamList( $4 ); } 3730 | '(' identifier_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3731 { $$ = $2->addParamList( $6 ); } 3738 3732 | '(' identifier_parameter_function ')' // redundant parenthesis 3739 3733 { $$ = $2; } … … 3785 3779 3786 3780 type_parameter_function: 3787 typedef_name '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3788 { $$ = $1->addParamList( $ 3); }3789 | '(' type_parameter_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3790 { $$ = $2->addParamList( $ 5); }3781 typedef_name '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3782 { $$ = $1->addParamList( $4 ); } 3783 | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3784 { $$ = $2->addParamList( $6 ); } 3791 3785 ; 3792 3786 … … 3835 3829 3836 3830 abstract_function: 3837 '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3838 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $ 2, nullptr ); }3839 | '(' abstract_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3840 { $$ = $2->addParamList( $ 5); }3831 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3832 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); } 3833 | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3834 { $$ = $2->addParamList( $6 ); } 3841 3835 | '(' abstract_function ')' // redundant parenthesis 3842 3836 { $$ = $2; } … … 3854 3848 // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; } 3855 3849 | '[' push array_type_list pop ']' // CFA 3856 { SemanticError( yylloc, "Type array dimension is currently unimplemented." ); $$ = nullptr; }3850 { $$ = DeclarationNode::newArray( $3, nullptr, false ); } 3857 3851 | multi_array_dimension 3858 3852 ; … … 3958 3952 3959 3953 abstract_parameter_function: 3960 '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3961 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $ 2, nullptr ); }3962 | '(' abstract_parameter_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3963 { $$ = $2->addParamList( $ 5); }3954 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3955 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); } 3956 | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3957 { $$ = $2->addParamList( $6 ); } 3964 3958 | '(' abstract_parameter_function ')' // redundant parenthesis 3965 3959 { $$ = $2; } … … 3998 3992 // This pattern parses a declaration of an abstract variable, but does not allow "int ()" for a function pointer. 3999 3993 // 4000 // struct S {4001 // int;4002 // int *;4003 // int [10];4004 // int (*)();4005 // };3994 // struct S { 3995 // int; 3996 // int *; 3997 // int [10]; 3998 // int (*)(); 3999 // }; 4006 4000 4007 4001 variable_abstract_declarator: … … 4037 4031 4038 4032 variable_abstract_function: 4039 '(' variable_abstract_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)4040 { $$ = $2->addParamList( $ 5); }4033 '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 4034 { $$ = $2->addParamList( $6 ); } 4041 4035 | '(' variable_abstract_function ')' // redundant parenthesis 4042 4036 { $$ = $2; }
Note:
See TracChangeset
for help on using the changeset viewer.