[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
|
---|
[71bd8c6] | 11 | // Last Modified By : Rob Schluntz
|
---|
| 12 | // Last Modified On : Wed Jul 08 14:46:45 2015
|
---|
| 13 | // Update Count : 25
|
---|
[b87a5ed] | 14 | //
|
---|
| 15 |
|
---|
[51b73452] | 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 ) {}
|
---|
[51b73452] | 24 |
|
---|
[59db689] | 25 | ParseNode::~ParseNode() {
|
---|
[a08ba92] | 26 | delete next;
|
---|
[51b73452] | 27 | };
|
---|
| 28 |
|
---|
[59db689] | 29 | ParseNode *ParseNode::get_link() const {
|
---|
[a08ba92] | 30 | return next;
|
---|
[51b73452] | 31 | }
|
---|
| 32 |
|
---|
[59db689] | 33 | ParseNode *ParseNode::get_last() {
|
---|
[a08ba92] | 34 | ParseNode *current = this;
|
---|
[51b73452] | 35 |
|
---|
[a08ba92] | 36 | while ( current->get_link() != 0 )
|
---|
[3848e0e] | 37 | current = current->get_link();
|
---|
[51b73452] | 38 |
|
---|
[a08ba92] | 39 | return current;
|
---|
[51b73452] | 40 | }
|
---|
| 41 |
|
---|
[59db689] | 42 | ParseNode *ParseNode::set_link( ParseNode *next_ ) {
|
---|
| 43 | if ( next_ == 0 ) return this;
|
---|
[51b73452] | 44 |
|
---|
[71bd8c6] | 45 | get_last()->next = next_;
|
---|
[51b73452] | 46 |
|
---|
[a08ba92] | 47 | return this;
|
---|
[51b73452] | 48 | }
|
---|
| 49 |
|
---|
[a61fea9a] | 50 | void ParseNode::print( std::ostream &os, int indent ) const {}
|
---|
[51b73452] | 51 |
|
---|
| 52 |
|
---|
[3848e0e] | 53 | void ParseNode::printList( std::ostream &os, int indent ) const {
|
---|
[a08ba92] | 54 | print( os, indent );
|
---|
[51b73452] | 55 |
|
---|
[a08ba92] | 56 | if ( next ) {
|
---|
[a61fea9a] | 57 | next->printList( os, indent );
|
---|
[59db689] | 58 | } // if
|
---|
[51b73452] | 59 | }
|
---|
| 60 |
|
---|
[3848e0e] | 61 | ParseNode &ParseNode::operator,( ParseNode &p ) {
|
---|
[a08ba92] | 62 | set_link( &p );
|
---|
[51b73452] | 63 |
|
---|
[a08ba92] | 64 | return *this;
|
---|
[51b73452] | 65 | }
|
---|
| 66 |
|
---|
[bdd516a] | 67 | ParseNode *mkList( ParseNode &pn ) {
|
---|
[a08ba92] | 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;
|
---|
[51b73452] | 72 | }
|
---|
| 73 |
|
---|
| 74 | // Local Variables: //
|
---|
[b87a5ed] | 75 | // tab-width: 4 //
|
---|
| 76 | // mode: c++ //
|
---|
| 77 | // compile-command: "make install" //
|
---|
[51b73452] | 78 | // End: //
|
---|