Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.cc

    r99cad3aa r7bf7fb9  
    1010// Created On       : Sat May 16 13:26:29 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 23:14:16 2016
    13 // Update Count     : 126
     12// Last Modified On : Sat Aug  6 08:26:11 2016
     13// Update Count     : 93
    1414//
    1515
     
    1717using namespace std;
    1818
     19// Builder
    1920int 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}
    2067
    2168// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.