source: src/Parser/ParseNode.cc@ 797347f

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

more refactoring of parser code

  • Property mode set to 100644
File size: 1.7 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 Aug 13 18:55:35 2016
13// Update Count : 98
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_last() {
31 ParseNode *current = this;
32
33 while ( current->get_next() != 0 )
34 current = current->get_next();
35 return current;
36}
37
38ParseNode *ParseNode::set_last( ParseNode *next_ ) {
39 if ( next_ != 0 ) get_last()->next = next_;
40 return this;
41}
42
43void ParseNode::print( std::ostream &os, int indent ) const {}
44
45
46void ParseNode::printList( std::ostream &os, int indent ) const {
47 print( os, indent );
48
49 if ( next ) {
50 next->printList( os, indent );
51 } // if
52}
53
54ParseNode &ParseNode::operator,( ParseNode &p ) {
55 set_last( &p );
56 return *this;
57}
58
59ParseNode *mkList( ParseNode &pn ) {
60 // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking
61 // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7))
62 // (although "nice" is probably not the word)
63 return &pn;
64}
65
66// Local Variables: //
67// tab-width: 4 //
68// mode: c++ //
69// compile-command: "make install" //
70// End: //
Note: See TracBrowser for help on using the repository browser.