Changeset 660665f for src/Parser


Ignore:
Timestamp:
Jun 29, 2021, 5:35:19 PM (4 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
dcad80a
Parents:
5a46e09 (diff), d02e547 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/Parser
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r5a46e09 r660665f  
    10761076        if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) {
    10771077                // otype is internally converted to dtype + otype parameters
    1078                 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::DStype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype, TypeDecl::Dtype };
     1078                static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype, TypeDecl::Dimension };
    10791079                static_assert( sizeof(kindMap) / sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." );
    10801080                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    1081                 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype || variable.tyClass == TypeDecl::ALtype, variable.initializer ? variable.initializer->buildType() : nullptr );
     1081                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype || variable.tyClass == TypeDecl::DStype, variable.initializer ? variable.initializer->buildType() : nullptr );
    10821082                buildList( variable.assertions, ret->get_assertions() );
    10831083                return ret;
  • src/Parser/ExpressionNode.cc

    r5a46e09 r660665f  
    509509} // build_varref
    510510
     511DimensionExpr * build_dimensionref( const string * name ) {
     512        DimensionExpr * expr = new DimensionExpr( *name );
     513        delete name;
     514        return expr;
     515} // build_varref
    511516// TODO: get rid of this and OperKinds and reuse code from OperatorTable
    512517static const char * OperName[] = {                                              // must harmonize with OperKinds
  • src/Parser/ParseNode.h

    r5a46e09 r660665f  
    183183
    184184NameExpr * build_varref( const std::string * name );
     185DimensionExpr * build_dimensionref( const std::string * name );
    185186
    186187Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
  • src/Parser/TypedefTable.cc

    r5a46e09 r660665f  
    1010// Created On       : Sat May 16 15:20:13 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 15 20:56:47 2021
    13 // Update Count     : 260
     12// Last Modified On : Wed May 19 08:30:14 2021
     13// Update Count     : 262
    1414//
    1515
     
    3131        switch ( kind ) {
    3232          case IDENTIFIER: return "identifier";
     33          case TYPEDIMname: return "typedim";
    3334          case TYPEDEFname: return "typedef";
    3435          case TYPEGENname: return "typegen";
  • src/Parser/lex.ll

    r5a46e09 r660665f  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Thu Apr  1 13:22:31 2021
    13  * Update Count     : 754
     12 * Last Modified On : Sun Jun 20 18:41:09 2021
     13 * Update Count     : 759
    1414 */
    1515
     
    117117hex_constant {hex_prefix}{hex_digits}{integer_suffix_opt}
    118118
    119                                 // GCC: D (double) and iI (imaginary) suffixes, and DL (long double)
     119                                // GCC: floating D (double), imaginary iI, and decimal floating DF, DD, DL
    120120exponent "_"?[eE]"_"?[+-]?{decimal_digits}
    121121floating_size 16|32|32x|64|64x|80|128|128x
    122122floating_length ([fFdDlLwWqQ]|[fF]{floating_size})
    123123floating_suffix ({floating_length}?[iI]?)|([iI]{floating_length})
    124 floating_suffix_opt ("_"?({floating_suffix}|"DL"))?
     124decimal_floating_suffix [dD][fFdDlL]
     125floating_suffix_opt ("_"?({floating_suffix}|{decimal_floating_suffix}))?
    125126decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal})
    126127floating_decimal {decimal_digits}"."{exponent}?{floating_suffix_opt}
     
    234235continue                { KEYWORD_RETURN(CONTINUE); }
    235236coroutine               { KEYWORD_RETURN(COROUTINE); }                  // CFA
     237_Decimal32              { KEYWORD_RETURN(DECIMAL32); }                  // GCC
     238_Decimal64              { KEYWORD_RETURN(DECIMAL64); }                  // GCC
     239_Decimal128             { KEYWORD_RETURN(DECIMAL128); }                 // GCC
    236240default                 { KEYWORD_RETURN(DEFAULT); }
    237241disable                 { KEYWORD_RETURN(DISABLE); }                    // CFA
  • src/Parser/parser.yy

    r5a46e09 r660665f  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr 26 18:41:54 2021
    13 // Update Count     : 4990
     12// Last Modified On : Tue Jun 29 09:12:47 2021
     13// Update Count     : 5027
    1414//
    1515
     
    2626// The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed, except for:
    2727//
    28 // 1. designation with '=' (use ':' instead)
    29 //
    30 // Most of the syntactic extensions from ANSI90 to ANSI11 C are marked with the comment "C99/C11". This grammar also has
    31 // two levels of extensions. The first extensions cover most of the GCC C extensions, except for:
    32 //
    33 // 1. designation with and without '=' (use ':' instead)
    34 
    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.
     28//   designation with '=' (use ':' instead)
     29//
     30// This incompatibility is discussed in detail before the "designation" grammar rule.  Most of the syntactic extensions
     31// from ANSI90 to ANSI11 C are marked with the comment "C99/C11".
     32
     33// This grammar also has two levels of extensions. The first extensions cover most of the GCC C extensions All of the
     34// syntactic extensions for GCC C are marked with the comment "GCC". The second extensions are for Cforall (CFA), which
     35// fixes several of C's outstanding problems and extends C with many modern language concepts. All of the syntactic
     36// extensions for CFA C are marked with the comment "CFA".
    4137
    4238%{
     
    269265%token INT128 UINT128 uuFLOAT80 uuFLOAT128                              // GCC
    270266%token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC
     267%token DECIMAL32 DECIMAL64 DECIMAL128                                   // GCC
    271268%token ZERO_T ONE_T                                                                             // CFA
    272269%token SIZEOF TYPEOF VALIST AUTO_TYPE                                   // GCC
     
    287284
    288285// names and constants: lexer differentiates between identifier and typedef names
    289 %token<tok> IDENTIFIER          QUOTED_IDENTIFIER       TYPEDEFname             TYPEGENname
     286%token<tok> IDENTIFIER          QUOTED_IDENTIFIER       TYPEDIMname             TYPEDEFname             TYPEGENname
    290287%token<tok> TIMEOUT                     WOR                                     CATCH                   RECOVER                 CATCHRESUME             FIXUP           FINALLY         // CFA
    291288%token<tok> INTEGERconstant     CHARACTERconstant       STRINGliteral
     
    586583        | quasi_keyword
    587584                { $$ = new ExpressionNode( build_varref( $1 ) ); }
     585        | TYPEDIMname                                                                           // CFA, generic length argument
     586                // { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( DeclarationNode::newFromTypedef( $1 ) ) ) ); }
     587                // { $$ = new ExpressionNode( build_varref( $1 ) ); }
     588                { $$ = new ExpressionNode( build_dimensionref( $1 ) ); }
    588589        | tuple
    589590        | '(' comma_expression ')'
     
    630631postfix_expression:
    631632        primary_expression
    632         | postfix_expression '[' assignment_expression ',' comma_expression ']'
    633                 // { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_binary_val( OperKinds::Index, $3, $5 ) ) ) ); }
    634                 { SemanticError( yylloc, "New array subscript is currently unimplemented." ); $$ = nullptr; }
     633        | postfix_expression '[' assignment_expression ',' tuple_expression_list ']'
     634                        // Historic, transitional: Disallow commas in subscripts.
     635                        // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts.
     636                // { SemanticError( yylloc, "New array subscript is currently unimplemented." ); $$ = nullptr; }
     637                        // Current: Commas in subscripts make tuples.
     638                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
    635639        | postfix_expression '[' assignment_expression ']'
    636640                // CFA, comma_expression disallowed in this context because it results in a common user error: subscripting a
     
    18871891        | uFLOAT128
    18881892                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat128 ); }
     1893        | DECIMAL32
     1894                { SemanticError( yylloc, "_Decimal32 is currently unimplemented." ); $$ = nullptr; }
     1895        | DECIMAL64
     1896                { SemanticError( yylloc, "_Decimal64 is currently unimplemented." ); $$ = nullptr; }
     1897        | DECIMAL128
     1898                { SemanticError( yylloc, "_Decimal128 is currently unimplemented." ); $$ = nullptr; }
    18891899        | COMPLEX                                                                                       // C99
    18901900                { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
     
    19091919        // empty
    19101920                { $$ = nullptr; }
    1911         | vtable;
     1921        | vtable
    19121922        ;
    19131923
     
    25352545        | '[' identifier_or_type_name ']'
    25362546                {
    2537                         typedefTable.addToScope( *$2, TYPEDEFname, "9" );
    2538                         $$ = DeclarationNode::newTypeParam( TypeDecl::ALtype, $2 );
     2547                        typedefTable.addToScope( *$2, TYPEDIMname, "9" );
     2548                        $$ = DeclarationNode::newTypeParam( TypeDecl::Dimension, $2 );
    25392549                }
    25402550        // | type_specifier identifier_parameter_declarator
     
    25502560        | '*'
    25512561                { $$ = TypeDecl::DStype; }                                              // dtype + sized
     2562        // | '(' '*' ')'
     2563        //      { $$ = TypeDecl::Ftype; }
    25522564        | ELLIPSIS
    25532565                { $$ = TypeDecl::Ttype; }
     
    25902602                { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
    25912603        | assignment_expression
    2592                 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; }
    25932604        | type_list ',' type
    25942605                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
    25952606        | type_list ',' assignment_expression
    2596                 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; }
    2597                 // { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     2607                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
    25982608        ;
    25992609
Note: See TracChangeset for help on using the changeset viewer.