source: src/Parser/ParseNode.cc @ 220ca4a

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 220ca4a 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
RevLine 
[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
[e869d663]11// Last Modified By : Rob Schluntz
12// Last Modified On : Wed Aug 12 13:26:00 2015
13// Update Count     : 36
[b87a5ed]14//
15
[51b7345]16#include "ParseNode.h"
17using namespace std;
18
19// Builder
20int ParseNode::indent_by = 4;
21
[e869d663]22ParseNode::ParseNode() : next( 0 ) {};
23ParseNode::ParseNode( const string *name ) : name( *name ), next( 0 ) { delete name; }
24ParseNode::ParseNode( const string &name ) : name( name ), next( 0 ) { }
[51b7345]25
[59db689]26ParseNode::~ParseNode() {
[e869d663]27        delete next;
[51b7345]28};
29
[59db689]30ParseNode *ParseNode::get_link() const {
[a08ba92]31        return next;
[51b7345]32}
33
[59db689]34ParseNode *ParseNode::get_last() {
[a08ba92]35        ParseNode *current = this;
[51b7345]36
[a08ba92]37        while ( current->get_link() != 0 )
[3848e0e]38        current = current->get_link();
[51b7345]39
[a08ba92]40        return current;
[51b7345]41}
42
[59db689]43ParseNode *ParseNode::set_link( ParseNode *next_ ) {
44        if ( next_ == 0 ) return this;
[51b7345]45
[71bd8c6]46        get_last()->next = next_;
[51b7345]47
[a08ba92]48        return this;
[51b7345]49}
50
[a61fea9a]51void ParseNode::print( std::ostream &os, int indent ) const {}
[51b7345]52
53
[3848e0e]54void ParseNode::printList( std::ostream &os, int indent ) const {
[a08ba92]55        print( os, indent );
[51b7345]56
[a08ba92]57        if ( next ) {
[a61fea9a]58                next->printList( os, indent );
[59db689]59        } // if
[51b7345]60}
61
[3848e0e]62ParseNode &ParseNode::operator,( ParseNode &p ) {
[a08ba92]63        set_link( &p );
[51b7345]64
[a08ba92]65        return *this;
[51b7345]66}
67
[bdd516a]68ParseNode *mkList( ParseNode &pn ) {
[a08ba92]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;
[51b7345]73}
74
75// Local Variables: //
[b87a5ed]76// tab-width: 4 //
77// mode: c++ //
78// compile-command: "make install" //
[51b7345]79// End: //
Note: See TracBrowser for help on using the repository browser.