source: src/Parser/ParseNode.cc@ f6d7e0f

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since f6d7e0f was 59db689, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

constant types, first attempt

  • 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
11// Last Modified By : Peter A. Buhr
[59db689]12// Last Modified On : Sat Jun 6 20:17:58 2015
13// Update Count : 23
[b87a5ed]14//
15
[51b73452]16#include "ParseNode.h"
17using namespace std;
18
19// Builder
20int ParseNode::indent_by = 4;
21
[59db689]22ParseNode::ParseNode() : name( 0 ), next( 0 ) {};
23ParseNode::ParseNode( const string *name_ ) : name( name_ ), next( 0 ) {}
[51b73452]24
[59db689]25ParseNode::~ParseNode() {
[a08ba92]26 delete next;
[51b73452]27};
28
[59db689]29ParseNode *ParseNode::get_link() const {
[a08ba92]30 return next;
[51b73452]31}
32
[59db689]33ParseNode *ParseNode::get_last() {
[a08ba92]34 ParseNode *current = this;
[51b73452]35
[a08ba92]36 while ( current->get_link() != 0 )
[3848e0e]37 current = current->get_link();
[51b73452]38
[a08ba92]39 return current;
[51b73452]40}
41
[59db689]42ParseNode *ParseNode::set_link( ParseNode *next_ ) {
[a08ba92]43 ParseNode *follow;
[51b73452]44
[59db689]45 if ( next_ == 0 ) return this;
[51b73452]46
[a08ba92]47 for ( follow = this; follow->next != 0; follow = follow->next );
[59db689]48 follow->next = next_;
[51b73452]49
[a08ba92]50 return this;
[51b73452]51}
52
[a61fea9a]53void ParseNode::print( std::ostream &os, int indent ) const {}
[51b73452]54
55
[3848e0e]56void ParseNode::printList( std::ostream &os, int indent ) const {
[a08ba92]57 print( os, indent );
[51b73452]58
[a08ba92]59 if ( next ) {
[a61fea9a]60 next->printList( os, indent );
[59db689]61 } // if
[51b73452]62}
63
[3848e0e]64ParseNode &ParseNode::operator,( ParseNode &p ) {
[a08ba92]65 set_link( &p );
[51b73452]66
[a08ba92]67 return *this;
[51b73452]68}
69
[bdd516a]70ParseNode *mkList( ParseNode &pn ) {
[a08ba92]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;
[51b73452]75}
76
77// Local Variables: //
[b87a5ed]78// tab-width: 4 //
79// mode: c++ //
80// compile-command: "make install" //
[51b73452]81// End: //
Note: See TracBrowser for help on using the repository browser.