source: src/Parser/ParseNode.cc @ e869d663

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since e869d663 was e869d663, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

designator parsing and AST building

  • Property mode set to 100644
File size: 1.8 KB
Line 
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"
17using namespace std;
18
19// Builder
20int ParseNode::indent_by = 4;
21
22ParseNode::ParseNode() : next( 0 ) {};
23ParseNode::ParseNode( const string *name ) : name( *name ), next( 0 ) { delete name; }
24ParseNode::ParseNode( const string &name ) : name( name ), next( 0 ) { }
25
26ParseNode::~ParseNode() {
27        delete next;
28};
29
30ParseNode *ParseNode::get_link() const {
31        return next;
32}
33
34ParseNode *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
43ParseNode *ParseNode::set_link( ParseNode *next_ ) {
44        if ( next_ == 0 ) return this;
45
46        get_last()->next = next_;
47
48        return this;
49}
50
51void ParseNode::print( std::ostream &os, int indent ) const {}
52
53
54void 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
62ParseNode &ParseNode::operator,( ParseNode &p ) {
63        set_link( &p );
64
65        return *this;
66}
67
68ParseNode *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: //
Note: See TracBrowser for help on using the repository browser.