Changeset 6ac5223 for src/Parser
- Timestamp:
- Aug 17, 2017, 3:42:21 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, stuck-waitfor-destruct, with_gc
- Children:
- e50e9ff
- Parents:
- 97e3296 (diff), 21f0aa8 (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) (1 diff)
-
ExpressionNode.cc (modified) (2 diffs)
-
InitializerNode.cc (modified) (1 diff)
-
ParseNode.h (modified) (3 diffs)
-
StatementNode.cc (modified) (3 diffs)
-
TypeData.cc (modified) (1 diff)
-
TypeData.h (modified) (1 diff)
-
TypedefTable.cc (modified) (1 diff)
-
TypedefTable.h (modified) (5 diffs)
-
parser.yy (modified) (9 diffs)
-
parserutility.cc (modified) (1 diff)
-
parserutility.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r97e3296 r6ac5223 14 14 // 15 15 16 #include <string> 17 #include <list> 18 #include <iterator> 19 #include <algorithm> 20 #include <cassert> 21 22 #include "TypeData.h" 23 24 #include "SynTree/Attribute.h" 25 #include "SynTree/Declaration.h" 26 #include "SynTree/Expression.h" 27 28 #include "TypedefTable.h" 16 #include <cassert> // for assert, assertf, safe_dynamic_cast 17 #include <iterator> // for back_insert_iterator 18 #include <list> // for list 19 #include <memory> // for unique_ptr 20 #include <ostream> // for operator<<, ostream, basic_ostream 21 #include <string> // for string, operator+, allocator, char... 22 23 #include "Common/SemanticError.h" // for SemanticError 24 #include "Common/UniqueName.h" // for UniqueName 25 #include "Common/utility.h" // for maybeClone, maybeBuild, CodeLocation 26 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall 27 #include "Parser/ParseNode.h" // for DeclarationNode, ExpressionNode 28 #include "SynTree/Attribute.h" // for Attribute 29 #include "SynTree/Declaration.h" // for TypeDecl, ObjectDecl, Declaration 30 #include "SynTree/Expression.h" // for Expression, ConstantExpr 31 #include "SynTree/Statement.h" // for AsmStmt 32 #include "SynTree/Type.h" // for Type, Type::StorageClasses, Type::... 33 #include "TypeData.h" // for TypeData, TypeData::Aggregate_t 34 #include "TypedefTable.h" // for TypedefTable, TypedefTable::kind_t... 35 36 class Initializer; 37 29 38 extern TypedefTable typedefTable; 30 39 -
src/Parser/ExpressionNode.cc
r97e3296 r6ac5223 14 14 // 15 15 16 #include <climits> // access INT_MAX, UINT_MAX, LONG_MAX, ULONG_MAX, LLONG_MAX 17 #include <sstream> 18 19 #include "ParseNode.h" 20 #include "TypeData.h" 21 #include "SynTree/Constant.h" 22 #include "SynTree/Expression.h" 23 #include "SynTree/Declaration.h" 24 #include "parserutility.h" 16 #include <cassert> // for assert 17 #include <stdio.h> // for sscanf, size_t 18 #include <climits> // for LLONG_MAX, LONG_MAX, INT_MAX, UINT... 19 #include <list> // for list 20 #include <sstream> // for basic_istream::operator>>, basic_i... 21 #include <string> // for string, operator+, operator== 22 23 #include "Common/SemanticError.h" // for SemanticError 24 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild, CodeLo... 25 #include "ParseNode.h" // for ExpressionNode, maybeMoveBuildType 26 #include "SynTree/Constant.h" // for Constant 27 #include "SynTree/Declaration.h" // for EnumDecl, StructDecl, UnionDecl 28 #include "SynTree/Expression.h" // for Expression, ConstantExpr, NameExpr 29 #include "SynTree/Statement.h" // for CompoundStmt, Statement 30 #include "SynTree/Type.h" // for BasicType, Type, Type::Qualifiers 31 #include "parserutility.h" // for notZeroExpr 32 33 class Initializer; 25 34 26 35 using namespace std; … … 69 78 goto CLEANUP; 70 79 } // if 71 80 72 81 if ( str[0] == '0' ) { // octal/hex constant ? 73 82 dec = false; -
src/Parser/InitializerNode.cc
r97e3296 r6ac5223 14 14 // 15 15 16 #include <cassert> 17 #include <iostream> 16 #include <iostream> // for operator<<, ostream, basic_ostream 17 #include <list> // for list 18 #include <string> // for operator<<, string 19 18 20 using namespace std; 19 21 20 #include "ParseNode.h" 21 #include "SynTree/Expression.h" 22 #include "SynTree/Initializer.h" 22 #include "Common/SemanticError.h" // for SemanticError 23 #include "Common/utility.h" // for maybeBuild 24 #include "ParseNode.h" // for InitializerNode, ExpressionNode 25 #include "SynTree/Expression.h" // for Expression 26 #include "SynTree/Initializer.h" // for Initializer, ListInit, SingleInit 23 27 24 28 InitializerNode::InitializerNode( ExpressionNode * _expr, bool aggrp, ExpressionNode * des ) -
src/Parser/ParseNode.h
r97e3296 r6ac5223 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Th u Aug 10 16:54:00 201713 // Update Count : 7 8912 // Last Modified On : Thr Aug 17 13:46:00 2017 13 // Update Count : 795 14 14 // 15 15 16 16 #pragma once 17 17 18 #include <string> 19 #include <list> 20 #include <iterator> 21 #include <memory> 22 23 #include "Parser/LinkageSpec.h" 24 #include "SynTree/Type.h" 25 #include "SynTree/Expression.h" 26 #include "SynTree/Statement.h" 27 #include "SynTree/Label.h" 28 #include "Common/utility.h" 29 #include "Common/UniqueName.h" 30 18 #include <algorithm> // for move 19 #include <cassert> // for assert, assertf 20 #include <iosfwd> // for ostream 21 #include <iterator> // for back_insert_iterator 22 #include <list> // for list 23 #include <memory> // for unique_ptr, pointer_traits 24 #include <string> // for string 25 26 #include "Common/CodeLocation.h" // for CodeLocation 27 #include "Common/SemanticError.h" // for SemanticError 28 #include "Common/UniqueName.h" // for UniqueName 29 #include "Common/utility.h" // for maybeClone, maybeBuild 30 #include "Parser/LinkageSpec.h" // for Spec 31 #include "SynTree/Expression.h" // for Expression, ConstantExpr (ptr only) 32 #include "SynTree/Label.h" // for Label 33 #include "SynTree/Statement.h" // for Statement, BranchStmt, BranchStmt:... 34 #include "SynTree/Type.h" // for Type, Type::FuncSpecifiers, Type::... 35 36 class Attribute; 37 class Declaration; 38 class DeclarationNode; 39 class DeclarationWithType; 40 class ExpressionNode; 41 class Initializer; 31 42 class StatementNode; 32 class CompoundStmtNode;33 class DeclarationNode;34 class ExpressionNode;35 class InitializerNode;36 class Attribute;37 43 38 44 //############################################################################## … … 371 377 Statement * build_expr( ExpressionNode * ctl ); 372 378 379 struct IfCtl { 380 IfCtl( DeclarationNode * decl, ExpressionNode * condition ) : 381 init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {} 382 383 StatementNode * init; 384 ExpressionNode * condition; 385 }; 386 373 387 struct ForCtl { 374 388 ForCtl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) : … … 382 396 }; 383 397 384 Statement * build_if( ExpressionNode* ctl, StatementNode * then_stmt, StatementNode * else_stmt );398 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ); 385 399 Statement * build_switch( ExpressionNode * ctl, StatementNode * stmt ); 386 400 Statement * build_case( ExpressionNode * ctl ); -
src/Parser/StatementNode.cc
r97e3296 r6ac5223 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 11 21:23:15 2017 13 // Update Count : 331 14 // 15 16 #include <list> 17 #include <algorithm> 18 #include <cassert> 19 20 #include "ParseNode.h" 21 #include "SynTree/Statement.h" 22 #include "SynTree/Expression.h" 23 #include "parserutility.h" 24 #include "Common/utility.h" 12 // Last Modified On : Wed Aug 16 16:39:43 2017 13 // Update Count : 340 14 // 15 16 #include <cassert> // for assert, safe_dynamic_cast, assertf 17 #include <list> // for list 18 #include <memory> // for unique_ptr 19 #include <string> // for string 20 21 #include "Common/SemanticError.h" // for SemanticError 22 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild 23 #include "ParseNode.h" // for StatementNode, ExpressionNode, bui... 24 #include "SynTree/Expression.h" // for Expression, ConstantExpr 25 #include "SynTree/Label.h" // for Label, noLabels 26 #include "SynTree/Statement.h" // for Statement, BranchStmt, CaseStmt 27 #include "parserutility.h" // for notZeroExpr 28 29 class Declaration; 25 30 26 31 using namespace std; … … 74 79 } 75 80 76 Statement *build_if( ExpressionNode *ctl, StatementNode *then_stmt, StatementNode *else_stmt ) {81 Statement *build_if( IfCtl * ctl, StatementNode *then_stmt, StatementNode *else_stmt ) { 77 82 Statement *thenb, *elseb = 0; 78 83 std::list< Statement * > branches; … … 87 92 elseb = branches.front(); 88 93 } // if 89 return new IfStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), thenb, elseb ); 94 95 std::list< Statement * > init; 96 if ( ctl->init != 0 ) { 97 buildMoveList( ctl->init, init ); 98 } // if 99 100 return new IfStmt( noLabels, notZeroExpr( 101 /*ctl->condition 102 ?*/ maybeMoveBuild< Expression >(ctl->condition) 103 /*: new VariableExpr( init.end() )*/ ) 104 , thenb, elseb ); 105 // ret->initialization = init; 106 // delete ctl; 107 // assert( ret ); 108 // return ret; 90 109 } 91 110 -
src/Parser/TypeData.cc
r97e3296 r6ac5223 14 14 // 15 15 16 #include <cassert> 17 #include <algorithm> 18 #include <iterator> 19 #include "Common/utility.h" 16 #include <cassert> // for assert 17 #include <ostream> // for operator<<, ostream, basic_ostream 18 19 #include "Common/SemanticError.h" // for SemanticError 20 #include "Common/utility.h" // for maybeClone, maybeBuild, maybeMoveB... 21 #include "Parser/ParseNode.h" // for DeclarationNode, ExpressionNode 22 #include "SynTree/Declaration.h" // for TypeDecl, ObjectDecl, FunctionDecl 23 #include "SynTree/Expression.h" // for Expression, ConstantExpr (ptr only) 24 #include "SynTree/Initializer.h" // for SingleInit, Initializer (ptr only) 25 #include "SynTree/Statement.h" // for CompoundStmt, Statement 26 #include "SynTree/Type.h" // for BasicType, Type, Type::ForallList 20 27 #include "TypeData.h" 21 #include "SynTree/Type.h" 22 #include "SynTree/Declaration.h" 23 #include "SynTree/Expression.h" 24 #include "SynTree/Statement.h" 25 #include "SynTree/Initializer.h" 28 29 class Attribute; 30 26 31 using namespace std; 27 32 -
src/Parser/TypeData.h
r97e3296 r6ac5223 16 16 #pragma once 17 17 18 #include "ParseNode.h" 19 #include "SynTree/Type.h" 18 #include <iosfwd> // for ostream 19 #include <list> // for list 20 #include <string> // for string 21 22 #include "ParseNode.h" // for DeclarationNode, DeclarationNode::Ag... 23 #include "Parser/LinkageSpec.h" // for Spec 24 #include "SynTree/Type.h" // for Type, ReferenceToType (ptr only) 25 #include "SynTree/SynTree.h" // for Visitor Nodes 20 26 21 27 struct TypeData { -
src/Parser/TypedefTable.cc
r97e3296 r6ac5223 14 14 // 15 15 16 #include <map> 17 #include <list> 18 #include <cassert> 16 #include <ext/alloc_traits.h> // for __alloc_traits<>::value_type 17 #include <cassert> // for assert 18 #include <list> // for list, _List_iterator, list<>::iterator 19 #include <map> // for _Rb_tree_iterator, _Rb_tree_const_it... 20 #include <memory> // for allocator_traits<>::value_type 21 #include <utility> // for pair 22 23 #include "Parser/ParserTypes.h" // for typedefTable 24 #include "Parser/parser.hh" // for IDENTIFIER 19 25 #include "TypedefTable.h" 26 20 27 using namespace std; 21 28 22 29 #if 0 23 30 #include <iostream> 31 24 32 #define debugPrint( x ) cerr << x 25 33 #else -
src/Parser/TypedefTable.h
r97e3296 r6ac5223 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TypedefTable.h -- 7 // TypedefTable.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 16 16 #pragma once 17 17 18 #include < map>19 #include < list>20 #include <st ring>21 #include <st ack>18 #include <list> // for list 19 #include <map> // for map, map<>::value_compare 20 #include <stack> // for stack 21 #include <string> // for string 22 22 23 23 #include "ParserTypes.h" 24 #include "parser.hh" 24 #include "parser.hh" // for IDENTIFIER, TYPEDEFname, TYPEGENname 25 25 26 26 class TypedefTable { … … 32 32 kind_t kind; 33 33 }; 34 34 35 35 struct DeferredEntry { 36 36 std::string identifier; … … 44 44 std::string currentTrait; 45 45 int contextScope; 46 46 47 47 typedef std::list< DeferredEntry > deferListType; 48 48 std::stack< deferListType > deferListStack; 49 49 std::map< std::string, deferListType > contexts; 50 50 51 51 std::stack< std::string > nextIdentifiers; 52 52 … … 70 70 void addToEnclosingScope( const std::string &identifier, kind_t kind ); 71 71 void addToEnclosingScope( kind_t kind ); // use nextIdentifiers.top() 72 72 73 73 // "addToEnclosingScope2" adds the identifier/type pair to the scope that encloses the scope enclosing the the 74 74 // current one. This is the right way to handle assertion names 75 75 void addToEnclosingScope2( const std::string &identifier, kind_t kind ); 76 76 void addToEnclosingScope2( kind_t kind ); // use nextIdentifiers.top() 77 77 78 78 // set the next identifier to be used by an "add" operation without an identifier parameter within the current scope 79 79 void setNextIdentifier( const std::string &identifier ); 80 80 81 81 // dump the definitions from a pre-defined context into the current scope 82 82 void openTrait( const std::string &contextName ); 83 83 84 84 void enterScope(); 85 85 void leaveScope(); -
src/Parser/parser.yy
r97e3296 r6ac5223 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 : Wed Aug 4 13:33:00201713 // Update Count : 24 7511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 16 18:09:14 2017 13 // Update Count : 2485 14 14 // 15 15 … … 98 98 StatementNode * sn; 99 99 ConstantExpr * constant; 100 IfCtl * ifctl; 100 101 ForCtl * fctl; 101 102 LabelNode * label; … … 175 176 %type<en> comma_expression comma_expression_opt 176 177 %type<en> argument_expression_list argument_expression default_initialize_opt 178 %type<ifctl> if_control_expression 177 179 %type<fctl> for_control_expression 178 180 %type<en> subrange … … 794 796 795 797 selection_statement: 796 IF '(' comma_expression ')' statement %prec THEN798 IF '(' if_control_expression ')' statement %prec THEN 797 799 // explicitly deal with the shift/reduce conflict on if/else 798 800 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); } 799 | IF '(' comma_expression ')' statement ELSE statement801 | IF '(' if_control_expression ')' statement ELSE statement 800 802 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); } 801 803 | SWITCH '(' comma_expression ')' case_clause // CFA … … 819 821 } 820 822 ; 823 824 if_control_expression: 825 comma_expression 826 { $$ = new IfCtl( nullptr, $1 ); } 827 | c_declaration // no semi-coln 828 { $$ = new IfCtl( $1, nullptr ); } 829 | cfa_declaration // no semi-colon 830 { $$ = new IfCtl( $1, nullptr ); } 831 | declaration comma_expression 832 { $$ = new IfCtl( $1, $2 ); } 833 ; 821 834 822 835 // CASE and DEFAULT clauses are only allowed in the SWITCH statement, precluding Duff's device. In addition, a case … … 1097 1110 1098 1111 KR_declaration_list: 1099 c_declaration 1100 | KR_declaration_list push c_declaration 1112 c_declaration ';' 1113 | KR_declaration_list push c_declaration ';' 1101 1114 { $$ = $1->appendList( $3 ); } 1102 1115 ; … … 1117 1130 ; 1118 1131 1119 declaration: // CFA, new & oldstyle declarations1120 c fa_declaration1121 | c _declaration1132 declaration: // old & new style declarations 1133 c_declaration ';' 1134 | cfa_declaration ';' // CFA 1122 1135 ; 1123 1136 … … 1134 1147 1135 1148 cfa_declaration: // CFA 1136 cfa_variable_declaration pop ';'1137 | cfa_typedef_declaration pop ';'1138 | cfa_function_declaration pop ';'1139 | type_declaring_list pop ';'1140 | trait_specifier pop ';'1149 cfa_variable_declaration pop 1150 | cfa_typedef_declaration pop 1151 | cfa_function_declaration pop 1152 | type_declaring_list pop 1153 | trait_specifier pop 1141 1154 ; 1142 1155 … … 1338 1351 1339 1352 c_declaration: 1340 declaration_specifier declaring_list pop ';'1353 declaration_specifier declaring_list pop 1341 1354 { 1342 1355 $$ = distAttr( $1, $2 ); 1343 1356 } 1344 | typedef_declaration pop ';'1345 | typedef_expression pop ';'// GCC, naming expression type1346 | sue_declaration_specifier pop ';'1357 | typedef_declaration pop 1358 | typedef_expression pop // GCC, naming expression type 1359 | sue_declaration_specifier pop 1347 1360 ; 1348 1361 -
src/Parser/parserutility.cc
r97e3296 r6ac5223 15 15 16 16 #include "parserutility.h" 17 #include "SynTree/Type.h" 18 #include "SynTree/Expression.h" 17 18 #include <list> // for list 19 #include <string> // for string 20 21 #include "SynTree/Constant.h" // for Constant 22 #include "SynTree/Expression.h" // for UntypedExpr, CastExpr, ConstantExpr 23 #include "SynTree/Type.h" // for BasicType, ZeroType, BasicType::Kind... 19 24 20 25 // rewrite -
src/Parser/parserutility.h
r97e3296 r6ac5223 16 16 #pragma once 17 17 18 #include "SynTree/SynTree.h" 18 class Expression; 19 19 20 20 Expression *notZeroExpr( Expression *orig );
Note:
See TracChangeset
for help on using the changeset viewer.