[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 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[59db689] | 12 | // Last Modified On : Sat Jun 6 20:17:58 2015 |
---|
| 13 | // Update Count : 23 |
---|
[b87a5ed] | 14 | // |
---|
| 15 | |
---|
[51b7345] | 16 | #include "ParseNode.h" |
---|
| 17 | using namespace std; |
---|
| 18 | |
---|
| 19 | // Builder |
---|
| 20 | int ParseNode::indent_by = 4; |
---|
| 21 | |
---|
[59db689] | 22 | ParseNode::ParseNode() : name( 0 ), next( 0 ) {}; |
---|
| 23 | ParseNode::ParseNode( const string *name_ ) : name( name_ ), next( 0 ) {} |
---|
[51b7345] | 24 | |
---|
[59db689] | 25 | ParseNode::~ParseNode() { |
---|
[a08ba92] | 26 | delete next; |
---|
[51b7345] | 27 | }; |
---|
| 28 | |
---|
[59db689] | 29 | ParseNode *ParseNode::get_link() const { |
---|
[a08ba92] | 30 | return next; |
---|
[51b7345] | 31 | } |
---|
| 32 | |
---|
[59db689] | 33 | ParseNode *ParseNode::get_last() { |
---|
[a08ba92] | 34 | ParseNode *current = this; |
---|
[51b7345] | 35 | |
---|
[a08ba92] | 36 | while ( current->get_link() != 0 ) |
---|
[3848e0e] | 37 | current = current->get_link(); |
---|
[51b7345] | 38 | |
---|
[a08ba92] | 39 | return current; |
---|
[51b7345] | 40 | } |
---|
| 41 | |
---|
[59db689] | 42 | ParseNode *ParseNode::set_link( ParseNode *next_ ) { |
---|
[a08ba92] | 43 | ParseNode *follow; |
---|
[51b7345] | 44 | |
---|
[59db689] | 45 | if ( next_ == 0 ) return this; |
---|
[51b7345] | 46 | |
---|
[a08ba92] | 47 | for ( follow = this; follow->next != 0; follow = follow->next ); |
---|
[59db689] | 48 | follow->next = next_; |
---|
[51b7345] | 49 | |
---|
[a08ba92] | 50 | return this; |
---|
[51b7345] | 51 | } |
---|
| 52 | |
---|
[a61fea9a] | 53 | void ParseNode::print( std::ostream &os, int indent ) const {} |
---|
[51b7345] | 54 | |
---|
| 55 | |
---|
[3848e0e] | 56 | void ParseNode::printList( std::ostream &os, int indent ) const { |
---|
[a08ba92] | 57 | print( os, indent ); |
---|
[51b7345] | 58 | |
---|
[a08ba92] | 59 | if ( next ) { |
---|
[a61fea9a] | 60 | next->printList( os, indent ); |
---|
[59db689] | 61 | } // if |
---|
[51b7345] | 62 | } |
---|
| 63 | |
---|
[3848e0e] | 64 | ParseNode &ParseNode::operator,( ParseNode &p ) { |
---|
[a08ba92] | 65 | set_link( &p ); |
---|
[51b7345] | 66 | |
---|
[a08ba92] | 67 | return *this; |
---|
[51b7345] | 68 | } |
---|
| 69 | |
---|
[bdd516a] | 70 | ParseNode *mkList( ParseNode &pn ) { |
---|
[a08ba92] | 71 | // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking |
---|
| 72 | // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7)) |
---|
| 73 | // (although "nice" is probably not the word) |
---|
| 74 | return &pn; |
---|
[51b7345] | 75 | } |
---|
| 76 | |
---|
| 77 | // Local Variables: // |
---|
[b87a5ed] | 78 | // tab-width: 4 // |
---|
| 79 | // mode: c++ // |
---|
| 80 | // compile-command: "make install" // |
---|
[51b7345] | 81 | // End: // |
---|