Changeset fcd17b2f for src/Parser


Ignore:
Timestamp:
Jul 27, 2017, 2:56:39 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
874960b
Parents:
4d4e5de (diff), a04ce4d (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:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    r4d4e5de rfcd17b2f  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 18 10:08:00 2017
    13 // Update Count     : 550
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 27 12:10:10 2017
     13// Update Count     : 556
    1414//
    1515
     
    6262        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
    6363        int size;                                                                                       // 0 => int, 1 => long, 2 => long long
    64         unsigned long long int v;                                                               // converted integral value
     64        unsigned long long int v;                                                       // converted integral value
    6565        size_t last = str.length() - 1;                                         // last character of constant
    66 
     66        Expression * ret;
     67
     68        // special constants
     69        if ( str == "0" ) {
     70                ret = new ConstantExpr( Constant( (Type *)new ZeroType( noQualifiers ), str, (unsigned long long int)0 ) );
     71                goto CLEANUP;
     72        } // if
     73        if ( str == "1" ) {
     74                ret = new ConstantExpr( Constant( (Type *)new OneType( noQualifiers ), str, (unsigned long long int)1 ) );
     75                goto CLEANUP;
     76        } // if
     77       
    6778        if ( str[0] == '0' ) {                                                          // octal/hex constant ?
    6879                dec = false;
     
    118129        } // if
    119130
    120         Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
     131        ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
     132  CLEANUP:
    121133        delete &str;                                                                            // created by lex
    122134        return ret;
     
    174186        return ret;
    175187} // build_constantStr
    176 
    177 Expression *build_constantZeroOne( const std::string & str ) {
    178         Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( noQualifiers ) : (Type*)new OneType( noQualifiers ), str,
    179                                                                                                    str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );
    180         delete &str;                                                                            // created by lex
    181         return ret;
    182 } // build_constantChar
    183188
    184189Expression * build_field_name_FLOATINGconstant( const std::string & str ) {
     
    252257}
    253258
     259
     260Expression *build_virtual_cast( DeclarationNode *decl_node, ExpressionNode *expr_node ) {
     261        Type *targetType = maybeMoveBuildType( decl_node );
     262        Expression *castArg = maybeMoveBuild< Expression >( expr_node );
     263        return new VirtualCastExpr( castArg, targetType );
     264}
     265
    254266Expression *build_fieldSel( ExpressionNode *expr_node, Expression *member ) {
    255267        UntypedMemberExpr *ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
  • src/Parser/ParseNode.h

    r4d4e5de rfcd17b2f  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:32:30 2017
    13 // Update Count     : 786
     12// Last Modified On : Thu Jul 27 12:08:08 2017
     13// Update Count     : 788
    1414//
    1515
     
    159159Expression * build_constantFloat( const std::string &str );
    160160Expression * build_constantChar( const std::string &str );
    161 Expression * build_constantZeroOne( const std::string &str );
    162161ConstantExpr * build_constantStr( const std::string &str );
    163162Expression * build_field_name_FLOATINGconstant( const std::string & str );
     
    170169
    171170Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
     171Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    172172Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
    173173Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member );
  • src/Parser/lex.ll

    r4d4e5de rfcd17b2f  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Mon Jul 24 08:27:23 2017
    13  * Update Count     : 545
     12 * Last Modified On : Thu Jul 27 12:05:50 2017
     13 * Update Count     : 549
    1414 */
    1515
     
    288288
    289289                                /* numeric constants */
    290 "0"                             { NUMERIC_RETURN(ZERO); }                               // CFA
    291 "1"                             { NUMERIC_RETURN(ONE); }                                // CFA
    292290{decimal_constant} { NUMERIC_RETURN(INTEGERconstant); }
    293291{octal_constant} { NUMERIC_RETURN(INTEGERconstant); }
  • src/Parser/parser.yy

    r4d4e5de rfcd17b2f  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 24 09:01:14 2017
    13 // Update Count     : 2463
     12// Last Modified On : Thu Jul 27 12:08:08 2017
     13// Update Count     : 2467
    1414//
    1515
     
    142142// converted into the tuple index (.)(1). e.g., 3.x
    143143%token<tok>     REALDECIMALconstant     REALFRACTIONconstant    FLOATINGconstant
    144 %token<tok> ZERO                                ONE                                             // CFA
    145144
    146145// multi-character operators
     
    159158%token ATassign                                                                                 // @=
    160159
    161 %type<tok> identifier  no_attr_identifier  zero_one
     160%type<tok> identifier  no_attr_identifier
    162161%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
    163162%type<constant> string_literal
     
    360359        ;
    361360
    362 zero_one:                                                                                               // CFA
    363         ZERO
    364         | ONE
    365         ;
    366 
    367361string_literal:
    368362        string_literal_list                                                     { $$ = build_constantStr( *$1 ); }
     
    384378        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    385379                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    386         | zero_one
    387                 { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); }
    388380        | tuple
    389381        | '(' comma_expression ')'
     
    484476                {
    485477                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
    486                 }
    487         | zero_one fraction_constants
    488                 {
    489                         $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );
    490478                }
    491479        ;
     
    573561                // VIRTUAL cannot be opt because of look ahead issues
    574562        | '(' VIRTUAL ')' cast_expression
    575                 { $$ = new ExpressionNode( build_cast( nullptr, $4 ) ); }
     563                { $$ = new ExpressionNode( build_virtual_cast( nullptr, $4 ) ); }
    576564        | '(' VIRTUAL type_no_function ')' cast_expression
    577                 { $$ = new ExpressionNode( build_cast( $3, $5 ) ); }
     565                { $$ = new ExpressionNode( build_virtual_cast( $3, $5 ) ); }
    578566//      | '(' type_no_function ')' tuple
    579567//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
Note: See TracChangeset for help on using the changeset viewer.