00001 #ifndef _STREE_H_ 00002 #define _STREE_H_ 00003 00004 #include <iostream> 00005 #include <algorithm> 00006 00007 #include "streenamedlist.h" 00008 00009 #define CMainList "MainList" 00010 00011 #define CStatementList "StatementList" 00012 #define CExpressionList "ExpressionList" 00013 #define CDeclareList "DeclareList" 00014 #define CArrayPairList "ArrayPairList" 00015 #define CTemplateList "TemplateList" 00016 #define CInlineHTMLList "InlineHTMLList" 00017 00018 #define CPHP "PHP" 00019 #define CEchoPHP "EchoPHP" 00020 00021 #define CCurlyBraces "CurlyBraces" 00022 #define CSmartyBraces "SmartyBraces" 00023 #define CDoubleQuote "DoubleQuote" 00024 00025 #define CIf "If" 00026 #define CFor "For" 00027 #define CWhile "While" 00028 #define CDo "Do" 00029 #define CSwitch "Switch" 00030 #define CBreak "Break" 00031 #define CContinue "Continue" 00032 #define CReturn "Return" 00033 #define CGlobal "Global" 00034 #define CStatic "Static" 00035 #define CEcho "Echo" 00036 #define CTemplate "Template" 00037 #define CSmartyAssign "SmartyAssign" 00038 #define CInlineHTML "InlineHTML" 00039 #define CExpression "Expression" 00040 #define CUnset "Unset" 00041 #define CUse "Use" 00042 #define CForeach "Foreach" 00043 #define CDeclare "Declare" 00044 #define CEmptyStatement "EmptyStatement" 00045 #define CFunction "Function" 00046 #define CClass "Class" 00047 00048 #define CCaseList "CaseList" 00049 #define CEncapsList "EncapsList" 00050 #define CAssignmentList "AssignmentList" 00051 00052 #define CConst "Const" 00053 #define CCase "Case" 00054 #define CParameter "Parameter" 00055 #define CClassVariable "ClassVariable" 00056 #define CUnaryOperator "UnaryOperator" 00057 #define CPostUnaryOperator "PostUnaryOperator" 00058 #define CBinaryOperator "BinaryOperator" 00059 #define CAList "AList" 00060 #define CEncapsExpr "EncapsExpr" 00061 #define CAskOperator "AskOperator" 00062 #define CExit "Exit" 00063 #define CPrint "Print" 00064 #define CArray "Array" 00065 #define CFunctionCall "FunctionCall" 00066 #define CArrayPair "ArrayPair" 00067 #define CObjectOperator "ObjectOperator" 00068 #define CArrayOperator "ArrayOperator" 00069 #define CMapOperator "MapOperator" 00070 #define OpRef "$" 00071 #define CIsset "Isset" 00072 #define CConstantEncapsedString "ConstantEncapsedString" 00073 #define CPHPVariable "PHPVariable" 00074 #define CConstantString "ConstantString" 00075 00077 class StatementList : public NamedList{ 00078 public: 00080 StatementList() ; 00082 StatementList(Node *statement) ; 00083 00084 virtual ostream& php(ostream &os) const; 00085 00086 virtual Node* copy() const; 00087 }; 00088 00090 class InlineHTMLList : public NamedList{ 00091 public: 00093 InlineHTMLList() ; 00095 InlineHTMLList(Node *statement) ; 00096 00097 virtual ostream& php(ostream &os) const; 00098 00099 virtual Node* copy() const; 00100 }; 00101 00103 class TemplateList : public NamedList{ 00104 public: 00106 TemplateList() ; 00108 TemplateList(Node *statement); 00109 00110 virtual ostream& php(ostream &os) const; 00111 00112 virtual Node* copy() const; 00113 }; 00114 00116 class ExpressionList : public NamedList{ 00117 public: 00119 ExpressionList() ; 00121 ExpressionList(Node *statement) ; 00122 00123 virtual ostream& php(ostream &os) const; 00124 00125 virtual Node* copy() const; 00126 }; 00127 00129 class ArrayPairList : public NamedList{ 00130 public: 00132 ArrayPairList() ; 00134 ArrayPairList(Node *statement) ; 00135 00136 virtual ostream& php(ostream &os) const; 00137 00138 virtual Node* copy() const; 00139 }; 00140 00142 class DeclareList : public NamedList{ 00143 public: 00145 DeclareList() ; 00147 DeclareList(Node *statement) ; 00148 00149 virtual ostream& php(ostream &os) const; 00150 00151 virtual Node* copy() const; 00152 }; 00153 00155 class CaseList : public NamedList{ 00156 public: 00158 CaseList() ; 00160 CaseList(Node *statement) ; 00161 00162 virtual ostream& php(ostream &os) const; 00163 00164 virtual Node* copy() const; 00165 }; 00166 00168 class EncapsList : public NamedList{ 00169 public: 00171 EncapsList() ; 00173 EncapsList(Node *statement) ; 00174 00175 virtual ostream& php(ostream &os) const; 00176 00177 virtual Node* copy() const; 00178 00179 virtual string evaluate(const NameSpace &nameSpace) const; 00180 }; 00181 00183 class AssignmentList : public NamedList{ 00184 public: 00186 AssignmentList() ; 00188 AssignmentList(Node *statement) ; 00189 00190 virtual ostream& php(ostream &os) const; 00191 virtual Node* copy() const; 00192 }; 00193 00195 class PHP : public Unary{ 00196 public: 00198 PHP(Node *statement); 00199 00200 virtual ostream& php(ostream &os) const; 00201 virtual Node* copy() const; 00202 }; 00203 00205 class EchoPHP : public Unary{ 00206 public: 00208 EchoPHP(Node *statement) ; 00209 00210 virtual ostream& php(ostream &os) const; 00211 virtual Node* copy() const; 00212 }; 00213 00215 class CurlyBraces : public Unary{ 00216 public: 00218 CurlyBraces(Node *statement) ; 00219 00220 virtual ostream& php(ostream &os) const; 00221 00222 virtual Node* copy() const; 00223 }; 00224 00226 class SmartyBraces : public Unary{ 00227 public: 00229 SmartyBraces(Node *statement) ; 00230 00231 virtual ostream& php(ostream &os) const; 00232 virtual Node* copy() const; 00233 }; 00234 00236 class DoubleQuote : public Unary{ 00237 public: 00239 DoubleQuote(Node *statement) ; 00240 00241 virtual ostream& php(ostream &os) const; 00242 virtual Node* copy() const; 00243 00244 virtual string evaluate(const NameSpace &nameSpace) const; 00245 }; 00246 00248 00254 class If : public Ternary{ 00255 public: 00257 If(Node* statement1, Node* statement2, Node* statement3) ; 00258 00259 virtual ostream& php(ostream &os) const; 00260 00261 virtual Node* copy() const; 00262 }; 00263 00265 00270 class For : public Quadary{ 00271 public: 00273 For(Node* statement1, Node* statement2, Node* statement3, Node* statement4); 00274 00275 virtual ostream& php(ostream &os) const; 00276 00277 virtual Node* copy() const; 00278 }; 00279 00281 00286 class While : public Binary{ 00287 public: 00289 While(Node* statement1, Node* statement2); 00290 00291 virtual ostream& php(ostream &os) const; 00292 virtual Node* copy() const; 00293 }; 00294 00296 00301 class Do : public Binary{ 00302 public: 00304 Do(Node* statement1, Node* statement2) ; 00305 00306 virtual ostream& php(ostream &os) const; 00307 virtual Node* copy() const; 00308 }; 00309 00311 00316 class Switch : public Binary{ 00317 public: 00319 Switch(Node* statement1, Node* statement2) ; 00320 00321 virtual ostream& php(ostream &os) const; 00322 virtual Node* copy() const; 00323 }; 00324 00326 00329 class Break : public Unary{ 00330 public: 00332 Break(Node *statement) ; 00333 00334 virtual ostream& php(ostream &os) const; 00335 00336 virtual Node* copy() const; 00337 }; 00338 00340 00343 class Continue : public Unary{ 00344 public: 00346 Continue(Node *statement) ; 00347 00348 virtual ostream& php(ostream &os) const; 00349 virtual Node* copy() const; 00350 }; 00351 00353 00356 class Return : public Unary{ 00357 public: 00359 Return(Node *statement) ; 00360 00361 virtual ostream& php(ostream &os) const; 00362 virtual Node* copy() const; 00363 }; 00364 00366 class Global : public Unary{ 00367 public: 00369 Global(Node *statement) ; 00370 00371 virtual ostream& php(ostream &os) const; 00372 00373 virtual Node* copy() const; 00374 }; 00375 00377 class Static : public Unary{ 00378 public: 00380 Static(Node *statement); 00381 00382 virtual ostream& php(ostream &os) const; 00383 virtual Node* copy() const; 00384 }; 00385 00387 class Echo : public Unary{ 00388 public: 00390 Echo(Node *statement) ; 00391 00392 virtual ostream& php(ostream &os) const; 00393 00394 virtual Node* copy() const; 00395 }; 00396 00398 class Template : public Unary{ 00399 public: 00401 Template(Node *statement) ; 00402 00403 virtual ostream& php(ostream &os) const; 00404 00405 virtual Node* copy() const; 00406 }; 00407 00409 00415 class SmartyAssign : public Binary{ 00417 string phpOut; 00418 public: 00420 SmartyAssign(Node* statement1, Node* statement2) ; 00422 SmartyAssign(Node* statement1, Node* statement2, string iphpOut) ; 00423 00424 virtual ostream& php(ostream &os) const; 00425 00427 const Node* getVariable() const; 00428 00430 const Node* getAssignment() const; 00431 00433 void setPHPOut(string iphpOut); 00434 00435 virtual Node* copy() const; 00436 }; 00437 00439 class InlineHTML : public Unary{ 00440 public: 00442 InlineHTML(Node *statement) ; 00443 00444 virtual ostream& php(ostream &os) const; 00445 00446 virtual Node* copy() const; 00447 00449 string getHTML() const; 00451 void setHTML(const string &html); 00452 }; 00453 00455 class Expression : public Unary{ 00456 public: 00458 Expression(Node *statement) ; 00459 00460 virtual ostream& php(ostream &os) const; 00461 00462 virtual Node* copy() const; 00463 }; 00464 00466 class Unset : public Unary{ 00467 public: 00469 Unset(Node *statement) ; 00470 00471 virtual ostream& php(ostream &os) const; 00472 00473 virtual Node* copy() const; 00474 }; 00475 00477 class Use : public Unary{ 00478 public: 00480 Use(Node *statement) ; 00481 00482 virtual ostream& php(ostream &os) const; 00483 00484 virtual Node* copy() const; 00485 }; 00486 00488 00495 class Foreach : public Quadary{ 00496 public: 00498 Foreach(Node* statement1, Node* statement2, Node* statement3, Node* statement4) ; 00499 00500 virtual ostream& php(ostream &os) const; 00501 00502 virtual Node* copy() const; 00503 }; 00504 00506 00511 class Declare : public Binary{ 00512 public: 00514 Declare(Node* statement1, Node* statement2) ; 00515 00516 virtual ostream& php(ostream &os) const; 00517 00518 virtual Node* copy() const; 00519 }; 00520 00522 00524 class EmptyStatement : public Nullary{ 00525 public: 00527 EmptyStatement() ; 00528 00529 virtual ostream& php(ostream &os) const; 00530 virtual Node* copy() const; 00531 }; 00532 00534 00541 class Function : public Quadary{ 00542 public: 00544 Function(Node* statement1, Node* statement2, Node* statement3, Node* statement4) ; 00545 00546 virtual ostream& php(ostream &os) const; 00547 00548 virtual Node* copy() const; 00549 }; 00550 00552 00558 class Class : public Ternary{ 00559 public: 00561 Class(Node* statement1, Node* statement2, Node* statement3) ; 00562 00563 virtual ostream& php(ostream &os) const; 00564 00565 virtual Node* copy() const; 00566 }; 00567 00569 class Const : public Binary{ 00570 public: 00572 Const(Node* statement1, Node* statement2) ; 00573 00574 virtual ostream& php(ostream &os) const; 00575 00576 virtual Node* copy() const; 00577 }; 00578 00580 class Case : public Binary{ 00581 public: 00583 Case(Node* statement1, Node* statement2); 00584 00585 virtual ostream& php(ostream &os) const; 00586 00587 virtual Node* copy() const; 00588 }; 00589 00591 00597 class Parameter : public Ternary{ 00598 public: 00600 Parameter(Node* statement1, Node* statement2, Node* statement3) ; 00601 00602 virtual ostream& php(ostream &os) const; 00603 00604 virtual Node* copy() const; 00605 }; 00606 00608 class ClassVariable : public Unary{ 00609 public: 00611 ClassVariable(Node *statement) ; 00612 00613 virtual ostream& php(ostream &os) const; 00614 00615 virtual Node* copy() const; 00616 }; 00617 00619 00622 class UnaryOperator : public Binary{ 00623 public: 00625 UnaryOperator(string oname, Node* statement2) ; 00626 00627 virtual ostream& php(ostream &os) const; 00628 00629 virtual Node* copy() const; 00630 00631 virtual string evaluate(const NameSpace &nameSpace) const; 00632 }; 00633 00635 00638 class PostUnaryOperator : public Binary{ 00639 public: 00641 PostUnaryOperator(string oname, Node* statement2) ; 00642 00643 virtual ostream& php(ostream &os) const; 00644 00645 virtual Node* copy() const; 00646 00647 virtual string evaluate(const NameSpace &nameSpace) const; 00648 }; 00649 00651 00654 class BinaryOperator : public Ternary{ 00655 public: 00657 BinaryOperator(string oname, Node* statement2, Node* statement3) ; 00658 BinaryOperator(Node* ioperator, Node* statement2, Node* statement3) ; 00659 00660 virtual ostream& php(ostream &os) const; 00661 00662 virtual Node* copy() const; 00663 00664 virtual string evaluate(const NameSpace &nameSpace) const; 00665 }; 00666 00668 class AList : public Unary{ 00669 public: 00671 AList(Node *statement); 00672 00673 virtual ostream& php(ostream &os) const; 00674 00675 virtual Node* copy() const; 00676 }; 00677 00679 class EncapsExpr : public Ternary{ 00680 public: 00682 EncapsExpr(string ebegin, Node *statement, string eend) ; 00683 00684 virtual ostream& php(ostream &os) const; 00685 00686 virtual Node* copy() const; 00687 00688 virtual string evaluate(const NameSpace &nameSpace) const; 00689 }; 00690 00692 class AskOperator : public Ternary{ 00693 public: 00695 AskOperator(Node* statement1, Node* statement2, Node* statement3); 00696 00697 virtual ostream& php(ostream &os) const; 00698 00699 virtual Node* copy() const; 00700 00701 virtual string evaluate(const NameSpace &nameSpace) const; 00702 }; 00703 00705 class Exit : public Unary{ 00706 public: 00708 Exit(Node *statement) ; 00709 00710 virtual ostream& php(ostream &os) const; 00711 00712 virtual Node* copy() const; 00713 }; 00714 00716 class Print : public Unary{ 00717 public: 00719 Print(Node *statement) ; 00720 00721 virtual ostream& php(ostream &os) const; 00722 00723 virtual Node* copy() const; 00724 }; 00725 00727 class Array : public Unary{ 00728 public: 00730 Array(Node *statement) ; 00731 00732 virtual ostream& php(ostream &os) const; 00733 00734 virtual Node* copy() const; 00735 }; 00736 00738 00744 class FunctionCall : public Ternary{ 00745 public: 00747 FunctionCall(Node* statement1, Node* statement2, Node* statement3) ; 00748 00749 virtual ostream& php(ostream &os) const; 00750 00751 virtual Node* copy() const; 00752 }; 00753 00755 00760 class ArrayPair : public Binary{ 00761 public: 00763 ArrayPair(Node* statement1, Node* statement2) ; 00764 00765 virtual ostream& php(ostream &os) const; 00766 00767 virtual Node* copy() const; 00768 }; 00769 00771 00776 class ObjectOperator : public Binary{ 00777 public: 00779 ObjectOperator(Node* statement1, Node* statement2) ; 00780 00781 virtual ostream& php(ostream &os) const; 00782 00783 virtual Node* copy() const; 00784 }; 00785 00787 00792 class ArrayOperator : public Binary{ 00793 public: 00795 ArrayOperator(Node* statement1, Node* statement2) ; 00796 00797 virtual ostream& php(ostream &os) const; 00798 00799 virtual Node* copy() const; 00800 }; 00801 00803 class MapOperator : public Binary{ 00804 public: 00806 MapOperator(Node* statement1, Node* statement2) ; 00807 00808 virtual ostream& php(ostream &os) const; 00809 00810 virtual Node* copy() const; 00811 }; 00812 00814 class Ref : public UnaryOperator{ 00815 public: 00817 Ref(Node* statement) ; 00818 }; 00819 00821 class Isset : public Unary{ 00822 public: 00824 Isset(Node *statement) ; 00825 00826 virtual ostream& php(ostream &os) const; 00827 00828 virtual Node* copy() const; 00829 }; 00830 00832 class ConstantEncapsedString : public Unary{ 00833 public: 00835 ConstantEncapsedString(Node *statement) ; 00836 00837 virtual ostream& php(ostream &os) const; 00838 00839 virtual Node* copy() const; 00840 00841 virtual string evaluate(const NameSpace &nameSpace) const; 00842 }; 00843 00845 class ConstantString : public Unary{ 00846 public: 00848 ConstantString(Node *statement) ; 00849 00850 virtual ostream& php(ostream &os) const; 00851 00852 virtual Node* copy() const; 00853 00854 virtual string evaluate(const NameSpace &nameSpace) const; 00855 }; 00856 00858 class PHPVariable : public Unary{ 00859 public: 00861 PHPVariable(Node *statement) ; 00862 00863 virtual ostream& php(ostream &os) const; 00864 00865 virtual Node* copy() const; 00866 }; 00867 00868 #endif 00869 00870 00871