Changes in / [4bf5298:b1a6d6b]


Ignore:
Files:
1 added
24 edited

Legend:

Unmodified
Added
Removed
  • LICENSE

    r4bf5298 rb1a6d6b  
    1 BSD Licence
     1This software Cforall is published under the BSD license as listed below.
    22
    3 Copyright (c) 2015 University of Waterloo.
     3Copyright (c) 2015 Huawei Technologies Co., Ltd and University of Waterloo.
    44All rights reserved.
    55
     
    88
    991. Redistributions of source code must retain the above copyright notice, this
    10 list of conditions and the following disclaimer.
     10   list of conditions and the following disclaimer.
    1111
    12122. Redistributions in binary form must reproduce the above copyright notice,
    13 this list of conditions and the following disclaimer in the documentation
    14 and/or other materials provided with the distribution.
     13   this list of conditions and the following disclaimer in the documentation
     14   and/or other materials provided with the distribution.
    1515
    16 3. Neither the name of the copyright holder nor the names of its contributors
    17 may be used to endorse or promote products derived from this software without
    18 specific prior written permission.
     163. Neither the name of Huawei Technologies Co., Ltd., nor University of
     17   Waterloo, nor the names of the contributors to Cfoall may be used to endorse
     18   or promote products derived from this software without specific prior
     19   written permission.
    1920
    2021THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    2122ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    2223WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    23 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
     24DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
    2425FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    2526DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  • driver/cc1.cc

    r4bf5298 rb1a6d6b  
    88// Created On       : Fri Aug 26 14:23:51 2005
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Thu May 14 13:24:45 2015
    11 // Update Count     : 43
     10// Last Modified On : Mon Apr 27 23:11:52 2015
     11// Update Count     : 39
    1212//
    1313
  • libcfa/prelude.cf

    r4bf5298 rb1a6d6b  
    88// Created On       : Sat Nov 29 07:23:41 2014
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Mon May  4 17:21:02 2015
    11 // Update Count     : 70
     10// Last Modified On : Wed Mar 18 11:36:59 2015
     11// Update Count     : 69
    1212//
    1313
  • translator/CodeGen/CodeGenerator2.cc

    r4bf5298 rb1a6d6b  
    631631          case Declaration::NoStorageClass:
    632632            break;
     633          case Declaration::Auto:
     634            break;
     635          case Declaration::Static:
     636            before << "static ";
     637            break;
    633638          case Declaration::Extern:
    634639            before << "extern ";
    635640            break;
    636           case Declaration::Static:
    637             before << "static ";
    638             break;
    639           case Declaration::Auto:
    640             // silently drop storage class
    641             break;
    642641          case Declaration::Register:
    643642            before << "register ";
    644643            break;
    645           case Declaration::Inline:
    646             before << "inline ";
    647             break;
    648644          case Declaration::Fortran:
    649645            before << "fortran ";
  • translator/ControlStruct/ForExprMutator.cc

    r4bf5298 rb1a6d6b  
    55namespace ControlStruct {
    66    Statement *ForExprMutator::mutate( ForStmt *forStmt ) {
    7         // recurse down all nest for loops to hoist any initializer declarations to make them C89 (rather than C99)
    87        forStmt->set_body( forStmt->get_body()->acceptMutator( *this ) );
    98        if ( DeclStmt *decl = dynamic_cast< DeclStmt * > ( forStmt->get_initialization() ) ) {
    10             // create compound statement, move initializer declaration outside, leave _for_ as-is
     9            // create compound statement, move declaration outside, leave _for_ as-is
    1110            CompoundStmt *block = new CompoundStmt( std::list< Label >() );
    1211            std::list<Statement *> &stmts = block->get_kids();
     
    1817            return block;
    1918        } // if
    20 
    21         return forStmt;
     19        // ForStmt still needs to be fixed
     20        else
     21            return forStmt;
    2222    }
    2323} // namespace ControlStruct
  • translator/Parser/DeclarationNode.cc

    r4bf5298 rb1a6d6b  
    5050const char *storageClassName[] = {
    5151    // order must correspond with DeclarationNode::StorageClass
    52     "extern",
    5352    "static",
    5453    "auto",
     54    "extern",
    5555    "register",
    5656    "inline",
     
    880880Declaration::StorageClass DeclarationNode::buildStorageClass() const {
    881881    static const Declaration::StorageClass scMap[] = { 
    882         Declaration::Extern,
    883882        Declaration::Static,
    884883        Declaration::Auto,
     884        Declaration::Extern,
    885885        Declaration::Register,
    886         Declaration::Inline,
     886        Declaration::NoStorageClass, // inline
    887887        Declaration::Fortran
    888888    }; 
  • translator/Parser/ParseNode.h

    r4bf5298 rb1a6d6b  
    262262class DeclarationNode : public ParseNode {
    263263  public:
    264     enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic, Attribute };
    265     enum StorageClass { Extern, Static, Auto, Register, Inline, Fortran };
     264    enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic };
     265    enum StorageClass { Static, Auto, Extern, Register, Inline, Fortran };
    266266    enum BasicType { Char, Int, Float, Double, Void, Bool, Complex, Imaginary };
    267267    enum Modifier { Signed, Unsigned, Short, Long };
  • translator/Parser/TypeData.cc

    r4bf5298 rb1a6d6b  
    544544          case DeclarationNode::Atomic:
    545545            q.isAtomic = true;
    546             break;
    547           case DeclarationNode::Attribute:
    548             q.isAttribute = true;
    549546            break;
    550547        }
  • translator/Parser/cfa.y

    r4bf5298 rb1a6d6b  
    1 //                              -*- Mode: C++ -*-
    2 //
    3 // CForall Grammar Version 1.0, Copyright (C) Peter A. Buhr 2001
    4 //
    5 // cfa.y --
    6 //
    7 // Author           : Peter A. Buhr
    8 // Created On       : Sat Sep  1 20:22:55 2001
    9 // Last Modified By : Peter A. Buhr
    10 // Last Modified On : Tue May 12 17:24:53 2015
    11 // Update Count     : 963
    12 //
    13 
    14 // This grammar is based on the ANSI99/11 C grammar, specifically parts of EXPRESSION and STATEMENTS, and on the C
    15 // grammar by James A. Roskind, specifically parts of DECLARATIONS and EXTERNAL DEFINITIONS.  While parts have been
    16 // copied, important changes have been made in all sections; these changes are sufficient to constitute a new grammar.
    17 // In particular, this grammar attempts to be more syntactically precise, i.e., it parses less incorrect language syntax
    18 // that must be subsequently rejected by semantic checks.  Nevertheless, there are still several semantic checks
    19 // required and many are noted in the grammar. Finally, the grammar is extended with GCC and CFA language extensions.
    20 
    21 // Acknowledgments to Richard Bilson, Glen Ditchfield, and Rodolfo Gabriel Esteves who all helped when I got stuck with
    22 // the grammar.
    23 
    24 // The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed, except for:
    25 //
    26 // 1. designation with '=' (use ':' instead)
    27 //
    28 // Most of the syntactic extensions from ANSI90 to ANSI11 C are marked with the comment "C99/C11". This grammar also has
    29 // two levels of extensions. The first extensions cover most of the GCC C extensions, except for:
    30 //
    31 // 1. nested functions
    32 // 2. generalized lvalues
    33 // 3. designation with and without '=' (use ':' instead)
    34 // 4. attributes not allowed in parenthesis of declarator
    35 //
    36 // All of the syntactic extensions for GCC C are marked with the comment "GCC". The second extensions are for Cforall
    37 // (CFA), which fixes several of C's outstanding problems and extends C with many modern language concepts. All of the
    38 // syntactic extensions for CFA C are marked with the comment "CFA". As noted above, there is one unreconcileable
    39 // parsing problem between C99 and CFA with respect to designators; this is discussed in detail before the "designation"
    40 // grammar rule.
     1/*                               -*- Mode: C -*-
     2 *
     3 * CForall Grammar Version 1.0, Copyright (C) Peter A. Buhr 2001 -- Permission is granted to copy this
     4 *      grammar and to use it within software systems.  THIS GRAMMAR IS PROVIDED "AS IS" AND WITHOUT
     5 *      ANY EXPRESS OR IMPLIED WARRANTIES.
     6 *
     7 * cfa.y --
     8 *
     9 * Author           : Peter A. Buhr
     10 * Created On       : Sat Sep  1 20:22:55 2001
     11 * Last Modified By : Peter A. Buhr
     12 * Last Modified On : Wed Apr 15 15:11:16 2015
     13 * Update Count     : 913
     14 */
     15
     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. */
     26
     27/* The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed, except for:
     28
     29   1. designation with '=' (use ':' instead)
     30
     31   Most of the syntactic extensions from ANSI90 to ANSI11 C are marked with the comment "C99/C11". This grammar
     32   also has two levels of extensions. The first extensions cover most of the GCC C extensions, except for:
     33
     34   1. nested functions
     35   2. generalized lvalues
     36   3. designation with and without '=' (use ':' instead)
     37   4. attributes not allowed in parenthesis of declarator
     38
     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. */
    4144
    4245%{
    43 #define YYDEBUG_LEXER_TEXT (yylval)                     // lexer loads this up each time
    44 #define YYDEBUG 1                                       // get the pretty debugging code to compile
     46#define YYDEBUG_LEXER_TEXT (yylval)                     /* lexer loads this up each time */
     47#define YYDEBUG 1                                       /* get the pretty debugging code to compile*/
    4548
    4649#undef __GNUC_MINOR__
     
    5356#include "LinkageSpec.h"
    5457
    55 DeclarationNode *theTree = 0;                           // the resulting parse tree
     58DeclarationNode *theTree = 0;                           /* the resulting parse tree */
    5659LinkageSpec::Type linkage = LinkageSpec::Cforall;
    5760std::stack< LinkageSpec::Type > linkageStack;
     
    5962%}
    6063
    61 //************************* TERMINAL TOKENS ********************************
    62 
    63 // keywords
     64/************************* TERMINAL TOKENS ********************************/
     65
     66/* keywords */
    6467%token TYPEDEF
    6568%token AUTO EXTERN REGISTER STATIC
    66 %token INLINE                                           // C99
    67 %token FORTRAN                                          // C99, extension ISO/IEC 9899:1999 Section J.5.9(1)
     69%token INLINE                                           /* C99 */
     70%token FORTRAN                                          /* C99, extension ISO/IEC 9899:1999 Section J.5.9(1) */
    6871%token CONST VOLATILE
    69 %token RESTRICT                                         // C99
    70 %token FORALL LVALUE                                    // CFA
     72%token RESTRICT                                         /* C99 */
     73%token FORALL LVALUE                                    /* CFA */
    7174%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    72 %token BOOL COMPLEX IMAGINARY                           // C99
    73 %token TYPEOF LABEL                                     // GCC
     75%token BOOL COMPLEX IMAGINARY                           /* C99 */
     76%token TYPEOF LABEL                                     /* GCC */
    7477%token ENUM STRUCT UNION
    75 %token TYPE FTYPE DTYPE CONTEXT                         // CFA
     78%token TYPE FTYPE DTYPE CONTEXT                         /* CFA */
    7679%token SIZEOF
    77 %token ATTRIBUTE EXTENSION                              // GCC
     80%token ATTRIBUTE EXTENSION                              /* GCC */
    7881%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    79 %token CHOOSE FALLTHRU TRY CATCH FINALLY THROW          // CFA
    80 %token ASM                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    81 %token ALIGNAS ALIGNOF ATOMIC GENERIC NORETURN STATICASSERT THREADLOCAL // C11
    82 
    83 // names and constants: lexer differentiates between identifier and typedef names
     82%token CHOOSE FALLTHRU TRY CATCH FINALLY THROW          /* CFA */
     83%token ASM                                              /* C99, extension ISO/IEC 9899:1999 Section J.5.10(1) */
     84%token ALIGNAS ALIGNOF ATOMIC GENERIC NORETURN STATICASSERT THREADLOCAL /* C11 */
     85
     86/* names and constants: lexer differentiates between identifier and typedef names */
    8487%token<tok> IDENTIFIER          QUOTED_IDENTIFIER       TYPEDEFname             TYPEGENname
    8588%token<tok> ATTR_IDENTIFIER     ATTR_TYPEDEFname        ATTR_TYPEGENname
    8689%token<tok> INTEGERconstant     FLOATINGconstant        CHARACTERconstant       STRINGliteral
    87 %token<tok> ZERO                ONE                     // CFA
    88 
    89 // multi-character operators
     90%token<tok> ZERO                ONE                     /* CFA */
     91
     92/* multi-character operators */
    9093%token ARROW                    /* ->                           */
    9194%token ICR DECR                 /* ++   --                      */
     
    100103%token ANDassign        ERassign        ORassign        /* &=   ^=      |=      */
    101104
    102 // Types declaration
     105/* Types declaration */
    103106%union
    104107{
    105     Token tok;
    106     ParseNode *pn;
    107     ExpressionNode *en;
    108     DeclarationNode *decl;
    109     DeclarationNode::TyCon aggKey;
    110     DeclarationNode::TypeClass tclass;
    111     StatementNode *sn;
    112     ConstantNode *constant;
    113     InitializerNode *in;
     108  Token tok;
     109  ParseNode *pn;
     110  ExpressionNode *en;
     111  DeclarationNode *decl;
     112  DeclarationNode::TyCon aggKey;
     113  DeclarationNode::TypeClass tclass;
     114  StatementNode *sn;
     115  ConstantNode *constant;
     116  InitializerNode *in;
    114117}
    115118
     
    118121%type<constant> string_literal_list
    119122
    120 // expressions
     123/* expressions */
    121124%type<constant> constant
    122125%type<en> tuple                         tuple_expression_list
     
    131134%type<en> subrange
    132135
    133 // statements
     136/* statements */
    134137%type<sn> labeled_statement     compound_statement      expression_statement    selection_statement
    135138%type<sn> iteration_statement   jump_statement          exception_statement     asm_statement
     
    143146%type<pn> handler_list          handler_clause          finally_clause
    144147
    145 // declarations
     148/* declarations */
    146149%type<decl> abstract_array abstract_declarator abstract_function abstract_parameter_array
    147150%type<decl> abstract_parameter_declaration abstract_parameter_declarator abstract_parameter_function
     
    225228%type<decl> variable_abstract_ptr variable_array variable_declarator variable_function variable_ptr
    226229
    227 // initializers
     230/* initializers */
    228231%type<in>  initializer initializer_list initializer_opt
    229232
    230 // designators
     233/* designators */
    231234%type<en>  designator designator_list designation
    232235
    233236
    234 // Handle single shift/reduce conflict for dangling else by shifting the ELSE token. For example, this string is
    235 // ambiguous:
    236 // .---------.                  matches IF '(' comma_expression ')' statement
    237 // if ( C ) S1 else S2
    238 // `-----------------'  matches IF '(' comma_expression ')' statement ELSE statement */
    239 
    240 %nonassoc THEN  // rule precedence for IF '(' comma_expression ')' statement
    241 %nonassoc ELSE  // token precedence for start of else clause in IF statement
    242 
    243 %start translation_unit                                 // parse-tree root
     237/* Handle single shift/reduce conflict for dangling else by shifting the ELSE token. For example, this string
     238   is ambiguous:
     239  .---------.                  matches IF '(' comma_expression ')' statement
     240  if ( C ) S1 else S2
     241  `-----------------'  matches IF '(' comma_expression ')' statement ELSE statement */
     242
     243%nonassoc THEN  /* rule precedence for IF '(' comma_expression ')' statement */
     244%nonassoc ELSE  /* token precedence for start of else clause in IF statement */
     245
     246%start translation_unit                                 /* parse-tree root */
    244247
    245248%%
    246 //************************* Namespace Management ********************************
    247 
    248 // The grammar in the ANSI C standard is not strictly context-free, since it relies upon the distinct terminal symbols
    249 // "identifier" and "TYPEDEFname" that are lexically identical.  While it is possible to write a purely context-free
    250 // grammar, such a grammar would obscure the relationship between syntactic and semantic constructs.  Hence, this
    251 // grammar uses the ANSI style.
    252 //
    253 // Cforall compounds this problem by introducing type names local to the scope of a declaration (for instance, those
    254 // introduced through "forall" qualifiers), and by introducing "type generators" -- parametrized types.  This latter
    255 // type name creates a third class of identifiers that must be distinguished by the scanner.
    256 //
    257 // Since the scanner cannot distinguish among the different classes of identifiers without some context information, it
    258 // accesses a data structure (the TypedefTable) to allow classification of an identifier that it has just read.
    259 // Semantic actions during the parser update this data structure when the class of identifiers change.
    260 //
    261 // Because the Cforall language is block-scoped, there is the possibility that an identifier can change its class in a
    262 // local scope; it must revert to its original class at the end of the block.  Since type names can be local to a
    263 // particular declaration, each declaration is itself a scope.  This requires distinguishing between type names that are
    264 // local to the current declaration scope and those that persist past the end of the declaration (i.e., names defined in
    265 // "typedef" or "type" declarations).
    266 //
    267 // The non-terminals "push" and "pop" derive the empty string; their only use is to denote the opening and closing of
    268 // scopes.  Every push must have a matching pop, although it is regrettable the matching pairs do not always occur
    269 // within the same rule.  These non-terminals may appear in more contexts than strictly necessary from a semantic point
    270 // of view.  Unfortunately, these extra rules are necessary to prevent parsing conflicts -- the parser may not have
    271 // enough context and look-ahead information to decide whether a new scope is necessary, so the effect of these extra
    272 // rules is to open a new scope unconditionally.  As the grammar evolves, it may be neccesary to add or move around
    273 // "push" and "pop" nonterminals to resolve conflicts of this sort.
     249/************************* Namespace Management ********************************/
     250
     251/* The grammar in the ANSI C standard is not strictly context-free, since it relies upon the distinct terminal
     252   symbols "identifier" and "TYPEDEFname" that are lexically identical.  While it is possible to write a
     253   purely context-free grammar, such a grammar would obscure the relationship between syntactic and semantic
     254   constructs.  Hence, this grammar uses the ANSI style.
     255
     256   Cforall compounds this problem by introducing type names local to the scope of a declaration (for instance,
     257   those introduced through "forall" qualifiers), and by introducing "type generators" -- parametrized types.
     258   This latter 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
     261   information, it accesses a data structure (the TypedefTable) to allow classification of an identifier that
     262   it has just read.  Semantic actions during the parser update this data structure when the class of
     263   identifiers change.
     264
     265   Because the Cforall language is block-scoped, there is the possibility that an identifier can change its
     266   class in a local scope; it must revert to its original class at the end of the block.  Since type names can
     267   be local to a particular declaration, each declaration is itself a scope.  This requires distinguishing
     268   between type names that are local to the current declaration scope and those that persist past the end of
     269   the declaration (i.e., names defined in "typedef" or "type" declarations).
     270
     271   The non-terminals "push" and "pop" derive the empty string; their only use is to denote the opening and
     272   closing of scopes.  Every push must have a matching pop, although it is regrettable the matching pairs do
     273   not always occur within the same rule.  These non-terminals may appear in more contexts than strictly
     274   necessary from a semantic point of view.  Unfortunately, these extra rules are necessary to prevent parsing
     275   conflicts -- the parser may not have enough context and look-ahead information to decide whether a new
     276   scope is necessary, so the effect of these extra rules is to open a new scope unconditionally.  As the
     277   grammar evolves, it may be neccesary to add or move around "push" and "pop" nonterminals to resolve
     278   conflicts of this sort.  */
    274279
    275280push:
     
    285290        ;
    286291
    287 //************************* CONSTANTS ********************************
     292/************************* CONSTANTS ********************************/
    288293
    289294constant:
    290                 // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration
    291                 // constant".
     295                /* ENUMERATIONconstant is not included here; it is treated as a variable with type
     296                   "enumeration constant". */
    292297        INTEGERconstant                                 { $$ = new ConstantNode(ConstantNode::Integer,   $1); }
    293298        | FLOATINGconstant                              { $$ = new ConstantNode(ConstantNode::Float,     $1); }
     
    297302identifier:
    298303        IDENTIFIER
    299         | ATTR_IDENTIFIER                               // CFA
    300         | zero_one                                      // CFA
     304        | ATTR_IDENTIFIER                               /* CFA */
     305        | zero_one                                      /* CFA */
    301306        ;
    302307
    303308no_01_identifier:
    304309        IDENTIFIER
    305         | ATTR_IDENTIFIER                               // CFA
     310        | ATTR_IDENTIFIER                               /* CFA */
    306311        ;
    307312
     
    310315        ;
    311316
    312 zero_one:                                               // CFA
     317zero_one:                                               /* CFA */
    313318        ZERO
    314319        | ONE
    315320        ;
    316321
    317 string_literal_list:                                    // juxtaposed strings are concatenated
     322string_literal_list:                                    /* juxtaposed strings are concatenated */
    318323        STRINGliteral                                   { $$ = new ConstantNode(ConstantNode::String, $1); }
    319324        | string_literal_list STRINGliteral             { $$ = $1->append( $2 ); }
    320325        ;
    321326
    322 //************************* EXPRESSIONS ********************************
     327/************************* EXPRESSIONS ********************************/
    323328
    324329primary_expression:
    325         IDENTIFIER                                      // typedef name cannot be used as a variable name
     330        IDENTIFIER                                      /* typedef name cannot be used as a variable name */
    326331                { $$ = new VarRefNode($1); }
    327332        | zero_one
     
    333338        | '(' comma_expression ')'
    334339                { $$ = $2; }
    335         | '(' compound_statement ')'                    // GCC, lambda expression
     340        | '(' compound_statement ')'                    /* GCC, lambda expression */
    336341                { $$ = new ValofExprNode($2); }
    337342        ;
     
    340345        primary_expression
    341346        | postfix_expression '[' push assignment_expression pop ']'
    342                 // CFA, comma_expression disallowed in the context because it results in a commom user error:
    343                 // subscripting a matrix with x[i,j] instead of x[i][j]. While this change is not backwards
    344                 // compatible, there seems to be little advantage to this feature and many disadvantages. It is
    345                 // possible to write x[(i,j)] in CFA, which is equivalent to the old x[i,j].
     347                 /* CFA, comma_expression disallowed in the context because it results in a commom user error:
     348                    subscripting a matrix with x[i,j] instead of x[i][j]. While this change is not backwards
     349                    compatible, there seems to be little advantage to this feature and many disadvantages. It
     350                    is possible to write x[(i,j)] in CFA, which is equivalent to the old x[i,j]. */
    346351                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Index), $1, $4); }
    347352        | postfix_expression '(' argument_expression_list ')'
     
    349354        | postfix_expression '.' no_attr_identifier
    350355                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::FieldSel), $1, new VarRefNode($3)); }
    351         | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
     356        | postfix_expression '.' '[' push field_list pop ']' /* CFA, tuple field selector */
    352357        | postfix_expression ARROW no_attr_identifier
    353358                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PFieldSel), $1, new VarRefNode($3)); }
    354         | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
     359        | postfix_expression ARROW '[' push field_list pop ']' /* CFA, tuple field selector */
    355360        | postfix_expression ICR
    356361                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::IncrPost), $1); }
    357362        | postfix_expression DECR
    358363                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::DecrPost), $1); }
    359                 // GCC has priority: cast_expression
    360         | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99
     364                /* GCC has priority: cast_expression */
     365        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' /* C99 */
    361366                { $$ = 0; }
    362367        ;
     
    369374
    370375argument_expression:
    371         // empty
    372                 { $$ = 0; }                             // use default argument
     376        /* empty */                                     /* use default argument */
     377                { $$ = 0; }
    373378        | assignment_expression
    374379        | no_attr_identifier ':' assignment_expression
    375380                                                        { $$ = $3->set_asArgName($1); }
    376                 // Only a list of no_attr_identifier_or_typedef_name is allowed in this context. However, there is
    377                 // insufficient look ahead to distinguish between this list of parameter names and a tuple, so the
    378                 // tuple form must be used with an appropriate semantic check.
     381                /* Only a list of no_attr_identifier_or_typedef_name is allowed in this context. However, there
     382                   is insufficient look ahead to distinguish between this list of parameter names and a tuple,
     383                   so the tuple form must be used with an appropriate semantic check. */
    379384        | '[' push assignment_expression pop ']' ':' assignment_expression
    380                                                         { $$ = $7->set_asArgName($3); }
     385                                                { $$ = $7->set_asArgName($3); }
    381386        | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression
    382                                                         { $$ = $9->set_asArgName(new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
    383         ;
    384 
    385 field_list:                                             // CFA, tuple field selector
     387                                                { $$ = $9->set_asArgName(new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
     388        ;
     389
     390field_list:                                             /* CFA, tuple field selector */
    386391        field
    387392        | field_list ',' field                          { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    388393        ;
    389394
    390 field:                                                  // CFA, tuple field selector
     395field:                                                  /* CFA, tuple field selector */
    391396        no_attr_identifier
    392397                                                        { $$ = new VarRefNode( $1 ); }
     
    407412        | DECR unary_expression
    408413                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Decr), $2); }
    409         | EXTENSION cast_expression                     // GCC
     414        | EXTENSION cast_expression                     /* GCC */
    410415                { $$ = $2; }
    411416        | unary_operator cast_expression
     
    413418        | '!' cast_expression
    414419                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Neg), $2); }
    415         | '*' cast_expression                           // CFA
     420        | '*' cast_expression                           /* CFA */
    416421                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::PointTo), $2); }
    417                 // '*' is is separated from unary_operator because of shift/reduce conflict in:
    418                 //      { * X; } // dereference X
    419                 //      { * int X; } // CFA declaration of pointer to int
    420                 // '&' must be moved here if C++ reference variables are supported.
     422                /* '*' is is separated from unary_operator because of shift/reduce conflict in:
     423                        { * X; } // dereference X
     424                        { * int X; } // CFA declaration of pointer to int
     425                   '&' must be moved here if C++ reference variables are supported. */
    421426        | SIZEOF unary_expression
    422427                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::SizeOf), $2); }
     
    429434        | ATTR_IDENTIFIER '(' argument_expression ')'
    430435                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Attr), new VarRefNode($1), $3); }
    431         | ALIGNOF unary_expression                      // GCC, variable alignment
     436        | ALIGNOF unary_expression                      /* GCC, variable alignment */
    432437                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::AlignOf), $2); }
    433         | ALIGNOF '(' type_name_no_function ')'         // GCC, type alignment
     438        | ALIGNOF '(' type_name_no_function ')'         /* GCC, type alignment */
    434439                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::AlignOf), new TypeValueNode($3)); }
    435         | ANDAND no_attr_identifier                     // GCC, address of label
     440        | ANDAND no_attr_identifier                     /* GCC, address of label */
    436441                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::LabelAddress), new VarRefNode($2, true)); }
    437442        ;
     
    533538                                                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Cond),
    534539                                                                       (ExpressionNode *)mkList((*$1,*$3,*$5))); }
    535         | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
     540        | logical_OR_expression '?' /* empty */ ':' conditional_expression /* GCC, omitted first operand */
    536541                                                { $$=new CompositeExprNode(new OperatorNode(OperatorNode::NCond),$1,$4); }
    537         | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
     542        | logical_OR_expression '?' comma_expression ':' tuple /* CFA, tuple expression */
    538543                                                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Cond),
    539544                                                                       (ExpressionNode *)mkList(( *$1, *$3, *$5 ))); }
     
    545550
    546551assignment_expression:
    547                 // CFA, assignment is separated from assignment_operator to ensure no assignment operations for tuples
     552                /* CFA, assignment is separated from assignment_operator to ensure no assignment operations
     553                   for tuples */
    548554        conditional_expression
    549555        | unary_expression '=' assignment_expression
     
    551557        | unary_expression assignment_operator assignment_expression
    552558                                                        { $$ =new CompositeExprNode($2, $1, $3); }
    553         | tuple assignment_opt                          // CFA, tuple expression
     559        | tuple assignment_opt                          /* CFA, tuple expression */
    554560                {
    555561                  if ( $2 == 0 ) {
     
    562568
    563569assignment_expression_opt:
    564         // empty
     570        /* empty */
    565571                { $$ = new NullExprNode; }
    566572        | assignment_expression
    567573        ;
    568574
    569 tuple:                                                  // CFA, tuple
    570                 // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce
    571                 // conflict with comma_expression in new_identifier_parameter_array and new_abstract_array
     575tuple:                                                  /* CFA, tuple */
     576                /* CFA, one assignment_expression is factored out of comma_expression to eliminate a
     577                   shift/reduce conflict with comma_expression in new_identifier_parameter_array and
     578                   new_abstract_array */
    572579        '[' push pop ']'
    573580                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ) ); }
     
    601608comma_expression:
    602609        assignment_expression
    603         | comma_expression ',' assignment_expression    // { $$ = (ExpressionNode *)$1->add_to_list($3); }
     610        | comma_expression ',' assignment_expression    /* { $$ = (ExpressionNode *)$1->add_to_list($3); } */
    604611                               { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Comma),$1,$3); }
    605612        ;
    606613
    607614comma_expression_opt:
    608         // empty
    609                 { $$ = 0; }
     615        /* empty */                                     { $$ = 0; }
    610616        | comma_expression
    611617        ;
    612618
    613 //*************************** STATEMENTS *******************************
     619/*************************** STATEMENTS *******************************/
    614620
    615621statement:
     
    633639                { $$ = new CompoundStmtNode( (StatementNode *)0 ); }
    634640        | '{'
    635                 // Two scopes are necessary because the block itself has a scope, but every declaration within the block
    636                 // also requires its own scope
     641                /* Two scopes are necessary because the block itself has a scope, but every declaration within
     642                   the block also requires its own scope */
    637643          push push
    638           label_declaration_opt                         // GCC, local labels
    639           block_item_list pop '}'                       // C99, intermix declarations and statements
     644          label_declaration_opt                         /* GCC, local labels */
     645          block_item_list pop '}'                       /* C99, intermix declarations and statements */
    640646                { $$ = new CompoundStmtNode( $5 ); }
    641647        ;
    642648
    643 block_item_list:                                        // C99
     649block_item_list:                                        /* C99 */
    644650        block_item
    645651        | block_item_list push block_item
     
    648654
    649655block_item:
    650         declaration                                     // CFA, new & old style declarations
     656        declaration                                     /* CFA, new & old style declarations */
    651657                { $$ = new StatementNode( $1 ); }
    652         | EXTENSION declaration                         // GCC
     658        | EXTENSION declaration                         /* GCC */
    653659                { $$ = new StatementNode( $2 ); }
    654660        | statement pop
     
    668674selection_statement:
    669675        IF '(' comma_expression ')' statement           %prec THEN
    670                 // explicitly deal with the shift/reduce conflict on if/else
     676                /* explicitly deal with the shift/reduce conflict on if/else */
    671677                { $$ = new StatementNode(StatementNode::If, $3, $5); }
    672678        | IF '(' comma_expression ')' statement ELSE statement
    673679                { $$ = new StatementNode(StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7)) ); }
    674         | SWITCH '(' comma_expression ')' case_clause   // CFA
     680        | SWITCH '(' comma_expression ')' case_clause   /* CFA */
    675681                { $$ = new StatementNode(StatementNode::Switch, $3, $5); }
    676         | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
     682        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' /* CFA */
    677683                { $$ = 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.
    682         | CHOOSE '(' comma_expression ')' case_clause   // CFA
     684                /* The semantics of the declaration list is changed to include any associated initialization,
     685                   which is performed *before* the transfer to the appropriate case clause.  Statements after
     686                   the initial declaration list can never be executed, and therefore, are removed from the
     687                   grammar even though C allows it. */
     688        | CHOOSE '(' comma_expression ')' case_clause   /* CFA */
    683689                { $$ = new StatementNode(StatementNode::Choose, $3, $5); }
    684         | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
     690        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' /* CFA */
    685691                { $$ = new StatementNode(StatementNode::Choose, $3, $8); }
    686692        ;
    687693
    688 // CASE and DEFAULT clauses are only allowed in the SWITCH statement, precluding Duff's device. In addition, a case
    689 // clause allows a list of values and subranges.
    690 
    691 case_value:                                             // CFA
     694/* CASE and DEFAULT clauses are only allowed in the SWITCH statement, precluding Duff's device. In addition, a
     695   case clause allows a list of values and subranges. */
     696
     697case_value:                                             /* CFA */
    692698        constant_expression                     { $$ = $1; }
    693         | constant_expression ELLIPSIS constant_expression // GCC, subrange
     699        | constant_expression ELLIPSIS constant_expression /* GCC, subrange */
    694700                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Range),$1,$3); }
    695         | subrange                                      // CFA, subrange
    696         ;
    697 
    698 case_value_list:                                        // CFA
     701        | subrange                                      /* CFA, subrange */
     702        ;
     703
     704case_value_list:                                        /* CFA */
    699705        case_value
    700706        | case_value_list ',' case_value
     
    702708        ;
    703709
    704 case_label:                                             // CFA
     710case_label:                                             /* CFA */
    705711        CASE case_value_list ':'                {  $$ = new StatementNode(StatementNode::Case, $2, 0); }
    706712        | DEFAULT ':'                           {  $$ = new StatementNode(StatementNode::Default);     }
    707                 // A semantic check is required to ensure only one default clause per switch/choose statement.
    708         ;
    709 
    710 case_label_list:                                        // CFA
     713                /* A semantic check is required to ensure only one default clause per switch/choose
     714                   statement. */
     715        ;
     716
     717case_label_list:                                        /* CFA */
    711718        case_label
    712719        | case_label_list case_label            { $$ = (StatementNode *)($1->set_link($2)); }
    713720        ;
    714721
    715 case_clause:                                            // CFA
     722case_clause:                                            /* CFA */
    716723        case_label_list statement               {  $$ = $1->append_last_case($2); }
    717724        ;
    718725
    719 switch_clause_list_opt:                                 // CFA
    720         // empty
    721                 { $$ = 0; }
     726switch_clause_list_opt:                                 /* CFA */
     727        /* empty */                             { $$ = 0; }
    722728        | switch_clause_list
    723729        ;
    724730
    725 switch_clause_list:                                     // CFA
     731switch_clause_list:                                     /* CFA */
    726732        case_label_list statement_list
    727733                                                { $$ = $1->append_last_case($2); }
     
    730736        ;
    731737
    732 choose_clause_list_opt:                                 // CFA
    733         // empty
    734                 { $$ = 0; }
     738choose_clause_list_opt:                                 /* CFA */
     739        /* empty */                             { $$ = 0; }
    735740        | choose_clause_list
    736741        ;
    737742
    738 choose_clause_list:                                     // CFA
     743choose_clause_list:                                     /* CFA */
    739744        case_label_list fall_through
    740                 { $$ = $1->append_last_case($2); }
     745                  { $$ = $1->append_last_case($2); }
    741746        | case_label_list statement_list fall_through_opt
    742                 { $$ = $1->append_last_case((StatementNode *)mkList((*$2,*$3))); }
     747                  { $$ = $1->append_last_case((StatementNode *)mkList((*$2,*$3))); }
    743748        | choose_clause_list case_label_list fall_through
    744                 { $$ = (StatementNode *)($1->set_link($2->append_last_case($3))); }
     749                  { $$ = (StatementNode *)($1->set_link($2->append_last_case($3))); }
    745750        | choose_clause_list case_label_list statement_list fall_through_opt
    746                 { $$ = (StatementNode *)($1->set_link($2->append_last_case((StatementNode *)mkList((*$3,*$4))))); }
    747         ;
    748 
    749 fall_through_opt:                                       // CFA
    750         // empty
    751                 { $$ = 0; }
     751                  { $$ = (StatementNode *)($1->set_link($2->append_last_case((StatementNode *)mkList((*$3,*$4))))); }
     752        ;
     753
     754fall_through_opt:                                       /* CFA */
     755        /* empty */                             { $$ = 0; }
    752756        | fall_through
    753757        ;
    754758
    755 fall_through:                                           // CFA
     759fall_through:                                           /* CFA */
    756760        FALLTHRU                                { $$ = new StatementNode(StatementNode::Fallthru, 0, 0); }
    757761        | FALLTHRU ';'                          { $$ = new StatementNode(StatementNode::Fallthru, 0, 0); }
     
    770774        comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt
    771775                                                { $$ = new ForCtlExprNode($1, $4, $6); }
    772         | declaration comma_expression_opt ';' comma_expression_opt // C99
    773                 // Like C++, the loop index can be declared local to the loop.
     776        | declaration comma_expression_opt ';' comma_expression_opt /* C99 */
     777                /* Like C++, the loop index can be declared local to the loop. */
    774778                                                { $$ = new ForCtlExprNode($1, $2, $4); }
    775779        ;
     
    778782        GOTO no_attr_identifier ';'
    779783                                                { $$ = new StatementNode(StatementNode::Goto, $2); }
    780         | GOTO '*' comma_expression ';'         // GCC, computed goto
    781                 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; =>
    782                 // goto *(i+3); whereas normal operator precedence yields goto (*i)+3;
     784        | GOTO '*' comma_expression ';'         /* GCC, computed goto */
     785                /* The syntax for the GCC computed goto violates normal expression precedence, e.g.,
     786                   goto *i+3; => goto *(i+3); whereas normal operator precedence yields goto (*i)+3; */
    783787                                                { $$ = new StatementNode(StatementNode::Goto, $3); }
    784788        | CONTINUE ';'
    785                 // A semantic check is required to ensure this statement appears only in the body of an iteration
    786                 // statement.
     789                /* A semantic check is required to ensure this statement appears only in the body of an
     790                   iteration statement. */
    787791                                                { $$ = new StatementNode(StatementNode::Continue, 0, 0); }
    788         | CONTINUE no_attr_identifier ';'       // CFA, multi-level continue
    789                 // A semantic check is required to ensure this statement appears only in the body of an iteration
    790                 // statement, and the target of the transfer appears only at the start of an iteration statement.
     792        | CONTINUE no_attr_identifier ';'       /* CFA, multi-level continue */
     793                /* A semantic check is required to ensure this statement appears only in the body of an
     794                   iteration statement, and the target of the transfer appears only at the start of an
     795                   iteration statement. */
    791796                                                { $$ = new StatementNode(StatementNode::Continue, $2); }
    792797        | BREAK ';'
    793                 // A semantic check is required to ensure this statement appears only in the body of an iteration
    794                 // statement.
     798                /* A semantic check is required to ensure this statement appears only in the body of an
     799                   iteration statement. */
    795800                                                { $$ = new StatementNode(StatementNode::Break, 0, 0); }
    796         | BREAK no_attr_identifier ';'          // CFA, multi-level exit
    797                 // A semantic check is required to ensure this statement appears only in the body of an iteration
    798                 // statement, and the target of the transfer appears only at the start of an iteration statement.
     801        | BREAK no_attr_identifier ';'  /* CFA, multi-level exit */
     802                /* A semantic check is required to ensure this statement appears only in the body of an
     803                   iteration statement, and the target of the transfer appears only at the start of an
     804                   iteration statement. */
    799805                                                { $$ = new StatementNode(StatementNode::Break, $2 ); }
    800806        | RETURN comma_expression_opt ';'
     
    819825
    820826handler_list:
    821                 // There must be at least one catch clause
     827                /* There must be at least one catch clause */
    822828        handler_clause
    823                 // ISO/IEC 9899:1999 Section 15.3(6) If present, a "..." handler shall be the last handler for its try
    824                 // block.
     829                /* ISO/IEC 9899:1999 Section 15.3(6) If present, a "..." handler shall be the last handler for
     830                   its try block. */
    825831        | CATCH '(' ELLIPSIS ')' compound_statement
    826832                                                { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
     
    844850
    845851exception_declaration:
    846                 // A semantic check is required to ensure type_specifier does not create a new type, e.g.:
    847                 //
    848                 //      catch ( struct { int i; } x ) ...
    849                 //
    850                 // This new type cannot catch any thrown type because of name equivalence among types.
     852                /* A semantic check is required to ensure type_specifier does not create a new type, e.g.:
     853
     854                        catch ( struct { int i; } x ) ...
     855
     856                   This new type cannot catch any thrown type because of name equivalence among types. */
    851857        type_specifier
    852858        | type_specifier declarator
     
    857863        | type_specifier variable_abstract_declarator
    858864                {   $$ = $2->addType( $1 ); }
    859         | new_abstract_declarator_tuple no_attr_identifier // CFA
     865        | new_abstract_declarator_tuple no_attr_identifier /* CFA */
    860866                {
    861867                    typedefTable.addToEnclosingScope( TypedefTable::ID );
    862868                    $$ = $1->addName( $2 );
    863869                }
    864         | new_abstract_declarator_tuple                 // CFA
     870        | new_abstract_declarator_tuple                 /* CFA */
    865871        ;
    866872
     
    868874        ASM type_qualifier_list_opt '(' constant_expression ')' ';'
    869875                                                { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
    870         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ')' ';' // remaining GCC
     876        | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ')' ';' /* remaining GCC */
    871877                                                { $$ = new StatementNode(StatementNode::Asm, 0, 0); }
    872878        | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ')' ';'
     
    877883        ;
    878884
    879 asm_operands_opt:                                       // GCC
    880         // empty
     885asm_operands_opt:                                       /* GCC */
     886        /* empty */
    881887        | asm_operands_list
    882888        ;
    883889
    884 asm_operands_list:                                      // GCC
     890asm_operands_list:                                      /* GCC */
    885891        asm_operand
    886892        | asm_operands_list ',' asm_operand
    887893        ;
    888894
    889 asm_operand:                                            // GCC
     895asm_operand:                                            /* GCC */
    890896        STRINGliteral '(' constant_expression ')'       {}
    891897        ;
    892898
    893 asm_clobbers_list:                                      // GCC
     899asm_clobbers_list:                                      /* GCC */
    894900        STRINGliteral                           {}
    895901        | asm_clobbers_list ',' STRINGliteral
    896902        ;
    897903
    898 //******************************* DECLARATIONS *********************************
    899 
    900 declaration_list_opt:                                   // used at beginning of switch statement
     904/******************************* DECLARATIONS *********************************/
     905
     906declaration_list_opt:                                   /* used at beginning of switch statement */
    901907        pop
    902908                { $$ = 0; }
     
    910916        ;
    911917
    912 old_declaration_list_opt:                               // used to declare parameter types in K&R style functions
     918old_declaration_list_opt:                               /* used to declare parameter types in K&R style functions */
    913919        pop
    914920                { $$ = 0; }
     
    922928        ;
    923929
    924 label_declaration_opt:                                  // GCC, local label
    925         // empty
     930label_declaration_opt:                                  /* GCC, local label */
     931        /* empty */
    926932        | label_declaration_list
    927933        ;
    928934
    929 label_declaration_list:                                 // GCC, local label
     935label_declaration_list:                                 /* GCC, local label */
    930936        LABEL label_list ';'
    931937        | label_declaration_list LABEL label_list ';'
    932938        ;
    933939
    934 label_list:                                             // GCC, local label
     940label_list:                                             /* GCC, local label */
    935941        no_attr_identifier_or_typedef_name              {}
    936942        | label_list ',' no_attr_identifier_or_typedef_name {}
    937943        ;
    938944
    939 declaration:                                            // CFA, new & old style declarations
     945declaration:                                            /* CFA, new & old style declarations */
    940946        new_declaration
    941947        | old_declaration
    942948        ;
    943949
    944 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
    945 // declarations. CFA declarations use the same declaration tokens as in C; however, CFA places declaration modifiers to
    946 // the left of the base type, while C declarations place modifiers to the right of the base type. CFA declaration
    947 // modifiers are interpreted from left to right and the entire type specification is distributed across all variables in
    948 // the declaration list (as in Pascal).  ANSI C and the new CFA declarations may appear together in the same program
    949 // block, but cannot be mixed within a specific declaration.
    950 //
    951 //          CFA             C
    952 //      [10] int x;     int x[10];      // array of 10 integers
    953 //      [10] * char y;  char *y[10];    // array of 10 pointers to char
    954 
    955 new_declaration:                                        // CFA
     950/* C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and
     951   function declarations. CFA declarations use the same declaration tokens as in C; however, CFA places
     952   declaration modifiers to the left of the base type, while C declarations place modifiers to the right of
     953   the base type. CFA declaration modifiers are interpreted from left to right and the entire type
     954   specification is distributed across all variables in the declaration list (as in Pascal).  ANSI C and the
     955   new CFA declarations may appear together in the same program block, but cannot be mixed within a specific
     956   declaration.
     957
     958            CFA             C
     959        [10] int x;     int x[10];      // array of 10 integers
     960        [10] * char y;  char *y[10];    // array of 10 pointers to char
     961   */
     962
     963new_declaration:                                        /* CFA */
    956964        new_variable_declaration pop ';'
    957965        | new_typedef_declaration pop ';'
     
    961969        ;
    962970
    963 new_variable_declaration:                               // CFA
     971new_variable_declaration:                               /* CFA */
    964972        new_variable_specifier initializer_opt
    965973                {
    966                         typedefTable.addToEnclosingScope( TypedefTable::ID );
     974                        typedefTable.addToEnclosingScope( TypedefTable::ID);
    967975                        $$ = $1;
    968976                }
    969977        | declaration_qualifier_list new_variable_specifier initializer_opt
    970                 // declaration_qualifier_list also includes type_qualifier_list, so a semantic check is necessary to
    971                 // preclude them as a type_qualifier cannot appear in that context.
    972                 {
    973                         typedefTable.addToEnclosingScope( TypedefTable::ID );
     978                /* declaration_qualifier_list also includes type_qualifier_list, so a semantic check is
     979                   necessary to preclude them as a type_qualifier cannot appear in that context. */
     980                {
     981                        typedefTable.addToEnclosingScope( TypedefTable::ID);
    974982                        $$ = $2->addQualifiers( $1 );
    975983                }
    976984        | new_variable_declaration pop ',' push identifier_or_typedef_name initializer_opt
    977985                {
    978                         typedefTable.addToEnclosingScope( *$5, TypedefTable::ID );
     986                        typedefTable.addToEnclosingScope( *$5, TypedefTable::ID);
    979987                        $$ = $1->appendList( $1->cloneType( $5 ) );
    980988                }
    981989        ;
    982990
    983 new_variable_specifier:                                 // CFA
    984                 // A semantic check is required to ensure asm_name only appears on declarations with implicit or
    985                 // explicit static storage-class
     991new_variable_specifier:                                 /* CFA */
     992                /* A semantic check is required to ensure asm_name only appears on declarations with implicit
     993                   or explicit static storage-class */
    986994        new_abstract_declarator_no_tuple identifier_or_typedef_name asm_name_opt
    987995                {
     
    10011009        ;
    10021010
    1003 new_function_declaration:                               // CFA
     1011new_function_declaration:                               /* CFA */
    10041012        new_function_specifier
    10051013                {
    1006                         typedefTable.addToEnclosingScope( TypedefTable::ID );
     1014                        typedefTable.addToEnclosingScope( TypedefTable::ID);
    10071015                        $$ = $1;
    10081016                }
    10091017        | declaration_qualifier_list new_function_specifier
    1010                 // declaration_qualifier_list also includes type_qualifier_list, so a semantic check is necessary to
    1011                 // preclude them as a type_qualifier cannot appear in this context.
    1012                 {
    1013                         typedefTable.addToEnclosingScope( TypedefTable::ID );
     1018                /* declaration_qualifier_list also includes type_qualifier_list, so a semantic check is
     1019                   necessary to preclude them as a type_qualifier cannot appear in this context. */
     1020                {
     1021                        typedefTable.addToEnclosingScope( TypedefTable::ID);
    10141022                        $$ = $2->addQualifiers( $1 );
    10151023                }
    10161024        | new_function_declaration pop ',' push identifier_or_typedef_name
    10171025                {
    1018                         typedefTable.addToEnclosingScope( *$5, TypedefTable::ID );
     1026                        typedefTable.addToEnclosingScope( *$5, TypedefTable::ID);
    10191027                        $$ = $1->appendList( $1->cloneType( $5 ) );
    10201028                }
    10211029        ;
    10221030
    1023 new_function_specifier:                                 // CFA
     1031new_function_specifier:                                 /* CFA */
    10241032        '[' push pop ']' identifier '(' push new_parameter_type_list_opt pop ')'
    10251033                {
     
    10521060        ;
    10531061
    1054 new_function_return:                                    // CFA
     1062new_function_return:                                    /* CFA */
    10551063        '[' push new_parameter_list pop ']'
    10561064                { $$ = DeclarationNode::newTuple( $3 ); }
     
    10611069        ;
    10621070
    1063 new_typedef_declaration:                                // CFA
     1071new_typedef_declaration:                                /* CFA */
    10641072        TYPEDEF new_variable_specifier
    10651073                {
     
    10941102                        $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() );
    10951103                }
    1096         | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2)
     1104        | type_qualifier_list TYPEDEF type_specifier declarator /* remaining OBSOLESCENT (see 2) */
    10971105                {
    10981106                        typedefTable.addToEnclosingScope( TypedefTable::TD);
     
    11111119        ;
    11121120
    1113 typedef_expression:                                     // GCC, naming expression type
     1121typedef_expression:                                     /* GCC, naming expression type */
    11141122        TYPEDEF no_attr_identifier '=' assignment_expression
    11151123                {
     
    11271135        declaring_list pop ';'
    11281136        | typedef_declaration pop ';'
    1129         | typedef_expression pop ';'                    // GCC, naming expression type
     1137        | typedef_expression pop ';'                    /* GCC, naming expression type */
    11301138        | sue_declaration_specifier pop ';'
    11311139        ;
     
    11411149        | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt
    11421150                {
    1143                         typedefTable.addToEnclosingScope( TypedefTable::ID );
     1151                        typedefTable.addToEnclosingScope( TypedefTable::ID);
    11441152                        $$ = $1->appendList( $1->cloneBaseType( $4->addInitializer($6) ) );
    11451153                }
    11461154        ;
    11471155
    1148 declaration_specifier:                                  // type specifier + storage class
     1156declaration_specifier:                                  /* type specifier + storage class */
    11491157        basic_declaration_specifier
    11501158        | sue_declaration_specifier
     
    11531161        ;
    11541162
    1155 type_specifier:                                         // declaration specifier - storage class
     1163type_specifier:                                         /* declaration specifier - storage class */
    11561164        basic_type_specifier
    11571165        | sue_type_specifier
     
    11601168        ;
    11611169
    1162 type_qualifier_list_opt:                                // GCC, used in asm_statement
    1163         // empty
     1170type_qualifier_list_opt:                                /* GCC, used in asm_statement */
     1171        /* empty */
    11641172                { $$ = 0; }
    11651173        | type_qualifier_list
     
    11811189        type_qualifier_name
    11821190        | attribute
    1183                 { $$ = DeclarationNode::newQualifier( DeclarationNode::Attribute ); }
     1191                { $$ = DeclarationNode::newQualifier( DeclarationNode::Const ); }
    11841192        ;
    11851193
     
    11911199        | VOLATILE
    11921200                { $$ = DeclarationNode::newQualifier( DeclarationNode::Volatile ); }
    1193         | LVALUE                                        // CFA
     1201        | LVALUE                                        /* CFA */
    11941202                { $$ = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); }
    11951203        | ATOMIC
    11961204                { $$ = DeclarationNode::newQualifier( DeclarationNode::Atomic ); }
    1197         | FORALL '('
     1205        | FORALL '(' 
    11981206                {
    11991207                        typedefTable.enterScope();
    12001208                }
    1201           type_parameter_list ')'                       // CFA
     1209          type_parameter_list ')'                       /* CFA */
    12021210                {
    12031211                        typedefTable.leaveScope();
     
    12081216declaration_qualifier_list:
    12091217        storage_class_list
    1210         | type_qualifier_list storage_class_list        // remaining OBSOLESCENT (see 2)
     1218        | type_qualifier_list storage_class_list        /* remaining OBSOLESCENT (see 2) */
    12111219                { $$ = $1->addQualifiers( $2 ); }
    12121220        | declaration_qualifier_list type_qualifier_list storage_class_list
     
    12311239
    12321240storage_class_name:
    1233         EXTERN
     1241        AUTO
     1242                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Auto ); }
     1243        | EXTERN
    12341244                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }
     1245        | REGISTER
     1246                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); }
    12351247        | STATIC
    12361248                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Static ); }
    1237         | AUTO
    1238                 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Auto ); }
    1239         | REGISTER
    1240                 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); }
    1241         | INLINE                                        // C99
    1242                 // INLINE is essentially a storage class specifier for functions, and hence, belongs here.
     1249        | INLINE                                        /* C99 */
     1250                /* INLINE is essentially a storage class specifier for functions, and hence, belongs here. */
    12431251                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Inline ); }
    1244         | FORTRAN                                       // C99
     1252        | FORTRAN                                       /* C99 */
    12451253                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); }
    12461254        ;
     
    12651273        | VOID
    12661274                { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
    1267         | BOOL                                          // C99
     1275        | BOOL                                          /* C99 */
    12681276                { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); }
    1269         | COMPLEX                                       // C99
     1277        | COMPLEX                                       /* C99 */
    12701278                { $$ = DeclarationNode::newBasicType( DeclarationNode::Complex ); }
    1271         | IMAGINARY                                     // C99
     1279        | IMAGINARY                                     /* C99 */
    12721280                { $$ = DeclarationNode::newBasicType( DeclarationNode::Imaginary ); }
    12731281        ;
    12741282
    12751283basic_declaration_specifier:
    1276                 // A semantic check is necessary for conflicting storage classes.
     1284                /* A semantic check is necessary for conflicting storage classes. */
    12771285        basic_type_specifier
    12781286        | declaration_qualifier_list basic_type_specifier
    12791287                { $$ = $2->addQualifiers( $1 ); }
    1280         | basic_declaration_specifier storage_class     // remaining OBSOLESCENT (see 2)
     1288        | basic_declaration_specifier storage_class     /* remaining OBSOLESCENT (see 2) */
    12811289                { $$ = $1->addQualifiers( $2 ); }
    12821290        | basic_declaration_specifier storage_class type_qualifier_list
     
    12931301
    12941302direct_type_name:
    1295                 // A semantic check is necessary for conflicting type qualifiers.
     1303                /* A semantic check is necessary for conflicting type qualifiers. */
    12961304        basic_type_name
    12971305        | type_qualifier_list basic_type_name
     
    13041312
    13051313indirect_type_name:
    1306         TYPEOF '(' type_name ')'                        // GCC: typeof(x) y;
     1314        TYPEOF '(' type_name ')'                        /* GCC: typeof(x) y; */
    13071315                { $$ = $3; }
    1308         | TYPEOF '(' comma_expression ')'               // GCC: typeof(a+b) y;
     1316        | TYPEOF '(' comma_expression ')'               /* GCC: typeof(a+b) y; */
    13091317                { $$ = DeclarationNode::newTypeof( $3 ); }
    1310         | ATTR_TYPEGENname '(' type_name ')'            // CFA: e.g., @type(x) y;
     1318        | ATTR_TYPEGENname '(' type_name ')'            /* CFA: e.g., @type(x) y; */
    13111319                { $$ = DeclarationNode::newAttr( $1, $3 ); }
    1312         | ATTR_TYPEGENname '(' comma_expression ')'     // CFA: e.g., @type(a+b) y;
     1320        | ATTR_TYPEGENname '(' comma_expression ')'     /* CFA: e.g., @type(a+b) y; */
    13131321                { $$ = DeclarationNode::newAttr( $1, $3 ); }
    13141322        ;
     
    13181326        | declaration_qualifier_list sue_type_specifier
    13191327                { $$ = $2->addQualifiers( $1 ); }
    1320         | sue_declaration_specifier storage_class       // remaining OBSOLESCENT (see 2)
     1328        | sue_declaration_specifier storage_class       /* remaining OBSOLESCENT (see 2) */
    13211329                { $$ = $1->addQualifiers( $2 ); }
    13221330        | sue_declaration_specifier storage_class type_qualifier_list
     
    13251333
    13261334sue_type_specifier:
    1327         elaborated_type_name                            // struct, union, enum
     1335        elaborated_type_name                            /* struct, union, enum */
    13281336        | type_qualifier_list elaborated_type_name
    13291337                { $$ = $2->addQualifiers( $1 ); }
     
    13361344        | declaration_qualifier_list typedef_type_specifier
    13371345                { $$ = $2->addQualifiers( $1 ); }
    1338         | typedef_declaration_specifier storage_class   // remaining OBSOLESCENT (see 2)
     1346        | typedef_declaration_specifier storage_class   /* remaining OBSOLESCENT (see 2) */
    13391347                { $$ = $1->addQualifiers( $2 ); }
    13401348        | typedef_declaration_specifier storage_class type_qualifier_list
     
    13421350        ;
    13431351
    1344 typedef_type_specifier:                                 // typedef types
     1352typedef_type_specifier:                                 /* typedef types */
    13451353        TYPEDEFname
    13461354                { $$ = DeclarationNode::newFromTypedef( $1 ); }
     
    13631371        | aggregate_key no_attr_identifier_or_typedef_name '{' field_declaration_list '}'
    13641372                { $$ = DeclarationNode::newAggregate( $1, $2, 0, 0, $4 ); }
    1365         | aggregate_key '(' push type_parameter_list pop ')' '{' field_declaration_list '}' // CFA
     1373        | aggregate_key '(' push type_parameter_list pop ')' '{' field_declaration_list '}' /* CFA */
    13661374                { $$ = DeclarationNode::newAggregate( $1, 0, $4, 0, $8 ); }
    1367         | aggregate_key '(' push type_parameter_list pop ')' no_attr_identifier_or_typedef_name // CFA
     1375        | aggregate_key '(' push type_parameter_list pop ')' no_attr_identifier_or_typedef_name /* CFA */
    13681376                { $$ = DeclarationNode::newAggregate( $1, $7, $4, 0, 0 ); }
    1369         | aggregate_key '(' push type_parameter_list pop ')' no_attr_identifier_or_typedef_name '{' field_declaration_list '}' // CFA
     1377        | aggregate_key '(' push type_parameter_list pop ')' no_attr_identifier_or_typedef_name '{' field_declaration_list '}' /* CFA */
    13701378                { $$ = DeclarationNode::newAggregate( $1, $7, $4, 0, $9 ); }
    1371         | aggregate_key '(' push type_parameter_list pop ')' '(' type_name_list ')' '{' field_declaration_list '}' // CFA
     1379        | aggregate_key '(' push type_parameter_list pop ')' '(' type_name_list ')' '{' field_declaration_list '}' /* CFA */
    13721380                { $$ = DeclarationNode::newAggregate( $1, 0, $4, $8, $11 ); }
    1373         | aggregate_key '(' push type_name_list pop ')' no_attr_identifier_or_typedef_name // CFA
    1374                 // push and pop are only to prevent S/R conflicts
     1381        | aggregate_key '(' push type_name_list pop ')' no_attr_identifier_or_typedef_name /* CFA */
     1382                /* push and pop are only to prevent S/R conflicts */
    13751383                { $$ = DeclarationNode::newAggregate( $1, $7, 0, $4, 0 ); }
    1376         | aggregate_key '(' push type_parameter_list pop ')' '(' type_name_list ')' no_attr_identifier_or_typedef_name '{' field_declaration_list '}' // CFA
     1384        | aggregate_key '(' push type_parameter_list pop ')' '(' type_name_list ')' no_attr_identifier_or_typedef_name '{' field_declaration_list '}' /* CFA */
    13771385                { $$ = DeclarationNode::newAggregate( $1, $10, $4, $8, $12 ); }
    13781386        ;
     
    13931401
    13941402field_declaration:
    1395         new_field_declaring_list ';'                    // CFA, new style field declaration
    1396         | EXTENSION new_field_declaring_list ';'        // GCC
     1403        new_field_declaring_list ';'                    /* CFA, new style field declaration */
     1404        | EXTENSION new_field_declaring_list ';'        /* GCC */
    13971405                { $$ = $2; }
    13981406        | field_declaring_list ';'
    1399         | EXTENSION field_declaring_list ';'            // GCC
    1400                 { $$ = $2; }
    1401         ;
    1402 
    1403 new_field_declaring_list:                               // CFA, new style field declaration
    1404         new_abstract_declarator_tuple                   // CFA, no field name
     1407        | EXTENSION field_declaring_list ';'            /* GCC */
     1408                { $$ = $2; }
     1409        ;
     1410
     1411new_field_declaring_list:                               /* CFA, new style field declaration */
     1412        new_abstract_declarator_tuple                   /* CFA, no field name */
    14051413        | new_abstract_declarator_tuple no_attr_identifier_or_typedef_name
    14061414                { $$ = $1->addName( $2 ); }
    14071415        | new_field_declaring_list ',' no_attr_identifier_or_typedef_name
    14081416                { $$ = $1->appendList( $1->cloneType( $3 ) ); }
    1409         | new_field_declaring_list ','                  // CFA, no field name
     1417        | new_field_declaring_list ','                  /* CFA, no field name */
    14101418                { $$ = $1->appendList( $1->cloneType( 0 ) ); }
    14111419        ;
     
    14191427
    14201428field_declarator:
    1421         // empty
    1422                 { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name
    1423         | bit_subrange_size                             // no field name
     1429        /* empty */                                     /* CFA, no field name */
     1430                { $$ = DeclarationNode::newName( 0 ); /* XXX */ }
     1431        | bit_subrange_size                             /* no field name */
    14241432                { $$ = DeclarationNode::newBitfield( $1 ); }
    14251433        | variable_declarator bit_subrange_size_opt
    1426                 // A semantic check is required to ensure bit_subrange only appears on base type int.
     1434                /* A semantic check is required to ensure bit_subrange only appears on base type int. */
    14271435                { $$ = $1->addBitfield( $2 ); }
    14281436        | typedef_redeclarator bit_subrange_size_opt
    1429                 // A semantic check is required to ensure bit_subrange only appears on base type int.
     1437                /* A semantic check is required to ensure bit_subrange only appears on base type int. */
    14301438                { $$ = $1->addBitfield( $2 ); }
    1431         | variable_abstract_declarator                  // CFA, no field name
     1439        | variable_abstract_declarator                  /* CFA, no field name */
    14321440        ;
    14331441
    14341442bit_subrange_size_opt:
    1435         // empty
     1443        /* empty */
    14361444                { $$ = 0; }
    14371445        | bit_subrange_size
     
    14651473
    14661474enumerator_value_opt:
    1467         // empty
     1475        /* empty */
    14681476                { $$ = 0; }
    14691477        | '=' constant_expression
     
    14711479        ;
    14721480
    1473 // Minimum of one parameter after which ellipsis is allowed only at the end.
    1474 
    1475 new_parameter_type_list_opt:                            // CFA
    1476         // empty
     1481/* Minimum of one parameter after which ellipsis is allowed only at the end. */
     1482
     1483new_parameter_type_list_opt:                            /* CFA */
     1484        /* empty */
    14771485                { $$ = 0; }
    14781486        | new_parameter_type_list
    14791487        ;
    14801488
    1481 new_parameter_type_list:                                // CFA, abstract + real
     1489new_parameter_type_list:                                /* CFA, abstract + real */
    14821490        new_abstract_parameter_list
    14831491        | new_parameter_list
     
    14901498        ;
    14911499
    1492 new_parameter_list:                                     // CFA
    1493                 // To obtain LR(1) between new_parameter_list and new_abstract_tuple, the last
    1494                 // new_abstract_parameter_list is factored out from new_parameter_list, flattening the rules
    1495                 // to get lookahead to the ']'.
     1500new_parameter_list:                                     /* CFA */
     1501                /* To obtain LR(1) between new_parameter_list and new_abstract_tuple, the last
     1502                  new_abstract_parameter_list is factored out from new_parameter_list, flattening the rules
     1503                   to get lookahead to the ']'. */
    14961504        new_parameter_declaration
    14971505        | new_abstract_parameter_list pop ',' push new_parameter_declaration
     
    15031511        ;
    15041512
    1505 new_abstract_parameter_list:                            // CFA, new & old style abstract
     1513new_abstract_parameter_list:                            /* CFA, new & old style abstract */
    15061514        new_abstract_parameter_declaration
    15071515        | new_abstract_parameter_list pop ',' push new_abstract_parameter_declaration
     
    15101518
    15111519parameter_type_list_opt:
    1512         // empty
     1520        /* empty */
    15131521                { $$ = 0; }
    15141522        | parameter_type_list
     
    15211529        ;
    15221530
    1523 parameter_list:                                         // abstract + real
     1531parameter_list:                                         /* abstract + real */
    15241532        abstract_parameter_declaration
    15251533        | parameter_declaration
     
    15301538        ;
    15311539
    1532 // Provides optional identifier names (abstract_declarator/variable_declarator), no initialization, different
    1533 // semantics for typedef name by using typedef_parameter_redeclarator instead of typedef_redeclarator, and
    1534 // function prototypes.
    1535 
    1536 new_parameter_declaration:                              // CFA, new & old style parameter declaration
     1540/* Provides optional identifier names (abstract_declarator/variable_declarator), no initialization, different
     1541  semantics for typedef name by using typedef_parameter_redeclarator instead of typedef_redeclarator, and
     1542   function prototypes. */
     1543
     1544new_parameter_declaration:                              /* CFA, new & old style parameter declaration */
    15371545        parameter_declaration
    15381546        | new_identifier_parameter_declarator_no_tuple identifier_or_typedef_name assignment_opt
    15391547                { $$ = $1->addName( $2 ); }
    15401548        | new_abstract_tuple identifier_or_typedef_name assignment_opt
    1541                 // To obtain LR(1), these rules must be duplicated here (see new_abstract_declarator).
     1549                /* To obtain LR(1), these rules must be duplicated here (see new_abstract_declarator). */
    15421550                { $$ = $1->addName( $2 ); }
    15431551        | type_qualifier_list new_abstract_tuple identifier_or_typedef_name assignment_opt
     
    15461554        ;
    15471555
    1548 new_abstract_parameter_declaration:                     // CFA, new & old style parameter declaration
     1556new_abstract_parameter_declaration:                     /* CFA, new & old style parameter declaration */
    15491557        abstract_parameter_declaration
    15501558        | new_identifier_parameter_declarator_no_tuple
    15511559        | new_abstract_tuple
    1552                 // To obtain LR(1), these rules must be duplicated here (see new_abstract_declarator).
     1560                /* To obtain LR(1), these rules must be duplicated here (see new_abstract_declarator). */
    15531561        | type_qualifier_list new_abstract_tuple
    15541562                { $$ = $2->addQualifiers( $1 ); }
     
    15591567        declaration_specifier identifier_parameter_declarator assignment_opt
    15601568                {
    1561                     typedefTable.addToEnclosingScope( TypedefTable::ID );
     1569                    typedefTable.addToEnclosingScope( TypedefTable::ID);
    15621570                    $$ = $2->addType( $1 )->addInitializer( new InitializerNode($3) );
    15631571                }
    15641572        | declaration_specifier typedef_parameter_redeclarator assignment_opt
    15651573                {
    1566                     typedefTable.addToEnclosingScope( TypedefTable::ID );
     1574                    typedefTable.addToEnclosingScope( TypedefTable::ID);
    15671575                    $$ = $2->addType( $1 )->addInitializer( new InitializerNode($3) );
    15681576                }
     
    15751583        ;
    15761584
    1577 // ISO/IEC 9899:1999 Section 6.9.1(6) : "An identifier declared as a typedef name shall not be redeclared as a
    1578 // parameter." Because the scope of the K&R-style parameter-list sees the typedef first, the following is
    1579 // based only on identifiers.  The ANSI-style parameter-list can redefine a typedef name.
    1580 
    1581 identifier_list:                                        // K&R-style parameter list => no types
     1585/* ISO/IEC 9899:1999 Section 6.9.1(6) : "An identifier declared as a typedef name shall not be redeclared as a
     1586  parameter." Because the scope of the K&R-style parameter-list sees the typedef first, the following is
     1587   based only on identifiers.  The ANSI-style parameter-list can redefine a typedef name. */
     1588
     1589identifier_list:                                        /* K&R-style parameter list => no types */
    15821590        no_attr_identifier
    15831591                { $$ = DeclarationNode::newName( $1 ); }
     
    16041612        ;
    16051613
    1606 type_name_no_function:                                  // sizeof, alignof, cast (constructor)
    1607         new_abstract_declarator_tuple                   // CFA
     1614type_name_no_function:                                  /* sizeof, alignof, cast (constructor) */
     1615        new_abstract_declarator_tuple                   /* CFA */
    16081616        | type_specifier
    16091617        | type_specifier variable_abstract_declarator
     
    16111619        ;
    16121620
    1613 type_name:                                              // typeof, assertion
    1614         new_abstract_declarator_tuple                   // CFA
    1615         | new_abstract_function                         // CFA
     1621type_name:                                              /* typeof, assertion */
     1622        new_abstract_declarator_tuple                   /* CFA */
     1623        | new_abstract_function                         /* CFA */
    16161624        | type_specifier
    16171625        | type_specifier abstract_declarator
     
    16371645        ;
    16381646
    1639 // There is an unreconcileable parsing problem between C99 and CFA with respect to designators. The problem
    1640 // is use of '=' to separator the designator from the initializer value, as in:
    1641 //
    1642 //      int x[10] = { [1] = 3 };
    1643 //
    1644 // The string "[1] = 3" can be parsed as a designator assignment or a tuple assignment.  To disambiguate this
    1645 // case, CFA changes the syntax from "=" to ":" as the separator between the designator and initializer. GCC
    1646 // does uses ":" for field selection. The optional use of the "=" in GCC, or in this case ":", cannot be
    1647 // supported either due to shift/reduce conflicts
     1647/* There is an unreconcileable parsing problem between C99 and CFA with respect to designators. The problem
     1648  is use of '=' to separator the designator from the initializer value, as in:
     1649
     1650        int x[10] = { [1] = 3 };
     1651
     1652  The string "[1] = 3" can be parsed as a designator assignment or a tuple assignment.  To disambiguate this
     1653  case, CFA changes the syntax from "=" to ":" as the separator between the designator and initializer. GCC
     1654  does uses ":" for field selection. The optional use of the "=" in GCC, or in this case ":", cannot be
     1655   supported either due to shift/reduce conflicts */
    16481656
    16491657designation:
    1650         designator_list ':'                             // C99, CFA uses ":" instead of "="
    1651         | no_attr_identifier_or_typedef_name ':'        // GCC, field name
     1658        designator_list ':'                             /* C99, CFA uses ":" instead of "=" */
     1659        | no_attr_identifier_or_typedef_name ':'        /* GCC, field name */
    16521660                                                        { $$ = new VarRefNode( $1 ); }
    16531661        ;
    16541662
    1655 designator_list:                                        // C99
     1663designator_list:                                        /* C99 */
    16561664        designator
    16571665        | designator_list designator                    { $$ = (ExpressionNode *)($1->set_link( $2 )); }
     
    16591667
    16601668designator:
    1661         '.' no_attr_identifier_or_typedef_name          // C99, field name
     1669        '.' no_attr_identifier_or_typedef_name          /* C99, field name */
    16621670                                                        { $$ = new VarRefNode( $2 ); }
    1663         | '[' push assignment_expression pop ']'        // C99, single array element
     1671        | '[' push assignment_expression pop ']'        /* C99, single array element */
    16641672                /* assignment_expression used instead of constant_expression because of shift/reduce conflicts
    16651673                   with tuple. */
    16661674                                                        { $$ = $3; }
    1667         | '[' push subrange pop ']'                     // CFA, multiple array elements
     1675        | '[' push subrange pop ']'                     /* CFA, multiple array elements */
    16681676                                                        { $$ = $3; }
    1669         | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
     1677        | '[' push constant_expression ELLIPSIS constant_expression pop ']' /* GCC, multiple array elements */
    16701678                                                        { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Range), $3, $5); }
    1671         | '.' '[' push field_list pop ']'               // CFA, tuple field selector
     1679        | '.' '[' push field_list pop ']'               /* CFA, tuple field selector */
    16721680                                                        { $$ = $4; }
    16731681        ;
    16741682
    1675 // The CFA type system is based on parametric polymorphism, the ability to declare functions with type
    1676 // parameters, rather than an object-oriented type system. This required four groups of extensions:
    1677 //
    1678 // Overloading: function, data, and operator identifiers may be overloaded.
    1679 //
    1680 // Type declarations: "type" is used to generate new types for declaring objects. Similarly, "dtype" is used
    1681 //     for object and incomplete types, and "ftype" is used for function types. Type declarations with
    1682 //     initializers provide definitions of new types. Type declarations with storage class "extern" provide
    1683 //     opaque types.
    1684 //
    1685 // Polymorphic functions: A forall clause declares a type parameter. The corresponding argument is inferred at
    1686 //     the call site. A polymorphic function is not a template; it is a function, with an address and a type.
    1687 //
    1688 // Specifications and Assertions: Specifications are collections of declarations parameterized by one or more
    1689 //     types. They serve many of the purposes of abstract classes, and specification hierarchies resemble
    1690 //     subclass hierarchies. Unlike classes, they can define relationships between types.  Assertions declare
    1691 //     that a type or types provide the operations declared by a specification.  Assertions are normally used
    1692 //     to declare requirements on type arguments of polymorphic functions.
    1693 
    1694 typegen_declaration_specifier:                          // CFA
     1683/* The CFA type system is based on parametric polymorphism, the ability to declare functions with type
     1684  parameters, rather than an object-oriented type system. This required four groups of extensions:
     1685
     1686  Overloading: function, data, and operator identifiers may be overloaded.
     1687
     1688  Type declarations: "type" is used to generate new types for declaring objects. Similarly, "dtype" is used
     1689       for object and incomplete types, and "ftype" is used for function types. Type declarations with
     1690       initializers provide definitions of new types. Type declarations with storage class "extern" provide
     1691       opaque types.
     1692
     1693  Polymorphic functions: A forall clause declares a type parameter. The corresponding argument is inferred at
     1694       the call site. A polymorphic function is not a template; it is a function, with an address and a type.
     1695
     1696  Specifications and Assertions: Specifications are collections of declarations parameterized by one or more
     1697       types. They serve many of the purposes of abstract classes, and specification hierarchies resemble
     1698       subclass hierarchies. Unlike classes, they can define relationships between types.  Assertions declare
     1699       that a type or types provide the operations declared by a specification.  Assertions are normally used
     1700       to declare requirements on type arguments of polymorphic functions.  */
     1701
     1702typegen_declaration_specifier:                          /* CFA */
    16951703        typegen_type_specifier
    16961704        | declaration_qualifier_list typegen_type_specifier
    16971705                { $$ = $2->addQualifiers( $1 ); }
    1698         | typegen_declaration_specifier storage_class   // remaining OBSOLESCENT (see 2)
     1706        | typegen_declaration_specifier storage_class   /* remaining OBSOLESCENT (see 2) */
    16991707                { $$ = $1->addQualifiers( $2 ); }
    17001708        | typegen_declaration_specifier storage_class type_qualifier_list
     
    17021710        ;
    17031711
    1704 typegen_type_specifier:                                 // CFA
     1712typegen_type_specifier:                                 /* CFA */
    17051713        TYPEGENname '(' type_name_list ')'
    17061714                { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }
     
    17111719        ;
    17121720
    1713 type_parameter_list:                                    // CFA
     1721type_parameter_list:                                    /* CFA */
    17141722        type_parameter assignment_opt
    17151723        | type_parameter_list ',' type_parameter assignment_opt
     
    17171725        ;
    17181726
    1719 type_parameter:                                         // CFA
     1727type_parameter:                                         /* CFA */
    17201728        type_class no_attr_identifier_or_typedef_name
    17211729                { typedefTable.addToEnclosingScope(*($2), TypedefTable::TD); }
     
    17251733        ;
    17261734
    1727 type_class:                                             // CFA
     1735type_class:                                             /* CFA */
    17281736        TYPE
    17291737                { $$ = DeclarationNode::Type; }
     
    17341742        ;
    17351743
    1736 assertion_list_opt:                                     // CFA
    1737         // empty
     1744assertion_list_opt:                                     /* CFA */
     1745        /* empty */
    17381746                { $$ = 0; }
    17391747        | assertion_list_opt assertion
     
    17411749        ;
    17421750
    1743 assertion:                                              // CFA
     1751assertion:                                              /* CFA */
    17441752        '|' no_attr_identifier_or_typedef_name '(' type_name_list ')'
    17451753                {
     
    17531761        ;
    17541762
    1755 type_name_list:                                         // CFA
     1763type_name_list:                                         /* CFA */
    17561764        type_name
    17571765                { $$ = new TypeValueNode( $1 ); }
     
    17631771        ;
    17641772
    1765 type_declaring_list:                                    // CFA
     1773type_declaring_list:                                    /* CFA */
    17661774        TYPE type_declarator
    17671775                { $$ = $2; }
     
    17721780        ;
    17731781
    1774 type_declarator:                                        // CFA
     1782type_declarator:                                        /* CFA */
    17751783        type_declarator_name assertion_list_opt
    17761784                { $$ = $1->addAssertions( $2 ); }
     
    17791787        ;
    17801788
    1781 type_declarator_name:                                   // CFA
     1789type_declarator_name:                                   /* CFA */
    17821790        no_attr_identifier_or_typedef_name
    17831791                {
     
    17921800        ;
    17931801
    1794 context_specifier:                                      // CFA
     1802context_specifier:                                      /* CFA */
    17951803        CONTEXT no_attr_identifier_or_typedef_name '(' push type_parameter_list pop ')' '{' '}'
    17961804                {
    1797                     typedefTable.addToEnclosingScope(*($2), TypedefTable::ID );
     1805                    typedefTable.addToEnclosingScope(*($2), TypedefTable::ID);
    17981806                    $$ = DeclarationNode::newContext( $2, $5, 0 );
    17991807                }
     
    18061814                {
    18071815                    typedefTable.leaveContext();
    1808                     typedefTable.addToEnclosingScope(*($2), TypedefTable::ID );
     1816                    typedefTable.addToEnclosingScope(*($2), TypedefTable::ID);
    18091817                    $$ = DeclarationNode::newContext( $2, $5, $10 );
    18101818                }
    18111819        ;
    18121820
    1813 context_declaration_list:                               // CFA
     1821context_declaration_list:                               /* CFA */
    18141822        context_declaration
    18151823        | context_declaration_list push context_declaration
     
    18171825        ;
    18181826
    1819 context_declaration:                                    // CFA
     1827context_declaration:                                    /* CFA */
    18201828        new_context_declaring_list pop ';'
    18211829        | context_declaring_list pop ';'
    18221830        ;
    18231831
    1824 new_context_declaring_list:                             // CFA
     1832new_context_declaring_list:                             /* CFA */
    18251833        new_variable_specifier
    18261834                {
     
    18401848        ;
    18411849
    1842 context_declaring_list:                                 // CFA
     1850context_declaring_list:                                 /* CFA */
    18431851        type_specifier declarator
    18441852                {
    1845                     typedefTable.addToEnclosingScope2( TypedefTable::ID );
     1853                    typedefTable.addToEnclosingScope2( TypedefTable::ID);
    18461854                    $$ = $2->addType( $1 );
    18471855                }
    18481856        | context_declaring_list pop ',' push declarator
    18491857                {
    1850                     typedefTable.addToEnclosingScope2( TypedefTable::ID );
     1858                    typedefTable.addToEnclosingScope2( TypedefTable::ID);
    18511859                    $$ = $1->appendList( $1->cloneBaseType( $5 ) );
    18521860                }
    18531861        ;
    18541862
    1855 //***************************** EXTERNAL DEFINITIONS *****************************
     1863/***************************** EXTERNAL DEFINITIONS *****************************/
    18561864
    18571865translation_unit:
    1858         // empty
    1859                 {}                                      // empty input file
     1866        /* empty */                                     /* empty input file */
     1867                {}
    18601868        | external_definition_list
    18611869                {
     
    18721880        | external_definition_list push external_definition
    18731881                {
    1874                     if ( $1 ) {
    1875                         $$ = $1->appendList( $3 );
    1876                     } else {
    1877                         $$ = $3;
    1878                     }
     1882                  if ( $1 ) {
     1883                    $$ = $1->appendList( $3 );
     1884                  } else {
     1885                    $$ = $3;
     1886                  }
    18791887                }
    18801888        ;
    18811889
    18821890external_definition_list_opt:
    1883         // empty
    1884                 { $$ = 0; }
     1891        /* empty */
     1892                {
     1893                  $$ = 0;
     1894                }
    18851895        | external_definition_list
    18861896        ;
     
    18891899        declaration
    18901900        | function_definition
    1891         | asm_statement                                 // GCC, global assembler statement
     1901        | asm_statement                                 /* GCC, global assembler statement */
    18921902                {}
    18931903        | EXTERN STRINGliteral
     
    18961906                  linkage = LinkageSpec::fromString( *$2 );
    18971907                }
    1898           '{' external_definition_list_opt '}'          // C++-style linkage specifier
     1908          '{' external_definition_list_opt '}'          /* C++-style linkage specifier */
    18991909                {
    19001910                  linkage = linkageStack.top();
     
    19071917
    19081918function_definition:
    1909         new_function_specifier compound_statement       // CFA
     1919        new_function_specifier compound_statement       /* CFA */
    19101920                {
    19111921                    typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    19131923                    $$ = $1->addFunctionBody( $2 );
    19141924                }
    1915         | declaration_qualifier_list new_function_specifier compound_statement // CFA
    1916                 // declaration_qualifier_list also includes type_qualifier_list, so a semantic check is
    1917                 // necessary to preclude them as a type_qualifier cannot appear in this context.
     1925        | declaration_qualifier_list new_function_specifier compound_statement /* CFA */
     1926                /* declaration_qualifier_list also includes type_qualifier_list, so a semantic check is
     1927                   necessary to preclude them as a type_qualifier cannot appear in this context. */
    19181928                {
    19191929                    typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    19291939                }
    19301940
    1931                 // These rules are a concession to the "implicit int" type_specifier because there is a
    1932                 // significant amount of code with functions missing a type-specifier on the return type.
    1933                 // Parsing is possible because function_definition does not appear in the context of an
    1934                 // expression (nested functions would preclude this concession). A function prototype
    1935                 // declaration must still have a type_specifier. OBSOLESCENT (see 1)
     1941                /* These rules are a concession to the "implicit int" type_specifier because there is a
     1942                  significant amount of code with functions missing a type-specifier on the return type.
     1943                  Parsing is possible because function_definition does not appear in the context of an
     1944                  expression (nested functions would preclude this concession). A function prototype
     1945                   declaration must still have a type_specifier. OBSOLESCENT (see 1) */
    19361946        | function_declarator compound_statement
    19371947                {
     
    19591969                }
    19601970
    1961                 // Old-style K&R function definition, OBSOLESCENT (see 4)
     1971                /* Old-style K&R function definition, OBSOLESCENT (see 4) */
    19621972        | declaration_specifier old_function_declarator push old_declaration_list_opt compound_statement
    19631973                {
     
    19791989                }
    19801990
    1981                 // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4)
     1991                /* Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4) */
    19821992        | declaration_qualifier_list old_function_declarator push old_declaration_list_opt compound_statement
    19831993                {
     
    20022012
    20032013subrange:
    2004         constant_expression '~' constant_expression     // CFA, integer subrange
     2014        constant_expression '~' constant_expression     /* CFA, integer subrange */
    20052015                { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::Range), $1, $3); }
    20062016        ;
    20072017
    2008 asm_name_opt:                                           // GCC
    2009         // empty
     2018asm_name_opt:                                           /* GCC */
     2019        /* empty */
    20102020        | ASM '(' string_literal_list ')' attribute_list_opt
    20112021        ;
    20122022
    2013 attribute_list_opt:                                     // GCC
    2014         // empty
     2023attribute_list_opt:                                     /* GCC */
     2024        /* empty */
    20152025        | attribute_list
    20162026        ;
    20172027
    2018 attribute_list:                                         // GCC
     2028attribute_list:                                         /* GCC */
    20192029        attribute
    20202030        | attribute_list attribute
    20212031        ;
    20222032
    2023 attribute:                                              // GCC
     2033attribute:                                              /* GCC */
    20242034        ATTRIBUTE '(' '(' attribute_parameter_list ')' ')'
    20252035        ;
    20262036
    2027 attribute_parameter_list:                               // GCC
     2037attribute_parameter_list:                               /* GCC */
    20282038        attrib
    20292039        | attribute_parameter_list ',' attrib
    20302040        ;
    20312041
    2032 attrib:                                                 // GCC
    2033         // empty
     2042attrib:                                                 /* GCC */
     2043        /* empty */
    20342044        | any_word
    20352045        | any_word '(' comma_expression_opt ')'
    20362046        ;
    20372047
    2038 any_word:                                               // GCC
     2048any_word:                                               /* GCC */
    20392049        identifier_or_typedef_name {}
    20402050        | storage_class_name {}
     
    20432053        ;
    20442054
    2045 // ============================================================================
    2046 // The following sections are a series of grammar patterns used to parse declarators. Multiple patterns are
    2047 // necessary because the type of an identifier in wrapped around the identifier in the same form as its usage
    2048 // in an expression, as in:
    2049 //
    2050 //      int (*f())[10] { ... };
    2051 //      ... (*f())[3] += 1;     // definition mimics usage
    2052 //
    2053 // Because these patterns are highly recursive, changes at a lower level in the recursion require copying some
    2054 // or all of the pattern. Each of these patterns has some subtle variation to ensure correct syntax in a
    2055 // particular context.
    2056 // ============================================================================
    2057 
    2058 // ----------------------------------------------------------------------------
    2059 // The set of valid declarators before a compound statement for defining a function is less than the set of
    2060 // declarators to define a variable or function prototype, e.g.:
    2061 //
    2062 //      valid declaration       invalid definition
    2063 //      -----------------       ------------------
    2064 //      int f;                  int f {}
    2065 //      int *f;                 int *f {}
    2066 //      int f[10];              int f[10] {}
    2067 //      int (*f)(int);          int (*f)(int) {}
    2068 //
    2069 // To preclude this syntactic anomaly requires separating the grammar rules for variable and function
    2070 // declarators, hence variable_declarator and function_declarator.
    2071 // ----------------------------------------------------------------------------
    2072 
    2073 // This pattern parses a declaration of a variable that is not redefining a typedef name. The pattern
    2074 // precludes declaring an array of functions versus a pointer to an array of functions.
     2055/* ============================================================================
     2056  The following sections are a series of grammar patterns used to parse declarators. Multiple patterns are
     2057  necessary because the type of an identifier in wrapped around the identifier in the same form as its usage
     2058  in an expression, as in:
     2059
     2060        int (*f())[10] { ... };
     2061        ... (*f())[3] += 1;     // definition mimics usage
     2062
     2063  Because these patterns are highly recursive, changes at a lower level in the recursion require copying some
     2064  or all of the pattern. Each of these patterns has some subtle variation to ensure correct syntax in a
     2065  particular context.
     2066   ============================================================================ */
     2067
     2068/* ----------------------------------------------------------------------------
     2069  The set of valid declarators before a compound statement for defining a function is less than the set of
     2070  declarators to define a variable or function prototype, e.g.:
     2071
     2072        valid declaration       invalid definition
     2073        -----------------       ------------------
     2074        int f;                  int f {}
     2075        int *f;                 int *f {}
     2076        int f[10];              int f[10] {}
     2077        int (*f)(int);          int (*f)(int) {}
     2078
     2079  To preclude this syntactic anomaly requires separating the grammar rules for variable and function
     2080  declarators, hence variable_declarator and function_declarator.
     2081   ---------------------------------------------------------------------------- */
     2082
     2083/* This pattern parses a declaration of a variable that is not redefining a typedef name. The pattern
     2084   precludes declaring an array of functions versus a pointer to an array of functions. */
    20752085
    20762086variable_declarator:
     
    20872097                    $$ = DeclarationNode::newName( $1 );
    20882098                }
    2089         | '(' paren_identifier ')'                      // redundant parenthesis
     2099        | '(' paren_identifier ')'                      /* redundant parenthesis */
    20902100                { $$ = $2; }
    20912101        ;
     
    21052115        | '(' variable_ptr ')' array_dimension
    21062116                { $$ = $2->addArray( $4 ); }
    2107         | '(' variable_array ')' multi_array_dimension  // redundant parenthesis
     2117        | '(' variable_array ')' multi_array_dimension  /* redundant parenthesis */
    21082118                { $$ = $2->addArray( $4 ); }
    2109         | '(' variable_array ')'                        // redundant parenthesis
     2119        | '(' variable_array ')'                        /* redundant parenthesis */
    21102120                { $$ = $2; }
    21112121        ;
    21122122
    21132123variable_function:
    2114         '(' variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2124        '(' variable_ptr ')' '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    21152125                { $$ = $2->addParamList( $6 ); }
    2116         | '(' variable_function ')'                     // redundant parenthesis
    2117                 { $$ = $2; }
    2118         ;
    2119 
    2120 // This pattern parses a function declarator that is not redefining a typedef name. Because functions cannot
    2121 // be nested, there is no context where a function definition can redefine a typedef name. To allow nested
    2122 // functions requires further separation of variable and function declarators in typedef_redeclarator.  The
    2123 // pattern precludes returning arrays and functions versus pointers to arrays and functions.
     2126        | '(' variable_function ')'                     /* redundant parenthesis */
     2127                { $$ = $2; }
     2128        ;
     2129
     2130/* This pattern parses a function declarator that is not redefining a typedef name. Because functions cannot
     2131  be nested, there is no context where a function definition can redefine a typedef name. To allow nested
     2132  functions requires further separation of variable and function declarators in typedef_redeclarator.  The
     2133   pattern precludes returning arrays and functions versus pointers to arrays and functions. */
    21242134
    21252135function_declarator:
     
    21302140
    21312141function_no_ptr:
    2132         paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2142        paren_identifier '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    21332143                { $$ = $1->addParamList( $4 ); }
    21342144        | '(' function_ptr ')' '(' push parameter_type_list_opt pop ')'
    21352145                { $$ = $2->addParamList( $6 ); }
    2136         | '(' function_no_ptr ')'                       // redundant parenthesis
     2146        | '(' function_no_ptr ')'                       /* redundant parenthesis */
    21372147                { $$ = $2; }
    21382148        ;
     
    21502160        '(' function_ptr ')' array_dimension
    21512161                { $$ = $2->addArray( $4 ); }
    2152         | '(' function_array ')' multi_array_dimension  // redundant parenthesis
     2162        | '(' function_array ')' multi_array_dimension  /* redundant parenthesis */
    21532163                { $$ = $2->addArray( $4 ); }
    2154         | '(' function_array ')'                        // redundant parenthesis
    2155                 { $$ = $2; }
    2156         ;
    2157 
    2158 // This pattern parses an old-style K&R function declarator (OBSOLESCENT, see 4) that is not redefining a
    2159 // typedef name (see function_declarator for additional comments). The pattern precludes returning arrays and
    2160 // functions versus pointers to arrays and functions.
     2164        | '(' function_array ')'                        /* redundant parenthesis */
     2165                { $$ = $2; }
     2166        ;
     2167
     2168/* This pattern parses an old-style K&R function declarator (OBSOLESCENT, see 4) that is not redefining a
     2169  typedef name (see function_declarator for additional comments). The pattern precludes returning arrays and
     2170   functions versus pointers to arrays and functions. */
    21612171
    21622172old_function_declarator:
     
    21672177
    21682178old_function_no_ptr:
    2169         paren_identifier '(' identifier_list ')'        // function_declarator handles empty parameter
     2179        paren_identifier '(' identifier_list ')'        /* function_declarator handles empty parameter */
    21702180                { $$ = $1->addIdList( $3 ); }
    21712181        | '(' old_function_ptr ')' '(' identifier_list ')'
    21722182                { $$ = $2->addIdList( $5 ); }
    2173         | '(' old_function_no_ptr ')'                   // redundant parenthesis
     2183        | '(' old_function_no_ptr ')'                   /* redundant parenthesis */
    21742184                { $$ = $2; }
    21752185        ;
     
    21872197        '(' old_function_ptr ')' array_dimension
    21882198                { $$ = $2->addArray( $4 ); }
    2189         | '(' old_function_array ')' multi_array_dimension // redundant parenthesis
     2199        | '(' old_function_array ')' multi_array_dimension /* redundant parenthesis */
    21902200                { $$ = $2->addArray( $4 ); }
    2191         | '(' old_function_array ')'                    // redundant parenthesis
    2192                 { $$ = $2; }
    2193         ;
    2194 
    2195 // This pattern parses a declaration for a variable or function prototype that redefines a typedef name, e.g.:
    2196 //
    2197 //      typedef int foo;
    2198 //      {
    2199 //         int foo; // redefine typedef name in new scope
    2200 //      }
    2201 //
    2202 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and
    2203 // returning arrays and functions versus pointers to arrays and functions.
     2201        | '(' old_function_array ')'                    /* redundant parenthesis */
     2202                { $$ = $2; }
     2203        ;
     2204
     2205/* This pattern parses a declaration for a variable or function prototype that redefines a typedef name, e.g.:
     2206
     2207        typedef int foo;
     2208        {
     2209           int foo; // redefine typedef name in new scope
     2210        }
     2211
     2212  The pattern precludes declaring an array of functions versus a pointer to an array of functions, and
     2213   returning arrays and functions versus pointers to arrays and functions. */
    22042214
    22052215typedef_redeclarator:
     
    22342244        | '(' typedef_ptr ')' array_dimension
    22352245                { $$ = $2->addArray( $4 ); }
    2236         | '(' typedef_array ')' multi_array_dimension   // redundant parenthesis
     2246        | '(' typedef_array ')' multi_array_dimension   /* redundant parenthesis */
    22372247                { $$ = $2->addArray( $4 ); }
    2238         | '(' typedef_array ')'                         // redundant parenthesis
     2248        | '(' typedef_array ')'                         /* redundant parenthesis */
    22392249                { $$ = $2; }
    22402250        ;
    22412251
    22422252typedef_function:
    2243         paren_typedef '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2253        paren_typedef '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    22442254                { $$ = $1->addParamList( $4 ); }
    2245         | '(' typedef_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2255        | '(' typedef_ptr ')' '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    22462256                { $$ = $2->addParamList( $6 ); }
    2247         | '(' typedef_function ')'                      // redundant parenthesis
    2248                 { $$ = $2; }
    2249         ;
    2250 
    2251 // This pattern parses a declaration for a parameter variable or function prototype that is not redefining a
    2252 // typedef name and allows the C99 array options, which can only appear in a parameter list.  The pattern
    2253 // precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
    2254 // and functions versus pointers to arrays and functions.
     2257        | '(' typedef_function ')'                      /* redundant parenthesis */
     2258                { $$ = $2; }
     2259        ;
     2260
     2261/* This pattern parses a declaration for a parameter variable or function prototype that is not redefining a
     2262  typedef name and allows the C99 array options, which can only appear in a parameter list.  The pattern
     2263  precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
     2264   and functions versus pointers to arrays and functions. */
    22552265
    22562266identifier_parameter_declarator:
     
    22752285        | '(' identifier_parameter_ptr ')' array_dimension
    22762286                { $$ = $2->addArray( $4 ); }
    2277         | '(' identifier_parameter_array ')' multi_array_dimension // redundant parenthesis
     2287        | '(' identifier_parameter_array ')' multi_array_dimension /* redundant parenthesis */
    22782288                { $$ = $2->addArray( $4 ); }
    2279         | '(' identifier_parameter_array ')'            // redundant parenthesis
     2289        | '(' identifier_parameter_array ')'            /* redundant parenthesis */
    22802290                { $$ = $2; }
    22812291        ;
    22822292
    22832293identifier_parameter_function:
    2284         paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2294        paren_identifier '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    22852295                { $$ = $1->addParamList( $4 ); }
    2286         | '(' identifier_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2296        | '(' identifier_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    22872297                { $$ = $2->addParamList( $6 ); }
    2288         | '(' identifier_parameter_function ')'         // redundant parenthesis
    2289                 { $$ = $2; }
    2290         ;
    2291 
    2292 // This pattern parses a declaration for a parameter variable or function prototype that is redefining a typedef name,
    2293 // e.g.:
    2294 //
    2295 //      typedef int foo;
    2296 //      int f( int foo ); // redefine typedef name in new scope
    2297 //
    2298 // and allows the C99 array options, which can only appear in a parameter list.  In addition, the pattern handles the
    2299 // special meaning of parenthesis around a typedef name:
    2300 //
    2301 //      ISO/IEC 9899:1999 Section 6.7.5.3(11) : "In a parameter declaration, a single typedef name in
    2302 //      parentheses is taken to be an abstract declarator that specifies a function with a single parameter,
    2303 //      not as redundant parentheses around the identifier."
    2304 //
    2305 // which precludes the following cases:
    2306 //
    2307 //      typedef float T;
    2308 //      int f( int ( T [5] ) );                 // see abstract_parameter_declarator
    2309 //      int g( int ( T ( int ) ) );             // see abstract_parameter_declarator
    2310 //      int f( int f1( T a[5] ) );              // see identifier_parameter_declarator
    2311 //      int g( int g1( T g2( int p ) ) );       // see identifier_parameter_declarator
    2312 //
    2313 // In essence, a '(' immediately to the left of typedef name, T, is interpreted as starting a parameter type list, and
    2314 // not as redundant parentheses around a redeclaration of T. Finally, the pattern also precludes declaring an array of
    2315 // functions versus a pointer to an array of functions, and returning arrays and functions versus pointers to arrays and
    2316 // functions.
     2298        | '(' identifier_parameter_function ')'         /* redundant parenthesis */
     2299                { $$ = $2; }
     2300        ;
     2301
     2302/* This pattern parses a declaration for a parameter variable or function prototype that is redefining a
     2303   typedef name, e.g.:
     2304
     2305        typedef int foo;
     2306        int f( int foo ); // redefine typedef name in new scope
     2307
     2308   and allows the C99 array options, which can only appear in a parameter list.  In addition, the pattern
     2309   handles the special meaning of parenthesis around a typedef name:
     2310
     2311        ISO/IEC 9899:1999 Section 6.7.5.3(11) : "In a parameter declaration, a single typedef name in
     2312        parentheses is taken to be an abstract declarator that specifies a function with a single parameter,
     2313        not as redundant parentheses around the identifier."
     2314
     2315  which precludes the following cases:
     2316
     2317        typedef float T;
     2318        int f( int ( T [5] ) );                 // see abstract_parameter_declarator
     2319        int g( int ( T ( int ) ) );             // see abstract_parameter_declarator
     2320        int f( int f1( T a[5] ) );              // see identifier_parameter_declarator
     2321        int g( int g1( T g2( int p ) ) );       // see identifier_parameter_declarator
     2322
     2323   In essence, a '(' immediately to the left of typedef name, T, is interpreted as starting a parameter type
     2324   list, and not as redundant parentheses around a redeclaration of T. Finally, the pattern also precludes
     2325   declaring an array of functions versus a pointer to an array of functions, and returning arrays and
     2326   functions versus pointers to arrays and functions. */
    23172327
    23182328typedef_parameter_redeclarator:
     
    23482358
    23492359typedef_parameter_function:
    2350         typedef '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2360        typedef '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    23512361                { $$ = $1->addParamList( $4 ); }
    2352         | '(' typedef_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2362        | '(' typedef_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    23532363                { $$ = $2->addParamList( $6 ); }
    23542364        ;
    23552365
    2356 // This pattern parses a declaration of an abstract variable or function prototype, i.e., there is no identifier to
    2357 // which the type applies, e.g.:
    2358 //
    2359 //      sizeof( int );
    2360 //      sizeof( int [10] );
    2361 //
    2362 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
    2363 // and functions versus pointers to arrays and functions.
     2366/* This pattern parses a declaration of an abstract variable or function prototype, i.e., there is no
     2367   identifier to which the type applies, e.g.:
     2368
     2369        sizeof( int );
     2370        sizeof( int [10] );
     2371
     2372   The pattern precludes declaring an array of functions versus a pointer to an array of functions, and
     2373   returning arrays and functions versus pointers to arrays and functions. */
    23642374
    23652375abstract_declarator:
     
    23862396        | '(' abstract_ptr ')' array_dimension
    23872397                { $$ = $2->addArray( $4 ); }
    2388         | '(' abstract_array ')' multi_array_dimension  // redundant parenthesis
     2398        | '(' abstract_array ')' multi_array_dimension  /* redundant parenthesis */
    23892399                { $$ = $2->addArray( $4 ); }
    2390         | '(' abstract_array ')'                        // redundant parenthesis
     2400        | '(' abstract_array ')'                        /* redundant parenthesis */
    23912401                { $$ = $2; }
    23922402        ;
    23932403
    23942404abstract_function:
    2395         '(' push parameter_type_list_opt pop ')'        // empty parameter list OBSOLESCENT (see 3)
     2405        '(' push parameter_type_list_opt pop ')'        /* empty parameter list OBSOLESCENT (see 3) */
    23962406                { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
    2397         | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2407        | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    23982408                { $$ = $2->addParamList( $6 ); }
    2399         | '(' abstract_function ')'                     // redundant parenthesis
     2409        | '(' abstract_function ')'                     /* redundant parenthesis */
    24002410                { $$ = $2; }
    24012411        ;
    24022412
    24032413array_dimension:
    2404                 // Only the first dimension can be empty.
     2414                /* Only the first dimension can be empty. */
    24052415        '[' push pop ']'
    24062416                { $$ = DeclarationNode::newArray( 0, 0, false ); }
     
    24132423        '[' push assignment_expression pop ']'
    24142424                { $$ = DeclarationNode::newArray( $3, 0, false ); }
    2415         | '[' push '*' pop ']'                          // C99
     2425        | '[' push '*' pop ']'                          /* C99 */
    24162426                { $$ = DeclarationNode::newVarArray( 0 ); }
    24172427        | multi_array_dimension '[' push assignment_expression pop ']'
    24182428                { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }
    2419         | multi_array_dimension '[' push '*' pop ']'    // C99
     2429        | multi_array_dimension '[' push '*' pop ']'    /* C99 */
    24202430                { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); }
    24212431        ;
    24222432
    2423 // This pattern parses a declaration of a parameter abstract variable or function prototype, i.e., there is no
    2424 // identifier to which the type applies, e.g.:
    2425 //
    2426 //      int f( int );           // abstract variable parameter; no parameter name specified
    2427 //      int f( int (int) );     // abstract function-prototype parameter; no parameter name specified
    2428 //
    2429 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
    2430 // and functions versus pointers to arrays and functions. */
     2433/* This pattern parses a declaration of a parameter abstract variable or function prototype, i.e., there is no
     2434  identifier to which the type applies, e.g.:
     2435
     2436        int f( int );           // abstract variable parameter; no parameter name specified
     2437        int f( int (int) );     // abstract function-prototype parameter; no parameter name specified
     2438
     2439   The pattern precludes declaring an array of functions versus a pointer to an array of functions, and
     2440   returning arrays and functions versus pointers to arrays and functions. */
    24312441
    24322442abstract_parameter_declarator:
     
    24532463        | '(' abstract_parameter_ptr ')' array_parameter_dimension
    24542464                { $$ = $2->addArray( $4 ); }
    2455         | '(' abstract_parameter_array ')' multi_array_dimension // redundant parenthesis
     2465        | '(' abstract_parameter_array ')' multi_array_dimension /* redundant parenthesis */
    24562466                { $$ = $2->addArray( $4 ); }
    2457         | '(' abstract_parameter_array ')'              // redundant parenthesis
     2467        | '(' abstract_parameter_array ')'              /* redundant parenthesis */
    24582468                { $$ = $2; }
    24592469        ;
    24602470
    24612471abstract_parameter_function:
    2462         '(' push parameter_type_list_opt pop ')'        // empty parameter list OBSOLESCENT (see 3)
     2472        '(' push parameter_type_list_opt pop ')'        /* empty parameter list OBSOLESCENT (see 3) */
    24632473                { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
    2464         | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2474        | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    24652475                { $$ = $2->addParamList( $6 ); }
    2466         | '(' abstract_parameter_function ')'           // redundant parenthesis
     2476        | '(' abstract_parameter_function ')'           /* redundant parenthesis */
    24672477                { $$ = $2; }
    24682478        ;
    24692479
    24702480array_parameter_dimension:
    2471                 // Only the first dimension can be empty or have qualifiers.
     2481                /* Only the first dimension can be empty or have qualifiers. */
    24722482        array_parameter_1st_dimension
    24732483        | array_parameter_1st_dimension multi_array_dimension
     
    24762486        ;
    24772487
    2478 // The declaration of an array parameter has additional syntax over arrays in normal variable declarations:
    2479 //
    2480 //      ISO/IEC 9899:1999 Section 6.7.5.2(1) : "The optional type qualifiers and the keyword static shall appear only in
    2481 //      a declaration of a function parameter with an array type, and then only in the outermost array type derivation."
     2488/* The declaration of an array parameter has additional syntax over arrays in normal variable declarations:
     2489
     2490        ISO/IEC 9899:1999 Section 6.7.5.2(1) : "The optional type qualifiers and the keyword static shall
     2491        appear only in a declaration of a function parameter with an array type, and then only in the
     2492        outermost array type derivation." */
    24822493
    24832494array_parameter_1st_dimension:
     
    24852496                { $$ = DeclarationNode::newArray( 0, 0, false ); }
    24862497        // multi_array_dimension handles the '[' '*' ']' case
    2487         | '[' push type_qualifier_list '*' pop ']'      // remaining C99
     2498        | '[' push type_qualifier_list '*' pop ']'      /* remaining C99 */
    24882499                { $$ = DeclarationNode::newVarArray( $3 ); }
    24892500        | '[' push type_qualifier_list pop ']'
     
    24982509        ;
    24992510
    2500 // This pattern parses a declaration of an abstract variable, i.e., there is no identifier to which the type applies,
    2501 // e.g.:
    2502 //
    2503 //      sizeof( int ); // abstract variable; no identifier name specified
    2504 //
    2505 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
    2506 // and functions versus pointers to arrays and functions. */
     2511/* This pattern parses a declaration of an abstract variable, i.e., there is no identifier to which the type
     2512   applies, e.g.:
     2513
     2514        sizeof( int ); // abstract variable; no identifier name specified
     2515
     2516   The pattern precludes declaring an array of functions versus a pointer to an array of functions, and
     2517   returning arrays and functions versus pointers to arrays and functions. */
    25072518
    25082519variable_abstract_declarator:
     
    25292540        | '(' variable_abstract_ptr ')' array_dimension
    25302541                { $$ = $2->addArray( $4 ); }
    2531         | '(' variable_abstract_array ')' multi_array_dimension // redundant parenthesis
     2542        | '(' variable_abstract_array ')' multi_array_dimension /* redundant parenthesis */
    25322543                { $$ = $2->addArray( $4 ); }
    2533         | '(' variable_abstract_array ')'               // redundant parenthesis
     2544        | '(' variable_abstract_array ')'               /* redundant parenthesis */
    25342545                { $$ = $2; }
    25352546        ;
    25362547
    25372548variable_abstract_function:
    2538         '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2549        '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' /* empty parameter list OBSOLESCENT (see 3) */
    25392550                { $$ = $2->addParamList( $6 ); }
    2540         | '(' variable_abstract_function ')'            // redundant parenthesis
    2541                 { $$ = $2; }
    2542         ;
    2543 
    2544 // This pattern parses a new-style declaration for a parameter variable or function prototype that is either an
    2545 // identifier or typedef name and allows the C99 array options, which can only appear in a parameter list.
    2546 
    2547 new_identifier_parameter_declarator_tuple:              // CFA
     2551        | '(' variable_abstract_function ')'            /* redundant parenthesis */
     2552                { $$ = $2; }
     2553        ;
     2554
     2555/* This pattern parses a new-style declaration for a parameter variable or function prototype that is either
     2556   an identifier or typedef name and allows the C99 array options, which can only appear in a parameter
     2557   list. */
     2558
     2559new_identifier_parameter_declarator_tuple:              /* CFA */
    25482560        new_identifier_parameter_declarator_no_tuple
    25492561        | new_abstract_tuple
     
    25522564        ;
    25532565
    2554 new_identifier_parameter_declarator_no_tuple:           // CFA
     2566new_identifier_parameter_declarator_no_tuple:           /* CFA */
    25552567        new_identifier_parameter_ptr
    25562568        | new_identifier_parameter_array
    25572569        ;
    25582570
    2559 new_identifier_parameter_ptr:                           // CFA
     2571new_identifier_parameter_ptr:                           /* CFA */
    25602572        '*' type_specifier
    25612573                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     
    25722584        ;
    25732585
    2574 new_identifier_parameter_array:                         // CFA
    2575                 // Only the first dimension can be empty or have qualifiers. Empty dimension must be factored out due to
    2576                 // shift/reduce conflict with new-style empty (void) function return type. */
     2586new_identifier_parameter_array:                         /* CFA */
     2587                /* Only the first dimension can be empty or have qualifiers. Empty dimension must be factored
     2588                   out due to shift/reduce conflict with new-style empty (void) function return type. */
    25772589        '[' push pop ']' type_specifier
    25782590                { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     
    25982610
    25992611new_array_parameter_1st_dimension:
    2600         '[' push type_qualifier_list '*' pop ']'        // remaining C99
     2612        '[' push type_qualifier_list '*' pop ']'        /* remaining C99 */
    26012613                { $$ = DeclarationNode::newVarArray( $3 ); }
    26022614        | '[' push type_qualifier_list assignment_expression pop ']'
    26032615                { $$ = DeclarationNode::newArray( $4, $3, false ); }
    26042616        | '[' push declaration_qualifier_list assignment_expression pop ']'
    2605                 // declaration_qualifier_list must be used because of shift/reduce conflict with assignment_expression,
    2606                 // so a semantic check is necessary to preclude them as a type_qualifier cannot appear in this
    2607                 // context.
     2617                /* declaration_qualifier_list must be used because of shift/reduce conflict with
     2618                   assignment_expression, so a semantic check is necessary to preclude them as a
     2619                   type_qualifier cannot appear in this context. */
    26082620                { $$ = DeclarationNode::newArray( $4, $3, true ); }
    26092621        | '[' push declaration_qualifier_list type_qualifier_list assignment_expression pop ']'
     
    26112623        ;
    26122624
    2613 // This pattern parses a new-style declaration of an abstract variable or function prototype, i.e., there is no
    2614 // identifier to which the type applies, e.g.:
    2615 //
    2616 //      [int] f( int );         // abstract variable parameter; no parameter name specified
    2617 //      [int] f( [int] (int) ); // abstract function-prototype parameter; no parameter name specified
    2618 //
    2619 // These rules need LR(3):
    2620 //
    2621 //      new_abstract_tuple identifier_or_typedef_name
    2622 //      '[' new_parameter_list ']' identifier_or_typedef_name '(' new_parameter_type_list_opt ')'
    2623 //
    2624 // since a function return type can be syntactically identical to a tuple type:
    2625 //
    2626 //      [int, int] t;
    2627 //      [int, int] f( int );
    2628 //
    2629 // Therefore, it is necessary to look at the token after identifier_or_typedef_name to know when to reduce
    2630 // new_abstract_tuple. To make this LR(1), several rules have to be flattened (lengthened) to allow the necessary
    2631 // lookahead. To accomplish this, new_abstract_declarator has an entry point without tuple, and tuple declarations are
    2632 // duplicated when appearing with new_function_specifier.
    2633 
    2634 new_abstract_declarator_tuple:                          // CFA
     2625/* This pattern parses a new-style declaration of an abstract variable or function prototype, i.e., there is
     2626   no identifier to which the type applies, e.g.:
     2627
     2628        [int] f( int );         // abstract variable parameter; no parameter name specified
     2629        [int] f( [int] (int) ); // abstract function-prototype parameter; no parameter name specified
     2630
     2631  These rules need LR(3):
     2632
     2633        new_abstract_tuple identifier_or_typedef_name
     2634        '[' new_parameter_list ']' identifier_or_typedef_name '(' new_parameter_type_list_opt ')'
     2635
     2636  since a function return type can be syntactically identical to a tuple type:
     2637
     2638        [int, int] t;
     2639        [int, int] f( int );
     2640
     2641  Therefore, it is necessary to look at the token after identifier_or_typedef_name to know when to reduce
     2642   new_abstract_tuple. To make this LR(1), several rules have to be flattened (lengthened) to allow
     2643   the necessary lookahead. To accomplish this, new_abstract_declarator has an entry point without tuple, and
     2644   tuple declarations are duplicated when appearing with new_function_specifier. */
     2645
     2646new_abstract_declarator_tuple:                          /* CFA */
    26352647        new_abstract_tuple
    26362648        | type_qualifier_list new_abstract_tuple
     
    26392651        ;
    26402652
    2641 new_abstract_declarator_no_tuple:                       // CFA
     2653new_abstract_declarator_no_tuple:                       /* CFA */
    26422654        new_abstract_ptr
    26432655        | new_abstract_array
    26442656        ;
    26452657
    2646 new_abstract_ptr:                                       // CFA
     2658new_abstract_ptr:                                       /* CFA */
    26472659        '*' type_specifier
    26482660                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     
    26592671        ;
    26602672
    2661 new_abstract_array:                                     // CFA
    2662                 // Only the first dimension can be empty. Empty dimension must be factored out due to shift/reduce
    2663                 // conflict with empty (void) function return type.
     2673new_abstract_array:                                     /* CFA */
     2674                /* Only the first dimension can be empty. Empty dimension must be factored out due to
     2675                   shift/reduce conflict with empty (void) function return type. */
    26642676        '[' push pop ']' type_specifier
    26652677                { $$ = $5->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     
    26762688        ;
    26772689
    2678 new_abstract_tuple:                                     // CFA
     2690new_abstract_tuple:                                     /* CFA */
    26792691        '[' push new_abstract_parameter_list pop ']'
    26802692                { $$ = DeclarationNode::newTuple( $3 ); }
    26812693        ;
    26822694
    2683 new_abstract_function:                                  // CFA
     2695new_abstract_function:                                  /* CFA */
    26842696        '[' push pop ']' '(' new_parameter_type_list_opt ')'
    26852697                { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $6, 0 ); }
     
    26902702        ;
    26912703
    2692 // 1) ISO/IEC 9899:1999 Section 6.7.2(2) : "At least one type specifier shall be given in the declaration specifiers in
    2693 //    each declaration, and in the specifier-qualifier list in each structure declaration and type name."
    2694 //
    2695 // 2) ISO/IEC 9899:1999 Section 6.11.5(1) : "The placement of a storage-class specifier other than at the beginning of
    2696 //    the declaration specifiers in a declaration is an obsolescent feature."
    2697 //
    2698 // 3) ISO/IEC 9899:1999 Section 6.11.6(1) : "The use of function declarators with empty parentheses (not
    2699 //    prototype-format parameter type declarators) is an obsolescent feature."
    2700 //
    2701 // 4) ISO/IEC 9899:1999 Section 6.11.7(1) : "The use of function definitions with separate parameter identifier and
    2702 //    declaration lists (not prototype-format parameter type and identifier declarators) is an obsolescent feature.
    2703 
    2704 //************************* MISCELLANEOUS ********************************
    2705 
    2706 comma_opt:                                              // redundant comma
    2707         // empty
     2704/* 1) ISO/IEC 9899:1999 Section 6.7.2(2) : "At least one type specifier shall be given in the declaration
     2705      specifiers in each declaration, and in the specifier-qualifier list in each structure declaration and
     2706      type name."
     2707
     2708   2) ISO/IEC 9899:1999 Section 6.11.5(1) : "The placement of a storage-class specifier other than at the
     2709      beginning of the declaration specifiers in a declaration is an obsolescent feature."
     2710
     2711   3) ISO/IEC 9899:1999 Section 6.11.6(1) : "The use of function declarators with empty parentheses (not
     2712      prototype-format parameter type declarators) is an obsolescent feature."
     2713
     2714   4) ISO/IEC 9899:1999 Section 6.11.7(1) : "The use of function definitions with separate parameter
     2715      identifier and declaration lists (not prototype-format parameter type and identifier declarators) is
     2716      an obsolescent feature."  */
     2717
     2718/************************* MISCELLANEOUS ********************************/
     2719
     2720comma_opt:                                              /* redundant comma */
     2721        /* empty */
    27082722        | ','
    27092723        ;
    27102724
    27112725assignment_opt:
    2712         // empty
     2726        /* empty */
    27132727                { $$ = 0; }
    27142728        | '=' assignment_expression
     
    27172731
    27182732%%
    2719 // ----end of grammar----
     2733/* ----end of grammar----*/
    27202734
    27212735void yyerror( char *string ) {
     
    27292743}
    27302744
    2731 // Local Variables: //
    2732 // fill-column: 110 //
    2733 // compile-command: "make install" //
    2734 // End: //
     2745/* Local Variables: */
     2746/* fill-column: 110 */
     2747/* compile-command: "make install" */
     2748/* End: */
  • translator/ResolvExpr/CastCost.cc

    r4bf5298 rb1a6d6b  
     1/*
     2 * This file is part of the Cforall project
     3 *
     4 * $Id: CastCost.cc,v 1.11 2005/08/29 20:14:15 rcbilson Exp $
     5 *
     6 */
     7
    18#include "typeops.h"
    29#include "Cost.h"
     
    815
    916namespace ResolvExpr {
    10     class CastCost : public ConversionCost {
    11       public:
    12         CastCost( Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env );
     17
     18class CastCost : public ConversionCost
     19{
     20public:
     21  CastCost( Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env );
    1322 
    14         virtual void visit( BasicType *basicType );
    15         virtual void visit( PointerType *pointerType );
    16     };
     23  virtual void visit(BasicType *basicType);
     24  virtual void visit(PointerType *pointerType);
     25};
    1726
    18     Cost castCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
    19         if ( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
    20             EqvClass eqvClass;
    21             NamedTypeDecl *namedType;
    22             if ( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) {
    23                 return castCost( src, eqvClass.type, indexer, env );
    24             } else if ( ( namedType = indexer.lookupType( destAsTypeInst->get_name() ) ) ) {
    25                 TypeDecl *type = dynamic_cast< TypeDecl* >( namedType );
    26                 // all typedefs should be gone by this point
    27                 assert( type );
    28                 if ( type->get_base() ) {
    29                     return castCost( src, type->get_base(), indexer, env ) + Cost( 0, 0, 1 );
    30                 } // if
    31             } // if
    32         } // if
    33         if ( typesCompatibleIgnoreQualifiers( src, dest, indexer, env ) ) {
    34             return Cost( 0, 0, 0 );
    35         } else if ( dynamic_cast< VoidType* >( dest ) ) {
    36             return Cost( 0, 0, 1 );
    37         } else {
    38             CastCost converter( dest, indexer, env );
    39             src->accept( converter );
    40             if ( converter.get_cost() == Cost::infinity ) {
    41                 return Cost::infinity;
    42             } else {
    43                 return converter.get_cost() + Cost( 0, 0, 0 );
    44             } // if
    45         } // if
     27Cost
     28castCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env )
     29{
     30//  std::cout << "casting" << std::endl;
     31//  src->print( std::cout, 8 );
     32//  std::cout << std::endl << "to" << std::endl;
     33//  dest->print( std::cout, 8 );
     34  if( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
     35    EqvClass eqvClass;
     36    NamedTypeDecl *namedType;
     37    if( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) {
     38      return castCost( src, eqvClass.type, indexer, env );
     39    } else if( ( namedType = indexer.lookupType( destAsTypeInst->get_name() ) ) ) {
     40      TypeDecl *type = dynamic_cast< TypeDecl* >( namedType );
     41      // all typedefs should be gone by this point
     42      assert( type );
     43      if( type->get_base() ) {
     44        return castCost( src, type->get_base(), indexer, env ) + Cost( 0, 0, 1 );
     45      }
    4646    }
     47  }
     48  if( typesCompatibleIgnoreQualifiers( src, dest, indexer, env ) ) {
     49//    std::cout << "types are compatible" << std::endl;
     50    return Cost( 0, 0, 0 );
     51  } else if( dynamic_cast< VoidType* >( dest ) ) {
     52//    std::cout << "destination is void" << std::endl;
     53    return Cost( 0, 0, 1 );
     54  } else {
     55    CastCost converter( dest, indexer, env );
     56    src->accept( converter );
     57//    std::cout << "cost is " << converter.get_cost() << std::endl;
     58    if( converter.get_cost() == Cost::infinity ) {
     59      return Cost::infinity;
     60    } else {
     61      return converter.get_cost() + Cost( 0, 0, 0 );
     62    }
     63  }
     64}
    4765
    48     CastCost::CastCost( Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env )
    49         : ConversionCost( dest, indexer, env ) {
     66CastCost::CastCost( Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env )
     67  : ConversionCost( dest, indexer, env )
     68{
     69}
     70
     71void
     72CastCost::visit(BasicType *basicType)
     73{
     74  if( dynamic_cast< PointerType* >( dest ) ) {
     75    cost = Cost( 1, 0, 0 );
     76  } else {
     77    ConversionCost::visit( basicType );
     78  }
     79}
     80
     81void
     82CastCost::visit(PointerType *pointerType)
     83{
     84  if( PointerType *destAsPtr = dynamic_cast< PointerType* >( dest ) ) {
     85    if( pointerType->get_qualifiers() <= destAsPtr->get_qualifiers() && typesCompatibleIgnoreQualifiers( pointerType->get_base(), destAsPtr->get_base(), indexer, env ) ) {
     86      cost = Cost( 0, 0, 1 );
     87    } else if( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {
     88      if( destAsBasic->isInteger() ) {
     89        cost = Cost( 1, 0, 0 );
     90      }
     91    } else {
     92      TypeEnvironment newEnv( env );
     93      newEnv.add( pointerType->get_forall() );
     94      newEnv.add( pointerType->get_base()->get_forall() );
     95      int assignResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
     96      if( assignResult > 0 ) {
     97        cost = Cost( 0, 0, 1 );
     98      } else if( assignResult < 0 ) {
     99        cost = Cost( 1, 0, 0 );
     100      }
    50101    }
     102  }
     103}
    51104
    52     void CastCost::visit( BasicType *basicType ) {
    53         if ( dynamic_cast< PointerType* >( dest ) ) {
    54             cost = Cost( 1, 0, 0 );
    55         } else {
    56             ConversionCost::visit( basicType );
    57         } // if
    58     }
    59 
    60     void CastCost::visit( PointerType *pointerType ) {
    61         if ( PointerType *destAsPtr = dynamic_cast< PointerType* >( dest ) ) {
    62             if ( pointerType->get_qualifiers() <= destAsPtr->get_qualifiers() && typesCompatibleIgnoreQualifiers( pointerType->get_base(), destAsPtr->get_base(), indexer, env ) ) {
    63                 cost = Cost( 0, 0, 1 );
    64             } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {
    65                 if ( destAsBasic->isInteger() ) {
    66                     cost = Cost( 1, 0, 0 );
    67                 }
    68             } else {
    69                 TypeEnvironment newEnv( env );
    70                 newEnv.add( pointerType->get_forall() );
    71                 newEnv.add( pointerType->get_base()->get_forall() );
    72                 int assignResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
    73                 if ( assignResult > 0 ) {
    74                     cost = Cost( 0, 0, 1 );
    75                 } else if ( assignResult < 0 ) {
    76                     cost = Cost( 1, 0, 0 );
    77                 } // if
    78             } // if
    79         } // if
    80     }
    81105} // namespace ResolvExpr
  • translator/ResolvExpr/PtrsAssignable.cc

    r4bf5298 rb1a6d6b  
     1/*
     2 * This file is part of the Cforall project
     3 *
     4 * $Id: PtrsAssignable.cc,v 1.3 2005/08/29 20:14:16 rcbilson Exp $
     5 *
     6 */
     7
    18#include "typeops.h"
    29#include "SynTree/Type.h"
     
    613
    714namespace ResolvExpr {
    8     class PtrsAssignable : public Visitor {
    9       public:
    10         PtrsAssignable( Type *dest, const TypeEnvironment &env );
     15
     16class PtrsAssignable : public Visitor
     17{
     18public:
     19  PtrsAssignable( Type *dest, const TypeEnvironment &env );
    1120 
    12         int get_result() const { return result; }
     21  int get_result() const { return result; }
    1322
    14         virtual void visit(VoidType *voidType);
    15         virtual void visit(BasicType *basicType);
    16         virtual void visit(PointerType *pointerType);
    17         virtual void visit(ArrayType *arrayType);
    18         virtual void visit(FunctionType *functionType);
    19         virtual void visit(StructInstType *inst);
    20         virtual void visit(UnionInstType *inst);
    21         virtual void visit(EnumInstType *inst);
    22         virtual void visit(ContextInstType *inst);
    23         virtual void visit(TypeInstType *inst);
    24         virtual void visit(TupleType *tupleType);
    25       private:
    26         Type *dest;
    27         int result;
    28         const TypeEnvironment &env;
    29     };
     23  virtual void visit(VoidType *voidType);
     24  virtual void visit(BasicType *basicType);
     25  virtual void visit(PointerType *pointerType);
     26  virtual void visit(ArrayType *arrayType);
     27  virtual void visit(FunctionType *functionType);
     28  virtual void visit(StructInstType *inst);
     29  virtual void visit(UnionInstType *inst);
     30  virtual void visit(EnumInstType *inst);
     31  virtual void visit(ContextInstType *inst);
     32  virtual void visit(TypeInstType *inst);
     33  virtual void visit(TupleType *tupleType);
    3034
    31     int ptrsAssignable( Type *src, Type *dest, const TypeEnvironment &env ) {
    32         if ( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
    33             EqvClass eqvClass;
    34             if ( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) {
    35                 return ptrsAssignable( src, eqvClass.type, env );
    36             }
    37         }
    38         if ( dynamic_cast< VoidType* >( dest ) ) {
    39             return 1;
    40         } else {
    41             PtrsAssignable ptrs( dest, env );
    42             src->accept( ptrs );
    43             return ptrs.get_result();
    44         }
     35private:
     36  Type *dest;
     37  int result;
     38  const TypeEnvironment &env;
     39};
     40
     41int
     42ptrsAssignable( Type *src, Type *dest, const TypeEnvironment &env )
     43{
     44  if( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
     45    EqvClass eqvClass;
     46    if( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) {
     47      return ptrsAssignable( src, eqvClass.type, env );
    4548    }
     49  }
     50  if( dynamic_cast< VoidType* >( dest ) ) {
     51    return 1;
     52  } else {
     53    PtrsAssignable ptrs( dest, env );
     54    src->accept( ptrs );
     55    return ptrs.get_result();
     56  }
     57}
    4658
    47     PtrsAssignable::PtrsAssignable( Type *dest, const TypeEnvironment &env ) : dest( dest ), result( 0 ), env( env ) {
    48     }
     59PtrsAssignable::PtrsAssignable( Type *dest, const TypeEnvironment &env )
     60  : dest( dest ), result( 0 ), env( env )
     61{
     62}
    4963
    50     void PtrsAssignable::visit(VoidType *voidType) {
    51         if ( dynamic_cast< FunctionType* >( dest ) ) {
    52             result = 0;
    53         } else {
    54             result = -1;
    55         }
    56     }
     64void
     65PtrsAssignable::visit(VoidType *voidType)
     66{
     67  if( dynamic_cast< FunctionType* >( dest ) ) {
     68    result = 0;
     69  } else {
     70    result = -1;
     71  }
     72}
    5773
    58     void PtrsAssignable::visit( BasicType *basicType ) {
    59     }
     74void
     75PtrsAssignable::visit(BasicType *basicType)
     76{
     77}
    6078
    61     void PtrsAssignable::visit( PointerType *pointerType ) {
    62     }
     79void
     80PtrsAssignable::visit(PointerType *pointerType)
     81{
     82}
    6383
    64     void PtrsAssignable::visit( ArrayType *arrayType ) {
    65     }
     84void
     85PtrsAssignable::visit(ArrayType *arrayType)
     86{
     87}
    6688
    67     void PtrsAssignable::visit( FunctionType *functionType ) {
    68         result = -1;
    69     }
     89void
     90PtrsAssignable::visit(FunctionType *functionType)
     91{
     92  result = -1;
     93}
    7094
    71     void PtrsAssignable::visit( StructInstType *inst ) {
    72         // I don't think we should be doing anything here, but I'm willing to admit that I might be wrong
    73     }
     95void
     96PtrsAssignable::visit(StructInstType *inst)
     97{
     98  // I don't think we should be doing anything here, but I'm willing to admit that I might be wrong
     99}
    74100
    75     void PtrsAssignable::visit( UnionInstType *inst ) {
    76         // I don't think we should be doing anything here, but I'm willing to admit that I might be wrong
    77     }
     101void
     102PtrsAssignable::visit(UnionInstType *inst)
     103{
     104  // I don't think we should be doing anything here, but I'm willing to admit that I might be wrong
     105}
    78106
    79     void PtrsAssignable::visit( EnumInstType *inst ) {
    80         if ( dynamic_cast< EnumInstType* >( inst ) ) {
    81             result = 1;
    82         } else if ( BasicType *bt = dynamic_cast< BasicType* >( inst ) ) {
    83             result = bt->get_kind() == BasicType::SignedInt;
    84         }
    85     }
     107void
     108PtrsAssignable::visit(EnumInstType *inst)
     109{
     110  if( dynamic_cast< EnumInstType* >( inst ) ) {
     111    result = 1;
     112  } else if( BasicType *bt = dynamic_cast< BasicType* >( inst ) ) {
     113    result = bt->get_kind() == BasicType::SignedInt;
     114  }
     115}
    86116
    87     void PtrsAssignable::visit( ContextInstType *inst ) {
    88         // I definitely don't think we should be doing anything here
    89     }
     117void
     118PtrsAssignable::visit(ContextInstType *inst)
     119{
     120  // I definitely don't think we should be doing anything here
     121}
    90122
    91     void PtrsAssignable::visit( TypeInstType *inst ) {
    92         EqvClass eqvClass;
    93         if ( env.lookup( inst->get_name(), eqvClass ) ) {
    94             result = ptrsAssignable( eqvClass.type, dest, env );
    95         } else {
    96             result = 0;
    97         }
    98     }
     123void
     124PtrsAssignable::visit(TypeInstType *inst)
     125{
     126  EqvClass eqvClass;
     127  if( env.lookup( inst->get_name(), eqvClass ) ) {
     128    result = ptrsAssignable( eqvClass.type, dest, env );
     129  } else {
     130    result = 0;
     131  }
     132}
    99133
    100     void PtrsAssignable::visit( TupleType *tupleType ) {
     134void
     135PtrsAssignable::visit(TupleType *tupleType)
     136{
    101137///  // This code doesn't belong here, but it might be useful somewhere else
    102 ///   if ( TupleType *destAsTuple = dynamic_cast< TupleType* >( dest ) ) {
     138///   if( TupleType *destAsTuple = dynamic_cast< TupleType* >( dest ) ) {
    103139///     int ret = 0;
    104140///     std::list< Type* >::const_iterator srcIt = tupleType->get_types().begin();
     
    106142///     while( srcIt != tupleType->get_types().end() && destIt != destAsTuple->get_types().end() ) {
    107143///       int assignResult = ptrsAssignable( *srcIt++, *destIt++ );
    108 ///       if ( assignResult == 0 ) {
     144///       if( assignResult == 0 ) {
    109145///         result = assignResult;
    110146///         return;
     
    115151///       }
    116152///     }
    117 ///     if ( srcIt == tupleType->get_types().end() && destIt == destAsTuple->get_types().end() ) {
     153///     if( srcIt == tupleType->get_types().end() && destIt == destAsTuple->get_types().end() ) {
    118154///       result = ret;
    119155///     } else {
     
    121157///     }
    122158///   }
    123     }
     159}
     160
    124161} // namespace ResolvExpr
  • translator/ResolvExpr/Resolver.cc

    r4bf5298 rb1a6d6b  
    9898                return bt->isInteger();
    9999            } else {
    100                 return false;
     100                return true;
    101101            } // if
    102102        }
     
    121121                if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {
    122122                    if ( newExpr ) {
    123                         throw SemanticError( "Too many interpretations for case control expression", untyped );
     123                        throw SemanticError( "Too many interpretations for switch control expression", untyped );
    124124                    } else {
    125125                        newExpr = i->expr->clone();
     
    128128                } // if
    129129            } // for
    130             if ( ! newExpr ) {
    131                 throw SemanticError( "No interpretations for case control expression", untyped );
     130            if ( !newExpr ) {
     131                throw SemanticError( "Too many interpretations for switch control expression", untyped );
    132132            } // if
    133133            finishExpr( newExpr, *newEnv );
  • translator/SymTab/Validate.cc

    r4bf5298 rb1a6d6b  
    278278            ObjectDecl *obj = dynamic_cast< ObjectDecl * >( *i );
    279279            assert( obj );
    280             obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false ), enumDecl->get_name() ) );
     280            obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false ), enumDecl->get_name() ) );
    281281        } // for
    282282        Parent::visit( enumDecl );
  • translator/SynTree/CompoundStmt.cc

    r4bf5298 rb1a6d6b  
    1111#include <functional>
    1212
    13 using std::string;
    14 using std::endl;
     13#include <iostream>
     14using namespace std;
    1515
    16 CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels ) {
     16CompoundStmt::CompoundStmt( std::list<Label> labels )
     17    : Statement( labels )
     18{
    1719}
    1820
    19 CompoundStmt::CompoundStmt( const CompoundStmt &other ) : Statement( other ) {
     21CompoundStmt::CompoundStmt( const CompoundStmt &other )
     22    : Statement( other )
     23{
    2024    cloneAll( other.kids, kids );
    2125}
    2226
    23 CompoundStmt::~CompoundStmt() {
     27CompoundStmt::~CompoundStmt()
     28{
    2429    deleteAll( kids );
    2530}
    2631
    27 void CompoundStmt::print( std::ostream &os, int indent ) {
     32void
     33CompoundStmt::print( std::ostream &os, int indent )
     34{
    2835    os << "\r" << string(indent, ' ') << "CompoundStmt" << endl ;
    2936    printAll( kids, os, indent+2 );
  • translator/SynTree/Declaration.h

    r4bf5298 rb1a6d6b  
    1212    enum StorageClass { 
    1313        NoStorageClass,
     14        Auto,
     15        Static,
    1416        Extern,
    15         Static,
    16         Auto,
    1717        Register,
    18         Inline,
    19         Fortran,
     18        Fortran
    2019    }; 
    2120
     
    109108    CompoundStmt *get_statements() const { return statements; }
    110109    void set_statements( CompoundStmt *newValue ) { statements = newValue; }
    111 //    bool get_isInline() const { return isInline; }
    112 //    void set_isInline( bool newValue ) { isInline = newValue; }
     110    bool get_isInline() const { return isInline; }
     111    void set_isInline( bool newValue ) { isInline = newValue; }
    113112    std::list< std::string >& get_oldIdents() { return oldIdents; }
    114113    std::list< Declaration* >& get_oldDecls() { return oldDecls; }
  • translator/SynTree/FunctionDecl.cc

    r4bf5298 rb1a6d6b  
     1/*
     2 * This file is part of the Cforall project
     3 *
     4 * $Id: FunctionDecl.cc,v 1.15 2005/08/29 20:59:25 rcbilson Exp $
     5 *
     6 */
     7
    18#include <cassert>
    29
     
    714
    815
    9 FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline )
    10         : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline ) {
    11     // this is a brazen hack to force the function "main" to have C linkage
    12     if ( name == "main" ) {
     16FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type,
     17                                            CompoundStmt *statements, bool isInline )
     18    : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline )
     19{
     20    // this is a pretty brazen hack to force the function "main" to have C linkage
     21    if( name == "main" ) {
    1322        set_linkage( LinkageSpec::C );
    1423    }
     
    1625
    1726FunctionDecl::FunctionDecl( const FunctionDecl &other )
    18     : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), isInline( other.isInline ) {
     27    : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ),
     28        isInline( other.isInline )
     29{
    1930}
    2031
    21 FunctionDecl::~FunctionDecl() {
     32FunctionDecl::~FunctionDecl()
     33{
    2234    delete type;
    2335    delete statements;
    2436}
    2537
    26 Type * FunctionDecl::get_type() const {
     38Type*
     39FunctionDecl::get_type() const
     40{
    2741    return type;
    2842}
    2943
    30 void FunctionDecl::set_type( Type *t ) {
     44void
     45FunctionDecl::set_type(Type *t)
     46{
    3147    type = dynamic_cast< FunctionType* >( t );
    3248    assert( type );
    3349}
    3450
    35 void FunctionDecl::print( std::ostream &os, int indent ) const {
     51void
     52FunctionDecl::print( std::ostream &os, int indent ) const
     53{
    3654    using std::endl;
    3755    using std::string;
    3856   
    39     if ( get_name() != "" ) {
     57    if( get_name() != "" ) {
    4058        os << get_name() << ": a ";
    4159    }
    42     if ( get_linkage() != LinkageSpec::Cforall ) {
     60    if( get_linkage() != LinkageSpec::Cforall ) {
    4361        os << LinkageSpec::toString( get_linkage() ) << " ";
    4462    }
    45     if ( isInline ) {
     63    if( isInline ) {
    4664        os << "inline ";
    4765    }
    48     if ( get_storageClass() != NoStorageClass ) {
     66    if( get_storageClass() != NoStorageClass ) {
    4967        os << storageClassName[ get_storageClass() ] << ' ';
    5068    }
    51     if ( get_type() ) {
     69    if( get_type() ) {
    5270        get_type()->print( os, indent );
    5371    } else {
    5472        os << "untyped entity ";
    5573    }
    56     if ( ! oldIdents.empty() ) {
     74    if( !oldIdents.empty() ) {
    5775        os << string( indent+2, ' ' ) << "with parameter names" << endl;
    5876        for( std::list< std::string >::const_iterator i = oldIdents.begin(); i != oldIdents.end(); ++i ) {
     
    6078        }
    6179    }
    62     if ( ! oldDecls.empty() ) {
     80    if( !oldDecls.empty() ) {
    6381        os << string( indent+2, ' ' ) << "with parameter declarations" << endl;
    6482        printAll( oldDecls, os, indent+4 );
    6583    }
    66     if ( statements ) {
     84    if( statements ) {
    6785        os << string( indent+2, ' ' ) << "with body " << endl;
    6886        statements->print( os, indent+4 );
     
    7088}
    7189
    72 void FunctionDecl::printShort( std::ostream &os, int indent ) const {
     90void
     91FunctionDecl::printShort( std::ostream &os, int indent ) const
     92{
    7393    using std::endl;
    7494    using std::string;
    7595   
    76     if ( get_name() != "" ) {
     96    if( get_name() != "" ) {
    7797        os << get_name() << ": a ";
    7898    }
    79     if ( isInline ) {
     99    if( isInline ) {
    80100        os << "inline ";
    81101    }
    82     if ( get_storageClass() != NoStorageClass ) {
     102    if( get_storageClass() != NoStorageClass ) {
    83103        os << storageClassName[ get_storageClass() ] << ' ';
    84104    }
    85     if ( get_type() ) {
     105    if( get_type() ) {
    86106        get_type()->print( os, indent );
    87107    } else {
     
    89109    }
    90110}
     111
  • translator/SynTree/Statement.cc

    r4bf5298 rb1a6d6b  
    1414
    1515
     16// *** Statement
    1617Statement::Statement(std::list<Label> _labels):
    1718    labels(_labels) {}
     
    2122Statement::~Statement() {}
    2223
     24//*** ExprStmt
    2325ExprStmt::ExprStmt( std::list<Label> _labels, Expression *_expr ):
    2426    Statement(_labels), expr(_expr) {}
     
    3133}
    3234
     35//*** BranchStmt
    3336const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
    3437
     
    5457}
    5558
     59//*** ReturnStmt
    5660ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) :
    5761    Statement( labels ), expr( _expr ), isThrow( throwP ) {}
     
    6872
    6973
     74// *** IfStmt
    7075IfStmt::IfStmt( std::list<Label> _labels, Expression *_condition, Statement *_thenPart, Statement *_elsePart ):
    7176    Statement(_labels), condition(_condition), thenPart(_thenPart), elsePart(_elsePart) {}
     
    8691}
    8792
     93// *** SwitchStmt
    8894SwitchStmt::SwitchStmt(std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches):
    8995    Statement(_labels), condition(_condition), branches(_branches)
     
    110116}
    111117
     118// *** CaseStmt
    112119CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition,
    113120                                        std::list<Statement *> &_statements, bool deflt )
     
    140147}
    141148
     149//*** ChooseStmt
    142150//ChooseStmt::ChooseStmt( std::list<Label> labels, Expression *condition, Statement *body ) {}
    143151ChooseStmt::ChooseStmt(std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches):
     
    164172}
    165173
     174//*** FallthruStmt
    166175void FallthruStmt::print(std::ostream &os, int indent) {
    167176    os << "\r" << string(indent, ' ') << "Fall-through statement" << endl;
    168177}
    169178
     179//*** WhileStmt
    170180WhileStmt::WhileStmt( std::list<Label> labels, Expression *condition_,
    171181                                            Statement *body_, bool isDoWhile_ ):
     
    186196}
    187197
     198//*** ForStmt
    188199ForStmt::ForStmt( std::list<Label> labels, Statement *initialization_,
    189200                                    Expression *condition_, Expression *increment_, Statement *body_ ):
     
    222233}
    223234
     235//*** TryStmt
    224236TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) :
    225237    Statement( labels ), block( tryBlock ),  handlers( _handlers ), finallyBlock( _finallyBlock )
     
    254266}
    255267
     268//*** CatchStmt
    256269CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) :
    257270    Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest )
     
    277290
    278291
     292//*** FinallyStmt
    279293FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *_block ) :
    280294    Statement( labels ), block( _block )
     
    293307}
    294308
     309//*** NullStmt
    295310NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {}
    296311NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {}
  • translator/SynTree/Statement.h

    r4bf5298 rb1a6d6b  
     1/*
     2 * This file is part of the Cforall project
     3 *
     4 * $Id: Statement.h,v 1.18 2005/08/29 20:59:26 rcbilson Exp $
     5 *
     6 */
     7
    18#ifndef STATEMENT_H
    29#define STATEMENT_H
  • translator/SynTree/Type.h

    r4bf5298 rb1a6d6b  
    1010  public:
    1111    struct Qualifiers { 
    12       Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isAttribute( false ) {}
    13       Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {}
     12      Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {}
     13      Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ) {}
    1414       
    1515        Qualifiers &operator+=( const Qualifiers &other );
     
    2828        bool isLvalue;
    2929        bool isAtomic;
    30         bool isAttribute;
    3130    }; 
    3231
     
    4140    bool get_isLvalue() { return tq.isLvalue; }
    4241    bool get_isAtomic() { return tq.isAtomic; }
    43     bool get_isAttribute() { return tq.isAttribute; }
    4442    void set_isConst( bool newValue ) { tq.isConst = newValue; }
    4543    void set_iisVolatile( bool newValue ) { tq.isVolatile = newValue; }
     
    4745    void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; }
    4846    void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; }
    49     void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; }
    5047    std::list<TypeDecl*>& get_forall() { return forall; }
    5148
  • translator/examples/identity.c

    r4bf5298 rb1a6d6b  
    99    ofstream *sout = ofstream_stdout();
    1010    char c = 'a';
    11     c = identity( c );
    1211    sout << c << ' ' << identity( c ) << '\n';
    1312    int i = 5;
    14     i = identity( i );
    1513    sout << i << ' ' << identity( i ) << '\n';
    1614    double d = 3.2;
    17     d = identity( d );
    1815    sout << d << ' ' << identity( d ) << '\n';
    1916}
  • translator/examples/min.c

    r4bf5298 rb1a6d6b  
    11extern "C" {
    22    int printf( const char *, ... );
    3 //#include <stdio.h>
    43}
    54
     
    1110int main() {
    1211    char c;
    13 //    c = min( 'z', 'a' );
    14 //    printf( "minimum %d\n", c );
     12    c = min( 'z', 'a' );
     13    printf( "minimum %d\n", c );
    1514    int i;
    1615    i = min( 4, 3 );
  • translator/examples/s.c

    r4bf5298 rb1a6d6b  
    1 //int ?!=?( int, int );
     1int ?!=?( int, int );
     2int 0;
    23
    3 void f() {
    4 //    int a;
    5 //    a ? 4 : 5;
    6     1 ? 4 : 5;
     4void f()
     5{
    76    0 ? 4 : 5;
    87}
  • translator/examples/square.c

    r4bf5298 rb1a6d6b  
     1// './cfa square.c'
     2
    13extern "C" {
    24#include <stdio.h>
  • translator/examples/swap.c

    r4bf5298 rb1a6d6b  
    55forall( type T )
    66void swap( T *left, T *right ) {
    7     T temp = *left;
     7    T temp;
     8    temp = *left;
    89    *left = *right;
    910    *right = temp;
Note: See TracChangeset for help on using the changeset viewer.