Changes in / [8f13c98:d2887f7]


Ignore:
Location:
src/Parser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r8f13c98 rd2887f7  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:37:17 2018
    13 // Update Count     : 1033
     12// Last Modified On : Mon Nov 20 09:21:52 2017
     13// Update Count     : 1031
    1414//
    1515
     
    120120} // DeclarationNode::clone
    121121
     122bool DeclarationNode::get_hasEllipsis() const {
     123        return hasEllipsis;
     124}
     125
    122126void DeclarationNode::print( std::ostream &os, int indent ) const {
    123127        os << string( indent, ' ' );
     
    163167}
    164168
    165 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ) {
     169DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) {
    166170        DeclarationNode * newnode = new DeclarationNode;
    167171        newnode->name = name;
    168172        newnode->type = new TypeData( TypeData::Function );
    169173        newnode->type->function.params = param;
     174        newnode->type->function.newStyle = newStyle;
    170175        newnode->type->function.body = body;
    171176
  • src/Parser/ParseNode.h

    r8f13c98 rd2887f7  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:31:48 2018
    13 // Update Count     : 826
     12// Last Modified On : Mon Nov 27 17:33:35 2017
     13// Update Count     : 824
    1414//
    1515
     
    226226        static DeclarationNode * newForall( DeclarationNode * );
    227227        static DeclarationNode * newFromTypedef( std::string * );
    228         static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
     228        static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false );
    229229        static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    230230        static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body );
     
    288288        Type * buildType() const;
    289289
     290        bool get_hasEllipsis() const;
    290291        LinkageSpec::Spec get_linkage() const { return linkage; }
    291292        DeclarationNode * extractAggregate() const;
  • src/Parser/TypeData.cc

    r8f13c98 rd2887f7  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:49:00 2018
    13 // Update Count     : 597
     12// Last Modified On : Mon Sep 25 18:33:41 2017
     13// Update Count     : 587
    1414//
    1515
     
    5454                function.oldDeclList = nullptr;
    5555                function.body = nullptr;
     56                function.newStyle = false;
    5657                function.withExprs = nullptr;
    5758                break;
     
    194195                newtype->function.oldDeclList = maybeClone( function.oldDeclList );
    195196                newtype->function.body = maybeClone( function.body );
     197                newtype->function.newStyle = function.newStyle;
    196198                newtype->function.withExprs = maybeClone( function.withExprs );
    197199                break;
     
    879881FunctionType * buildFunction( const TypeData * td ) {
    880882        assert( td->kind == TypeData::Function );
    881         FunctionType * ft = new FunctionType( buildQualifiers( td ), ! td->function.params || td->function.params->hasEllipsis );
     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 );
    882886        buildList( td->function.params, ft->get_parameters() );
    883887        buildForall( td->forall, ft->get_forall() );
  • src/Parser/TypeData.h

    r8f13c98 rd2887f7  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:21:23 2018
    13 // Update Count     : 191
     12// Last Modified On : Fri Sep  1 23:33:45 2017
     13// Update Count     : 190
    1414//
    1515
     
    6464                mutable DeclarationNode * oldDeclList;
    6565                StatementNode * body;
     66                bool newStyle;
    6667                ExpressionNode * withExprs;             // expressions from function's with_clause
    6768        };
  • src/Parser/parser.yy

    r8f13c98 rd2887f7  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:31:19 2018
    13 // Update Count     : 3027
     12// Last Modified On : Thu Feb 15 17:12:31 2018
     13// Update Count     : 3006
    1414//
    1515
     
    314314%type<decl> cfa_identifier_parameter_declarator_tuple cfa_identifier_parameter_ptr
    315315
    316 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list_opt
     316%type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list cfa_parameter_type_list_opt
    317317
    318318%type<decl> cfa_typedef_declaration cfa_variable_declaration cfa_variable_specifier
     
    322322%type<decl> KR_declaration_list KR_declaration_list_opt
    323323
    324 %type<decl> parameter_declaration parameter_list parameter_type_list_opt
     324%type<decl> parameter_declaration parameter_list parameter_type_list
     325%type<decl> parameter_type_list_opt
    325326
    326327%type<decl> paren_identifier paren_type
     
    778779        | unary_expression assignment_operator assignment_expression
    779780                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
    780         | unary_expression '=' '{' initializer_list comma_opt '}'
    781                 { throw SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME
     781        | unary_expression '=' '{' initializer_list comma_opt '}' // FIX ME
     782                { $$ = nullptr; }
    782783        ;
    783784
     
    848849        | waitfor_statement
    849850        | exception_statement
    850         | enable_disable_statement
    851                 { throw SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
    852851        | asm_statement
    853852        ;
     
    10651064        | RETURN comma_expression_opt ';'
    10661065                { $$ = new StatementNode( build_return( $2 ) ); }
    1067         | RETURN '{' initializer_list comma_opt '}'
    1068                 { throw SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1066        | RETURN '{' initializer_list comma_opt '}'                     // FIX ME
     1067                { $$ = nullptr; }
    10691068        | THROW assignment_expression_opt ';'                           // handles rethrow
    10701069                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    11941193        ;
    11951194
    1196 enable_disable_statement:
    1197         enable_disable_key identifier_list compound_statement
    1198         ;
    1199 
    1200 enable_disable_key:
    1201         ENABLE
    1202         | DISABLE
    1203         ;
    1204 
    12051195asm_statement:
    12061196        ASM asm_volatile_opt '(' string_literal ')' ';'
     
    14021392                        DeclarationNode * ret = new DeclarationNode;
    14031393                        ret->type = maybeClone( $1->type->base );
    1404                         $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr ) );
     1394                        $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr, true ) );
    14051395                }
    14061396        ;
     
    14321422                // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator).
    14331423                {
    1434                         $$ = DeclarationNode::newFunction( $2, $1, $5, 0 );
     1424                        $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true );
    14351425                }
    14361426        | cfa_function_return identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')'
    14371427                {
    1438                         $$ = DeclarationNode::newFunction( $2, $1, $5, 0 );
     1428                        $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true );
    14391429                }
    14401430        ;
     
    20001990        ;
    20011991
    2002 cfa_parameter_type_list_opt:                                                    // CFA, abstract + real
     1992// Minimum of one parameter after which ellipsis is allowed only at the end.
     1993
     1994cfa_parameter_type_list_opt:                                                    // CFA
    20031995        // empty
    2004                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
    2005         | ELLIPSIS
    20061996                { $$ = nullptr; }
    2007         | cfa_abstract_parameter_list
     1997        | cfa_parameter_type_list
     1998        ;
     1999
     2000cfa_parameter_type_list:                                                                // CFA, abstract + real
     2001        cfa_abstract_parameter_list
    20082002        | cfa_parameter_list
    20092003        | cfa_parameter_list pop ',' push cfa_abstract_parameter_list
     
    20362030        // empty
    20372031                { $$ = nullptr; }
    2038         | ELLIPSIS
    2039                 { $$ = nullptr; }
    2040         | parameter_list
     2032        | parameter_type_list
     2033        ;
     2034
     2035parameter_type_list:
     2036        parameter_list
    20412037        | parameter_list pop ',' push ELLIPSIS
    20422038                { $$ = $1->addVarArgs(); }
Note: See TracChangeset for help on using the changeset viewer.