Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rde62360d r68cd1ce  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 22 15:19:44 2015
    13 // Update Count     : 1082
     12// Last Modified On : Sat Jun 13 07:21:45 2015
     13// Update Count     : 1048
    1414//
    1515
    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.
     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.
    2526
    2627// The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed, except for:
     
    2829// 1. designation with '=' (use ':' instead)
    2930//
    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:
     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:
    3233//
    3334// 1. nested functions
     
    3637// 4. attributes not allowed in parenthesis of declarator
    3738//
    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.
     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.
    4344
    4445%{
     
    249250//************************* Namespace Management ********************************
    250251
    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.
     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.
    277280
    278281push:
     
    291294
    292295constant:
    293                 // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
     296                // ENUMERATIONconstant is not included here; it is treated as a variable with type
     297                // "enumeration constant".
    294298        INTEGERconstant                                                         { $$ = new ConstantNode( ConstantNode::Integer, $1 ); }
    295299        | FLOATINGconstant                                                      { $$ = new ConstantNode( ConstantNode::Float, $1 ); }
     
    326330primary_expression:
    327331        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    328                 { $$ = new VarRefNode( $1 ); }
     332                { $$ = new VarRefNode($1); }
    329333        | zero_one
    330                 { $$ = new VarRefNode( $1 ); }
     334                { $$ = new VarRefNode($1); }
    331335        | constant
    332336                { $$ = $1; }
     
    336340                { $$ = $2; }
    337341        | '(' compound_statement ')'                                            // GCC, lambda expression
    338                 { $$ = new ValofExprNode( $2 ); }
     342                { $$ = new ValofExprNode($2); }
    339343        ;
    340344
     
    342346        primary_expression
    343347        | postfix_expression '[' push assignment_expression pop ']'
    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 ); }
     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); }
    349353        | postfix_expression '(' argument_expression_list ')'
    350                 { $$ = new CompositeExprNode( $1, $3 ); }
     354                { $$ = new CompositeExprNode($1, $3); }
    351355        | postfix_expression '.' no_attr_identifier
    352                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::FieldSel ), $1, new VarRefNode( $3 )); }
     356                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::FieldSel), $1, new VarRefNode($3)); }
    353357        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
    354358        | postfix_expression ARROW no_attr_identifier
    355                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PFieldSel ), $1, new VarRefNode( $3 )); }
     359                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PFieldSel), $1, new VarRefNode($3)); }
    356360        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
    357361        | postfix_expression ICR
    358                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::IncrPost ), $1 ); }
     362                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::IncrPost), $1); }
    359363        | postfix_expression DECR
    360                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::DecrPost ), $1 ); }
     364                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::DecrPost), $1); }
    361365                // GCC has priority: cast_expression
    362366        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99
     
    367371        argument_expression
    368372        | argument_expression_list ',' argument_expression
    369                 { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
     373                { $$ = (ExpressionNode *)($1->set_link($3)); }
    370374        ;
    371375
     
    375379        | assignment_expression
    376380        | no_attr_identifier ':' assignment_expression
    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.
     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.
    381385        | '[' push assignment_expression pop ']' ':' assignment_expression
    382                 { $$ = $7->set_asArgName( $3 ); }
     386                { $$ = $7->set_asArgName($3); }
    383387        | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression
    384388                { $$ = $9->set_asArgName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
     
    394398                { $$ = new VarRefNode( $1 ); }
    395399        | no_attr_identifier '.' field
    396                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( $1 ), $3 ); }
     400                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::FieldSel), new VarRefNode( $1 ), $3); }
    397401        | no_attr_identifier '.' '[' push field_list pop ']'
    398                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( $1 ), $5 ); }
     402                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::FieldSel), new VarRefNode( $1 ), $5); }
    399403        | no_attr_identifier ARROW field
    400                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( $1 ), $3 ); }
     404                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PFieldSel), new VarRefNode( $1 ), $3); }
    401405        | no_attr_identifier ARROW '[' push field_list pop ']'
    402                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( $1 ), $5 ); }
     406                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PFieldSel), new VarRefNode( $1 ), $5); }
    403407        ;
    404408
     
    406410        postfix_expression
    407411        | ICR unary_expression
    408                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2 ); }
     412                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Incr), $2); }
    409413        | DECR unary_expression
    410                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Decr ), $2 ); }
     414                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Decr), $2); }
    411415        | EXTENSION cast_expression                                                     // GCC
    412416                { $$ = $2; }
    413417        | unary_operator cast_expression
    414                 { $$ = new CompositeExprNode( $1, $2 ); }
     418                { $$ = new CompositeExprNode($1, $2); }
    415419        | '!' cast_expression
    416                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Neg ), $2 ); }
     420                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Neg), $2); }
    417421        | '*' cast_expression                                                           // CFA
    418                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PointTo ), $2 ); }
     422                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PointTo), $2); }
    419423                // '*' is is separated from unary_operator because of shift/reduce conflict in:
    420424                //              { * X; } // dereference X
     
    422426                // '&' must be moved here if C++ reference variables are supported.
    423427        | SIZEOF unary_expression
    424                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), $2 ); }
     428                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::SizeOf), $2); }
    425429        | SIZEOF '(' type_name_no_function ')'
    426                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), new TypeValueNode( $3 )); }
     430                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::SizeOf), new TypeValueNode($3)); }
    427431        | ATTR_IDENTIFIER
    428                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 )); }
     432                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Attr), new VarRefNode($1)); }
    429433        | ATTR_IDENTIFIER '(' type_name ')'
    430                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ), new TypeValueNode( $3 )); }
     434                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Attr), new VarRefNode($1), new TypeValueNode($3)); }
    431435        | ATTR_IDENTIFIER '(' argument_expression ')'
    432                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ), $3 ); }
     436                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Attr), new VarRefNode($1), $3); }
    433437        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    434                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::AlignOf ), $2 ); }
     438                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::AlignOf), $2); }
    435439        | ALIGNOF '(' type_name_no_function ')'                         // GCC, type alignment
    436                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::AlignOf ), new TypeValueNode( $3 )); }
     440                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::AlignOf), new TypeValueNode($3)); }
    437441        | ANDAND no_attr_identifier                                                     // GCC, address of label
    438                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LabelAddress ), new VarRefNode( $2, true )); }
     442                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::LabelAddress), new VarRefNode($2, true)); }
    439443        ;
    440444
    441445unary_operator:
    442         '&'                                                                                     { $$ = new OperatorNode( OperatorNode::AddressOf ); }
    443         | '+'                                                                           { $$ = new OperatorNode( OperatorNode::UnPlus ); }
    444         | '-'                                                                           { $$ = new OperatorNode( OperatorNode::UnMinus ); }
    445         | '~'                                                                           { $$ = new OperatorNode( OperatorNode::BitNeg ); }
     446        '&'                                                                                     { $$ = new OperatorNode(OperatorNode::AddressOf); }
     447        | '+'                                                                           { $$ = new OperatorNode(OperatorNode::UnPlus); }
     448        | '-'                                                                           { $$ = new OperatorNode(OperatorNode::UnMinus); }
     449        | '~'                                                                           { $$ = new OperatorNode(OperatorNode::BitNeg); }
    446450        ;
    447451
     
    449453        unary_expression
    450454        | '(' type_name_no_function ')' cast_expression
    451                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( $2 ), $4 ); }
     455                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Cast), new TypeValueNode($2), $4); }
    452456        | '(' type_name_no_function ')' tuple
    453                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( $2 ), $4 ); }
     457                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Cast), new TypeValueNode($2), $4); }
    454458        ;
    455459
     
    457461        cast_expression
    458462        | multiplicative_expression '*' cast_expression
    459                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Mul ), $1, $3 ); }
     463                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Mul),$1,$3); }
    460464        | multiplicative_expression '/' cast_expression
    461                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Div ), $1, $3 ); }
     465                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Div),$1,$3); }
    462466        | multiplicative_expression '%' cast_expression
    463                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Mod ), $1, $3 ); }
     467                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Mod),$1,$3); }
    464468        ;
    465469
     
    467471        multiplicative_expression
    468472        | additive_expression '+' multiplicative_expression
    469                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Plus ), $1, $3 ); }
     473                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Plus),$1,$3); }
    470474        | additive_expression '-' multiplicative_expression
    471                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Minus ), $1, $3 ); }
     475                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Minus),$1,$3); }
    472476        ;
    473477
     
    475479        additive_expression
    476480        | shift_expression LS additive_expression
    477                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LShift ), $1, $3 ); }
     481                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::LShift),$1,$3); }
    478482        | shift_expression RS additive_expression
    479                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::RShift ), $1, $3 ); }
     483                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::RShift),$1,$3); }
    480484        ;
    481485
     
    483487        shift_expression
    484488        | relational_expression '<' shift_expression
    485                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LThan ), $1, $3 ); }
     489                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::LThan),$1,$3); }
    486490        | relational_expression '>' shift_expression
    487                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::GThan ), $1, $3 ); }
     491                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::GThan),$1,$3); }
    488492        | relational_expression LE shift_expression
    489                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LEThan ), $1, $3 ); }
     493                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::LEThan),$1,$3); }
    490494        | relational_expression GE shift_expression
    491                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::GEThan ), $1, $3 ); }
     495                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::GEThan),$1,$3); }
    492496        ;
    493497
     
    495499        relational_expression
    496500        | equality_expression EQ relational_expression
    497                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Eq ), $1, $3 ); }
     501                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Eq), $1, $3); }
    498502        | equality_expression NE relational_expression
    499                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Neq ), $1, $3 ); }
     503                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Neq), $1, $3); }
    500504        ;
    501505
     
    503507        equality_expression
    504508        | AND_expression '&' equality_expression
    505                 { $$ =new CompositeExprNode( new OperatorNode( OperatorNode::BitAnd ), $1, $3 ); }
     509                { $$ =new CompositeExprNode(new OperatorNode(OperatorNode::BitAnd), $1, $3); }
    506510        ;
    507511
     
    509513        AND_expression
    510514        | exclusive_OR_expression '^' AND_expression
    511                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Xor ), $1, $3 ); }
     515                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Xor), $1, $3); }
    512516        ;
    513517
     
    515519        exclusive_OR_expression
    516520        | inclusive_OR_expression '|' exclusive_OR_expression
    517                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::BitOr ), $1, $3 ); }
     521                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::BitOr), $1, $3); }
    518522        ;
    519523
     
    521525        inclusive_OR_expression
    522526        | logical_AND_expression ANDAND inclusive_OR_expression
    523                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::And ), $1, $3 ); }
     527                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::And), $1, $3); }
    524528        ;
    525529
     
    527531        logical_AND_expression
    528532        | logical_OR_expression OROR logical_AND_expression
    529                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Or ), $1, $3 ); }
     533                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Or), $1, $3); }
    530534        ;
    531535
     
    533537        logical_OR_expression
    534538        | logical_OR_expression '?' comma_expression ':' conditional_expression
    535                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*$1, *$3, *$5 ) ) ); }
     539                { $$ = new CompositeExprNode( new OperatorNode(OperatorNode::Cond), (ExpressionNode *)mkList( (*$1, *$3, *$5) ) ); }
    536540        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    537                 { $$=new CompositeExprNode( new OperatorNode( OperatorNode::NCond ), $1, $4 ); }
     541                { $$=new CompositeExprNode(new OperatorNode(OperatorNode::NCond),$1,$4); }
    538542        | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
    539                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*$1, *$3, *$5 ) ) ); }
     543                { $$ = new CompositeExprNode( new OperatorNode(OperatorNode::Cond), (ExpressionNode *)mkList( (*$1, *$3, *$5) ) ); }
    540544        ;
    541545
     
    548552        conditional_expression
    549553        | unary_expression '=' assignment_expression
    550                 { $$ =new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $3 ); }
     554                { $$ =new CompositeExprNode(new OperatorNode(OperatorNode::Assign), $1, $3); }
    551555        | unary_expression assignment_operator assignment_expression
    552                 { $$ =new CompositeExprNode( $2, $1, $3 ); }
     556                { $$ =new CompositeExprNode($2, $1, $3); }
    553557        | tuple assignment_opt                                                          // CFA, tuple expression
    554                 { $$ = ( $2 == 0 ) ? $1 : new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $2 ); }
     558                { $$ = ($2 == 0) ? $1 : new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $2 ); }
    555559        ;
    556560
     
    562566
    563567tuple:                                                                                                  // CFA, tuple
    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
     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
    566570        '[' push pop ']'
    567571                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ) ); }
     
    581585
    582586assignment_operator:
    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 ); }
     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); }
    593597        ;
    594598
    595599comma_expression:
    596600        assignment_expression
    597         | comma_expression ',' assignment_expression    // { $$ = (ExpressionNode *)$1->add_to_list( $3 ); }
    598                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Comma ), $1, $3 ); }
     601        | comma_expression ',' assignment_expression    // { $$ = (ExpressionNode *)$1->add_to_list($3); }
     602                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Comma),$1,$3); }
    599603        ;
    600604
     
    620624labeled_statement:
    621625        no_attr_identifier ':' attribute_list_opt statement
    622                 { $$ = $4->add_label( $1 );}
     626                { $$ = $4->add_label($1);}
    623627        ;
    624628
     
    627631                { $$ = new CompoundStmtNode( (StatementNode *)0 ); }
    628632        | '{'
    629                 // Two scopes are necessary because the block itself has a scope, but every declaration within the block also
    630                 // requires its own scope
     633                // Two scopes are necessary because the block itself has a scope, but every declaration within the
     634                // block also requires its own scope
    631635          push push
    632636          label_declaration_opt                                                         // GCC, local labels
     
    638642        block_item
    639643        | block_item_list push block_item
    640                 { if ( $1 != 0 ) { $1->set_link( $3 ); $$ = $1; } }
     644                { if ($1 != 0) { $1->set_link($3); $$ = $1; } }
    641645        ;
    642646
     
    654658        statement
    655659        | statement_list statement
    656                 { if ( $1 != 0 ) { $1->set_link( $2 ); $$ = $1; } }
     660                { if ($1 != 0) { $1->set_link($2); $$ = $1; } }
    657661        ;
    658662
    659663expression_statement:
    660664        comma_expression_opt ';'
    661                 { $$ = new StatementNode( StatementNode::Exp, $1, 0 ); }
     665                { $$ = new StatementNode(StatementNode::Exp, $1, 0); }
    662666        ;
    663667
     
    665669        IF '(' comma_expression ')' statement                           %prec THEN
    666670                // explicitly deal with the shift/reduce conflict on if/else
    667                 { $$ = new StatementNode( StatementNode::If, $3, $5 ); }
     671                { $$ = new StatementNode(StatementNode::If, $3, $5); }
    668672        | IF '(' comma_expression ')' statement ELSE statement
    669                 { $$ = new StatementNode( StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7 )) ); }
     673                { $$ = new StatementNode(StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7)) ); }
    670674        | SWITCH '(' comma_expression ')' case_clause           // CFA
    671                 { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
     675                { $$ = new StatementNode(StatementNode::Switch, $3, $5); }
    672676        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    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.
     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.
    677682        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    678                 { $$ = new StatementNode( StatementNode::Choose, $3, $5 ); }
     683                { $$ = new StatementNode(StatementNode::Choose, $3, $5); }
    679684        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    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.
     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.
    685690
    686691case_value:                                                                                             // CFA
    687692        constant_expression                                                     { $$ = $1; }
    688693        | constant_expression ELLIPSIS constant_expression      // GCC, subrange
    689                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $1, $3 ); }
     694                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Range),$1,$3); }
    690695        | subrange                                                                                      // CFA, subrange
    691696        ;
     
    694699        case_value
    695700        | case_value_list ',' case_value
    696                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( $1 ))->set_link( $3 ) ); }
     701                { $$ = new CompositeExprNode(new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents($1))->set_link($3) ); }
    697702        ;
    698703
    699704case_label:                                                                                             // CFA
    700         CASE case_value_list ':'                                        { $$ = new StatementNode( StatementNode::Case, $2, 0 ); }
    701         | DEFAULT ':'                                                           { $$ = new StatementNode( StatementNode::Default ); }
     705        CASE case_value_list ':'                                        { $$ = new StatementNode(StatementNode::Case, $2, 0); }
     706        | DEFAULT ':'                                                           { $$ = new StatementNode(StatementNode::Default); }
    702707                // A semantic check is required to ensure only one default clause per switch/choose statement.
    703708        ;
     
    705710case_label_list:                                                                                // CFA
    706711        case_label
    707         | case_label_list case_label                            { $$ = (StatementNode *)( $1->set_link( $2 )); }
     712        | case_label_list case_label                            { $$ = (StatementNode *)($1->set_link($2)); }
    708713        ;
    709714
    710715case_clause:                                                                                    // CFA
    711         case_label_list statement                                       { $$ = $1->append_last_case( $2 ); }
     716        case_label_list statement                                       { $$ = $1->append_last_case($2); }
    712717        ;
    713718
     
    720725switch_clause_list:                                                                             // CFA
    721726        case_label_list statement_list
    722                 { $$ = $1->append_last_case( $2 ); }
     727                { $$ = $1->append_last_case($2); }
    723728        | switch_clause_list case_label_list statement_list
    724                 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }
     729                { $$ = (StatementNode *)($1->set_link($2->append_last_case($3))); }
    725730        ;
    726731
     
    733738choose_clause_list:                                                                             // CFA
    734739        case_label_list fall_through
    735                 { $$ = $1->append_last_case( $2 ); }
     740                { $$ = $1->append_last_case($2); }
    736741        | case_label_list statement_list fall_through_opt
    737                 { $$ = $1->append_last_case((StatementNode *)mkList((*$2,*$3 ))); }
     742                { $$ = $1->append_last_case((StatementNode *)mkList((*$2,*$3))); }
    738743        | choose_clause_list case_label_list fall_through
    739                 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }
     744                { $$ = (StatementNode *)($1->set_link($2->append_last_case($3))); }
    740745        | choose_clause_list case_label_list statement_list fall_through_opt
    741                 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case((StatementNode *)mkList((*$3,*$4 ))))); }
     746                { $$ = (StatementNode *)($1->set_link($2->append_last_case((StatementNode *)mkList((*$3,*$4))))); }
    742747        ;
    743748
     
    749754
    750755fall_through:                                                                                   // CFA
    751         FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
    752         | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
     756        FALLTHRU                                                                        { $$ = new StatementNode(StatementNode::Fallthru, 0, 0); }
     757        | FALLTHRU ';'                                                          { $$ = new StatementNode(StatementNode::Fallthru, 0, 0); }
    753758        ;
    754759
    755760iteration_statement:
    756761        WHILE '(' comma_expression ')' statement
    757                 { $$ = new StatementNode( StatementNode::While, $3, $5 ); }
     762                { $$ = new StatementNode(StatementNode::While, $3, $5); }
    758763        | DO statement WHILE '(' comma_expression ')' ';'
    759                 { $$ = new StatementNode( StatementNode::Do, $5, $2 ); }
     764                { $$ = new StatementNode(StatementNode::Do, $5, $2); }
    760765        | FOR '(' push for_control_expression ')' statement
    761                 { $$ = new StatementNode( StatementNode::For, $4, $6 ); }
     766                { $$ = new StatementNode(StatementNode::For, $4, $6); }
    762767        ;
    763768
    764769for_control_expression:
    765770        comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt
    766                 { $$ = new ForCtlExprNode( $1, $4, $6 ); }
     771                { $$ = new ForCtlExprNode($1, $4, $6); }
    767772        | declaration comma_expression_opt ';' comma_expression_opt // C99
    768                 { $$ = new ForCtlExprNode( $1, $2, $4 ); }
     773                { $$ = new ForCtlExprNode($1, $2, $4); }
    769774        ;
    770775
    771776jump_statement:
    772777        GOTO no_attr_identifier ';'
    773                 { $$ = new StatementNode( StatementNode::Goto, $2 ); }
     778                { $$ = new StatementNode(StatementNode::Goto, $2); }
    774779        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    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 ); }
     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); }
    778783        | CONTINUE ';'
    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 ); }
     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); }
    781787        | CONTINUE no_attr_identifier ';'                                       // CFA, multi-level continue
    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 ); }
     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); }
    785791        | BREAK ';'
    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 ); }
     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); }
    788795        | BREAK no_attr_identifier ';'                                          // CFA, multi-level exit
    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 ); }
     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 ); }
    792799        | RETURN comma_expression_opt ';'
    793                 { $$ = new StatementNode( StatementNode::Return, $2, 0 ); }
     800                { $$ = new StatementNode(StatementNode::Return, $2, 0); }
    794801        | THROW assignment_expression ';'
    795                 { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
     802                { $$ = new StatementNode(StatementNode::Throw, $2, 0); }
    796803        | THROW ';'
    797                 { $$ = new StatementNode( StatementNode::Throw, 0, 0 ); }
     804                { $$ = new StatementNode(StatementNode::Throw, 0, 0); }
    798805        ;
    799806
    800807exception_statement:
    801808        TRY compound_statement handler_list
    802                 { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
     809                { $$ = new StatementNode(StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3)))); }
    803810        | TRY compound_statement finally_clause
    804                 { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
     811                { $$ = new StatementNode(StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3)))); }
    805812        | TRY compound_statement handler_list finally_clause
    806813                {
    807                         $3->set_link( $4 );
    808                         $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 ))));
     814                        $3->set_link($4);
     815                        $$ = new StatementNode(StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3))));
    809816                }
    810817        ;
     
    813820                // There must be at least one catch clause
    814821        handler_clause
    815                 // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
     822                // ISO/IEC 9899:1999 Section 15.3(6) If present, a "..." handler shall be the last handler for its try
     823                // block.
    816824        | CATCH '(' ELLIPSIS ')' compound_statement
    817825                { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
     
    822830handler_clause:
    823831        CATCH '(' push push exception_declaration pop ')' compound_statement pop
    824                 { $$ = StatementNode::newCatchStmt( $5, $8 ); }
     832                { $$ = StatementNode::newCatchStmt($5, $8); }
    825833        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    826                 { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
     834                { $$ = $1->set_link( StatementNode::newCatchStmt($6, $9) ); }
    827835        ;
    828836
     
    830838        FINALLY compound_statement
    831839                {
    832                         $$ = new StatementNode( StatementNode::Finally, 0, $2 );
     840                        $$ = new StatementNode(StatementNode::Finally, 0, $2);
    833841                        std::cout << "Just created a finally node" << std::endl;
    834842                }
     
    859867asm_statement:
    860868        ASM type_qualifier_list_opt '(' constant_expression ')' ';'
    861                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
     869                { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
    862870        | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ')' ';' // remaining GCC
    863                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
     871                { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
    864872        | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    865                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
     873                { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
    866874        | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list ')' ';'
    867                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
     875                { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
    868876        ;
    869877
     
    933941        ;
    934942
    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.
     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.
    941950//
    942951//                      CFA                                     C
     
    959968                }
    960969        | declaration_qualifier_list new_variable_specifier initializer_opt
    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.
     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.
    963972                {
    964973                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    973982
    974983new_variable_specifier:                                                                 // CFA
    975                 // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static
    976                 // storage-class
     984                // A semantic check is required to ensure asm_name only appears on declarations with implicit or
     985                // explicit static storage-class
    977986        new_abstract_declarator_no_tuple identifier_or_typedef_name asm_name_opt
    978987                {
     
    10231032        '[' push pop ']' identifier '(' push new_parameter_type_list_opt pop ')'
    10241033                {
    1025                         typedefTable.setNextIdentifier( *( $5 ) );
     1034                        typedefTable.setNextIdentifier( *($5) );
    10261035                        $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    10271036                }
    10281037        | '[' push pop ']' TYPEDEFname '(' push new_parameter_type_list_opt pop ')'
    10291038                {
    1030                         typedefTable.setNextIdentifier( *( $5 ) );
     1039                        typedefTable.setNextIdentifier( *($5) );
    10311040                        $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    10321041                }
     
    10361045                //   '[' ']' type_specifier
    10371046                //
    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.
     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.
    10401050        | new_abstract_tuple identifier_or_typedef_name '(' push new_parameter_type_list_opt pop ')'
    1041                 // To obtain LR(1 ), this rule must be factored out from function return type (see new_abstract_declarator).
     1051                // To obtain LR(1), this rule must be factored out from function return type (see
     1052                //   new_abstract_declarator).
    10421053                {
    10431054                        $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true );
     
    10531064                { $$ = DeclarationNode::newTuple( $3 ); }
    10541065        | '[' push new_parameter_list pop ',' push new_abstract_parameter_list pop ']'
    1055                 // To obtain LR(1 ), the last new_abstract_parameter_list is added into this flattened rule to lookahead to the
    1056                 // ']'.
     1066                // To obtain LR(1), the last new_abstract_parameter_list is added into this flattened rule to
     1067                // lookahead to the ']'.
    10571068                { $$ = DeclarationNode::newTuple( $3->appendList( $7 ) ); }
    10581069        ;
     
    10611072        TYPEDEF new_variable_specifier
    10621073                {
    1063                         typedefTable.addToEnclosingScope( TypedefTable::TD );
     1074                        typedefTable.addToEnclosingScope( TypedefTable::TD);
    10641075                        $$ = $2->addTypedef();
    10651076                }
    10661077        | TYPEDEF new_function_specifier
    10671078                {
    1068                         typedefTable.addToEnclosingScope( TypedefTable::TD );
     1079                        typedefTable.addToEnclosingScope( TypedefTable::TD);
    10691080                        $$ = $2->addTypedef();
    10701081                }
    10711082        | new_typedef_declaration pop ',' push no_attr_identifier
    10721083                {
    1073                         typedefTable.addToEnclosingScope( *$5, TypedefTable::TD );
     1084                        typedefTable.addToEnclosingScope( *$5, TypedefTable::TD);
    10741085                        $$ = $1->appendList( $1->cloneType( $5 ) );
    10751086                }
    10761087        ;
    10771088
    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.
     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.
    10801092
    10811093typedef_declaration:
    10821094        TYPEDEF type_specifier declarator
    10831095                {
    1084                         typedefTable.addToEnclosingScope( TypedefTable::TD );
     1096                        typedefTable.addToEnclosingScope( TypedefTable::TD);
    10851097                        $$ = $3->addType( $2 )->addTypedef();
    10861098                }
    10871099        | typedef_declaration pop ',' push declarator
    10881100                {
    1089                         typedefTable.addToEnclosingScope( TypedefTable::TD );
     1101                        typedefTable.addToEnclosingScope( TypedefTable::TD);
    10901102                        $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() );
    10911103                }
    1092         | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 )
    1093                 {
    1094                         typedefTable.addToEnclosingScope( TypedefTable::TD );
     1104        | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2)
     1105                {
     1106                        typedefTable.addToEnclosingScope( TypedefTable::TD);
    10951107                        $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef();
    10961108                }
    10971109        | type_specifier TYPEDEF declarator
    10981110                {
    1099                         typedefTable.addToEnclosingScope( TypedefTable::TD );
     1111                        typedefTable.addToEnclosingScope( TypedefTable::TD);
    11001112                        $$ = $3->addType( $1 )->addTypedef();
    11011113                }
    11021114        | type_specifier TYPEDEF type_qualifier_list declarator
    11031115                {
    1104                         typedefTable.addToEnclosingScope( TypedefTable::TD );
    1105                         $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 );
     1116                        typedefTable.addToEnclosingScope( TypedefTable::TD);
     1117                        $$ = $4->addQualifiers($1)->addTypedef()->addType($1);
    11061118                }
    11071119        ;
     
    11101122        TYPEDEF no_attr_identifier '=' assignment_expression
    11111123                {
    1112                         typedefTable.addToEnclosingScope( *$2, TypedefTable::TD );
     1124                        typedefTable.addToEnclosingScope(*($2), TypedefTable::TD);
    11131125                        $$ = DeclarationNode::newName( 0 ); // XXX
    11141126                }
    11151127        | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression
    11161128                {
    1117                         typedefTable.addToEnclosingScope( *$5, TypedefTable::TD );
     1129                        typedefTable.addToEnclosingScope(*($5), TypedefTable::TD);
    11181130                        $$ = DeclarationNode::newName( 0 ); // XXX
    11191131                }
     
    11281140
    11291141declaring_list:
    1130                 // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static
    1131                 // storage-class
     1142                // A semantic check is required to ensure asm_name only appears on declarations with implicit or
     1143                // explicit static storage-class
    11321144        declaration_specifier declarator asm_name_opt initializer_opt
    11331145                {
    11341146                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1135                         $$ = ( $2->addType( $1 ))->addInitializer( $4 );
     1147                        $$ = ($2->addType( $1 ))->addInitializer($4);
    11361148                }
    11371149        | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt
    11381150                {
    11391151                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1140                         $$ = $1->appendList( $1->cloneBaseType( $4->addInitializer( $6 ) ) );
     1152                        $$ = $1->appendList( $1->cloneBaseType( $4->addInitializer($6) ) );
    11411153                }
    11421154        ;
     
    11631175
    11641176type_qualifier_list:
    1165                 // A semantic check is necessary to ensure a type qualifier is appropriate for the kind of declaration.
     1177                // A semantic check is necessary to ensure a type qualifier is appropriate for the kind of
     1178                // declaration.
    11661179                //
    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.
     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.
    11701183        type_qualifier
    11711184        | type_qualifier_list type_qualifier
     
    12031216declaration_qualifier_list:
    12041217        storage_class_list
    1205         | type_qualifier_list storage_class_list                        // remaining OBSOLESCENT (see 2 )
     1218        | type_qualifier_list storage_class_list                        // remaining OBSOLESCENT (see 2)
    12061219                { $$ = $1->addQualifiers( $2 ); }
    12071220        | declaration_qualifier_list type_qualifier_list storage_class_list
     
    12101223
    12111224storage_class_list:
    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.
     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.
    12141227                //
    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.
     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.
    12171230        storage_class
    12181231        | storage_class_list storage_class
     
    13681381        | aggregate_key '(' push type_parameter_list pop ')' '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    13691382                { $$ = DeclarationNode::newAggregate( $1, 0, $4, $8, $11 ); }
    1370         | aggregate_key TYPEGENname '(' type_name_list ')' // CFA
    1371                 {}
    13721383        | aggregate_key '(' push type_name_list pop ')' no_attr_identifier_or_typedef_name // CFA
    13731384                // push and pop are only to prevent S/R conflicts
     
    14901501
    14911502new_parameter_list:                                                                             // CFA
    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 ']'.
     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 ']'.
    14941506        new_parameter_declaration
    14951507        | new_abstract_parameter_list pop ',' push new_parameter_declaration
     
    15281540        ;
    15291541
    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.
     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.
    15321545
    15331546new_parameter_declaration:                                                              // CFA, new & old style parameter declaration
     
    15571570                {
    15581571                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1559                         $$ = $2->addType( $1 )->addInitializer( new InitializerNode( $3 ) );
     1572                        $$ = $2->addType( $1 )->addInitializer( new InitializerNode($3) );
    15601573                }
    15611574        | declaration_specifier typedef_parameter_redeclarator assignment_opt
    15621575                {
    15631576                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1564                         $$ = $2->addType( $1 )->addInitializer( new InitializerNode( $3 ) );
     1577                        $$ = $2->addType( $1 )->addInitializer( new InitializerNode($3) );
    15651578                }
    15661579        ;
     
    15731586
    15741587// ISO/IEC 9899:1999 Section 6.9.1(6) : "An identifier declared as a typedef name shall not be redeclared as a
    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.
     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.
    15771590
    15781591identifier_list:                                                                                // K&R-style parameter list => no types
     
    15981611        no_attr_identifier
    15991612        | TYPEDEFname
    1600         //      | TYPEGENname
     1613        | TYPEGENname
    16011614        ;
    16021615
     
    16231636
    16241637initializer:
    1625         assignment_expression                                           { $$ = new InitializerNode( $1 ); }
    1626         | '{' initializer_list comma_opt '}'            { $$ = new InitializerNode( $2, true ); }
     1638        assignment_expression                                           { $$ = new InitializerNode($1); }
     1639        | '{' initializer_list comma_opt '}'            { $$ = new InitializerNode($2, true); }
    16271640        ;
    16281641
     
    16301643        initializer
    16311644        | designation initializer                                       { $$ = $2->set_designators( $1 ); }
    1632         | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_link( $3 ) ); }
     1645        | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_link($3) ); }
    16331646        | initializer_list ',' designation initializer
    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:
     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:
    16391652//
    16401653//              int x[10] = { [1] = 3 };
    16411654//
    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
     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
    16461659
    16471660designation:
     
    16531666designator_list:                                                                                // C99
    16541667        designator
    1655         | designator_list designator                                    { $$ = (ExpressionNode *)( $1->set_link( $2 )); }
    1656         //| designator_list designator                                          { $$ = new CompositeExprNode( $1, $2 ); }
     1668        | designator_list designator                                    { $$ = (ExpressionNode *)($1->set_link( $2 )); }
    16571669        ;
    16581670
     
    16611673                { $$ = new VarRefNode( $2 ); }
    16621674        | '[' push assignment_expression pop ']'                        // C99, single array element
    1663                 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
     1675                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with
     1676                // tuple.
    16641677                { $$ = $3; }
    16651678        | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    16661679                { $$ = $3; }
    16671680        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    1668                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ); }
     1681                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Range), $3, $5); }
    16691682        | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    16701683                { $$ = $4; }
    16711684        ;
    16721685
    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:
     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:
    16751688//
    16761689// Overloading: function, data, and operator identifiers may be overloaded.
    16771690//
    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.
     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.
    16841698//
    16851699// Specifications and Assertions: Specifications are collections of declarations parameterized by one or more
    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.
     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.
    16901704
    16911705typegen_declaration_specifier:                                                  // CFA
     
    17161730type_parameter:                                                                                 // CFA
    17171731        type_class no_attr_identifier_or_typedef_name
    1718                 { typedefTable.addToEnclosingScope(*( $2 ), TypedefTable::TD ); }
     1732                { typedefTable.addToEnclosingScope(*($2), TypedefTable::TD); }
    17191733          assertion_list_opt
    17201734                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addAssertions( $4 ); }
     
    17411755        '|' no_attr_identifier_or_typedef_name '(' type_name_list ')'
    17421756                {
    1743                         typedefTable.openContext( *( $2 ) );
     1757                        typedefTable.openContext( *($2) );
    17441758                        $$ = DeclarationNode::newContextUse( $2, $4 );
    17451759                }
     
    17551769        | assignment_expression
    17561770        | type_name_list ',' type_name
    1757                 { $$ = (ExpressionNode *)( $1->set_link( new TypeValueNode( $3 ))); }
     1771                { $$ = (ExpressionNode *)($1->set_link(new TypeValueNode( $3 ))); }
    17581772        | type_name_list ',' assignment_expression
    1759                 { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
     1773                { $$ = (ExpressionNode *)($1->set_link($3)); }
    17601774        ;
    17611775
     
    17791793        no_attr_identifier_or_typedef_name
    17801794                {
    1781                         typedefTable.addToEnclosingScope( *$1, TypedefTable::TD );
     1795                        typedefTable.addToEnclosingScope(*($1), TypedefTable::TD);
    17821796                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    17831797                }
    17841798        | no_01_identifier_or_typedef_name '(' push type_parameter_list pop ')'
    17851799                {
    1786                         typedefTable.addToEnclosingScope( *$1, TypedefTable::TG );
     1800                        typedefTable.addToEnclosingScope(*($1), TypedefTable::TG);
    17871801                        $$ = DeclarationNode::newTypeDecl( $1, $4 );
    17881802                }
     
    17921806        CONTEXT no_attr_identifier_or_typedef_name '(' push type_parameter_list pop ')' '{' '}'
    17931807                {
    1794                         typedefTable.addToEnclosingScope( *$2, TypedefTable::ID );
     1808                        typedefTable.addToEnclosingScope(*($2), TypedefTable::ID );
    17951809                        $$ = DeclarationNode::newContext( $2, $5, 0 );
    17961810                }
    17971811        | CONTEXT no_attr_identifier_or_typedef_name '(' push type_parameter_list pop ')' '{'
    17981812                {
    1799                         typedefTable.enterContext( *$2 );
     1813                        typedefTable.enterContext( *($2) );
    18001814                        typedefTable.enterScope();
    18011815                }
     
    18031817                {
    18041818                        typedefTable.leaveContext();
    1805                         typedefTable.addToEnclosingScope( *$2, TypedefTable::ID );
     1819                        typedefTable.addToEnclosingScope(*($2), TypedefTable::ID );
    18061820                        $$ = DeclarationNode::newContext( $2, $5, $10 );
    18071821                }
     
    18321846        | new_context_declaring_list pop ',' push identifier_or_typedef_name
    18331847                {
    1834                         typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID );
     1848                        typedefTable.addToEnclosingScope2( *($5), TypedefTable::ID );
    18351849                        $$ = $1->appendList( $1->cloneType( $5 ) );
    18361850                }
     
    18681882        external_definition
    18691883        | external_definition_list push external_definition
    1870                 { $$ = ( $1 != NULL ) ? $1->appendList( $3 ) : $3; }
     1884                { $$ = ($1 != NULL ) ? $1->appendList( $3 ) : $3; }
    18711885        ;
    18721886
     
    19001914        function_definition
    19011915
    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)
     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)
    19061921        | function_declarator compound_statement
    19071922                {
     
    19872002subrange:
    19882003        constant_expression '~' constant_expression                     // CFA, integer subrange
    1989                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $1, $3 ); }
     2004                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Range), $1, $3); }
    19902005        ;
    19912006
     
    20282043
    20292044// ============================================================================
    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:
     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:
    20332048//
    20342049//              int (*f())[10] { ... };
    20352050//              ... (*f())[3] += 1;             // definition mimics usage
    20362051//
    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.
     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.
    20392055// ============================================================================
    20402056
    20412057// ----------------------------------------------------------------------------
    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.:
     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.:
    20442060//
    20452061//              valid declaration               invalid definition
     
    20502066//              int (*f)(int);                  int (*f)(int) {}
    20512067//
    2052 // To preclude this syntactic anomaly requires separating the grammar rules for variable and function declarators, hence
    2053 // variable_declarator and function_declarator.
     2068// To preclude this syntactic anomaly requires separating the grammar rules for variable and function
     2069// declarators, hence variable_declarator and function_declarator.
    20542070// ----------------------------------------------------------------------------
    20552071
    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.
     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.
    20582074
    20592075variable_declarator:
     
    20672083        identifier
    20682084                {
    2069                         typedefTable.setNextIdentifier( *$1 );
     2085                        typedefTable.setNextIdentifier( *($1) );
    20702086                        $$ = DeclarationNode::newName( $1 );
    20712087                }
     
    21012117        ;
    21022118
    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.
     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.
    21072123
    21082124function_declarator:
     
    21392155        ;
    21402156
    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.
     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.
    21442160
    21452161old_function_declarator:
     
    21832199//              }
    21842200//
    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.
     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.
    21872203
    21882204typedef_redeclarator:
     
    21962212        TYPEDEFname
    21972213                {
    2198                         typedefTable.setNextIdentifier( *( $1 ) );
     2214                        typedefTable.setNextIdentifier( *($1) );
    21992215                        $$ = DeclarationNode::newName( $1 );
    22002216                }
     
    22322248        ;
    22332249
    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.
     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.
    22382254
    22392255identifier_parameter_declarator:
     
    22732289        ;
    22742290
    2275 // This pattern parses a declaration for a parameter variable or function prototype that is redefining a typedef name,
    2276 // e.g.:
     2291// This pattern parses a declaration for a parameter variable or function prototype that is redefining a
     2292// typedef name, e.g.:
    22772293//
    22782294//              typedef int foo;
    22792295//              int f( int foo ); // redefine typedef name in new scope
    22802296//
    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:
     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:
    22832299//
    22842300//              ISO/IEC 9899:1999 Section 6.7.5.3(11) : "In a parameter declaration, a single typedef name in
     
    22942310//              int g( int g1( T g2( int p ) ) );               // see identifier_parameter_declarator
    22952311//
    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.
     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.
    23002316
    23012317typedef_parameter_redeclarator:
     
    23092325        TYPEDEFname
    23102326                {
    2311                         typedefTable.setNextIdentifier( *$1 );
     2327                        typedefTable.setNextIdentifier( *($1) );
    23122328                        $$ = DeclarationNode::newName( $1 );
    23132329                }
     
    23372353        ;
    23382354
    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.:
     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.:
    23412357//
    23422358//              sizeof( int );
    23432359//              sizeof( int [10] );
    23442360//
    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.
     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.
    23472363
    23482364abstract_declarator:
     
    24102426//              int f( int (int) );             // abstract function-prototype parameter; no parameter name specified
    24112427//
    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.
     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.
    24142430
    24152431abstract_parameter_declarator:
     
    24612477// The declaration of an array parameter has additional syntax over arrays in normal variable declarations:
    24622478//
    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."
     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."
    24652482
    24662483array_parameter_1st_dimension:
     
    24812498        ;
    24822499
    2483 // This pattern parses a declaration of an abstract variable, i.e., there is no identifier to which the type applies,
    2484 // e.g.:
     2500// This pattern parses a declaration of an abstract variable, i.e., there is no identifier to which the type
     2501// applies, e.g.:
    24852502//
    24862503//              sizeof( int ); // abstract variable; no identifier name specified
    24872504//
    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.
     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.
    24902507
    24912508variable_abstract_declarator:
     
    25252542        ;
    25262543
    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.
     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.
    25292546
    25302547new_identifier_parameter_declarator_tuple:                              // CFA
     
    25562573
    25572574new_identifier_parameter_array:                                                 // CFA
    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.
     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.
    25602577        '[' push pop ']' type_specifier
    25612578                { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     
    25942611        ;
    25952612
    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.:
     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.:
    25982615//
    25992616//              [int] f( int );                         // abstract variable parameter; no parameter name specified
     
    26112628//
    26122629// Therefore, it is necessary to look at the token after identifier_or_typedef_name to know when to reduce
    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.
     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.
    26162633
    26172634new_abstract_declarator_tuple:                                                  // CFA
     
    26432660
    26442661new_abstract_array:                                                                             // CFA
    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.
     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.
    26472664        '[' push pop ']' type_specifier
    26482665                { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     
    26732690        ;
    26742691
    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."
     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."
    26802698//
    26812699// 3) ISO/IEC 9899:1999 Section 6.11.6(1) : "The use of function declarators with empty parentheses (not
    26822700//    prototype-format parameter type declarators) is an obsolescent feature."
    26832701//
    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.
     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.
    26862705
    26872706//************************* MISCELLANEOUS ********************************
     
    27112730
    27122731// Local Variables: //
     2732// tab-width: 4 //
    27132733// mode: c++ //
    2714 // tab-width: 4 //
    27152734// compile-command: "make install" //
    27162735// End: //
Note: See TracChangeset for help on using the changeset viewer.