Changeset 9236060 for src/Parser
- Timestamp:
- Aug 14, 2017, 2:03:39 PM (8 years ago)
- 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:
- 74b007ba
- Parents:
- fd344aa (diff), 54cd58b0 (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. - Location:
- src/Parser
- Files:
-
- 13 edited
-
DeclarationNode.cc (modified) (3 diffs)
-
ExpressionNode.cc (modified) (11 diffs)
-
InitializerNode.cc (modified) (7 diffs)
-
LinkageSpec.h (modified) (2 diffs)
-
ParseNode.h (modified) (7 diffs)
-
ParserTypes.h (modified) (2 diffs)
-
TypeData.cc (modified) (8 diffs)
-
TypeData.h (modified) (3 diffs)
-
TypedefTable.h (modified) (2 diffs)
-
lex.ll (modified) (9 diffs)
-
parser.yy (modified) (22 diffs)
-
parserutility.cc (modified) (2 diffs)
-
parserutility.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rfd344aa r9236060 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:27:00 201713 // Update Count : 10 1912 // Last Modified On : Fri Jul 14 16:55:00 2017 13 // Update Count : 1020 14 14 // 15 15 … … 253 253 newnode->type->aggregate.fields = fields; 254 254 newnode->type->aggregate.body = body; 255 newnode->type->aggregate.tagged = false; 256 newnode->type->aggregate.parent = nullptr; 255 257 return newnode; 256 258 } // DeclarationNode::newAggregate … … 273 275 return newnode; 274 276 } // DeclarationNode::newEnumConstant 277 278 DeclarationNode * 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 275 291 276 292 DeclarationNode * DeclarationNode::newName( string * name ) { -
src/Parser/ExpressionNode.cc
rfd344aa r9236060 9 9 // Author : Rodolfo G. Esteves 10 10 // 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 14 // 15 16 #include <cassert> 17 #include <cctype> 18 #include <climits> 19 #include <cstdio> 20 #include <algorithm> 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 2 11:12:00 2017 13 // Update Count : 568 14 // 15 16 #include <climits> // access INT_MAX, UINT_MAX, LONG_MAX, ULONG_MAX, LLONG_MAX 21 17 #include <sstream> 22 18 … … 26 22 #include "SynTree/Expression.h" 27 23 #include "SynTree/Declaration.h" 28 #include "Common/UnimplementedError.h"29 24 #include "parserutility.h" 30 #include "Common/utility.h"31 25 32 26 using namespace std; … … 46 40 // type. 47 41 48 Type::Qualifiers emptyQualifiers;// no qualifiers on constants42 extern const Type::Qualifiers noQualifiers; // no qualifiers on constants 49 43 50 44 static inline bool checkU( char c ) { return c == 'u' || c == 'U'; } … … 55 49 static inline bool checkX( char c ) { return c == 'x' || c == 'X'; } 56 50 57 Expression * build_constantInteger( const std::string & str ) {51 Expression * build_constantInteger( const std::string & str ) { 58 52 static const BasicType::Kind kind[2][3] = { 59 53 { BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt }, … … 62 56 bool dec = true, Unsigned = false; // decimal, unsigned constant 63 57 int size; // 0 => int, 1 => long, 2 => long long 64 unsigned long long int v; // converted integral value58 unsigned long long int v; // converted integral value 65 59 size_t last = str.length() - 1; // last character of constant 66 60 Expression * ret; 61 62 // special constants 63 if ( str == "0" ) { 64 ret = new ConstantExpr( Constant( (Type *)new ZeroType( noQualifiers ), str, (unsigned long long int)0 ) ); 65 goto CLEANUP; 66 } // if 67 if ( str == "1" ) { 68 ret = new ConstantExpr( Constant( (Type *)new OneType( noQualifiers ), str, (unsigned long long int)1 ) ); 69 goto CLEANUP; 70 } // if 71 67 72 if ( str[0] == '0' ) { // octal/hex constant ? 68 73 dec = false; … … 118 123 } // if 119 124 120 Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str, v ) ); 125 ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) ); 126 CLEANUP: 121 127 delete &str; // created by lex 122 128 return ret; 123 129 } // build_constantInteger 124 130 125 Expression * build_constantFloat( const std::string & str ) {131 Expression * build_constantFloat( const std::string & str ) { 126 132 static const BasicType::Kind kind[2][3] = { 127 133 { BasicType::Float, BasicType::Double, BasicType::LongDouble }, … … 153 159 } // if 154 160 155 Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str, v ) );161 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) ); 156 162 delete &str; // created by lex 157 163 return ret; 158 164 } // build_constantFloat 159 165 160 Expression * 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] ) );166 Expression * build_constantChar( const std::string & str ) { 167 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) ); 162 168 delete &str; // created by lex 163 169 return ret; 164 170 } // build_constantChar 165 171 166 ConstantExpr * build_constantStr( const std::string & str ) {172 ConstantExpr * build_constantStr( const std::string & str ) { 167 173 // string should probably be a primitive type 168 ArrayType * at = new ArrayType( emptyQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),169 new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"'174 ArrayType * at = new ArrayType( noQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), 175 new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"' 170 176 false, false ); 171 // constant 0 is ignored for pure string value 172 ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) ); 177 ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) ); // constant 0 is ignored for pure string value 173 178 delete &str; // created by lex 174 179 return ret; 175 180 } // build_constantStr 176 177 Expression *build_constantZeroOne( const std::string & str ) {178 Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str,179 str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );180 delete &str; // created by lex181 return ret;182 } // build_constantChar183 181 184 182 Expression * build_field_name_FLOATINGconstant( const std::string & str ) { … … 209 207 } // build_field_name_fraction_constants 210 208 211 212 213 209 Expression * build_field_name_REALFRACTIONconstant( const std::string & str ) { 214 210 if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throw SemanticError( "invalid tuple index " + str ); … … 225 221 } // build_field_name_REALDECIMALconstant 226 222 227 NameExpr * build_varref( const string * name ) {228 NameExpr * expr = new NameExpr( *name, nullptr );223 NameExpr * build_varref( const string * name ) { 224 NameExpr * expr = new NameExpr( *name, nullptr ); 229 225 delete name; 230 226 return expr; 231 } 232 233 static const char *OperName[] = { 227 } // build_varref 228 229 230 static const char * OperName[] = { // must harmonize with OperKinds 234 231 // diadic 235 "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "? *?", "?/?", "?%?", "||", "&&",232 "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&", 236 233 "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?", 237 "?=?", "?@=?", "? *=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",234 "?=?", "?@=?", "?\\=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?", 238 235 "?[?]", "...", 239 236 // monadic 240 237 "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&" 241 }; 242 243 Expression * build_cast( DeclarationNode *decl_node, ExpressionNode *expr_node ) {244 Type * targetType = maybeMoveBuildType( decl_node );238 }; // OperName 239 240 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) { 241 Type * targetType = maybeMoveBuildType( decl_node ); 245 242 if ( dynamic_cast< VoidType * >( targetType ) ) { 246 243 delete targetType; … … 249 246 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType ); 250 247 } // if 251 } 252 253 Expression *build_fieldSel( ExpressionNode *expr_node, Expression *member ) { 254 UntypedMemberExpr *ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) ); 255 return ret; 256 } 257 258 Expression *build_pfieldSel( ExpressionNode *expr_node, Expression *member ) { 259 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 248 } // build_cast 249 250 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) { 251 Type * targetType = maybeMoveBuildType( decl_node ); 252 Expression * castArg = maybeMoveBuild< Expression >( expr_node ); 253 return new VirtualCastExpr( castArg, targetType ); 254 } // build_virtual_cast 255 256 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ) { 257 UntypedMemberExpr * ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) ); 258 return ret; 259 } // build_fieldSel 260 261 Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member ) { 262 UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) ); 260 263 deref->location = expr_node->location; 261 264 deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) ); 262 UntypedMemberExpr * ret = new UntypedMemberExpr( member, deref );263 return ret; 264 } 265 266 Expression * build_addressOf( ExpressionNode *expr_node ) {265 UntypedMemberExpr * ret = new UntypedMemberExpr( member, deref ); 266 return ret; 267 } // build_pfieldSel 268 269 Expression * build_addressOf( ExpressionNode * expr_node ) { 267 270 return new AddressExpr( maybeMoveBuild< Expression >(expr_node) ); 268 } 269 Expression *build_sizeOfexpr( ExpressionNode *expr_node ) { 271 } // build_addressOf 272 273 Expression * build_sizeOfexpr( ExpressionNode * expr_node ) { 270 274 return new SizeofExpr( maybeMoveBuild< Expression >(expr_node) ); 271 } 272 Expression *build_sizeOftype( DeclarationNode *decl_node ) { 275 } // build_sizeOfexpr 276 277 Expression * build_sizeOftype( DeclarationNode * decl_node ) { 273 278 return new SizeofExpr( maybeMoveBuildType( decl_node ) ); 274 } 275 Expression *build_alignOfexpr( ExpressionNode *expr_node ) { 279 } // build_sizeOftype 280 281 Expression * build_alignOfexpr( ExpressionNode * expr_node ) { 276 282 return new AlignofExpr( maybeMoveBuild< Expression >(expr_node) ); 277 } 278 Expression *build_alignOftype( DeclarationNode *decl_node ) { 283 } // build_alignOfexpr 284 285 Expression * build_alignOftype( DeclarationNode * decl_node ) { 279 286 return new AlignofExpr( maybeMoveBuildType( decl_node) ); 280 } 281 Expression *build_offsetOf( DeclarationNode *decl_node, NameExpr *member ) { 287 } // build_alignOftype 288 289 Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member ) { 282 290 Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() ); 283 291 delete member; 284 292 return ret; 285 } 286 287 Expression * build_and_or( ExpressionNode *expr_node1, ExpressionNode *expr_node2, bool kind ) {293 } // build_offsetOf 294 295 Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind ) { 288 296 return new LogicalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), notZeroExpr( maybeMoveBuild< Expression >(expr_node2) ), kind ); 289 } 290 291 Expression * build_unary_val( OperKinds op, ExpressionNode *expr_node ) {297 } // build_and_or 298 299 Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node ) { 292 300 std::list< Expression * > args; 293 301 args.push_back( maybeMoveBuild< Expression >(expr_node) ); 294 302 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 295 } 296 Expression *build_unary_ptr( OperKinds op, ExpressionNode *expr_node ) { 303 } // build_unary_val 304 305 Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node ) { 297 306 std::list< Expression * > args; 298 307 args.push_back( maybeMoveBuild< Expression >(expr_node) ); // xxx 299 308 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 300 } 301 Expression *build_binary_val( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) { 309 } // build_unary_ptr 310 311 Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) { 302 312 std::list< Expression * > args; 303 313 args.push_back( maybeMoveBuild< Expression >(expr_node1) ); 304 314 args.push_back( maybeMoveBuild< Expression >(expr_node2) ); 305 315 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 306 } 307 Expression *build_binary_ptr( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) { 316 } // build_binary_val 317 318 Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) { 308 319 std::list< Expression * > args; 309 320 args.push_back( maybeMoveBuild< Expression >(expr_node1) ); 310 321 args.push_back( maybeMoveBuild< Expression >(expr_node2) ); 311 322 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 312 } 313 314 Expression * build_cond( ExpressionNode *expr_node1, ExpressionNode *expr_node2, ExpressionNode *expr_node3 ) {323 } // build_binary_ptr 324 325 Expression * build_cond( ExpressionNode * expr_node1, ExpressionNode * expr_node2, ExpressionNode * expr_node3 ) { 315 326 return new ConditionalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), maybeMoveBuild< Expression >(expr_node2), maybeMoveBuild< Expression >(expr_node3) ); 316 } 317 318 Expression * build_comma( ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {327 } // build_cond 328 329 Expression * build_comma( ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) { 319 330 return new CommaExpr( maybeMoveBuild< Expression >(expr_node1), maybeMoveBuild< Expression >(expr_node2) ); 320 } 321 322 Expression * build_attrexpr( NameExpr *var, ExpressionNode * expr_node ) {331 } // build_comma 332 333 Expression * build_attrexpr( NameExpr * var, ExpressionNode * expr_node ) { 323 334 return new AttrExpr( var, maybeMoveBuild< Expression >(expr_node) ); 324 } 325 Expression *build_attrtype( NameExpr *var, DeclarationNode * decl_node ) { 335 } // build_attrexpr 336 337 Expression * build_attrtype( NameExpr * var, DeclarationNode * decl_node ) { 326 338 return new AttrExpr( var, maybeMoveBuildType( decl_node ) ); 327 } 328 329 Expression * build_tuple( ExpressionNode * expr_node ) {339 } // build_attrtype 340 341 Expression * build_tuple( ExpressionNode * expr_node ) { 330 342 std::list< Expression * > exprs; 331 343 buildMoveList( expr_node, exprs ); 332 344 return new UntypedTupleExpr( exprs );; 333 } 334 335 Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node ) {345 } // build_tuple 346 347 Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node ) { 336 348 std::list< Expression * > args; 337 349 buildMoveList( expr_node, args ); 338 350 return new UntypedExpr( maybeMoveBuild< Expression >(function), args, nullptr ); 339 } 340 341 Expression * build_range( ExpressionNode * low, ExpressionNode *high ) {351 } // build_func 352 353 Expression * build_range( ExpressionNode * low, ExpressionNode * high ) { 342 354 return new RangeExpr( maybeMoveBuild< Expression >( low ), maybeMoveBuild< Expression >( high ) ); 343 } 344 345 Expression * build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) {355 } // build_range 356 357 Expression * build_asmexpr( ExpressionNode * inout, ConstantExpr * constraint, ExpressionNode * operand ) { 346 358 return new AsmExpr( maybeMoveBuild< Expression >( inout ), constraint, maybeMoveBuild< Expression >(operand) ); 347 } 348 349 Expression * build_valexpr( StatementNode *s ) {359 } // build_asmexpr 360 361 Expression * build_valexpr( StatementNode * s ) { 350 362 return new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(s) ) ); 351 } 352 Expression *build_typevalue( DeclarationNode *decl ) { 363 } // build_valexpr 364 365 Expression * build_typevalue( DeclarationNode * decl ) { 353 366 return new TypeExpr( maybeMoveBuildType( decl ) ); 354 } 355 356 Expression * build_compoundLiteral( DeclarationNode *decl_node, InitializerNode *kids ) {367 } // build_typevalue 368 369 Expression * build_compoundLiteral( DeclarationNode * decl_node, InitializerNode * kids ) { 357 370 Declaration * newDecl = maybeBuild< Declaration >(decl_node); // compound literal type 358 371 if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type … … 380 393 assert( false ); 381 394 } // if 382 } 395 } // build_compoundLiteral 383 396 384 397 // Local Variables: // -
src/Parser/InitializerNode.cc
rfd344aa r9236060 10 10 // Created On : Sat May 16 13:20:24 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Oct 1 23:09:51 201613 // Update Count : 2 112 // Last Modified On : Fri Jul 28 23:27:20 2017 13 // Update Count : 26 14 14 // 15 15 … … 22 22 #include "SynTree/Initializer.h" 23 23 24 InitializerNode::InitializerNode( ExpressionNode * _expr, bool aggrp, ExpressionNode *des )25 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( 0), maybeConstructed( true ) {24 InitializerNode::InitializerNode( ExpressionNode * _expr, bool aggrp, ExpressionNode * des ) 25 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) { 26 26 if ( aggrp ) 27 27 kids = dynamic_cast< InitializerNode * >( get_next() ); 28 28 29 if ( kids != 0)30 set_last( 0);31 } 29 if ( kids ) 30 set_last( nullptr ); 31 } // InitializerNode::InitializerNode 32 32 33 InitializerNode::InitializerNode( InitializerNode * init, bool aggrp, ExpressionNode *des )34 : expr( 0 ), aggregate( aggrp ), designator( des ), kids( 0), maybeConstructed( true ) {35 if ( init != 0)33 InitializerNode::InitializerNode( InitializerNode * init, bool aggrp, ExpressionNode * des ) 34 : expr( nullptr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ) { 35 if ( init ) 36 36 set_last( init ); 37 37 … … 39 39 kids = dynamic_cast< InitializerNode * >( get_next() ); 40 40 41 if ( kids != 0)42 set_next( 0);43 } 41 if ( kids ) 42 set_next( nullptr ); 43 } // InitializerNode::InitializerNode 44 44 45 45 InitializerNode::~InitializerNode() { … … 47 47 delete designator; 48 48 delete kids; 49 } 49 } // InitializerNode::~InitializerNode 50 50 51 51 void InitializerNode::print( std::ostream &os, int indent ) const { 52 52 os << std::string( indent, ' ' ) << "Initializer expression" << std::endl; 53 } 53 } // InitializerNode::print 54 54 55 55 void InitializerNode::printOneLine( std::ostream &os ) const { 56 56 if ( ! aggregate ) { 57 if ( designator != 0) {57 if ( designator ) { 58 58 os << "designated by: ("; 59 59 ExpressionNode *curdes = designator; 60 while ( curdes != 0) {60 while ( curdes != nullptr) { 61 61 curdes->printOneLine(os); 62 62 curdes = (ExpressionNode *)(curdes->get_next()); … … 65 65 os << ")"; 66 66 } // if 67 if ( expr ) expr->printOneLine( os);67 if ( expr ) expr->printOneLine( os ); 68 68 } else { // It's an aggregate 69 69 os << "[--"; 70 if ( next_init() != 0)71 next_init()->printOneLine( os);70 if ( next_init() != nullptr ) 71 next_init()->printOneLine( os ); 72 72 if (aggregate) os << "--]"; 73 73 } // if … … 76 76 if ( (moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) ) { 77 77 moreInit->printOneLine( os ); 78 } 79 } 78 } // if 79 } // InitializerNode::printOneLine 80 80 81 Initializer * InitializerNode::build() const {81 Initializer * InitializerNode::build() const { 82 82 if ( aggregate ) { 83 83 // steal designators from children … … 93 93 return new ListInit( initlist, designlist, maybeConstructed ); 94 94 } else { 95 if ( get_expression() != 0) {95 if ( get_expression() ) { 96 96 return new SingleInit( maybeBuild< Expression >( get_expression() ), maybeConstructed ); 97 } 97 } // if 98 98 } // if 99 return 0;100 } 99 return nullptr; 100 } // InitializerNode::build 101 101 102 102 // Local Variables: // -
src/Parser/LinkageSpec.h
rfd344aa r9236060 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:24:28 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Jul 7 11:03:00201713 // Update Count : 1 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:32:16 2017 13 // Update Count : 14 14 14 // 15 15 16 #ifndef LINKAGESPEC_H 17 #define LINKAGESPEC_H 16 #pragma once 18 17 19 18 #include <string> … … 78 77 }; 79 78 80 #endif // LINKAGESPEC_H81 82 79 // Local Variables: // 83 80 // tab-width: 4 // -
src/Parser/ParseNode.h
rfd344aa r9236060 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:28:16 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jun 12 13:00:00201713 // Update Count : 7 7911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 27 12:08:08 2017 13 // Update Count : 788 14 14 // 15 15 16 #ifndef PARSENODE_H 17 #define PARSENODE_H 16 #pragma once 18 17 19 18 #include <string> … … 141 140 }; 142 141 142 // Must harmonize with OperName. 143 143 enum class OperKinds { 144 144 // diadic 145 SizeOf, AlignOf, OffsetOf, Plus, Minus, Mul, Div, Mod, Or, And,145 SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And, 146 146 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, 148 148 Index, Range, 149 149 // monadic … … 159 159 Expression * build_constantFloat( const std::string &str ); 160 160 Expression * build_constantChar( const std::string &str ); 161 Expression * build_constantZeroOne( const std::string &str );162 161 ConstantExpr * build_constantStr( const std::string &str ); 163 162 Expression * build_field_name_FLOATINGconstant( const std::string & str ); … … 170 169 171 170 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 171 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 172 172 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ); 173 173 Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member ); … … 248 248 static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement 249 249 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 250 253 DeclarationNode(); 251 254 ~DeclarationNode(); … … 332 335 333 336 static UniqueName anonymous; 337 338 // Temp to test TreeStruct 339 const std::string * parent_name; 334 340 }; // DeclarationNode 335 341 … … 443 449 std::ostream & operator<<( std::ostream & out, const ParseNode * node ); 444 450 445 #endif // PARSENODE_H446 447 451 // Local Variables: // 448 452 // tab-width: 4 // -
src/Parser/ParserTypes.h
rfd344aa r9236060 10 10 // Created On : Sat Sep 22 08:58:10 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 28 22:10:17201713 // Update Count : 3 4912 // Last Modified On : Sat Jul 22 09:33:28 2017 13 // Update Count : 350 14 14 // 15 15 16 #ifndef PARSER_HH 17 #define PARSER_HH 16 #pragma once 18 17 19 18 int yylex(); … … 42 41 }; // Token 43 42 44 #endif // PARSER_HH45 46 43 // Local Variables: // 47 44 // tab-width: 4 // -
src/Parser/TypeData.cc
rfd344aa r9236060 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:28:00 201713 // Update Count : 56 412 // Last Modified On : Wed Aug 9 13:50:00 2017 13 // Update Count : 567 14 14 // 15 15 … … 64 64 aggregate.fields = nullptr; 65 65 aggregate.body = false; 66 aggregate.tagged = false; 67 aggregate.parent = nullptr; 66 68 break; 67 69 case AggregateInst: … … 123 125 delete aggregate.actuals; 124 126 delete aggregate.fields; 127 delete aggregate.parent; 125 128 // delete aggregate; 126 129 break; … … 195 198 newtype->aggregate.kind = aggregate.kind; 196 199 newtype->aggregate.body = aggregate.body; 200 newtype->aggregate.tagged = aggregate.tagged; 201 newtype->aggregate.parent = aggregate.parent ? new string( *aggregate.parent ) : nullptr; 197 202 break; 198 203 case AggregateInst: … … 454 459 case TypeData::Builtin: 455 460 if(td->builtintype == DeclarationNode::Zero) { 456 return new ZeroType( emptyQualifiers );461 return new ZeroType( noQualifiers ); 457 462 } 458 463 else if(td->builtintype == DeclarationNode::One) { 459 return new OneType( emptyQualifiers );464 return new OneType( noQualifiers ); 460 465 } 461 466 else { … … 635 640 switch ( td->aggregate.kind ) { 636 641 case DeclarationNode::Struct: 642 if ( td->aggregate.tagged ) { 643 at = new StructDecl( *td->aggregate.name, td->aggregate.parent, attributes, linkage ); 644 buildForall( td->aggregate.params, at->get_parameters() ); 645 break; 646 } 637 647 case DeclarationNode::Coroutine: 638 648 case DeclarationNode::Monitor: … … 754 764 } // buildAggInst 755 765 756 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs ) {766 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) { 757 767 assert( td->kind == TypeData::Symbolic ); 758 768 NamedTypeDecl * ret; 759 769 assert( td->base ); 760 770 if ( td->symbolic.isTypedef ) { 761 ret = new TypedefDecl( name, scs, typebuild( td->base ) );771 ret = new TypedefDecl( name, scs, typebuild( td->base ), linkage ); 762 772 } else { 763 773 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Any ); … … 823 833 return buildEnum( td, attributes ); 824 834 } else if ( td->kind == TypeData::Symbolic ) { 825 return buildSymbolic( td, name, scs );835 return buildSymbolic( td, name, scs, linkage ); 826 836 } else { 827 837 return (new ObjectDecl( name, scs, linkage, bitfieldWidth, typebuild( td ), init, attributes ))->set_asmName( asmName ); -
src/Parser/TypeData.h
rfd344aa r9236060 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:18:36 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Jun 28 15:29:00201713 // Update Count : 18 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:32:47 2017 13 // Update Count : 188 14 14 // 15 15 16 #ifndef TYPEDATA_H 17 #define TYPEDATA_H 16 #pragma once 18 17 19 18 #include "ParseNode.h" … … 31 30 DeclarationNode * fields; 32 31 bool body; 32 33 bool tagged; 34 const std::string * parent; 33 35 }; 34 36 … … 114 116 void buildKRFunction( const TypeData::Function_t & function ); 115 117 116 #endif // TYPEDATA_H117 118 118 // Local Variables: // 119 119 // tab-width: 4 // -
src/Parser/TypedefTable.h
rfd344aa r9236060 10 10 // Created On : Sat May 16 15:24:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 28 21:56:34 201713 // Update Count : 3 312 // Last Modified On : Sat Jul 22 09:33:14 2017 13 // Update Count : 34 14 14 // 15 15 16 #ifndef TYPEDEFTABLE_H 17 #define TYPEDEFTABLE_H 16 #pragma once 18 17 19 18 #include <map> … … 91 90 }; 92 91 93 #endif // TYPEDEFTABLE_H94 95 92 // Local Variables: // 96 93 // tab-width: 4 // -
src/Parser/lex.ll
rfd344aa r9236060 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Jul 12 18:04:44201713 * Update Count : 5 3512 * Last Modified On : Thu Jul 27 21:46:06 2017 13 * Update Count : 550 14 14 */ 15 15 16 16 %option yylineno 17 %option noyywrap 17 18 %option nounput 18 19 … … 125 126 op_unary {op_unary_only}|{op_unary_binary}|{op_unary_pre_post} 126 127 127 op_binary_only "/"|"%"|" ^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"&="|"|="|"^="|"<<="|">>="128 op_binary_only "/"|"%"|"\\"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"\\="|"&="|"|="|"^="|"<<="|">>=" 128 129 op_binary_over {op_unary_binary}|{op_binary_only} 129 130 // op_binary_not_over "?"|"->"|"."|"&&"|"||"|"@=" … … 136 137 137 138 %% 138 /* line directives */139 /* line directives */ 139 140 ^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" { 140 141 /* " stop highlighting */ … … 232 233 int { KEYWORD_RETURN(INT); } 233 234 __int128 { KEYWORD_RETURN(INT); } // GCC 235 __int128_t { KEYWORD_RETURN(INT); } // GCC 234 236 __label__ { KEYWORD_RETURN(LABEL); } // GCC 235 237 long { KEYWORD_RETURN(LONG); } … … 265 267 __typeof { KEYWORD_RETURN(TYPEOF); } // GCC 266 268 __typeof__ { KEYWORD_RETURN(TYPEOF); } // GCC 269 __uint128_t { KEYWORD_RETURN(INT); } // GCC 267 270 union { KEYWORD_RETURN(UNION); } 268 271 unsigned { KEYWORD_RETURN(UNSIGNED); } 269 272 __builtin_va_list { KEYWORD_RETURN(VALIST); } // GCC 273 virtual { KEYWORD_RETURN(VIRTUAL); } // CFA 270 274 void { KEYWORD_RETURN(VOID); } 271 275 volatile { KEYWORD_RETURN(VOLATILE); } … … 284 288 285 289 /* numeric constants */ 286 "0" { NUMERIC_RETURN(ZERO); } // CFA287 "1" { NUMERIC_RETURN(ONE); } // CFA288 290 {decimal_constant} { NUMERIC_RETURN(INTEGERconstant); } 289 291 {octal_constant} { NUMERIC_RETURN(INTEGERconstant); } … … 336 338 "-" { ASCIIOP_RETURN(); } 337 339 "*" { ASCIIOP_RETURN(); } 340 "\\" { ASCIIOP_RETURN(); } // CFA, exponentiation 338 341 "/" { ASCIIOP_RETURN(); } 339 342 "%" { ASCIIOP_RETURN(); } … … 360 363 "+=" { NAMEDOP_RETURN(PLUSassign); } 361 364 "-=" { NAMEDOP_RETURN(MINUSassign); } 365 "\\=" { NAMEDOP_RETURN(EXPassign); } // CFA, exponentiation 362 366 "*=" { NAMEDOP_RETURN(MULTassign); } 363 367 "/=" { NAMEDOP_RETURN(DIVassign); } … … 414 418 415 419 /* unknown characters */ 416 . { printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno); }420 . { printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno); } 417 421 418 422 %% -
src/Parser/parser.yy
rfd344aa r9236060 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Jul 12 18:23:36201713 // Update Count : 24 2611 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 4 13:33:00 2017 13 // Update Count : 2475 14 14 // 15 15 … … 118 118 %token RESTRICT // C99 119 119 %token ATOMIC // C11 120 %token FORALL MUTEX // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T 120 %token FORALL 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 122 124 %token VALIST // GCC 123 %token BOOL COMPLEX IMAGINARY // C99124 125 %token TYPEOF LABEL // GCC 125 126 %token ENUM STRUCT UNION … … 141 142 // converted into the tuple index (.)(1). e.g., 3.x 142 143 %token<tok> REALDECIMALconstant REALFRACTIONconstant FLOATINGconstant 143 %token<tok> ZERO ONE // CFA144 144 145 145 // multi-character operators … … 151 151 %token ELLIPSIS // ... 152 152 153 %token MULTassign DIVassign MODassign // *= /= %=/153 %token EXPassign MULTassign DIVassign MODassign // \= *= /= %= 154 154 %token PLUSassign MINUSassign // += -= 155 155 %token LSassign RSassign // <<= >>= … … 158 158 %token ATassign // @= 159 159 160 %type<tok> identifier no_attr_identifier zero_one160 %type<tok> identifier no_attr_identifier 161 161 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name attr_name 162 162 %type<constant> string_literal … … 168 168 %type<op> ptrref_operator unary_operator assignment_operator 169 169 %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 170 %type<en> cast_expression exponential_expression multiplicative_expression additive_expression 171 %type<en> shift_expression relational_expression equality_expression 172 %type<en> AND_expression exclusive_OR_expression inclusive_OR_expression 173 %type<en> logical_AND_expression logical_OR_expression 174 %type<en> conditional_expression constant_expression assignment_expression assignment_expression_opt 174 175 %type<en> comma_expression comma_expression_opt 175 %type<en> argument_expression_list argument_expression assignment_opt176 %type<en> argument_expression_list argument_expression default_initialize_opt 176 177 %type<fctl> for_control_expression 177 178 %type<en> subrange … … 181 182 %type<en> asm_clobbers_list_opt 182 183 %type<flag> asm_volatile_opt 184 %type<en> handler_predicate_opt 183 185 184 186 // statements … … 358 360 ; 359 361 360 zero_one: // CFA361 ZERO362 | ONE363 ;364 365 362 string_literal: 366 363 string_literal_list { $$ = build_constantStr( *$1 ); } … … 382 379 IDENTIFIER // typedef name cannot be used as a variable name 383 380 { $$ = new ExpressionNode( build_varref( $1 ) ); } 384 | zero_one385 { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); }386 381 | tuple 387 382 | '(' comma_expression ')' … … 483 478 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); 484 479 } 485 | zero_one fraction_constants486 {487 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );488 }489 480 ; 490 481 … … 537 528 | ALIGNOF unary_expression // GCC, variable alignment 538 529 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); } 539 | ALIGNOF '(' type_no_function ')' // GCC, type alignment530 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 540 531 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); } 541 532 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')' … … 569 560 | '(' type_no_function ')' cast_expression 570 561 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 562 // VIRTUAL cannot be opt because of look ahead issues 563 | '(' VIRTUAL ')' cast_expression 564 { $$ = new ExpressionNode( build_virtual_cast( nullptr, $4 ) ); } 565 | '(' VIRTUAL type_no_function ')' cast_expression 566 { $$ = new ExpressionNode( build_virtual_cast( $3, $5 ) ); } 571 567 // | '(' type_no_function ')' tuple 572 568 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 573 569 ; 574 570 571 exponential_expression: 572 cast_expression 573 | exponential_expression '\\' cast_expression 574 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); } 575 ; 576 575 577 multiplicative_expression: 576 cast_expression577 | multiplicative_expression '*' cast_expression578 exponential_expression 579 | multiplicative_expression '*' exponential_expression 578 580 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); } 579 | multiplicative_expression '/' cast_expression581 | multiplicative_expression '/' exponential_expression 580 582 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); } 581 | multiplicative_expression '%' cast_expression583 | multiplicative_expression '%' exponential_expression 582 584 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); } 583 585 ; … … 678 680 '=' { $$ = OperKinds::Assign; } 679 681 | ATassign { $$ = OperKinds::AtAssn; } 682 | EXPassign { $$ = OperKinds::ExpAssn; } 680 683 | MULTassign { $$ = OperKinds::MulAssn; } 681 684 | DIVassign { $$ = OperKinds::DivAssn; } … … 939 942 940 943 with_statement: 941 WITH identifier_listcompound_statement944 WITH '(' tuple_expression_list ')' compound_statement 942 945 { $$ = (StatementNode *)0; } // FIX ME 943 946 ; … … 966 969 967 970 handler_clause: 968 // TEMPORARY, TEST EXCEPTIONS 969 handler_key '(' push push INTEGERconstant pop ')' compound_statement pop 970 { $$ = new StatementNode( build_catch( $1, nullptr, new ExpressionNode( build_constantInteger( *$5 ) ), $8 ) ); } 971 | handler_clause handler_key '(' push push INTEGERconstant pop ')' compound_statement pop 972 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); } 973 974 | handler_key '(' push push exception_declaration pop ')' compound_statement pop 975 { $$ = new StatementNode( build_catch( $1, $5, nullptr, $8 ) ); } 976 | handler_clause handler_key '(' push push exception_declaration pop ')' compound_statement pop 977 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $9 ) ) ); } 971 handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 972 { $$ = new StatementNode( build_catch( $1, $5, $7, $9 ) ); } 973 | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 974 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, $8, $10 ) ) ); } 975 ; 976 977 handler_predicate_opt: 978 //empty 979 { $$ = nullptr; } 980 | ';' conditional_expression 981 { $$ = $2; } 978 982 ; 979 983 … … 1500 1504 | IMAGINARY // C99 1501 1505 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1502 | VALIST // GCC, __builtin_va_list1503 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }1504 1506 | ZERO_T 1505 1507 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1506 1508 | ONE_T 1507 1509 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1510 | VALIST // GCC, __builtin_va_list 1511 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1508 1512 ; 1509 1513 … … 1843 1847 cfa_parameter_declaration: // CFA, new & old style parameter declaration 1844 1848 parameter_declaration 1845 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt1849 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt 1846 1850 { $$ = $1->addName( $2 ); } 1847 | cfa_abstract_tuple identifier_or_type_name assignment_opt1851 | cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1848 1852 // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator). 1849 1853 { $$ = $1->addName( $2 ); } 1850 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt1854 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1851 1855 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 1852 1856 | cfa_function_specifier … … 1865 1869 parameter_declaration: 1866 1870 // No SUE declaration in parameter list. 1867 declaration_specifier_nobody identifier_parameter_declarator assignment_opt1871 declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt 1868 1872 { 1869 1873 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1870 1874 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1871 1875 } 1872 | declaration_specifier_nobody type_parameter_redeclarator assignment_opt1876 | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt 1873 1877 { 1874 1878 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1878 1882 1879 1883 abstract_parameter_declaration: 1880 declaration_specifier_nobody assignment_opt1884 declaration_specifier_nobody default_initialize_opt 1881 1885 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1882 | declaration_specifier_nobody abstract_parameter_declarator assignment_opt1886 | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt 1883 1887 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1884 1888 ; … … 1924 1928 | '=' initializer 1925 1929 { $$ = $2; } 1930 | '=' VOID 1931 { $$ = nullptr; } 1926 1932 | ATassign initializer 1927 1933 { $$ = $2->set_maybeConstructed( false ); } … … 2220 2226 // empty 2221 2227 { $$ = (StatementNode *)0; } // FIX ME 2222 | WITH identifier_list2228 | WITH '(' tuple_expression_list ')' 2223 2229 { $$ = (StatementNode *)0; } // FIX ME 2224 2230 ; … … 3043 3049 ; 3044 3050 3045 assignment_opt:3051 default_initialize_opt: 3046 3052 // empty 3047 3053 { $$ = nullptr; } -
src/Parser/parserutility.cc
rfd344aa r9236060 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:30:39 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Jun 28 22:11:32201713 // Update Count : 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Tus Jul 18 10:12:00 2017 13 // Update Count : 8 14 14 // 15 15 … … 26 26 UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) ); 27 27 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 ) ) ); 29 29 return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 30 30 } -
src/Parser/parserutility.h
rfd344aa r9236060 10 10 // Created On : Sat May 16 15:31:46 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 28 22:11:40201713 // Update Count : 312 // Last Modified On : Sat Jul 22 09:32:58 2017 13 // Update Count : 4 14 14 // 15 15 16 #ifndef PARSEUTILITY_H 17 #define PARSEUTILITY_H 16 #pragma once 18 17 19 18 #include "SynTree/SynTree.h" 20 19 21 20 Expression *notZeroExpr( Expression *orig ); 22 23 #endif // PARSEUTILITY_H24 21 25 22 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.