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