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 Aug 12 13:26:00 2015 |
---|
13 | // Update Count : 36 |
---|
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_link() const { |
---|
31 | return next; |
---|
32 | } |
---|
33 | |
---|
34 | ParseNode *ParseNode::get_last() { |
---|
35 | ParseNode *current = this; |
---|
36 | |
---|
37 | while ( current->get_link() != 0 ) |
---|
38 | current = current->get_link(); |
---|
39 | |
---|
40 | return current; |
---|
41 | } |
---|
42 | |
---|
43 | ParseNode *ParseNode::set_link( ParseNode *next_ ) { |
---|
44 | if ( next_ == 0 ) return this; |
---|
45 | |
---|
46 | get_last()->next = next_; |
---|
47 | |
---|
48 | return this; |
---|
49 | } |
---|
50 | |
---|
51 | void ParseNode::print( std::ostream &os, int indent ) const {} |
---|
52 | |
---|
53 | |
---|
54 | void ParseNode::printList( std::ostream &os, int indent ) const { |
---|
55 | print( os, indent ); |
---|
56 | |
---|
57 | if ( next ) { |
---|
58 | next->printList( os, indent ); |
---|
59 | } // if |
---|
60 | } |
---|
61 | |
---|
62 | ParseNode &ParseNode::operator,( ParseNode &p ) { |
---|
63 | set_link( &p ); |
---|
64 | |
---|
65 | return *this; |
---|
66 | } |
---|
67 | |
---|
68 | ParseNode *mkList( ParseNode &pn ) { |
---|
69 | // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking |
---|
70 | // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7)) |
---|
71 | // (although "nice" is probably not the word) |
---|
72 | return &pn; |
---|
73 | } |
---|
74 | |
---|
75 | // Local Variables: // |
---|
76 | // tab-width: 4 // |
---|
77 | // mode: c++ // |
---|
78 | // compile-command: "make install" // |
---|
79 | // End: // |
---|