[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
|
---|
[ca35c51] | 11 | // Last Modified By : Peter A. Buhr
|
---|
[d1625f8] | 12 | // Last Modified On : Sun Aug 7 23:32:47 2016
|
---|
| 13 | // Update Count : 94
|
---|
[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_last() {
|
---|
[a08ba92] | 31 | ParseNode *current = this;
|
---|
[51b73452] | 32 |
|
---|
[a08ba92] | 33 | while ( current->get_link() != 0 )
|
---|
[3848e0e] | 34 | current = current->get_link();
|
---|
[51b73452] | 35 |
|
---|
[a08ba92] | 36 | return current;
|
---|
[51b73452] | 37 | }
|
---|
| 38 |
|
---|
[59db689] | 39 | ParseNode *ParseNode::set_link( ParseNode *next_ ) {
|
---|
[4e06c1e] | 40 | if ( next_ != 0 ) get_last()->next = next_;
|
---|
[a08ba92] | 41 | return this;
|
---|
[51b73452] | 42 | }
|
---|
| 43 |
|
---|
[a61fea9a] | 44 | void ParseNode::print( std::ostream &os, int indent ) const {}
|
---|
[51b73452] | 45 |
|
---|
| 46 |
|
---|
[3848e0e] | 47 | void ParseNode::printList( std::ostream &os, int indent ) const {
|
---|
[a08ba92] | 48 | print( os, indent );
|
---|
[51b73452] | 49 |
|
---|
[a08ba92] | 50 | if ( next ) {
|
---|
[a61fea9a] | 51 | next->printList( os, indent );
|
---|
[59db689] | 52 | } // if
|
---|
[51b73452] | 53 | }
|
---|
| 54 |
|
---|
[3848e0e] | 55 | ParseNode &ParseNode::operator,( ParseNode &p ) {
|
---|
[a08ba92] | 56 | set_link( &p );
|
---|
[51b73452] | 57 |
|
---|
[a08ba92] | 58 | return *this;
|
---|
[51b73452] | 59 | }
|
---|
| 60 |
|
---|
[bdd516a] | 61 | ParseNode *mkList( ParseNode &pn ) {
|
---|
[a08ba92] | 62 | // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking
|
---|
| 63 | // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7))
|
---|
| 64 | // (although "nice" is probably not the word)
|
---|
| 65 | return &pn;
|
---|
[51b73452] | 66 | }
|
---|
| 67 |
|
---|
| 68 | // Local Variables: //
|
---|
[b87a5ed] | 69 | // tab-width: 4 //
|
---|
| 70 | // mode: c++ //
|
---|
| 71 | // compile-command: "make install" //
|
---|
[51b73452] | 72 | // End: //
|
---|