typeNode.h
Ir a la documentación de este archivo.
1 //typeNode.h
2 //-------------------------------------------------------------------------------------------
3 /*
4  * Fco. Javier Bohórquez Ogalla
5  * 75766599-E
6  * Puerto Real (Cádiz)
7  * powersgame@gmail.com
8  */
9 //-------------------------------------------------------------------------------------------
10 /*
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24  * MA 02110-1301, USA.
25  */
26 //-------------------------------------------------------------------------------------------
38 #ifndef _RUN_TREE_TYPENODE_
39 #define _RUN_TREE_TYPENODE_
40 
41 //-------------------------------------------------------------------------------------------
42 
43 #include <string>
44 #include <vector>
45 #include <map>
46 #include <iostream>
47 #include <sstream>
48 #include <stdlib.h>
49 #include <sstream>
50 #include <boost/regex.hpp>
51 
52 #include "../table/classNode.h"
53 #include "expNode.h"
54 
55 using namespace std;
56 using namespace boost;
57 
58 //-------------------------------------------------------------------------------------------
59 
66 class boolNode :
67  public logicNode {
68  public:
73  boolNode (bool data);
78  boolNode (boolNode* data);
85  void run ();
86 };
87 
88 //-------------------------------------------------------------------------------------------
89 
97 class boolConstNode : public boolNode {
98  public:
103  boolConstNode (bool data);
107  void rmRef();
108 };
109 
110 //-------------------------------------------------------------------------------------------
111 
119 class numNode :
120  public arithNode {
121  public:
125  numNode (num data);
136  numNode (string data);
141  numNode (numNode* data);
148  void run ();
149 };
150 
151 //-------------------------------------------------------------------------------------------
152 
160 class numConstNode : public numNode {
161  public:
166  numConstNode (num data);
170  void rmRef();
171 };
172 
173 //-------------------------------------------------------------------------------------------
174 
184 class strNode :
185  public stringNode {
186  public:
191  strNode (string data);
196  strNode (strNode* data);
201  strNode (runNode* data);
207  strNode (runNode* data, bool id );
214  void run ();
219  bool is_string () const;
220 };
221 
222 //-------------------------------------------------------------------------------------------
223 
231 class strConstNode : public strNode {
232  public:
237  strConstNode (string data);
241  void rmRef();
242 };
243 
244 //-------------------------------------------------------------------------------------------
245 
252 class nullNode :
253  public dexpNode {
254  public:
258  nullNode ();
265  void run ();
270  string print () const;
271 };
272 
273 //-------------------------------------------------------------------------------------------
274 
294 class listNode :
295  public runNode {
296  public:
302  listNode (runNode* ele1, runNode* ele2 = NULL);
309  void run ();
314  int size ();
319  vector<runNode*> listvalue () const;
325  bool isAsigList ();
331  listNode* quitAsig ();
337  bool is_runlist () const;
338  private:
339  runNode* ele1_, *ele2_;
340  vector<runNode*> list_;
341  bool exec_;
342 };
343 
344 //-------------------------------------------------------------------------------------------
345 
355 class mapNode :
356  public runNode {
357  public:
363  mapNode (runNode* key, runNode* value);
367  void run ();
372  runNode* key () const;
377  runNode* value () const;
378  private:
379  runNode *key_, *value_;
380 };
381 
382 //-------------------------------------------------------------------------------------------
383 
403 class arrayNode :
404  public dexpNode {
405  public:
410  arrayNode (listNode* list);
414  arrayNode ();
419  arrayNode (arrayNode* array);
426  arrayNode (arrayNode* array, refNode* &refSearch);
431  void run ();
436  string print () const;
441  symbols* getArray ();
448  void insert (runNode* key, runNode* val, bool str = false);
455  void del (runNode* key, bool str = false, bool force_position = false );
462  runNode *get (runNode* key, bool str = false);
467  int size () const;
484  bool compare (runNode* node, int op = 0);
489  int getCount () const;
500  void cAll (runNode* node_search, runNode* node_new);
510  bool isref (runNode* node);
514  void clear ();
518  void clearRef ();
523  void setArray (symbols array);
528  void push (runNode* node);
534  virtual runNode * copyArray (arrayNode * a);
539  runNode * getClass ();
543  static void generateClass ();
548  bool boolvalue () const;
553  num numvalue () const;
558  string strvalue () const;
563  ~arrayNode ();
567 #if JSON==1
568  void toJsonSymbols ();
569 #endif
570  protected:
571  string printLevel (short int level) const;
572  void fromList (listNode * l, bool addref = false);
573  static runNode *copy(arrayNode *a, arrayNode *b);
574  static classNode *class_;
575  bool asociative_;
576  symbols array_;
577 };
578 
579 //-------------------------------------------------------------------------------------------
580 
588 class arrayConstNode : public arrayNode {
589  public:
594  arrayConstNode (listNode* list);
599  void run ();
603  void rmRef();
608  inline void isCloned (bool cloned) {cloned_ = cloned;}
609  private:
610  listNode* list_;
611  bool cloned_;
612 };
613 
614 //-------------------------------------------------------------------------------------------
615 
626 class objectNode : public arrayNode {
627  public:
632  objectNode (classNode * c = NULL);
638  objectNode (symbols* s, classNode * c = NULL);
644  objectNode (listNode* l, classNode * c = NULL);
649  objectNode (arrayNode* a);
654  objectNode (objectNode* a);
659  runNode * getClass ();
666  string print () const ;
667  private:
668  classNode * class_;
669 };
670 
671 //-------------------------------------------------------------------------------------------
672 
688  public dexpNode {
689  public:
695  regexpNode (string str);
700  regexpNode (regexpNode* r);
705  regex exvalue () const;
712  void run ();
718  string strvalue () const;
724  bool boolvalue () const;
730  num numvalue () const;
736  string print () const;
737  private:
738  string str_;
739  regex ex_;
740 };
741 
742 //-------------------------------------------------------------------------------------------
743 
751 class regexpConstNode : public regexpNode {
752  public:
756  void rmRef();
757 };
758 
759 //-------------------------------------------------------------------------------------------
760 
761 template <typename T>
762 runNode *create(listNode* list) {
763  return new T(list);
764 }
765 
766 #endif
767 //-------------------------------------------------------------------------------------------
768 //Fco. Javier Bohórquez Ogalla
769 
770 
void isCloned(bool cloned)
Definition: typeNode.h:608
Nodo cadena de caracteres.
Definition: typeNode.h:184
Nodo lista de elementos.
Definition: typeNode.h:294
Nodo array constante.
Definition: typeNode.h:588
Nodos lógicos.
Definition: expNode.h:279
Nodo cadena de caracteres constante.
Definition: typeNode.h:231
Nodo boleano constante.
Definition: typeNode.h:97
Nodos aritméticos.
Definition: expNode.h:351
Nodo clase.
Definition: classNode.h:89
Tabla de símbolos.
Definition: symbols.h:65
Nodo numérico.
Definition: typeNode.h:119
Nodo array.
Definition: typeNode.h:403
Nodo numérico constante.
Definition: typeNode.h:160
Nodo ejecutable.
Definition: runTree.h:123
Nodo expresión regular constante.
Definition: typeNode.h:751
Nodo expresión regular.
Definition: typeNode.h:687
Expresiones.
Nodo referencia.
Definition: runTree.h:279
Nodo nulo.
Definition: typeNode.h:252
Nodos cadenas de texto.
Definition: expNode.h:418
Nodo expresión de tipo definido.
Definition: expNode.h:115
Nodo booleano.
Definition: typeNode.h:66
Nodo asociativo.
Definition: typeNode.h:355
Nodo objeto.
Definition: typeNode.h:626