/* -*- C++ -*- */ #include "ParseNode.h" using namespace std; // Builder int ParseNode::indent_by = 4; // ParseNode::ParseNode(void): next( 0 ) {}; ParseNode::ParseNode( std::string _name, char *filename, int lineno ) : name(_name), next( 0 ), filename( filename ), lineno( lineno ) { } ParseNode *ParseNode::set_name (string _name) { name = _name; return this; } ParseNode *ParseNode::set_name (string *_name) { name = *_name; // deep copy delete _name; return this; } ParseNode::~ParseNode(void){ delete next; }; string ParseNode::get_name(void) { return name; } ParseNode *ParseNode::get_link(void) const { return next; } ParseNode *ParseNode::get_last(void) { ParseNode * current = this; while(current->get_link() != 0) current = current->get_link(); return current; } ParseNode *ParseNode::set_link(ParseNode *_next){ ParseNode *follow; if(_next == 0) return this; for(follow = this; follow->next != 0; follow = follow->next); follow->next = _next; return this; } const string ParseNode::get_name(void) const { return name; } void ParseNode::print(std::ostream &os, int indent) const { } void ParseNode::printList(std::ostream &os, int indent) const { print( os, indent ); if( next ) { next->printList( os, indent ); } } ParseNode &ParseNode::operator,(ParseNode &p){ set_link(&p); return *this; } ParseNode *mkList(ParseNode &pn){ /* it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7)) (although "nice" is probably not the word) */ return &pn; } // Local Variables: // // mode: C++ // // compile-command: "gmake" // // End: //