Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r3ed994e r3d26610  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 22 08:41:57 2018
    13 // Update Count     : 3353
     12// Last Modified On : Thu May 31 15:11:40 2018
     13// Update Count     : 3444
    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
     267%type<sn> selection_statement                   if_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_type_list_opt
     328%type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_ellipsis_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_declaration_list KR_declaration_list_opt
     334%type<decl> KR_parameter_list KR_parameter_list_opt
    335335
    336336%type<decl> parameter_declaration parameter_list parameter_type_list_opt
     
    404404//************************* Namespace Management ********************************
    405405
    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.
     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
    428432
    429433push:
     
    852856//      '[' ']'
    853857//              { $$ = new ExpressionNode( build_tuple() ); }
    854 //      '[' push assignment_expression pop ']'
     858//      | '[' push assignment_expression pop ']'
    855859//              { $$ = new ExpressionNode( build_tuple( $3 ) ); }
    856860        '[' ',' tuple_expression_list ']'
    857861                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    858         | '[' assignment_expression ',' tuple_expression_list ']'
    859                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$2->set_last( $4 ) ) ); }
     862        | '[' push assignment_expression pop ',' tuple_expression_list ']'
     863                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); }
    860864        ;
    861865
     
    883887        labeled_statement
    884888        | compound_statement
    885         | expression_statement                                          { $$ = $1; }
     889        | expression_statement
    886890        | selection_statement
    887891        | iteration_statement
     
    909913        '{' '}'
    910914                { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    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
     915        | '{' push
    915916          local_label_declaration_opt                                           // GCC, local labels
    916917          statement_decl_list                                                           // C99, intermix declarations and statements
    917918          pop '}'
    918                 { $$ = new StatementNode( build_compound( $5 ) ); }
     919                { $$ = new StatementNode( build_compound( $4 ) ); }
    919920        ;
    920921
    921922statement_decl_list:                                                                    // C99
    922923        statement_decl
    923         | statement_decl_list push statement_decl
    924                 { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } }
     924        | statement_decl_list statement_decl
     925                { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
    925926        ;
    926927
     
    940941                        $$ = new StatementNode( $2 );
    941942                }
    942         | statement pop
     943        | statement
    943944        ;
    944945
     
    955956
    956957selection_statement:
    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 ) ); }
     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; }
    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 '}' // CFA
     964        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // 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 '}' // CFA
     976        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // CFA
    977977                {
    978978                        StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) );
     
    981981        ;
    982982
     983if_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
    983992if_control_expression:
    984         comma_expression pop
     993        comma_expression
    985994                { $$ = new IfCtl( nullptr, $1 ); }
    986         | c_declaration pop                                                                     // no semi-colon
     995        | c_declaration                                                                         // no semi-colon
    987996                { $$ = new IfCtl( $1, nullptr ); }
    988         | cfa_declaration pop                                                           // no semi-colon
     997        | cfa_declaration                                                                       // no semi-colon
    989998                { $$ = new IfCtl( $1, nullptr ); }
    990999        | declaration comma_expression                                          // semi-colon separated
     
    10471056        | DO statement WHILE '(' comma_expression ')' ';'
    10481057                { $$ = new StatementNode( build_while( $5, $2, true ) ); }
    1049         | FOR '(' push for_control_expression ')' statement
     1058        | FOR '(' push for_control_expression ')' statement pop
    10501059                { $$ = new StatementNode( build_for( $4, $6 ) ); }
    10511060        ;
    10521061
    10531062for_control_expression:
    1054         comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt
    1055                 { $$ = new ForCtl( $1, $4, $6 ); }
     1063        comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt
     1064                { $$ = new ForCtl( $1, $3, $5 ); }
    10561065        | declaration comma_expression_opt ';' comma_expression_opt // C99
    10571066                { $$ = new ForCtl( $1, $2, $4 ); }
     
    11751184
    11761185handler_clause:
    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 ) ) ); }
     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 ) ) ); }
    11811190        ;
    11821191
     
    12001209        type_specifier_nobody
    12011210        | type_specifier_nobody declarator
    1202                 {
    1203                         $$ = $2->addType( $1 );
    1204                 }
     1211                { $$ = $2->addType( $1 ); }
    12051212        | type_specifier_nobody variable_abstract_declarator
    12061213                { $$ = $2->addType( $1 ); }
    12071214        | cfa_abstract_declarator_tuple no_attr_identifier      // CFA
    1208                 {
    1209                         $$ = $1->addName( $2 );
    1210                 }
     1215                { $$ = $1->addName( $2 ); }
    12111216        | cfa_abstract_declarator_tuple                                         // CFA
    12121217        ;
     
    12861291
    12871292declaration_list_opt:                                                                   // used at beginning of switch statement
    1288         pop
     1293        // empty
    12891294                { $$ = nullptr; }
    12901295        | declaration_list
     
    12931298declaration_list:
    12941299        declaration
    1295         | declaration_list push declaration
    1296                 { $$ = $1->appendList( $3 ); }
    1297         ;
    1298 
    1299 KR_declaration_list_opt:                                                                // used to declare parameter types in K&R style functions
     1300        | declaration_list declaration
     1301                { $$ = $1->appendList( $2 ); }
     1302        ;
     1303
     1304KR_parameter_list_opt:                                                          // used to declare parameter types in K&R style functions
    13001305        // empty
    13011306                { $$ = nullptr; }
    1302         | KR_declaration_list
    1303         ;
    1304 
    1305 KR_declaration_list:
     1307        | KR_parameter_list
     1308        ;
     1309
     1310KR_parameter_list:
    13061311        push c_declaration pop ';'
    13071312                { $$ = $2; }
    1308         | KR_declaration_list push c_declaration pop ';'
     1313        | KR_parameter_list push c_declaration pop ';'
    13091314                { $$ = $1->appendList( $3 ); }
    13101315        ;
     
    13211326
    13221327local_label_list:                                                                               // GCC, local label
    1323         no_attr_identifier_or_type_name                         {}
    1324         | local_label_list ',' no_attr_identifier_or_type_name {}
     1328        no_attr_identifier_or_type_name
     1329        | local_label_list ',' no_attr_identifier_or_type_name
    13251330        ;
    13261331
    13271332declaration:                                                                                    // old & new style declarations
    1328         c_declaration pop ';'
    1329         | cfa_declaration pop ';'                                                       // CFA
     1333        c_declaration ';'
     1334        | cfa_declaration ';'                                                           // CFA
    13301335        | static_assert
    13311336        ;
     
    13851390        | declaration_qualifier_list type_qualifier_list cfa_function_specifier
    13861391                { $$ = $3->addQualifiers( $1 )->addQualifiers( $2 ); }
    1387         | cfa_function_declaration ',' identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
     1392        | cfa_function_declaration ',' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
    13881393                {
    13891394                        // Append the return type at the start (left-hand-side) to each identifier in the list.
    13901395                        DeclarationNode * ret = new DeclarationNode;
    13911396                        ret->type = maybeClone( $1->type->base );
    1392                         $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $5, nullptr ) );
     1397                        $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $6, nullptr ) );
    13931398                }
    13941399        ;
    13951400
    13961401cfa_function_specifier:                                                                 // CFA
    1397 //      '[' ']' identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' // S/R conflict
     1402//      '[' ']' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' // S/R conflict
    13981403//              {
    13991404//                      $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );
    14001405//              }
    1401 //      '[' ']' identifier '(' push cfa_parameter_type_list_opt pop ')'
     1406//      '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')'
    14021407//              {
    14031408//                      typedefTable.setNextIdentifier( *$5 );
    14041409//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    14051410//              }
    1406 //      | '[' ']' TYPEDEFname '(' push cfa_parameter_type_list_opt pop ')'
     1411//      | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')'
    14071412//              {
    14081413//                      typedefTable.setNextIdentifier( *$5 );
     
    14121417                // identifier_or_type_name must be broken apart because of the sequence:
    14131418                //
    1414                 //   '[' ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
     1419                //   '[' ']' identifier_or_type_name '(' cfa_parameter_ellipsis_list_opt ')'
    14151420                //   '[' ']' type_specifier
    14161421                //
    14171422                // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be
    14181423                // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name.
    1419         cfa_abstract_tuple identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
     1424        cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
    14201425                // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator).
    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 ); }
     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 ); }
    14241429        ;
    14251430
    14261431cfa_function_return:                                                                    // CFA
    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 ) ); }
     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 ) ); }
    14331437        ;
    14341438
     
    14361440        TYPEDEF cfa_variable_specifier
    14371441                {
    1438                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname );
     1442                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "1"*/ );
    14391443                        $$ = $2->addTypedef();
    14401444                }
    14411445        | TYPEDEF cfa_function_specifier
    14421446                {
    1443                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname );
     1447                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "2"*/ );
    14441448                        $$ = $2->addTypedef();
    14451449                }
    14461450        | cfa_typedef_declaration pop ',' push no_attr_identifier
    14471451                {
    1448                         typedefTable.addToEnclosingScope( *$5, TYPEDEFname );
     1452                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname /*, "3"*/ );
    14491453                        $$ = $1->appendList( $1->cloneType( $5 ) );
    14501454                }
     
    14571461        TYPEDEF type_specifier declarator
    14581462                {
    1459                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname );
     1463                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "4"*/ );
    14601464                        $$ = $3->addType( $2 )->addTypedef();
    14611465                }
    14621466        | typedef_declaration pop ',' push declarator
    14631467                {
    1464                         typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname );
     1468                        typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname /*, "5"*/ );
    14651469                        $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() );
    14661470                }
    14671471        | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 )
    14681472                {
    1469                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname );
     1473                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "6"*/ );
    14701474                        $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef();
    14711475                }
    14721476        | type_specifier TYPEDEF declarator
    14731477                {
    1474                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname );
     1478                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "7"*/ );
    14751479                        $$ = $3->addType( $1 )->addTypedef();
    14761480                }
    14771481        | type_specifier TYPEDEF type_qualifier_list declarator
    14781482                {
    1479                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname );
     1483                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "8"*/ );
    14801484                        $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 );
    14811485                }
     
    16041608
    16051609forall:
    1606         FORALL '('
    1607                 {
    1608                         typedefTable.enterScope();
    1609                 }
    1610           type_parameter_list ')'                                                       // CFA
    1611                 {
    1612                         typedefTable.leaveScope();
    1613                         $$ = DeclarationNode::newForall( $4 );
    1614                 }
     1610        FORALL '(' type_parameter_list ')'                                      // CFA
     1611                { $$ = DeclarationNode::newForall( $3 ); }
    16151612        ;
    16161613
     
    19801977        ;
    19811978
    1982 cfa_parameter_type_list_opt:                                                    // CFA, abstract + real
     1979cfa_parameter_ellipsis_list_opt:                                                        // CFA, abstract + real
    19831980        // empty
    19841981                { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
     
    19871984        | cfa_abstract_parameter_list
    19881985        | cfa_parameter_list
    1989         | cfa_parameter_list ',' cfa_abstract_parameter_list
    1990                 { $$ = $1->appendList( $3 ); }
    1991         | cfa_abstract_parameter_list ',' ELLIPSIS
     1986        | cfa_parameter_list pop ',' push cfa_abstract_parameter_list
     1987                { $$ = $1->appendList( $5 ); }
     1988        | cfa_abstract_parameter_list pop ',' push ELLIPSIS
    19921989                { $$ = $1->addVarArgs(); }
    1993         | cfa_parameter_list ',' ELLIPSIS
     1990        | cfa_parameter_list pop ',' push ELLIPSIS
    19941991                { $$ = $1->addVarArgs(); }
    19951992        ;
     
    19991996                // factored out from cfa_parameter_list, flattening the rules to get lookahead to the ']'.
    20001997        cfa_parameter_declaration
    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 ); }
     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 ); }
    20072004        ;
    20082005
    20092006cfa_abstract_parameter_list:                                                    // CFA, new & old style abstract
    20102007        cfa_abstract_parameter_declaration
    2011         | cfa_abstract_parameter_list ',' cfa_abstract_parameter_declaration
    2012                 { $$ = $1->appendList( $3 ); }
     2008        | cfa_abstract_parameter_list pop ',' push cfa_abstract_parameter_declaration
     2009                { $$ = $1->appendList( $5 ); }
    20132010        ;
    20142011
     
    21592156        '.' no_attr_identifier                                                          // C99, field name
    21602157                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    2161         | '[' assignment_expression ']'                                         // C99, single array element
     2158        | '[' push assignment_expression pop ']'                        // C99, single array element
    21622159                // 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
    21692160                { $$ = $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; }
    21702167        ;
    21712168
     
    22042201type_parameter:                                                                                 // CFA
    22052202        type_class no_attr_identifier_or_type_name
    2206                 { typedefTable.addToEnclosingScope( *$2, TYPEDEFname ); }
     2203                { typedefTable.addToScope( *$2, TYPEDEFname /*, "9"*/ ); }
    22072204          type_initializer_opt assertion_list_opt
    22082205                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
     
    22382235        '|' no_attr_identifier_or_type_name '(' type_list ')'
    22392236                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    2240         | '|' '{' push trait_declaration_list '}'
     2237        | '|' '{' push trait_declaration_list pop '}'
    22412238                { $$ = $4; }
    2242         | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')'
    2243                 { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; }
     2239        // | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}' '(' type_list ')'
     2240        //      { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; }
    22442241        ;
    22452242
     
    22732270        no_attr_identifier_or_type_name
    22742271                {
    2275                         typedefTable.addToEnclosingScope( *$1, TYPEDEFname );
     2272                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname /*, "10"*/ );
    22762273                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    22772274                }
    2278         | no_attr_identifier_or_type_name '(' push type_parameter_list pop ')'
    2279                 {
    2280                         typedefTable.addToEnclosingScope( *$1, TYPEGENname );
    2281                         $$ = DeclarationNode::newTypeDecl( $1, $4 );
     2275        | no_attr_identifier_or_type_name '(' type_parameter_list ')'
     2276                {
     2277                        typedefTable.addToEnclosingScope( *$1, TYPEGENname /*, "11"*/ );
     2278                        $$ = DeclarationNode::newTypeDecl( $1, $3 );
    22822279                }
    22832280        ;
    22842281
    22852282trait_specifier:                                                                                // CFA
    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 ); }
     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 ); }
    22922287        ;
    22932288
    22942289trait_declaration_list:                                                                 // CFA
    22952290        trait_declaration
    2296         | trait_declaration_list push trait_declaration
    2297                 { $$ = $1->appendList( $3 ); }
     2291        | trait_declaration_list pop push trait_declaration
     2292                { $$ = $1->appendList( $4 ); }
    22982293        ;
    22992294
    23002295trait_declaration:                                                                              // CFA
    2301         cfa_trait_declaring_list pop ';'
    2302         | trait_declaring_list pop ';'
     2296        cfa_trait_declaring_list ';'
     2297        | trait_declaring_list ';'
    23032298        ;
    23042299
    23052300cfa_trait_declaring_list:                                                               // CFA
    23062301        cfa_variable_specifier
    2307                 { $$ = $1; }
    23082302        | cfa_function_specifier
    2309                 { $$ = $1; }
    23102303        | cfa_trait_declaring_list pop ',' push identifier_or_type_name
    23112304                { $$ = $1->appendList( $1->cloneType( $5 ) ); }
     
    23292322
    23302323external_definition_list:
    2331         external_definition
     2324        push external_definition pop
     2325                { $$ = $2; }
    23322326        | external_definition_list
    23332327                { forall = xxx; }
    2334           push external_definition
     2328          push external_definition pop
    23352329                { $$ = $1 ? $1->appendList( $4 ) : $4; }
    23362330        ;
     
    23542348                        linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
    23552349                }
    2356           '{' external_definition_list_opt '}'
     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 '}'
    23572355                {
    23582356                        linkage = linkageStack.top();
    23592357                        linkageStack.pop();
    2360                         $$ = $5;
     2358                        $$ = $6;
    23612359                }
    23622360        | EXTENSION external_definition                                         // GCC, multiple __extension__ allowed, meaning unknown
     
    23662364                }
    23672365        | type_qualifier_list
    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() ) {
     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() ) {
    23742370                                if ( isMangled( iter->linkage ) ) {             // ignore extern "C"
    23752371                                        iter->addQualifiers( $1->clone() );
     
    23782374                        xxx = false;
    23792375                        delete $1;
    2380                         $$ = $5;
     2376                        $$ = $4;
    23812377                }
    23822378        | declaration_qualifier_list
    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() ) {
     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() ) {
    23892383                                if ( isMangled( iter->linkage ) ) {             // ignore extern "C"
    23902384                                        iter->addQualifiers( $1->clone() );
     
    23932387                        xxx = false;
    23942388                        delete $1;
    2395                         $$ = $5;
     2389                        $$ = $4;
    23962390                }
    23972391        | declaration_qualifier_list type_qualifier_list
     
    24002394                        if ( $2->type->forall ) xxx = forall = true; // remember generic type
    24012395                }
    2402           push '{' external_definition_list '}'                         // CFA, namespace
    2403                 {
    2404                         for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     2396          '{' external_definition_list '}'                                      // CFA, namespace
     2397                {
     2398                        for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
    24052399                                if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C"
    24062400                                        iter->addQualifiers( $1->clone() );
     
    24112405                        delete $1;
    24122406                        delete $2;
    2413                         $$ = $6;
     2407                        $$ = $5;
    24142408                }
    24152409        ;
     
    24232417                // declaration must still have a type_specifier.  OBSOLESCENT (see 1)
    24242418        | function_declarator compound_statement
    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                 }
     2419                { $$ = $1->addFunctionBody( $2 ); }
     2420        | KR_function_declarator KR_parameter_list_opt compound_statement
     2421                { $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); }
    24342422        ;
    24352423
     
    24442432        cfa_function_declaration with_clause_opt compound_statement     // CFA
    24452433                {
    2446                         typedefTable.leaveScope();
    24472434                        // Add the function body to the last identifier in the function definition list, i.e., foo3:
    24482435                        //   [const double] foo1(), foo2( int ), foo3( double ) { return 3.0; }
     
    24532440                {
    24542441                        rebindForall( $1, $2 );
    2455                         typedefTable.leaveScope();
    24562442                        $$ = $2->addFunctionBody( $4, $3 )->addType( $1 );
    24572443                }
     
    24592445                {
    24602446                        rebindForall( $1, $2 );
    2461                         typedefTable.leaveScope();
    24622447                        $$ = $2->addFunctionBody( $4, $3 )->addType( $1 );
    24632448                }
    24642449                // handles default int return type, OBSOLESCENT (see 1)
    24652450        | type_qualifier_list function_declarator with_clause_opt compound_statement
    2466                 {
    2467                         typedefTable.leaveScope();
    2468                         $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 );
    2469                 }
     2451                { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); }
    24702452                // handles default int return type, OBSOLESCENT (see 1)
    24712453        | declaration_qualifier_list function_declarator with_clause_opt compound_statement
    2472                 {
    2473                         typedefTable.leaveScope();
    2474                         $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 );
    2475                 }
     2454                { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); }
    24762455                // handles default int return type, OBSOLESCENT (see 1)
    24772456        | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement
    2478                 {
    2479                         typedefTable.leaveScope();
    2480                         $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 );
    2481                 }
     2457                { $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); }
    24822458
    24832459                // Old-style K&R function definition, OBSOLESCENT (see 4)
    2484         | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement
     2460        | declaration_specifier KR_function_declarator KR_parameter_list_opt with_clause_opt compound_statement
    24852461                {
    24862462                        rebindForall( $1, $2 );
    2487                         typedefTable.leaveScope();
    24882463                        $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addType( $1 );
    24892464                }
    24902465                // handles default int return type, OBSOLESCENT (see 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                 }
     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 ); }
    24962468                // handles default int return type, OBSOLESCENT (see 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                 }
     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 ); }
    25022471                // handles default int return type, OBSOLESCENT (see 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                 }
     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 ); }
    25082474        ;
    25092475
     
    27022668        paren_identifier '(' identifier_list ')'                        // function_declarator handles empty parameter
    27032669                { $$ = $1->addIdList( $3 ); }
    2704         | '(' KR_function_ptr ')' '(' parameter_type_list_opt ')'
    2705                 { $$ = $2->addParamList( $5 ); }
     2670        | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
     2671                { $$ = $2->addParamList( $6 ); }
    27062672        | '(' KR_function_no_ptr ')'                                            // redundant parenthesis
    27072673                { $$ = $2; }
     
    27492715        typedef
    27502716                // hide type name in enclosing scope by variable name
    2751                 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER ); }
     2717                { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER /*, "ID"*/ ); }
    27522718        | '(' paren_type ')'
    27532719                { $$ = $2; }
     
    28212787
    28222788identifier_parameter_function:
    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 ); }
     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 ); }
    28272793        | '(' identifier_parameter_function ')'                         // redundant parenthesis
    28282794                { $$ = $2; }
     
    28742840
    28752841type_parameter_function:
    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 ); }
     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 ); }
    28802846        ;
    28812847
     
    29242890
    29252891abstract_function:
    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 ); }
     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 ); }
    29302896        | '(' abstract_function ')'                                                     // redundant parenthesis
    29312897                { $$ = $2; }
     
    29422908
    29432909multi_array_dimension:
    2944         '[' assignment_expression ']'
    2945                 { $$ = DeclarationNode::newArray( $2, 0, false ); }
    2946         | '[' '*' ']'                                                                           // C99
     2910        '[' push assignment_expression pop ']'
     2911                { $$ = DeclarationNode::newArray( $3, 0, false ); }
     2912        | '[' push '*' pop ']'                                                          // C99
    29472913                { $$ = DeclarationNode::newVarArray( 0 ); }
    2948         | multi_array_dimension '[' assignment_expression ']'
    2949                 { $$ = $1->addArray( DeclarationNode::newArray( $3, 0, false ) ); }
    2950         | multi_array_dimension '[' '*' ']'                                     // C99
     2914        | multi_array_dimension '[' push assignment_expression pop ']'
     2915                { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }
     2916        | multi_array_dimension '[' push '*' pop ']'            // C99
    29512917                { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); }
    29522918        ;
     
    30152981
    30162982abstract_parameter_function:
    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 ); }
     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 ); }
    30212987        | '(' abstract_parameter_function ')'                           // redundant parenthesis
    30222988                { $$ = $2; }
     
    30393005        '[' ']'
    30403006                { $$ = DeclarationNode::newArray( 0, 0, false ); }
    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 ); }
     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 ); }
    30533019        ;
    30543020
     
    30943060
    30953061variable_abstract_function:
    3096         '(' variable_abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3097                 { $$ = $2->addParamList( $5 ); }
     3062        '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3063                { $$ = $2->addParamList( $6 ); }
    30983064        | '(' variable_abstract_function ')'                            // redundant parenthesis
    30993065                { $$ = $2; }
     
    31583124
    31593125cfa_array_parameter_1st_dimension:
    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 ']'
     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 ']'
    31653131                // declaration_qualifier_list must be used because of shift/reduce conflict with
    31663132                // assignment_expression, so a semantic check is necessary to preclude them as a type_qualifier cannot
    31673133                // appear in this context.
    3168                 { $$ = DeclarationNode::newArray( $3, $2, true ); }
    3169         | '[' declaration_qualifier_list type_qualifier_list assignment_expression ']'
    3170                 { $$ = DeclarationNode::newArray( $4, $3->addQualifiers( $3 ), true ); }
     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 ); }
    31713137        ;
    31723138
     
    31803146//
    31813147//              cfa_abstract_tuple identifier_or_type_name
    3182 //              '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')'
     3148//              '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_ellipsis_list_opt ')'
    31833149//
    31843150// since a function return type can be syntactically identical to a tuple type:
     
    32373203
    32383204cfa_abstract_tuple:                                                                             // CFA
    3239         '[' cfa_abstract_parameter_list ']'
    3240                 { $$ = DeclarationNode::newTuple( $2 ); }
     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; }
    32413211        ;
    32423212
    32433213cfa_abstract_function:                                                                  // CFA
    3244 //      '[' ']' '(' cfa_parameter_type_list_opt ')'
     3214//      '[' ']' '(' cfa_parameter_ellipsis_list_opt ')'
    32453215//              { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $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 ); }
     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 ); }
    32503220        ;
    32513221
Note: See TracChangeset for help on using the changeset viewer.