source: src/Parser/ParseNode.cc @ 5f2f2d7

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 5f2f2d7 was 59db689, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

constant types, first attempt

  • 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 : Peter A. Buhr
12// Last Modified On : Sat Jun  6 20:17:58 2015
13// Update Count     : 23
14//
15
16#include "ParseNode.h"
17using namespace std;
18
19// Builder
20int ParseNode::indent_by = 4;
21
22ParseNode::ParseNode() : name( 0 ), next( 0 ) {};
23ParseNode::ParseNode( const string *name_ ) : name( name_ ), next( 0 ) {}
24
25ParseNode::~ParseNode() {
26        delete next;
27};
28
29ParseNode *ParseNode::get_link() const {
30        return next;
31}
32
33ParseNode *ParseNode::get_last() {
34        ParseNode *current = this;
35
36        while ( current->get_link() != 0 )
37        current = current->get_link();
38
39        return current;
40}
41
42ParseNode *ParseNode::set_link( ParseNode *next_ ) {
43        ParseNode *follow;
44
45        if ( next_ == 0 ) return this;
46
47        for ( follow = this; follow->next != 0; follow = follow->next );
48        follow->next = next_;
49
50        return this;
51}
52
53void ParseNode::print( std::ostream &os, int indent ) const {}
54
55
56void ParseNode::printList( std::ostream &os, int indent ) const {
57        print( os, indent );
58
59        if ( next ) {
60                next->printList( os, indent );
61        } // if
62}
63
64ParseNode &ParseNode::operator,( ParseNode &p ) {
65        set_link( &p );
66
67        return *this;
68}
69
70ParseNode *mkList( ParseNode &pn ) {
71        // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking
72        // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7))
73        // (although "nice" is probably not the word)
74        return &pn;
75}
76
77// Local Variables: //
78// tab-width: 4 //
79// mode: c++ //
80// compile-command: "make install" //
81// End: //
Note: See TracBrowser for help on using the repository browser.