source: src/Parser/ParseNode.cc@ db82596

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 db82596 was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

licencing: seventh groups of files

  • Property mode set to 100644
File size: 2.1 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
[a08ba92]12// Last Modified On : Tue May 19 16:48:30 2015
13// Update Count : 3
[b87a5ed]14//
15
[51b73452]16#include "ParseNode.h"
17using namespace std;
18
19// Builder
20int ParseNode::indent_by = 4;
21
[3848e0e]22ParseNode::ParseNode( void ) : next( 0 ) {};
23ParseNode::ParseNode( string _name ) : name( _name ), next( 0 ) {}
[51b73452]24
[3848e0e]25ParseNode *ParseNode::set_name( string _name ) {
[a08ba92]26 name = _name;
27 return this;
[51b73452]28}
29
[3848e0e]30ParseNode *ParseNode::set_name( string *_name ) {
[a08ba92]31 name = *_name; // deep copy
32 delete _name;
[51b73452]33
[a08ba92]34 return this;
[51b73452]35}
36
[3848e0e]37ParseNode::~ParseNode( void ) {
[a08ba92]38 delete next;
[51b73452]39};
40
[3848e0e]41string ParseNode::get_name( void ) {
[a08ba92]42 return name;
[51b73452]43}
44
[3848e0e]45ParseNode *ParseNode::get_link( void ) const {
[a08ba92]46 return next;
[51b73452]47}
48
49ParseNode *ParseNode::get_last(void) {
[a08ba92]50 ParseNode *current = this;
[51b73452]51
[a08ba92]52 while ( current->get_link() != 0 )
[3848e0e]53 current = current->get_link();
[51b73452]54
[a08ba92]55 return current;
[51b73452]56}
57
[a08ba92]58ParseNode *ParseNode::set_link(ParseNode *_next) {
59 ParseNode *follow;
[51b73452]60
[a08ba92]61 if ( _next == 0 ) return this;
[51b73452]62
[a08ba92]63 for ( follow = this; follow->next != 0; follow = follow->next );
64 follow->next = _next;
[51b73452]65
[a08ba92]66 return this;
[51b73452]67}
68
69const string ParseNode::get_name(void) const {
[a08ba92]70 return name;
[51b73452]71}
72
[3848e0e]73void ParseNode::print(std::ostream &os, int indent) const {}
[51b73452]74
75
[3848e0e]76void ParseNode::printList( std::ostream &os, int indent ) const {
[a08ba92]77 print( os, indent );
[51b73452]78
[a08ba92]79 if ( next ) {
[3848e0e]80 next->printList( os, indent );
[a08ba92]81 }
[51b73452]82}
83
[3848e0e]84ParseNode &ParseNode::operator,( ParseNode &p ) {
[a08ba92]85 set_link( &p );
[51b73452]86
[a08ba92]87 return *this;
[51b73452]88}
89
[bdd516a]90ParseNode *mkList( ParseNode &pn ) {
[a08ba92]91 // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking
92 // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7))
93 // (although "nice" is probably not the word)
94 return &pn;
[51b73452]95}
96
97// Local Variables: //
[b87a5ed]98// tab-width: 4 //
99// mode: c++ //
100// compile-command: "make install" //
[51b73452]101// End: //
Note: See TracBrowser for help on using the repository browser.