| [b87a5ed] | 1 | // | 
|---|
|  | 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | 
|---|
|  | 3 | // | 
|---|
|  | 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
|  | 5 | // file "LICENCE" distributed with Cforall. | 
|---|
|  | 6 | // | 
|---|
|  | 7 | // ParseNode.cc -- | 
|---|
|  | 8 | // | 
|---|
|  | 9 | // Author           : Rodolfo G. Esteves | 
|---|
|  | 10 | // Created On       : Sat May 16 13:26:29 2015 | 
|---|
| [e869d663] | 11 | // Last Modified By : Rob Schluntz | 
|---|
|  | 12 | // Last Modified On : Wed Aug 12 13:26:00 2015 | 
|---|
|  | 13 | // Update Count     : 36 | 
|---|
| [b87a5ed] | 14 | // | 
|---|
|  | 15 |  | 
|---|
| [51b73452] | 16 | #include "ParseNode.h" | 
|---|
|  | 17 | using namespace std; | 
|---|
|  | 18 |  | 
|---|
|  | 19 | // Builder | 
|---|
|  | 20 | int ParseNode::indent_by = 4; | 
|---|
|  | 21 |  | 
|---|
| [e869d663] | 22 | ParseNode::ParseNode() : next( 0 ) {}; | 
|---|
|  | 23 | ParseNode::ParseNode( const string *name ) : name( *name ), next( 0 ) { delete name; } | 
|---|
|  | 24 | ParseNode::ParseNode( const string &name ) : name( name ), next( 0 ) { } | 
|---|
| [51b73452] | 25 |  | 
|---|
| [59db689] | 26 | ParseNode::~ParseNode() { | 
|---|
| [e869d663] | 27 | delete next; | 
|---|
| [51b73452] | 28 | }; | 
|---|
|  | 29 |  | 
|---|
| [59db689] | 30 | ParseNode *ParseNode::get_link() const { | 
|---|
| [a08ba92] | 31 | return next; | 
|---|
| [51b73452] | 32 | } | 
|---|
|  | 33 |  | 
|---|
| [59db689] | 34 | ParseNode *ParseNode::get_last() { | 
|---|
| [a08ba92] | 35 | ParseNode *current = this; | 
|---|
| [51b73452] | 36 |  | 
|---|
| [a08ba92] | 37 | while ( current->get_link() != 0 ) | 
|---|
| [3848e0e] | 38 | current = current->get_link(); | 
|---|
| [51b73452] | 39 |  | 
|---|
| [a08ba92] | 40 | return current; | 
|---|
| [51b73452] | 41 | } | 
|---|
|  | 42 |  | 
|---|
| [59db689] | 43 | ParseNode *ParseNode::set_link( ParseNode *next_ ) { | 
|---|
|  | 44 | if ( next_ == 0 ) return this; | 
|---|
| [51b73452] | 45 |  | 
|---|
| [71bd8c6] | 46 | get_last()->next = next_; | 
|---|
| [51b73452] | 47 |  | 
|---|
| [a08ba92] | 48 | return this; | 
|---|
| [51b73452] | 49 | } | 
|---|
|  | 50 |  | 
|---|
| [a61fea9a] | 51 | void ParseNode::print( std::ostream &os, int indent ) const {} | 
|---|
| [51b73452] | 52 |  | 
|---|
|  | 53 |  | 
|---|
| [3848e0e] | 54 | void ParseNode::printList( std::ostream &os, int indent ) const { | 
|---|
| [a08ba92] | 55 | print( os, indent ); | 
|---|
| [51b73452] | 56 |  | 
|---|
| [a08ba92] | 57 | if ( next ) { | 
|---|
| [a61fea9a] | 58 | next->printList( os, indent ); | 
|---|
| [59db689] | 59 | } // if | 
|---|
| [51b73452] | 60 | } | 
|---|
|  | 61 |  | 
|---|
| [3848e0e] | 62 | ParseNode &ParseNode::operator,( ParseNode &p ) { | 
|---|
| [a08ba92] | 63 | set_link( &p ); | 
|---|
| [51b73452] | 64 |  | 
|---|
| [a08ba92] | 65 | return *this; | 
|---|
| [51b73452] | 66 | } | 
|---|
|  | 67 |  | 
|---|
| [bdd516a] | 68 | ParseNode *mkList( ParseNode &pn ) { | 
|---|
| [a08ba92] | 69 | // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking | 
|---|
|  | 70 | // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7)) | 
|---|
|  | 71 | // (although "nice" is probably not the word) | 
|---|
|  | 72 | return &pn; | 
|---|
| [51b73452] | 73 | } | 
|---|
|  | 74 |  | 
|---|
|  | 75 | // Local Variables: // | 
|---|
| [b87a5ed] | 76 | // tab-width: 4 // | 
|---|
|  | 77 | // mode: c++ // | 
|---|
|  | 78 | // compile-command: "make install" // | 
|---|
| [51b73452] | 79 | // End: // | 
|---|