Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

echonormalizer.cpp

Go to the documentation of this file.
00001 #include "echonormalizer.h"
00002 #include "stree.h"
00003 #include "streeconstant.h"
00004 
00005 Node* EchoNormalizer::transform(Node *node) const{
00006 /*  if (node->getName() != CStatementList)*/ return node;
00007 
00008   StatementList *statementList = dynamic_cast<StatementList *>(node);
00009   // TODO : zmienic "Echo" na CEcho i inne takie
00010 
00011   StatementList new_list;
00012 #ifdef ciebie_debug
00013   cout << "Normalizing statement list: BEGIN" << endl;
00014 #endif
00015   StatementList::const_iterator it = statementList->begin();
00016   StatementList::const_iterator eit = statementList->end();
00017   while (it!=eit){
00018     if (((*it)->getName() == "Echo") && 
00019         (dynamic_cast<Echo*>(*it)->front()->getName() == "ExpressionList"))
00020       {
00021 #ifdef ciebie_debug
00022         cout << "ECHO" << endl;
00023 #endif
00024         Echo *l = dynamic_cast<Echo*>(*it);
00025         ExpressionList *e = dynamic_cast<ExpressionList*>(l->front());
00026         list<Node*>::iterator nl = e->begin();
00027         list<Node*>::iterator enl = e->end();
00028         while (nl!=enl) {
00029           if ((*nl)->getName() == "DoubleQuote") {
00030             EncapsList *e = dynamic_cast<EncapsList*>(dynamic_cast<DoubleQuote*>(*nl)->front());
00031             list<Node*>::iterator nl = e->begin();
00032             list<Node*>::iterator enl = e->end();
00033             while (nl!=enl) {
00034               if (((*nl)->getName() == "Constant") && (dynamic_cast<Constant*>(*nl)->getValue()[0] == '$'))
00035                 new_list.push_back(new Echo(new ExpressionList(new DoubleQuote(*nl))));
00036               else 
00037                 new_list.push_back(new Echo(new ExpressionList((*nl))));
00038               nl++;
00039             }
00040 
00041           } else {
00042             new_list.push_back(new Echo(new ExpressionList(*nl)));        
00043 #ifdef ciebie_debug
00044             cout << "New ECHO " << (*nl)->getName() << endl;
00045 #endif
00046           }
00047           nl++;
00048         }
00049       }
00050     else
00051       {
00052         new_list.push_back(*it);
00053       }
00054     it++;
00055   };
00056   statementList->clear();
00057   swap(*statementList,new_list);
00058   /*
00059   while (!new_list.empty()) {
00060     statementList->push_back(new_list.front());
00061     new_list.pop_front();
00062     }
00063   */
00064 #ifdef ciebie_debug
00065   cout << "Normalizing statement list: END" << endl;
00066 #endif
00067   return node;
00068 };

Generated on Fri Nov 21 17:54:02 2003 for PHPX by doxygen 1.3.3