Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r68cd1ce rde62360d  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 13 07:21:45 2015
    13 // Update Count     : 1048
     12// Last Modified On : Mon Jun 22 15:19:44 2015
     13// Update Count     : 1082
    1414//
    1515
    16 // This grammar is based on the ANSI99/11 C grammar, specifically parts of EXPRESSION and STATEMENTS, and on
    17 // the C grammar by James A. Roskind, specifically parts of DECLARATIONS and EXTERNAL DEFINITIONS.  While
    18 // parts have been copied, important changes have been made in all sections; these changes are sufficient to
    19 // constitute a new grammar.  In particular, this grammar attempts to be more syntactically precise, i.e., it
    20 // parses less incorrect language syntax that must be subsequently rejected by semantic checks.  Nevertheless,
    21 // there are still several semantic checks required and many are noted in the grammar. Finally, the grammar is
    22 // extended with GCC and CFA language extensions.
    23 
    24 // Acknowledgments to Richard Bilson, Glen Ditchfield, and Rodolfo Gabriel Esteves who all helped when I got
    25 // stuck with the grammar.
     16// This grammar is based on the ANSI99/11 C grammar, specifically parts of EXPRESSION and STATEMENTS, and on the C
     17// grammar by James A. Roskind, specifically parts of DECLARATIONS and EXTERNAL DEFINITIONS.  While parts have been
     18// copied, important changes have been made in all sections; these changes are sufficient to constitute a new grammar.
     19// In particular, this grammar attempts to be more syntactically precise, i.e., it parses less incorrect language syntax
     20// that must be subsequently rejected by semantic checks.  Nevertheless, there are still several semantic checks
     21// required and many are noted in the grammar. Finally, the grammar is extended with GCC and CFA language extensions.
     22
     23// Acknowledgments to Richard Bilson, Glen Ditchfield, and Rodolfo Gabriel Esteves who all helped when I got stuck with
     24// the grammar.
    2625
    2726// The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed, except for:
     
    2928// 1. designation with '=' (use ':' instead)
    3029//
    31 // Most of the syntactic extensions from ANSI90 to ANSI11 C are marked with the comment "C99/C11". This
    32 // grammar also has two levels of extensions. The first extensions cover most of the GCC C extensions, except for:
     30// Most of the syntactic extensions from ANSI90 to ANSI11 C are marked with the comment "C99/C11". This grammar also has
     31// two levels of extensions. The first extensions cover most of the GCC C extensions, except for:
    3332//
    3433// 1. nested functions
     
    3736// 4. attributes not allowed in parenthesis of declarator
    3837//
    39 // All of the syntactic extensions for GCC C are marked with the comment "GCC". The second extensions are for
    40 // Cforall (CFA), which fixes several of C's outstanding problems and extends C with many modern language
    41 // concepts. All of the syntactic extensions for CFA C are marked with the comment "CFA". As noted above,
    42 // there is one unreconcileable parsing problem between C99 and CFA with respect to designators; this is
    43 // discussed in detail before the "designation" grammar rule.
     38// All of the syntactic extensions for GCC C are marked with the comment "GCC". The second extensions are for Cforall
     39// (CFA), which fixes several of C's outstanding problems and extends C with many modern language concepts. All of the
     40// syntactic extensions for CFA C are marked with the comment "CFA". As noted above, there is one unreconcileable
     41// parsing problem between C99 and CFA with respect to designators; this is discussed in detail before the "designation"
     42// grammar rule.
    4443
    4544%{
     
    250249//************************* Namespace Management ********************************
    251250
    252 // The grammar in the ANSI C standard is not strictly context-free, since it relies upon the distinct terminal
    253 // symbols "identifier" and "TYPEDEFname" that are lexically identical.  While it is possible to write a
    254 // purely context-free grammar, such a grammar would obscure the relationship between syntactic and semantic
    255 // constructs.  Hence, this grammar uses the ANSI style.
    256 //
    257 // Cforall compounds this problem by introducing type names local to the scope of a declaration (for instance,
    258 // those introduced through "forall" qualifiers), and by introducing "type generators" -- parametrized types.
    259 // This latter type name creates a third class of identifiers that must be distinguished by the scanner.
    260 //
    261 // Since the scanner cannot distinguish among the different classes of identifiers without some context
    262 // information, it accesses a data structure (the TypedefTable) to allow classification of an identifier that
    263 // it has just read.  Semantic actions during the parser update this data structure when the class of
    264 // identifiers change.
    265 //
    266 // Because the Cforall language is block-scoped, there is the possibility that an identifier can change its
    267 // class in a local scope; it must revert to its original class at the end of the block.  Since type names can
    268 // be local to a particular declaration, each declaration is itself a scope.  This requires distinguishing
    269 // between type names that are local to the current declaration scope and those that persist past the end of
    270 // the declaration (i.e., names defined in "typedef" or "type" declarations).
    271 //
    272 // The non-terminals "push" and "pop" derive the empty string; their only use is to denote the opening and
    273 // closing of scopes.  Every push must have a matching pop, although it is regrettable the matching pairs do
    274 // not always occur within the same rule.  These non-terminals may appear in more contexts than strictly
    275 // necessary from a semantic point of view.  Unfortunately, these extra rules are necessary to prevent parsing
    276 // conflicts -- the parser may not have enough context and look-ahead information to decide whether a new
    277 // scope is necessary, so the effect of these extra rules is to open a new scope unconditionally.  As the
    278 // grammar evolves, it may be neccesary to add or move around "push" and "pop" nonterminals to resolve
    279 // conflicts of this sort.
     251// The grammar in the ANSI C standard is not strictly context-free, since it relies upon the distinct terminal symbols
     252// "identifier" and "TYPEDEFname" that are lexically identical.  While it is possible to write a purely context-free
     253// grammar, such a grammar would obscure the relationship between syntactic and semantic constructs.  Hence, this
     254// grammar uses the ANSI style.
     255//
     256// Cforall compounds this problem by introducing type names local to the scope of a declaration (for instance, those
     257// introduced through "forall" qualifiers), and by introducing "type generators" -- parametrized types.  This latter
     258// type name creates a third class of identifiers that must be distinguished by the scanner.
     259//
     260// Since the scanner cannot distinguish among the different classes of identifiers without some context information, it
     261// accesses a data structure (the TypedefTable) to allow classification of an identifier that it has just read.
     262// Semantic actions during the parser update this data structure when the class of identifiers change.
     263//
     264// Because the Cforall language is block-scoped, there is the possibility that an identifier can change its class in a
     265// local scope; it must revert to its original class at the end of the block.  Since type names can be local to a
     266// particular declaration, each declaration is itself a scope.  This requires distinguishing between type names that are
     267// local to the current declaration scope and those that persist past the end of the declaration (i.e., names defined in
     268// "typedef" or "type" declarations).
     269//
     270// The non-terminals "push" and "pop" derive the empty string; their only use is to denote the opening and closing of
     271// scopes.  Every push must have a matching pop, although it is regrettable the matching pairs do not always occur
     272// within the same rule.  These non-terminals may appear in more contexts than strictly necessary from a semantic point
     273// of view.  Unfortunately, these extra rules are necessary to prevent parsing conflicts -- the parser may not have
     274// enough context and look-ahead information to decide whether a new scope is necessary, so the effect of these extra
     275// rules is to open a new scope unconditionally.  As the grammar evolves, it may be neccesary to add or move around
     276// "push" and "pop" nonterminals to resolve conflicts of this sort.
    280277
    281278push:
     
    294291
    295292constant:
    296                 // ENUMERATIONconstant is not included here; it is treated as a variable with type
    297                 // "enumeration constant".
     293                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    298294        INTEGERconstant                                                         { $$ = new ConstantNode( ConstantNode::Integer, $1 ); }
    299295        | FLOATINGconstant                                                      { $$ = new ConstantNode( ConstantNode::Float, $1 ); }
     
    330326primary_expression:
    331327        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    332                 { $$ = new VarRefNode($1); }
     328                { $$ = new VarRefNode( $1 ); }
    333329        | zero_one
    334                 { $$ = new VarRefNode($1); }
     330                { $$ = new VarRefNode( $1 ); }
    335331        | constant
    336332                { $$ = $1; }
     
    340336                { $$ = $2; }
    341337        | '(' compound_statement ')'                                            // GCC, lambda expression
    342                 { $$ = new ValofExprNode($2); }
     338                { $$ = new ValofExprNode( $2 ); }
    343339        ;
    344340
     
    346342        primary_expression
    347343        | postfix_expression '[' push assignment_expression pop ']'
    348                 // CFA, comma_expression disallowed in the context because it results in a commom user error:
    349                 // subscripting a matrix with x[i,j] instead of x[i][j]. While this change is not backwards
    350                 // compatible, there seems to be little advantage to this feature and many disadvantages. It is
    351                 // possible to write x[(i,j)] in CFA, which is equivalent to the old x[i,j].
    352                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Index), $1, $4); }
     344                // CFA, comma_expression disallowed in the context because it results in a commom user error: subscripting a
     345                // matrix with x[i,j] instead of x[i][j]. While this change is not backwards compatible, there seems to be
     346                // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is
     347                // equivalent to the old x[i,j].
     348                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Index ), $1, $4 ); }
    353349        | postfix_expression '(' argument_expression_list ')'
    354                 { $$ = new CompositeExprNode($1, $3); }
     350                { $$ = new CompositeExprNode( $1, $3 ); }
    355351        | postfix_expression '.' no_attr_identifier
    356                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::FieldSel), $1, new VarRefNode($3)); }
     352                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::FieldSel ), $1, new VarRefNode( $3 )); }
    357353        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
    358354        | postfix_expression ARROW no_attr_identifier
    359                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PFieldSel), $1, new VarRefNode($3)); }
     355                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PFieldSel ), $1, new VarRefNode( $3 )); }
    360356        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
    361357        | postfix_expression ICR
    362                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::IncrPost), $1); }
     358                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::IncrPost ), $1 ); }
    363359        | postfix_expression DECR
    364                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::DecrPost), $1); }
     360                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::DecrPost ), $1 ); }
    365361                // GCC has priority: cast_expression
    366362        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99
     
    371367        argument_expression
    372368        | argument_expression_list ',' argument_expression
    373                 { $$ = (ExpressionNode *)($1->set_link($3)); }
     369                { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
    374370        ;
    375371
     
    379375        | assignment_expression
    380376        | no_attr_identifier ':' assignment_expression
    381                 { $$ = $3->set_asArgName($1); }
    382                 // Only a list of no_attr_identifier_or_typedef_name is allowed in this context. However, there is
    383                 // insufficient look ahead to distinguish between this list of parameter names and a tuple, so the
    384                 // tuple form must be used with an appropriate semantic check.
     377                { $$ = $3->set_asArgName( $1 ); }
     378                // Only a list of no_attr_identifier_or_typedef_name is allowed in this context. However, there is insufficient
     379                // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used
     380                // with an appropriate semantic check.
    385381        | '[' push assignment_expression pop ']' ':' assignment_expression
    386                 { $$ = $7->set_asArgName($3); }
     382                { $$ = $7->set_asArgName( $3 ); }
    387383        | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression
    388384                { $$ = $9->set_asArgName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
     
    398394                { $$ = new VarRefNode( $1 ); }
    399395        | no_attr_identifier '.' field
    400                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::FieldSel), new VarRefNode( $1 ), $3); }
     396                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( $1 ), $3 ); }
    401397        | no_attr_identifier '.' '[' push field_list pop ']'
    402                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::FieldSel), new VarRefNode( $1 ), $5); }
     398                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( $1 ), $5 ); }
    403399        | no_attr_identifier ARROW field
    404                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PFieldSel), new VarRefNode( $1 ), $3); }
     400                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( $1 ), $3 ); }
    405401        | no_attr_identifier ARROW '[' push field_list pop ']'
    406                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PFieldSel), new VarRefNode( $1 ), $5); }
     402                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( $1 ), $5 ); }
    407403        ;
    408404
     
    410406        postfix_expression
    411407        | ICR unary_expression
    412                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Incr), $2); }
     408                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2 ); }
    413409        | DECR unary_expression
    414                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Decr), $2); }
     410                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Decr ), $2 ); }
    415411        | EXTENSION cast_expression                                                     // GCC
    416412                { $$ = $2; }
    417413        | unary_operator cast_expression
    418                 { $$ = new CompositeExprNode($1, $2); }
     414                { $$ = new CompositeExprNode( $1, $2 ); }
    419415        | '!' cast_expression
    420                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Neg), $2); }
     416                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Neg ), $2 ); }
    421417        | '*' cast_expression                                                           // CFA
    422                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PointTo), $2); }
     418                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PointTo ), $2 ); }
    423419                // '*' is is separated from unary_operator because of shift/reduce conflict in:
    424420                //              { * X; } // dereference X
     
    426422                // '&' must be moved here if C++ reference variables are supported.
    427423        | SIZEOF unary_expression
    428                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::SizeOf), $2); }
     424                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), $2 ); }
    429425        | SIZEOF '(' type_name_no_function ')'
    430                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::SizeOf), new TypeValueNode($3)); }
     426                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), new TypeValueNode( $3 )); }
    431427        | ATTR_IDENTIFIER
    432                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Attr), new VarRefNode($1)); }
     428                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 )); }
    433429        | ATTR_IDENTIFIER '(' type_name ')'
    434                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Attr), new VarRefNode($1), new TypeValueNode($3)); }
     430                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ), new TypeValueNode( $3 )); }
    435431        | ATTR_IDENTIFIER '(' argument_expression ')'
    436                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Attr), new VarRefNode($1), $3); }
     432                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ), $3 ); }
    437433        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    438                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::AlignOf), $2); }
     434                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::AlignOf ), $2 ); }
    439435        | ALIGNOF '(' type_name_no_function ')'                         // GCC, type alignment
    440                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::AlignOf), new TypeValueNode($3)); }
     436                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::AlignOf ), new TypeValueNode( $3 )); }
    441437        | ANDAND no_attr_identifier                                                     // GCC, address of label
    442                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::LabelAddress), new VarRefNode($2, true)); }
     438                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LabelAddress ), new VarRefNode( $2, true )); }
    443439        ;
    444440
    445441unary_operator:
    446         '&'                                                                                     { $$ = new OperatorNode(OperatorNode::AddressOf); }
    447         | '+'                                                                           { $$ = new OperatorNode(OperatorNode::UnPlus); }
    448         | '-'                                                                           { $$ = new OperatorNode(OperatorNode::UnMinus); }
    449         | '~'                                                                           { $$ = new OperatorNode(OperatorNode::BitNeg); }
     442        '&'                                                                                     { $$ = new OperatorNode( OperatorNode::AddressOf ); }
     443        | '+'                                                                           { $$ = new OperatorNode( OperatorNode::UnPlus ); }
     444        | '-'                                                                           { $$ = new OperatorNode( OperatorNode::UnMinus ); }
     445        | '~'                                                                           { $$ = new OperatorNode( OperatorNode::BitNeg ); }
    450446        ;
    451447
     
    453449        unary_expression
    454450        | '(' type_name_no_function ')' cast_expression
    455                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Cast), new TypeValueNode($2), $4); }
     451                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( $2 ), $4 ); }
    456452        | '(' type_name_no_function ')' tuple
    457                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Cast), new TypeValueNode($2), $4); }
     453                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( $2 ), $4 ); }
    458454        ;
    459455
     
    461457        cast_expression
    462458        | multiplicative_expression '*' cast_expression
    463                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Mul),$1,$3); }
     459                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Mul ), $1, $3 ); }
    464460        | multiplicative_expression '/' cast_expression
    465                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Div),$1,$3); }
     461                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Div ), $1, $3 ); }
    466462        | multiplicative_expression '%' cast_expression
    467                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Mod),$1,$3); }
     463                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Mod ), $1, $3 ); }
    468464        ;
    469465
     
    471467        multiplicative_expression
    472468        | additive_expression '+' multiplicative_expression
    473                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Plus),$1,$3); }
     469                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Plus ), $1, $3 ); }
    474470        | additive_expression '-' multiplicative_expression
    475                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Minus),$1,$3); }
     471                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Minus ), $1, $3 ); }
    476472        ;
    477473
     
    479475        additive_expression
    480476        | shift_expression LS additive_expression
    481                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::LShift),$1,$3); }
     477                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LShift ), $1, $3 ); }
    482478        | shift_expression RS additive_expression
    483                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::RShift),$1,$3); }
     479                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::RShift ), $1, $3 ); }
    484480        ;
    485481
     
    487483        shift_expression
    488484        | relational_expression '<' shift_expression
    489                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::LThan),$1,$3); }
     485                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LThan ), $1, $3 ); }
    490486        | relational_expression '>' shift_expression
    491                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::GThan),$1,$3); }
     487                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::GThan ), $1, $3 ); }
    492488        | relational_expression LE shift_expression
    493                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::LEThan),$1,$3); }
     489                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LEThan ), $1, $3 ); }
    494490        | relational_expression GE shift_expression
    495                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::GEThan),$1,$3); }
     491                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::GEThan ), $1, $3 ); }
    496492        ;
    497493
     
    499495        relational_expression
    500496        | equality_expression EQ relational_expression
    501                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Eq), $1, $3); }
     497                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Eq ), $1, $3 ); }
    502498        | equality_expression NE relational_expression
    503                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Neq), $1, $3); }
     499                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Neq ), $1, $3 ); }
    504500        ;
    505501
     
    507503        equality_expression
    508504        | AND_expression '&' equality_expression
    509                 { $$ =new CompositeExprNode(new OperatorNode(OperatorNode::BitAnd), $1, $3); }
     505                { $$ =new CompositeExprNode( new OperatorNode( OperatorNode::BitAnd ), $1, $3 ); }
    510506        ;
    511507
     
    513509        AND_expression
    514510        | exclusive_OR_expression '^' AND_expression
    515                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Xor), $1, $3); }
     511                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Xor ), $1, $3 ); }
    516512        ;
    517513
     
    519515        exclusive_OR_expression
    520516        | inclusive_OR_expression '|' exclusive_OR_expression
    521                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::BitOr), $1, $3); }
     517                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::BitOr ), $1, $3 ); }
    522518        ;
    523519
     
    525521        inclusive_OR_expression
    526522        | logical_AND_expression ANDAND inclusive_OR_expression
    527                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::And), $1, $3); }
     523                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::And ), $1, $3 ); }
    528524        ;
    529525
     
    531527        logical_AND_expression
    532528        | logical_OR_expression OROR logical_AND_expression
    533                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Or), $1, $3); }
     529                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Or ), $1, $3 ); }
    534530        ;
    535531
     
    537533        logical_OR_expression
    538534        | logical_OR_expression '?' comma_expression ':' conditional_expression
    539                 { $$ = new CompositeExprNode( new OperatorNode(OperatorNode::Cond), (ExpressionNode *)mkList( (*$1, *$3, *$5) ) ); }
     535                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*$1, *$3, *$5 ) ) ); }
    540536        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    541                 { $$=new CompositeExprNode(new OperatorNode(OperatorNode::NCond),$1,$4); }
     537                { $$=new CompositeExprNode( new OperatorNode( OperatorNode::NCond ), $1, $4 ); }
    542538        | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
    543                 { $$ = new CompositeExprNode( new OperatorNode(OperatorNode::Cond), (ExpressionNode *)mkList( (*$1, *$3, *$5) ) ); }
     539                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*$1, *$3, *$5 ) ) ); }
    544540        ;
    545541
     
    552548        conditional_expression
    553549        | unary_expression '=' assignment_expression
    554                 { $$ =new CompositeExprNode(new OperatorNode(OperatorNode::Assign), $1, $3); }
     550                { $$ =new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $3 ); }
    555551        | unary_expression assignment_operator assignment_expression
    556                 { $$ =new CompositeExprNode($2, $1, $3); }
     552                { $$ =new CompositeExprNode( $2, $1, $3 ); }
    557553        | tuple assignment_opt                                                          // CFA, tuple expression
    558                 { $$ = ($2 == 0) ? $1 : new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $2 ); }
     554                { $$ = ( $2 == 0 ) ? $1 : new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $2 ); }
    559555        ;
    560556
     
    566562
    567563tuple:                                                                                                  // CFA, tuple
    568                 // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce
    569                 // conflict with comma_expression in new_identifier_parameter_array and new_abstract_array
     564                // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce conflict with
     565                // comma_expression in new_identifier_parameter_array and new_abstract_array
    570566        '[' push pop ']'
    571567                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ) ); }
     
    585581
    586582assignment_operator:
    587         MULTassign                                                                      { $$ = new OperatorNode(OperatorNode::MulAssn); }
    588         | DIVassign                                                                     { $$ = new OperatorNode(OperatorNode::DivAssn); }
    589         | MODassign                                                                     { $$ = new OperatorNode(OperatorNode::ModAssn); }
    590         | PLUSassign                                                            { $$ = new OperatorNode(OperatorNode::PlusAssn); }
    591         | MINUSassign                                                           { $$ = new OperatorNode(OperatorNode::MinusAssn); }
    592         | LSassign                                                                      { $$ = new OperatorNode(OperatorNode::LSAssn); }
    593         | RSassign                                                                      { $$ = new OperatorNode(OperatorNode::RSAssn); }
    594         | ANDassign                                                                     { $$ = new OperatorNode(OperatorNode::AndAssn); }
    595         | ERassign                                                                      { $$ = new OperatorNode(OperatorNode::ERAssn); }
    596         | ORassign                                                                      { $$ = new OperatorNode(OperatorNode::OrAssn); }
     583        MULTassign                                                                      { $$ = new OperatorNode( OperatorNode::MulAssn ); }
     584        | DIVassign                                                                     { $$ = new OperatorNode( OperatorNode::DivAssn ); }
     585        | MODassign                                                                     { $$ = new OperatorNode( OperatorNode::ModAssn ); }
     586        | PLUSassign                                                            { $$ = new OperatorNode( OperatorNode::PlusAssn ); }
     587        | MINUSassign                                                           { $$ = new OperatorNode( OperatorNode::MinusAssn ); }
     588        | LSassign                                                                      { $$ = new OperatorNode( OperatorNode::LSAssn ); }
     589        | RSassign                                                                      { $$ = new OperatorNode( OperatorNode::RSAssn ); }
     590        | ANDassign                                                                     { $$ = new OperatorNode( OperatorNode::AndAssn ); }
     591        | ERassign                                                                      { $$ = new OperatorNode( OperatorNode::ERAssn ); }
     592        | ORassign                                                                      { $$ = new OperatorNode( OperatorNode::OrAssn ); }
    597593        ;
    598594
    599595comma_expression:
    600596        assignment_expression
    601         | comma_expression ',' assignment_expression    // { $$ = (ExpressionNode *)$1->add_to_list($3); }
    602                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Comma),$1,$3); }
     597        | comma_expression ',' assignment_expression    // { $$ = (ExpressionNode *)$1->add_to_list( $3 ); }
     598                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Comma ), $1, $3 ); }
    603599        ;
    604600
     
    624620labeled_statement:
    625621        no_attr_identifier ':' attribute_list_opt statement
    626                 { $$ = $4->add_label($1);}
     622                { $$ = $4->add_label( $1 );}
    627623        ;
    628624
     
    631627                { $$ = new CompoundStmtNode( (StatementNode *)0 ); }
    632628        | '{'
    633                 // Two scopes are necessary because the block itself has a scope, but every declaration within the
    634                 // block also requires its own scope
     629                // Two scopes are necessary because the block itself has a scope, but every declaration within the block also
     630                // requires its own scope
    635631          push push
    636632          label_declaration_opt                                                         // GCC, local labels
     
    642638        block_item
    643639        | block_item_list push block_item
    644                 { if ($1 != 0) { $1->set_link($3); $$ = $1; } }
     640                { if ( $1 != 0 ) { $1->set_link( $3 ); $$ = $1; } }
    645641        ;
    646642
     
    658654        statement
    659655        | statement_list statement
    660                 { if ($1 != 0) { $1->set_link($2); $$ = $1; } }
     656                { if ( $1 != 0 ) { $1->set_link( $2 ); $$ = $1; } }
    661657        ;
    662658
    663659expression_statement:
    664660        comma_expression_opt ';'
    665                 { $$ = new StatementNode(StatementNode::Exp, $1, 0); }
     661                { $$ = new StatementNode( StatementNode::Exp, $1, 0 ); }
    666662        ;
    667663
     
    669665        IF '(' comma_expression ')' statement                           %prec THEN
    670666                // explicitly deal with the shift/reduce conflict on if/else
    671                 { $$ = new StatementNode(StatementNode::If, $3, $5); }
     667                { $$ = new StatementNode( StatementNode::If, $3, $5 ); }
    672668        | IF '(' comma_expression ')' statement ELSE statement
    673                 { $$ = new StatementNode(StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7)) ); }
     669                { $$ = new StatementNode( StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7 )) ); }
    674670        | SWITCH '(' comma_expression ')' case_clause           // CFA
    675                 { $$ = new StatementNode(StatementNode::Switch, $3, $5); }
     671                { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
    676672        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    677                 { $$ = new StatementNode(StatementNode::Switch, $3, $8); /* xxx */ }
    678                 // The semantics of the declaration list is changed to include any associated initialization, which is
    679                 // performed *before* the transfer to the appropriate case clause.  Statements after the initial
    680                 // declaration list can never be executed, and therefore, are removed from the grammar even though C
    681                 // allows it.
     673                { $$ = new StatementNode( StatementNode::Switch, $3, $8 ); /* xxx */ }
     674                // The semantics of the declaration list is changed to include any associated initialization, which is performed
     675                // *before* the transfer to the appropriate case clause.  Statements after the initial declaration list can
     676                // never be executed, and therefore, are removed from the grammar even though C allows it.
    682677        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    683                 { $$ = new StatementNode(StatementNode::Choose, $3, $5); }
     678                { $$ = new StatementNode( StatementNode::Choose, $3, $5 ); }
    684679        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    685                 { $$ = new StatementNode(StatementNode::Choose, $3, $8); }
    686         ;
    687 
    688 // CASE and DEFAULT clauses are only allowed in the SWITCH statement, precluding Duff's device. In addition, a
    689 // case clause allows a list of values and subranges.
     680                { $$ = new StatementNode( StatementNode::Choose, $3, $8 ); }
     681        ;
     682
     683// CASE and DEFAULT clauses are only allowed in the SWITCH statement, precluding Duff's device. In addition, a case
     684// clause allows a list of values and subranges.
    690685
    691686case_value:                                                                                             // CFA
    692687        constant_expression                                                     { $$ = $1; }
    693688        | constant_expression ELLIPSIS constant_expression      // GCC, subrange
    694                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Range),$1,$3); }
     689                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $1, $3 ); }
    695690        | subrange                                                                                      // CFA, subrange
    696691        ;
     
    699694        case_value
    700695        | case_value_list ',' case_value
    701                 { $$ = new CompositeExprNode(new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents($1))->set_link($3) ); }
     696                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( $1 ))->set_link( $3 ) ); }
    702697        ;
    703698
    704699case_label:                                                                                             // CFA
    705         CASE case_value_list ':'                                        { $$ = new StatementNode(StatementNode::Case, $2, 0); }
    706         | DEFAULT ':'                                                           { $$ = new StatementNode(StatementNode::Default); }
     700        CASE case_value_list ':'                                        { $$ = new StatementNode( StatementNode::Case, $2, 0 ); }
     701        | DEFAULT ':'                                                           { $$ = new StatementNode( StatementNode::Default ); }
    707702                // A semantic check is required to ensure only one default clause per switch/choose statement.
    708703        ;
     
    710705case_label_list:                                                                                // CFA
    711706        case_label
    712         | case_label_list case_label                            { $$ = (StatementNode *)($1->set_link($2)); }
     707        | case_label_list case_label                            { $$ = (StatementNode *)( $1->set_link( $2 )); }
    713708        ;
    714709
    715710case_clause:                                                                                    // CFA
    716         case_label_list statement                                       { $$ = $1->append_last_case($2); }
     711        case_label_list statement                                       { $$ = $1->append_last_case( $2 ); }
    717712        ;
    718713
     
    725720switch_clause_list:                                                                             // CFA
    726721        case_label_list statement_list
    727                 { $$ = $1->append_last_case($2); }
     722                { $$ = $1->append_last_case( $2 ); }
    728723        | switch_clause_list case_label_list statement_list
    729                 { $$ = (StatementNode *)($1->set_link($2->append_last_case($3))); }
     724                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }
    730725        ;
    731726
     
    738733choose_clause_list:                                                                             // CFA
    739734        case_label_list fall_through
    740                 { $$ = $1->append_last_case($2); }
     735                { $$ = $1->append_last_case( $2 ); }
    741736        | case_label_list statement_list fall_through_opt
    742                 { $$ = $1->append_last_case((StatementNode *)mkList((*$2,*$3))); }
     737                { $$ = $1->append_last_case((StatementNode *)mkList((*$2,*$3 ))); }
    743738        | choose_clause_list case_label_list fall_through
    744                 { $$ = (StatementNode *)($1->set_link($2->append_last_case($3))); }
     739                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }
    745740        | choose_clause_list case_label_list statement_list fall_through_opt
    746                 { $$ = (StatementNode *)($1->set_link($2->append_last_case((StatementNode *)mkList((*$3,*$4))))); }
     741                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case((StatementNode *)mkList((*$3,*$4 ))))); }
    747742        ;
    748743
     
    754749
    755750fall_through:                                                                                   // CFA
    756         FALLTHRU                                                                        { $$ = new StatementNode(StatementNode::Fallthru, 0, 0); }
    757         | FALLTHRU ';'                                                          { $$ = new StatementNode(StatementNode::Fallthru, 0, 0); }
     751        FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
     752        | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
    758753        ;
    759754
    760755iteration_statement:
    761756        WHILE '(' comma_expression ')' statement
    762                 { $$ = new StatementNode(StatementNode::While, $3, $5); }
     757                { $$ = new StatementNode( StatementNode::While, $3, $5 ); }
    763758        | DO statement WHILE '(' comma_expression ')' ';'
    764                 { $$ = new StatementNode(StatementNode::Do, $5, $2); }
     759                { $$ = new StatementNode( StatementNode::Do, $5, $2 ); }
    765760        | FOR '(' push for_control_expression ')' statement
    766                 { $$ = new StatementNode(StatementNode::For, $4, $6); }
     761                { $$ = new StatementNode( StatementNode::For, $4, $6 ); }
    767762        ;
    768763
    769764for_control_expression:
    770765        comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt
    771                 { $$ = new ForCtlExprNode($1, $4, $6); }
     766                { $$ = new ForCtlExprNode( $1, $4, $6 ); }
    772767        | declaration comma_expression_opt ';' comma_expression_opt // C99
    773                 { $$ = new ForCtlExprNode($1, $2, $4); }
     768                { $$ = new ForCtlExprNode( $1, $2, $4 ); }
    774769        ;
    775770
    776771jump_statement:
    777772        GOTO no_attr_identifier ';'
    778                 { $$ = new StatementNode(StatementNode::Goto, $2); }
     773                { $$ = new StatementNode( StatementNode::Goto, $2 ); }
    779774        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    780                 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; =>
    781                 // goto *(i+3); whereas normal operator precedence yields goto (*i)+3;
    782                 { $$ = new StatementNode(StatementNode::Goto, $3); }
     775                // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3 );
     776                // whereas normal operator precedence yields goto (*i)+3;
     777                { $$ = new StatementNode( StatementNode::Goto, $3 ); }
    783778        | CONTINUE ';'
    784                 // A semantic check is required to ensure this statement appears only in the body of an iteration
    785                 // statement.
    786                 { $$ = new StatementNode(StatementNode::Continue, 0, 0); }
     779                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
     780                { $$ = new StatementNode( StatementNode::Continue, 0, 0 ); }
    787781        | CONTINUE no_attr_identifier ';'                                       // CFA, multi-level continue
    788                 // A semantic check is required to ensure this statement appears only in the body of an iteration
    789                 // statement, and the target of the transfer appears only at the start of an iteration statement.
    790                 { $$ = new StatementNode(StatementNode::Continue, $2); }
     782                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     783                // the target of the transfer appears only at the start of an iteration statement.
     784                { $$ = new StatementNode( StatementNode::Continue, $2 ); }
    791785        | BREAK ';'
    792                 // A semantic check is required to ensure this statement appears only in the body of an iteration
    793                 // statement.
    794                 { $$ = new StatementNode(StatementNode::Break, 0, 0); }
     786                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
     787                { $$ = new StatementNode( StatementNode::Break, 0, 0 ); }
    795788        | BREAK no_attr_identifier ';'                                          // CFA, multi-level exit
    796                 // A semantic check is required to ensure this statement appears only in the body of an iteration
    797                 // statement, and the target of the transfer appears only at the start of an iteration statement.
    798                 { $$ = new StatementNode(StatementNode::Break, $2 ); }
     789                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     790                // the target of the transfer appears only at the start of an iteration statement.
     791                { $$ = new StatementNode( StatementNode::Break, $2 ); }
    799792        | RETURN comma_expression_opt ';'
    800                 { $$ = new StatementNode(StatementNode::Return, $2, 0); }
     793                { $$ = new StatementNode( StatementNode::Return, $2, 0 ); }
    801794        | THROW assignment_expression ';'
    802                 { $$ = new StatementNode(StatementNode::Throw, $2, 0); }
     795                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
    803796        | THROW ';'
    804                 { $$ = new StatementNode(StatementNode::Throw, 0, 0); }
     797                { $$ = new StatementNode( StatementNode::Throw, 0, 0 ); }
    805798        ;
    806799
    807800exception_statement:
    808801        TRY compound_statement handler_list
    809                 { $$ = new StatementNode(StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3)))); }
     802                { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
    810803        | TRY compound_statement finally_clause
    811                 { $$ = new StatementNode(StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3)))); }
     804                { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
    812805        | TRY compound_statement handler_list finally_clause
    813806                {
    814                         $3->set_link($4);
    815                         $$ = new StatementNode(StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3))));
     807                        $3->set_link( $4 );
     808                        $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 ))));
    816809                }
    817810        ;
     
    820813                // There must be at least one catch clause
    821814        handler_clause
    822                 // ISO/IEC 9899:1999 Section 15.3(6) If present, a "..." handler shall be the last handler for its try
    823                 // block.
     815                // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
    824816        | CATCH '(' ELLIPSIS ')' compound_statement
    825817                { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
     
    830822handler_clause:
    831823        CATCH '(' push push exception_declaration pop ')' compound_statement pop
    832                 { $$ = StatementNode::newCatchStmt($5, $8); }
     824                { $$ = StatementNode::newCatchStmt( $5, $8 ); }
    833825        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    834                 { $$ = $1->set_link( StatementNode::newCatchStmt($6, $9) ); }
     826                { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
    835827        ;
    836828
     
    838830        FINALLY compound_statement
    839831                {
    840                         $$ = new StatementNode(StatementNode::Finally, 0, $2);
     832                        $$ = new StatementNode( StatementNode::Finally, 0, $2 );
    841833                        std::cout << "Just created a finally node" << std::endl;
    842834                }
     
    867859asm_statement:
    868860        ASM type_qualifier_list_opt '(' constant_expression ')' ';'
    869                 { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
     861                { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    870862        | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ')' ';' // remaining GCC
    871                 { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
     863                { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    872864        | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    873                 { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
     865                { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    874866        | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list ')' ';'
    875                 { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
     867                { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    876868        ;
    877869
     
    941933        ;
    942934
    943 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and
    944 // function declarations. CFA declarations use the same declaration tokens as in C; however, CFA places
    945 // declaration modifiers to the left of the base type, while C declarations place modifiers to the right of
    946 // the base type. CFA declaration modifiers are interpreted from left to right and the entire type
    947 // specification is distributed across all variables in the declaration list (as in Pascal).  ANSI C and the
    948 // new CFA declarations may appear together in the same program block, but cannot be mixed within a specific
    949 // declaration.
     935// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     936// declarations. CFA declarations use the same declaration tokens as in C; however, CFA places declaration modifiers to
     937// the left of the base type, while C declarations place modifiers to the right of the base type. CFA declaration
     938// modifiers are interpreted from left to right and the entire type specification is distributed across all variables in
     939// the declaration list (as in Pascal).  ANSI C and the new CFA declarations may appear together in the same program
     940// block, but cannot be mixed within a specific declaration.
    950941//
    951942//                      CFA                                     C
     
    968959                }
    969960        | declaration_qualifier_list new_variable_specifier initializer_opt
    970                 // declaration_qualifier_list also includes type_qualifier_list, so a semantic check is necessary to
    971                 // preclude them as a type_qualifier cannot appear in that context.
     961                // declaration_qualifier_list also includes type_qualifier_list, so a semantic check is necessary to preclude
     962                // them as a type_qualifier cannot appear in that context.
    972963                {
    973964                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    982973
    983974new_variable_specifier:                                                                 // CFA
    984                 // A semantic check is required to ensure asm_name only appears on declarations with implicit or
    985                 // explicit static storage-class
     975                // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static
     976                // storage-class
    986977        new_abstract_declarator_no_tuple identifier_or_typedef_name asm_name_opt
    987978                {
     
    10321023        '[' push pop ']' identifier '(' push new_parameter_type_list_opt pop ')'
    10331024                {
    1034                         typedefTable.setNextIdentifier( *($5) );
     1025                        typedefTable.setNextIdentifier( *( $5 ) );
    10351026                        $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    10361027                }
    10371028        | '[' push pop ']' TYPEDEFname '(' push new_parameter_type_list_opt pop ')'
    10381029                {
    1039                         typedefTable.setNextIdentifier( *($5) );
     1030                        typedefTable.setNextIdentifier( *( $5 ) );
    10401031                        $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    10411032                }
     
    10451036                //   '[' ']' type_specifier
    10461037                //
    1047                 // type_specifier can resolve to just TYPEDEFname (e.g. typedef int T; int f( T );). Therefore this
    1048                 // must be flattened to allow lookahead to the '(' without having to reduce
    1049                 // identifier_or_typedef_name.
     1038                // type_specifier can resolve to just TYPEDEFname (e.g. typedef int T; int f( T );). Therefore this must be
     1039                // flattened to allow lookahead to the '(' without having to reduce identifier_or_typedef_name.
    10501040        | new_abstract_tuple identifier_or_typedef_name '(' push new_parameter_type_list_opt pop ')'
    1051                 // To obtain LR(1), this rule must be factored out from function return type (see
    1052                 //   new_abstract_declarator).
     1041                // To obtain LR(1 ), this rule must be factored out from function return type (see new_abstract_declarator).
    10531042                {
    10541043                        $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true );
     
    10641053                { $$ = DeclarationNode::newTuple( $3 ); }
    10651054        | '[' push new_parameter_list pop ',' push new_abstract_parameter_list pop ']'
    1066                 // To obtain LR(1), the last new_abstract_parameter_list is added into this flattened rule to
    1067                 // lookahead to the ']'.
     1055                // To obtain LR(1 ), the last new_abstract_parameter_list is added into this flattened rule to lookahead to the
     1056                // ']'.
    10681057                { $$ = DeclarationNode::newTuple( $3->appendList( $7 ) ); }
    10691058        ;
     
    10721061        TYPEDEF new_variable_specifier
    10731062                {
    1074                         typedefTable.addToEnclosingScope( TypedefTable::TD);
     1063                        typedefTable.addToEnclosingScope( TypedefTable::TD );
    10751064                        $$ = $2->addTypedef();
    10761065                }
    10771066        | TYPEDEF new_function_specifier
    10781067                {
    1079                         typedefTable.addToEnclosingScope( TypedefTable::TD);
     1068                        typedefTable.addToEnclosingScope( TypedefTable::TD );
    10801069                        $$ = $2->addTypedef();
    10811070                }
    10821071        | new_typedef_declaration pop ',' push no_attr_identifier
    10831072                {
    1084                         typedefTable.addToEnclosingScope( *$5, TypedefTable::TD);
     1073                        typedefTable.addToEnclosingScope( *$5, TypedefTable::TD );
    10851074                        $$ = $1->appendList( $1->cloneType( $5 ) );
    10861075                }
    10871076        ;
    10881077
    1089 // Traditionally typedef is part of storage-class specifier for syntactic convenience only. Here, it is
    1090 // factored out as a separate form of declaration, which syntactically precludes storage-class specifiers and
    1091 // initialization.
     1078// Traditionally typedef is part of storage-class specifier for syntactic convenience only. Here, it is factored out as
     1079// a separate form of declaration, which syntactically precludes storage-class specifiers and initialization.
    10921080
    10931081typedef_declaration:
    10941082        TYPEDEF type_specifier declarator
    10951083                {
    1096                         typedefTable.addToEnclosingScope( TypedefTable::TD);
     1084                        typedefTable.addToEnclosingScope( TypedefTable::TD );
    10971085                        $$ = $3->addType( $2 )->addTypedef();
    10981086                }
    10991087        | typedef_declaration pop ',' push declarator
    11001088                {
    1101                         typedefTable.addToEnclosingScope( TypedefTable::TD);
     1089                        typedefTable.addToEnclosingScope( TypedefTable::TD );
    11021090                        $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() );
    11031091                }
    1104         | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2)
    1105                 {
    1106                         typedefTable.addToEnclosingScope( TypedefTable::TD);
     1092        | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 )
     1093                {
     1094                        typedefTable.addToEnclosingScope( TypedefTable::TD );
    11071095                        $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef();
    11081096                }
    11091097        | type_specifier TYPEDEF declarator
    11101098                {
    1111                         typedefTable.addToEnclosingScope( TypedefTable::TD);
     1099                        typedefTable.addToEnclosingScope( TypedefTable::TD );
    11121100                        $$ = $3->addType( $1 )->addTypedef();
    11131101                }
    11141102        | type_specifier TYPEDEF type_qualifier_list declarator
    11151103                {
    1116                         typedefTable.addToEnclosingScope( TypedefTable::TD);
    1117                         $$ = $4->addQualifiers($1)->addTypedef()->addType($1);
     1104                        typedefTable.addToEnclosingScope( TypedefTable::TD );
     1105                        $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 );
    11181106                }
    11191107        ;
     
    11221110        TYPEDEF no_attr_identifier '=' assignment_expression
    11231111                {
    1124                         typedefTable.addToEnclosingScope(*($2), TypedefTable::TD);
     1112                        typedefTable.addToEnclosingScope( *$2, TypedefTable::TD );
    11251113                        $$ = DeclarationNode::newName( 0 ); // XXX
    11261114                }
    11271115        | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression
    11281116                {
    1129                         typedefTable.addToEnclosingScope(*($5), TypedefTable::TD);
     1117                        typedefTable.addToEnclosingScope( *$5, TypedefTable::TD );
    11301118                        $$ = DeclarationNode::newName( 0 ); // XXX
    11311119                }
     
    11401128
    11411129declaring_list:
    1142                 // A semantic check is required to ensure asm_name only appears on declarations with implicit or
    1143                 // explicit static storage-class
     1130                // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static
     1131                // storage-class
    11441132        declaration_specifier declarator asm_name_opt initializer_opt
    11451133                {
    11461134                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1147                         $$ = ($2->addType( $1 ))->addInitializer($4);
     1135                        $$ = ( $2->addType( $1 ))->addInitializer( $4 );
    11481136                }
    11491137        | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt
    11501138                {
    11511139                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1152                         $$ = $1->appendList( $1->cloneBaseType( $4->addInitializer($6) ) );
     1140                        $$ = $1->appendList( $1->cloneBaseType( $4->addInitializer( $6 ) ) );
    11531141                }
    11541142        ;
     
    11751163
    11761164type_qualifier_list:
    1177                 // A semantic check is necessary to ensure a type qualifier is appropriate for the kind of
    1178                 // declaration.
     1165                // A semantic check is necessary to ensure a type qualifier is appropriate for the kind of declaration.
    11791166                //
    1180                 // ISO/IEC 9899:1999 Section 6.7.3(4) : If the same qualifier appears more than once in the same
    1181                 // specifier-qualifier-list, either directly or via one or more typedefs, the behavior is the same as
    1182                 // if it appeared only once.
     1167                // ISO/IEC 9899:1999 Section 6.7.3(4 ) : If the same qualifier appears more than once in the same
     1168                // specifier-qualifier-list, either directly or via one or more typedefs, the behavior is the same as if it
     1169                // appeared only once.
    11831170        type_qualifier
    11841171        | type_qualifier_list type_qualifier
     
    12161203declaration_qualifier_list:
    12171204        storage_class_list
    1218         | type_qualifier_list storage_class_list                        // remaining OBSOLESCENT (see 2)
     1205        | type_qualifier_list storage_class_list                        // remaining OBSOLESCENT (see 2 )
    12191206                { $$ = $1->addQualifiers( $2 ); }
    12201207        | declaration_qualifier_list type_qualifier_list storage_class_list
     
    12231210
    12241211storage_class_list:
    1225                 // A semantic check is necessary to ensure a storage class is appropriate for the kind of declaration
    1226                 // and that only one of each is specified, except for inline, which can appear with the others.
     1212                // A semantic check is necessary to ensure a storage class is appropriate for the kind of declaration and that
     1213                // only one of each is specified, except for inline, which can appear with the others.
    12271214                //
    1228                 // ISO/IEC 9899:1999 Section 6.7.1(2) : At most, one storage-class specifier may be given in the
    1229                 // declaration specifiers in a declaration.
     1215                // ISO/IEC 9899:1999 Section 6.7.1(2) : At most, one storage-class specifier may be given in the declaration
     1216                // specifiers in a declaration.
    12301217        storage_class
    12311218        | storage_class_list storage_class
     
    13811368        | aggregate_key '(' push type_parameter_list pop ')' '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    13821369                { $$ = DeclarationNode::newAggregate( $1, 0, $4, $8, $11 ); }
     1370        | aggregate_key TYPEGENname '(' type_name_list ')' // CFA
     1371                {}
    13831372        | aggregate_key '(' push type_name_list pop ')' no_attr_identifier_or_typedef_name // CFA
    13841373                // push and pop are only to prevent S/R conflicts
     
    15011490
    15021491new_parameter_list:                                                                             // CFA
    1503                 // To obtain LR(1) between new_parameter_list and new_abstract_tuple, the last
    1504                 // new_abstract_parameter_list is factored out from new_parameter_list, flattening the rules to get
    1505                 // lookahead to the ']'.
     1492                // To obtain LR(1) between new_parameter_list and new_abstract_tuple, the last new_abstract_parameter_list is
     1493                // factored out from new_parameter_list, flattening the rules to get lookahead to the ']'.
    15061494        new_parameter_declaration
    15071495        | new_abstract_parameter_list pop ',' push new_parameter_declaration
     
    15401528        ;
    15411529
    1542 // Provides optional identifier names (abstract_declarator/variable_declarator), no initialization, different
    1543 // semantics for typedef name by using typedef_parameter_redeclarator instead of typedef_redeclarator, and
    1544 // function prototypes.
     1530// Provides optional identifier names (abstract_declarator/variable_declarator), no initialization, different semantics
     1531// for typedef name by using typedef_parameter_redeclarator instead of typedef_redeclarator, and function prototypes.
    15451532
    15461533new_parameter_declaration:                                                              // CFA, new & old style parameter declaration
     
    15701557                {
    15711558                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1572                         $$ = $2->addType( $1 )->addInitializer( new InitializerNode($3) );
     1559                        $$ = $2->addType( $1 )->addInitializer( new InitializerNode( $3 ) );
    15731560                }
    15741561        | declaration_specifier typedef_parameter_redeclarator assignment_opt
    15751562                {
    15761563                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1577                         $$ = $2->addType( $1 )->addInitializer( new InitializerNode($3) );
     1564                        $$ = $2->addType( $1 )->addInitializer( new InitializerNode( $3 ) );
    15781565                }
    15791566        ;
     
    15861573
    15871574// ISO/IEC 9899:1999 Section 6.9.1(6) : "An identifier declared as a typedef name shall not be redeclared as a
    1588 // parameter." Because the scope of the K&R-style parameter-list sees the typedef first, the following is
    1589 // based only on identifiers.  The ANSI-style parameter-list can redefine a typedef name.
     1575// parameter." Because the scope of the K&R-style parameter-list sees the typedef first, the following is based only on
     1576// identifiers.  The ANSI-style parameter-list can redefine a typedef name.
    15901577
    15911578identifier_list:                                                                                // K&R-style parameter list => no types
     
    16111598        no_attr_identifier
    16121599        | TYPEDEFname
    1613         | TYPEGENname
     1600        //      | TYPEGENname
    16141601        ;
    16151602
     
    16361623
    16371624initializer:
    1638         assignment_expression                                           { $$ = new InitializerNode($1); }
    1639         | '{' initializer_list comma_opt '}'            { $$ = new InitializerNode($2, true); }
     1625        assignment_expression                                           { $$ = new InitializerNode( $1 ); }
     1626        | '{' initializer_list comma_opt '}'            { $$ = new InitializerNode( $2, true ); }
    16401627        ;
    16411628
     
    16431630        initializer
    16441631        | designation initializer                                       { $$ = $2->set_designators( $1 ); }
    1645         | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_link($3) ); }
     1632        | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_link( $3 ) ); }
    16461633        | initializer_list ',' designation initializer
    1647                 { $$ = (InitializerNode *)( $1->set_link( $4->set_designators($3) ) ); }
    1648         ;
    1649 
    1650 // There is an unreconcileable parsing problem between C99 and CFA with respect to designators. The problem is
    1651 // use of '=' to separator the designator from the initializer value, as in:
     1634                { $$ = (InitializerNode *)( $1->set_link( $4->set_designators( $3 ) ) ); }
     1635        ;
     1636
     1637// There is an unreconcileable parsing problem between C99 and CFA with respect to designators. The problem is use of
     1638// '=' to separator the designator from the initializer value, as in:
    16521639//
    16531640//              int x[10] = { [1] = 3 };
    16541641//
    1655 // The string "[1] = 3" can be parsed as a designator assignment or a tuple assignment.  To disambiguate this
    1656 // case, CFA changes the syntax from "=" to ":" as the separator between the designator and initializer. GCC
    1657 // does uses ":" for field selection. The optional use of the "=" in GCC, or in this case ":", cannot be
    1658 // supported either due to shift/reduce conflicts
     1642// The string "[1] = 3" can be parsed as a designator assignment or a tuple assignment.  To disambiguate this case, CFA
     1643// changes the syntax from "=" to ":" as the separator between the designator and initializer. GCC does uses ":" for
     1644// field selection. The optional use of the "=" in GCC, or in this case ":", cannot be supported either due to
     1645// shift/reduce conflicts
    16591646
    16601647designation:
     
    16661653designator_list:                                                                                // C99
    16671654        designator
    1668         | designator_list designator                                    { $$ = (ExpressionNode *)($1->set_link( $2 )); }
     1655        | designator_list designator                                    { $$ = (ExpressionNode *)( $1->set_link( $2 )); }
     1656        //| designator_list designator                                          { $$ = new CompositeExprNode( $1, $2 ); }
    16691657        ;
    16701658
     
    16731661                { $$ = new VarRefNode( $2 ); }
    16741662        | '[' push assignment_expression pop ']'                        // C99, single array element
    1675                 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with
    1676                 // tuple.
     1663                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
    16771664                { $$ = $3; }
    16781665        | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    16791666                { $$ = $3; }
    16801667        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    1681                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Range), $3, $5); }
     1668                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ); }
    16821669        | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    16831670                { $$ = $4; }
    16841671        ;
    16851672
    1686 // The CFA type system is based on parametric polymorphism, the ability to declare functions with type
    1687 // parameters, rather than an object-oriented type system. This required four groups of extensions:
     1673// The CFA type system is based on parametric polymorphism, the ability to declare functions with type parameters,
     1674// rather than an object-oriented type system. This required four groups of extensions:
    16881675//
    16891676// Overloading: function, data, and operator identifiers may be overloaded.
    16901677//
    1691 // Type declarations: "type" is used to generate new types for declaring objects. Similarly, "dtype" is used
    1692 //     for object and incomplete types, and "ftype" is used for function types. Type declarations with
    1693 //     initializers provide definitions of new types. Type declarations with storage class "extern" provide
    1694 //     opaque types.
    1695 //
    1696 // Polymorphic functions: A forall clause declares a type parameter. The corresponding argument is inferred at
    1697 //     the call site. A polymorphic function is not a template; it is a function, with an address and a type.
     1678// Type declarations: "type" is used to generate new types for declaring objects. Similarly, "dtype" is used for object
     1679//     and incomplete types, and "ftype" is used for function types. Type declarations with initializers provide
     1680//     definitions of new types. Type declarations with storage class "extern" provide opaque types.
     1681//
     1682// Polymorphic functions: A forall clause declares a type parameter. The corresponding argument is inferred at the call
     1683//     site. A polymorphic function is not a template; it is a function, with an address and a type.
    16981684//
    16991685// Specifications and Assertions: Specifications are collections of declarations parameterized by one or more
    1700 //     types. They serve many of the purposes of abstract classes, and specification hierarchies resemble
    1701 //     subclass hierarchies. Unlike classes, they can define relationships between types.  Assertions declare
    1702 //     that a type or types provide the operations declared by a specification.  Assertions are normally used
    1703 //     to declare requirements on type arguments of polymorphic functions.
     1686//     types. They serve many of the purposes of abstract classes, and specification hierarchies resemble subclass
     1687//     hierarchies. Unlike classes, they can define relationships between types.  Assertions declare that a type or
     1688//     types provide the operations declared by a specification.  Assertions are normally used to declare requirements
     1689//     on type arguments of polymorphic functions.
    17041690
    17051691typegen_declaration_specifier:                                                  // CFA
     
    17301716type_parameter:                                                                                 // CFA
    17311717        type_class no_attr_identifier_or_typedef_name
    1732                 { typedefTable.addToEnclosingScope(*($2), TypedefTable::TD); }
     1718                { typedefTable.addToEnclosingScope(*( $2 ), TypedefTable::TD ); }
    17331719          assertion_list_opt
    17341720                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addAssertions( $4 ); }
     
    17551741        '|' no_attr_identifier_or_typedef_name '(' type_name_list ')'
    17561742                {
    1757                         typedefTable.openContext( *($2) );
     1743                        typedefTable.openContext( *( $2 ) );
    17581744                        $$ = DeclarationNode::newContextUse( $2, $4 );
    17591745                }
     
    17691755        | assignment_expression
    17701756        | type_name_list ',' type_name
    1771                 { $$ = (ExpressionNode *)($1->set_link(new TypeValueNode( $3 ))); }
     1757                { $$ = (ExpressionNode *)( $1->set_link( new TypeValueNode( $3 ))); }
    17721758        | type_name_list ',' assignment_expression
    1773                 { $$ = (ExpressionNode *)($1->set_link($3)); }
     1759                { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
    17741760        ;
    17751761
     
    17931779        no_attr_identifier_or_typedef_name
    17941780                {
    1795                         typedefTable.addToEnclosingScope(*($1), TypedefTable::TD);
     1781                        typedefTable.addToEnclosingScope( *$1, TypedefTable::TD );
    17961782                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    17971783                }
    17981784        | no_01_identifier_or_typedef_name '(' push type_parameter_list pop ')'
    17991785                {
    1800                         typedefTable.addToEnclosingScope(*($1), TypedefTable::TG);
     1786                        typedefTable.addToEnclosingScope( *$1, TypedefTable::TG );
    18011787                        $$ = DeclarationNode::newTypeDecl( $1, $4 );
    18021788                }
     
    18061792        CONTEXT no_attr_identifier_or_typedef_name '(' push type_parameter_list pop ')' '{' '}'
    18071793                {
    1808                         typedefTable.addToEnclosingScope(*($2), TypedefTable::ID );
     1794                        typedefTable.addToEnclosingScope( *$2, TypedefTable::ID );
    18091795                        $$ = DeclarationNode::newContext( $2, $5, 0 );
    18101796                }
    18111797        | CONTEXT no_attr_identifier_or_typedef_name '(' push type_parameter_list pop ')' '{'
    18121798                {
    1813                         typedefTable.enterContext( *($2) );
     1799                        typedefTable.enterContext( *$2 );
    18141800                        typedefTable.enterScope();
    18151801                }
     
    18171803                {
    18181804                        typedefTable.leaveContext();
    1819                         typedefTable.addToEnclosingScope(*($2), TypedefTable::ID );
     1805                        typedefTable.addToEnclosingScope( *$2, TypedefTable::ID );
    18201806                        $$ = DeclarationNode::newContext( $2, $5, $10 );
    18211807                }
     
    18461832        | new_context_declaring_list pop ',' push identifier_or_typedef_name
    18471833                {
    1848                         typedefTable.addToEnclosingScope2( *($5), TypedefTable::ID );
     1834                        typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID );
    18491835                        $$ = $1->appendList( $1->cloneType( $5 ) );
    18501836                }
     
    18821868        external_definition
    18831869        | external_definition_list push external_definition
    1884                 { $$ = ($1 != NULL ) ? $1->appendList( $3 ) : $3; }
     1870                { $$ = ( $1 != NULL ) ? $1->appendList( $3 ) : $3; }
    18851871        ;
    18861872
     
    19141900        function_definition
    19151901
    1916                 // These rules are a concession to the "implicit int" type_specifier because there is a significant
    1917                 // amount of code with functions missing a type-specifier on the return type.  Parsing is possible
    1918                 // because function_definition does not appear in the context of an expression (nested functions would
    1919                 // preclude this concession). A function prototype declaration must still have a type_specifier.
    1920                 // OBSOLESCENT (see 1)
     1902                // These rules are a concession to the "implicit int" type_specifier because there is a significant amount of
     1903                // code with functions missing a type-specifier on the return type.  Parsing is possible because
     1904                // function_definition does not appear in the context of an expression (nested functions would preclude this
     1905                // concession). A function prototype declaration must still have a type_specifier.  OBSOLESCENT (see 1)
    19211906        | function_declarator compound_statement
    19221907                {
     
    20021987subrange:
    20031988        constant_expression '~' constant_expression                     // CFA, integer subrange
    2004                 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Range), $1, $3); }
     1989                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $1, $3 ); }
    20051990        ;
    20061991
     
    20432028
    20442029// ============================================================================
    2045 // The following sections are a series of grammar patterns used to parse declarators. Multiple patterns are
    2046 // necessary because the type of an identifier in wrapped around the identifier in the same form as its usage
    2047 // in an expression, as in:
     2030// The following sections are a series of grammar patterns used to parse declarators. Multiple patterns are necessary
     2031// because the type of an identifier in wrapped around the identifier in the same form as its usage in an expression, as
     2032// in:
    20482033//
    20492034//              int (*f())[10] { ... };
    20502035//              ... (*f())[3] += 1;             // definition mimics usage
    20512036//
    2052 // Because these patterns are highly recursive, changes at a lower level in the recursion require copying some
    2053 // or all of the pattern. Each of these patterns has some subtle variation to ensure correct syntax in a
    2054 // particular context.
     2037// Because these patterns are highly recursive, changes at a lower level in the recursion require copying some or all of
     2038// the pattern. Each of these patterns has some subtle variation to ensure correct syntax in a particular context.
    20552039// ============================================================================
    20562040
    20572041// ----------------------------------------------------------------------------
    2058 // The set of valid declarators before a compound statement for defining a function is less than the set of
    2059 // declarators to define a variable or function prototype, e.g.:
     2042// The set of valid declarators before a compound statement for defining a function is less than the set of declarators
     2043// to define a variable or function prototype, e.g.:
    20602044//
    20612045//              valid declaration               invalid definition
     
    20662050//              int (*f)(int);                  int (*f)(int) {}
    20672051//
    2068 // To preclude this syntactic anomaly requires separating the grammar rules for variable and function
    2069 // declarators, hence variable_declarator and function_declarator.
     2052// To preclude this syntactic anomaly requires separating the grammar rules for variable and function declarators, hence
     2053// variable_declarator and function_declarator.
    20702054// ----------------------------------------------------------------------------
    20712055
    2072 // This pattern parses a declaration of a variable that is not redefining a typedef name. The pattern
    2073 // precludes declaring an array of functions versus a pointer to an array of functions.
     2056// This pattern parses a declaration of a variable that is not redefining a typedef name. The pattern precludes
     2057// declaring an array of functions versus a pointer to an array of functions.
    20742058
    20752059variable_declarator:
     
    20832067        identifier
    20842068                {
    2085                         typedefTable.setNextIdentifier( *($1) );
     2069                        typedefTable.setNextIdentifier( *$1 );
    20862070                        $$ = DeclarationNode::newName( $1 );
    20872071                }
     
    21172101        ;
    21182102
    2119 // This pattern parses a function declarator that is not redefining a typedef name. Because functions cannot
    2120 // be nested, there is no context where a function definition can redefine a typedef name. To allow nested
    2121 // functions requires further separation of variable and function declarators in typedef_redeclarator.  The
    2122 // pattern precludes returning arrays and functions versus pointers to arrays and functions.
     2103// This pattern parses a function declarator that is not redefining a typedef name. Because functions cannot be nested,
     2104// there is no context where a function definition can redefine a typedef name. To allow nested functions requires
     2105// further separation of variable and function declarators in typedef_redeclarator.  The pattern precludes returning
     2106// arrays and functions versus pointers to arrays and functions.
    21232107
    21242108function_declarator:
     
    21552139        ;
    21562140
    2157 // This pattern parses an old-style K&R function declarator (OBSOLESCENT, see 4) that is not redefining a
    2158 // typedef name (see function_declarator for additional comments). The pattern precludes returning arrays and
    2159 // functions versus pointers to arrays and functions.
     2141// This pattern parses an old-style K&R function declarator (OBSOLESCENT, see 4) that is not redefining a typedef name
     2142// (see function_declarator for additional comments). The pattern precludes returning arrays and functions versus
     2143// pointers to arrays and functions.
    21602144
    21612145old_function_declarator:
     
    21992183//              }
    22002184//
    2201 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and
    2202 // returning arrays and functions versus pointers to arrays and functions.
     2185// The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
     2186// and functions versus pointers to arrays and functions.
    22032187
    22042188typedef_redeclarator:
     
    22122196        TYPEDEFname
    22132197                {
    2214                         typedefTable.setNextIdentifier( *($1) );
     2198                        typedefTable.setNextIdentifier( *( $1 ) );
    22152199                        $$ = DeclarationNode::newName( $1 );
    22162200                }
     
    22482232        ;
    22492233
    2250 // This pattern parses a declaration for a parameter variable or function prototype that is not redefining a
    2251 // typedef name and allows the C99 array options, which can only appear in a parameter list.  The pattern
    2252 // precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
    2253 // and functions versus pointers to arrays and functions.
     2234// This pattern parses a declaration for a parameter variable or function prototype that is not redefining a typedef
     2235// name and allows the C99 array options, which can only appear in a parameter list.  The pattern precludes declaring an
     2236// array of functions versus a pointer to an array of functions, and returning arrays and functions versus pointers to
     2237// arrays and functions.
    22542238
    22552239identifier_parameter_declarator:
     
    22892273        ;
    22902274
    2291 // This pattern parses a declaration for a parameter variable or function prototype that is redefining a
    2292 // typedef name, e.g.:
     2275// This pattern parses a declaration for a parameter variable or function prototype that is redefining a typedef name,
     2276// e.g.:
    22932277//
    22942278//              typedef int foo;
    22952279//              int f( int foo ); // redefine typedef name in new scope
    22962280//
    2297 // and allows the C99 array options, which can only appear in a parameter list.  In addition, the pattern
    2298 // handles the special meaning of parenthesis around a typedef name:
     2281// and allows the C99 array options, which can only appear in a parameter list.  In addition, the pattern handles the
     2282// special meaning of parenthesis around a typedef name:
    22992283//
    23002284//              ISO/IEC 9899:1999 Section 6.7.5.3(11) : "In a parameter declaration, a single typedef name in
     
    23102294//              int g( int g1( T g2( int p ) ) );               // see identifier_parameter_declarator
    23112295//
    2312 // In essence, a '(' immediately to the left of typedef name, T, is interpreted as starting a parameter type
    2313 // list, and not as redundant parentheses around a redeclaration of T. Finally, the pattern also precludes
    2314 // declaring an array of functions versus a pointer to an array of functions, and returning arrays and
    2315 // functions versus pointers to arrays and functions.
     2296// In essence, a '(' immediately to the left of typedef name, T, is interpreted as starting a parameter type list, and
     2297// not as redundant parentheses around a redeclaration of T. Finally, the pattern also precludes declaring an array of
     2298// functions versus a pointer to an array of functions, and returning arrays and functions versus pointers to arrays and
     2299// functions.
    23162300
    23172301typedef_parameter_redeclarator:
     
    23252309        TYPEDEFname
    23262310                {
    2327                         typedefTable.setNextIdentifier( *($1) );
     2311                        typedefTable.setNextIdentifier( *$1 );
    23282312                        $$ = DeclarationNode::newName( $1 );
    23292313                }
     
    23532337        ;
    23542338
    2355 // This pattern parses a declaration of an abstract variable or function prototype, i.e., there is no
    2356 // identifier to which the type applies, e.g.:
     2339// This pattern parses a declaration of an abstract variable or function prototype, i.e., there is no identifier to
     2340// which the type applies, e.g.:
    23572341//
    23582342//              sizeof( int );
    23592343//              sizeof( int [10] );
    23602344//
    2361 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and
    2362 // returning arrays and functions versus pointers to arrays and functions.
     2345// The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
     2346// and functions versus pointers to arrays and functions.
    23632347
    23642348abstract_declarator:
     
    24262410//              int f( int (int) );             // abstract function-prototype parameter; no parameter name specified
    24272411//
    2428 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and
    2429 // returning arrays and functions versus pointers to arrays and functions.
     2412// The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
     2413// and functions versus pointers to arrays and functions.
    24302414
    24312415abstract_parameter_declarator:
     
    24772461// The declaration of an array parameter has additional syntax over arrays in normal variable declarations:
    24782462//
    2479 //              ISO/IEC 9899:1999 Section 6.7.5.2(1) : "The optional type qualifiers and the keyword static shall
    2480 //              appear only in a declaration of a function parameter with an array type, and then only in the
    2481 //              outermost array type derivation."
     2463//              ISO/IEC 9899:1999 Section 6.7.5.2(1) : "The optional type qualifiers and the keyword static shall appear only in
     2464//              a declaration of a function parameter with an array type, and then only in the outermost array type derivation."
    24822465
    24832466array_parameter_1st_dimension:
     
    24982481        ;
    24992482
    2500 // This pattern parses a declaration of an abstract variable, i.e., there is no identifier to which the type
    2501 // applies, e.g.:
     2483// This pattern parses a declaration of an abstract variable, i.e., there is no identifier to which the type applies,
     2484// e.g.:
    25022485//
    25032486//              sizeof( int ); // abstract variable; no identifier name specified
    25042487//
    2505 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and
    2506 // returning arrays and functions versus pointers to arrays and functions.
     2488// The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
     2489// and functions versus pointers to arrays and functions.
    25072490
    25082491variable_abstract_declarator:
     
    25422525        ;
    25432526
    2544 // This pattern parses a new-style declaration for a parameter variable or function prototype that is either
    2545 // an identifier or typedef name and allows the C99 array options, which can only appear in a parameter list.
     2527// This pattern parses a new-style declaration for a parameter variable or function prototype that is either an
     2528// identifier or typedef name and allows the C99 array options, which can only appear in a parameter list.
    25462529
    25472530new_identifier_parameter_declarator_tuple:                              // CFA
     
    25732556
    25742557new_identifier_parameter_array:                                                 // CFA
    2575                 // Only the first dimension can be empty or have qualifiers. Empty dimension must be factored out due
    2576                 // to shift/reduce conflict with new-style empty (void) function return type.
     2558                // Only the first dimension can be empty or have qualifiers. Empty dimension must be factored out due to
     2559                // shift/reduce conflict with new-style empty (void) function return type.
    25772560        '[' push pop ']' type_specifier
    25782561                { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     
    26112594        ;
    26122595
    2613 // This pattern parses a new-style declaration of an abstract variable or function prototype, i.e., there is
    2614 // no identifier to which the type applies, e.g.:
     2596// This pattern parses a new-style declaration of an abstract variable or function prototype, i.e., there is no
     2597// identifier to which the type applies, e.g.:
    26152598//
    26162599//              [int] f( int );                         // abstract variable parameter; no parameter name specified
     
    26282611//
    26292612// Therefore, it is necessary to look at the token after identifier_or_typedef_name to know when to reduce
    2630 // new_abstract_tuple. To make this LR(1), several rules have to be flattened (lengthened) to allow the
    2631 // necessary lookahead. To accomplish this, new_abstract_declarator has an entry point without tuple, and
    2632 // tuple declarations are duplicated when appearing with new_function_specifier.
     2613// new_abstract_tuple. To make this LR(1), several rules have to be flattened (lengthened) to allow the necessary
     2614// lookahead. To accomplish this, new_abstract_declarator has an entry point without tuple, and tuple declarations are
     2615// duplicated when appearing with new_function_specifier.
    26332616
    26342617new_abstract_declarator_tuple:                                                  // CFA
     
    26602643
    26612644new_abstract_array:                                                                             // CFA
    2662                 // Only the first dimension can be empty. Empty dimension must be factored out due to shift/reduce
    2663                 // conflict with empty (void) function return type.
     2645                // Only the first dimension can be empty. Empty dimension must be factored out due to shift/reduce conflict with
     2646                // empty (void) function return type.
    26642647        '[' push pop ']' type_specifier
    26652648                { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     
    26902673        ;
    26912674
    2692 // 1) ISO/IEC 9899:1999 Section 6.7.2(2) : "At least one type specifier shall be given in the declaration
    2693 //    specifiers in each declaration, and in the specifier-qualifier list in each structure declaration and
    2694 //    type name."
    2695 //
    2696 // 2) ISO/IEC 9899:1999 Section 6.11.5(1) : "The placement of a storage-class specifier other than at the
    2697 //    beginning of the declaration specifiers in a declaration is an obsolescent feature."
     2675// 1) ISO/IEC 9899:1999 Section 6.7.2(2) : "At least one type specifier shall be given in the declaration specifiers in
     2676//    each declaration, and in the specifier-qualifier list in each structure declaration and type name."
     2677//
     2678// 2) ISO/IEC 9899:1999 Section 6.11.5(1) : "The placement of a storage-class specifier other than at the beginning of
     2679//    the declaration specifiers in a declaration is an obsolescent feature."
    26982680//
    26992681// 3) ISO/IEC 9899:1999 Section 6.11.6(1) : "The use of function declarators with empty parentheses (not
    27002682//    prototype-format parameter type declarators) is an obsolescent feature."
    27012683//
    2702 // 4) ISO/IEC 9899:1999 Section 6.11.7(1) : "The use of function definitions with separate parameter
    2703 //    identifier and declaration lists (not prototype-format parameter type and identifier declarators) is an
    2704 //    obsolescent feature.
     2684// 4) ISO/IEC 9899:1999 Section 6.11.7(1) : "The use of function definitions with separate parameter identifier and
     2685//    declaration lists (not prototype-format parameter type and identifier declarators) is an obsolescent feature.
    27052686
    27062687//************************* MISCELLANEOUS ********************************
     
    27302711
    27312712// Local Variables: //
     2713// mode: c++ //
    27322714// tab-width: 4 //
    2733 // mode: c++ //
    27342715// compile-command: "make install" //
    27352716// End: //
Note: See TracChangeset for help on using the changeset viewer.