Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r3d26610 r3ed994e  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May 31 15:11:40 2018
    13 // Update Count     : 3444
     12// Last Modified On : Tue May 22 08:41:57 2018
     13// Update Count     : 3353
    1414//
    1515
     
    265265%type<sn> statement                                             labeled_statement                       compound_statement
    266266%type<sn> statement_decl                                statement_decl_list                     statement_list_nodecl
    267 %type<sn> selection_statement                   if_statement
     267%type<sn> selection_statement
    268268%type<sn> switch_clause_list_opt                switch_clause_list
    269269%type<en> case_value
     
    326326%type<decl> cfa_identifier_parameter_declarator_tuple cfa_identifier_parameter_ptr
    327327
    328 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_ellipsis_list_opt
     328%type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list_opt
    329329
    330330%type<decl> cfa_typedef_declaration cfa_variable_declaration cfa_variable_specifier
     
    332332%type<decl> c_declaration static_assert
    333333%type<decl> KR_function_declarator KR_function_no_ptr KR_function_ptr KR_function_array
    334 %type<decl> KR_parameter_list KR_parameter_list_opt
     334%type<decl> KR_declaration_list KR_declaration_list_opt
    335335
    336336%type<decl> parameter_declaration parameter_list parameter_type_list_opt
     
    404404//************************* Namespace Management ********************************
    405405
    406 // The C grammar is not context free because it relies on the distinct terminal symbols "identifier" and "TYPEDEFname",
    407 // which are lexically identical.
    408 //
    409 //   typedef int foo; // identifier foo must now be scanned as TYPEDEFname
    410 //   foo f;           // to allow it to appear in this context
    411 //
    412 // While it may be possible to write a purely context-free grammar, such a grammar would obscure the relationship
    413 // between syntactic and semantic constructs.  Cforall compounds this problem by introducing type names local to the
    414 // scope of a declaration (for instance, those introduced through "forall" qualifiers), and by introducing "type
    415 // generators" -- parameterized types.  This latter type name creates a third class of identifiers, "TYPEGENname", which
    416 // must be distinguished by the lexical scanner.
    417 //
    418 // Since the scanner cannot distinguish among the different classes of identifiers without some context information,
    419 // there is a type table (typedefTable), which holds type names and identifiers that override type names, for each named
    420 // scope. During parsing, semantic actions update the type table by adding new identifiers in the current scope. For
    421 // each context that introduces a name scope, a new level is created in the type table and that level is popped on
    422 // exiting the scope.  Since type names can be local to a particular declaration, each declaration is itself a scope.
    423 // This requires distinguishing between type names that are local to the current declaration scope and those that
    424 // persist past the end of the declaration (i.e., names defined in "typedef" or "otype" declarations).
    425 //
    426 // The non-terminals "push" and "pop" denote the opening and closing of named scopes. Every push has a matching pop in
    427 // the production rule. There are multiple lists of declarations, where each declaration is a named scope, so pop/push
    428 // around the list separator.
    429 //
    430 //  int f( forall(T) T (*f1) T , forall( S ) S (*f2)( S ) );
    431 //      push               pop   push                   pop
     406// The grammar in the ANSI C standard is not strictly context-free, since it relies upon the distinct terminal symbols
     407// "identifier", "TYPEDEFname", and "TYPEGENname" that are lexically identical.  While it is possible to write a purely
     408// context-free grammar, such a grammar would obscure the relationship between syntactic and semantic constructs.
     409// Hence, this grammar uses the ANSI style.
     410//
     411// Cforall compounds this problem by introducing type names local to the scope of a declaration (for instance, those
     412// introduced through "forall" qualifiers), and by introducing "type generators" -- parameterized types.  This latter
     413// type name creates a third class of identifiers that must be distinguished by the scanner.
     414//
     415// Since the scanner cannot distinguish among the different classes of identifiers without some context information, it
     416// accesses a data structure (TypedefTable) to allow classification of an identifier that it has just read.  Semantic
     417// actions during the parser update this data structure when the class of identifiers change.
     418//
     419// Because the Cforall language is block-scoped, an identifier can change its class in a local scope; it must revert to
     420// its original class at the end of the block.  Since type names can be local to a particular declaration, each
     421// declaration is itself a scope.  This requires distinguishing between type names that are local to the current
     422// declaration scope and those that persist past the end of the declaration (i.e., names defined in "typedef" or "otype"
     423// declarations).
     424//
     425// The non-terminals "push" and "pop" denote the opening and closing of scopes.  Every push must have a matching pop,
     426// although it is regrettable the matching pairs do not always occur within the same rule.  These non-terminals may
     427// appear in more contexts than strictly necessary from a semantic point of view.
    432428
    433429push:
     
    856852//      '[' ']'
    857853//              { $$ = new ExpressionNode( build_tuple() ); }
    858 //      | '[' push assignment_expression pop ']'
     854//      '[' push assignment_expression pop ']'
    859855//              { $$ = new ExpressionNode( build_tuple( $3 ) ); }
    860856        '[' ',' tuple_expression_list ']'
    861857                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    862         | '[' push assignment_expression pop ',' tuple_expression_list ']'
    863                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); }
     858        | '[' assignment_expression ',' tuple_expression_list ']'
     859                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$2->set_last( $4 ) ) ); }
    864860        ;
    865861
     
    887883        labeled_statement
    888884        | compound_statement
    889         | expression_statement
     885        | expression_statement                                          { $$ = $1; }
    890886        | selection_statement
    891887        | iteration_statement
     
    913909        '{' '}'
    914910                { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    915         | '{' push
     911        | '{'
     912                // Two scopes are necessary because the block itself has a scope, but every declaration within the block also
     913                // requires its own scope.
     914          push push
    916915          local_label_declaration_opt                                           // GCC, local labels
    917916          statement_decl_list                                                           // C99, intermix declarations and statements
    918917          pop '}'
    919                 { $$ = new StatementNode( build_compound( $4 ) ); }
     918                { $$ = new StatementNode( build_compound( $5 ) ); }
    920919        ;
    921920
    922921statement_decl_list:                                                                    // C99
    923922        statement_decl
    924         | statement_decl_list statement_decl
    925                 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
     923        | statement_decl_list push statement_decl
     924                { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } }
    926925        ;
    927926
     
    941940                        $$ = new StatementNode( $2 );
    942941                }
    943         | statement
     942        | statement pop
    944943        ;
    945944
     
    956955
    957956selection_statement:
    958                         // pop causes a S/R conflict without separating the IF statement into a non-terminal even after resolving
    959                         // the inherent S/R conflict with THEN/ELSE.
    960         push if_statement pop
    961                 { $$ = $2; }
     957        IF '(' push if_control_expression ')' statement         %prec THEN
     958                // explicitly deal with the shift/reduce conflict on if/else
     959                { $$ = new StatementNode( build_if( $4, $6, nullptr ) ); }
     960        | IF '(' push if_control_expression ')' statement ELSE statement
     961                { $$ = new StatementNode( build_if( $4, $6, $8 ) ); }
    962962        | SWITCH '(' comma_expression ')' case_clause
    963963                { $$ = new StatementNode( build_switch( true, $3, $5 ) ); }
    964         | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // CFA
     964        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    965965                {
    966966                        StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) );
     
    974974        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    975975                { $$ = new StatementNode( build_switch( false, $3, $5 ) ); }
    976         | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // CFA
     976        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    977977                {
    978978                        StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) );
     
    981981        ;
    982982
    983 if_statement:
    984         IF '(' if_control_expression ')' statement                      %prec THEN
    985                 // explicitly deal with the shift/reduce conflict on if/else
    986                 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); }
    987         | IF '(' if_control_expression ')' statement ELSE statement
    988                 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); }
    989         ;
    990 
    991 
    992983if_control_expression:
    993         comma_expression
     984        comma_expression pop
    994985                { $$ = new IfCtl( nullptr, $1 ); }
    995         | c_declaration                                                                         // no semi-colon
     986        | c_declaration pop                                                                     // no semi-colon
    996987                { $$ = new IfCtl( $1, nullptr ); }
    997         | cfa_declaration                                                                       // no semi-colon
     988        | cfa_declaration pop                                                           // no semi-colon
    998989                { $$ = new IfCtl( $1, nullptr ); }
    999990        | declaration comma_expression                                          // semi-colon separated
     
    10561047        | DO statement WHILE '(' comma_expression ')' ';'
    10571048                { $$ = new StatementNode( build_while( $5, $2, true ) ); }
    1058         | FOR '(' push for_control_expression ')' statement pop
     1049        | FOR '(' push for_control_expression ')' statement
    10591050                { $$ = new StatementNode( build_for( $4, $6 ) ); }
    10601051        ;
    10611052
    10621053for_control_expression:
    1063         comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt
    1064                 { $$ = new ForCtl( $1, $3, $5 ); }
     1054        comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt
     1055                { $$ = new ForCtl( $1, $4, $6 ); }
    10651056        | declaration comma_expression_opt ';' comma_expression_opt // C99
    10661057                { $$ = new ForCtl( $1, $2, $4 ); }
     
    11841175
    11851176handler_clause:
    1186         handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement pop
    1187                 { $$ = new StatementNode( build_catch( $1, $4, $6, $8 ) ); }
    1188         | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement pop
    1189                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $5, $7, $9 ) ) ); }
     1177        handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
     1178                { $$ = new StatementNode( build_catch( $1, $5, $7, $9 ) ); }
     1179        | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
     1180                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, $8, $10 ) ) ); }
    11901181        ;
    11911182
     
    12091200        type_specifier_nobody
    12101201        | type_specifier_nobody declarator
    1211                 { $$ = $2->addType( $1 ); }
     1202                {
     1203                        $$ = $2->addType( $1 );
     1204                }
    12121205        | type_specifier_nobody variable_abstract_declarator
    12131206                { $$ = $2->addType( $1 ); }
    12141207        | cfa_abstract_declarator_tuple no_attr_identifier      // CFA
    1215                 { $$ = $1->addName( $2 ); }
     1208                {
     1209                        $$ = $1->addName( $2 );
     1210                }
    12161211        | cfa_abstract_declarator_tuple                                         // CFA
    12171212        ;
     
    12911286
    12921287declaration_list_opt:                                                                   // used at beginning of switch statement
     1288        pop
     1289                { $$ = nullptr; }
     1290        | declaration_list
     1291        ;
     1292
     1293declaration_list:
     1294        declaration
     1295        | declaration_list push declaration
     1296                { $$ = $1->appendList( $3 ); }
     1297        ;
     1298
     1299KR_declaration_list_opt:                                                                // used to declare parameter types in K&R style functions
    12931300        // empty
    12941301                { $$ = nullptr; }
    1295         | declaration_list
    1296         ;
    1297 
    1298 declaration_list:
    1299         declaration
    1300         | declaration_list declaration
    1301                 { $$ = $1->appendList( $2 ); }
    1302         ;
    1303 
    1304 KR_parameter_list_opt:                                                          // used to declare parameter types in K&R style functions
    1305         // empty
    1306                 { $$ = nullptr; }
    1307         | KR_parameter_list
    1308         ;
    1309 
    1310 KR_parameter_list:
     1302        | KR_declaration_list
     1303        ;
     1304
     1305KR_declaration_list:
    13111306        push c_declaration pop ';'
    13121307                { $$ = $2; }
    1313         | KR_parameter_list push c_declaration pop ';'
     1308        | KR_declaration_list push c_declaration pop ';'
    13141309                { $$ = $1->appendList( $3 ); }
    13151310        ;
     
    13261321
    13271322local_label_list:                                                                               // GCC, local label
    1328         no_attr_identifier_or_type_name
    1329         | local_label_list ',' no_attr_identifier_or_type_name
     1323        no_attr_identifier_or_type_name                         {}
     1324        | local_label_list ',' no_attr_identifier_or_type_name {}
    13301325        ;
    13311326
    13321327declaration:                                                                                    // old & new style declarations
    1333         c_declaration ';'
    1334         | cfa_declaration ';'                                                           // CFA
     1328        c_declaration pop ';'
     1329        | cfa_declaration pop ';'                                                       // CFA
    13351330        | static_assert
    13361331        ;
     
    13901385        | declaration_qualifier_list type_qualifier_list cfa_function_specifier
    13911386                { $$ = $3->addQualifiers( $1 )->addQualifiers( $2 ); }
    1392         | cfa_function_declaration ',' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
     1387        | cfa_function_declaration ',' identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
    13931388                {
    13941389                        // Append the return type at the start (left-hand-side) to each identifier in the list.
    13951390                        DeclarationNode * ret = new DeclarationNode;
    13961391                        ret->type = maybeClone( $1->type->base );
    1397                         $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $6, nullptr ) );
     1392                        $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $5, nullptr ) );
    13981393                }
    13991394        ;
    14001395
    14011396cfa_function_specifier:                                                                 // CFA
    1402 //      '[' ']' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' // S/R conflict
     1397//      '[' ']' identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' // S/R conflict
    14031398//              {
    14041399//                      $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );
    14051400//              }
    1406 //      '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')'
     1401//      '[' ']' identifier '(' push cfa_parameter_type_list_opt pop ')'
    14071402//              {
    14081403//                      typedefTable.setNextIdentifier( *$5 );
    14091404//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    14101405//              }
    1411 //      | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')'
     1406//      | '[' ']' TYPEDEFname '(' push cfa_parameter_type_list_opt pop ')'
    14121407//              {
    14131408//                      typedefTable.setNextIdentifier( *$5 );
     
    14171412                // identifier_or_type_name must be broken apart because of the sequence:
    14181413                //
    1419                 //   '[' ']' identifier_or_type_name '(' cfa_parameter_ellipsis_list_opt ')'
     1414                //   '[' ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
    14201415                //   '[' ']' type_specifier
    14211416                //
    14221417                // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be
    14231418                // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name.
    1424         cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
     1419        cfa_abstract_tuple identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
    14251420                // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator).
    1426                 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); }
    1427         | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
    1428                 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); }
     1421                { $$ = DeclarationNode::newFunction( $2, $1, $4, 0 ); }
     1422        | cfa_function_return identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
     1423                { $$ = DeclarationNode::newFunction( $2, $1, $4, 0 ); }
    14291424        ;
    14301425
    14311426cfa_function_return:                                                                    // CFA
    1432         '[' push cfa_parameter_list pop ']'
    1433                 { $$ = DeclarationNode::newTuple( $3 ); }
    1434         | '[' push cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ']'
    1435                 // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the ']'.
    1436                 { $$ = DeclarationNode::newTuple( $3->appendList( $7 ) ); }
     1427        '[' cfa_parameter_list ']'
     1428                { $$ = DeclarationNode::newTuple( $2 ); }
     1429        | '[' cfa_parameter_list ',' cfa_abstract_parameter_list ']'
     1430                // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the
     1431                // ']'.
     1432                { $$ = DeclarationNode::newTuple( $2->appendList( $4 ) ); }
    14371433        ;
    14381434
     
    14401436        TYPEDEF cfa_variable_specifier
    14411437                {
    1442                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "1"*/ );
     1438                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname );
    14431439                        $$ = $2->addTypedef();
    14441440                }
    14451441        | TYPEDEF cfa_function_specifier
    14461442                {
    1447                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "2"*/ );
     1443                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname );
    14481444                        $$ = $2->addTypedef();
    14491445                }
    14501446        | cfa_typedef_declaration pop ',' push no_attr_identifier
    14511447                {
    1452                         typedefTable.addToEnclosingScope( *$5, TYPEDEFname /*, "3"*/ );
     1448                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname );
    14531449                        $$ = $1->appendList( $1->cloneType( $5 ) );
    14541450                }
     
    14611457        TYPEDEF type_specifier declarator
    14621458                {
    1463                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "4"*/ );
     1459                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname );
    14641460                        $$ = $3->addType( $2 )->addTypedef();
    14651461                }
    14661462        | typedef_declaration pop ',' push declarator
    14671463                {
    1468                         typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname /*, "5"*/ );
     1464                        typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname );
    14691465                        $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() );
    14701466                }
    14711467        | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 )
    14721468                {
    1473                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "6"*/ );
     1469                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname );
    14741470                        $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef();
    14751471                }
    14761472        | type_specifier TYPEDEF declarator
    14771473                {
    1478                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "7"*/ );
     1474                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname );
    14791475                        $$ = $3->addType( $1 )->addTypedef();
    14801476                }
    14811477        | type_specifier TYPEDEF type_qualifier_list declarator
    14821478                {
    1483                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "8"*/ );
     1479                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname );
    14841480                        $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 );
    14851481                }
     
    16081604
    16091605forall:
    1610         FORALL '(' type_parameter_list ')'                                      // CFA
    1611                 { $$ = DeclarationNode::newForall( $3 ); }
     1606        FORALL '('
     1607                {
     1608                        typedefTable.enterScope();
     1609                }
     1610          type_parameter_list ')'                                                       // CFA
     1611                {
     1612                        typedefTable.leaveScope();
     1613                        $$ = DeclarationNode::newForall( $4 );
     1614                }
    16121615        ;
    16131616
     
    19771980        ;
    19781981
    1979 cfa_parameter_ellipsis_list_opt:                                                        // CFA, abstract + real
     1982cfa_parameter_type_list_opt:                                                    // CFA, abstract + real
    19801983        // empty
    19811984                { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
     
    19841987        | cfa_abstract_parameter_list
    19851988        | cfa_parameter_list
    1986         | cfa_parameter_list pop ',' push cfa_abstract_parameter_list
    1987                 { $$ = $1->appendList( $5 ); }
    1988         | cfa_abstract_parameter_list pop ',' push ELLIPSIS
     1989        | cfa_parameter_list ',' cfa_abstract_parameter_list
     1990                { $$ = $1->appendList( $3 ); }
     1991        | cfa_abstract_parameter_list ',' ELLIPSIS
    19891992                { $$ = $1->addVarArgs(); }
    1990         | cfa_parameter_list pop ',' push ELLIPSIS
     1993        | cfa_parameter_list ',' ELLIPSIS
    19911994                { $$ = $1->addVarArgs(); }
    19921995        ;
     
    19961999                // factored out from cfa_parameter_list, flattening the rules to get lookahead to the ']'.
    19972000        cfa_parameter_declaration
    1998         | cfa_abstract_parameter_list pop ',' push cfa_parameter_declaration
    1999                 { $$ = $1->appendList( $5 ); }
    2000         | cfa_parameter_list pop ',' push cfa_parameter_declaration
    2001                 { $$ = $1->appendList( $5 ); }
    2002         | cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ',' push cfa_parameter_declaration
    2003                 { $$ = $1->appendList( $5 )->appendList( $9 ); }
     2001        | cfa_abstract_parameter_list ',' cfa_parameter_declaration
     2002                { $$ = $1->appendList( $3 ); }
     2003        | cfa_parameter_list ',' cfa_parameter_declaration
     2004                { $$ = $1->appendList( $3 ); }
     2005        | cfa_parameter_list ',' cfa_abstract_parameter_list ',' cfa_parameter_declaration
     2006                { $$ = $1->appendList( $3 )->appendList( $5 ); }
    20042007        ;
    20052008
    20062009cfa_abstract_parameter_list:                                                    // CFA, new & old style abstract
    20072010        cfa_abstract_parameter_declaration
    2008         | cfa_abstract_parameter_list pop ',' push cfa_abstract_parameter_declaration
    2009                 { $$ = $1->appendList( $5 ); }
     2011        | cfa_abstract_parameter_list ',' cfa_abstract_parameter_declaration
     2012                { $$ = $1->appendList( $3 ); }
    20102013        ;
    20112014
     
    21562159        '.' no_attr_identifier                                                          // C99, field name
    21572160                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    2158         | '[' push assignment_expression pop ']'                        // C99, single array element
     2161        | '[' assignment_expression ']'                                         // C99, single array element
    21592162                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
     2163                { $$ = $2; }
     2164        | '[' subrange ']'                                                                      // CFA, multiple array elements
     2165                { $$ = $2; }
     2166        | '[' constant_expression ELLIPSIS constant_expression ']' // GCC, multiple array elements
     2167                { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $2 ), maybeMoveBuild< Expression >( $4 ) ) ); }
     2168        | '.' '[' field_list ']'                                                        // CFA, tuple field selector
    21602169                { $$ = $3; }
    2161         | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    2162                 { $$ = $3; }
    2163         | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    2164                 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $3 ), maybeMoveBuild< Expression >( $5 ) ) ); }
    2165         | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    2166                 { $$ = $4; }
    21672170        ;
    21682171
     
    22012204type_parameter:                                                                                 // CFA
    22022205        type_class no_attr_identifier_or_type_name
    2203                 { typedefTable.addToScope( *$2, TYPEDEFname /*, "9"*/ ); }
     2206                { typedefTable.addToEnclosingScope( *$2, TYPEDEFname ); }
    22042207          type_initializer_opt assertion_list_opt
    22052208                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
     
    22352238        '|' no_attr_identifier_or_type_name '(' type_list ')'
    22362239                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    2237         | '|' '{' push trait_declaration_list pop '}'
     2240        | '|' '{' push trait_declaration_list '}'
    22382241                { $$ = $4; }
    2239         // | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}' '(' type_list ')'
    2240         //      { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; }
     2242        | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')'
     2243                { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; }
    22412244        ;
    22422245
     
    22702273        no_attr_identifier_or_type_name
    22712274                {
    2272                         typedefTable.addToEnclosingScope( *$1, TYPEDEFname /*, "10"*/ );
     2275                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname );
    22732276                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    22742277                }
    2275         | no_attr_identifier_or_type_name '(' type_parameter_list ')'
    2276                 {
    2277                         typedefTable.addToEnclosingScope( *$1, TYPEGENname /*, "11"*/ );
    2278                         $$ = DeclarationNode::newTypeDecl( $1, $3 );
     2278        | no_attr_identifier_or_type_name '(' push type_parameter_list pop ')'
     2279                {
     2280                        typedefTable.addToEnclosingScope( *$1, TYPEGENname );
     2281                        $$ = DeclarationNode::newTypeDecl( $1, $4 );
    22792282                }
    22802283        ;
    22812284
    22822285trait_specifier:                                                                                // CFA
    2283         TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}'
    2284                 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); }
    2285         | TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
    2286                 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); }
     2286        TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'
     2287                { $$ = DeclarationNode::newTrait( $2, $5, 0 ); }
     2288        | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{'
     2289                { typedefTable.enterScope(); }
     2290          trait_declaration_list '}'
     2291                { $$ = DeclarationNode::newTrait( $2, $5, $10 ); }
    22872292        ;
    22882293
    22892294trait_declaration_list:                                                                 // CFA
    22902295        trait_declaration
    2291         | trait_declaration_list pop push trait_declaration
    2292                 { $$ = $1->appendList( $4 ); }
     2296        | trait_declaration_list push trait_declaration
     2297                { $$ = $1->appendList( $3 ); }
    22932298        ;
    22942299
    22952300trait_declaration:                                                                              // CFA
    2296         cfa_trait_declaring_list ';'
    2297         | trait_declaring_list ';'
     2301        cfa_trait_declaring_list pop ';'
     2302        | trait_declaring_list pop ';'
    22982303        ;
    22992304
    23002305cfa_trait_declaring_list:                                                               // CFA
    23012306        cfa_variable_specifier
     2307                { $$ = $1; }
    23022308        | cfa_function_specifier
     2309                { $$ = $1; }
    23032310        | cfa_trait_declaring_list pop ',' push identifier_or_type_name
    23042311                { $$ = $1->appendList( $1->cloneType( $5 ) ); }
     
    23222329
    23232330external_definition_list:
    2324         push external_definition pop
    2325                 { $$ = $2; }
     2331        external_definition
    23262332        | external_definition_list
    23272333                { forall = xxx; }
    2328           push external_definition pop
     2334          push external_definition
    23292335                { $$ = $1 ? $1->appendList( $4 ) : $4; }
    23302336        ;
     
    23482354                        linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
    23492355                }
    2350                         // SKULLDUGGERY: Declarations in extern "X" need to be added to the current lexical scope.  However,
    2351                         // external_definition_list_opt creates a new scope that loses the types at the end of the extern block. The
    2352                         // correction is a pop/push (reverse order) to undo the push/pop from external_definition_list_opt.  This
    2353                         // trick works for nested extern "X"s, as each one undoes itself in the nesting.
    2354           '{' pop external_definition_list_opt push '}'
     2356          '{' external_definition_list_opt '}'
    23552357                {
    23562358                        linkage = linkageStack.top();
    23572359                        linkageStack.pop();
    2358                         $$ = $6;
     2360                        $$ = $5;
    23592361                }
    23602362        | EXTENSION external_definition                                         // GCC, multiple __extension__ allowed, meaning unknown
     
    23642366                }
    23652367        | type_qualifier_list
    2366                 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type
    2367           '{' external_definition_list push '}'                  // CFA, namespace
    2368                 {
    2369                         for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     2368                {
     2369                        if ( $1->type->forall ) xxx = forall = true; // remember generic type
     2370                }
     2371          push '{' external_definition_list '}'                         // CFA, namespace
     2372                {
     2373                        for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
    23702374                                if ( isMangled( iter->linkage ) ) {             // ignore extern "C"
    23712375                                        iter->addQualifiers( $1->clone() );
     
    23742378                        xxx = false;
    23752379                        delete $1;
    2376                         $$ = $4;
     2380                        $$ = $5;
    23772381                }
    23782382        | declaration_qualifier_list
    2379                 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type
    2380           '{' external_definition_list '}'                                       // CFA, namespace
    2381                 {
    2382                         for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     2383                {
     2384                        if ( $1->type->forall ) xxx = forall = true; // remember generic type
     2385                }
     2386          push '{' external_definition_list '}'                         // CFA, namespace
     2387                {
     2388                        for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
    23832389                                if ( isMangled( iter->linkage ) ) {             // ignore extern "C"
    23842390                                        iter->addQualifiers( $1->clone() );
     
    23872393                        xxx = false;
    23882394                        delete $1;
    2389                         $$ = $4;
     2395                        $$ = $5;
    23902396                }
    23912397        | declaration_qualifier_list type_qualifier_list
     
    23942400                        if ( $2->type->forall ) xxx = forall = true; // remember generic type
    23952401                }
    2396           '{' external_definition_list '}'                                      // CFA, namespace
    2397                 {
    2398                         for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     2402          push '{' external_definition_list '}'                         // CFA, namespace
     2403                {
     2404                        for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
    23992405                                if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C"
    24002406                                        iter->addQualifiers( $1->clone() );
     
    24052411                        delete $1;
    24062412                        delete $2;
    2407                         $$ = $5;
     2413                        $$ = $6;
    24082414                }
    24092415        ;
     
    24172423                // declaration must still have a type_specifier.  OBSOLESCENT (see 1)
    24182424        | function_declarator compound_statement
    2419                 { $$ = $1->addFunctionBody( $2 ); }
    2420         | KR_function_declarator KR_parameter_list_opt compound_statement
    2421                 { $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); }
     2425                {
     2426                        typedefTable.leaveScope();
     2427                        $$ = $1->addFunctionBody( $2 );
     2428                }
     2429        | KR_function_declarator KR_declaration_list_opt compound_statement
     2430                {
     2431                        typedefTable.leaveScope();
     2432                        $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 );
     2433                }
    24222434        ;
    24232435
     
    24322444        cfa_function_declaration with_clause_opt compound_statement     // CFA
    24332445                {
     2446                        typedefTable.leaveScope();
    24342447                        // Add the function body to the last identifier in the function definition list, i.e., foo3:
    24352448                        //   [const double] foo1(), foo2( int ), foo3( double ) { return 3.0; }
     
    24402453                {
    24412454                        rebindForall( $1, $2 );
     2455                        typedefTable.leaveScope();
    24422456                        $$ = $2->addFunctionBody( $4, $3 )->addType( $1 );
    24432457                }
     
    24452459                {
    24462460                        rebindForall( $1, $2 );
     2461                        typedefTable.leaveScope();
    24472462                        $$ = $2->addFunctionBody( $4, $3 )->addType( $1 );
    24482463                }
    24492464                // handles default int return type, OBSOLESCENT (see 1)
    24502465        | type_qualifier_list function_declarator with_clause_opt compound_statement
    2451                 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); }
     2466                {
     2467                        typedefTable.leaveScope();
     2468                        $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 );
     2469                }
    24522470                // handles default int return type, OBSOLESCENT (see 1)
    24532471        | declaration_qualifier_list function_declarator with_clause_opt compound_statement
    2454                 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); }
     2472                {
     2473                        typedefTable.leaveScope();
     2474                        $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 );
     2475                }
    24552476                // handles default int return type, OBSOLESCENT (see 1)
    24562477        | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement
    2457                 { $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); }
     2478                {
     2479                        typedefTable.leaveScope();
     2480                        $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 );
     2481                }
    24582482
    24592483                // Old-style K&R function definition, OBSOLESCENT (see 4)
    2460         | declaration_specifier KR_function_declarator KR_parameter_list_opt with_clause_opt compound_statement
     2484        | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
    24612485                {
    24622486                        rebindForall( $1, $2 );
     2487                        typedefTable.leaveScope();
    24632488                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addType( $1 );
    24642489                }
    24652490                // handles default int return type, OBSOLESCENT (see 1)
    2466         | type_qualifier_list KR_function_declarator KR_parameter_list_opt with_clause_opt compound_statement
    2467                 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); }
     2491        | type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
     2492                {
     2493                        typedefTable.leaveScope();
     2494                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 );
     2495                }
    24682496                // handles default int return type, OBSOLESCENT (see 1)
    2469         | declaration_qualifier_list KR_function_declarator KR_parameter_list_opt with_clause_opt compound_statement
    2470                 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); }
     2497        | declaration_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
     2498                {
     2499                        typedefTable.leaveScope();
     2500                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 );
     2501                }
    24712502                // handles default int return type, OBSOLESCENT (see 1)
    2472         | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_parameter_list_opt with_clause_opt compound_statement
    2473                 { $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); }
     2503        | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
     2504                {
     2505                        typedefTable.leaveScope();
     2506                        $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 );
     2507                }
    24742508        ;
    24752509
     
    26682702        paren_identifier '(' identifier_list ')'                        // function_declarator handles empty parameter
    26692703                { $$ = $1->addIdList( $3 ); }
    2670         | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
    2671                 { $$ = $2->addParamList( $6 ); }
     2704        | '(' KR_function_ptr ')' '(' parameter_type_list_opt ')'
     2705                { $$ = $2->addParamList( $5 ); }
    26722706        | '(' KR_function_no_ptr ')'                                            // redundant parenthesis
    26732707                { $$ = $2; }
     
    27152749        typedef
    27162750                // hide type name in enclosing scope by variable name
    2717                 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER /*, "ID"*/ ); }
     2751                { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER ); }
    27182752        | '(' paren_type ')'
    27192753                { $$ = $2; }
     
    27872821
    27882822identifier_parameter_function:
    2789         paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2790                 { $$ = $1->addParamList( $4 ); }
    2791         | '(' identifier_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2792                 { $$ = $2->addParamList( $6 ); }
     2823        paren_identifier '(' parameter_type_list_opt ')'        // empty parameter list OBSOLESCENT (see 3)
     2824                { $$ = $1->addParamList( $3 ); }
     2825        | '(' identifier_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     2826                { $$ = $2->addParamList( $5 ); }
    27932827        | '(' identifier_parameter_function ')'                         // redundant parenthesis
    27942828                { $$ = $2; }
     
    28402874
    28412875type_parameter_function:
    2842         typedef '(' push parameter_type_list_opt pop ')'        // empty parameter list OBSOLESCENT (see 3)
    2843                 { $$ = $1->addParamList( $4 ); }
    2844         | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2845                 { $$ = $2->addParamList( $6 ); }
     2876        typedef '(' parameter_type_list_opt ')'                         // empty parameter list OBSOLESCENT (see 3)
     2877                { $$ = $1->addParamList( $3 ); }
     2878        | '(' type_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     2879                { $$ = $2->addParamList( $5 ); }
    28462880        ;
    28472881
     
    28902924
    28912925abstract_function:
    2892         '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2893                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    2894         | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2895                 { $$ = $2->addParamList( $6 ); }
     2926        '(' parameter_type_list_opt ')'                                         // empty parameter list OBSOLESCENT (see 3)
     2927                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); }
     2928        | '(' abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     2929                { $$ = $2->addParamList( $5 ); }
    28962930        | '(' abstract_function ')'                                                     // redundant parenthesis
    28972931                { $$ = $2; }
     
    29082942
    29092943multi_array_dimension:
    2910         '[' push assignment_expression pop ']'
    2911                 { $$ = DeclarationNode::newArray( $3, 0, false ); }
    2912         | '[' push '*' pop ']'                                                          // C99
     2944        '[' assignment_expression ']'
     2945                { $$ = DeclarationNode::newArray( $2, 0, false ); }
     2946        | '[' '*' ']'                                                                           // C99
    29132947                { $$ = DeclarationNode::newVarArray( 0 ); }
    2914         | multi_array_dimension '[' push assignment_expression pop ']'
    2915                 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }
    2916         | multi_array_dimension '[' push '*' pop ']'            // C99
     2948        | multi_array_dimension '[' assignment_expression ']'
     2949                { $$ = $1->addArray( DeclarationNode::newArray( $3, 0, false ) ); }
     2950        | multi_array_dimension '[' '*' ']'                                     // C99
    29172951                { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); }
    29182952        ;
     
    29813015
    29823016abstract_parameter_function:
    2983         '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2984                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    2985         | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    2986                 { $$ = $2->addParamList( $6 ); }
     3017        '(' parameter_type_list_opt ')'                                         // empty parameter list OBSOLESCENT (see 3)
     3018                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); }
     3019        | '(' abstract_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3020                { $$ = $2->addParamList( $5 ); }
    29873021        | '(' abstract_parameter_function ')'                           // redundant parenthesis
    29883022                { $$ = $2; }
     
    30053039        '[' ']'
    30063040                { $$ = DeclarationNode::newArray( 0, 0, false ); }
    3007                 // multi_array_dimension handles the '[' '*' ']' case
    3008         | '[' push type_qualifier_list '*' pop ']'                      // remaining C99
    3009                 { $$ = DeclarationNode::newVarArray( $3 ); }
    3010         | '[' push type_qualifier_list pop ']'
    3011                 { $$ = DeclarationNode::newArray( 0, $3, false ); }
    3012                 // multi_array_dimension handles the '[' assignment_expression ']' case
    3013         | '[' push type_qualifier_list assignment_expression pop ']'
    3014                 { $$ = DeclarationNode::newArray( $4, $3, false ); }
    3015         | '[' push STATIC type_qualifier_list_opt assignment_expression pop ']'
    3016                 { $$ = DeclarationNode::newArray( $5, $4, true ); }
    3017         | '[' push type_qualifier_list STATIC assignment_expression pop ']'
    3018                 { $$ = DeclarationNode::newArray( $5, $3, true ); }
     3041        // multi_array_dimension handles the '[' '*' ']' case
     3042        | '[' type_qualifier_list '*' ']'                                       // remaining C99
     3043                { $$ = DeclarationNode::newVarArray( $2 ); }
     3044        | '[' type_qualifier_list ']'
     3045                { $$ = DeclarationNode::newArray( 0, $2, false ); }
     3046        // multi_array_dimension handles the '[' assignment_expression ']' case
     3047        | '[' type_qualifier_list assignment_expression ']'
     3048                { $$ = DeclarationNode::newArray( $3, $2, false ); }
     3049        | '[' STATIC type_qualifier_list_opt assignment_expression ']'
     3050                { $$ = DeclarationNode::newArray( $4, $3, true ); }
     3051        | '[' type_qualifier_list STATIC assignment_expression ']'
     3052                { $$ = DeclarationNode::newArray( $4, $2, true ); }
    30193053        ;
    30203054
     
    30603094
    30613095variable_abstract_function:
    3062         '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3063                 { $$ = $2->addParamList( $6 ); }
     3096        '(' variable_abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3097                { $$ = $2->addParamList( $5 ); }
    30643098        | '(' variable_abstract_function ')'                            // redundant parenthesis
    30653099                { $$ = $2; }
     
    31243158
    31253159cfa_array_parameter_1st_dimension:
    3126         '[' push type_qualifier_list '*' pop ']'                        // remaining C99
    3127                 { $$ = DeclarationNode::newVarArray( $3 ); }
    3128         | '[' push type_qualifier_list assignment_expression pop ']'
    3129                 { $$ = DeclarationNode::newArray( $4, $3, false ); }
    3130         | '[' push declaration_qualifier_list assignment_expression pop ']'
     3160        '[' type_qualifier_list '*' ']'                                         // remaining C99
     3161                { $$ = DeclarationNode::newVarArray( $2 ); }
     3162        | '[' type_qualifier_list assignment_expression ']'
     3163                { $$ = DeclarationNode::newArray( $3, $2, false ); }
     3164        | '[' declaration_qualifier_list assignment_expression ']'
    31313165                // declaration_qualifier_list must be used because of shift/reduce conflict with
    31323166                // assignment_expression, so a semantic check is necessary to preclude them as a type_qualifier cannot
    31333167                // appear in this context.
    3134                 { $$ = DeclarationNode::newArray( $4, $3, true ); }
    3135         | '[' push declaration_qualifier_list type_qualifier_list assignment_expression pop ']'
    3136                 { $$ = DeclarationNode::newArray( $5, $4->addQualifiers( $3 ), true ); }
     3168                { $$ = DeclarationNode::newArray( $3, $2, true ); }
     3169        | '[' declaration_qualifier_list type_qualifier_list assignment_expression ']'
     3170                { $$ = DeclarationNode::newArray( $4, $3->addQualifiers( $3 ), true ); }
    31373171        ;
    31383172
     
    31463180//
    31473181//              cfa_abstract_tuple identifier_or_type_name
    3148 //              '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_ellipsis_list_opt ')'
     3182//              '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
    31493183//
    31503184// since a function return type can be syntactically identical to a tuple type:
     
    32033237
    32043238cfa_abstract_tuple:                                                                             // CFA
    3205         '[' push cfa_abstract_parameter_list pop ']'
    3206                 { $$ = DeclarationNode::newTuple( $3 ); }
    3207         | '[' push type_specifier_nobody ELLIPSIS pop ']'
    3208                 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; }
    3209         | '[' push type_specifier_nobody ELLIPSIS constant_expression pop ']'
    3210                 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; }
     3239        '[' cfa_abstract_parameter_list ']'
     3240                { $$ = DeclarationNode::newTuple( $2 ); }
    32113241        ;
    32123242
    32133243cfa_abstract_function:                                                                  // CFA
    3214 //      '[' ']' '(' cfa_parameter_ellipsis_list_opt ')'
     3244//      '[' ']' '(' cfa_parameter_type_list_opt ')'
    32153245//              { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
    3216         cfa_abstract_tuple '(' push cfa_parameter_ellipsis_list_opt pop ')'
    3217                 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
    3218         | cfa_function_return '(' push cfa_parameter_ellipsis_list_opt pop ')'
    3219                 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
     3246        cfa_abstract_tuple '(' cfa_parameter_type_list_opt ')'
     3247                { $$ = DeclarationNode::newFunction( nullptr, $1, $3, nullptr ); }
     3248        | cfa_function_return '(' cfa_parameter_type_list_opt ')'
     3249                { $$ = DeclarationNode::newFunction( nullptr, $1, $3, nullptr ); }
    32203250        ;
    32213251
Note: See TracChangeset for help on using the changeset viewer.