Ignore:
Timestamp:
Sep 13, 2017, 3:09:12 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
121c3c0
Parents:
7aa257ae
Message:

generalize types for encoded strings, and fold simple ExpressionNode? build routines into parser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r7aa257ae r513e165  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 11 18:12:00 2017
    13 // Update Count     : 2787
     12// Last Modified On : Wed Sep 13 11:01:20 2017
     13// Update Count     : 2803
    1414//
    1515
     
    5656#include "LinkageSpec.h"
    5757#include "Common/SemanticError.h"                                               // error_str
     58#include "Common/utility.h"                                                             // for maybeMoveBuild, maybeBuild, CodeLo...
    5859
    5960extern DeclarationNode * parseTree;
     
    438439                { $$ = $2; }
    439440        | '(' compound_statement ')'                                            // GCC, lambda expression
    440                 { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
     441                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
    441442        | primary_expression '{' argument_expression_list '}' // CFA, constructor call
    442443                {
     
    618619                // VIRTUAL cannot be opt because of look ahead issues
    619620        | '(' VIRTUAL ')' cast_expression
    620                 { $$ = new ExpressionNode( build_virtual_cast( nullptr, $4 ) ); }
     621                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); }
    621622        | '(' VIRTUAL type_no_function ')' cast_expression
    622                 { $$ = new ExpressionNode( build_virtual_cast( $3, $5 ) ); }
     623                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); }
    623624//      | '(' type_no_function ')' tuple
    624625//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     
    771772        assignment_expression
    772773        | comma_expression ',' assignment_expression
    773                 { $$ = new ExpressionNode( build_comma( $1, $3 ) ); }
     774                { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild< Expression >( $1 ), maybeMoveBuild< Expression >( $3 ) ) ); }
    774775        ;
    775776
     
    11541155asm_operand:                                                                                    // GCC
    11551156        string_literal '(' constant_expression ')'
    1156                 { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
     1157                { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ), $1, maybeMoveBuild< Expression >( $3 ) ) ); }
    11571158        | '[' constant_expression ']' string_literal '(' constant_expression ')'
    1158                 { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
     1159                { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( $2 ), $4, maybeMoveBuild< Expression >( $6 ) ) ); }
    11591160        ;
    11601161
     
    11651166                { $$ = new ExpressionNode( $1 ); }
    11661167        | asm_clobbers_list_opt ',' string_literal
    1167                 // set_last return ParseNode *
     1168                // set_last returns ParseNode *
    11681169                { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
    11691170        ;
     
    21652166type_list:                                                                                              // CFA
    21662167        type
    2167                 { $$ = new ExpressionNode( build_typevalue( $1 ) ); }
     2168                { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
    21682169        | assignment_expression
    21692170        | type_list ',' type
    2170                 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); }
     2171                { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) ) ); }
    21712172        | type_list ',' assignment_expression
    21722173                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
Note: See TracChangeset for help on using the changeset viewer.