Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r1dbc8590 r9a705dc8  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri May 11 17:51:38 2018
    13 // Update Count     : 3261
     12// Last Modified On : Tue Apr 17 17:10:30 2018
     13// Update Count     : 3144
    1414//
    1515
     
    133133} // build_postfix_name
    134134
    135 bool forall = false, xxx = false;                                               // aggregate have one or more forall qualifiers ?
     135bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
    136136
    137137// https://www.gnu.org/software/bison/manual/bison.html#Location-Type
     
    208208%token<tok> ATTR_IDENTIFIER             ATTR_TYPEDEFname                ATTR_TYPEGENname
    209209%token<tok> INTEGERconstant             CHARACTERconstant               STRINGliteral
    210 %token<tok> DIRECTIVE
    211210// Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and
    212211// overloading constants 0/1, e.g., x.1 is lexed as (x)(.1), where (.1) is a factional constant, but is semantically
     
    283282%type<decl> aggregate_type aggregate_type_nobody
    284283
    285 %type<decl> assertion assertion_list assertion_list_opt
     284%type<decl> assertion assertion_list_opt
    286285
    287286%type<en>   bit_subrange_size_opt bit_subrange_size
     
    302301
    303302%type<decl> field_declaration field_declaration_list field_declarator field_declaring_list
    304 %type<en> field field_list field_name fraction_constants_opt
     303%type<en> field field_list field_name fraction_constants
    305304
    306305%type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr
     
    499498        | type_name '.' no_attr_identifier                                      // CFA, nested type
    500499                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    501 //              { $$ = nullptr; }
    502500        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    503501                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    504 //              { $$ = nullptr; }
    505502        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
    506503                { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; }
     
    535532        | postfix_expression '.' no_attr_identifier
    536533                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    537         | postfix_expression '.' INTEGERconstant                        // CFA, tuple index
    538                 { $$ = new ExpressionNode( build_fieldSel( $1, build_constantInteger( *$3 ) ) ); }
     534        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
     535                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    539536        | postfix_expression FLOATING_FRACTIONconstant          // CFA, tuple index
    540537                { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); }
    541         | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
    542                 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    543538        | postfix_expression ARROW no_attr_identifier
    544539                {
    545540                        $$ = new ExpressionNode( build_pfieldSel( $1, *$3 == "0" || *$3 == "1" ? build_constantInteger( *$3 ) : build_varref( $3 ) ) );
    546541                }
     542        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
     543                        { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    547544        | postfix_expression ARROW INTEGERconstant                      // CFA, tuple index
    548545                { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); }
    549         | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
    550                 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    551546        | postfix_expression ICR
    552547                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
     
    601596
    602597field_name:
    603         INTEGERconstant fraction_constants_opt
     598        INTEGERconstant fraction_constants
    604599                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *$1 ), $2 ) ); }
    605         | FLOATINGconstant fraction_constants_opt
     600        | FLOATINGconstant fraction_constants
    606601                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    607         | no_attr_identifier fraction_constants_opt
     602        | no_attr_identifier fraction_constants
    608603                {
    609604                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     
    611606        ;
    612607
    613 fraction_constants_opt:
     608fraction_constants:
    614609        // empty
    615610                { $$ = nullptr; }
    616         | fraction_constants_opt FLOATING_FRACTIONconstant
     611        | fraction_constants FLOATING_FRACTIONconstant
    617612                {
    618613                        Expression * constant = build_field_name_FLOATING_FRACTIONconstant( *$2 );
     
    880875                { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; }
    881876        | asm_statement
    882         | DIRECTIVE
    883                 { $$ = new StatementNode( build_directive( $1 ) ); }
    884877        ;
    885878
     
    12111204asm_statement:
    12121205        ASM asm_volatile_opt '(' string_literal ')' ';'
    1213                 { $$ = new StatementNode( build_asm( $2, $4, 0 ) ); }
     1206                { $$ = new StatementNode( build_asmstmt( $2, $4, 0 ) ); }
    12141207        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ')' ';' // remaining GCC
    1215                 { $$ = new StatementNode( build_asm( $2, $4, $6 ) ); }
     1208                { $$ = new StatementNode( build_asmstmt( $2, $4, $6 ) ); }
    12161209        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    1217                 { $$ = new StatementNode( build_asm( $2, $4, $6, $8 ) ); }
     1210                { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8 ) ); }
    12181211        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';'
    1219                 { $$ = new StatementNode( build_asm( $2, $4, $6, $8, $10 ) ); }
     1212                { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8, $10 ) ); }
    12201213        | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
    1221                 { $$ = new StatementNode( build_asm( $2, $5, 0, $8, $10, $12 ) ); }
     1214                { $$ = new StatementNode( build_asmstmt( $2, $5, 0, $8, $10, $12 ) ); }
    12221215        ;
    12231216
     
    18731866                {
    18741867                        typedefTable.makeTypedef( *$3 );
    1875                         if ( forall ) typedefTable.changeKind( *$3, TypedefTable::TG ); // possibly update
    1876                         forall = false;                                                         // reset
    18771868                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
    18781869                }
     
    22442235                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    22452236        | type_specifier identifier_parameter_declarator
    2246         | assertion_list
    2247                 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
    22482237        ;
    22492238
     
    22622251        // empty
    22632252                { $$ = nullptr; }
    2264         | assertion_list
    2265         ;
    2266 
    2267 assertion_list:                                                                                 // CFA
    2268         assertion
    2269         | assertion_list assertion
     2253        | assertion_list_opt assertion
    22702254                { $$ = $1 ? $1->appendList( $2 ) : $2; }
    22712255        ;
     
    23942378external_definition_list:
    23952379        external_definition
    2396         | external_definition_list
    2397                 { forall = xxx; }
    2398           push external_definition
    2399                 { $$ = $1 ? $1->appendList( $4 ) : $4; }
     2380        | external_definition_list push external_definition
     2381                { $$ = $1 ? $1->appendList( $3 ) : $3; }
    24002382        ;
    24012383
     
    24112393        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    24122394                {
    2413                         $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) );
     2395                        $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asmstmt( false, $3, 0 ) ) );
    24142396                }
    24152397        | EXTERN STRINGliteral                                                          // C++-style linkage specifier
     
    24292411                        $$ = $2;
    24302412                }
    2431         | type_qualifier_list
    2432                 {
    2433                         if ( $1->type->forall ) xxx = forall = true; // remember generic type
    2434                 }
    2435           push '{' external_definition_list '}'                         // CFA, namespace
    2436                 {
    2437                         for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
    2438                                 if ( isMangled( iter->linkage ) ) {             // ignore extern "C"
    2439                                         iter->addQualifiers( $1->clone() );
    2440                                 } // if
    2441                         } // for
    2442                         xxx = false;
    2443                         delete $1;
    2444                         $$ = $5;
    2445                 }
    2446         | declaration_qualifier_list
    2447                 {
    2448                         if ( $1->type->forall ) xxx = forall = true; // remember generic type
    2449                 }
    2450           push '{' external_definition_list '}'                         // CFA, namespace
    2451                 {
    2452                         for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
    2453                                 if ( isMangled( iter->linkage ) ) {             // ignore extern "C"
    2454                                         iter->addQualifiers( $1->clone() );
    2455                                 } // if
    2456                         } // for
    2457                         xxx = false;
    2458                         delete $1;
    2459                         $$ = $5;
    2460                 }
    2461         | declaration_qualifier_list type_qualifier_list
    2462                 {
    2463                         // forall must be in the type_qualifier_list
    2464                         if ( $2->type->forall ) xxx = forall = true; // remember generic type
    2465                 }
    2466           push '{' external_definition_list '}'                         // CFA, namespace
    2467                 {
    2468                         for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
    2469                                 if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C"
    2470                                         iter->addQualifiers( $1->clone() );
    2471                                         iter->addQualifiers( $2->clone() );
    2472                                 } // if
    2473                         } // for
    2474                         xxx = false;
    2475                         delete $1;
    2476                         delete $2;
    2477                         $$ = $6;
    2478                 }
     2413        | type_qualifier_list '{' external_definition_list '}'                  // CFA, namespace
    24792414        ;
    24802415
     
    25022437with_clause_opt:
    25032438        // empty
    2504                 { $$ = nullptr; forall = false; }
     2439                { $$ = nullptr; }
    25052440        | WITH '(' tuple_expression_list ')'
    2506                 { $$ = $3; forall = false; }
     2441                { $$ = $3; }
    25072442        ;
    25082443
Note: See TracChangeset for help on using the changeset viewer.