Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r1e30df7 r7cf8006  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Oct  8 08:21:18 2022
    13 // Update Count     : 5709
     12// Last Modified On : Wed Nov  2 21:31:21 2022
     13// Update Count     : 5810
    1414//
    1515
     
    278278
    279279// Types declaration for productions
     280
    280281%union {
    281282        Token tok;
     
    290291        CondCtl * ifctl;
    291292        ForCtrl * fctl;
    292         enum OperKinds compop;
     293        OperKinds compop;
    293294        LabelNode * label;
    294295        InitializerNode * in;
     
    296297        std::string * str;
    297298        bool flag;
     299        EnumHiding hide;
    298300        CatchStmt::Kind catch_kind;
    299301        GenericExpr * genexpr;
     
    305307%token TYPEDEF
    306308%token EXTERN STATIC AUTO REGISTER
    307 %token THREADLOCALGCC THREADLOCALC11                                            // GCC, C11
     309%token THREADLOCALGCC THREADLOCALC11                                    // GCC, C11
    308310%token INLINE FORTRAN                                                                   // C99, extension ISO/IEC 9899:1999 Section J.5.9(1)
    309311%token NORETURN                                                                                 // C11
     
    318320%token DECIMAL32 DECIMAL64 DECIMAL128                                   // GCC
    319321%token ZERO_T ONE_T                                                                             // CFA
    320 %token SIZEOF TYPEOF VALIST AUTO_TYPE                                   // GCC
     322%token SIZEOF TYPEOF VA_LIST VA_ARG AUTO_TYPE                   // GCC
    321323%token OFFSETOF BASETYPEOF TYPEID                                               // CFA
    322324%token ENUM STRUCT UNION
     
    364366%type<constant> string_literal
    365367%type<str> string_literal_list
     368
     369%type<hide> hide_opt                                    visible_hide_opt
    366370
    367371// expressions
     
    409413// declarations
    410414%type<decl> abstract_declarator abstract_ptr abstract_array abstract_function array_dimension multi_array_dimension
    411 %type<decl> abstract_parameter_declarator abstract_parameter_ptr abstract_parameter_array abstract_parameter_function array_parameter_dimension array_parameter_1st_dimension
     415%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
    412416%type<decl> abstract_parameter_declaration
    413417
     
    698702        primary_expression
    699703        | postfix_expression '[' assignment_expression ',' tuple_expression_list ']'
    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.
     704                // Historic, transitional: Disallow commas in subscripts.
     705                // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts.
     706                // Current: Commas in subscripts make tuples.
    703707                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
    704708        | postfix_expression '[' assignment_expression ']'
     
    720724        | postfix_expression '(' argument_expression_list_opt ')'
    721725                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     726        | VA_ARG '(' primary_expression ',' declaration_specifier_nobody abstract_parameter_declarator_opt ')'
     727                // { SemanticError( yylloc, "va_arg is currently unimplemented." ); $$ = nullptr; }
     728                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( new string( "__builtin_va_arg") ) ),
     729                                                                                           (ExpressionNode *)($3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) )) ) ); }
    722730        | postfix_expression '`' identifier                                     // CFA, postfix call
    723731                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
     
    21562164        | LONG
    21572165                { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
    2158         | VALIST                                                                                        // GCC, __builtin_va_list
     2166        | VA_LIST                                                                                       // GCC, __builtin_va_list
    21592167                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    21602168        | AUTO_TYPE
     
    25492557        | ENUM attribute_list_opt identifier
    25502558                { typedefTable.makeTypedef( *$3 ); }
    2551           '{' enumerator_list comma_opt '}'
    2552                 { $$ = DeclarationNode::newEnum( $3, $6, true, false )->addQualifiers( $2 ); }
     2559          hide_opt '{' enumerator_list comma_opt '}'
     2560          { $$ = DeclarationNode::newEnum( $3, $7, true, false )->addQualifiers( $2 ); }
    25532561        | ENUM attribute_list_opt typedef_name                          // unqualified type name
    2554           '{' enumerator_list comma_opt '}'
    2555                 { $$ = DeclarationNode::newEnum( $3->name, $5, true, false )->addQualifiers( $2 ); }
     2562          hide_opt '{' enumerator_list comma_opt '}'
     2563                { $$ = DeclarationNode::newEnum( $3->name, $6, true, false )->addQualifiers( $2 ); }
    25562564        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    25572565                {
     
    25702578                        typedefTable.makeTypedef( *$6 );
    25712579                }
    2572           '{' enumerator_list comma_opt '}'
    2573                 {
    2574                         $$ = DeclarationNode::newEnum( $6, $10, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
     2580          hide_opt '{' enumerator_list comma_opt '}'
     2581                {
     2582                        $$ = DeclarationNode::newEnum( $6, $11, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
    25752583                }
    25762584        | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt
    2577           '{' enumerator_list comma_opt '}'
    2578                 {
    2579                         $$ = DeclarationNode::newEnum( $5, $8, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 );
    2580                 }
    2581         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}'
    2582                 {
    2583                         $$ = DeclarationNode::newEnum( $6->name, $9, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
    2584                 }
    2585         | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}'
    2586                 {
    2587                         $$ = DeclarationNode::newEnum( $5->name, $8, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 );
     2585          hide_opt '{' enumerator_list comma_opt '}'
     2586                {
     2587                        $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 );
     2588                }
     2589        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt
     2590          hide_opt '{' enumerator_list comma_opt '}'
     2591                {
     2592                        $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
     2593                }
     2594        | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt
     2595          hide_opt '{' enumerator_list comma_opt '}'
     2596                {
     2597                        $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 );
    25882598                }
    25892599        | enum_type_nobody
     2600        ;
     2601
     2602hide_opt:
     2603        // empty
     2604                { $$ = EnumHiding::Visible; }
     2605        | '!'
     2606                { $$ = EnumHiding::Hide; }
    25902607        ;
    25912608
     
    25982615
    25992616enumerator_list:
    2600         identifier_or_type_name enumerator_value_opt
    2601                 { $$ = DeclarationNode::newEnumValueGeneric( $1, $2 ); }
     2617        visible_hide_opt identifier_or_type_name enumerator_value_opt
     2618                { $$ = DeclarationNode::newEnumValueGeneric( $2, $3 ); }
    26022619        | INLINE type_name
    26032620                { $$ = DeclarationNode::newEnumInLine( *$2->type->symbolic.name ); }
    2604         | enumerator_list ',' identifier_or_type_name enumerator_value_opt
    2605                 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $3, $4 ) ); }
     2621        | enumerator_list ',' visible_hide_opt identifier_or_type_name enumerator_value_opt
     2622                { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $4, $5 ) ); }
    26062623        | enumerator_list ',' INLINE type_name enumerator_value_opt
    26072624                { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ) ); }
     2625        ;
     2626
     2627visible_hide_opt:
     2628        hide_opt
     2629        | '^'
     2630                { $$ = EnumHiding::Visible; }
    26082631        ;
    26092632
     
    36763699// functions.
    36773700
     3701abstract_parameter_declarator_opt:
     3702        // empty
     3703                { $$ = nullptr; }
     3704        | abstract_parameter_declarator
     3705        ;
     3706
    36783707abstract_parameter_declarator:
    36793708        abstract_parameter_ptr
Note: See TracChangeset for help on using the changeset viewer.