source: src/Parser/ParseNode.cc @ d2f5469

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since d2f5469 was d1625f8, checked in by Peter A. Buhr <pabuhr@…>, 8 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 : Sun Aug  7 23:32:47 2016
13// Update Count     : 94
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_link() != 0 )
34        current = current->get_link();
35
36        return current;
37}
38
39ParseNode *ParseNode::set_link( ParseNode *next_ ) {
40        if ( next_ != 0 ) get_last()->next = next_;
41        return this;
42}
43
44void ParseNode::print( std::ostream &os, int indent ) const {}
45
46
47void ParseNode::printList( std::ostream &os, int indent ) const {
48        print( os, indent );
49
50        if ( next ) {
51                next->printList( os, indent );
52        } // if
53}
54
55ParseNode &ParseNode::operator,( ParseNode &p ) {
56        set_link( &p );
57
58        return *this;
59}
60
61ParseNode *mkList( ParseNode &pn ) {
62        // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking
63        // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7))
64        // (although "nice" is probably not the word)
65        return &pn;
66}
67
68// Local Variables: //
69// tab-width: 4 //
70// mode: c++ //
71// compile-command: "make install" //
72// End: //
Note: See TracBrowser for help on using the repository browser.