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
|
---|
12 | // Last Modified On : Sun Aug 7 23:32:47 2016
|
---|
13 | // Update Count : 94
|
---|
14 | //
|
---|
15 |
|
---|
16 | #include "ParseNode.h"
|
---|
17 | using namespace std;
|
---|
18 |
|
---|
19 | // Builder
|
---|
20 | int ParseNode::indent_by = 4;
|
---|
21 |
|
---|
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 ) { }
|
---|
25 |
|
---|
26 | ParseNode::~ParseNode() {
|
---|
27 | delete next;
|
---|
28 | };
|
---|
29 |
|
---|
30 | ParseNode *ParseNode::get_last() {
|
---|
31 | ParseNode *current = this;
|
---|
32 |
|
---|
33 | while ( current->get_link() != 0 )
|
---|
34 | current = current->get_link();
|
---|
35 |
|
---|
36 | return current;
|
---|
37 | }
|
---|
38 |
|
---|
39 | ParseNode *ParseNode::set_link( ParseNode *next_ ) {
|
---|
40 | if ( next_ != 0 ) get_last()->next = next_;
|
---|
41 | return this;
|
---|
42 | }
|
---|
43 |
|
---|
44 | void ParseNode::print( std::ostream &os, int indent ) const {}
|
---|
45 |
|
---|
46 |
|
---|
47 | void ParseNode::printList( std::ostream &os, int indent ) const {
|
---|
48 | print( os, indent );
|
---|
49 |
|
---|
50 | if ( next ) {
|
---|
51 | next->printList( os, indent );
|
---|
52 | } // if
|
---|
53 | }
|
---|
54 |
|
---|
55 | ParseNode &ParseNode::operator,( ParseNode &p ) {
|
---|
56 | set_link( &p );
|
---|
57 |
|
---|
58 | return *this;
|
---|
59 | }
|
---|
60 |
|
---|
61 | ParseNode *mkList( ParseNode &pn ) {
|
---|
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;
|
---|
66 | }
|
---|
67 |
|
---|
68 | // Local Variables: //
|
---|
69 | // tab-width: 4 //
|
---|
70 | // mode: c++ //
|
---|
71 | // compile-command: "make install" //
|
---|
72 | // End: //
|
---|