Changeset 33218c6 for src/Parser


Ignore:
Timestamp:
Jul 26, 2017, 12:19:41 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:
b947fb2
Parents:
e0a653d (diff), ea91c42 (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:
12 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    re0a653d r33218c6  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 15:27:00 2017
    13 // Update Count     : 1019
     12// Last Modified On : Fri Jul 14 16:55:00 2017
     13// Update Count     : 1020
    1414//
    1515
     
    253253        newnode->type->aggregate.fields = fields;
    254254        newnode->type->aggregate.body = body;
     255        newnode->type->aggregate.tagged = false;
     256        newnode->type->aggregate.parent = nullptr;
    255257        return newnode;
    256258} // DeclarationNode::newAggregate
     
    273275        return newnode;
    274276} // DeclarationNode::newEnumConstant
     277
     278DeclarationNode * DeclarationNode::newTreeStruct( Aggregate kind, const string * name, const string * parent, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
     279        assert( name );
     280        DeclarationNode * newnode = new DeclarationNode;
     281        newnode->type = new TypeData( TypeData::Aggregate );
     282        newnode->type->aggregate.kind = kind;
     283        newnode->type->aggregate.name = name;
     284        newnode->type->aggregate.actuals = actuals;
     285        newnode->type->aggregate.fields = fields;
     286        newnode->type->aggregate.body = body;
     287        newnode->type->aggregate.tagged = true;
     288        newnode->type->aggregate.parent = parent;
     289        return newnode;
     290} // DeclarationNode::newTreeStruct
    275291
    276292DeclarationNode * DeclarationNode::newName( string * name ) {
  • src/Parser/ExpressionNode.cc

    re0a653d r33218c6  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 28 21:08:15 2017
    13 // Update Count     : 542
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tus Jul 18 10:08:00 2017
     13// Update Count     : 550
    1414//
    1515
     
    4646// type.
    4747
    48 Type::Qualifiers emptyQualifiers;                               // no qualifiers on constants
     48Type::Qualifiers noQualifiers;                          // no qualifiers on constants
    4949
    5050static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
     
    118118        } // if
    119119
    120         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str, v ) );
     120        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
    121121        delete &str;                                                                            // created by lex
    122122        return ret;
     
    153153        } // if
    154154
    155         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str, v ) );
     155        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) );
    156156        delete &str;                                                                            // created by lex
    157157        return ret;
     
    159159
    160160Expression *build_constantChar( const std::string & str ) {
    161         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
     161        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
    162162        delete &str;                                                                            // created by lex
    163163        return ret;
     
    166166ConstantExpr *build_constantStr( const std::string & str ) {
    167167        // string should probably be a primitive type
    168         ArrayType *at = new ArrayType( emptyQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
     168        ArrayType *at = new ArrayType( noQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
    169169                                                                   new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ),  // +1 for '\0' and -2 for '"'
    170170                                                                   false, false );
     
    176176
    177177Expression *build_constantZeroOne( const std::string & str ) {
    178         Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str,
     178        Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( noQualifiers ) : (Type*)new OneType( noQualifiers ), str,
    179179                                                                                                   str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );
    180180        delete &str;                                                                            // created by lex
     
    231231}
    232232
     233// Must harmonize with OperKinds.
    233234static const char *OperName[] = {
    234235        // diadic
    235         "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
     236        "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&",
    236237        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    237         "?=?", "?@=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
     238        "?=?", "?@=?", "?\\=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
    238239        "?[?]", "...",
    239240        // monadic
  • src/Parser/LinkageSpec.h

    re0a653d r33218c6  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:24:28 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul  7 11:03:00 2017
    13 // Update Count     : 13
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 22 09:32:16 2017
     13// Update Count     : 14
    1414//
    1515
    16 #ifndef LINKAGESPEC_H
    17 #define LINKAGESPEC_H
     16#pragma once
    1817
    1918#include <string>
     
    7877};
    7978
    80 #endif // LINKAGESPEC_H
    81 
    8279// Local Variables: //
    8380// tab-width: 4 //
  • src/Parser/ParseNode.h

    re0a653d r33218c6  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jun 12 13:00:00 2017
    13 // Update Count     : 779
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 22 09:32:30 2017
     13// Update Count     : 786
    1414//
    1515
    16 #ifndef PARSENODE_H
    17 #define PARSENODE_H
     16#pragma once
    1817
    1918#include <string>
     
    141140};
    142141
     142// Must harmonize with OperName.
    143143enum class OperKinds {
    144144        // diadic
    145         SizeOf, AlignOf, OffsetOf, Plus, Minus, Mul, Div, Mod, Or, And,
     145        SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And,
    146146        BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
    147         Assign, AtAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
     147        Assign, AtAssn, ExpAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
    148148        Index, Range,
    149149        // monadic
     
    248248        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
    249249
     250        // Perhaps this would best fold into newAggragate.
     251        static DeclarationNode * newTreeStruct( Aggregate kind, const std::string * name, const std::string * parent, ExpressionNode * actuals, DeclarationNode * fields, bool body );
     252
    250253        DeclarationNode();
    251254        ~DeclarationNode();
     
    332335
    333336        static UniqueName anonymous;
     337
     338        // Temp to test TreeStruct
     339        const std::string * parent_name;
    334340}; // DeclarationNode
    335341
     
    443449std::ostream & operator<<( std::ostream & out, const ParseNode * node );
    444450
    445 #endif // PARSENODE_H
    446 
    447451// Local Variables: //
    448452// tab-width: 4 //
  • src/Parser/ParserTypes.h

    re0a653d r33218c6  
    1010// Created On       : Sat Sep 22 08:58:10 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 28 22:10:17 2017
    13 // Update Count     : 349
     12// Last Modified On : Sat Jul 22 09:33:28 2017
     13// Update Count     : 350
    1414//
    1515
    16 #ifndef PARSER_HH
    17 #define PARSER_HH
     16#pragma once
    1817
    1918int yylex();
     
    4241}; // Token
    4342
    44 #endif // PARSER_HH
    45 
    4643// Local Variables: //
    4744// tab-width: 4 //
  • src/Parser/TypeData.cc

    re0a653d r33218c6  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 15:28:00 2017
    13 // Update Count     : 564
     12// Last Modified On : Tus Jul 18 10:10:00 2017
     13// Update Count     : 566
    1414//
    1515
     
    6363                aggregate.fields = nullptr;
    6464                aggregate.body = false;
     65                aggregate.tagged = false;
     66                aggregate.parent = nullptr;
    6567                break;
    6668          case AggregateInst:
     
    121123                delete aggregate.actuals;
    122124                delete aggregate.fields;
     125                delete aggregate.parent;
    123126                // delete aggregate;
    124127                break;
     
    192195                newtype->aggregate.kind = aggregate.kind;
    193196                newtype->aggregate.body = aggregate.body;
     197                newtype->aggregate.tagged = aggregate.tagged;
     198                newtype->aggregate.parent = aggregate.parent ? new string( *aggregate.parent ) : nullptr;
    194199                break;
    195200          case AggregateInst:
     
    449454          case TypeData::Builtin:
    450455                if(td->builtintype == DeclarationNode::Zero) {
    451                         return new ZeroType( emptyQualifiers );
     456                        return new ZeroType( noQualifiers );
    452457                }
    453458                else if(td->builtintype == DeclarationNode::One) {
    454                         return new OneType( emptyQualifiers );
     459                        return new OneType( noQualifiers );
    455460                }
    456461                else {
     
    619624        switch ( td->aggregate.kind ) {
    620625          case DeclarationNode::Struct:
     626                if ( td->aggregate.tagged ) {
     627                        at = new StructDecl( *td->aggregate.name, td->aggregate.parent, attributes, linkage );
     628                        buildForall( td->aggregate.params, at->get_parameters() );
     629                        break;
     630                }
    621631          case DeclarationNode::Coroutine:
    622632          case DeclarationNode::Monitor:
  • src/Parser/TypeData.h

    re0a653d r33218c6  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:18:36 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 15:29:00 2017
    13 // Update Count     : 186
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 22 09:32:47 2017
     13// Update Count     : 188
    1414//
    1515
    16 #ifndef TYPEDATA_H
    17 #define TYPEDATA_H
     16#pragma once
    1817
    1918#include "ParseNode.h"
     
    3130                DeclarationNode * fields;
    3231                bool body;
     32
     33                bool tagged;
     34                const std::string * parent;
    3335        };
    3436
     
    113115void buildKRFunction( const TypeData::Function_t & function );
    114116
    115 #endif // TYPEDATA_H
    116 
    117117// Local Variables: //
    118118// tab-width: 4 //
  • src/Parser/TypedefTable.h

    re0a653d r33218c6  
    1010// Created On       : Sat May 16 15:24:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 28 21:56:34 2017
    13 // Update Count     : 33
     12// Last Modified On : Sat Jul 22 09:33:14 2017
     13// Update Count     : 34
    1414//
    1515
    16 #ifndef TYPEDEFTABLE_H
    17 #define TYPEDEFTABLE_H
     16#pragma once
    1817
    1918#include <map>
     
    9190};
    9291
    93 #endif // TYPEDEFTABLE_H
    94 
    9592// Local Variables: //
    9693// tab-width: 4 //
  • src/Parser/lex.ll

    re0a653d r33218c6  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Tue Jul 11 21:30:51 2017
    13  * Update Count     : 534
     12 * Last Modified On : Mon Jul 24 08:27:23 2017
     13 * Update Count     : 545
    1414 */
    1515
     
    125125op_unary {op_unary_only}|{op_unary_binary}|{op_unary_pre_post}
    126126
    127 op_binary_only "/"|"%"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"&="|"|="|"^="|"<<="|">>="
     127op_binary_only "/"|"%"|"\\"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"\\="|"&="|"|="|"^="|"<<="|">>="
    128128op_binary_over {op_unary_binary}|{op_binary_only}
    129129                                // op_binary_not_over "?"|"->"|"."|"&&"|"||"|"@="
     
    136136
    137137%%
    138                                    /* line directives */
     138                                /* line directives */
    139139^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" {
    140140        /* " stop highlighting */
     
    232232int                             { KEYWORD_RETURN(INT); }
    233233__int128                { KEYWORD_RETURN(INT); }                                // GCC
     234__int128_t              { KEYWORD_RETURN(INT); }                                // GCC
    234235__label__               { KEYWORD_RETURN(LABEL); }                              // GCC
    235236long                    { KEYWORD_RETURN(LONG); }
     
    266267__typeof                { KEYWORD_RETURN(TYPEOF); }                             // GCC
    267268__typeof__              { KEYWORD_RETURN(TYPEOF); }                             // GCC
     269__uint128_t             { KEYWORD_RETURN(INT); }                                // GCC
    268270union                   { KEYWORD_RETURN(UNION); }
    269271unsigned                { KEYWORD_RETURN(UNSIGNED); }
    270272__builtin_va_list { KEYWORD_RETURN(VALIST); }                   // GCC
     273virtual                 { KEYWORD_RETURN(VIRTUAL); }                    // CFA
    271274void                    { KEYWORD_RETURN(VOID); }
    272275volatile                { KEYWORD_RETURN(VOLATILE); }
     
    274277__volatile__    { KEYWORD_RETURN(VOLATILE); }                   // GCC
    275278while                   { KEYWORD_RETURN(WHILE); }
     279with                    { KEYWORD_RETURN(WITH); }                               // CFA
    276280zero_t                  { NUMERIC_RETURN(ZERO_T); }                             // CFA
    277281
     
    336340"-"                             { ASCIIOP_RETURN(); }
    337341"*"                             { ASCIIOP_RETURN(); }
     342"\\"                    { ASCIIOP_RETURN(); }                                   // CFA, exponentiation
    338343"/"                             { ASCIIOP_RETURN(); }
    339344"%"                             { ASCIIOP_RETURN(); }
     
    360365"+="                    { NAMEDOP_RETURN(PLUSassign); }
    361366"-="                    { NAMEDOP_RETURN(MINUSassign); }
     367"\\="                   { NAMEDOP_RETURN(EXPassign); }                  // CFA, exponentiation
    362368"*="                    { NAMEDOP_RETURN(MULTassign); }
    363369"/="                    { NAMEDOP_RETURN(DIVassign); }
  • src/Parser/parser.yy

    re0a653d r33218c6  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 11 13:39:00 2017
    13 // Update Count     : 2416
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jul 24 09:01:14 2017
     13// Update Count     : 2463
    1414//
    1515
     
    118118%token RESTRICT                                                                                 // C99
    119119%token ATOMIC                                                                                   // C11
    120 %token FORALL LVALUE MUTEX                                                              // CFA
    121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T
     120%token FORALL LVALUE MUTEX VIRTUAL                                              // CFA
     121%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
     122%token BOOL COMPLEX IMAGINARY                                                   // C99
     123%token ZERO_T ONE_T                                                                             // CFA
    122124%token VALIST                                                                                   // GCC
    123 %token BOOL COMPLEX IMAGINARY                                                   // C99
    124125%token TYPEOF LABEL                                                                             // GCC
    125126%token ENUM STRUCT UNION
     
    129130%token ATTRIBUTE EXTENSION                                                              // GCC
    130131%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    131 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT        // CFA
     132%token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH   // CFA
    132133%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    133134%token ALIGNAS ALIGNOF GENERIC STATICASSERT                             // C11
     
    151152%token ELLIPSIS                                                                                 // ...
    152153
    153 %token MULTassign       DIVassign       MODassign                               // *=   /=      %=/
     154%token EXPassign        MULTassign      DIVassign       MODassign       // \=   *=      /=      %=
    154155%token PLUSassign       MINUSassign                                                     // +=   -=
    155156%token LSassign         RSassign                                                        // <<=  >>=
     
    168169%type<op> ptrref_operator                               unary_operator                          assignment_operator
    169170%type<en> primary_expression                    postfix_expression                      unary_expression
    170 %type<en> cast_expression                               multiplicative_expression       additive_expression                     shift_expression
    171 %type<en> relational_expression                 equality_expression                     AND_expression                          exclusive_OR_expression
    172 %type<en> inclusive_OR_expression               logical_AND_expression          logical_OR_expression           conditional_expression
    173 %type<en> constant_expression                   assignment_expression           assignment_expression_opt
     171%type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
     172%type<en> shift_expression                              relational_expression           equality_expression
     173%type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
     174%type<en> logical_AND_expression                logical_OR_expression
     175%type<en> conditional_expression                constant_expression                     assignment_expression           assignment_expression_opt
    174176%type<en> comma_expression                              comma_expression_opt
    175 %type<en> argument_expression_list              argument_expression                     assignment_opt
     177%type<en> argument_expression_list              argument_expression                     default_initialize_opt
    176178%type<fctl> for_control_expression
    177179%type<en> subrange
     
    184186// statements
    185187%type<sn> labeled_statement                             compound_statement                      expression_statement            selection_statement
    186 %type<sn> iteration_statement                   jump_statement                          exception_statement                     asm_statement
     188%type<sn> iteration_statement                   jump_statement
     189%type<sn> with_statement                                exception_statement                     asm_statement
    187190%type<sn> fall_through_opt                              fall_through
    188191%type<sn> statement                                             statement_list
    189192%type<sn> block_item_list                               block_item
    190 %type<sn> case_clause
     193%type<sn> with_clause_opt
    191194%type<en> case_value
    192 %type<sn> case_value_list                               case_label                                      case_label_list
     195%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    193196%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    194197%type<sn> /* handler_list */                    handler_clause                          finally_clause
     
    568571        | '(' type_no_function ')' cast_expression
    569572                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     573                // VIRTUAL cannot be opt because of look ahead issues
     574        | '(' VIRTUAL ')' cast_expression
     575                { $$ = new ExpressionNode( build_cast( nullptr, $4 ) ); }
     576        | '(' VIRTUAL type_no_function ')' cast_expression
     577                { $$ = new ExpressionNode( build_cast( $3, $5 ) ); }
    570578//      | '(' type_no_function ')' tuple
    571579//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    572580        ;
    573581
     582exponential_expression:
     583        cast_expression
     584        | exponential_expression '\\' cast_expression
     585                { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); }
     586        ;
     587
    574588multiplicative_expression:
    575         cast_expression
    576         | multiplicative_expression '*' cast_expression
     589        exponential_expression
     590        | multiplicative_expression '*' exponential_expression
    577591                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
    578         | multiplicative_expression '/' cast_expression
     592        | multiplicative_expression '/' exponential_expression
    579593                { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
    580         | multiplicative_expression '%' cast_expression
     594        | multiplicative_expression '%' exponential_expression
    581595                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
    582596        ;
     
    677691        '='                                                                                     { $$ = OperKinds::Assign; }
    678692        | ATassign                                                                      { $$ = OperKinds::AtAssn; }
     693        | EXPassign                                                                     { $$ = OperKinds::ExpAssn; }
    679694        | MULTassign                                                            { $$ = OperKinds::MulAssn; }
    680695        | DIVassign                                                                     { $$ = OperKinds::DivAssn; }
     
    729744        | iteration_statement
    730745        | jump_statement
     746        | with_statement
    731747        | exception_statement
    732748        | asm_statement
     
    936952        ;
    937953
     954with_statement:
     955        WITH '(' tuple_expression_list ')' compound_statement
     956                { $$ = (StatementNode *)0; }                                    // FIX ME
     957        ;
     958
    938959exception_statement:
    939960        TRY compound_statement handler_clause
     
    965986                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); }
    966987
    967         | handler_key '(' push push exception_declaration pop ')' compound_statement pop
    968                 { $$ = new StatementNode( build_catch( $1, $5, nullptr, $8 ) ); }
    969         | handler_clause handler_key '(' push push exception_declaration pop ')' compound_statement pop
    970                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $9 ) ) ); }
     988        | handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
     989                { $$ = new StatementNode( build_catch( $1, $5, nullptr, $9 ) ); }
     990        | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
     991                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $10 ) ) ); }
     992        ;
     993
     994handler_predicate_opt:
     995        //empty
     996        | ';' conditional_expression
    971997        ;
    972998
     
    14951521        | IMAGINARY                                                                                     // C99
    14961522                { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); }
    1497         | VALIST                                                                                        // GCC, __builtin_va_list
    1498                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    14991523        | ZERO_T
    15001524                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
    15011525        | ONE_T
    15021526                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
     1527        | VALIST                                                                                        // GCC, __builtin_va_list
     1528                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    15031529        ;
    15041530
     
    16601686        | aggregate_key attribute_list_opt typegen_name         // CFA
    16611687                { $$ = $3->addQualifiers( $2 ); }
     1688
     1689// Temp, testing TreeStruct
     1690    | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name
     1691        {
     1692            typedefTable.makeTypedef( *$4 );            // create typedef
     1693            if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $
     1694            forall = false;                             // reset
     1695        }
     1696      '{' field_declaration_list '}'
     1697        {
     1698            $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct,
     1699                $4, nullptr, nullptr, $7, true )->addQualifiers( $3 );
     1700        }
     1701    | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name TYPEDEFname
     1702        {
     1703            typedefTable.makeTypedef( *$4 );            // create typedef
     1704            if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $
     1705            forall = false;                             // reset
     1706        }
     1707      '{' field_declaration_list '}'
     1708        {
     1709            $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct,
     1710                $4, $5, nullptr, $8, true )->addQualifiers( $3 );
     1711        }
    16621712        ;
    16631713
     
    18381888cfa_parameter_declaration:                                                              // CFA, new & old style parameter declaration
    18391889        parameter_declaration
    1840         | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt
     1890        | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt
    18411891                { $$ = $1->addName( $2 ); }
    1842         | cfa_abstract_tuple identifier_or_type_name assignment_opt
     1892        | cfa_abstract_tuple identifier_or_type_name default_initialize_opt
    18431893                // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator).
    18441894                { $$ = $1->addName( $2 ); }
    1845         | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt
     1895        | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt
    18461896                { $$ = $2->addName( $3 )->addQualifiers( $1 ); }
    18471897        | cfa_function_specifier
     
    18601910parameter_declaration:
    18611911                // No SUE declaration in parameter list.
    1862         declaration_specifier_nobody identifier_parameter_declarator assignment_opt
     1912        declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt
    18631913                {
    18641914                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    18651915                        $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr );
    18661916                }
    1867         | declaration_specifier_nobody type_parameter_redeclarator assignment_opt
     1917        | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt
    18681918                {
    18691919                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    18731923
    18741924abstract_parameter_declaration:
    1875         declaration_specifier_nobody assignment_opt
     1925        declaration_specifier_nobody default_initialize_opt
    18761926                { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); }
    1877         | declaration_specifier_nobody abstract_parameter_declarator assignment_opt
     1927        | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt
    18781928                { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); }
    18791929        ;
     
    22122262        ;
    22132263
     2264with_clause_opt:
     2265        // empty
     2266                { $$ = (StatementNode *)0; }                                    // FIX ME
     2267        | WITH '(' tuple_expression_list ')'
     2268                { $$ = (StatementNode *)0; }                                    // FIX ME
     2269        ;
     2270
    22142271function_definition:
    2215         cfa_function_declaration compound_statement                     // CFA
     2272        cfa_function_declaration with_clause_opt compound_statement     // CFA
    22162273                {
    22172274                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22182275                        typedefTable.leaveScope();
    2219                         $$ = $1->addFunctionBody( $2 );
    2220                 }
    2221         | declaration_specifier function_declarator compound_statement
     2276                        $$ = $1->addFunctionBody( $3 );
     2277                }
     2278        | declaration_specifier function_declarator with_clause_opt compound_statement
    22222279                {
    22232280                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22242281                        typedefTable.leaveScope();
    2225                         $$ = $2->addFunctionBody( $3 )->addType( $1 );
    2226                 }
    2227         | type_qualifier_list function_declarator compound_statement
     2282                        $$ = $2->addFunctionBody( $4 )->addType( $1 );
     2283                }
     2284        | type_qualifier_list function_declarator with_clause_opt compound_statement
    22282285                {
    22292286                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22302287                        typedefTable.leaveScope();
    2231                         $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
    2232                 }
    2233         | declaration_qualifier_list function_declarator compound_statement
     2288                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
     2289                }
     2290        | declaration_qualifier_list function_declarator with_clause_opt compound_statement
    22342291                {
    22352292                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22362293                        typedefTable.leaveScope();
    2237                         $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
    2238                 }
    2239         | declaration_qualifier_list type_qualifier_list function_declarator compound_statement
     2294                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
     2295                }
     2296        | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement
    22402297                {
    22412298                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22422299                        typedefTable.leaveScope();
    2243                         $$ = $3->addFunctionBody( $4 )->addQualifiers( $2 )->addQualifiers( $1 );
     2300                        $$ = $3->addFunctionBody( $5 )->addQualifiers( $2 )->addQualifiers( $1 );
    22442301                }
    22452302
    22462303                // Old-style K&R function definition, OBSOLESCENT (see 4)
    2247         | declaration_specifier KR_function_declarator push KR_declaration_list_opt compound_statement
     2304        | declaration_specifier KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22482305                {
    22492306                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22502307                        typedefTable.leaveScope();
    2251                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addType( $1 );
    2252                 }
    2253         | type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2308                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addType( $1 );
     2309                }
     2310        | type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22542311                {
    22552312                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22562313                        typedefTable.leaveScope();
    2257                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
     2314                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
    22582315                }
    22592316
    22602317                // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4)
    2261         | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2318        | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22622319                {
    22632320                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22642321                        typedefTable.leaveScope();
    2265                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
    2266                 }
    2267         | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2322                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
     2323                }
     2324        | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22682325                {
    22692326                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22702327                        typedefTable.leaveScope();
    2271                         $$ = $3->addOldDeclList( $5 )->addFunctionBody( $6 )->addQualifiers( $2 )->addQualifiers( $1 );
     2328                        $$ = $3->addOldDeclList( $5 )->addFunctionBody( $7 )->addQualifiers( $2 )->addQualifiers( $1 );
    22722329                }
    22732330        ;
     
    30313088        ;
    30323089
    3033 assignment_opt:
     3090default_initialize_opt:
    30343091        // empty
    30353092                { $$ = nullptr; }
  • src/Parser/parserutility.cc

    re0a653d r33218c6  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:30:39 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 28 22:11:32 2017
    13 // Update Count     : 7
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tus Jul 18 10:12:00 2017
     13// Update Count     : 8
    1414//
    1515
     
    2626        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    2727        comparison->get_args().push_back( orig );
    28         comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0", (unsigned long long int)0 ) ) );
     28        comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( noQualifiers ), "0", (unsigned long long int)0 ) ) );
    2929        return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    3030}
  • src/Parser/parserutility.h

    re0a653d r33218c6  
    1010// Created On       : Sat May 16 15:31:46 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 28 22:11:40 2017
    13 // Update Count     : 3
     12// Last Modified On : Sat Jul 22 09:32:58 2017
     13// Update Count     : 4
    1414//
    1515
    16 #ifndef PARSEUTILITY_H
    17 #define PARSEUTILITY_H
     16#pragma once
    1817
    1918#include "SynTree/SynTree.h"
    2019
    2120Expression *notZeroExpr( Expression *orig );
    22 
    23 #endif // PARSEUTILITY_H
    2421
    2522// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.