Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r60a8062 r312029a  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Feb 16 08:22:14 2020
    13 // Update Count     : 4461
     12// Last Modified On : Tue Dec 10 23:07:17 2019
     13// Update Count     : 4400
    1414//
    1515
     
    5555#include "TypedefTable.h"
    5656#include "TypeData.h"
    57 #include "SynTree/LinkageSpec.h"
     57#include "LinkageSpec.h"
    5858#include "Common/SemanticError.h"                                               // error_str
    5959#include "Common/utility.h"                                                             // for maybeMoveBuild, maybeBuild, CodeLo...
     
    166166} // rebindForall
    167167
    168 string * build_postfix_name( string * name ) {
    169         *name = string("__postfix_func_") + *name;
    170         return name;
     168NameExpr * build_postfix_name( const string * name ) {
     169        NameExpr * new_name = build_varref( new string( "?`" + *name ) );
     170        delete name;
     171        return new_name;
    171172} // build_postfix_name
    172173
     
    237238        DeclarationNode * decl;
    238239        AggregateDecl::Aggregate aggKey;
    239         TypeDecl::Kind tclass;
     240        DeclarationNode::TypeClass tclass;
    240241        StatementNode * sn;
    241242        WaitForStmt * wfs;
     
    322323%type<op> ptrref_operator                               unary_operator                          assignment_operator
    323324%type<en> primary_expression                    postfix_expression                      unary_expression
    324 %type<en> cast_expression_list                  cast_expression                         exponential_expression          multiplicative_expression       additive_expression
     325%type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
    325326%type<en> shift_expression                              relational_expression           equality_expression
    326327%type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
     
    578579        | '(' compound_statement ')'                                            // GCC, lambda expression
    579580                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
     581        | constant '`' IDENTIFIER                                                       // CFA, postfix call
     582                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     583        | string_literal '`' IDENTIFIER                                         // CFA, postfix call
     584                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }
     585        | IDENTIFIER '`' IDENTIFIER                                                     // CFA, postfix call
     586                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); }
     587        | tuple '`' IDENTIFIER                                                          // CFA, postfix call
     588                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     589        | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
     590                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    580591        | type_name '.' identifier                                                      // CFA, nested type
    581592                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    631642        | postfix_expression '(' argument_expression_list ')'
    632643                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    633         | postfix_expression '`' identifier                                     // CFA, postfix call
    634                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
    635         | constant '`' identifier                                                       // CFA, postfix call
    636                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
    637         | string_literal '`' identifier                                         // CFA, postfix call
    638                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); }
    639644        | postfix_expression '.' identifier
    640645                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     
    661666        | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal
    662667                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    663         | '^' primary_expression '{' argument_expression_list '}' // CFA, destructor call
     668        | '^' primary_expression '{' argument_expression_list '}' // CFA
    664669                {
    665670                        Token fn;
     
    674679        | argument_expression
    675680        | argument_expression_list ',' argument_expression
    676                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     681                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
    677682        ;
    678683
     
    686691field_name_list:                                                                                // CFA, tuple field selector
    687692        field
    688         | field_name_list ',' field                                     { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     693        | field_name_list ',' field                                     { $$ = (ExpressionNode *)$1->set_last( $3 ); }
    689694        ;
    690695
     
    955960                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    956961        | '[' push assignment_expression pop ',' tuple_expression_list ']'
    957                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); }
     962                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); }
    958963        ;
    959964
     
    961966        assignment_expression_opt
    962967        | tuple_expression_list ',' assignment_expression_opt
    963                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     968                { $$ = (ExpressionNode *)$1->set_last( $3 ); }
    964969        ;
    965970
     
    11851190                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11861191                                                OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1187         | '=' comma_expression                                                                  // CFA
    1188                 { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    1189                                                 OperKinds::LEThan, $2->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    11901192        | comma_expression inclexcl comma_expression            // CFA
    11911193                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    11951197                { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11961198                                                OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1197         | comma_expression ';' '=' comma_expression                             // CFA
    1198                 { $$ = forCtrl( $4, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    1199                                                 OperKinds::LEThan, $4->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    12001199        | comma_expression ';' comma_expression inclexcl comma_expression // CFA
    12011200                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    13021301        WAITFOR '(' cast_expression ')'
    13031302                { $$ = $3; }
    1304 //      | WAITFOR '(' cast_expression ',' argument_expression_list ')'
    1305 //              { $$ = (ExpressionNode *)$3->set_last( $5 ); }
    1306         | WAITFOR '(' cast_expression_list ':' argument_expression_list ')'
    1307                 { $$ = (ExpressionNode *)($3->set_last( $5 )); }
    1308         ;
    1309 
    1310 cast_expression_list:
    1311         cast_expression
    1312         | cast_expression_list ',' cast_expression
    1313                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     1303        | WAITFOR '(' cast_expression ',' argument_expression_list ')'
     1304                { $$ = (ExpressionNode *)$3->set_last( $5 ); }
    13141305        ;
    13151306
     
    14221413        asm_operand
    14231414        | asm_operands_list ',' asm_operand
    1424                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     1415                { $$ = (ExpressionNode *)$1->set_last( $3 ); }
    14251416        ;
    14261417
     
    14381429                { $$ = new ExpressionNode( $1 ); }
    14391430        | asm_clobbers_list_opt ',' string_literal
    1440                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); }
     1431                // set_last returns ParseNode *
     1432                { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
    14411433        ;
    14421434
     
    23612353        | initializer_list_opt ',' initializer          { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
    23622354        | initializer_list_opt ',' designation initializer
    2363                 { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); }
     2355                { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); }
    23642356        ;
    23652357
     
    23832375        designator
    23842376        | designator_list designator
    2385                 { $$ = (ExpressionNode *)($1->set_last( $2 )); }
     2377                { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); }
    23862378        //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
    23872379        ;
     
    24392431        | type_specifier identifier_parameter_declarator
    24402432        | assertion_list
    2441                 { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
     2433                { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
    24422434        ;
    24432435
    24442436type_class:                                                                                             // CFA
    24452437        OTYPE
    2446                 { $$ = TypeDecl::Otype; }
     2438                { $$ = DeclarationNode::Otype; }
    24472439        | DTYPE
    2448                 { $$ = TypeDecl::Dtype; }
     2440                { $$ = DeclarationNode::Dtype; }
    24492441        | FTYPE
    2450                 { $$ = TypeDecl::Ftype; }
     2442                { $$ = DeclarationNode::Ftype; }
    24512443        | TTYPE
    2452                 { $$ = TypeDecl::Ttype; }
     2444                { $$ = DeclarationNode::Ttype; }
    24532445        ;
    24542446
     
    24802472                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; }
    24812473        | type_list ',' type
    2482                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
     2474                { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) ) ); }
    24832475        | type_list ',' assignment_expression
    24842476                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; }
     
    25912583                {
    25922584                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    2593                         linkage = LinkageSpec::update( yylloc, linkage, $2 );
     2585                        linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
    25942586                }
    25952587          '{' up external_definition_list_opt down '}'
Note: See TracChangeset for help on using the changeset viewer.