Changeset 33218c6 for src/Parser
- Timestamp:
- Jul 26, 2017, 12:19:41 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:
- 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. - Location:
- src/Parser
- Files:
-
- 12 edited
-
DeclarationNode.cc (modified) (3 diffs)
-
ExpressionNode.cc (modified) (8 diffs)
-
LinkageSpec.h (modified) (2 diffs)
-
ParseNode.h (modified) (5 diffs)
-
ParserTypes.h (modified) (2 diffs)
-
TypeData.cc (modified) (6 diffs)
-
TypeData.h (modified) (3 diffs)
-
TypedefTable.h (modified) (2 diffs)
-
lex.ll (modified) (8 diffs)
-
parser.yy (modified) (18 diffs)
-
parserutility.cc (modified) (2 diffs)
-
parserutility.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
re0a653d r33218c6 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
re0a653d r33218c6 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:17:07 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Jun 28 21:08:15201713 // Update Count : 5 4211 // Last Modified By : Andrew Beach 12 // Last Modified On : Tus Jul 18 10:08:00 2017 13 // Update Count : 550 14 14 // 15 15 … … 46 46 // type. 47 47 48 Type::Qualifiers emptyQualifiers; // no qualifiers on constants48 Type::Qualifiers noQualifiers; // no qualifiers on constants 49 49 50 50 static inline bool checkU( char c ) { return c == 'u' || c == 'U'; } … … 118 118 } // if 119 119 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 ) ); 121 121 delete &str; // created by lex 122 122 return ret; … … 153 153 } // if 154 154 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 ) ); 156 156 delete &str; // created by lex 157 157 return ret; … … 159 159 160 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] ) );161 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) ); 162 162 delete &str; // created by lex 163 163 return ret; … … 166 166 ConstantExpr *build_constantStr( const std::string & str ) { 167 167 // 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 ), 169 169 new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"' 170 170 false, false ); … … 176 176 177 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,178 Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( noQualifiers ) : (Type*)new OneType( noQualifiers ), str, 179 179 str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) ); 180 180 delete &str; // created by lex … … 231 231 } 232 232 233 // Must harmonize with OperKinds. 233 234 static const char *OperName[] = { 234 235 // diadic 235 "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "? *?", "?/?", "?%?", "||", "&&",236 "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&", 236 237 "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?", 237 "?=?", "?@=?", "? *=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",238 "?=?", "?@=?", "?\\=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?", 238 239 "?[?]", "...", 239 240 // monadic -
src/Parser/LinkageSpec.h
re0a653d r33218c6 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
re0a653d r33218c6 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:00 201713 // Update Count : 7 7911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:32:30 2017 13 // Update Count : 786 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 … … 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
re0a653d r33218c6 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
re0a653d r33218c6 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 : Tus Jul 18 10:10:00 2017 13 // Update Count : 566 14 14 // 15 15 … … 63 63 aggregate.fields = nullptr; 64 64 aggregate.body = false; 65 aggregate.tagged = false; 66 aggregate.parent = nullptr; 65 67 break; 66 68 case AggregateInst: … … 121 123 delete aggregate.actuals; 122 124 delete aggregate.fields; 125 delete aggregate.parent; 123 126 // delete aggregate; 124 127 break; … … 192 195 newtype->aggregate.kind = aggregate.kind; 193 196 newtype->aggregate.body = aggregate.body; 197 newtype->aggregate.tagged = aggregate.tagged; 198 newtype->aggregate.parent = aggregate.parent ? new string( *aggregate.parent ) : nullptr; 194 199 break; 195 200 case AggregateInst: … … 449 454 case TypeData::Builtin: 450 455 if(td->builtintype == DeclarationNode::Zero) { 451 return new ZeroType( emptyQualifiers );456 return new ZeroType( noQualifiers ); 452 457 } 453 458 else if(td->builtintype == DeclarationNode::One) { 454 return new OneType( emptyQualifiers );459 return new OneType( noQualifiers ); 455 460 } 456 461 else { … … 619 624 switch ( td->aggregate.kind ) { 620 625 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 } 621 631 case DeclarationNode::Coroutine: 622 632 case DeclarationNode::Monitor: -
src/Parser/TypeData.h
re0a653d r33218c6 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 … … 113 115 void buildKRFunction( const TypeData::Function_t & function ); 114 116 115 #endif // TYPEDATA_H116 117 117 // Local Variables: // 118 118 // tab-width: 4 // -
src/Parser/TypedefTable.h
re0a653d r33218c6 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
re0a653d r33218c6 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Tue Jul 11 21:30:51201713 * Update Count : 5 3412 * Last Modified On : Mon Jul 24 08:27:23 2017 13 * Update Count : 545 14 14 */ 15 15 … … 125 125 op_unary {op_unary_only}|{op_unary_binary}|{op_unary_pre_post} 126 126 127 op_binary_only "/"|"%"|" ^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"&="|"|="|"^="|"<<="|">>="127 op_binary_only "/"|"%"|"\\"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"\\="|"&="|"|="|"^="|"<<="|">>=" 128 128 op_binary_over {op_unary_binary}|{op_binary_only} 129 129 // op_binary_not_over "?"|"->"|"."|"&&"|"||"|"@=" … … 136 136 137 137 %% 138 /* line directives */138 /* line directives */ 139 139 ^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" { 140 140 /* " stop highlighting */ … … 232 232 int { KEYWORD_RETURN(INT); } 233 233 __int128 { KEYWORD_RETURN(INT); } // GCC 234 __int128_t { KEYWORD_RETURN(INT); } // GCC 234 235 __label__ { KEYWORD_RETURN(LABEL); } // GCC 235 236 long { KEYWORD_RETURN(LONG); } … … 266 267 __typeof { KEYWORD_RETURN(TYPEOF); } // GCC 267 268 __typeof__ { KEYWORD_RETURN(TYPEOF); } // GCC 269 __uint128_t { KEYWORD_RETURN(INT); } // GCC 268 270 union { KEYWORD_RETURN(UNION); } 269 271 unsigned { KEYWORD_RETURN(UNSIGNED); } 270 272 __builtin_va_list { KEYWORD_RETURN(VALIST); } // GCC 273 virtual { KEYWORD_RETURN(VIRTUAL); } // CFA 271 274 void { KEYWORD_RETURN(VOID); } 272 275 volatile { KEYWORD_RETURN(VOLATILE); } … … 274 277 __volatile__ { KEYWORD_RETURN(VOLATILE); } // GCC 275 278 while { KEYWORD_RETURN(WHILE); } 279 with { KEYWORD_RETURN(WITH); } // CFA 276 280 zero_t { NUMERIC_RETURN(ZERO_T); } // CFA 277 281 … … 336 340 "-" { ASCIIOP_RETURN(); } 337 341 "*" { ASCIIOP_RETURN(); } 342 "\\" { ASCIIOP_RETURN(); } // CFA, exponentiation 338 343 "/" { ASCIIOP_RETURN(); } 339 344 "%" { ASCIIOP_RETURN(); } … … 360 365 "+=" { NAMEDOP_RETURN(PLUSassign); } 361 366 "-=" { NAMEDOP_RETURN(MINUSassign); } 367 "\\=" { NAMEDOP_RETURN(EXPassign); } // CFA, exponentiation 362 368 "*=" { NAMEDOP_RETURN(MULTassign); } 363 369 "/=" { NAMEDOP_RETURN(DIVassign); } -
src/Parser/parser.yy
re0a653d r33218c6 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tus Jul 11 13:39:00201713 // Update Count : 24 1611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 24 09:01:14 2017 13 // Update Count : 2463 14 14 // 15 15 … … 118 118 %token RESTRICT // C99 119 119 %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 122 124 %token VALIST // GCC 123 %token BOOL COMPLEX IMAGINARY // C99124 125 %token TYPEOF LABEL // GCC 125 126 %token ENUM STRUCT UNION … … 129 130 %token ATTRIBUTE EXTENSION // GCC 130 131 %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 // CFA132 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH // CFA 132 133 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 133 134 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 … … 151 152 %token ELLIPSIS // ... 152 153 153 %token MULTassign DIVassign MODassign // *= /= %=/154 %token EXPassign MULTassign DIVassign MODassign // \= *= /= %= 154 155 %token PLUSassign MINUSassign // += -= 155 156 %token LSassign RSassign // <<= >>= … … 168 169 %type<op> ptrref_operator unary_operator assignment_operator 169 170 %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 174 176 %type<en> comma_expression comma_expression_opt 175 %type<en> argument_expression_list argument_expression assignment_opt177 %type<en> argument_expression_list argument_expression default_initialize_opt 176 178 %type<fctl> for_control_expression 177 179 %type<en> subrange … … 184 186 // statements 185 187 %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 187 190 %type<sn> fall_through_opt fall_through 188 191 %type<sn> statement statement_list 189 192 %type<sn> block_item_list block_item 190 %type<sn> case_clause193 %type<sn> with_clause_opt 191 194 %type<en> case_value 192 %type<sn> case_ value_list case_label case_label_list195 %type<sn> case_clause case_value_list case_label case_label_list 193 196 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 194 197 %type<sn> /* handler_list */ handler_clause finally_clause … … 568 571 | '(' type_no_function ')' cast_expression 569 572 { $$ = 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 ) ); } 570 578 // | '(' type_no_function ')' tuple 571 579 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 572 580 ; 573 581 582 exponential_expression: 583 cast_expression 584 | exponential_expression '\\' cast_expression 585 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); } 586 ; 587 574 588 multiplicative_expression: 575 cast_expression576 | multiplicative_expression '*' cast_expression589 exponential_expression 590 | multiplicative_expression '*' exponential_expression 577 591 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); } 578 | multiplicative_expression '/' cast_expression592 | multiplicative_expression '/' exponential_expression 579 593 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); } 580 | multiplicative_expression '%' cast_expression594 | multiplicative_expression '%' exponential_expression 581 595 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); } 582 596 ; … … 677 691 '=' { $$ = OperKinds::Assign; } 678 692 | ATassign { $$ = OperKinds::AtAssn; } 693 | EXPassign { $$ = OperKinds::ExpAssn; } 679 694 | MULTassign { $$ = OperKinds::MulAssn; } 680 695 | DIVassign { $$ = OperKinds::DivAssn; } … … 729 744 | iteration_statement 730 745 | jump_statement 746 | with_statement 731 747 | exception_statement 732 748 | asm_statement … … 936 952 ; 937 953 954 with_statement: 955 WITH '(' tuple_expression_list ')' compound_statement 956 { $$ = (StatementNode *)0; } // FIX ME 957 ; 958 938 959 exception_statement: 939 960 TRY compound_statement handler_clause … … 965 986 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); } 966 987 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 994 handler_predicate_opt: 995 //empty 996 | ';' conditional_expression 971 997 ; 972 998 … … 1495 1521 | IMAGINARY // C99 1496 1522 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1497 | VALIST // GCC, __builtin_va_list1498 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }1499 1523 | ZERO_T 1500 1524 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1501 1525 | ONE_T 1502 1526 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1527 | VALIST // GCC, __builtin_va_list 1528 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1503 1529 ; 1504 1530 … … 1660 1686 | aggregate_key attribute_list_opt typegen_name // CFA 1661 1687 { $$ = $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 } 1662 1712 ; 1663 1713 … … 1838 1888 cfa_parameter_declaration: // CFA, new & old style parameter declaration 1839 1889 parameter_declaration 1840 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt1890 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt 1841 1891 { $$ = $1->addName( $2 ); } 1842 | cfa_abstract_tuple identifier_or_type_name assignment_opt1892 | cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1843 1893 // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator). 1844 1894 { $$ = $1->addName( $2 ); } 1845 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt1895 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1846 1896 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 1847 1897 | cfa_function_specifier … … 1860 1910 parameter_declaration: 1861 1911 // No SUE declaration in parameter list. 1862 declaration_specifier_nobody identifier_parameter_declarator assignment_opt1912 declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt 1863 1913 { 1864 1914 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1865 1915 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1866 1916 } 1867 | declaration_specifier_nobody type_parameter_redeclarator assignment_opt1917 | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt 1868 1918 { 1869 1919 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1873 1923 1874 1924 abstract_parameter_declaration: 1875 declaration_specifier_nobody assignment_opt1925 declaration_specifier_nobody default_initialize_opt 1876 1926 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1877 | declaration_specifier_nobody abstract_parameter_declarator assignment_opt1927 | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt 1878 1928 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1879 1929 ; … … 2212 2262 ; 2213 2263 2264 with_clause_opt: 2265 // empty 2266 { $$ = (StatementNode *)0; } // FIX ME 2267 | WITH '(' tuple_expression_list ')' 2268 { $$ = (StatementNode *)0; } // FIX ME 2269 ; 2270 2214 2271 function_definition: 2215 cfa_function_declaration compound_statement// CFA2272 cfa_function_declaration with_clause_opt compound_statement // CFA 2216 2273 { 2217 2274 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2218 2275 typedefTable.leaveScope(); 2219 $$ = $1->addFunctionBody( $ 2);2220 } 2221 | declaration_specifier function_declarator compound_statement2276 $$ = $1->addFunctionBody( $3 ); 2277 } 2278 | declaration_specifier function_declarator with_clause_opt compound_statement 2222 2279 { 2223 2280 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2224 2281 typedefTable.leaveScope(); 2225 $$ = $2->addFunctionBody( $ 3)->addType( $1 );2226 } 2227 | type_qualifier_list function_declarator compound_statement2282 $$ = $2->addFunctionBody( $4 )->addType( $1 ); 2283 } 2284 | type_qualifier_list function_declarator with_clause_opt compound_statement 2228 2285 { 2229 2286 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2230 2287 typedefTable.leaveScope(); 2231 $$ = $2->addFunctionBody( $ 3)->addQualifiers( $1 );2232 } 2233 | declaration_qualifier_list function_declarator compound_statement2288 $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 ); 2289 } 2290 | declaration_qualifier_list function_declarator with_clause_opt compound_statement 2234 2291 { 2235 2292 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2236 2293 typedefTable.leaveScope(); 2237 $$ = $2->addFunctionBody( $ 3)->addQualifiers( $1 );2238 } 2239 | declaration_qualifier_list type_qualifier_list function_declarator compound_statement2294 $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 ); 2295 } 2296 | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement 2240 2297 { 2241 2298 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2242 2299 typedefTable.leaveScope(); 2243 $$ = $3->addFunctionBody( $ 4)->addQualifiers( $2 )->addQualifiers( $1 );2300 $$ = $3->addFunctionBody( $5 )->addQualifiers( $2 )->addQualifiers( $1 ); 2244 2301 } 2245 2302 2246 2303 // Old-style K&R function definition, OBSOLESCENT (see 4) 2247 | declaration_specifier KR_function_declarator push KR_declaration_list_opt compound_statement2304 | declaration_specifier KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2248 2305 { 2249 2306 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2250 2307 typedefTable.leaveScope(); 2251 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $ 5)->addType( $1 );2252 } 2253 | type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement2308 $$ = $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 2254 2311 { 2255 2312 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2256 2313 typedefTable.leaveScope(); 2257 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $ 5)->addQualifiers( $1 );2314 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 ); 2258 2315 } 2259 2316 2260 2317 // 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_statement2318 | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2262 2319 { 2263 2320 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2264 2321 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_statement2322 $$ = $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 2268 2325 { 2269 2326 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2270 2327 typedefTable.leaveScope(); 2271 $$ = $3->addOldDeclList( $5 )->addFunctionBody( $ 6)->addQualifiers( $2 )->addQualifiers( $1 );2328 $$ = $3->addOldDeclList( $5 )->addFunctionBody( $7 )->addQualifiers( $2 )->addQualifiers( $1 ); 2272 2329 } 2273 2330 ; … … 3031 3088 ; 3032 3089 3033 assignment_opt:3090 default_initialize_opt: 3034 3091 // empty 3035 3092 { $$ = nullptr; } -
src/Parser/parserutility.cc
re0a653d r33218c6 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
re0a653d r33218c6 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.