expNode.h
Ir a la documentación de este archivo.
1 //expNode.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 //-------------------------------------------------------------------------------------------
27 
28 //-------------------------------------------------------------------------------------------
37 //-------------------------------------------------------------------------------------------
38 
39 //-------------------------------------------------------------------------------------------
40 #ifndef _RUN_TREE_EXPNODE_
41 #define _RUN_TREE_EXPNODE_
42 //-------------------------------------------------------------------------------------------
43 
44 //-------------------------------------------------------------------------------------------
45 #include <string>
46 #include <vector>
47 #include <map>
48 #include <iostream>
49 #include "runTree.h"
50 
51 using namespace std;
52 //-------------------------------------------------------------------------------------------
53 
54 //-------------------------------------------------------------------------------------------
75 class expNode :
76  public objectTypeNode {
77  public:
83  static runNode * clone (runNode* node);
89  virtual void setNodeValue (runNode* node);
90 };
91 //-------------------------------------------------------------------------------------------
92 
93 //-------------------------------------------------------------------------------------------
115 class dexpNode : public expNode {
116  public:
121  virtual bool boolvalue () const;
126  virtual num numvalue () const;
131  virtual string strvalue () const;
132 };
133 //-------------------------------------------------------------------------------------------
134 
135 //-------------------------------------------------------------------------------------------
164 class nexpNode : public expNode {
165  public:
166  nexpNode ();
171  virtual refNode *ref ();
175  virtual void noderef (runNode* node);
179  virtual runNode* nodeval () const;
183  virtual void setRef (refNode* node);
188  virtual refNode* getRef ();
197  static runNode* resolved (runNode* &node);
206  static runNode* resolvedRef (runNode* &node);
217  static runNode* resolved (runNode* &node, runNode* &ref);
225  static runNode* resolvedAsFunction (runNode* &node);
235  static runNode* resolvedAsFunction (runNode* &node, runNode* &ref);
243  static runNode* resolv (runNode* node);
250  void asig (runNode* &node, bool run = true);
255  void setVal (runNode * node );
261  string print () const;
262  protected:
263  refNode *ref_;
264 };
265 //-------------------------------------------------------------------------------------------
266 
267 //-------------------------------------------------------------------------------------------
268 //logicNode
279 class logicNode :
280  public dexpNode {
281  public:
282  logicNode ();
288  string print () const;
293  bool boolvalue () const;
299  runNode* nodeval () const;
304  static bool to_bool (runNode* node);
309  num numvalue () const;
314  string strvalue () const;
319  runNode * getClass ();
324  virtual void setNodeValue (runNode* node);
329  static void generateClass ();
330  protected:
331  static runNode* class_;
336 };
337 //-------------------------------------------------------------------------------------------
338 
339 //-------------------------------------------------------------------------------------------
351 class arithNode :
352  public dexpNode {
353  public:
359  string print () const;
365  runNode* nodeval () const;
370  num numvalue () const;
375  static num to_num (runNode* node, bool exception = true);
380  bool boolvalue () const;
385  string strvalue () const;
390  runNode * getClass ();
394  static void generateClass ();
399  virtual void setNodeValue (runNode* node);
400  protected:
401  static runNode* class_;
406 };
407 //-------------------------------------------------------------------------------------------
408 
409 //-------------------------------------------------------------------------------------------
418 class stringNode :
419  public dexpNode {
420  public:
421  stringNode ();
426  string print () const;
432  runNode* nodeval () const;
437  string strvalue () const;
442  string* strref ();
450  num numvalue () const;
455  bool is_numvalue () const;
461  static string to_str (runNode* node);
466  runNode * getClass ();
470  static void generateClass ();
475  void setStrValue (string s);
480  void setNodeValue (runNode* node);
485  bool boolvalue () const;
486  protected:
487  static runNode* class_;
491  string strvalue_;
492 };
493 //-------------------------------------------------------------------------------------------
494 
495 //-------------------------------------------------------------------------------------------
503 class fexpNode : public expNode {
504  public:
509  bool is_print () const;
514  bool is_runlist () const;
518  void rmRef ();
519 };
520 //-------------------------------------------------------------------------------------------
521 #endif
522 //-------------------------------------------------------------------------------------------
523 
524 //Fco. javier Bóhorquez Ogalla
525 
526 
string strvalue_
Definition: expNode.h:491
Nodo tipo de objeto.
Definition: runTree.h:379
Nodos lógicos.
Definition: expNode.h:279
Nodos aritméticos.
Definition: expNode.h:351
Árbol de ejecución.
Nodo ejecutable.
Definition: runTree.h:123
Nodo expresiones funciones.
Definition: expNode.h:503
num numvalue_
Definition: expNode.h:405
Nodo referencia.
Definition: runTree.h:279
Nodos cadenas de texto.
Definition: expNode.h:418
bool boolvalue_
Definition: expNode.h:335
Nodo expresión de tipo definido.
Definition: expNode.h:115
Nodo de expresión.
Definition: expNode.h:75
Nodo expresión de tipo no definido.
Definition: expNode.h:164