Changeset 5bd0aad for src/Parser
- Timestamp:
- Jul 17, 2017, 3:54:08 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:
- 969b3fe
- Parents:
- e60e0dc (diff), 59e86eb (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:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
re60e0dc r5bd0aad 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
re60e0dc r5bd0aad 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 28 21:08:15201713 // Update Count : 54 212 // Last Modified On : Sat Jul 15 16:09:04 2017 13 // Update Count : 549 14 14 // 15 15 … … 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/ParseNode.h
re60e0dc r5bd0aad 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 : Sat Jul 15 16:00:48 2017 13 // Update Count : 785 14 14 // 15 15 … … 141 141 }; 142 142 143 // Must harmonize with OperName. 143 144 enum class OperKinds { 144 145 // diadic 145 SizeOf, AlignOf, OffsetOf, Plus, Minus, Mul, Div, Mod, Or, And,146 SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And, 146 147 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,148 Assign, AtAssn, ExpAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn, 148 149 Index, Range, 149 150 // monadic … … 248 249 static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement 249 250 251 // Perhaps this would best fold into newAggragate. 252 static DeclarationNode * newTreeStruct( Aggregate kind, const std::string * name, const std::string * parent, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 253 250 254 DeclarationNode(); 251 255 ~DeclarationNode(); … … 332 336 333 337 static UniqueName anonymous; 338 339 // Temp to test TreeStruct 340 const std::string * parent_name; 334 341 }; // DeclarationNode 335 342 -
src/Parser/TypeData.cc
re60e0dc r5bd0aad 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 : Fri Jul 14 16:58:00 2017 13 // Update Count : 565 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: … … 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
re60e0dc r5bd0aad 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 28 15:29:00 201713 // Update Count : 18 612 // Last Modified On : Fri Jul 14 16:57:00 2017 13 // Update Count : 187 14 14 // 15 15 … … 31 31 DeclarationNode * fields; 32 32 bool body; 33 34 bool tagged; 35 const std::string * parent; 33 36 }; 34 37 -
src/Parser/lex.ll
re60e0dc r5bd0aad 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:44 201713 * Update Count : 5 3512 * Last Modified On : Sat Jul 15 15:46:34 2017 13 * Update Count : 542 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 138 /* line directives */ 139 139 ^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" { 140 140 /* " stop highlighting */ … … 337 337 "-" { ASCIIOP_RETURN(); } 338 338 "*" { ASCIIOP_RETURN(); } 339 "\\" { ASCIIOP_RETURN(); } // CFA, exponentiation 339 340 "/" { ASCIIOP_RETURN(); } 340 341 "%" { ASCIIOP_RETURN(); } … … 361 362 "+=" { NAMEDOP_RETURN(PLUSassign); } 362 363 "-=" { NAMEDOP_RETURN(MINUSassign); } 364 "\\=" { NAMEDOP_RETURN(EXPassign); } // CFA, exponentiation 363 365 "*=" { NAMEDOP_RETURN(MULTassign); } 364 366 "/=" { NAMEDOP_RETURN(DIVassign); } -
src/Parser/parser.yy
re60e0dc r5bd0aad 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 : Thu Jul 13 14:38:54201713 // Update Count : 24 3111 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jul 17 12:17:00 2017 13 // Update Count : 2455 14 14 // 15 15 … … 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 // <<= >>= … … 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 … … 573 574 ; 574 575 576 exponential_expression: 577 cast_expression 578 | exponential_expression '\\' cast_expression 579 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); } 580 ; 581 575 582 multiplicative_expression: 576 cast_expression577 | multiplicative_expression '*' cast_expression583 exponential_expression 584 | multiplicative_expression '*' exponential_expression 578 585 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); } 579 | multiplicative_expression '/' cast_expression586 | multiplicative_expression '/' exponential_expression 580 587 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); } 581 | multiplicative_expression '%' cast_expression588 | multiplicative_expression '%' exponential_expression 582 589 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); } 583 590 ; … … 678 685 '=' { $$ = OperKinds::Assign; } 679 686 | ATassign { $$ = OperKinds::AtAssn; } 687 | EXPassign { $$ = OperKinds::ExpAssn; } 680 688 | MULTassign { $$ = OperKinds::MulAssn; } 681 689 | DIVassign { $$ = OperKinds::DivAssn; } … … 972 980 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); } 973 981 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 ) ) ); } 982 | handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 983 { $$ = new StatementNode( build_catch( $1, $5, nullptr, $9 ) ); } 984 | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 985 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $10 ) ) ); } 986 ; 987 988 handler_predicate_opt: 989 //empty 990 | ';' conditional_expression 978 991 ; 979 992 … … 1667 1680 | aggregate_key attribute_list_opt typegen_name // CFA 1668 1681 { $$ = $3->addQualifiers( $2 ); } 1682 1683 // Temp, testing TreeStruct 1684 | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name 1685 { 1686 typedefTable.makeTypedef( *$4 ); // create typedef 1687 if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $ 1688 forall = false; // reset 1689 } 1690 '{' field_declaration_list '}' 1691 { 1692 $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct, 1693 $4, nullptr, nullptr, $7, true )->addQualifiers( $3 ); 1694 } 1695 | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name TYPEDEFname 1696 { 1697 typedefTable.makeTypedef( *$4 ); // create typedef 1698 if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $ 1699 forall = false; // reset 1700 } 1701 '{' field_declaration_list '}' 1702 { 1703 $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct, 1704 $4, $5, nullptr, $8, true )->addQualifiers( $3 ); 1705 } 1669 1706 ; 1670 1707 … … 1845 1882 cfa_parameter_declaration: // CFA, new & old style parameter declaration 1846 1883 parameter_declaration 1847 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt1884 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt 1848 1885 { $$ = $1->addName( $2 ); } 1849 | cfa_abstract_tuple identifier_or_type_name assignment_opt1886 | cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1850 1887 // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator). 1851 1888 { $$ = $1->addName( $2 ); } 1852 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt1889 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1853 1890 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 1854 1891 | cfa_function_specifier … … 1867 1904 parameter_declaration: 1868 1905 // No SUE declaration in parameter list. 1869 declaration_specifier_nobody identifier_parameter_declarator assignment_opt1906 declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt 1870 1907 { 1871 1908 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1872 1909 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1873 1910 } 1874 | declaration_specifier_nobody type_parameter_redeclarator assignment_opt1911 | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt 1875 1912 { 1876 1913 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1880 1917 1881 1918 abstract_parameter_declaration: 1882 declaration_specifier_nobody assignment_opt1919 declaration_specifier_nobody default_initialize_opt 1883 1920 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1884 | declaration_specifier_nobody abstract_parameter_declarator assignment_opt1921 | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt 1885 1922 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1886 1923 ; … … 3045 3082 ; 3046 3083 3047 assignment_opt:3084 default_initialize_opt: 3048 3085 // empty 3049 3086 { $$ = nullptr; }
Note:
See TracChangeset
for help on using the changeset viewer.